addio-admin-sdk 1.7.185 → 1.7.186-canary-1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,7 @@
1
+ {
2
+ "permissions": {
3
+ "allow": [
4
+ "Bash(yarn test *)"
5
+ ]
6
+ }
7
+ }
package/.env CHANGED
@@ -2,14 +2,13 @@ NEXT_PUBLIC_FIREBASE_CONFIG_API_KEY_DEV='AIzaSyBNtwzdIe2__HJD23S87RIbWbIqKQVtFiw
2
2
  NEXT_PUBLIC_FIREBASE_CONFIG_API_KEY_PROD='AIzaSyDK6WQZkCrsMGunAPHn9KkdCGPky4hTgL4'
3
3
  NEXT_PUBLIC_MESSAGING_SENDER_ID_DEV='188490998694'
4
4
  NEXT_PUBLIC_MESSAGING_SENDER_ID_PROD='725873016982'
5
- NEXT_PUBLIC_FIREBASE_APP_ID_PROD='1:725873016982:web:9b1f6d77819909e19102b7'
6
5
  NEXT_PUBLIC_FIREBASE_APP_ID_DEV='1:188490998694:web:eecd719e7b18f38d272567'
6
+ NEXT_PUBLIC_FIREBASE_APP_ID_PROD='1:725873016982:web:9b1f6d77819909e19102b7'
7
7
  NEXT_PUBLIC_MEASUREMENT_ID_DEV='G-4BB66ZRTWZ'
8
8
  NEXT_PUBLIC_MEASUREMENT_ID_PROD='G-BB8HHZ466R'
9
-
10
9
  NEXT_PUBLIC_SERVICE_DATABASE_READ_PROVIDER=nobase
11
- NEXT_PUBLIC_SERVICE_DATABASE_WRITE_PROVIDER=nobase
10
+ NEXT_PUBLIC_SERVICE_DATABASE_WRITE_PROVIDER=nobase,firebase
12
11
  NEXT_PUBLIC_SERVICE_DATABASE_URL=https://db-test.addiocommerce.com/
13
- NEXT_PUBLIC_API_URL=https://api-test.addiocommerce.com/v1
14
- NEXT_PUBLIC_SERVICE_DATABASE_TOKEN='337043a374-6f0be-5eb26-05be550631'
15
- LOCAL_FIRESTORE=false
12
+ NEXT_PUBLIC_SERVICE_DATABASE_TOKEN=$SERVICE_DATABASE_TOKEN
13
+ # NEXT_PUBLIC_API_URL=https://api-test.addiocommerce.com/v1
14
+ NEXT_PUBLIC_API_URL=http://localhost:8080
package/changelog.md CHANGED
@@ -1,3 +1,12 @@
1
+ ## [25-06-2026]
2
+
3
+ ### Délai minimum des commandes d'installation (Groupe Richer)
4
+
5
+ - **Added**
6
+ - **Changed**
7
+ - Dans `getMinDateOffset` (`rules/GR/utils/expedition.ts`), nouvelle logique de première plage horaire disponible pour les commandes d'installation : Jeudi et Vendredi → Lundi, les autres jours → +2 jours. L'ancienne logique « Medium staff » (Jeudi → Samedi) est conservée en commentaire daté pour pouvoir y revenir.
8
+ - **Fixed**
9
+
1
10
  ## [03-06-2026]
2
11
 
3
12
  ### Ajustement à la logique qui génère l'item de "type de panier" pour le bon de commande G2
@@ -274,8 +274,9 @@ export default class Cart extends BaseServiceClass<ICart> {
274
274
  * @param escompteItems list of discount products from the dash
275
275
  * @param customPriceList list of products with their custom pric from G2
276
276
  * @param banksUsedForCart Optionnal. Array of banks_used applied to cart
277
+ * @param isCartModification Optionnal. Is it a modification process
277
278
  */
278
- updateWithPromiseToPurchasePrices: (escompteItems: IndexedProduct[], customPriceList?: string | ICustomPriceItem[] | undefined, banksUsedForCart?: IBankUsed[]) => Promise<void>;
279
+ updateWithPromiseToPurchasePrices: (escompteItems: IndexedProduct[], customPriceList?: string | ICustomPriceItem[] | undefined, banksUsedForCart?: IBankUsed[], isCartModification?: boolean) => Promise<void>;
279
280
  /**
280
281
  * Function canBePaidWithMyPromiseToPurchase
281
282
  * @description Check if a cart can be paid with a promise to purchase
@@ -306,9 +307,10 @@ export default class Cart extends BaseServiceClass<ICart> {
306
307
  * @param customPriceList a list of custom price items
307
308
  * @param space the space
308
309
  * @param forcedCartType Optionnal. If provided, overrides cart type found by check cart item types.
310
+ * @param isCartModification Optionnal. Pass true when called from the POS order modification flow so escompte lines are rebuilt even on a paid cart.
309
311
  * @returns the updated cart and a boolean canBePaid determining if the cart can be paid with the promise or not
310
312
  */
311
- canBePaidWithPA: (applicableBanks: IApplicablePromiseBank[], customerID: string, customPriceList: ICustomPriceItem[], space: Space, forcedBankTypeId?: string) => Promise<{
313
+ canBePaidWithPA: (applicableBanks: IApplicablePromiseBank[], customerID: string, customPriceList: ICustomPriceItem[], space: Space, forcedBankTypeId?: string, isCartModification?: boolean) => Promise<{
312
314
  canBePaid: boolean;
313
315
  canBePaidReason?: ApplyBanksToCartErrorsEnum | undefined;
314
316
  updatedCart: ICart;
@@ -60,7 +60,6 @@ const g2_1 = require("../../rules/GR/utils/g2");
60
60
  const cart_1 = require("../../utils/cart");
61
61
  const promiseToPurchase_1 = require("../../utils/promiseToPurchase");
62
62
  const PromiseToPurchase_2 = require("../../Interfaces/PromiseToPurchase");
63
- const products_2 = require("../../rules/GR/utils/products");
64
63
  const baseService_1 = require("../baseService");
65
64
  const DatabaseService_1 = __importDefault(require("../../services/database/DatabaseService"));
66
65
  const logs_1 = require("../../services/logs");
@@ -1906,46 +1905,15 @@ class Cart extends baseService_1.BaseServiceClass {
1906
1905
  const space = await Space_2.default.getCurrentSpaceWithRef(this._collection.path, this._user);
1907
1906
  if (!!!space)
1908
1907
  throw new Error('could not init space obj');
1909
- // If the cart is associated to a promise
1910
- if (!!options.usedPromise) {
1911
- for (const bank of options.usedPromise.banks_used) {
1912
- const promiseQuery = await space.promisesToPurchase.get({
1913
- query: [{ field: 'id', operator: '==', value: bank.promise_id }]
1914
- });
1915
- // If the promise is closed or doesn't exist, we don't adjust it
1916
- if (!!!promiseQuery || !!!promiseQuery.length)
1917
- continue;
1918
- if (!!promiseQuery[0].data().ending_date)
1919
- continue;
1920
- // If the bank is inactive, we don't adjust it
1921
- const bankInDB = promiseQuery[0].data().banks.find((b) => b.bank_type_id === bank.bank_type_id);
1922
- if (!!!bankInDB || !!!bankInDB.active)
1923
- continue;
1924
- let amountTotal = 0;
1925
- const taxes = this.data().total - this.data().subtotal;
1926
- if ((0, promiseToPurchase_1.getBankTypeName)(space.bankTypes.get(), bank.bank_type_id) === 'installation') {
1927
- amountTotal = Number((0, products_2.getInstallItemPrice)('installation-gazon', itemsForInventory.filter((i) => !!i.is_service)));
1928
- }
1929
- else {
1930
- const itemsWithoutInstallation = itemsForInventory.filter((i) => !!!i.parent_slug || !!!['installation-gazon', 'frais-de-mobilisation'].includes(i.parent_slug));
1931
- itemsWithoutInstallation.map((i) => (amountTotal += (0, products_1.getLowestPrice)(i).price.amount * i.qte));
1932
- amountTotal += taxes;
1933
- }
1934
- const adjustment = {
1935
- amount: amountTotal * -1,
1936
- reason: `Modification de la commande #${this.data().ref}`,
1937
- issued_at: new Date(),
1938
- issued_by: !!currentUser ? currentUser : (0, services_1.getDefaultSpaceUserEmail)(space.data().id)
1939
- };
1940
- const remainingAmount = await space.promisesToPurchase.getSpecificAvailableBankAmount(bank.promise_id, bank.bank_type_id, promiseQuery[0]);
1941
- let newRemainingAmount;
1942
- if (!!remainingAmount && !!remainingAmount.remaining_amount) {
1943
- newRemainingAmount = (0, round_1.default)(remainingAmount.remaining_amount, 3) + (0, round_1.default)(adjustment.amount);
1944
- }
1945
- await promiseQuery[0].adjustAmountLeftInPromise(adjustment, bank.bank_type_id, !!newRemainingAmount && newRemainingAmount < 1);
1908
+ await this.save(partial, undefined, shouldSaveToDB, true);
1909
+ if (shouldSaveToDB && !!this._data.promise_to_purchase) {
1910
+ try {
1911
+ await this.checkForEmptyBanksAfterPayment(space);
1912
+ }
1913
+ catch (e) {
1914
+ console.log('error on checking for empty banks after modification: ', e.toString());
1946
1915
  }
1947
1916
  }
1948
- await this.save(partial, undefined, shouldSaveToDB, true);
1949
1917
  // INVENTORY MANAGEMENT
1950
1918
  const data = this.data();
1951
1919
  const storeIdToUse = !!data.current_store_id
@@ -3328,12 +3296,14 @@ class Cart extends baseService_1.BaseServiceClass {
3328
3296
  * @param escompteItems list of discount products from the dash
3329
3297
  * @param customPriceList list of products with their custom pric from G2
3330
3298
  * @param banksUsedForCart Optionnal. Array of banks_used applied to cart
3299
+ * @param isCartModification Optionnal. Is it a modification process
3331
3300
  */
3332
- this.updateWithPromiseToPurchasePrices = async (escompteItems, customPriceList = undefined, banksUsedForCart) => {
3301
+ this.updateWithPromiseToPurchasePrices = async (escompteItems, customPriceList = undefined, banksUsedForCart, isCartModification = false) => {
3333
3302
  var _b, _c, _d, _e;
3334
3303
  if (!!!customPriceList || typeof customPriceList == 'string')
3335
3304
  throw new Error('CustomPriceList is undefined!');
3336
- if (!!this.data().status &&
3305
+ if (!isCartModification &&
3306
+ !!this.data().status &&
3337
3307
  this.data().status >= Cart_1.CartStatusEnum.CHECKOUT_PAYMENT_SUCCESS &&
3338
3308
  !!this.data().paid_at) {
3339
3309
  console.log('cannot update a paid cart with a PA, returning');
@@ -3607,9 +3577,10 @@ class Cart extends baseService_1.BaseServiceClass {
3607
3577
  * @param customPriceList a list of custom price items
3608
3578
  * @param space the space
3609
3579
  * @param forcedCartType Optionnal. If provided, overrides cart type found by check cart item types.
3580
+ * @param isCartModification Optionnal. Pass true when called from the POS order modification flow so escompte lines are rebuilt even on a paid cart.
3610
3581
  * @returns the updated cart and a boolean canBePaid determining if the cart can be paid with the promise or not
3611
3582
  */
3612
- this.canBePaidWithPA = async (applicableBanks, customerID, customPriceList, space, forcedBankTypeId) => {
3583
+ this.canBePaidWithPA = async (applicableBanks, customerID, customPriceList, space, forcedBankTypeId, isCartModification = false) => {
3613
3584
  const contingency = space.promisesToPurchase.getContingency();
3614
3585
  const escomptesItems = await space.promisesToPurchase.getEscompteItems();
3615
3586
  // Get use history for applicable banks
@@ -3640,13 +3611,13 @@ class Cart extends baseService_1.BaseServiceClass {
3640
3611
  bank_type_id: b.bank.bank_type_id,
3641
3612
  amount: 0
3642
3613
  }));
3643
- await this.updateWithPromiseToPurchasePrices(escomptesItems, customPriceList, possibleBanksToUse);
3614
+ await this.updateWithPromiseToPurchasePrices(escomptesItems, customPriceList, possibleBanksToUse, isCartModification);
3644
3615
  const canBePaidCheck = await this.canBePaidWithMyPromiseToPurchase(applicableBanks, filteredApplicableBanksHistory, customPriceList, contingency, forcedBankTypeId);
3645
3616
  // if banks applicable length is different from banks truly applied to cart,
3646
3617
  // adjust added escomptes with banks used for cart
3647
3618
  if (!!this._data.promise_to_purchase &&
3648
3619
  applicableBanks.length !== this._data.promise_to_purchase.banks_used.length) {
3649
- await this.updateWithPromiseToPurchasePrices(escomptesItems, customPriceList, this._data.promise_to_purchase.banks_used);
3620
+ await this.updateWithPromiseToPurchasePrices(escomptesItems, customPriceList, this._data.promise_to_purchase.banks_used, isCartModification);
3650
3621
  }
3651
3622
  const canBePaid = typeof canBePaidCheck === 'boolean';
3652
3623
  return Object.assign(Object.assign({ canBePaid }, (!!!canBePaid ? { canBePaidReason: canBePaidCheck } : {})), { updatedCart: this.data() });