addio-admin-sdk 1.6.27 → 1.6.29-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.
package/changelog.md CHANGED
@@ -1,3 +1,12 @@
1
+ ## [28-05-2024]
2
+
3
+ ### Create Pro custom price list - Adjustments for entente prices
4
+
5
+ - **Added**
6
+ - **Changed**
7
+ - Adjusted logic in `getCustomPriceList` since the entente price for a product can be **higher** than the regular price, but should still be the applied price for customer.
8
+ - **Fixed**
9
+
1
10
  ## [27-05-2024]
2
11
 
3
12
  ### GR rules - Calculate shipping fee quantities bug
@@ -179,6 +179,6 @@ export default class Cart extends BaseServiceClass<ICart> {
179
179
  }>;
180
180
  checkForEmptyBanksAfterPayment: (space: Space) => Promise<void>;
181
181
  setCartAsProcessed: (processedAtStore: IStore, space: Space, currentUser?: IUser) => Promise<string | undefined>;
182
- setCartWithInvoiceRef: (space: Space, saveToDatabase?: boolean) => Promise<string | undefined>;
182
+ setCartWithInvoiceRef: (space: Space, saveToDatabase?: boolean, newCartRef?: string) => Promise<string | undefined>;
183
183
  setCartAsRefunded: () => string | undefined;
184
184
  }
@@ -1320,7 +1320,7 @@ var Cart = (function (_super) {
1320
1320
  _this.createOrderWithSuccessfulPaymentPayload = function (_b) {
1321
1321
  var paypal_payload = _b.paypal_payload, stripe_payload = _b.stripe_payload, pandapay_payload = _b.pandapay_payload, paysafe_payload = _b.paysafe_payload, _c = _b.charge_credit, charge_credit = _c === void 0 ? false : _c, _d = _b.other_payment_method, other_payment_method = _d === void 0 ? undefined : _d, _e = _b.multi_payment_methods, multi_payment_methods = _e === void 0 ? undefined : _e, isDev = _b.isDev, _f = _b.saveToDatabase, saveToDatabase = _f === void 0 ? true : _f;
1322
1322
  return __awaiter(_this, void 0, void 0, function () {
1323
- var space, getPaymentRef, newRef, incrementSpaceRef, delay1, partialCartPaidData, delay2, isPOSTransactionnal, delay3, invoiceRef, delay5, error_8, delay6, e_7, error_9;
1323
+ var space, getPaymentRef, newRef, incrementSpaceRef, delay1, partialCartPaidData, isPOSTransactionnal, delay3, invoiceRef, delay2, delay5, error_8, delay6, e_7, error_9;
1324
1324
  var _this = this;
1325
1325
  return __generator(this, function (_g) {
1326
1326
  switch (_g.label) {
@@ -1418,72 +1418,74 @@ var Cart = (function (_super) {
1418
1418
  custom_payment_type: __assign({ method: other_payment_method.method }, (!!other_payment_method.amount ? { amount: other_payment_method.amount } : {}))
1419
1419
  }
1420
1420
  : {})), (!!multi_payment_methods && !!multi_payment_methods.length ? { payment_details: multi_payment_methods } : {})), { paypal_payload: paypal_payload, stripe_payload: stripe_payload, pandapay_payload: pandapay_payload, paysafe_payload: paysafe_payload, paid_at: (0, moment_1.default)().toDate(), status: Cart_1.CartStatusEnum.CHECKOUT_PAYMENT_SUCCESS, payment_reference: getPaymentRef(), ref: isDev ? "".concat((0, toString_1.default)(newRef), "-test") : (0, toString_1.default)(newRef), is_test: isDev, is: this.defineWhatICanBe() });
1421
+ isPOSTransactionnal = this.data().cart_type === Cart_1.CartTypeEnum.POS_TRANSACTIONNAL;
1421
1422
  _g.label = 6;
1422
1423
  case 6:
1423
- _g.trys.push([6, 21, , 23]);
1424
- console.log('---------------');
1425
- delay2 = (0, moment_1.default)();
1426
- return [4, this.save(partialCartPaidData, undefined, saveToDatabase)];
1427
- case 7:
1428
- _g.sent();
1429
- console.log('saving to DB delay: ', (0, moment_1.default)().diff(delay2, 'seconds'));
1430
- isPOSTransactionnal = this.data().cart_type === Cart_1.CartTypeEnum.POS_TRANSACTIONNAL;
1431
- if (!!!isPOSTransactionnal) return [3, 10];
1424
+ _g.trys.push([6, 22, , 24]);
1425
+ if (!!!isPOSTransactionnal) return [3, 9];
1432
1426
  console.log('---------------');
1433
1427
  delay3 = (0, moment_1.default)();
1434
- return [4, this.setCartWithInvoiceRef(space, false)];
1435
- case 8:
1428
+ return [4, this.setCartWithInvoiceRef(space, false, partialCartPaidData.ref)];
1429
+ case 7:
1436
1430
  invoiceRef = _g.sent();
1437
1431
  console.log("saving POS transactionnal cart to database: ".concat(!!saveToDatabase, ", with ref: ").concat(partialCartPaidData.ref, ", status: ").concat(partialCartPaidData.status, " and invoice ref: ").concat(partialCartPaidData.invoice_ref));
1438
- return [4, this.save({ status: Cart_1.CartStatusEnum.COMPLETED, invoice_ref: invoiceRef }, undefined, !!saveToDatabase)];
1439
- case 9:
1432
+ return [4, this.save(__assign(__assign({}, partialCartPaidData), { status: Cart_1.CartStatusEnum.COMPLETED, invoice_ref: invoiceRef }), undefined, saveToDatabase)];
1433
+ case 8:
1440
1434
  _g.sent();
1441
1435
  console.log('setting invoice ref delay: ', (0, moment_1.default)().diff(delay3, 'seconds'));
1442
- _g.label = 10;
1443
- case 10:
1436
+ return [3, 11];
1437
+ case 9:
1444
1438
  console.log('---------------');
1445
- delay5 = (0, moment_1.default)();
1439
+ delay2 = (0, moment_1.default)();
1440
+ return [4, this.save(partialCartPaidData, undefined, saveToDatabase)];
1441
+ case 10:
1442
+ _g.sent();
1443
+ console.log('saving to DB delay: ', (0, moment_1.default)().diff(delay2, 'seconds'));
1446
1444
  _g.label = 11;
1447
1445
  case 11:
1448
- _g.trys.push([11, 13, , 15]);
1449
- return [4, space.inventory.ajust(this.data().items, 'paid', this.data().cart_type, this.data().current_store_id || '')];
1446
+ console.log('---------------');
1447
+ delay5 = (0, moment_1.default)();
1448
+ _g.label = 12;
1450
1449
  case 12:
1451
- _g.sent();
1452
- return [3, 15];
1450
+ _g.trys.push([12, 14, , 16]);
1451
+ return [4, space.inventory.ajust(this.data().items, 'paid', this.data().cart_type, this.data().current_store_id || '')];
1453
1452
  case 13:
1453
+ _g.sent();
1454
+ return [3, 16];
1455
+ case 14:
1454
1456
  error_8 = _g.sent();
1455
1457
  console.log('error while updating inventory', error_8);
1456
1458
  return [4, (0, console_1.alertAdminV2)("Error while updating inventory", "We are here: /src/lib/Cart/index.ts#1574. We are in space ".concat(space.data().id, ". JSON error: ").concat(JSON.stringify(error_8)), error_8.toString(), space.getRef())];
1457
- case 14:
1458
- _g.sent();
1459
- return [3, 15];
1460
1459
  case 15:
1460
+ _g.sent();
1461
+ return [3, 16];
1462
+ case 16:
1461
1463
  console.log('adjusting inventory delay: ', (0, moment_1.default)().diff(delay5, 'seconds'));
1462
- if (!!!this._data.promise_to_purchase) return [3, 20];
1464
+ if (!!!this._data.promise_to_purchase) return [3, 21];
1463
1465
  console.log('---------------');
1464
1466
  delay6 = (0, moment_1.default)();
1465
- _g.label = 16;
1466
- case 16:
1467
- _g.trys.push([16, 18, , 19]);
1468
- return [4, this.checkForEmptyBanksAfterPayment(space)];
1467
+ _g.label = 17;
1469
1468
  case 17:
1470
- _g.sent();
1471
- return [3, 19];
1469
+ _g.trys.push([17, 19, , 20]);
1470
+ return [4, this.checkForEmptyBanksAfterPayment(space)];
1472
1471
  case 18:
1472
+ _g.sent();
1473
+ return [3, 20];
1474
+ case 19:
1473
1475
  e_7 = _g.sent();
1474
1476
  console.log('error on checking for empty banks after payment: ', e_7.toString());
1475
- return [3, 19];
1476
- case 19:
1477
+ return [3, 20];
1478
+ case 20:
1477
1479
  console.log('checkForEmptyBanks delay: ', (0, moment_1.default)().diff(delay6, 'seconds'));
1478
- _g.label = 20;
1479
- case 20: return [3, 23];
1480
- case 21:
1480
+ _g.label = 21;
1481
+ case 21: return [3, 24];
1482
+ case 22:
1481
1483
  error_9 = _g.sent();
1482
1484
  return [4, (0, console_1.alertAdminV2)("Error while saving new cart", "We are here: /src/lib/Cart/index.ts#1352. We are in space ".concat(space.data().id, ". JSON error: ").concat(JSON.stringify(error_9)), error_9.toString(), space.getRef())];
1483
- case 22:
1485
+ case 23:
1484
1486
  _g.sent();
1485
1487
  throw error_9;
1486
- case 23:
1488
+ case 24:
1487
1489
  console.log('====================');
1488
1490
  return [2, this];
1489
1491
  }
@@ -3560,13 +3562,13 @@ var Cart = (function (_super) {
3560
3562
  return [2];
3561
3563
  });
3562
3564
  }); };
3563
- _this.setCartWithInvoiceRef = function (space, saveToDatabase) { return __awaiter(_this, void 0, void 0, function () {
3565
+ _this.setCartWithInvoiceRef = function (space, saveToDatabase, newCartRef) { return __awaiter(_this, void 0, void 0, function () {
3564
3566
  var invoiceRef, newData, e_19;
3565
3567
  return __generator(this, function (_b) {
3566
3568
  switch (_b.label) {
3567
3569
  case 0:
3568
3570
  invoiceRef = undefined;
3569
- newData = __assign({}, this.data());
3571
+ newData = __assign(__assign({}, this.data()), (!!newCartRef && !!!this.data().ref ? { ref: newCartRef } : {}));
3570
3572
  _b.label = 1;
3571
3573
  case 1:
3572
3574
  _b.trys.push([1, 4, , 5]);