rerobe-js-orm 3.8.5 → 3.8.6
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.
|
@@ -216,7 +216,7 @@ export default class OrderHelpers {
|
|
|
216
216
|
};
|
|
217
217
|
getPaymentTerminalReceiptInfo(payload?: any): PaymentTerminalReceiptInfo;
|
|
218
218
|
getFormattedFulfillmentLocation(order: ReRobeOrderObj): string;
|
|
219
|
-
generateReceiptLabels(locale: string, paymentMethod: string,
|
|
219
|
+
generateReceiptLabels(locale: string, paymentMethod: string, entryMode?: string): ReceiptLabels;
|
|
220
220
|
buildReceiptObjFromOrder({ order, merchant, merchantLogoUrl, receiptNumber, }: {
|
|
221
221
|
order: ReRobeOrderObj;
|
|
222
222
|
merchant: MerchantObj;
|
|
@@ -521,7 +521,7 @@ class OrderHelpers {
|
|
|
521
521
|
const location = (_a = fulfillmentLocations[0]) === null || _a === void 0 ? void 0 : _a.location;
|
|
522
522
|
return (0, Utilities_1.convertAddressInputToFormatted)(location);
|
|
523
523
|
}
|
|
524
|
-
generateReceiptLabels(locale, paymentMethod,
|
|
524
|
+
generateReceiptLabels(locale, paymentMethod, entryMode = '') {
|
|
525
525
|
let paymentMethodLabel = translations_1.cardPaymentTranslations[locale] || translations_1.cardPaymentTranslations['en-US'];
|
|
526
526
|
if (paymentMethod === order_constants_1.PAYMENT_TYPES.cash) {
|
|
527
527
|
paymentMethodLabel = translations_1.cashTranslations[locale] || translations_1.cashTranslations['en-US'];
|
|
@@ -529,10 +529,10 @@ class OrderHelpers {
|
|
|
529
529
|
if (paymentMethod === order_constants_1.PAYMENT_TYPES.mobilePayment) {
|
|
530
530
|
paymentMethodLabel = translations_1.mobilePaymentTranslations[locale] || translations_1.mobilePaymentTranslations['en-US'];
|
|
531
531
|
}
|
|
532
|
-
let
|
|
532
|
+
let entryModeLabel = '';
|
|
533
533
|
const contactlessRegex = /contactless|kontaktlos|kontaktløs|kontaktlös|contact-less/i;
|
|
534
|
-
if (contactlessRegex.test(
|
|
535
|
-
|
|
534
|
+
if (contactlessRegex.test(entryMode.toLowerCase())) {
|
|
535
|
+
entryModeLabel = translations_1.contactlessTranslations[locale] || translations_1.contactlessTranslations['en-US'];
|
|
536
536
|
}
|
|
537
537
|
return {
|
|
538
538
|
receiptLabel: translations_1.receiptTranslations[locale] || translations_1.receiptTranslations['en-US'],
|
|
@@ -542,11 +542,11 @@ class OrderHelpers {
|
|
|
542
542
|
authorizationCodeLabel: translations_1.authorizationCodeTranslations[locale] || translations_1.authorizationCodeTranslations['en-US'],
|
|
543
543
|
referenceLabel: translations_1.referenceTranslations[locale] || translations_1.referenceTranslations['en-US'],
|
|
544
544
|
paymentMethodLabel,
|
|
545
|
-
|
|
545
|
+
entryModeLabel,
|
|
546
546
|
};
|
|
547
547
|
}
|
|
548
548
|
buildReceiptObjFromOrder({ order, merchant, merchantLogoUrl = '', receiptNumber = '', }) {
|
|
549
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
549
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
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;
|
|
552
552
|
const presentmentLocale = (0, Utilities_1.getPresentmentLocaleByCurrencyCode)(currencyCode);
|
|
@@ -628,26 +628,28 @@ class OrderHelpers {
|
|
|
628
628
|
}
|
|
629
629
|
return address;
|
|
630
630
|
};
|
|
631
|
-
const
|
|
631
|
+
const paymentTerminalInfo = this.getPaymentTerminalReceiptInfo(order);
|
|
632
|
+
const receiptLabels = this.generateReceiptLabels(presentmentLocale, (_b = order.paymentType) !== null && _b !== void 0 ? _b : '', (_c = paymentTerminalInfo.entryMode) !== null && _c !== void 0 ? _c : '');
|
|
632
633
|
return Object.assign(Object.assign({ merchantLogoUrl, merchantName: legalName, storeAddress: buildStoreAddress(), phone,
|
|
633
634
|
contactEmail,
|
|
634
|
-
organizationNumber,
|
|
635
|
+
organizationNumber,
|
|
636
|
+
primaryDomain, storeUrl: `https://${primaryDomain}`, orderDate: (0, Utilities_1.getFormattedTimestamp)(presentmentLocale), receiptNumber, lineItems: buildLineItems(), subTotal: (0, Utilities_1.formatPrice)({
|
|
635
637
|
currencyCode,
|
|
636
|
-
amount: (
|
|
638
|
+
amount: (_e = (_d = order.subtotalPricePresentment) === null || _d === void 0 ? void 0 : _d.amount) !== null && _e !== void 0 ? _e : '',
|
|
637
639
|
fractionDigits: 2,
|
|
638
640
|
}), total: (0, Utilities_1.formatPrice)({
|
|
639
641
|
currencyCode,
|
|
640
|
-
amount: (
|
|
642
|
+
amount: (_g = (_f = order.totalPricePresentment) === null || _f === void 0 ? void 0 : _f.amount) !== null && _g !== void 0 ? _g : '',
|
|
641
643
|
fractionDigits: 2,
|
|
642
644
|
}), amountPaid: (0, Utilities_1.formatPrice)({
|
|
643
645
|
currencyCode,
|
|
644
|
-
amount: (
|
|
646
|
+
amount: (_j = (_h = order.totalPricePresentment) === null || _h === void 0 ? void 0 : _h.amount) !== null && _j !== void 0 ? _j : '',
|
|
645
647
|
fractionDigits: 2,
|
|
646
648
|
}), tax: (0, Utilities_1.formatPrice)({
|
|
647
649
|
currencyCode,
|
|
648
|
-
amount: (
|
|
650
|
+
amount: (_l = (_k = order.totalTaxPresentment) === null || _k === void 0 ? void 0 : _k.amount) !== null && _l !== void 0 ? _l : '',
|
|
649
651
|
fractionDigits: 2,
|
|
650
|
-
}), taxRates: formattedTaxRates },
|
|
652
|
+
}), taxRates: formattedTaxRates }, paymentTerminalInfo), receiptLabels);
|
|
651
653
|
}
|
|
652
654
|
}
|
|
653
655
|
exports.default = OrderHelpers;
|
|
@@ -49,7 +49,7 @@ interface ReceiptLabels {
|
|
|
49
49
|
taxLabel: string;
|
|
50
50
|
purchaseLabel: string;
|
|
51
51
|
paymentMethodLabel: string;
|
|
52
|
-
|
|
52
|
+
entryModeLabel: string;
|
|
53
53
|
authorizationCodeLabel: string;
|
|
54
54
|
referenceLabel: string;
|
|
55
55
|
}
|
|
@@ -62,6 +62,7 @@ type ReceiptObj = {
|
|
|
62
62
|
contactEmail: string;
|
|
63
63
|
organizationNumber: string;
|
|
64
64
|
primaryDomain: string;
|
|
65
|
+
storeUrl: string;
|
|
65
66
|
orderDate: string;
|
|
66
67
|
receiptNumber: string;
|
|
67
68
|
lineItems: ReceiptLineItem[];
|