@pisell/pisellos 2.2.313 → 2.2.315
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/index.d.ts +2 -0
- package/dist/index.js +3 -1
- package/dist/model/strategy/adapter/itemRule/adapter.d.ts +3 -1
- package/dist/model/strategy/adapter/itemRule/adapter.js +74 -7
- package/dist/model/strategy/adapter/itemRule/evaluator.d.ts +3 -1
- package/dist/model/strategy/adapter/itemRule/evaluator.js +13 -0
- package/dist/model/strategy/adapter/itemRule/type.d.ts +40 -1
- package/dist/model/strategy/adapter/itemRule/type.js +10 -0
- package/dist/modules/BookingContext/utils/productExtend.d.ts +7 -0
- package/dist/modules/BookingContext/utils/productExtend.js +62 -18
- package/dist/modules/BookingContext/utils/resources.js +1 -1
- package/dist/modules/BusinessAvailability/index.d.ts +30 -0
- package/dist/modules/BusinessAvailability/index.js +204 -0
- package/dist/modules/Cart/index.js +4 -3
- package/dist/modules/Cart/types.d.ts +2 -0
- package/dist/modules/Cart/utils/cartProduct.d.ts +3 -1
- package/dist/modules/Cart/utils/cartProduct.js +59 -32
- package/dist/modules/FulfillmentTiming/index.d.ts +11 -0
- package/dist/modules/FulfillmentTiming/index.js +407 -0
- package/dist/modules/FulfillmentTiming/types.d.ts +67 -0
- package/dist/modules/FulfillmentTiming/types.js +1 -0
- package/dist/modules/OpenData/types.d.ts +14 -0
- package/dist/modules/Order/index.d.ts +14 -2
- package/dist/modules/Order/index.js +856 -486
- package/dist/modules/Order/localEftposState.d.ts +13 -0
- package/dist/modules/Order/localEftposState.js +39 -0
- package/dist/modules/Order/pickupTiming.d.ts +46 -0
- package/dist/modules/Order/pickupTiming.js +53 -0
- package/dist/modules/Order/types.d.ts +30 -2
- package/dist/modules/Order/utils.js +25 -7
- package/dist/modules/Payment/index.js +9 -10
- package/dist/modules/Product/types.d.ts +11 -0
- package/dist/modules/ProductList/index.js +1 -1
- package/dist/modules/ResourcePlanner/planner.d.ts +2 -0
- package/dist/modules/ResourcePlanner/planner.js +332 -23
- package/dist/modules/ResourcePlanner/types.d.ts +29 -0
- package/dist/modules/Schedule/index.d.ts +8 -0
- package/dist/modules/Schedule/index.js +141 -39
- package/dist/modules/index.d.ts +1 -0
- package/dist/modules/index.js +1 -0
- package/dist/plugins/request.d.ts +7 -0
- package/dist/server/index.d.ts +1 -0
- package/dist/server/index.js +1536 -1309
- package/dist/server/modules/form/index.d.ts +19 -0
- package/dist/server/modules/form/index.js +205 -0
- package/dist/server/modules/form/types.d.ts +13 -0
- package/dist/server/modules/form/types.js +3 -0
- package/dist/server/modules/index.d.ts +3 -0
- package/dist/server/modules/index.js +4 -0
- package/dist/server/modules/order/index.d.ts +15 -0
- package/dist/server/modules/order/index.js +920 -688
- package/dist/server/modules/order/types.d.ts +1 -0
- package/dist/server/test.json +1 -1
- package/dist/server/utils/small-ticket.d.ts +1 -85
- package/dist/server/utils/small-ticket.js +2 -2542
- package/dist/shared/payment/loadPaymentMethods.d.ts +9 -0
- package/dist/shared/payment/loadPaymentMethods.js +66 -0
- package/dist/shared/receipt/customerInvoiceLanguages.d.ts +8 -0
- package/dist/shared/receipt/customerInvoiceLanguages.js +60 -0
- package/dist/shared/receipt/loadCustomerInvoiceLayout.d.ts +27 -0
- package/dist/shared/receipt/loadCustomerInvoiceLayout.js +184 -0
- package/dist/shared/receipt/small-ticket.d.ts +96 -0
- package/dist/shared/receipt/small-ticket.js +2751 -0
- package/dist/shared/receipt/templateVisibility.d.ts +23 -0
- package/dist/shared/receipt/templateVisibility.js +64 -0
- package/dist/shared/sales/loadSalesOrderSnapshot.d.ts +9 -0
- package/dist/shared/sales/loadSalesOrderSnapshot.js +21 -0
- package/dist/solution/BaseSales/fulfillmentItemRules.d.ts +27 -0
- package/dist/solution/BaseSales/fulfillmentItemRules.js +750 -0
- package/dist/solution/BaseSales/index.d.ts +39 -16
- package/dist/solution/BaseSales/index.js +1754 -1154
- package/dist/solution/BaseSales/pickupTiming.d.ts +47 -0
- package/dist/solution/BaseSales/pickupTiming.js +616 -0
- package/dist/solution/BaseSales/types.d.ts +11 -0
- package/dist/solution/BaseSales/utils/parseSalesResponse.js +3 -0
- package/dist/solution/BookingByStep/index.d.ts +4 -2
- package/dist/solution/BookingByStep/index.js +8 -3
- package/dist/solution/BookingTicket/index.d.ts +8 -2
- package/dist/solution/BookingTicket/index.js +513 -436
- package/dist/solution/BookingTicket/utils/addProductDecision.d.ts +0 -1
- package/dist/solution/BookingTicket/utils/addProductDecision.js +1 -1
- package/dist/solution/BookingTicket/utils/cartView.js +3 -1
- package/dist/solution/OrderInvoicePreview/index.d.ts +66 -0
- package/dist/solution/OrderInvoicePreview/index.js +340 -0
- package/dist/solution/RegisterAndLogin/config.js +54 -11
- package/dist/solution/RegisterAndLogin/index.d.ts +2 -0
- package/dist/solution/RegisterAndLogin/index.js +1 -1
- package/dist/solution/RegisterAndLogin/utils.d.ts +12 -4
- package/dist/solution/RegisterAndLogin/utils.js +36 -16
- package/dist/solution/Sales/index.js +1 -1
- package/dist/solution/UnifiedBookingSales/businessAvailability.d.ts +27 -0
- package/dist/solution/UnifiedBookingSales/businessAvailability.js +292 -0
- package/dist/solution/UnifiedBookingSales/index.d.ts +36 -4
- package/dist/solution/UnifiedBookingSales/index.js +1714 -905
- package/dist/solution/UnifiedBookingSales/types.d.ts +16 -2
- package/dist/solution/VenueBooking/index.d.ts +15 -2
- package/dist/solution/VenueBooking/index.js +1062 -785
- package/dist/solution/VenueBooking/types.d.ts +2 -1
- package/dist/solution/VenueBooking/types.js +1 -0
- package/dist/solution/VenueBooking/utils/dateSummary.d.ts +1 -0
- package/dist/solution/VenueBooking/utils/dateSummary.js +7 -4
- package/dist/solution/VenueBooking/utils/smartPricing.d.ts +71 -0
- package/dist/solution/VenueBooking/utils/smartPricing.js +273 -0
- package/dist/solution/VenueBooking/utils/timeSlot.d.ts +1 -0
- package/dist/solution/VenueBooking/utils/timeSlot.js +6 -3
- package/dist/solution/index.d.ts +1 -0
- package/dist/solution/index.js +2 -1
- package/lib/index.d.ts +2 -0
- package/lib/index.js +21 -1
- package/lib/model/strategy/adapter/itemRule/adapter.d.ts +3 -1
- package/lib/model/strategy/adapter/itemRule/adapter.js +54 -4
- package/lib/model/strategy/adapter/itemRule/evaluator.d.ts +3 -1
- package/lib/model/strategy/adapter/itemRule/evaluator.js +9 -0
- package/lib/model/strategy/adapter/itemRule/type.d.ts +40 -1
- package/lib/model/strategy/adapter/itemRule/type.js +10 -0
- package/lib/modules/BookingContext/utils/productExtend.d.ts +7 -0
- package/lib/modules/BookingContext/utils/productExtend.js +45 -2
- package/lib/modules/BookingContext/utils/resources.js +1 -1
- package/lib/modules/BusinessAvailability/index.d.ts +30 -0
- package/lib/modules/BusinessAvailability/index.js +146 -0
- package/lib/modules/Cart/index.js +4 -2
- package/lib/modules/Cart/types.d.ts +2 -0
- package/lib/modules/Cart/utils/cartProduct.d.ts +3 -1
- package/lib/modules/Cart/utils/cartProduct.js +39 -20
- package/lib/modules/FulfillmentTiming/index.d.ts +11 -0
- package/lib/modules/FulfillmentTiming/index.js +359 -0
- package/lib/modules/FulfillmentTiming/types.d.ts +67 -0
- package/lib/modules/FulfillmentTiming/types.js +5 -0
- package/lib/modules/OpenData/types.d.ts +14 -0
- package/lib/modules/Order/index.d.ts +14 -2
- package/lib/modules/Order/index.js +240 -38
- package/lib/modules/Order/localEftposState.d.ts +13 -0
- package/lib/modules/Order/localEftposState.js +44 -0
- package/lib/modules/Order/pickupTiming.d.ts +46 -0
- package/lib/modules/Order/pickupTiming.js +61 -0
- package/lib/modules/Order/types.d.ts +30 -2
- package/lib/modules/Order/utils.js +21 -5
- package/lib/modules/Payment/index.js +3 -4
- package/lib/modules/Product/types.d.ts +11 -0
- package/lib/modules/ProductList/index.js +1 -1
- package/lib/modules/ResourcePlanner/planner.d.ts +2 -0
- package/lib/modules/ResourcePlanner/planner.js +252 -8
- package/lib/modules/ResourcePlanner/types.d.ts +29 -0
- package/lib/modules/Schedule/index.d.ts +8 -0
- package/lib/modules/Schedule/index.js +68 -12
- package/lib/modules/index.d.ts +1 -0
- package/lib/modules/index.js +11 -0
- package/lib/plugins/request.d.ts +7 -0
- package/lib/server/index.d.ts +1 -0
- package/lib/server/index.js +158 -37
- package/lib/server/modules/form/index.d.ts +19 -0
- package/lib/server/modules/form/index.js +73 -0
- package/lib/server/modules/form/types.d.ts +13 -0
- package/lib/server/modules/form/types.js +9 -0
- package/lib/server/modules/index.d.ts +3 -0
- package/lib/server/modules/index.js +15 -1
- package/lib/server/modules/order/index.d.ts +15 -0
- package/lib/server/modules/order/index.js +114 -3
- package/lib/server/modules/order/types.d.ts +1 -0
- package/lib/server/test.json +1 -1
- package/lib/server/utils/small-ticket.d.ts +1 -85
- package/lib/server/utils/small-ticket.js +9 -2305
- package/lib/shared/payment/loadPaymentMethods.d.ts +9 -0
- package/lib/shared/payment/loadPaymentMethods.js +40 -0
- package/lib/shared/receipt/customerInvoiceLanguages.d.ts +8 -0
- package/lib/shared/receipt/customerInvoiceLanguages.js +58 -0
- package/lib/shared/receipt/loadCustomerInvoiceLayout.d.ts +27 -0
- package/lib/shared/receipt/loadCustomerInvoiceLayout.js +124 -0
- package/lib/shared/receipt/small-ticket.d.ts +96 -0
- package/lib/shared/receipt/small-ticket.js +2546 -0
- package/lib/shared/receipt/templateVisibility.d.ts +23 -0
- package/lib/shared/receipt/templateVisibility.js +63 -0
- package/lib/shared/sales/loadSalesOrderSnapshot.d.ts +9 -0
- package/lib/shared/sales/loadSalesOrderSnapshot.js +22 -0
- package/lib/solution/BaseSales/fulfillmentItemRules.d.ts +27 -0
- package/lib/solution/BaseSales/fulfillmentItemRules.js +259 -0
- package/lib/solution/BaseSales/index.d.ts +39 -16
- package/lib/solution/BaseSales/index.js +333 -31
- package/lib/solution/BaseSales/pickupTiming.d.ts +47 -0
- package/lib/solution/BaseSales/pickupTiming.js +290 -0
- package/lib/solution/BaseSales/types.d.ts +11 -0
- package/lib/solution/BaseSales/utils/parseSalesResponse.js +3 -0
- package/lib/solution/BookingByStep/index.d.ts +4 -2
- package/lib/solution/BookingByStep/index.js +7 -3
- package/lib/solution/BookingTicket/index.d.ts +8 -2
- package/lib/solution/BookingTicket/index.js +65 -6
- package/lib/solution/BookingTicket/utils/addProductDecision.d.ts +0 -1
- package/lib/solution/BookingTicket/utils/addProductDecision.js +1 -1
- package/lib/solution/BookingTicket/utils/cartView.js +3 -1
- package/lib/solution/OrderInvoicePreview/index.d.ts +66 -0
- package/lib/solution/OrderInvoicePreview/index.js +246 -0
- package/lib/solution/RegisterAndLogin/config.js +57 -11
- package/lib/solution/RegisterAndLogin/index.d.ts +2 -0
- package/lib/solution/RegisterAndLogin/index.js +9 -1
- package/lib/solution/RegisterAndLogin/utils.d.ts +12 -4
- package/lib/solution/RegisterAndLogin/utils.js +24 -17
- package/lib/solution/Sales/index.js +1 -1
- package/lib/solution/UnifiedBookingSales/businessAvailability.d.ts +27 -0
- package/lib/solution/UnifiedBookingSales/businessAvailability.js +138 -0
- package/lib/solution/UnifiedBookingSales/index.d.ts +36 -4
- package/lib/solution/UnifiedBookingSales/index.js +561 -74
- package/lib/solution/UnifiedBookingSales/types.d.ts +16 -2
- package/lib/solution/VenueBooking/index.d.ts +15 -2
- package/lib/solution/VenueBooking/index.js +243 -96
- package/lib/solution/VenueBooking/types.d.ts +2 -1
- package/lib/solution/VenueBooking/types.js +1 -0
- package/lib/solution/VenueBooking/utils/dateSummary.d.ts +1 -0
- package/lib/solution/VenueBooking/utils/dateSummary.js +7 -4
- package/lib/solution/VenueBooking/utils/smartPricing.d.ts +71 -0
- package/lib/solution/VenueBooking/utils/smartPricing.js +224 -0
- package/lib/solution/VenueBooking/utils/timeSlot.d.ts +1 -0
- package/lib/solution/VenueBooking/utils/timeSlot.js +5 -2
- package/lib/solution/index.d.ts +1 -0
- package/lib/solution/index.js +11 -0
- package/package.json +1 -1
|
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.OrderModule = void 0;
|
|
7
7
|
var _lodashEs = require("lodash-es");
|
|
8
|
+
var _localEftposState = require("../../../modules/Order/localEftposState");
|
|
8
9
|
var _dayjs = _interopRequireDefault(require("dayjs"));
|
|
9
10
|
var _BaseModule = require("../../../modules/BaseModule");
|
|
10
11
|
var _orderCollectionIdentity = require("../../../modules/Order/utils/orderCollectionIdentity");
|
|
@@ -259,9 +260,9 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
259
260
|
mergeAuthoritativeOrderCollection(field, existing, incoming, uidRemaps = [], options = {}) {
|
|
260
261
|
const kind = ORDER_COLLECTION_KIND_BY_FIELD[field];
|
|
261
262
|
const existingItems = Array.isArray(existing) ? existing : [];
|
|
262
|
-
if (field === 'payments' && options.preserveIdentifiedPendingPayments) {
|
|
263
|
+
if (field === 'payments' && (options.preserveIdentifiedPendingPayments || existingItems.some(_localEftposState.isLocalFinalizedPayment))) {
|
|
263
264
|
return (0, _paymentUtils.mergeOrderPaymentListsByIdentity)(existingItems, incoming, {
|
|
264
|
-
preserveUnmatchedExistingWhen: _paymentUtils.isIdentifiedPendingOrderPayment
|
|
265
|
+
preserveUnmatchedExistingWhen: payment => options.preserveIdentifiedPendingPayments === true && (0, _paymentUtils.isIdentifiedPendingOrderPayment)(payment) || (0, _localEftposState.isLocalFinalizedPayment)(payment)
|
|
265
266
|
});
|
|
266
267
|
}
|
|
267
268
|
return incoming.map(incomingItem => {
|
|
@@ -637,6 +638,42 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
637
638
|
const memoryOrder = this.store.list.find(order => this.isOrderLookupMatch(order, key));
|
|
638
639
|
return memoryOrder || null;
|
|
639
640
|
}
|
|
641
|
+
|
|
642
|
+
/** Read-only payment gate lookup; never hydrate the whole order list on a miss. */
|
|
643
|
+
async getLocalOrderForPaymentReadiness(lookup) {
|
|
644
|
+
if (lookup === undefined || lookup === null || lookup === '') return null;
|
|
645
|
+
const memoryOrder = this.getLocalOrderFromMemoryByLookup(lookup);
|
|
646
|
+
if (memoryOrder) return memoryOrder;
|
|
647
|
+
if (typeof this.dbManager?.find !== 'function') {
|
|
648
|
+
return this.getLocalOrderByLookup(lookup);
|
|
649
|
+
}
|
|
650
|
+
const key = this.getIdKey(lookup);
|
|
651
|
+
const fields = ['order_id', 'external_sale_number', 'order_number', 'shop_order_number', 'shop_full_order_number'];
|
|
652
|
+
const candidates = [];
|
|
653
|
+
for (const column of fields) {
|
|
654
|
+
// Match getAll's storage-key ordering even when aliases collide across rows.
|
|
655
|
+
// Let query errors reach the payment gate rather than treating them as a miss.
|
|
656
|
+
const rows = await this.dbManager.find(INDEXDB_STORE_NAME, {
|
|
657
|
+
filters: [{
|
|
658
|
+
column,
|
|
659
|
+
op: '=',
|
|
660
|
+
value: key
|
|
661
|
+
}],
|
|
662
|
+
orderBy: [{
|
|
663
|
+
column: '__order_storage_key',
|
|
664
|
+
dir: 'asc'
|
|
665
|
+
}],
|
|
666
|
+
limit: 1
|
|
667
|
+
});
|
|
668
|
+
if (rows?.[0] && this.isOrderLookupMatch(rows[0], key)) candidates.push(rows[0]);
|
|
669
|
+
}
|
|
670
|
+
candidates.sort((left, right) => {
|
|
671
|
+
const leftKey = String(left.__order_storage_key ?? this.getOrderStorageKey(left));
|
|
672
|
+
const rightKey = String(right.__order_storage_key ?? this.getOrderStorageKey(right));
|
|
673
|
+
return leftKey < rightKey ? -1 : leftKey > rightKey ? 1 : 0;
|
|
674
|
+
});
|
|
675
|
+
return candidates.length ? this.normalizeOrderForMemoryList(candidates[0], 'paymentReadiness.sqlite') : null;
|
|
676
|
+
}
|
|
640
677
|
async getLocalOrderByLookup(lookup, options = {}) {
|
|
641
678
|
const key = this.getIdKey(lookup);
|
|
642
679
|
const logContext = {
|
|
@@ -753,6 +790,13 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
753
790
|
return null;
|
|
754
791
|
}
|
|
755
792
|
const previousPayment = (0, _lodashEs.cloneDeep)(found.payment);
|
|
793
|
+
if (params.finalizeUnsuccessful && (found.payment.status === 'paid' || found.payment.metadata?.transactions?.some(transaction => transaction.status === 'success') || (0, _localEftposState.isLocalFinalizedPayment)(found.payment))) {
|
|
794
|
+
return {
|
|
795
|
+
order: found.order,
|
|
796
|
+
payment: found.payment,
|
|
797
|
+
previousPayment
|
|
798
|
+
};
|
|
799
|
+
}
|
|
756
800
|
const nextPayment = (0, _paymentUtils.mergeOrderPaymentRecord)(found.payment, {
|
|
757
801
|
...params.updates,
|
|
758
802
|
updated_at: params.updates.updated_at || (0, _dayjs.default)().format('YYYY-MM-DD HH:mm:ss')
|
|
@@ -762,6 +806,13 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
762
806
|
payments: (found.order.payments || []).map((payment, index) => index === found.paymentIndex ? nextPayment : payment),
|
|
763
807
|
updated_at: (0, _dayjs.default)().format('YYYY-MM-DD HH:mm:ss')
|
|
764
808
|
};
|
|
809
|
+
if (params.finalizeUnsuccessful && this.hasRealOrderId(found.order) && Number(found.order.need_sync || 0) === 0 && !(nextOrder.payments || []).some(_paymentUtils.isPendingOrderPayment)) {
|
|
810
|
+
nextOrder.is_draft_order = 0;
|
|
811
|
+
nextOrder.metadata = {
|
|
812
|
+
...nextOrder.metadata,
|
|
813
|
+
[_localEftposState.LOCAL_EFTPOS_REFRESH_REQUIRED]: true
|
|
814
|
+
};
|
|
815
|
+
}
|
|
765
816
|
const paymentContext = {
|
|
766
817
|
...logContext,
|
|
767
818
|
matched_by: found.matchedBy,
|
|
@@ -813,6 +864,60 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
813
864
|
previousPayment
|
|
814
865
|
};
|
|
815
866
|
}
|
|
867
|
+
async finalizeLocalEftposPayment(params) {
|
|
868
|
+
const found = await this.getLocalPayment(params);
|
|
869
|
+
if (!found) throw new Error('未找到本地支付记录');
|
|
870
|
+
const transactions = found.payment.metadata?.transactions || [];
|
|
871
|
+
if (transactions.some(transaction => transaction.status !== 'fail' && transaction.status !== 'success' && !params.failedTransactionNumbers.includes(String(transaction.number)))) {
|
|
872
|
+
throw new Error('仍有结果未知的交易,保留待确认支付');
|
|
873
|
+
}
|
|
874
|
+
if (params.result === 'not_started' && transactions.length > 0 && !(0, _localEftposState.isLocalFinalizedPayment)(found.payment) && found.payment.status !== 'paid') {
|
|
875
|
+
throw new Error('支付已有交易记录,不能按未发起交易结束');
|
|
876
|
+
}
|
|
877
|
+
return this.updateLocalPayment({
|
|
878
|
+
...params,
|
|
879
|
+
finalizeUnsuccessful: true,
|
|
880
|
+
updates: {
|
|
881
|
+
status: 'voided',
|
|
882
|
+
metadata: {
|
|
883
|
+
[_localEftposState.LOCAL_EFTPOS_FINALIZED]: true,
|
|
884
|
+
transactions: params.failedTransactionNumbers.map(number => ({
|
|
885
|
+
number,
|
|
886
|
+
status: 'fail'
|
|
887
|
+
}))
|
|
888
|
+
}
|
|
889
|
+
}
|
|
890
|
+
});
|
|
891
|
+
}
|
|
892
|
+
|
|
893
|
+
/** Only a successful full detail GET may release the persisted payment gate. */
|
|
894
|
+
async completeLocalPaymentRefresh(fresh) {
|
|
895
|
+
const existing = await this.getLocalOrderByLookup(fresh.order_id);
|
|
896
|
+
if (!existing || !(0, _localEftposState.requiresLocalPaymentRefresh)(existing)) {
|
|
897
|
+
await this.upsertOrdersFromRemote([fresh]);
|
|
898
|
+
return (await this.getLocalOrderByLookup(fresh.order_id)) || fresh;
|
|
899
|
+
}
|
|
900
|
+
if (this.isPendingSyncOrder(existing) || this.isDraftOrder(existing) || (existing.payments || []).some(_paymentUtils.isPendingOrderPayment)) {
|
|
901
|
+
throw new Error('订单仍有未结束支付或待同步改动,暂不能刷新');
|
|
902
|
+
}
|
|
903
|
+
if (!Array.isArray(fresh.products) || !fresh.summary) {
|
|
904
|
+
throw new Error('远端订单详情不完整,请重新刷新');
|
|
905
|
+
}
|
|
906
|
+
const nextOrder = this.mergeOrderRecords(existing, this.normalizeRemoteSyncedOrder(fresh));
|
|
907
|
+
nextOrder.metadata = {
|
|
908
|
+
...nextOrder.metadata
|
|
909
|
+
};
|
|
910
|
+
delete nextOrder.metadata[_localEftposState.LOCAL_EFTPOS_REFRESH_REQUIRED];
|
|
911
|
+
// Do not publish/clear the gate in memory until SQLite has accepted the full snapshot.
|
|
912
|
+
await this.updateOrderInSQLite(nextOrder, 'completeLocalPaymentRefresh', {
|
|
913
|
+
throwOnError: true
|
|
914
|
+
});
|
|
915
|
+
const index = this.findOrderIndexByIdentity(this.store.list, existing);
|
|
916
|
+
this.store.list = index < 0 ? [...this.store.list, nextOrder] : this.store.list.map((order, i) => i === index ? nextOrder : order);
|
|
917
|
+
this.syncOrdersMap();
|
|
918
|
+
await this.emitOrdersChanged([nextOrder], 'completeLocalPaymentRefresh');
|
|
919
|
+
return nextOrder;
|
|
920
|
+
}
|
|
816
921
|
async loadOrdersByServer(options = {}) {
|
|
817
922
|
let orderList = [];
|
|
818
923
|
let hasFetchedRemoteSnapshot = false;
|
|
@@ -1997,7 +2102,7 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
1997
2102
|
return payments.filter(payment => (0, _paymentUtils.isIdentifiedPendingOrderPayment)(payment));
|
|
1998
2103
|
}
|
|
1999
2104
|
shouldProtectLocalOrderFromRemoteSnapshot(order) {
|
|
2000
|
-
return this.isPendingSyncOrder(order) || this.isDraftOrder(order) || this.getIdentifiedPendingPayments(order).length > 0;
|
|
2105
|
+
return this.isPendingSyncOrder(order) || this.isDraftOrder(order) || this.getIdentifiedPendingPayments(order).length > 0 || (0, _localEftposState.requiresLocalPaymentRefresh)(order) || (order.payments || []).some(_localEftposState.isLocalFinalizedPayment);
|
|
2001
2106
|
}
|
|
2002
2107
|
getUnmatchedIdentifiedPendingPayments(existing, incoming) {
|
|
2003
2108
|
const existingPayments = Array.isArray(existing) ? existing : [];
|
|
@@ -2019,6 +2124,12 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
2019
2124
|
const secondaryRecord = secondary;
|
|
2020
2125
|
const existingRecord = existing;
|
|
2021
2126
|
const incomingRecord = incoming;
|
|
2127
|
+
if ((0, _localEftposState.requiresLocalPaymentRefresh)(existing)) {
|
|
2128
|
+
mergedRecord.metadata = {
|
|
2129
|
+
...mergedRecord.metadata,
|
|
2130
|
+
[_localEftposState.LOCAL_EFTPOS_REFRESH_REQUIRED]: true
|
|
2131
|
+
};
|
|
2132
|
+
}
|
|
2022
2133
|
const childUidRemaps = [];
|
|
2023
2134
|
for (const field of fieldsToPreserve) {
|
|
2024
2135
|
if (!this.isBlankIdentityValue(preferredRecord[field])) {
|
package/lib/server/test.json
CHANGED
|
@@ -1,85 +1 @@
|
|
|
1
|
-
export
|
|
2
|
-
name?: string;
|
|
3
|
-
phone?: string;
|
|
4
|
-
address?: string;
|
|
5
|
-
address_street?: string;
|
|
6
|
-
address_detail?: string;
|
|
7
|
-
city?: string;
|
|
8
|
-
province?: string;
|
|
9
|
-
country?: string;
|
|
10
|
-
zip?: string;
|
|
11
|
-
tax_number?: string;
|
|
12
|
-
tax_title?: string;
|
|
13
|
-
is_price_include_tax?: 0 | 1 | boolean;
|
|
14
|
-
currency_symbol?: string;
|
|
15
|
-
currency_code?: string;
|
|
16
|
-
primary_locale?: string;
|
|
17
|
-
timezone?: string;
|
|
18
|
-
[key: string]: any;
|
|
19
|
-
}
|
|
20
|
-
export interface BuildSmallTicketDataParams {
|
|
21
|
-
order: Record<string, any>;
|
|
22
|
-
shopInfo?: SmallTicketShopInfo | null;
|
|
23
|
-
locales?: string[];
|
|
24
|
-
productMap?: Record<string | number, Record<string, any>>;
|
|
25
|
-
}
|
|
26
|
-
export interface SmallTicketItem {
|
|
27
|
-
item: string;
|
|
28
|
-
value: string;
|
|
29
|
-
size?: number;
|
|
30
|
-
align?: string;
|
|
31
|
-
product_uid?: string | number;
|
|
32
|
-
booking_uid?: string | number;
|
|
33
|
-
}
|
|
34
|
-
export interface SmallTicketProduct {
|
|
35
|
-
product_title: string;
|
|
36
|
-
product_quantity: number;
|
|
37
|
-
selling_price: string;
|
|
38
|
-
total_selling_price: string;
|
|
39
|
-
original_price: string;
|
|
40
|
-
base_price?: string;
|
|
41
|
-
total_original_price: string;
|
|
42
|
-
options_total_price?: string;
|
|
43
|
-
package_items_total_price?: string;
|
|
44
|
-
extension_list: any[];
|
|
45
|
-
product_uid?: string | number;
|
|
46
|
-
booking_uid?: string | number;
|
|
47
|
-
product_note?: string;
|
|
48
|
-
allergy?: string;
|
|
49
|
-
options?: Array<{
|
|
50
|
-
name: string;
|
|
51
|
-
num?: number;
|
|
52
|
-
price?: string;
|
|
53
|
-
total_price: string;
|
|
54
|
-
value?: string;
|
|
55
|
-
}>;
|
|
56
|
-
variant?: string;
|
|
57
|
-
combinations?: any[];
|
|
58
|
-
}
|
|
59
|
-
export type SmallTicketAppointment = SmallTicketItem[];
|
|
60
|
-
export interface SmallTicketLocaleData {
|
|
61
|
-
base_data: Record<string, any>;
|
|
62
|
-
products: SmallTicketProduct[];
|
|
63
|
-
fees: {
|
|
64
|
-
fees: SmallTicketItem[];
|
|
65
|
-
countFee: Record<string, any>;
|
|
66
|
-
};
|
|
67
|
-
customer: SmallTicketItem[];
|
|
68
|
-
appointment: SmallTicketAppointment;
|
|
69
|
-
delivery?: SmallTicketItem[];
|
|
70
|
-
resources: Array<{
|
|
71
|
-
id: string | number;
|
|
72
|
-
code: string;
|
|
73
|
-
title: string;
|
|
74
|
-
form_title: string;
|
|
75
|
-
}>;
|
|
76
|
-
payment_data: SmallTicketItem[][];
|
|
77
|
-
wallets: SmallTicketItem[][];
|
|
78
|
-
tickets: any[];
|
|
79
|
-
source_shop: any[];
|
|
80
|
-
refund_data: SmallTicketItem[][];
|
|
81
|
-
expend_data: any[];
|
|
82
|
-
}
|
|
83
|
-
export type SmallTicketData = Record<string, SmallTicketLocaleData>;
|
|
84
|
-
export declare function buildSmallTicketData(params: BuildSmallTicketDataParams): SmallTicketData;
|
|
85
|
-
export declare function hasSmallTicketData(value: any): boolean;
|
|
1
|
+
export * from '../../shared/receipt/small-ticket';
|