@pisell/pisellos 2.3.104 → 2.3.106

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.
@@ -101,6 +101,9 @@ export interface AvailabilityOperatingHoursSnapshot {
101
101
  scheduleIds: AvailabilityId[];
102
102
  missingScheduleIds: AvailabilityId[];
103
103
  windows: AvailabilityResourceWindow[];
104
+ /** Schedule windows omitted only because their date is excluded. POS may use
105
+ * these to surface an unavailable, manually selectable candidate. */
106
+ excludedWindows?: AvailabilityResourceWindow[];
104
107
  }
105
108
  export interface AvailabilityResource {
106
109
  id: AvailabilityId;
@@ -110,6 +113,8 @@ export interface AvailabilityResource {
110
113
  resourceType: AvailabilityResourceType;
111
114
  capacity: number;
112
115
  windows: AvailabilityResourceWindow[];
116
+ /** Resource work windows omitted only by an excluded schedule date. */
117
+ excludedWindows?: AvailabilityResourceWindow[];
113
118
  raw?: Record<string, any>;
114
119
  }
115
120
  export interface AvailabilityOccupancy extends AvailabilityAbsoluteRange {
@@ -213,6 +218,8 @@ export interface ProductTimeRangeGroup {
213
218
  title?: string;
214
219
  kind: AvailabilityProductKind;
215
220
  slotStepMinutes?: number;
221
+ /** 单日查询对应营业窗口的最终结束时刻,不受资源排班是否为空影响。 */
222
+ operatingEndAt?: string;
216
223
  ranges: ProductTimeRange[];
217
224
  }
218
225
  export interface AvailabilityAssignment extends AvailabilityAbsoluteRange {
@@ -243,6 +250,25 @@ export interface GetProductTimeRangesRequest {
243
250
  }
244
251
  export interface GetProductTimeRangesRuntimeOptions {
245
252
  evaluatedAt?: string;
253
+ /**
254
+ * Internal POS capability: fixed-duration candidates start from the stable
255
+ * context anchor's current minute instead of rounding up to ten minutes, and
256
+ * that minute remains selectable during before-start cutoff evaluation.
257
+ * Other callers keep the legacy alignment and strict second-level cutoff.
258
+ */
259
+ useExactDurationCandidateMinute?: boolean;
260
+ /**
261
+ * Internal POS capability: allow explicit duration/start overrides to append
262
+ * a custom duration candidate for Session products. Fixed Session ranges are
263
+ * still returned unchanged. Callers outside the POS facade must leave this
264
+ * disabled.
265
+ */
266
+ allowSessionCustomRanges?: boolean;
267
+ /**
268
+ * Internal POS capability: materialize candidates whose schedule date was
269
+ * explicitly excluded, while availability evaluation keeps them unavailable.
270
+ */
271
+ allowExcludedScheduleDateOverride?: boolean;
246
272
  }
247
273
  export interface QueryAvailabilityBaseRequest {
248
274
  productIds?: AvailabilityId[];
@@ -1388,7 +1388,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
1388
1388
  // bundle子商品:保存到扁平化Map
1389
1389
  processedFlatItemsMap.set(flatItem._id, [_objectSpread(_objectSpread({}, flatItem), {}, {
1390
1390
  discount_list: isManualDiscount ? _this4.resolveDiscountListForManualOverride(((_flatItem$bundleItem8 = flatItem.bundleItem) === null || _flatItem$bundleItem8 === void 0 ? void 0 : _flatItem$bundleItem8.discount_list) || []) : _this4.filterDiscountListByType(((_flatItem$bundleItem9 = flatItem.bundleItem) === null || _flatItem$bundleItem9 === void 0 ? void 0 : _flatItem$bundleItem9.discount_list) || [], 'promotion'),
1391
- price: isManualDiscount ? flatItem.bundleItem.price : flatItem.bundleItem.original_price,
1391
+ price: flatItem.bundleItem.price,
1392
1392
  bundle_selling_price: (_flatItem$bundleItem$ = flatItem.bundleItem.bundle_selling_price) !== null && _flatItem$bundleItem$ !== void 0 ? _flatItem$bundleItem$ : isManualDiscount ? flatItem.bundleItem.price : flatItem.bundleItem.original_price,
1393
1393
  processed: true
1394
1394
  })]);
@@ -421,6 +421,7 @@ declare class Server {
421
421
  private shouldUseLocalOrderQuery;
422
422
  /**
423
423
  * 预约查询是否走本地:
424
+ * - 日历周/月/资源视图通过 compact_fields 显式标识,始终走远端;
424
425
  * - 当 sales_time_between 的开始和结束都不是今天时,走远端;
425
426
  * - 其余情况走本地。
426
427
  */
@@ -4262,12 +4262,14 @@ var Server = /*#__PURE__*/function () {
4262
4262
 
4263
4263
  /**
4264
4264
  * 预约查询是否走本地:
4265
+ * - 日历周/月/资源视图通过 compact_fields 显式标识,始终走远端;
4265
4266
  * - 当 sales_time_between 的开始和结束都不是今天时,走远端;
4266
4267
  * - 其余情况走本地。
4267
4268
  */
4268
4269
  }, {
4269
4270
  key: "shouldUseLocalBookingQuery",
4270
4271
  value: function shouldUseLocalBookingQuery(data) {
4272
+ if ((data === null || data === void 0 ? void 0 : data.compact_fields) === true) return false;
4271
4273
  var range = data === null || data === void 0 ? void 0 : data.sales_time_between;
4272
4274
  if (!Array.isArray(range) || range.length < 2) return true;
4273
4275
  return !this.isRangeBothNotToday(range[0], range[1]);
@@ -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,
@@ -130,8 +130,8 @@ export declare class UnifiedBookingSalesImpl extends BookingTicket {
130
130
  */
131
131
  clearSessionStorageOrderSnapshot(): void;
132
132
  /**
133
- * Kiosk 不能把已收款订单留在本地等待重试:默认直接等待云端 checkout。
134
- * 兼容仍需要 WebPOS 待同步模式的入口可显式传 checkoutSyncTaskEnabled: true。
133
+ * H5/Kiosk 不能把已收款订单留在本地等待重试,必须直接等待云端 checkout。
134
+ * 其它平台保持 WebPOS/POS 的本地待同步任务;显式 true 仍可强制使用本地任务。
135
135
  */
136
136
  protected shouldUseCheckoutSyncTask(): boolean;
137
137
  /** UnifiedBookingSales 的真实结账默认请求收据数据,供云端确认后再本地打印。 */
@@ -43,7 +43,7 @@ import { UnifiedBookingSalesHooks } from "./types";
43
43
  import { AvailabilityRemoteOccupancyCache } from "./remoteOccupancyCache";
44
44
  import { BookingTicket } from "../BookingTicket";
45
45
  import { addLocalCalendarDays, captureRuntimeOffsetMinutes, formatLocalDate, formatLocalDateTime, formatLocalTime, localDateTimeToScalar, localDateToScalar, localDateToScalarStart, parseLocalDate, parseLocalDateTime } from "../../modules/ResourcePlanner/localClock";
46
- import { isCustomerUserPlatform } from "../../utils/platform";
46
+ import { isCustomerUserPlatform, normalizeRuntimePlatform } from "../../utils/platform";
47
47
  import { ItemRuleEvaluator } from "../../model/strategy/adapter/itemRule";
48
48
  export * from "./types";
49
49
  export { AvailabilityError } from "../../modules/ResourcePlanner";
@@ -697,14 +697,9 @@ function normalizeResource(raw) {
697
697
  var id = (_ref5 = (_raw$resourceId = raw.resourceId) !== null && _raw$resourceId !== void 0 ? _raw$resourceId : raw.resource_id) !== null && _ref5 !== void 0 ? _ref5 : raw.id;
698
698
  if (id === undefined || id === null || id === '') return null;
699
699
  var rawWindows = raw.windows || raw.times || [];
700
- return {
701
- id: id,
702
- formId: (_ref6 = (_raw$formId = raw.formId) !== null && _raw$formId !== void 0 ? _raw$formId : raw.form_id) !== null && _ref6 !== void 0 ? _ref6 : raw.resource_form_id,
703
- name: raw.resourceName || raw.main_field || raw.name || raw.title,
704
- code: raw.code,
705
- resourceType: normalizeResourceType(raw.type || raw.resourceType),
706
- capacity: Math.max(1, Number(raw.capacity || raw.max_capacity || 1) || 1),
707
- windows: (Array.isArray(rawWindows) ? rawWindows : []).flatMap(function (window) {
700
+ var rawExcludedWindows = raw.excludedWindows || raw.excluded_windows || [];
701
+ var normalizeWindows = function normalizeWindows(windows) {
702
+ return (Array.isArray(windows) ? windows : []).flatMap(function (window) {
708
703
  var range = normalizeAvailabilityLocalDateTimeRange({
709
704
  startAt: window.startAt || window.start_at || window.start,
710
705
  endAt: window.endAt || window.end_at || window.end,
@@ -718,7 +713,17 @@ function normalizeResource(raw) {
718
713
  source: window.source,
719
714
  raw: window
720
715
  }];
721
- }),
716
+ });
717
+ };
718
+ return {
719
+ id: id,
720
+ formId: (_ref6 = (_raw$formId = raw.formId) !== null && _raw$formId !== void 0 ? _raw$formId : raw.form_id) !== null && _ref6 !== void 0 ? _ref6 : raw.resource_form_id,
721
+ name: raw.resourceName || raw.main_field || raw.name || raw.title,
722
+ code: raw.code,
723
+ resourceType: normalizeResourceType(raw.type || raw.resourceType),
724
+ capacity: Math.max(1, Number(raw.capacity || raw.max_capacity || 1) || 1),
725
+ windows: normalizeWindows(rawWindows),
726
+ excludedWindows: normalizeWindows(rawExcludedWindows),
722
727
  raw: raw
723
728
  };
724
729
  }
@@ -742,6 +747,16 @@ function dateRangeDays(dateRange) {
742
747
  }
743
748
  return dates;
744
749
  }
750
+ function getExcludedScheduleDateOverrideTimePoints(date, schedule) {
751
+ var _schedule$repeat_rule;
752
+ if (!((_schedule$repeat_rule = schedule.repeat_rule) !== null && _schedule$repeat_rule !== void 0 && (_schedule$repeat_rule = _schedule$repeat_rule.excluded_date) !== null && _schedule$repeat_rule !== void 0 && _schedule$repeat_rule.length)) return [];
753
+ if (getScheduleStartEndTimePoints(date, [schedule]).length > 0) return [];
754
+ return getScheduleStartEndTimePoints(date, [_objectSpread(_objectSpread({}, schedule), {}, {
755
+ repeat_rule: _objectSpread(_objectSpread({}, schedule.repeat_rule), {}, {
756
+ excluded_date: []
757
+ })
758
+ })]);
759
+ }
745
760
  function normalizeResourceOccupancy(rawEvent, resourceId) {
746
761
  var _ref9, _ref10, _rawEvent$start_at, _ref11, _ref12, _rawEvent$end_at, _ref13, _ref14, _rawEvent$pax, _rawEvent$schedule_ev, _ref15, _rawEvent$schedule_ev2, _ref16, _rawEvent$booking_uid, _rawEvent$metadata, _ref17, _rawEvent$product_uid, _rawEvent$metadata2;
747
762
  var source = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'remote';
@@ -848,7 +863,30 @@ export function buildAvailabilityResourcesFromV2(params) {
848
863
  });
849
864
  });
850
865
  });
866
+ var excludedWindows = dates.flatMap(function (date) {
867
+ return schedules.flatMap(function (schedule) {
868
+ return getExcludedScheduleDateOverrideTimePoints(date, schedule).flatMap(function (slot) {
869
+ var range = normalizeAvailabilityLocalDateTimeRange({
870
+ startAt: slot.start_at,
871
+ endAt: slot.end_at,
872
+ fixedOffsetMinutes: fixedOffsetMinutes,
873
+ rollOverEnd: true
874
+ });
875
+ if (!range) return [];
876
+ return [{
877
+ startAt: range.startAt,
878
+ endAt: range.endAt,
879
+ source: "resource_schedule_excluded:".concat(schedule.id),
880
+ raw: {
881
+ scheduleId: schedule.id,
882
+ excludedDate: date
883
+ }
884
+ }];
885
+ });
886
+ });
887
+ });
851
888
  resource.windows = materializedWindows.length > 0 ? materializedWindows : explicitWindows;
889
+ resource.excludedWindows = [].concat(_toConsumableArray(resource.excludedWindows || []), _toConsumableArray(excludedWindows));
852
890
  if (resource.windows.length === 0 && missingScheduleIds.length > 0) {
853
891
  resource.windows = buildResourceWindowFallbackTimes({
854
892
  raw: raw,
@@ -1053,7 +1091,7 @@ function buildBookingFromAvailabilitySelection(params) {
1053
1091
  var timeSlotId = (_candidate$primarySch3 = (_candidate$primarySch4 = candidate.primaryScheduleRef) === null || _candidate$primarySch4 === void 0 ? void 0 : _candidate$primarySch4.timeSlotId) !== null && _candidate$primarySch3 !== void 0 ? _candidate$primarySch3 : (_assignments$find2 = assignments.find(function (assignment) {
1054
1092
  return assignment.timeSlotId != null;
1055
1093
  })) === null || _assignments$find2 === void 0 ? void 0 : _assignments$find2.timeSlotId;
1056
- if (product.kind === 'session' && scheduleId == null) {
1094
+ if (product.kind === 'session' && candidate.source === 'session_schedule' && scheduleId == null) {
1057
1095
  throw new AvailabilityError('REVALIDATION_FAILED', 'session 候选缺少真实 schedule identity', {
1058
1096
  productId: product.id,
1059
1097
  candidateKey: candidate.key,
@@ -1062,15 +1100,16 @@ function buildBookingFromAvailabilitySelection(params) {
1062
1100
  }
1063
1101
  var normalizedHolder = holder && _typeof(holder) === 'object' ? cloneDeep(holder) : undefined;
1064
1102
  var normalizedHolderIds = Array.isArray(holderIds) ? cloneDeep(holderIds) : holderIds;
1065
- return _objectSpread(_objectSpread({
1103
+ return _objectSpread(_objectSpread(_objectSpread({
1066
1104
  start_date: bookingStartAt.slice(0, 10),
1067
1105
  start_time: bookingStartAt.slice(11, 16),
1068
1106
  end_date: bookingEndAt.slice(0, 10),
1069
1107
  end_time: bookingEndAt.slice(11, 16),
1070
1108
  duration: Math.max(1, Math.trunc((endScalar - startScalar) / (60 * 1000))),
1071
- like_status: 'common',
1109
+ like_status: 'common'
1110
+ }, product.kind === 'session' && candidate.source === 'duration_window' ? {} : {
1072
1111
  schedule_id: scheduleId !== null && scheduleId !== void 0 ? scheduleId : 0
1073
- }, normalizedHolder ? {
1112
+ }), normalizedHolder ? {
1074
1113
  holder: normalizedHolder
1075
1114
  } : {}), {}, {
1076
1115
  resources: assignments.map(function (assignment) {
@@ -1115,7 +1154,7 @@ function buildBookingFromAvailabilitySelection(params) {
1115
1154
  } : {})
1116
1155
  });
1117
1156
  }
1118
- var POS_OVERRIDABLE_AVAILABILITY_CONFLICT_CODES = new Set(['past', 'booking_cutoff', 'resource_full', 'resource_unavailable', 'resource_capacity_exceeded',
1157
+ var POS_OVERRIDABLE_AVAILABILITY_CONFLICT_CODES = new Set(['past', 'booking_cutoff', 'schedule_excluded_date', 'resource_full', 'resource_unavailable', 'resource_capacity_exceeded',
1119
1158
  // A required group whose selected resource is outside its window is surfaced
1120
1159
  // as missing_resource at group level. Structural validation below still
1121
1160
  // rejects a genuinely missing selection.
@@ -1867,15 +1906,17 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
1867
1906
  }
1868
1907
 
1869
1908
  /**
1870
- * Kiosk 不能把已收款订单留在本地等待重试:默认直接等待云端 checkout。
1871
- * 兼容仍需要 WebPOS 待同步模式的入口可显式传 checkoutSyncTaskEnabled: true。
1909
+ * H5/Kiosk 不能把已收款订单留在本地等待重试,必须直接等待云端 checkout。
1910
+ * 其它平台保持 WebPOS/POS 的本地待同步任务;显式 true 仍可强制使用本地任务。
1872
1911
  */
1873
1912
  }, {
1874
1913
  key: "shouldUseCheckoutSyncTask",
1875
1914
  value: function shouldUseCheckoutSyncTask() {
1876
- var _this$otherParams15;
1915
+ var _this$otherParams15, _this$otherParams16;
1877
1916
  var configured = (_this$otherParams15 = this.otherParams) === null || _this$otherParams15 === void 0 ? void 0 : _this$otherParams15.checkoutSyncTaskEnabled;
1878
- return typeof configured === 'boolean' ? configured : false;
1917
+ if (configured === true) return true;
1918
+ var platform = normalizeRuntimePlatform((_this$otherParams16 = this.otherParams) === null || _this$otherParams16 === void 0 ? void 0 : _this$otherParams16.platform);
1919
+ return platform !== 'h5' && platform !== 'kiosk';
1879
1920
  }
1880
1921
 
1881
1922
  /** UnifiedBookingSales 的真实结账默认请求收据数据,供云端确认后再本地打印。 */
@@ -2029,8 +2070,8 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
2029
2070
  }, {
2030
2071
  key: "isAuthenticatedCustomerUserPlatform",
2031
2072
  value: function isAuthenticatedCustomerUserPlatform() {
2032
- var _this$otherParams16;
2033
- return isCustomerUserPlatform((_this$otherParams16 = this.otherParams) === null || _this$otherParams16 === void 0 ? void 0 : _this$otherParams16.platform);
2073
+ var _this$otherParams17;
2074
+ return isCustomerUserPlatform((_this$otherParams17 = this.otherParams) === null || _this$otherParams17 === void 0 ? void 0 : _this$otherParams17.platform);
2034
2075
  }
2035
2076
  }, {
2036
2077
  key: "resolveDiscountOrderIdentity",
@@ -2208,13 +2249,13 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
2208
2249
  key: "getOpenData",
2209
2250
  value: function () {
2210
2251
  var _getOpenData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {
2211
- var _this$otherParams17, _this$otherParams18, _this$store$openData;
2252
+ var _this$otherParams18, _this$otherParams19, _this$store$openData;
2212
2253
  var businessCode, channel, target, cachedData;
2213
2254
  return _regeneratorRuntime().wrap(function _callee12$(_context12) {
2214
2255
  while (1) switch (_context12.prev = _context12.next) {
2215
2256
  case 0:
2216
- businessCode = String(((_this$otherParams17 = this.otherParams) === null || _this$otherParams17 === void 0 ? void 0 : _this$otherParams17.businessCode) || '').trim();
2217
- channel = String(((_this$otherParams18 = this.otherParams) === null || _this$otherParams18 === void 0 ? void 0 : _this$otherParams18.channel) || '').trim();
2257
+ businessCode = String(((_this$otherParams18 = this.otherParams) === null || _this$otherParams18 === void 0 ? void 0 : _this$otherParams18.businessCode) || '').trim();
2258
+ channel = String(((_this$otherParams19 = this.otherParams) === null || _this$otherParams19 === void 0 ? void 0 : _this$otherParams19.channel) || '').trim();
2218
2259
  if (!(!businessCode || !channel)) {
2219
2260
  _context12.next = 4;
2220
2261
  break;
@@ -2381,7 +2422,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
2381
2422
  key: "resolveProductAllergyRequirement",
2382
2423
  value: (function () {
2383
2424
  var _resolveProductAllergyRequirement = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16(params) {
2384
- var _this$otherParams19, _this$getOrderProduct, _runtimePax$total, _runtimePax$adult, _runtimePax$child, _ref35, _runtimeConfig$servic, _this$otherParams20, _ref36, _ref37, _params$channel, _this$otherParams21, _this$otherParams22, _runtimeConfig$submis;
2425
+ var _this$otherParams20, _this$getOrderProduct, _runtimePax$total, _runtimePax$adult, _runtimePax$child, _ref35, _runtimeConfig$servic, _this$otherParams21, _ref36, _ref37, _params$channel, _this$otherParams22, _this$otherParams23, _runtimeConfig$submis;
2385
2426
  var productId, strategyConfigs, productVariantId, runtimeConfig, runtimePax, cartItems;
2386
2427
  return _regeneratorRuntime().wrap(function _callee16$(_context16) {
2387
2428
  while (1) switch (_context16.prev = _context16.next) {
@@ -2404,7 +2445,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
2404
2445
  return _context16.abrupt("return", null);
2405
2446
  case 8:
2406
2447
  productVariantId = normalizePositiveInteger(params.productVariantId);
2407
- runtimeConfig = ((_this$otherParams19 = this.otherParams) === null || _this$otherParams19 === void 0 ? void 0 : _this$otherParams19.itemRule) || {};
2448
+ runtimeConfig = ((_this$otherParams20 = this.otherParams) === null || _this$otherParams20 === void 0 ? void 0 : _this$otherParams20.itemRule) || {};
2408
2449
  runtimePax = runtimeConfig.pax || {};
2409
2450
  cartItems = (((_this$getOrderProduct = this.getOrderProducts) === null || _this$getOrderProduct === void 0 ? void 0 : _this$getOrderProduct.call(this)) || []).map(function (item) {
2410
2451
  var _item$product_id, _item$product_variant, _ref34, _item$num;
@@ -2423,8 +2464,8 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
2423
2464
  child: Number((_runtimePax$child = runtimePax.child) !== null && _runtimePax$child !== void 0 ? _runtimePax$child : 0) || 0
2424
2465
  },
2425
2466
  cartItems: cartItems,
2426
- serviceType: String((_ref35 = (_runtimeConfig$servic = runtimeConfig.serviceType) !== null && _runtimeConfig$servic !== void 0 ? _runtimeConfig$servic : (_this$otherParams20 = this.otherParams) === null || _this$otherParams20 === void 0 ? void 0 : _this$otherParams20.serviceType) !== null && _ref35 !== void 0 ? _ref35 : ''),
2427
- channel: String((_ref36 = (_ref37 = (_params$channel = params.channel) !== null && _params$channel !== void 0 ? _params$channel : (_this$otherParams21 = this.otherParams) === null || _this$otherParams21 === void 0 ? void 0 : _this$otherParams21.channel) !== null && _ref37 !== void 0 ? _ref37 : (_this$otherParams22 = this.otherParams) === null || _this$otherParams22 === void 0 ? void 0 : _this$otherParams22.platform) !== null && _ref36 !== void 0 ? _ref36 : ''),
2467
+ serviceType: String((_ref35 = (_runtimeConfig$servic = runtimeConfig.serviceType) !== null && _runtimeConfig$servic !== void 0 ? _runtimeConfig$servic : (_this$otherParams21 = this.otherParams) === null || _this$otherParams21 === void 0 ? void 0 : _this$otherParams21.serviceType) !== null && _ref35 !== void 0 ? _ref35 : ''),
2468
+ channel: String((_ref36 = (_ref37 = (_params$channel = params.channel) !== null && _params$channel !== void 0 ? _params$channel : (_this$otherParams22 = this.otherParams) === null || _this$otherParams22 === void 0 ? void 0 : _this$otherParams22.channel) !== null && _ref37 !== void 0 ? _ref37 : (_this$otherParams23 = this.otherParams) === null || _this$otherParams23 === void 0 ? void 0 : _this$otherParams23.platform) !== null && _ref36 !== void 0 ? _ref36 : ''),
2428
2469
  currentProduct: _objectSpread({
2429
2470
  product_id: productId
2430
2471
  }, productVariantId ? {
@@ -3316,12 +3357,35 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
3316
3357
  }] : [];
3317
3358
  });
3318
3359
  });
3319
- return {
3360
+ var excludedWindows = dateRangeDays(params.dateRange).flatMap(function (date) {
3361
+ return schedules.flatMap(function (schedule) {
3362
+ return getExcludedScheduleDateOverrideTimePoints(date, schedule).flatMap(function (slot) {
3363
+ var range = normalizeAvailabilityLocalDateTimeRange({
3364
+ startAt: slot.start_at,
3365
+ endAt: slot.end_at,
3366
+ fixedOffsetMinutes: _this4.getAvailabilityRuntimeOffsetMinutes(),
3367
+ rollOverEnd: true
3368
+ });
3369
+ return range ? [{
3370
+ startAt: range.startAt,
3371
+ endAt: range.endAt,
3372
+ source: "operating_schedule_excluded:".concat(schedule.id),
3373
+ raw: {
3374
+ scheduleId: schedule.id,
3375
+ excludedDate: date
3376
+ }
3377
+ }] : [];
3378
+ });
3379
+ });
3380
+ });
3381
+ return _objectSpread({
3320
3382
  source: descriptor.source,
3321
3383
  scheduleIds: _toConsumableArray(descriptor.scheduleIds),
3322
3384
  missingScheduleIds: missingScheduleIds,
3323
3385
  windows: windows
3324
- };
3386
+ }, excludedWindows.length > 0 ? {
3387
+ excludedWindows: excludedWindows
3388
+ } : {});
3325
3389
  }
3326
3390
  }, {
3327
3391
  key: "loadAvailabilityProducts",
@@ -4466,13 +4530,14 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
4466
4530
  value: (function () {
4467
4531
  var _getProductTimeRanges = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee40(contextId) {
4468
4532
  var _this$otherParams$pla,
4469
- _this$otherParams23,
4533
+ _this$otherParams24,
4470
4534
  _this10 = this;
4471
4535
  var request,
4472
4536
  _yield$this$ensureAva,
4473
4537
  context,
4474
4538
  projectionEntry,
4475
4539
  contextVersion,
4540
+ isPosAvailabilityRequest,
4476
4541
  allowOutsideOperatingHoursForRequestedStartTimes,
4477
4542
  _args40 = arguments;
4478
4543
  return _regeneratorRuntime().wrap(function _callee40$(_context40) {
@@ -4486,13 +4551,17 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
4486
4551
  context = _yield$this$ensureAva.context;
4487
4552
  projectionEntry = _yield$this$ensureAva.projectionEntry;
4488
4553
  contextVersion = context.activeVersion;
4489
- allowOutsideOperatingHoursForRequestedStartTimes = String((_this$otherParams$pla = (_this$otherParams23 = this.otherParams) === null || _this$otherParams23 === void 0 ? void 0 : _this$otherParams23.platform) !== null && _this$otherParams$pla !== void 0 ? _this$otherParams$pla : '').trim().toLowerCase() === 'pos' && Object.values(request.durationStartTimesByProductId || {}).some(function (startTimes) {
4554
+ isPosAvailabilityRequest = String((_this$otherParams$pla = (_this$otherParams24 = this.otherParams) === null || _this$otherParams24 === void 0 ? void 0 : _this$otherParams24.platform) !== null && _this$otherParams$pla !== void 0 ? _this$otherParams$pla : '').trim().toLowerCase() === 'pos';
4555
+ allowOutsideOperatingHoursForRequestedStartTimes = isPosAvailabilityRequest && Object.values(request.durationStartTimesByProductId || {}).some(function (startTimes) {
4490
4556
  return Array.isArray(startTimes) && startTimes.length > 0;
4491
4557
  });
4492
4558
  return _context40.abrupt("return", getProjectionProductTimeRanges(projectionEntry.projection, _objectSpread(_objectSpread({}, request), allowOutsideOperatingHoursForRequestedStartTimes ? {
4493
4559
  allowOutsideOperatingHoursForRequestedStartTimes: true
4494
4560
  } : {}), {
4495
- evaluatedAt: this.getAvailabilityRuntimeDateTime()
4561
+ evaluatedAt: this.getAvailabilityRuntimeDateTime(),
4562
+ useExactDurationCandidateMinute: isPosAvailabilityRequest,
4563
+ allowSessionCustomRanges: isPosAvailabilityRequest,
4564
+ allowExcludedScheduleDateOverride: isPosAvailabilityRequest
4496
4565
  }).map(function (group) {
4497
4566
  return _objectSpread(_objectSpread({}, group), {}, {
4498
4567
  ranges: group.ranges.map(function (candidate) {
@@ -4500,7 +4569,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
4500
4569
  })
4501
4570
  });
4502
4571
  }));
4503
- case 9:
4572
+ case 10:
4504
4573
  case "end":
4505
4574
  return _context40.stop();
4506
4575
  }
@@ -4515,7 +4584,8 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
4515
4584
  key: "queryBookingAvailability",
4516
4585
  value: (function () {
4517
4586
  var _queryBookingAvailability = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee41(contextId, request) {
4518
- var _yield$this$ensureAva2, context, projectionEntry, refreshed, result, contextVersion, contextualResult;
4587
+ var _this$otherParams$pla2, _this$otherParams25;
4588
+ var _yield$this$ensureAva2, context, projectionEntry, refreshed, isPosAvailabilityRequest, result, contextVersion, contextualResult;
4519
4589
  return _regeneratorRuntime().wrap(function _callee41$(_context41) {
4520
4590
  while (1) switch (_context41.prev = _context41.next) {
4521
4591
  case 0:
@@ -4527,7 +4597,11 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
4527
4597
  projectionEntry = _yield$this$ensureAva2.projectionEntry;
4528
4598
  refreshed = _yield$this$ensureAva2.refreshed;
4529
4599
  this.assertContextualQueryFreshness(context, request);
4530
- result = queryAvailabilityProjection(projectionEntry.projection, request);
4600
+ isPosAvailabilityRequest = String((_this$otherParams$pla2 = (_this$otherParams25 = this.otherParams) === null || _this$otherParams25 === void 0 ? void 0 : _this$otherParams25.platform) !== null && _this$otherParams$pla2 !== void 0 ? _this$otherParams$pla2 : '').trim().toLowerCase() === 'pos';
4601
+ result = queryAvailabilityProjection(projectionEntry.projection, request, {
4602
+ useExactDurationCandidateMinute: isPosAvailabilityRequest,
4603
+ allowExcludedScheduleDateOverride: isPosAvailabilityRequest
4604
+ });
4531
4605
  contextVersion = context.activeVersion;
4532
4606
  contextualResult = result.target === 'time' ? _objectSpread(_objectSpread({}, result), {}, {
4533
4607
  data: result.data.map(function (group) {
@@ -4559,7 +4633,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
4559
4633
  contextVersion: contextVersion,
4560
4634
  refreshed: refreshed
4561
4635
  }));
4562
- case 11:
4636
+ case 12:
4563
4637
  case "end":
4564
4638
  return _context41.stop();
4565
4639
  }
@@ -4636,7 +4710,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
4636
4710
  key: "commitAvailabilitySelection",
4637
4711
  value: (function () {
4638
4712
  var _commitAvailabilitySelection = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee42(contextId, params) {
4639
- var normalizedContextId, _params$bookingCount, _ref51, _params$orderProduct$, _params$orderProduct, _params$orderProduct2, _params$orderProduct3, _params$orderProduct$2, _params$orderProduct4, _params$orderProduct5, _editingLine$product_, _baseProjection$meta$, _refreshedProjection$, _baseProjection$meta$2, _this$otherParams$pla2, _this$otherParams24, _ref52, _params$orderProduct$3, _params$orderProduct6, _existingBooking$meta, _ref53, _ref54, _params$orderProduct$4, _params$orderProduct7, _params$orderProduct8, _existingBooking$meta2, _existingBooking$hold, bookingCount, orderProductQuantity, partySize, _yield$this$ensureAva3, context, projectionEntry, refreshed, boundEditingUids, orderProductId, editingLine, _editingLine$product_2, baseProjection, commitWriteGuard, prepareParams, fallbackResources, commitSnapshot, refreshedProjection, _baseProjection$meta$3, latestContext, candidateDurationMinutes, candidateStartTime, allowPosAvailabilityOverride, refreshedRanges, refreshedCandidateBase, product, validation, forced, capacityConflict, revalidationEntry, revalidatedContext, refreshedCandidate, existingBooking, existingBookingUid, booking, transformed, productLineUid, bookingUid, productLineUids, bookingUids, _transformed$product_, _transformed$product_2, _transformed$product_3, _ref55, _transformed$product_4, _this$getTempOrder4, _this$getTempOrder5, _params$salesNotes, _this$getTempOrder6, beforeProductLineUids, beforeBookingUids, products, addedLines, addedBookings, nextContext, result;
4713
+ var normalizedContextId, _params$bookingCount, _ref51, _params$orderProduct$, _params$orderProduct, _params$orderProduct2, _params$orderProduct3, _params$orderProduct$2, _params$orderProduct4, _params$orderProduct5, _editingLine$product_, _baseProjection$meta$, _refreshedProjection$, _baseProjection$meta$2, _this$otherParams$pla3, _this$otherParams26, _ref52, _params$orderProduct$3, _params$orderProduct6, _existingBooking$meta, _ref53, _ref54, _params$orderProduct$4, _params$orderProduct7, _params$orderProduct8, _existingBooking$meta2, _existingBooking$hold, bookingCount, orderProductQuantity, partySize, _yield$this$ensureAva3, context, projectionEntry, refreshed, boundEditingUids, orderProductId, editingLine, _editingLine$product_2, baseProjection, commitWriteGuard, prepareParams, fallbackResources, commitSnapshot, refreshedProjection, _baseProjection$meta$3, latestContext, candidateDurationMinutes, candidateStartTime, allowPosAvailabilityOverride, refreshedRanges, refreshedCandidateBase, product, validation, forced, capacityConflict, revalidationEntry, revalidatedContext, refreshedCandidate, existingBooking, existingBookingUid, booking, transformed, productLineUid, bookingUid, productLineUids, bookingUids, _transformed$product_, _transformed$product_2, _transformed$product_3, _ref55, _transformed$product_4, _this$getTempOrder4, _this$getTempOrder5, _params$salesNotes, _this$getTempOrder6, beforeProductLineUids, beforeBookingUids, products, addedLines, addedBookings, nextContext, result;
4640
4714
  return _regeneratorRuntime().wrap(function _callee42$(_context42) {
4641
4715
  while (1) switch (_context42.prev = _context42.next) {
4642
4716
  case 0:
@@ -4866,7 +4940,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
4866
4940
  this.assertAvailabilityCommitWriteCAS(commitWriteGuard);
4867
4941
  candidateDurationMinutes = getCandidateDurationMinutes(params.candidate);
4868
4942
  candidateStartTime = getCandidateStartTime(params.candidate);
4869
- allowPosAvailabilityOverride = String((_this$otherParams$pla2 = (_this$otherParams24 = this.otherParams) === null || _this$otherParams24 === void 0 ? void 0 : _this$otherParams24.platform) !== null && _this$otherParams$pla2 !== void 0 ? _this$otherParams$pla2 : '').trim().toLowerCase() === 'pos';
4943
+ allowPosAvailabilityOverride = String((_this$otherParams$pla3 = (_this$otherParams26 = this.otherParams) === null || _this$otherParams26 === void 0 ? void 0 : _this$otherParams26.platform) !== null && _this$otherParams$pla3 !== void 0 ? _this$otherParams$pla3 : '').trim().toLowerCase() === 'pos';
4870
4944
  refreshedRanges = getProjectionProductTimeRanges(refreshedProjection, _objectSpread({
4871
4945
  productIds: [params.candidate.productId],
4872
4946
  dateRange: {
@@ -4879,7 +4953,11 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
4879
4953
  durationStartTimesByProductId: _defineProperty({}, String(params.candidate.productId), [candidateStartTime])
4880
4954
  }, allowPosAvailabilityOverride ? {
4881
4955
  allowOutsideOperatingHoursForRequestedStartTimes: true
4882
- } : {}) : {}) : {})).flatMap(function (group) {
4956
+ } : {}) : {}) : {}), {
4957
+ useExactDurationCandidateMinute: allowPosAvailabilityOverride,
4958
+ allowSessionCustomRanges: allowPosAvailabilityOverride,
4959
+ allowExcludedScheduleDateOverride: allowPosAvailabilityOverride
4960
+ }).flatMap(function (group) {
4883
4961
  return group.ranges;
4884
4962
  });
4885
4963
  refreshedCandidateBase = refreshedRanges.find(function (candidate) {
@@ -4911,6 +4989,9 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
4911
4989
  requirementSelections: params.requirementSelections,
4912
4990
  partySize: partySize,
4913
4991
  bookingCount: bookingCount
4992
+ }, {
4993
+ useExactDurationCandidateMinute: allowPosAvailabilityOverride,
4994
+ allowExcludedScheduleDateOverride: allowPosAvailabilityOverride
4914
4995
  });
4915
4996
  if (allowPosAvailabilityOverride && !validation.ok && validation.conflicts.every(function (conflict) {
4916
4997
  return POS_OVERRIDABLE_AVAILABILITY_CONFLICT_CODES.has(conflict.code);
@@ -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";
@@ -5122,6 +5122,23 @@ class OrderModule extends _BaseModule.BaseModule {
5122
5122
  row.metadata.booking_uid = row.booking_uid;
5123
5123
  }
5124
5124
  row = (0, _bundleDiscountHydration.restoreHydratedBundleDiscounts)(row, _utils.normalizeOrderProductDiscountList);
5125
+ const rawOriginalPrice = Number(row.original_price);
5126
+ const rawSellingPrice = Number(row.selling_price);
5127
+ const hasProductDiscounts = Array.isArray(row.discount_list) && row.discount_list.length > 0;
5128
+ const hasBundleDiscounts = row.product_bundle.some(bundle => Array.isArray(bundle?.discount_list) && bundle.discount_list.length > 0);
5129
+ const isUndiscountedV2Line = String(row.metadata.price_schema_version) === '2' && Number.isFinite(rawOriginalPrice) && Number.isFinite(rawSellingPrice) && new _decimal.default(rawOriginalPrice).eq(rawSellingPrice) && !hasProductDiscounts && !hasBundleDiscounts;
5130
+ if (isUndiscountedV2Line) {
5131
+ const hasPriceValue = value => value !== undefined && value !== null && value !== '';
5132
+ row.product_bundle = row.product_bundle.map(bundle => {
5133
+ if (!bundle || (0, _utils.isMarkdownBundle)(bundle) || hasPriceValue(bundle.original_price) || hasPriceValue(bundle.product_price) || !hasPriceValue(bundle.bundle_selling_price)) {
5134
+ return bundle;
5135
+ }
5136
+ return {
5137
+ ...bundle,
5138
+ original_price: bundle.bundle_selling_price
5139
+ };
5140
+ });
5141
+ }
5125
5142
  const existingIdentity = row.metadata.unique_identification_number || row.unique_identification_number;
5126
5143
  if (!existingIdentity) {
5127
5144
  row.metadata.unique_identification_number = (0, _utils.createUuidV4)();