rerobe-js-orm 3.8.1 → 3.8.2
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.
|
@@ -217,8 +217,9 @@ export default class OrderHelpers {
|
|
|
217
217
|
getPaymentTerminalReceiptInfo(payload?: any): PaymentTerminalReceiptInfo;
|
|
218
218
|
getFormattedFulfillmentLocation(order: ReRobeOrderObj): string;
|
|
219
219
|
generateReceiptLabels(locale: string, paymentMethod: string, entryMethod?: string): ReceiptLabels;
|
|
220
|
-
buildReceiptObjFromOrder({ order, merchant }: {
|
|
220
|
+
buildReceiptObjFromOrder({ order, merchant, merchantLogoUrl, }: {
|
|
221
221
|
order: ReRobeOrderObj;
|
|
222
222
|
merchant: MerchantObj;
|
|
223
|
+
merchantLogoUrl: string;
|
|
223
224
|
}): ReceiptObj;
|
|
224
225
|
}
|
|
@@ -545,7 +545,7 @@ class OrderHelpers {
|
|
|
545
545
|
entryMethodLabel,
|
|
546
546
|
};
|
|
547
547
|
}
|
|
548
|
-
buildReceiptObjFromOrder({ order, merchant }) {
|
|
548
|
+
buildReceiptObjFromOrder({ order, merchant, merchantLogoUrl = '', }) {
|
|
549
549
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
550
550
|
const { address: merchantAddress, legalName, contactEmail, phone = '', organizationNumber = '', primaryDomain, currency: storeCurrencyCode, } = merchant;
|
|
551
551
|
const currencyCode = ((_a = order.totalPricePresentment) === null || _a === void 0 ? void 0 : _a.currencyCode) || storeCurrencyCode;
|
|
@@ -619,6 +619,14 @@ class OrderHelpers {
|
|
|
619
619
|
}
|
|
620
620
|
return acc;
|
|
621
621
|
}, {});
|
|
622
|
+
const formattedTaxRates = Object.keys(taxRates).reduce((formattedAcc, taxRate) => {
|
|
623
|
+
formattedAcc[taxRate] = (0, Utilities_1.formatPrice)({
|
|
624
|
+
currencyCode,
|
|
625
|
+
amount: taxRates[taxRate],
|
|
626
|
+
fractionDigits: 2,
|
|
627
|
+
});
|
|
628
|
+
return formattedAcc;
|
|
629
|
+
}, {});
|
|
622
630
|
const buildStoreAddress = () => {
|
|
623
631
|
let address = this.getFormattedFulfillmentLocation(order);
|
|
624
632
|
if (!address) {
|
|
@@ -627,7 +635,7 @@ class OrderHelpers {
|
|
|
627
635
|
return address;
|
|
628
636
|
};
|
|
629
637
|
const paymentMethod = (_b = order.paymentMethod) !== null && _b !== void 0 ? _b : '';
|
|
630
|
-
return Object.assign(Object.assign({ merchantName: legalName, storeAddress: buildStoreAddress(), phone,
|
|
638
|
+
return Object.assign(Object.assign({ merchantLogoUrl, merchantName: legalName, storeAddress: buildStoreAddress(), phone,
|
|
631
639
|
contactEmail,
|
|
632
640
|
organizationNumber, primaryDomain: `https://${primaryDomain}`, orderDate: (0, Utilities_1.getFormattedTimestamp)(presentmentLocale), lineItems: buildLineItems(), subTotal: (0, Utilities_1.formatPrice)({
|
|
633
641
|
currencyCode,
|
|
@@ -641,7 +649,7 @@ class OrderHelpers {
|
|
|
641
649
|
currencyCode,
|
|
642
650
|
amount: (_h = (_g = order.totalTaxPresentment) === null || _g === void 0 ? void 0 : _g.amount) !== null && _h !== void 0 ? _h : '',
|
|
643
651
|
fractionDigits: 2,
|
|
644
|
-
}), taxRates }, this.generateReceiptLabels(presentmentLocale, paymentMethod)), this.getPaymentTerminalReceiptInfo(order));
|
|
652
|
+
}), taxRates: formattedTaxRates }, this.generateReceiptLabels(presentmentLocale, paymentMethod)), this.getPaymentTerminalReceiptInfo(order));
|
|
645
653
|
}
|
|
646
654
|
}
|
|
647
655
|
exports.default = OrderHelpers;
|
|
@@ -58,6 +58,7 @@ interface ReceiptLabels {
|
|
|
58
58
|
}
|
|
59
59
|
type ReceiptLabelsAndPaymentTerminalInfo = ReceiptLabels & PaymentTerminalReceiptInfo;
|
|
60
60
|
interface ReceiptObj extends ReceiptLabelsAndPaymentTerminalInfo {
|
|
61
|
+
merchantLogoUrl: string;
|
|
61
62
|
merchantName: string;
|
|
62
63
|
storeAddress: string;
|
|
63
64
|
phone: string;
|
|
@@ -70,7 +71,7 @@ interface ReceiptObj extends ReceiptLabelsAndPaymentTerminalInfo {
|
|
|
70
71
|
amountPaid: string;
|
|
71
72
|
tax: string;
|
|
72
73
|
taxRates: {
|
|
73
|
-
[key:
|
|
74
|
+
[key: string]: string;
|
|
74
75
|
};
|
|
75
76
|
}
|
|
76
77
|
type ReRobeOrderObj = {
|