@pisell/pisellos 2.2.291 → 2.2.293
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.
- package/dist/core/index.d.ts +7 -0
- package/dist/core/index.js +108 -65
- package/dist/model/strategy/adapter/itemRule/adapter.d.ts +4 -1
- package/dist/model/strategy/adapter/itemRule/adapter.js +135 -35
- package/dist/model/strategy/adapter/itemRule/evaluator.d.ts +8 -1
- package/dist/model/strategy/adapter/itemRule/evaluator.js +25 -1
- package/dist/model/strategy/adapter/itemRule/type.d.ts +44 -0
- package/dist/model/strategy/adapter/itemRule/type.js +19 -1
- package/dist/model/strategy/adapter/promotion/index.js +0 -9
- package/dist/modules/BookingContext/index.d.ts +3 -0
- package/dist/modules/BookingContext/index.js +42 -13
- package/dist/modules/BookingContext/types.d.ts +4 -4
- package/dist/modules/BookingContext/types.js +3 -3
- package/dist/modules/OpenData/types.d.ts +1 -0
- package/dist/modules/Order/index.d.ts +18 -3
- package/dist/modules/Order/index.js +885 -485
- package/dist/modules/Order/salesNotes.d.ts +31 -0
- package/dist/modules/Order/salesNotes.js +492 -0
- package/dist/modules/Order/types.d.ts +93 -5
- package/dist/modules/Order/types.js +5 -0
- package/dist/modules/Order/utils.d.ts +12 -0
- package/dist/modules/Order/utils.js +96 -31
- package/dist/modules/Product/types.d.ts +2 -0
- package/dist/modules/ProductList/clientDataVariants.d.ts +50 -0
- package/dist/modules/ProductList/clientDataVariants.js +216 -0
- package/dist/modules/ProductList/index.d.ts +18 -3
- package/dist/modules/ProductList/index.js +220 -38
- package/dist/modules/ProductList/types.d.ts +10 -0
- package/dist/modules/Quotation/index.d.ts +22 -0
- package/dist/modules/Quotation/index.js +293 -28
- package/dist/modules/ResourcePlanner/index.d.ts +0 -22
- package/dist/modules/ResourcePlanner/index.js +1 -180
- package/dist/modules/ResourcePlanner/localClock.d.ts +33 -0
- package/dist/modules/ResourcePlanner/localClock.js +183 -0
- package/dist/modules/ResourcePlanner/planner.d.ts +5 -14
- package/dist/modules/ResourcePlanner/planner.js +2111 -958
- package/dist/modules/ResourcePlanner/types.d.ts +359 -187
- package/dist/modules/ResourcePlanner/types.js +33 -1
- package/dist/plugins/request.d.ts +1 -0
- package/dist/server/index.d.ts +17 -2
- package/dist/server/index.js +1134 -932
- package/dist/server/modules/floor-plan/index.d.ts +4 -0
- package/dist/server/modules/floor-plan/index.js +240 -98
- package/dist/server/modules/menu/index.js +48 -23
- package/dist/server/modules/order/index.d.ts +17 -7
- package/dist/server/modules/order/index.js +419 -207
- package/dist/server/modules/products/index.d.ts +10 -4
- package/dist/server/modules/products/index.js +177 -84
- package/dist/server/modules/resource/index.js +21 -13
- package/dist/server/utils/product.d.ts +1 -1
- package/dist/server/utils/product.js +186 -22
- package/dist/server/utils/small-ticket.d.ts +9 -1
- package/dist/server/utils/small-ticket.js +131 -84
- package/dist/solution/BaseSales/index.d.ts +26 -3
- package/dist/solution/BaseSales/index.js +1384 -905
- package/dist/solution/BaseSales/types.d.ts +2 -0
- package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.d.ts +3 -0
- package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +10 -3
- package/dist/solution/BaseSales/utils.js +6 -3
- package/dist/solution/BookingByStep/index.d.ts +4 -4
- package/dist/solution/BookingTicket/index.d.ts +1 -1
- package/dist/solution/BookingTicket/index.js +4 -2
- package/dist/solution/BookingTicket/utils/addProductDecision.d.ts +2 -1
- package/dist/solution/BookingTicket/utils/addProductDecision.js +6 -3
- package/dist/solution/BookingTicket/utils/orderCustomer.js +3 -2
- package/dist/solution/RegisterAndLogin/config.d.ts +9 -3
- package/dist/solution/RegisterAndLogin/config.js +95 -40
- package/dist/solution/RegisterAndLogin/index.js +4 -1
- package/dist/solution/ScanOrder/index.d.ts +1 -0
- package/dist/solution/ScanOrder/index.js +31 -27
- package/dist/solution/ScanOrder/types.d.ts +2 -0
- package/dist/solution/ScanOrder/utils.d.ts +1 -0
- package/dist/solution/ScanOrder/utils.js +8 -3
- package/dist/solution/UnifiedBookingSales/index.d.ts +128 -74
- package/dist/solution/UnifiedBookingSales/index.js +3877 -963
- package/dist/solution/UnifiedBookingSales/remoteOccupancyCache.d.ts +49 -0
- package/dist/solution/UnifiedBookingSales/remoteOccupancyCache.js +430 -0
- package/dist/solution/UnifiedBookingSales/types.d.ts +161 -77
- package/dist/solution/UnifiedBookingSales/types.js +4 -9
- package/dist/solution/VenueBooking/index.d.ts +3 -0
- package/dist/solution/VenueBooking/index.js +549 -497
- package/dist/solution/VenueBooking/utils/dateSummary.d.ts +1 -0
- package/dist/solution/VenueBooking/utils/dateSummary.js +3 -1
- package/dist/solution/VenueBooking/utils/slotMerge.d.ts +2 -0
- package/dist/solution/VenueBooking/utils/slotMerge.js +3 -1
- package/dist/utils/platform.d.ts +8 -0
- package/dist/utils/platform.js +15 -0
- package/lib/core/index.d.ts +7 -0
- package/lib/core/index.js +20 -2
- package/lib/model/strategy/adapter/itemRule/adapter.d.ts +4 -1
- package/lib/model/strategy/adapter/itemRule/adapter.js +73 -4
- package/lib/model/strategy/adapter/itemRule/evaluator.d.ts +8 -1
- package/lib/model/strategy/adapter/itemRule/evaluator.js +23 -1
- package/lib/model/strategy/adapter/itemRule/type.d.ts +44 -0
- package/lib/model/strategy/adapter/itemRule/type.js +19 -1
- package/lib/modules/BookingContext/index.d.ts +3 -0
- package/lib/modules/BookingContext/index.js +35 -8
- package/lib/modules/BookingContext/types.d.ts +4 -4
- package/lib/modules/BookingContext/types.js +3 -3
- package/lib/modules/OpenData/types.d.ts +1 -0
- package/lib/modules/Order/index.d.ts +18 -3
- package/lib/modules/Order/index.js +325 -28
- package/lib/modules/Order/salesNotes.d.ts +31 -0
- package/lib/modules/Order/salesNotes.js +382 -0
- package/lib/modules/Order/types.d.ts +93 -5
- package/lib/modules/Order/types.js +4 -0
- package/lib/modules/Order/utils.d.ts +12 -0
- package/lib/modules/Order/utils.js +85 -16
- package/lib/modules/Product/types.d.ts +2 -0
- package/lib/modules/ProductList/clientDataVariants.d.ts +50 -0
- package/lib/modules/ProductList/clientDataVariants.js +204 -0
- package/lib/modules/ProductList/index.d.ts +18 -3
- package/lib/modules/ProductList/index.js +137 -8
- package/lib/modules/ProductList/types.d.ts +10 -0
- package/lib/modules/Quotation/index.d.ts +22 -0
- package/lib/modules/Quotation/index.js +158 -11
- package/lib/modules/ResourcePlanner/index.d.ts +0 -22
- package/lib/modules/ResourcePlanner/index.js +9 -129
- package/lib/modules/ResourcePlanner/localClock.d.ts +33 -0
- package/lib/modules/ResourcePlanner/localClock.js +205 -0
- package/lib/modules/ResourcePlanner/planner.d.ts +5 -14
- package/lib/modules/ResourcePlanner/planner.js +1807 -783
- package/lib/modules/ResourcePlanner/types.d.ts +359 -187
- package/lib/modules/ResourcePlanner/types.js +13 -1
- package/lib/plugins/request.d.ts +1 -0
- package/lib/server/index.d.ts +17 -2
- package/lib/server/index.js +149 -21
- package/lib/server/modules/floor-plan/index.d.ts +4 -0
- package/lib/server/modules/floor-plan/index.js +60 -7
- package/lib/server/modules/menu/index.js +26 -4
- package/lib/server/modules/order/index.d.ts +17 -7
- package/lib/server/modules/order/index.js +194 -57
- package/lib/server/modules/products/index.d.ts +10 -4
- package/lib/server/modules/products/index.js +93 -23
- package/lib/server/modules/resource/index.js +12 -2
- package/lib/server/utils/product.d.ts +1 -1
- package/lib/server/utils/product.js +163 -3
- package/lib/server/utils/small-ticket.d.ts +9 -1
- package/lib/server/utils/small-ticket.js +123 -79
- package/lib/solution/BaseSales/index.d.ts +26 -3
- package/lib/solution/BaseSales/index.js +396 -70
- package/lib/solution/BaseSales/types.d.ts +2 -0
- package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.d.ts +3 -0
- package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +9 -2
- package/lib/solution/BaseSales/utils.js +3 -0
- package/lib/solution/BookingByStep/index.d.ts +4 -4
- package/lib/solution/BookingTicket/index.d.ts +1 -1
- package/lib/solution/BookingTicket/index.js +2 -1
- package/lib/solution/BookingTicket/utils/addProductDecision.d.ts +2 -1
- package/lib/solution/BookingTicket/utils/addProductDecision.js +5 -2
- package/lib/solution/BookingTicket/utils/orderCustomer.js +2 -1
- package/lib/solution/RegisterAndLogin/config.d.ts +9 -3
- package/lib/solution/RegisterAndLogin/config.js +49 -8
- package/lib/solution/RegisterAndLogin/index.js +4 -1
- package/lib/solution/ScanOrder/index.d.ts +1 -0
- package/lib/solution/ScanOrder/index.js +5 -1
- package/lib/solution/ScanOrder/types.d.ts +2 -0
- package/lib/solution/ScanOrder/utils.d.ts +1 -0
- package/lib/solution/ScanOrder/utils.js +4 -0
- package/lib/solution/UnifiedBookingSales/index.d.ts +128 -74
- package/lib/solution/UnifiedBookingSales/index.js +2592 -424
- package/lib/solution/UnifiedBookingSales/remoteOccupancyCache.d.ts +49 -0
- package/lib/solution/UnifiedBookingSales/remoteOccupancyCache.js +316 -0
- package/lib/solution/UnifiedBookingSales/types.d.ts +161 -77
- package/lib/solution/UnifiedBookingSales/types.js +4 -6
- package/lib/solution/VenueBooking/index.d.ts +3 -0
- package/lib/solution/VenueBooking/index.js +33 -9
- package/lib/solution/VenueBooking/utils/dateSummary.d.ts +1 -0
- package/lib/solution/VenueBooking/utils/dateSummary.js +3 -1
- package/lib/solution/VenueBooking/utils/slotMerge.d.ts +2 -0
- package/lib/solution/VenueBooking/utils/slotMerge.js +3 -1
- package/lib/utils/platform.d.ts +8 -0
- package/lib/utils/platform.js +22 -0
- package/package.json +1 -1
|
@@ -22,8 +22,6 @@ const LABELS = {
|
|
|
22
22
|
pickUpTime: 'Pick-up time',
|
|
23
23
|
asap: 'ASAP',
|
|
24
24
|
cash: 'Cash',
|
|
25
|
-
cashReceived: 'Cash received',
|
|
26
|
-
changeDue: 'Change due',
|
|
27
25
|
eftpos: 'Eftpos',
|
|
28
26
|
wallet: 'Wallet',
|
|
29
27
|
giftCard: 'Gift card',
|
|
@@ -34,6 +32,7 @@ const LABELS = {
|
|
|
34
32
|
orderDiscount: 'Order discount',
|
|
35
33
|
manualDiscount: 'Manual discount',
|
|
36
34
|
payProcessingFee: 'Pay processing fee',
|
|
35
|
+
surchargeIncluded: 'Surcharge(Included)',
|
|
37
36
|
rounding: 'Rounding',
|
|
38
37
|
gross: 'Gross',
|
|
39
38
|
tare: 'Tare'
|
|
@@ -50,8 +49,6 @@ const LABELS = {
|
|
|
50
49
|
pickUpTime: '取餐时间',
|
|
51
50
|
asap: '尽快',
|
|
52
51
|
cash: '现金支付',
|
|
53
|
-
cashReceived: '收取现金',
|
|
54
|
-
changeDue: '找零',
|
|
55
52
|
eftpos: '刷卡支付',
|
|
56
53
|
wallet: '钱包支付',
|
|
57
54
|
giftCard: '礼品卡',
|
|
@@ -62,6 +59,7 @@ const LABELS = {
|
|
|
62
59
|
orderDiscount: '整单折扣',
|
|
63
60
|
manualDiscount: '手动折扣',
|
|
64
61
|
payProcessingFee: '支付手续费',
|
|
62
|
+
surchargeIncluded: '手续费(已含)',
|
|
65
63
|
rounding: '抹零',
|
|
66
64
|
gross: '重量',
|
|
67
65
|
tare: '去皮'
|
|
@@ -78,8 +76,6 @@ const LABELS = {
|
|
|
78
76
|
pickUpTime: '取餐時間',
|
|
79
77
|
asap: '盡快',
|
|
80
78
|
cash: '現金支付',
|
|
81
|
-
cashReceived: '收取現金',
|
|
82
|
-
changeDue: '找零',
|
|
83
79
|
eftpos: '刷卡支付',
|
|
84
80
|
wallet: '錢包支付',
|
|
85
81
|
giftCard: '禮品卡',
|
|
@@ -90,17 +86,10 @@ const LABELS = {
|
|
|
90
86
|
orderDiscount: '整單折扣',
|
|
91
87
|
manualDiscount: '手動折扣',
|
|
92
88
|
payProcessingFee: '支付手續費',
|
|
89
|
+
surchargeIncluded: '手續費(已含)',
|
|
93
90
|
rounding: '抹零',
|
|
94
91
|
gross: '重量',
|
|
95
92
|
tare: '去皮'
|
|
96
|
-
},
|
|
97
|
-
ja: {
|
|
98
|
-
cashReceived: 'お預かり',
|
|
99
|
-
changeDue: 'お釣り'
|
|
100
|
-
},
|
|
101
|
-
pt: {
|
|
102
|
-
cashReceived: 'Dinheiro recebido',
|
|
103
|
-
changeDue: 'Troco'
|
|
104
93
|
}
|
|
105
94
|
};
|
|
106
95
|
function buildSmallTicketData(params) {
|
|
@@ -155,6 +144,11 @@ function buildLocaleData(params) {
|
|
|
155
144
|
locale,
|
|
156
145
|
currencySymbol
|
|
157
146
|
}),
|
|
147
|
+
wallets: buildWallets({
|
|
148
|
+
order,
|
|
149
|
+
locale,
|
|
150
|
+
currencySymbol
|
|
151
|
+
}),
|
|
158
152
|
tickets: Array.isArray(order.tickets) ? order.tickets : [],
|
|
159
153
|
source_shop: [],
|
|
160
154
|
refund_data: [],
|
|
@@ -175,12 +169,15 @@ function buildBaseData(params) {
|
|
|
175
169
|
order_number: orderNumber,
|
|
176
170
|
shop_tax_number: stringify(shopInfo.tax_number || order.shop_tax_number),
|
|
177
171
|
shop_phone: stringify(shopInfo.phone || order.shop_phone),
|
|
178
|
-
shop_address: stringify(shopInfo.
|
|
172
|
+
shop_address: stringify(shopInfo.address || buildShopAddress(shopInfo) || order.shop_address),
|
|
179
173
|
original_payment_status: stringify(order.payment_status),
|
|
180
174
|
is_repeat: 0,
|
|
181
175
|
buzzer: stringify(order.buzzer || order.pickup_number || order.metadata?.buzzer),
|
|
182
176
|
order_no: orderNumber,
|
|
183
|
-
order_time: formatDateTime(order.created_at || order.sales_time || new Date(), locale)
|
|
177
|
+
order_time: formatDateTime(order.created_at || order.sales_time || new Date(), locale),
|
|
178
|
+
...(isPresentId(order.updated_at) ? {
|
|
179
|
+
updated_at: formatDateTime(order.updated_at, locale)
|
|
180
|
+
} : {})
|
|
184
181
|
};
|
|
185
182
|
}
|
|
186
183
|
function buildProducts(order, locale, productMap) {
|
|
@@ -214,6 +211,8 @@ function buildProducts(order, locale, productMap) {
|
|
|
214
211
|
parentProduct,
|
|
215
212
|
locale
|
|
216
213
|
});
|
|
214
|
+
const productUid = firstPresentValue(product.metadata?.unique_identification_number, product.unique_identification_number);
|
|
215
|
+
const bookingUid = firstPresentValue(product.booking_uid, product.metadata?.booking_uid);
|
|
217
216
|
const extensionList = buildProductExtensionList({
|
|
218
217
|
product,
|
|
219
218
|
locale,
|
|
@@ -228,6 +227,12 @@ function buildProducts(order, locale, productMap) {
|
|
|
228
227
|
original_price: formatMoney(originalPrice, currencySymbol),
|
|
229
228
|
total_original_price: formatMoney(new _decimal.default(toMoneyNumber(originalPrice)).mul(quantity), currencySymbol),
|
|
230
229
|
extension_list: extensionList,
|
|
230
|
+
...(isPresentId(productUid) ? {
|
|
231
|
+
product_uid: productUid
|
|
232
|
+
} : {}),
|
|
233
|
+
...(isPresentId(bookingUid) ? {
|
|
234
|
+
booking_uid: bookingUid
|
|
235
|
+
} : {}),
|
|
231
236
|
...(options.length ? {
|
|
232
237
|
options
|
|
233
238
|
} : {}),
|
|
@@ -593,6 +598,9 @@ function isNonZeroId(value) {
|
|
|
593
598
|
function isPresentId(value) {
|
|
594
599
|
return value !== undefined && value !== null && value !== '';
|
|
595
600
|
}
|
|
601
|
+
function firstPresentValue(...values) {
|
|
602
|
+
return values.find(value => isPresentId(value));
|
|
603
|
+
}
|
|
596
604
|
function isSameId(left, right) {
|
|
597
605
|
if (!isPresentId(left) || !isPresentId(right)) return false;
|
|
598
606
|
return String(left) === String(right);
|
|
@@ -661,12 +669,13 @@ function buildFees(params) {
|
|
|
661
669
|
});
|
|
662
670
|
}
|
|
663
671
|
const productExpectAmount = summary.product_expect_amount || summary.product_amount || order.product_expect_amount;
|
|
664
|
-
const productOriginalAmount = summary.product_original_amount
|
|
672
|
+
const productOriginalAmount = firstPresentValue(summary.product_original_amount, order.product_original_amount) ?? calculateProductOriginalAmount(order);
|
|
665
673
|
const totalSavingsAmount = new _decimal.default(toMoneyNumber(productOriginalAmount)).minus(toMoneyNumber(productExpectAmount)).plus(toMoneyNumber(discountAmount));
|
|
666
674
|
return {
|
|
667
675
|
fees,
|
|
668
676
|
countFee: {
|
|
669
677
|
total_amount: formatMoney(summary.total_amount || order.total_amount, currencySymbol),
|
|
678
|
+
original_item_amount: formatMoney(productOriginalAmount, currencySymbol),
|
|
670
679
|
product_expect_amount: formatMoney(productExpectAmount, currencySymbol),
|
|
671
680
|
expect_amount: formatMoney(summary.expect_amount || order.expect_amount || summary.total_amount || order.total_amount, currencySymbol),
|
|
672
681
|
product_quantity: toNumber(summary.product_quantity || products.reduce((sum, product) => sum + product.product_quantity, 0), 0),
|
|
@@ -689,6 +698,13 @@ function buildFees(params) {
|
|
|
689
698
|
}
|
|
690
699
|
};
|
|
691
700
|
}
|
|
701
|
+
function calculateProductOriginalAmount(order) {
|
|
702
|
+
return normalizeArray(order.products).reduce((total, product) => {
|
|
703
|
+
const quantity = toNumber(product.product_quantity ?? product.quantity ?? product.num ?? 1, 1);
|
|
704
|
+
const originalPrice = product.original_price ?? product.selling_price ?? product.payment_price ?? product.price ?? 0;
|
|
705
|
+
return total.plus(new _decimal.default(toMoneyNumber(originalPrice)).mul(quantity));
|
|
706
|
+
}, new _decimal.default(0));
|
|
707
|
+
}
|
|
692
708
|
function buildCustomer(order, locale) {
|
|
693
709
|
return [{
|
|
694
710
|
item: label(locale, 'contactName'),
|
|
@@ -726,6 +742,27 @@ function buildDelivery(order, locale) {
|
|
|
726
742
|
return items;
|
|
727
743
|
}
|
|
728
744
|
function buildAppointment(order, locale) {
|
|
745
|
+
const bookings = normalizeArray(order.bookings);
|
|
746
|
+
if (bookings.length) {
|
|
747
|
+
return bookings.map(booking => {
|
|
748
|
+
const snapshot = {
|
|
749
|
+
...booking
|
|
750
|
+
};
|
|
751
|
+
delete snapshot.product_uid;
|
|
752
|
+
delete snapshot.booking_uid;
|
|
753
|
+
const productUid = firstPresentValue(booking.product_uid, booking.metadata?.product_uid);
|
|
754
|
+
const bookingUid = firstPresentValue(booking.metadata?.unique_identification_number, booking.booking_uid);
|
|
755
|
+
return {
|
|
756
|
+
...snapshot,
|
|
757
|
+
...(isPresentId(productUid) ? {
|
|
758
|
+
product_uid: productUid
|
|
759
|
+
} : {}),
|
|
760
|
+
...(isPresentId(bookingUid) ? {
|
|
761
|
+
booking_uid: bookingUid
|
|
762
|
+
} : {})
|
|
763
|
+
};
|
|
764
|
+
});
|
|
765
|
+
}
|
|
729
766
|
const tableName = order.table_name || order.metadata?.table_name || order.metadata?.table?.name || order.form_data?.table_name;
|
|
730
767
|
if (!tableName) return [];
|
|
731
768
|
return [{
|
|
@@ -743,76 +780,81 @@ function buildResources(order, locale) {
|
|
|
743
780
|
}
|
|
744
781
|
function buildPaymentData(params) {
|
|
745
782
|
const payments = normalizeArray(params.order.payments);
|
|
746
|
-
return payments.filter(payment => isPrintablePayment(payment)).map(payment => {
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
fundRecord,
|
|
761
|
-
locale: params.locale,
|
|
762
|
-
currencySymbol: params.currencySymbol
|
|
763
|
-
}));
|
|
764
|
-
} else {
|
|
765
|
-
const remainingAmount = payment.remaining_amount ?? payment.balance ?? payment.metadata?.remaining_amount;
|
|
766
|
-
if (remainingAmount !== undefined && remainingAmount !== null) {
|
|
767
|
-
items.push({
|
|
768
|
-
item: label(params.locale, 'remainingAmount'),
|
|
769
|
-
value: formatMoney(remainingAmount, params.currencySymbol)
|
|
770
|
-
});
|
|
771
|
-
}
|
|
772
|
-
}
|
|
773
|
-
items.push({
|
|
774
|
-
item: formatDateTime(payment.paid_at || payment.created_at || payment.updated_at || new Date(), params.locale),
|
|
775
|
-
value: ''
|
|
776
|
-
});
|
|
777
|
-
return items;
|
|
778
|
-
});
|
|
783
|
+
return payments.filter(payment => isPrintablePayment(payment)).map(payment => buildPaymentItems({
|
|
784
|
+
payment,
|
|
785
|
+
locale: params.locale,
|
|
786
|
+
currencySymbol: params.currencySymbol,
|
|
787
|
+
includeFundRecordBalance: false
|
|
788
|
+
}));
|
|
789
|
+
}
|
|
790
|
+
function buildWallets(params) {
|
|
791
|
+
return normalizeArray(params.order.payments).filter(payment => isPrintablePayment(payment) && !!getFundRecord(payment)).map(payment => buildPaymentItems({
|
|
792
|
+
payment,
|
|
793
|
+
locale: params.locale,
|
|
794
|
+
currencySymbol: params.currencySymbol,
|
|
795
|
+
includeFundRecordBalance: true
|
|
796
|
+
}));
|
|
779
797
|
}
|
|
780
|
-
function
|
|
798
|
+
function buildPaymentItems(params) {
|
|
781
799
|
const {
|
|
782
800
|
payment,
|
|
783
801
|
locale,
|
|
784
|
-
currencySymbol
|
|
802
|
+
currencySymbol,
|
|
803
|
+
includeFundRecordBalance
|
|
785
804
|
} = params;
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
item:
|
|
789
|
-
value: formatMoney(payment
|
|
790
|
-
}, {
|
|
791
|
-
item: label(locale, 'changeDue'),
|
|
792
|
-
value: formatMoney(payment.metadata.change_given_amount, currencySymbol)
|
|
805
|
+
const serviceFee = getPaymentServiceFee(payment);
|
|
806
|
+
const items = [{
|
|
807
|
+
item: paymentMethodName(payment, locale),
|
|
808
|
+
value: formatMoney(resolveReceiptPaymentAmount(payment, serviceFee), currencySymbol)
|
|
793
809
|
}];
|
|
810
|
+
if (serviceFee.gt(0)) {
|
|
811
|
+
items.push({
|
|
812
|
+
item: label(locale, 'surchargeIncluded'),
|
|
813
|
+
value: formatMoney(serviceFee, currencySymbol)
|
|
814
|
+
});
|
|
815
|
+
}
|
|
816
|
+
const fundRecord = getFundRecord(payment);
|
|
817
|
+
if (fundRecord) {
|
|
818
|
+
items.push(...buildFundRecordPaymentItems({
|
|
819
|
+
payment,
|
|
820
|
+
fundRecord,
|
|
821
|
+
locale,
|
|
822
|
+
currencySymbol,
|
|
823
|
+
includeBalance: includeFundRecordBalance
|
|
824
|
+
}));
|
|
825
|
+
} else {
|
|
826
|
+
const remainingAmount = payment.remaining_amount ?? payment.balance ?? payment.metadata?.remaining_amount;
|
|
827
|
+
if (remainingAmount !== undefined && remainingAmount !== null) {
|
|
828
|
+
items.push({
|
|
829
|
+
item: label(locale, 'remainingAmount'),
|
|
830
|
+
value: formatMoney(remainingAmount, currencySymbol)
|
|
831
|
+
});
|
|
832
|
+
}
|
|
833
|
+
}
|
|
834
|
+
items.push({
|
|
835
|
+
item: formatDateTime(payment.paid_at || payment.created_at || payment.updated_at || new Date(), locale),
|
|
836
|
+
value: ''
|
|
837
|
+
});
|
|
838
|
+
return items;
|
|
794
839
|
}
|
|
795
|
-
function
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
const
|
|
800
|
-
const
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
if (typeof value === 'number') return Number.isFinite(value);
|
|
806
|
-
if (typeof value !== 'string') return false;
|
|
807
|
-
const normalized = value.trim();
|
|
808
|
-
return normalized !== '' && /^[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i.test(normalized);
|
|
840
|
+
function getPaymentServiceFee(payment) {
|
|
841
|
+
return new _decimal.default(toMoneyNumber(payment.service_fee));
|
|
842
|
+
}
|
|
843
|
+
function resolveReceiptPaymentAmount(payment, serviceFee) {
|
|
844
|
+
const amount = new _decimal.default(toMoneyNumber(payment.amount ?? payment.origin_amount));
|
|
845
|
+
const hasAmount = payment.amount !== undefined && payment.amount !== null && payment.amount !== '';
|
|
846
|
+
const hasOriginAmount = payment.origin_amount !== undefined && payment.origin_amount !== null && payment.origin_amount !== '';
|
|
847
|
+
if (!hasAmount || !hasOriginAmount || serviceFee.lte(0)) return amount;
|
|
848
|
+
const originAmount = new _decimal.default(toMoneyNumber(payment.origin_amount));
|
|
849
|
+
return amount.eq(originAmount) ? amount.plus(serviceFee) : amount;
|
|
809
850
|
}
|
|
810
851
|
function buildFundRecordPaymentItems(params) {
|
|
811
852
|
const {
|
|
812
853
|
payment,
|
|
813
854
|
fundRecord,
|
|
814
855
|
locale,
|
|
815
|
-
currencySymbol
|
|
856
|
+
currencySymbol,
|
|
857
|
+
includeBalance
|
|
816
858
|
} = params;
|
|
817
859
|
const items = [];
|
|
818
860
|
const usingBeforeValue = fundRecord.using_before_value;
|
|
@@ -823,13 +865,15 @@ function buildFundRecordPaymentItems(params) {
|
|
|
823
865
|
item: label(locale, 'redeemPoints'),
|
|
824
866
|
value: trimDecimal(usedPoints)
|
|
825
867
|
});
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
868
|
+
if (includeBalance) {
|
|
869
|
+
items.push({
|
|
870
|
+
item: label(locale, 'remainingPoints'),
|
|
871
|
+
value: trimDecimal(new _decimal.default(toMoneyNumber(usingAfterValue)))
|
|
872
|
+
});
|
|
873
|
+
}
|
|
830
874
|
return items;
|
|
831
875
|
}
|
|
832
|
-
if (usingAfterValue !== undefined && usingAfterValue !== null) {
|
|
876
|
+
if (includeBalance && usingAfterValue !== undefined && usingAfterValue !== null) {
|
|
833
877
|
items.push({
|
|
834
878
|
item: label(locale, 'remainingAmount'),
|
|
835
879
|
value: formatMoney(usingAfterValue, currencySymbol)
|
|
@@ -2,7 +2,7 @@ import { Module, ModuleOptions, PisellCore } from '../../types';
|
|
|
2
2
|
import { BaseModule } from '../../modules/BaseModule';
|
|
3
3
|
import { BaseSalesOrderProduct, BaseSalesOrderProductIdentity, BaseSalesPaymentStatus, BaseSalesUpdateOrderProductQuantityParams, BaseSalesCalculateProductBookingPriceParams, BaseSalesPriceRecalculationContextChange, BaseSalesProductBookingPriceResult, BaseSalesQuotationCustomerScopeInfo, BaseSalesScanCodeResult, BaseSalesCashPaymentConfig, BaseSalesPayCashParams, BaseSalesPayCashResult, BaseSalesCommitPaymentMethodParams, BaseSalesCommitPaymentMethodResult, BaseSalesConfirmWalletPaymentResult } from './types';
|
|
4
4
|
import { OrderModule } from '../../modules/Order';
|
|
5
|
-
import type { AddProductBookingInput, AddProductToOrderOptions, LoadSalesDetailParams, OrderPaymentData, OrderPaymentUpdateOptions, OrderPaymentUpdateResult, OrderPaymentSource, SendCustomerPayLinkParams, SyncPaymentsToOrderParams, SyncPaymentsToOrderResult, UpdateTempOrderCustomerInput, UpdateOrderBookingParams, UpdateOrderProductParams, OrderTempOrder, OrderSummary, OrderPromotionEvaluator, OrderGiftSelectResolver, OrderUnfulfilledPromotion, OrderLastGiftActions, RemoveProductsFromOrderOptions, ReplaceTempOrderOptions } from '../../modules/Order/types';
|
|
5
|
+
import type { AddProductBookingInput, AddProductToOrderOptions, LoadSalesDetailParams, OrderPaymentData, OrderPaymentUpdateOptions, OrderPaymentUpdateResult, OrderPaymentSource, SendCustomerPayLinkParams, SyncPaymentsToOrderParams, SyncPaymentsToOrderResult, UpdateTempOrderCustomerInput, UpdateOrderBookingParams, UpdateOrderProductParams, OrderTempOrder, OrderSummary, OrderPromotionEvaluator, OrderGiftSelectResolver, OrderUnfulfilledPromotion, OrderLastGiftActions, RemoveProductsFromOrderOptions, ReplaceTempOrderOptions, SalesNote, SalesNotesMutationSnapshot, SetSalesNoteInput, PickupReferenceMode, ShopServiceData, ShopServiceType } from '../../modules/Order/types';
|
|
6
6
|
import type { SubmitPayloadEnhancer } from '../../modules/Order/utils';
|
|
7
7
|
import type { Discount } from '../../modules/Discount/types';
|
|
8
8
|
import { RequestPlugin, WindowPlugin } from '../../plugins';
|
|
@@ -129,8 +129,23 @@ export declare class BaseSalesImpl extends BaseModule implements Module {
|
|
|
129
129
|
*/
|
|
130
130
|
protected preferAuthoritativeProductQueryPrice(): boolean;
|
|
131
131
|
private getPriceQuerySchedule;
|
|
132
|
+
private isCustomerUserPriceQuery;
|
|
133
|
+
private getPriceQueryScheduleList;
|
|
134
|
+
private buildPriceQueryPayload;
|
|
135
|
+
private getRawProductPriceSources;
|
|
136
|
+
private rememberRawProductPriceSources;
|
|
137
|
+
private getSelectedProductVariantId;
|
|
138
|
+
/**
|
|
139
|
+
* 将目录原始商品还原为本次选择的 SKU 基线。
|
|
140
|
+
*
|
|
141
|
+
* 这里绝不能复用已评估后的目录商品,否则从命中智能价切回不命中的
|
|
142
|
+
* 日期时会残留旧价格。套餐仅验证所选关系存在,最终仍由 merge 方法把
|
|
143
|
+
* 评估后的套餐价格映射回用户的选择数据。
|
|
144
|
+
*/
|
|
145
|
+
private prepareRawProductForPriceQuery;
|
|
146
|
+
private resolveLocalProductForPriceQuery;
|
|
132
147
|
private loadProductsForPriceQuery;
|
|
133
|
-
private
|
|
148
|
+
private resolveProductsForPriceQuery;
|
|
134
149
|
private getAuthoritativeBundleItems;
|
|
135
150
|
private findAuthoritativeBundleItem;
|
|
136
151
|
private getAuthoritativeBundleUnitPrice;
|
|
@@ -210,12 +225,20 @@ export declare class BaseSalesImpl extends BaseModule implements Module {
|
|
|
210
225
|
getOrderSyncState(): import("../../modules/Order/types").OrderSyncState;
|
|
211
226
|
getOrderAmountSnapshot(): import("../../modules/Order/types").OrderAmountSnapshot | null;
|
|
212
227
|
getTempOrderNote(): string;
|
|
228
|
+
getSalesNotes(): SalesNote[];
|
|
229
|
+
createSalesNotesMutationSnapshot(): SalesNotesMutationSnapshot;
|
|
230
|
+
restoreSalesNotesMutationSnapshot(snapshot: SalesNotesMutationSnapshot): void;
|
|
231
|
+
setSalesNote(input: SetSalesNoteInput): Promise<SalesNote>;
|
|
232
|
+
removeSalesNote(uuid: string): Promise<void>;
|
|
233
|
+
clearSalesNotes(): Promise<void>;
|
|
213
234
|
updateTempOrderNote(note: string): string;
|
|
214
235
|
updateTempOrderNote(note: string, sync: true): Promise<string>;
|
|
215
236
|
updateTempOrderNote(note: string, sync: boolean): string | Promise<string>;
|
|
216
237
|
updateRemoteOrderNote(orderId: number | string, note: string): void;
|
|
217
238
|
updateTempOrderShopDiscount(amount: string | number): string;
|
|
218
239
|
updateTempOrderDepositAmount(amount: string | number): OrderSummary;
|
|
240
|
+
setPickupReferenceMode(mode: PickupReferenceMode): ShopServiceData;
|
|
241
|
+
setServiceType(serviceType: ShopServiceType): ShopServiceData;
|
|
219
242
|
updateTempOrderContactsInfo(contactsInfo: Record<string, any> | null): Record<string, any> | null;
|
|
220
243
|
/** @deprecated OrderModule 不再负责 tempOrder localStorage 持久化。 */
|
|
221
244
|
setEnableTempOrderPersist(enabled: boolean): void;
|
|
@@ -498,7 +521,7 @@ export declare class BaseSalesImpl extends BaseModule implements Module {
|
|
|
498
521
|
getUnfulfilledPromotions(): OrderUnfulfilledPromotion[];
|
|
499
522
|
/** 最近一次促销计算输出的赠品操作 diff。 */
|
|
500
523
|
getLastGiftActions(): OrderLastGiftActions | null;
|
|
501
|
-
getProductList(): Promise<
|
|
524
|
+
getProductList(): Promise<import("../..").ProductData[] | undefined>;
|
|
502
525
|
getOtherParams(): Record<string, any>;
|
|
503
526
|
setOtherParams(params: Record<string, any>, { cover }?: {
|
|
504
527
|
cover?: boolean;
|