rerobe-js-orm 3.8.3 → 3.8.5
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,9 +217,10 @@ 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, merchantLogoUrl, }: {
|
|
220
|
+
buildReceiptObjFromOrder({ order, merchant, merchantLogoUrl, receiptNumber, }: {
|
|
221
221
|
order: ReRobeOrderObj;
|
|
222
222
|
merchant: MerchantObj;
|
|
223
223
|
merchantLogoUrl: string;
|
|
224
|
+
receiptNumber: string;
|
|
224
225
|
}): ReceiptObj;
|
|
225
226
|
}
|
|
@@ -545,36 +545,37 @@ class OrderHelpers {
|
|
|
545
545
|
entryMethodLabel,
|
|
546
546
|
};
|
|
547
547
|
}
|
|
548
|
-
buildReceiptObjFromOrder({ order, merchant, merchantLogoUrl = '', }) {
|
|
549
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
548
|
+
buildReceiptObjFromOrder({ order, merchant, merchantLogoUrl = '', receiptNumber = '', }) {
|
|
549
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
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);
|
|
553
553
|
const mapLineItem = (l) => {
|
|
554
|
-
var _a, _b, _c
|
|
554
|
+
var _a, _b, _c;
|
|
555
555
|
let totalPrice = Number((_a = l.presentmentTotalPrice) === null || _a === void 0 ? void 0 : _a.amount);
|
|
556
556
|
if (l.isTaxable && l.taxRate) {
|
|
557
557
|
const taxRate = Number(l.taxRate);
|
|
558
558
|
totalPrice *= 1 + taxRate;
|
|
559
559
|
}
|
|
560
|
+
let title = l.title || l.brand || '';
|
|
561
|
+
if (Number(l === null || l === void 0 ? void 0 : l.quantity) > 1) {
|
|
562
|
+
title += `\n${Number(l === null || l === void 0 ? void 0 : l.quantity)} x ${(0, Utilities_1.formatPrice)({
|
|
563
|
+
currencyCode,
|
|
564
|
+
amount: (_c = (_b = l === null || l === void 0 ? void 0 : l.originalUnitPrice) === null || _b === void 0 ? void 0 : _b.amount) !== null && _c !== void 0 ? _c : '',
|
|
565
|
+
fractionDigits: 2,
|
|
566
|
+
})}`;
|
|
567
|
+
}
|
|
560
568
|
return {
|
|
561
|
-
title
|
|
569
|
+
title,
|
|
562
570
|
price: (0, Utilities_1.formatPrice)({
|
|
563
571
|
currencyCode,
|
|
564
572
|
amount: totalPrice,
|
|
565
573
|
fractionDigits: 2,
|
|
566
574
|
}),
|
|
567
|
-
quantity: Number((_b = l === null || l === void 0 ? void 0 : l.quantity) !== null && _b !== void 0 ? _b : 0),
|
|
568
|
-
showUnitPrice: Number(l === null || l === void 0 ? void 0 : l.quantity) > 1,
|
|
569
|
-
unitPrice: (0, Utilities_1.formatPrice)({
|
|
570
|
-
currencyCode,
|
|
571
|
-
amount: (_d = (_c = l === null || l === void 0 ? void 0 : l.originalUnitPrice) === null || _c === void 0 ? void 0 : _c.amount) !== null && _d !== void 0 ? _d : '',
|
|
572
|
-
fractionDigits: 2,
|
|
573
|
-
}),
|
|
574
575
|
};
|
|
575
576
|
};
|
|
576
577
|
const buildLineItems = () => {
|
|
577
|
-
var _a, _b, _c
|
|
578
|
+
var _a, _b, _c;
|
|
578
579
|
let result = order.lineItems.map(mapLineItem);
|
|
579
580
|
if (((_a = order.totalDiscountPresentment) === null || _a === void 0 ? void 0 : _a.amount) && Number((_b = order.totalDiscountPresentment) === null || _b === void 0 ? void 0 : _b.amount) > 0) {
|
|
580
581
|
result = [
|
|
@@ -586,13 +587,6 @@ class OrderHelpers {
|
|
|
586
587
|
amount: (_c = order.totalDiscountPresentment) === null || _c === void 0 ? void 0 : _c.amount,
|
|
587
588
|
fractionDigits: 2,
|
|
588
589
|
}),
|
|
589
|
-
showUnitPrice: false,
|
|
590
|
-
quantity: 1,
|
|
591
|
-
unitPrice: (0, Utilities_1.formatPrice)({
|
|
592
|
-
currencyCode,
|
|
593
|
-
amount: (_d = order.totalDiscountPresentment) === null || _d === void 0 ? void 0 : _d.amount,
|
|
594
|
-
fractionDigits: 2,
|
|
595
|
-
}),
|
|
596
590
|
},
|
|
597
591
|
];
|
|
598
592
|
}
|
|
@@ -637,17 +631,21 @@ class OrderHelpers {
|
|
|
637
631
|
const paymentMethod = (_b = order.paymentMethod) !== null && _b !== void 0 ? _b : '';
|
|
638
632
|
return Object.assign(Object.assign({ merchantLogoUrl, merchantName: legalName, storeAddress: buildStoreAddress(), phone,
|
|
639
633
|
contactEmail,
|
|
640
|
-
organizationNumber, primaryDomain: `https://${primaryDomain}`, orderDate: (0, Utilities_1.getFormattedTimestamp)(presentmentLocale), lineItems: buildLineItems(), subTotal: (0, Utilities_1.formatPrice)({
|
|
634
|
+
organizationNumber, primaryDomain: `https://${primaryDomain}`, orderDate: (0, Utilities_1.getFormattedTimestamp)(presentmentLocale), receiptNumber, lineItems: buildLineItems(), subTotal: (0, Utilities_1.formatPrice)({
|
|
641
635
|
currencyCode,
|
|
642
636
|
amount: (_d = (_c = order.subtotalPricePresentment) === null || _c === void 0 ? void 0 : _c.amount) !== null && _d !== void 0 ? _d : '',
|
|
643
637
|
fractionDigits: 2,
|
|
644
|
-
}),
|
|
638
|
+
}), total: (0, Utilities_1.formatPrice)({
|
|
645
639
|
currencyCode,
|
|
646
640
|
amount: (_f = (_e = order.totalPricePresentment) === null || _e === void 0 ? void 0 : _e.amount) !== null && _f !== void 0 ? _f : '',
|
|
647
641
|
fractionDigits: 2,
|
|
642
|
+
}), amountPaid: (0, Utilities_1.formatPrice)({
|
|
643
|
+
currencyCode,
|
|
644
|
+
amount: (_h = (_g = order.totalPricePresentment) === null || _g === void 0 ? void 0 : _g.amount) !== null && _h !== void 0 ? _h : '',
|
|
645
|
+
fractionDigits: 2,
|
|
648
646
|
}), tax: (0, Utilities_1.formatPrice)({
|
|
649
647
|
currencyCode,
|
|
650
|
-
amount: (
|
|
648
|
+
amount: (_k = (_j = order.totalTaxPresentment) === null || _j === void 0 ? void 0 : _j.amount) !== null && _k !== void 0 ? _k : '',
|
|
651
649
|
fractionDigits: 2,
|
|
652
650
|
}), taxRates: formattedTaxRates }, this.generateReceiptLabels(presentmentLocale, paymentMethod)), this.getPaymentTerminalReceiptInfo(order));
|
|
653
651
|
}
|
|
@@ -42,9 +42,6 @@ interface PaymentTerminalReceiptInfo {
|
|
|
42
42
|
type ReceiptLineItem = {
|
|
43
43
|
title: string;
|
|
44
44
|
price: string;
|
|
45
|
-
showUnitPrice: boolean;
|
|
46
|
-
quantity: number;
|
|
47
|
-
unitPrice: string;
|
|
48
45
|
};
|
|
49
46
|
interface ReceiptLabels {
|
|
50
47
|
receiptLabel: string;
|
|
@@ -66,8 +63,10 @@ type ReceiptObj = {
|
|
|
66
63
|
organizationNumber: string;
|
|
67
64
|
primaryDomain: string;
|
|
68
65
|
orderDate: string;
|
|
66
|
+
receiptNumber: string;
|
|
69
67
|
lineItems: ReceiptLineItem[];
|
|
70
68
|
subTotal: string;
|
|
69
|
+
total: string;
|
|
71
70
|
amountPaid: string;
|
|
72
71
|
tax: string;
|
|
73
72
|
taxRates: {
|