rerobe-js-orm 3.8.0 → 3.8.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.
@@ -598,6 +598,27 @@ class OrderHelpers {
598
598
  }
599
599
  return result;
600
600
  };
601
+ const taxRates = order.lineItems
602
+ .map((lineItem) => {
603
+ var _a;
604
+ if (lineItem.isTaxable) {
605
+ return {
606
+ taxRate: lineItem.taxRate,
607
+ taxAmount: ((_a = lineItem.taxAmountWithDiscount) === null || _a === void 0 ? void 0 : _a.amount) || 0,
608
+ };
609
+ }
610
+ return {};
611
+ })
612
+ .reduce((acc, cur) => {
613
+ if (cur.taxRate) {
614
+ if (!acc[cur.taxRate]) {
615
+ acc[cur.taxRate] = 0;
616
+ }
617
+ acc[cur.taxRate] += Number(cur.taxAmount);
618
+ acc[cur.taxRate] = parseFloat(acc[cur.taxRate].toFixed(2));
619
+ }
620
+ return acc;
621
+ }, {});
601
622
  const buildStoreAddress = () => {
602
623
  let address = this.getFormattedFulfillmentLocation(order);
603
624
  if (!address) {
@@ -620,7 +641,7 @@ class OrderHelpers {
620
641
  currencyCode,
621
642
  amount: (_h = (_g = order.totalTaxPresentment) === null || _g === void 0 ? void 0 : _g.amount) !== null && _h !== void 0 ? _h : '',
622
643
  fractionDigits: 2,
623
- }) }, this.generateReceiptLabels(presentmentLocale, paymentMethod)), this.getPaymentTerminalReceiptInfo(order));
644
+ }), taxRates }, this.generateReceiptLabels(presentmentLocale, paymentMethod)), this.getPaymentTerminalReceiptInfo(order));
624
645
  }
625
646
  }
626
647
  exports.default = OrderHelpers;
@@ -46,7 +46,7 @@ type ReceiptLineItem = {
46
46
  quantity: number;
47
47
  unitPrice: string;
48
48
  };
49
- type ReceiptLabels = {
49
+ interface ReceiptLabels {
50
50
  receiptLabel: string;
51
51
  totalLabel: string;
52
52
  taxLabel: string;
@@ -55,8 +55,9 @@ type ReceiptLabels = {
55
55
  entryMethodLabel: string;
56
56
  authorizationCodeLabel: string;
57
57
  referenceLabel: string;
58
- };
59
- interface ReceiptObj extends PaymentTerminalReceiptInfo {
58
+ }
59
+ type ReceiptLabelsAndPaymentTerminalInfo = ReceiptLabels & PaymentTerminalReceiptInfo;
60
+ interface ReceiptObj extends ReceiptLabelsAndPaymentTerminalInfo {
60
61
  merchantName: string;
61
62
  storeAddress: string;
62
63
  phone: string;
@@ -68,8 +69,9 @@ interface ReceiptObj extends PaymentTerminalReceiptInfo {
68
69
  subTotal: string;
69
70
  amountPaid: string;
70
71
  tax: string;
71
- receiptLabel: string;
72
- totalLabel: string;
72
+ taxRates: {
73
+ [key: number]: number;
74
+ };
73
75
  }
74
76
  type ReRobeOrderObj = {
75
77
  id: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rerobe-js-orm",
3
- "version": "3.8.0",
3
+ "version": "3.8.1",
4
4
  "description": "ReRobe's Javascript ORM Framework",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",