rerobe-js-orm 4.8.3 → 4.8.4

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.
@@ -580,7 +580,7 @@ class OrderHelpers {
580
580
  };
581
581
  }
582
582
  buildReceiptObjFromOrder({ order, merchant, merchantLogoUrl = '', receiptNumber = '', additionalInfo = '', isRefund = false, refundId = null, originalReceiptNumber = null, }) {
583
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
583
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x;
584
584
  const { address: merchantAddress, legalName, name, contactEmail, phone = '', organizationNumber = '', primaryDomain, currency: storeCurrencyCode, returnPolicy, } = merchant;
585
585
  const currencyCode = ((_a = order.totalPricePresentment) === null || _a === void 0 ? void 0 : _a.currencyCode) || storeCurrencyCode;
586
586
  const presentmentLocale = (0, Utilities_1.getPresentmentLocaleByCurrencyCode)(currencyCode);
@@ -689,7 +689,7 @@ class OrderHelpers {
689
689
  const num = Number(amount);
690
690
  return isNaN(num) ? amount : -Math.abs(num);
691
691
  };
692
- return Object.assign(Object.assign({ merchantLogoUrl, merchantName: name, legalName, storeAddress: buildStoreAddress(), phone,
692
+ return Object.assign(Object.assign(Object.assign({ merchantLogoUrl, merchantName: name, legalName, storeAddress: buildStoreAddress(), phone,
693
693
  contactEmail,
694
694
  organizationNumber,
695
695
  primaryDomain, storeUrl: `https://${primaryDomain}`, orderDate: (0, Utilities_1.getFormattedTimestamp)(presentmentLocale, order === null || order === void 0 ? void 0 : order.createdAtTimestamp), receiptNumber, additionalInfo: info, isRefund, originalReceiptNumber: originalReceiptNumber || null, originalReceiptLabel: translations_1.originalReceiptTranslations[presentmentLocale] || translations_1.originalReceiptTranslations['en-US'], lineItems: buildLineItems(), subTotal: (0, Utilities_1.formatPrice)({
@@ -708,7 +708,30 @@ class OrderHelpers {
708
708
  currencyCode,
709
709
  amount: (_q = negateForRefund((_p = (_o = order.totalTaxPresentment) === null || _o === void 0 ? void 0 : _o.amount) !== null && _p !== void 0 ? _p : '')) !== null && _q !== void 0 ? _q : '',
710
710
  fractionDigits: 2,
711
- }), taxRates: formattedTaxRates }, paymentTerminalInfo), receiptLabels);
711
+ }), taxRates: formattedTaxRates }, paymentTerminalInfo), receiptLabels), (Number(((_r = order.totalRefundedPresentment) === null || _r === void 0 ? void 0 : _r.amount) || 0) > 0 && {
712
+ totalRefunded: (0, Utilities_1.formatPrice)({
713
+ currencyCode,
714
+ amount: (_t = (_s = order.totalRefundedPresentment) === null || _s === void 0 ? void 0 : _s.amount) !== null && _t !== void 0 ? _t : '',
715
+ fractionDigits: 2,
716
+ }),
717
+ netPayment: (0, Utilities_1.formatPrice)({
718
+ currencyCode,
719
+ amount: Number((_v = (_u = order.totalPricePresentment) === null || _u === void 0 ? void 0 : _u.amount) !== null && _v !== void 0 ? _v : 0) - Number((_x = (_w = order.totalRefundedPresentment) === null || _w === void 0 ? void 0 : _w.amount) !== null && _x !== void 0 ? _x : 0),
720
+ fractionDigits: 2,
721
+ }),
722
+ refundLineItems: (order.refunds || []).flatMap((refund) => (refund.refundLineItems || []).map((item) => {
723
+ var _a, _b;
724
+ return ({
725
+ title: item.title || '',
726
+ quantity: item.quantity || 1,
727
+ price: (0, Utilities_1.formatPrice)({
728
+ currencyCode,
729
+ amount: -Number(((_a = item.presentmentTotalPrice) === null || _a === void 0 ? void 0 : _a.amount) || ((_b = item.totalPrice) === null || _b === void 0 ? void 0 : _b.amount) || 0),
730
+ fractionDigits: 2,
731
+ }),
732
+ });
733
+ })),
734
+ }));
712
735
  }
713
736
  /**
714
737
  * Generates an idempotency key from a ReRobeOrderObj to prevent duplicate order creation
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rerobe-js-orm",
3
- "version": "4.8.3",
3
+ "version": "4.8.4",
4
4
  "description": "ReRobe's Javascript ORM Framework",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",