addio-admin-sdk 1.7.168 → 1.7.170

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
@@ -3350,6 +3350,7 @@ class Cart extends baseService_1.BaseServiceClass {
3350
3350
  * @param banksUsedForCart Optionnal. Array of banks_used applied to cart
3351
3351
  */
3352
3352
  this.updateWithPromiseToPurchasePrices = async (escompteItems, customPriceList = undefined, banksUsedForCart) => {
3353
+ var _b, _c, _d, _e;
3353
3354
  if (!!!customPriceList || typeof customPriceList == 'string')
3354
3355
  throw new Error('CustomPriceList is undefined!');
3355
3356
  if (!!this.data().status &&
@@ -3373,21 +3374,44 @@ class Cart extends baseService_1.BaseServiceClass {
3373
3374
  // for each item in the cart look for an associated discount item
3374
3375
  for (let index = 0; index < updatedPriceProducts.length; index++) {
3375
3376
  const item = updatedPriceProducts[index];
3376
- // if item hasn't got an associated bank,
3377
- // or if associated bank not found in banks used for cart,
3378
- // don't look for an associated discount item
3379
- if (!!!item.promise_to_purchase_association_ids ||
3380
- item.promise_to_purchase_association_ids.length == 0 ||
3381
- (!!banksUsedForCart &&
3382
- banksUsedForCart.every((b) => !!!item.promise_to_purchase_association_ids.includes(b.bank_type_id)))) {
3377
+ // item isn't linked to any bank, so it can't get a PA discount
3378
+ if (!!!item.promise_to_purchase_association_ids || item.promise_to_purchase_association_ids.length == 0) {
3379
+ (0, logs_1.SystemLog)({
3380
+ clientName: 'sdk-admin | Cart | updateWithPromiseToPurchasePrices',
3381
+ clientToken: (_b = process.env.NEXT_PUBLIC_LOG_SYSTEM_KEY) !== null && _b !== void 0 ? _b : ''
3382
+ }, logs_1.LogType.INFO, `[PA-ESCOMPTE-DIAG] cart=${this._data.id} item=${item.sku} : escompte ignoré — aucune banque associée`);
3383
+ continue;
3384
+ }
3385
+ // item is linked to a bank but none of its banks are in banks_used
3386
+ if (!!banksUsedForCart &&
3387
+ banksUsedForCart.every((b) => !!!item.promise_to_purchase_association_ids.includes(b.bank_type_id))) {
3388
+ (0, logs_1.SystemLog)({
3389
+ clientName: 'sdk-admin | Cart | updateWithPromiseToPurchasePrices',
3390
+ clientToken: (_c = process.env.NEXT_PUBLIC_LOG_SYSTEM_KEY) !== null && _c !== void 0 ? _c : ''
3391
+ }, logs_1.LogType.WARNING, `[PA-ESCOMPTE-DIAG] cart=${this._data.id} item=${item.sku} : escompte ignoré — banque associée non utilisée. assoc=${item.promise_to_purchase_association_ids.join(',')} banksUsed=${banksUsedForCart.map((b) => b.bank_type_id).join(',')}`);
3383
3392
  continue;
3384
3393
  }
3385
3394
  const associatedEscompte = (0, g2_1.getItemEscompteSupp)(customPriceList, item);
3386
- if (!!!associatedEscompte)
3395
+ if (!!!associatedEscompte) {
3396
+ // item is eligible (bank linked + used) but no ESC<cat2> entry was found in the price list
3397
+ const diagCode2 = (0, object_1.recursiveCheckObject)(item, 'external_values.catégorie2');
3398
+ (0, logs_1.SystemLog)({
3399
+ clientName: 'sdk-admin | Cart | updateWithPromiseToPurchasePrices',
3400
+ clientToken: (_d = process.env.NEXT_PUBLIC_LOG_SYSTEM_KEY) !== null && _d !== void 0 ? _d : ''
3401
+ }, logs_1.LogType.WARNING, `[PA-ESCOMPTE-DIAG] cart=${this._data.id} item=${item.sku} cat2=${diagCode2} : escompte NON trouvé — recherche=ESC${diagCode2} presentDansListe=${!!customPriceList.find((p) => p.sku === 'ESC' + diagCode2)} tailleListe=${customPriceList.length}`);
3387
3402
  continue;
3403
+ }
3388
3404
  const escompteSuppCartItem = (0, g2_1.buildEscompteSuppCartItem)(escompteItems, customPriceList, associatedEscompte, item);
3389
- if (!!!escompteSuppCartItem)
3405
+ if (!!!escompteSuppCartItem) {
3406
+ // the ESC<cat2> entry exists in the price list but the discount item couldn't be built
3407
+ const escSuppProduct = escompteItems[0];
3408
+ const escDecliPresent = !!escSuppProduct && escSuppProduct.data().declinations.some((d) => d.sku === associatedEscompte.sku);
3409
+ (0, logs_1.SystemLog)({
3410
+ clientName: 'sdk-admin | Cart | updateWithPromiseToPurchasePrices',
3411
+ clientToken: (_e = process.env.NEXT_PUBLIC_LOG_SYSTEM_KEY) !== null && _e !== void 0 ? _e : ''
3412
+ }, logs_1.LogType.WARNING, `[PA-ESCOMPTE-DIAG] cart=${this._data.id} item=${item.sku} : escompte NON construit — escSku=${associatedEscompte.sku} type=${associatedEscompte.type} price=${associatedEscompte.price} declinationEscSuppPaPresente=${escDecliPresent} nbEscompteItems=${escompteItems.length}`);
3390
3413
  continue;
3414
+ }
3391
3415
  associatedEscomptes.push(escompteSuppCartItem);
3392
3416
  }
3393
3417
  this._data = Object.assign(Object.assign({}, this._data), { items: [...updatedPriceProducts, ...associatedEscomptes] });