@pisell/pisellos 2.2.295 → 2.2.296
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.
|
@@ -30,6 +30,8 @@ var LABELS = {
|
|
|
30
30
|
pickUpTime: 'Pick-up time',
|
|
31
31
|
asap: 'ASAP',
|
|
32
32
|
cash: 'Cash',
|
|
33
|
+
cashReceived: 'Cash received',
|
|
34
|
+
changeDue: 'Change due',
|
|
33
35
|
eftpos: 'Eftpos',
|
|
34
36
|
wallet: 'Wallet',
|
|
35
37
|
giftCard: 'Gift card',
|
|
@@ -57,6 +59,8 @@ var LABELS = {
|
|
|
57
59
|
pickUpTime: '取餐时间',
|
|
58
60
|
asap: '尽快',
|
|
59
61
|
cash: '现金支付',
|
|
62
|
+
cashReceived: '收取现金',
|
|
63
|
+
changeDue: '找零',
|
|
60
64
|
eftpos: '刷卡支付',
|
|
61
65
|
wallet: '钱包支付',
|
|
62
66
|
giftCard: '礼品卡',
|
|
@@ -84,6 +88,8 @@ var LABELS = {
|
|
|
84
88
|
pickUpTime: '取餐時間',
|
|
85
89
|
asap: '盡快',
|
|
86
90
|
cash: '現金支付',
|
|
91
|
+
cashReceived: '收取現金',
|
|
92
|
+
changeDue: '找零',
|
|
87
93
|
eftpos: '刷卡支付',
|
|
88
94
|
wallet: '錢包支付',
|
|
89
95
|
giftCard: '禮品卡',
|
|
@@ -98,6 +104,14 @@ var LABELS = {
|
|
|
98
104
|
rounding: '抹零',
|
|
99
105
|
gross: '重量',
|
|
100
106
|
tare: '去皮'
|
|
107
|
+
},
|
|
108
|
+
ja: {
|
|
109
|
+
cashReceived: 'お預かり',
|
|
110
|
+
changeDue: 'お釣り'
|
|
111
|
+
},
|
|
112
|
+
pt: {
|
|
113
|
+
cashReceived: 'Dinheiro recebido',
|
|
114
|
+
changeDue: 'Troco'
|
|
101
115
|
}
|
|
102
116
|
};
|
|
103
117
|
export function buildSmallTicketData(params) {
|
|
@@ -174,7 +188,7 @@ function buildBaseData(params) {
|
|
|
174
188
|
order_number: orderNumber,
|
|
175
189
|
shop_tax_number: stringify(shopInfo.tax_number || order.shop_tax_number),
|
|
176
190
|
shop_phone: stringify(shopInfo.phone || order.shop_phone),
|
|
177
|
-
shop_address: stringify(shopInfo.address || buildShopAddress(shopInfo) || order.shop_address),
|
|
191
|
+
shop_address: stringify(shopInfo.receipt_address || shopInfo.address || buildShopAddress(shopInfo) || order.shop_address),
|
|
178
192
|
original_payment_status: stringify(order.payment_status),
|
|
179
193
|
is_repeat: 0,
|
|
180
194
|
buzzer: stringify(order.buzzer || order.pickup_number || ((_order$metadata = order.metadata) === null || _order$metadata === void 0 ? void 0 : _order$metadata.buzzer)),
|
|
@@ -839,6 +853,11 @@ function buildPaymentItems(params) {
|
|
|
839
853
|
item: paymentMethodName(payment, locale),
|
|
840
854
|
value: formatMoney(resolveReceiptPaymentAmount(payment, serviceFee), currencySymbol)
|
|
841
855
|
}];
|
|
856
|
+
items.push.apply(items, _toConsumableArray(buildCashChangePaymentItems({
|
|
857
|
+
payment: payment,
|
|
858
|
+
locale: locale,
|
|
859
|
+
currencySymbol: currencySymbol
|
|
860
|
+
})));
|
|
842
861
|
if (serviceFee.gt(0)) {
|
|
843
862
|
items.push({
|
|
844
863
|
item: label(locale, 'surchargeIncluded'),
|
|
@@ -882,6 +901,35 @@ function resolveReceiptPaymentAmount(payment, serviceFee) {
|
|
|
882
901
|
var originAmount = new Decimal(toMoneyNumber(payment.origin_amount));
|
|
883
902
|
return amount.eq(originAmount) ? amount.plus(serviceFee) : amount;
|
|
884
903
|
}
|
|
904
|
+
function buildCashChangePaymentItems(params) {
|
|
905
|
+
var payment = params.payment,
|
|
906
|
+
locale = params.locale,
|
|
907
|
+
currencySymbol = params.currencySymbol;
|
|
908
|
+
if (!shouldDisplayCashChange(payment)) return [];
|
|
909
|
+
return [{
|
|
910
|
+
item: label(locale, 'cashReceived'),
|
|
911
|
+
value: formatMoney(payment.metadata.actual_paid_amount, currencySymbol)
|
|
912
|
+
}, {
|
|
913
|
+
item: label(locale, 'changeDue'),
|
|
914
|
+
value: formatMoney(payment.metadata.change_given_amount, currencySymbol)
|
|
915
|
+
}];
|
|
916
|
+
}
|
|
917
|
+
function shouldDisplayCashChange(payment) {
|
|
918
|
+
var _payment$code, _payment$metadata2, _payment$metadata3;
|
|
919
|
+
if (stringify(payment.status).toLowerCase() !== 'paid') return false;
|
|
920
|
+
var paymentMethod = stringify((_payment$code = payment.code) !== null && _payment$code !== void 0 ? _payment$code : payment.payment_method).toUpperCase();
|
|
921
|
+
if (paymentMethod !== 'CASHMANUAL') return false;
|
|
922
|
+
var actualPaidAmount = (_payment$metadata2 = payment.metadata) === null || _payment$metadata2 === void 0 ? void 0 : _payment$metadata2.actual_paid_amount;
|
|
923
|
+
var changeGivenAmount = (_payment$metadata3 = payment.metadata) === null || _payment$metadata3 === void 0 ? void 0 : _payment$metadata3.change_given_amount;
|
|
924
|
+
if (!isNumericAmount(actualPaidAmount) || !isNumericAmount(changeGivenAmount)) return false;
|
|
925
|
+
return new Decimal(changeGivenAmount).toDecimalPlaces(2).gt(0);
|
|
926
|
+
}
|
|
927
|
+
function isNumericAmount(value) {
|
|
928
|
+
if (typeof value === 'number') return Number.isFinite(value);
|
|
929
|
+
if (typeof value !== 'string') return false;
|
|
930
|
+
var normalized = value.trim();
|
|
931
|
+
return normalized !== '' && /^[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i.test(normalized);
|
|
932
|
+
}
|
|
885
933
|
function buildFundRecordPaymentItems(params) {
|
|
886
934
|
var payment = params.payment,
|
|
887
935
|
fundRecord = params.fundRecord,
|
|
@@ -1,46 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
Object.defineProperty(exports, "BUY_X_GET_Y_FREE_STRATEGY", {
|
|
7
|
-
enumerable: true,
|
|
8
|
-
get: function () {
|
|
9
|
-
return _examples.BUY_X_GET_Y_FREE_STRATEGY;
|
|
10
|
-
}
|
|
11
|
-
});
|
|
12
|
-
Object.defineProperty(exports, "ITEM_REWARD_STRATEGY", {
|
|
13
|
-
enumerable: true,
|
|
14
|
-
get: function () {
|
|
15
|
-
return _examples.ITEM_REWARD_STRATEGY;
|
|
16
|
-
}
|
|
17
|
-
});
|
|
18
|
-
Object.defineProperty(exports, "PromotionAdapter", {
|
|
19
|
-
enumerable: true,
|
|
20
|
-
get: function () {
|
|
21
|
-
return _adapter.PromotionAdapter;
|
|
22
|
-
}
|
|
23
|
-
});
|
|
24
|
-
Object.defineProperty(exports, "PromotionEvaluator", {
|
|
25
|
-
enumerable: true,
|
|
26
|
-
get: function () {
|
|
27
|
-
return _evaluator.PromotionEvaluator;
|
|
28
|
-
}
|
|
29
|
-
});
|
|
30
|
-
Object.defineProperty(exports, "X_ITEMS_FOR_Y_PRICE_STRATEGY", {
|
|
31
|
-
enumerable: true,
|
|
32
|
-
get: function () {
|
|
33
|
-
return _examples.X_ITEMS_FOR_Y_PRICE_STRATEGY;
|
|
34
|
-
}
|
|
35
|
-
});
|
|
36
|
-
Object.defineProperty(exports, "default", {
|
|
37
|
-
enumerable: true,
|
|
38
|
-
get: function () {
|
|
39
|
-
return _adapter.default;
|
|
40
|
-
}
|
|
41
|
-
});
|
|
42
|
-
var _evaluator = require("./evaluator");
|
|
43
|
-
var _adapter = _interopRequireWildcard(require("./adapter"));
|
|
44
|
-
var _examples = require("./examples");
|
|
45
|
-
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
46
|
-
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
1
|
+
"use strict";
|
|
@@ -22,6 +22,8 @@ const LABELS = {
|
|
|
22
22
|
pickUpTime: 'Pick-up time',
|
|
23
23
|
asap: 'ASAP',
|
|
24
24
|
cash: 'Cash',
|
|
25
|
+
cashReceived: 'Cash received',
|
|
26
|
+
changeDue: 'Change due',
|
|
25
27
|
eftpos: 'Eftpos',
|
|
26
28
|
wallet: 'Wallet',
|
|
27
29
|
giftCard: 'Gift card',
|
|
@@ -49,6 +51,8 @@ const LABELS = {
|
|
|
49
51
|
pickUpTime: '取餐时间',
|
|
50
52
|
asap: '尽快',
|
|
51
53
|
cash: '现金支付',
|
|
54
|
+
cashReceived: '收取现金',
|
|
55
|
+
changeDue: '找零',
|
|
52
56
|
eftpos: '刷卡支付',
|
|
53
57
|
wallet: '钱包支付',
|
|
54
58
|
giftCard: '礼品卡',
|
|
@@ -76,6 +80,8 @@ const LABELS = {
|
|
|
76
80
|
pickUpTime: '取餐時間',
|
|
77
81
|
asap: '盡快',
|
|
78
82
|
cash: '現金支付',
|
|
83
|
+
cashReceived: '收取現金',
|
|
84
|
+
changeDue: '找零',
|
|
79
85
|
eftpos: '刷卡支付',
|
|
80
86
|
wallet: '錢包支付',
|
|
81
87
|
giftCard: '禮品卡',
|
|
@@ -90,6 +96,14 @@ const LABELS = {
|
|
|
90
96
|
rounding: '抹零',
|
|
91
97
|
gross: '重量',
|
|
92
98
|
tare: '去皮'
|
|
99
|
+
},
|
|
100
|
+
ja: {
|
|
101
|
+
cashReceived: 'お預かり',
|
|
102
|
+
changeDue: 'お釣り'
|
|
103
|
+
},
|
|
104
|
+
pt: {
|
|
105
|
+
cashReceived: 'Dinheiro recebido',
|
|
106
|
+
changeDue: 'Troco'
|
|
93
107
|
}
|
|
94
108
|
};
|
|
95
109
|
function buildSmallTicketData(params) {
|
|
@@ -169,7 +183,7 @@ function buildBaseData(params) {
|
|
|
169
183
|
order_number: orderNumber,
|
|
170
184
|
shop_tax_number: stringify(shopInfo.tax_number || order.shop_tax_number),
|
|
171
185
|
shop_phone: stringify(shopInfo.phone || order.shop_phone),
|
|
172
|
-
shop_address: stringify(shopInfo.address || buildShopAddress(shopInfo) || order.shop_address),
|
|
186
|
+
shop_address: stringify(shopInfo.receipt_address || shopInfo.address || buildShopAddress(shopInfo) || order.shop_address),
|
|
173
187
|
original_payment_status: stringify(order.payment_status),
|
|
174
188
|
is_repeat: 0,
|
|
175
189
|
buzzer: stringify(order.buzzer || order.pickup_number || order.metadata?.buzzer),
|
|
@@ -807,6 +821,11 @@ function buildPaymentItems(params) {
|
|
|
807
821
|
item: paymentMethodName(payment, locale),
|
|
808
822
|
value: formatMoney(resolveReceiptPaymentAmount(payment, serviceFee), currencySymbol)
|
|
809
823
|
}];
|
|
824
|
+
items.push(...buildCashChangePaymentItems({
|
|
825
|
+
payment,
|
|
826
|
+
locale,
|
|
827
|
+
currencySymbol
|
|
828
|
+
}));
|
|
810
829
|
if (serviceFee.gt(0)) {
|
|
811
830
|
items.push({
|
|
812
831
|
item: label(locale, 'surchargeIncluded'),
|
|
@@ -848,6 +867,36 @@ function resolveReceiptPaymentAmount(payment, serviceFee) {
|
|
|
848
867
|
const originAmount = new _decimal.default(toMoneyNumber(payment.origin_amount));
|
|
849
868
|
return amount.eq(originAmount) ? amount.plus(serviceFee) : amount;
|
|
850
869
|
}
|
|
870
|
+
function buildCashChangePaymentItems(params) {
|
|
871
|
+
const {
|
|
872
|
+
payment,
|
|
873
|
+
locale,
|
|
874
|
+
currencySymbol
|
|
875
|
+
} = params;
|
|
876
|
+
if (!shouldDisplayCashChange(payment)) return [];
|
|
877
|
+
return [{
|
|
878
|
+
item: label(locale, 'cashReceived'),
|
|
879
|
+
value: formatMoney(payment.metadata.actual_paid_amount, currencySymbol)
|
|
880
|
+
}, {
|
|
881
|
+
item: label(locale, 'changeDue'),
|
|
882
|
+
value: formatMoney(payment.metadata.change_given_amount, currencySymbol)
|
|
883
|
+
}];
|
|
884
|
+
}
|
|
885
|
+
function shouldDisplayCashChange(payment) {
|
|
886
|
+
if (stringify(payment.status).toLowerCase() !== 'paid') return false;
|
|
887
|
+
const paymentMethod = stringify(payment.code ?? payment.payment_method).toUpperCase();
|
|
888
|
+
if (paymentMethod !== 'CASHMANUAL') return false;
|
|
889
|
+
const actualPaidAmount = payment.metadata?.actual_paid_amount;
|
|
890
|
+
const changeGivenAmount = payment.metadata?.change_given_amount;
|
|
891
|
+
if (!isNumericAmount(actualPaidAmount) || !isNumericAmount(changeGivenAmount)) return false;
|
|
892
|
+
return new _decimal.default(changeGivenAmount).toDecimalPlaces(2).gt(0);
|
|
893
|
+
}
|
|
894
|
+
function isNumericAmount(value) {
|
|
895
|
+
if (typeof value === 'number') return Number.isFinite(value);
|
|
896
|
+
if (typeof value !== 'string') return false;
|
|
897
|
+
const normalized = value.trim();
|
|
898
|
+
return normalized !== '' && /^[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i.test(normalized);
|
|
899
|
+
}
|
|
851
900
|
function buildFundRecordPaymentItems(params) {
|
|
852
901
|
const {
|
|
853
902
|
payment,
|