@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.
Files changed (215) hide show
  1. package/dist/index.d.ts +2 -0
  2. package/dist/index.js +3 -1
  3. package/dist/model/strategy/adapter/itemRule/adapter.d.ts +3 -1
  4. package/dist/model/strategy/adapter/itemRule/adapter.js +74 -7
  5. package/dist/model/strategy/adapter/itemRule/evaluator.d.ts +3 -1
  6. package/dist/model/strategy/adapter/itemRule/evaluator.js +13 -0
  7. package/dist/model/strategy/adapter/itemRule/type.d.ts +40 -1
  8. package/dist/model/strategy/adapter/itemRule/type.js +10 -0
  9. package/dist/modules/BookingContext/utils/productExtend.d.ts +7 -0
  10. package/dist/modules/BookingContext/utils/productExtend.js +62 -18
  11. package/dist/modules/BookingContext/utils/resources.js +1 -1
  12. package/dist/modules/BusinessAvailability/index.d.ts +30 -0
  13. package/dist/modules/BusinessAvailability/index.js +204 -0
  14. package/dist/modules/Cart/index.js +4 -3
  15. package/dist/modules/Cart/types.d.ts +2 -0
  16. package/dist/modules/Cart/utils/cartProduct.d.ts +3 -1
  17. package/dist/modules/Cart/utils/cartProduct.js +59 -32
  18. package/dist/modules/FulfillmentTiming/index.d.ts +11 -0
  19. package/dist/modules/FulfillmentTiming/index.js +407 -0
  20. package/dist/modules/FulfillmentTiming/types.d.ts +67 -0
  21. package/dist/modules/FulfillmentTiming/types.js +1 -0
  22. package/dist/modules/OpenData/types.d.ts +14 -0
  23. package/dist/modules/Order/index.d.ts +14 -2
  24. package/dist/modules/Order/index.js +856 -486
  25. package/dist/modules/Order/localEftposState.d.ts +13 -0
  26. package/dist/modules/Order/localEftposState.js +39 -0
  27. package/dist/modules/Order/pickupTiming.d.ts +46 -0
  28. package/dist/modules/Order/pickupTiming.js +53 -0
  29. package/dist/modules/Order/types.d.ts +30 -2
  30. package/dist/modules/Order/utils.js +25 -7
  31. package/dist/modules/Payment/index.js +9 -10
  32. package/dist/modules/Product/types.d.ts +11 -0
  33. package/dist/modules/ProductList/index.js +1 -1
  34. package/dist/modules/ResourcePlanner/planner.d.ts +2 -0
  35. package/dist/modules/ResourcePlanner/planner.js +332 -23
  36. package/dist/modules/ResourcePlanner/types.d.ts +29 -0
  37. package/dist/modules/Schedule/index.d.ts +8 -0
  38. package/dist/modules/Schedule/index.js +141 -39
  39. package/dist/modules/index.d.ts +1 -0
  40. package/dist/modules/index.js +1 -0
  41. package/dist/plugins/request.d.ts +7 -0
  42. package/dist/server/index.d.ts +1 -0
  43. package/dist/server/index.js +1536 -1309
  44. package/dist/server/modules/form/index.d.ts +19 -0
  45. package/dist/server/modules/form/index.js +205 -0
  46. package/dist/server/modules/form/types.d.ts +13 -0
  47. package/dist/server/modules/form/types.js +3 -0
  48. package/dist/server/modules/index.d.ts +3 -0
  49. package/dist/server/modules/index.js +4 -0
  50. package/dist/server/modules/order/index.d.ts +15 -0
  51. package/dist/server/modules/order/index.js +920 -688
  52. package/dist/server/modules/order/types.d.ts +1 -0
  53. package/dist/server/test.json +1 -1
  54. package/dist/server/utils/small-ticket.d.ts +1 -85
  55. package/dist/server/utils/small-ticket.js +2 -2542
  56. package/dist/shared/payment/loadPaymentMethods.d.ts +9 -0
  57. package/dist/shared/payment/loadPaymentMethods.js +66 -0
  58. package/dist/shared/receipt/customerInvoiceLanguages.d.ts +8 -0
  59. package/dist/shared/receipt/customerInvoiceLanguages.js +60 -0
  60. package/dist/shared/receipt/loadCustomerInvoiceLayout.d.ts +27 -0
  61. package/dist/shared/receipt/loadCustomerInvoiceLayout.js +184 -0
  62. package/dist/shared/receipt/small-ticket.d.ts +96 -0
  63. package/dist/shared/receipt/small-ticket.js +2751 -0
  64. package/dist/shared/receipt/templateVisibility.d.ts +23 -0
  65. package/dist/shared/receipt/templateVisibility.js +64 -0
  66. package/dist/shared/sales/loadSalesOrderSnapshot.d.ts +9 -0
  67. package/dist/shared/sales/loadSalesOrderSnapshot.js +21 -0
  68. package/dist/solution/BaseSales/fulfillmentItemRules.d.ts +27 -0
  69. package/dist/solution/BaseSales/fulfillmentItemRules.js +750 -0
  70. package/dist/solution/BaseSales/index.d.ts +39 -16
  71. package/dist/solution/BaseSales/index.js +1754 -1154
  72. package/dist/solution/BaseSales/pickupTiming.d.ts +47 -0
  73. package/dist/solution/BaseSales/pickupTiming.js +616 -0
  74. package/dist/solution/BaseSales/types.d.ts +11 -0
  75. package/dist/solution/BaseSales/utils/parseSalesResponse.js +3 -0
  76. package/dist/solution/BookingByStep/index.d.ts +4 -2
  77. package/dist/solution/BookingByStep/index.js +8 -3
  78. package/dist/solution/BookingTicket/index.d.ts +8 -2
  79. package/dist/solution/BookingTicket/index.js +513 -436
  80. package/dist/solution/BookingTicket/utils/addProductDecision.d.ts +0 -1
  81. package/dist/solution/BookingTicket/utils/addProductDecision.js +1 -1
  82. package/dist/solution/BookingTicket/utils/cartView.js +3 -1
  83. package/dist/solution/OrderInvoicePreview/index.d.ts +66 -0
  84. package/dist/solution/OrderInvoicePreview/index.js +340 -0
  85. package/dist/solution/RegisterAndLogin/config.js +54 -11
  86. package/dist/solution/RegisterAndLogin/index.d.ts +2 -0
  87. package/dist/solution/RegisterAndLogin/index.js +1 -1
  88. package/dist/solution/RegisterAndLogin/utils.d.ts +12 -4
  89. package/dist/solution/RegisterAndLogin/utils.js +36 -16
  90. package/dist/solution/Sales/index.js +1 -1
  91. package/dist/solution/UnifiedBookingSales/businessAvailability.d.ts +27 -0
  92. package/dist/solution/UnifiedBookingSales/businessAvailability.js +292 -0
  93. package/dist/solution/UnifiedBookingSales/index.d.ts +36 -4
  94. package/dist/solution/UnifiedBookingSales/index.js +1714 -905
  95. package/dist/solution/UnifiedBookingSales/types.d.ts +16 -2
  96. package/dist/solution/VenueBooking/index.d.ts +15 -2
  97. package/dist/solution/VenueBooking/index.js +1062 -785
  98. package/dist/solution/VenueBooking/types.d.ts +2 -1
  99. package/dist/solution/VenueBooking/types.js +1 -0
  100. package/dist/solution/VenueBooking/utils/dateSummary.d.ts +1 -0
  101. package/dist/solution/VenueBooking/utils/dateSummary.js +7 -4
  102. package/dist/solution/VenueBooking/utils/smartPricing.d.ts +71 -0
  103. package/dist/solution/VenueBooking/utils/smartPricing.js +273 -0
  104. package/dist/solution/VenueBooking/utils/timeSlot.d.ts +1 -0
  105. package/dist/solution/VenueBooking/utils/timeSlot.js +6 -3
  106. package/dist/solution/index.d.ts +1 -0
  107. package/dist/solution/index.js +2 -1
  108. package/lib/index.d.ts +2 -0
  109. package/lib/index.js +21 -1
  110. package/lib/model/strategy/adapter/itemRule/adapter.d.ts +3 -1
  111. package/lib/model/strategy/adapter/itemRule/adapter.js +54 -4
  112. package/lib/model/strategy/adapter/itemRule/evaluator.d.ts +3 -1
  113. package/lib/model/strategy/adapter/itemRule/evaluator.js +9 -0
  114. package/lib/model/strategy/adapter/itemRule/type.d.ts +40 -1
  115. package/lib/model/strategy/adapter/itemRule/type.js +10 -0
  116. package/lib/modules/BookingContext/utils/productExtend.d.ts +7 -0
  117. package/lib/modules/BookingContext/utils/productExtend.js +45 -2
  118. package/lib/modules/BookingContext/utils/resources.js +1 -1
  119. package/lib/modules/BusinessAvailability/index.d.ts +30 -0
  120. package/lib/modules/BusinessAvailability/index.js +146 -0
  121. package/lib/modules/Cart/index.js +4 -2
  122. package/lib/modules/Cart/types.d.ts +2 -0
  123. package/lib/modules/Cart/utils/cartProduct.d.ts +3 -1
  124. package/lib/modules/Cart/utils/cartProduct.js +39 -20
  125. package/lib/modules/FulfillmentTiming/index.d.ts +11 -0
  126. package/lib/modules/FulfillmentTiming/index.js +359 -0
  127. package/lib/modules/FulfillmentTiming/types.d.ts +67 -0
  128. package/lib/modules/FulfillmentTiming/types.js +5 -0
  129. package/lib/modules/OpenData/types.d.ts +14 -0
  130. package/lib/modules/Order/index.d.ts +14 -2
  131. package/lib/modules/Order/index.js +240 -38
  132. package/lib/modules/Order/localEftposState.d.ts +13 -0
  133. package/lib/modules/Order/localEftposState.js +44 -0
  134. package/lib/modules/Order/pickupTiming.d.ts +46 -0
  135. package/lib/modules/Order/pickupTiming.js +61 -0
  136. package/lib/modules/Order/types.d.ts +30 -2
  137. package/lib/modules/Order/utils.js +21 -5
  138. package/lib/modules/Payment/index.js +3 -4
  139. package/lib/modules/Product/types.d.ts +11 -0
  140. package/lib/modules/ProductList/index.js +1 -1
  141. package/lib/modules/ResourcePlanner/planner.d.ts +2 -0
  142. package/lib/modules/ResourcePlanner/planner.js +252 -8
  143. package/lib/modules/ResourcePlanner/types.d.ts +29 -0
  144. package/lib/modules/Schedule/index.d.ts +8 -0
  145. package/lib/modules/Schedule/index.js +68 -12
  146. package/lib/modules/index.d.ts +1 -0
  147. package/lib/modules/index.js +11 -0
  148. package/lib/plugins/request.d.ts +7 -0
  149. package/lib/server/index.d.ts +1 -0
  150. package/lib/server/index.js +158 -37
  151. package/lib/server/modules/form/index.d.ts +19 -0
  152. package/lib/server/modules/form/index.js +73 -0
  153. package/lib/server/modules/form/types.d.ts +13 -0
  154. package/lib/server/modules/form/types.js +9 -0
  155. package/lib/server/modules/index.d.ts +3 -0
  156. package/lib/server/modules/index.js +15 -1
  157. package/lib/server/modules/order/index.d.ts +15 -0
  158. package/lib/server/modules/order/index.js +114 -3
  159. package/lib/server/modules/order/types.d.ts +1 -0
  160. package/lib/server/test.json +1 -1
  161. package/lib/server/utils/small-ticket.d.ts +1 -85
  162. package/lib/server/utils/small-ticket.js +9 -2305
  163. package/lib/shared/payment/loadPaymentMethods.d.ts +9 -0
  164. package/lib/shared/payment/loadPaymentMethods.js +40 -0
  165. package/lib/shared/receipt/customerInvoiceLanguages.d.ts +8 -0
  166. package/lib/shared/receipt/customerInvoiceLanguages.js +58 -0
  167. package/lib/shared/receipt/loadCustomerInvoiceLayout.d.ts +27 -0
  168. package/lib/shared/receipt/loadCustomerInvoiceLayout.js +124 -0
  169. package/lib/shared/receipt/small-ticket.d.ts +96 -0
  170. package/lib/shared/receipt/small-ticket.js +2546 -0
  171. package/lib/shared/receipt/templateVisibility.d.ts +23 -0
  172. package/lib/shared/receipt/templateVisibility.js +63 -0
  173. package/lib/shared/sales/loadSalesOrderSnapshot.d.ts +9 -0
  174. package/lib/shared/sales/loadSalesOrderSnapshot.js +22 -0
  175. package/lib/solution/BaseSales/fulfillmentItemRules.d.ts +27 -0
  176. package/lib/solution/BaseSales/fulfillmentItemRules.js +259 -0
  177. package/lib/solution/BaseSales/index.d.ts +39 -16
  178. package/lib/solution/BaseSales/index.js +333 -31
  179. package/lib/solution/BaseSales/pickupTiming.d.ts +47 -0
  180. package/lib/solution/BaseSales/pickupTiming.js +290 -0
  181. package/lib/solution/BaseSales/types.d.ts +11 -0
  182. package/lib/solution/BaseSales/utils/parseSalesResponse.js +3 -0
  183. package/lib/solution/BookingByStep/index.d.ts +4 -2
  184. package/lib/solution/BookingByStep/index.js +7 -3
  185. package/lib/solution/BookingTicket/index.d.ts +8 -2
  186. package/lib/solution/BookingTicket/index.js +65 -6
  187. package/lib/solution/BookingTicket/utils/addProductDecision.d.ts +0 -1
  188. package/lib/solution/BookingTicket/utils/addProductDecision.js +1 -1
  189. package/lib/solution/BookingTicket/utils/cartView.js +3 -1
  190. package/lib/solution/OrderInvoicePreview/index.d.ts +66 -0
  191. package/lib/solution/OrderInvoicePreview/index.js +246 -0
  192. package/lib/solution/RegisterAndLogin/config.js +57 -11
  193. package/lib/solution/RegisterAndLogin/index.d.ts +2 -0
  194. package/lib/solution/RegisterAndLogin/index.js +9 -1
  195. package/lib/solution/RegisterAndLogin/utils.d.ts +12 -4
  196. package/lib/solution/RegisterAndLogin/utils.js +24 -17
  197. package/lib/solution/Sales/index.js +1 -1
  198. package/lib/solution/UnifiedBookingSales/businessAvailability.d.ts +27 -0
  199. package/lib/solution/UnifiedBookingSales/businessAvailability.js +138 -0
  200. package/lib/solution/UnifiedBookingSales/index.d.ts +36 -4
  201. package/lib/solution/UnifiedBookingSales/index.js +561 -74
  202. package/lib/solution/UnifiedBookingSales/types.d.ts +16 -2
  203. package/lib/solution/VenueBooking/index.d.ts +15 -2
  204. package/lib/solution/VenueBooking/index.js +243 -96
  205. package/lib/solution/VenueBooking/types.d.ts +2 -1
  206. package/lib/solution/VenueBooking/types.js +1 -0
  207. package/lib/solution/VenueBooking/utils/dateSummary.d.ts +1 -0
  208. package/lib/solution/VenueBooking/utils/dateSummary.js +7 -4
  209. package/lib/solution/VenueBooking/utils/smartPricing.d.ts +71 -0
  210. package/lib/solution/VenueBooking/utils/smartPricing.js +224 -0
  211. package/lib/solution/VenueBooking/utils/timeSlot.d.ts +1 -0
  212. package/lib/solution/VenueBooking/utils/timeSlot.js +5 -2
  213. package/lib/solution/index.d.ts +1 -0
  214. package/lib/solution/index.js +11 -0
  215. 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])) {
@@ -463,6 +463,7 @@ export interface OrderData {
463
463
  id: number | string;
464
464
  tag: 'virtual_currency';
465
465
  product_id?: number | string;
466
+ code?: string;
466
467
  product_name: string;
467
468
  par_value: string;
468
469
  used_par_value: string;
@@ -132,7 +132,7 @@
132
132
  "contacts_info": null,
133
133
  "holder": null,
134
134
  "metadata": {},
135
- "delivery_type": "nil",
135
+ "delivery_type": "shop_service",
136
136
  "small_ticket_data_flag": 1,
137
137
  "need_sync": 1,
138
138
  "payment_info": {
@@ -1,85 +1 @@
1
- export interface SmallTicketShopInfo {
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';