@pisell/pisellos 0.10.37 → 0.10.38

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.
@@ -535,7 +535,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
535
535
  generateIdempotencyToken(): string;
536
536
  syncPaymentsToOrder<T = any>(params: SyncPaymentsToOrderParams): Promise<SyncPaymentsToOrderResult<T>>;
537
537
  createOrder(params: CommitOrderParams['query']): {
538
- type: "virtual" | "appointment_booking";
538
+ type: "appointment_booking" | "virtual";
539
539
  platform: string;
540
540
  sales_channel: string;
541
541
  order_sales_channel: string;
@@ -41,6 +41,7 @@ var LABELS = {
41
41
  giftCard: 'Gift card',
42
42
  pointCard: 'Point card',
43
43
  balance: 'Balance',
44
+ validity: 'Validity',
44
45
  remainingAmount: 'Remaining amount',
45
46
  redeemPoints: 'Redeem points',
46
47
  remainingPoints: 'Points balance',
@@ -79,6 +80,7 @@ var LABELS = {
79
80
  giftCard: '礼品卡',
80
81
  pointCard: '积分卡',
81
82
  balance: '余额',
83
+ validity: '有效期',
82
84
  remainingAmount: '剩余金额',
83
85
  redeemPoints: '本次使用积分',
84
86
  remainingPoints: '积分余额',
@@ -117,6 +119,7 @@ var LABELS = {
117
119
  giftCard: '禮品卡',
118
120
  pointCard: '積分卡',
119
121
  balance: '餘額',
122
+ validity: '有效期',
120
123
  remainingAmount: '剩餘金額',
121
124
  redeemPoints: '本次使用積分',
122
125
  remainingPoints: '積分餘額',
@@ -153,6 +156,7 @@ var LABELS = {
153
156
  giftCard: 'ギフトカード',
154
157
  pointCard: 'ポイントカード',
155
158
  balance: '残高',
159
+ validity: '有効期限',
156
160
  remainingAmount: '残高',
157
161
  redeemPoints: '利用ポイント',
158
162
  remainingPoints: 'ポイント残高',
@@ -190,6 +194,7 @@ var LABELS = {
190
194
  giftCard: 'Cartão-presente',
191
195
  pointCard: 'Cartão de pontos',
192
196
  balance: 'Saldo',
197
+ validity: 'Validade',
193
198
  remainingAmount: 'Saldo restante',
194
199
  redeemPoints: 'Pontos utilizados',
195
200
  remainingPoints: 'Saldo de pontos',
@@ -671,7 +676,7 @@ function normalizeProductCombinations(params) {
671
676
  parentProduct = params.parentProduct;
672
677
  var bundles = Array.isArray(product.product_bundle) ? product.product_bundle : [];
673
678
  return bundles.map(function (bundle) {
674
- var _ref26, _bundle$num, _bundle$metadata;
679
+ var _ref26, _bundle$num;
675
680
  var combinationsOptions = normalizeProductOptions({
676
681
  product: {},
677
682
  locale: locale,
@@ -690,7 +695,7 @@ function normalizeProductCombinations(params) {
690
695
  var quantity = toNumber((_ref26 = (_bundle$num = bundle.num) !== null && _bundle$num !== void 0 ? _bundle$num : bundle.quantity) !== null && _ref26 !== void 0 ? _ref26 : 1, 1);
691
696
  var formattedPrice = formatBundlePrice(bundle, currencySymbol);
692
697
  var optionsTotal = sumNormalizedOptionTotals(combinationsOptions, currencySymbol);
693
- var explicitBasePrice = firstPresentValue(bundle.base_price, (_bundle$metadata = bundle.metadata) === null || _bundle$metadata === void 0 ? void 0 : _bundle$metadata.source_product_price);
698
+ var explicitBasePrice = resolveCombinationBasePrice(bundle);
694
699
  var basePrice = isPresentId(explicitBasePrice) ? explicitBasePrice : 0;
695
700
  var extensionList = buildProductExtensionList({
696
701
  product: bundle,
@@ -747,7 +752,7 @@ function normalizeExistingCombinations(combinations, locale, currencySymbol) {
747
752
  var optionsAmount = sumMoneyValues(normalizedOptions.map(function (option) {
748
753
  return option.total_price;
749
754
  }));
750
- var explicitBasePrice = firstPresentValue(combination.base_price);
755
+ var explicitBasePrice = resolveCombinationBasePrice(combination, true);
751
756
  var basePrice = isPresentId(explicitBasePrice) ? explicitBasePrice : 0;
752
757
  var extensionList = buildProductExtensionList({
753
758
  product: combination,
@@ -784,6 +789,12 @@ function sumMoneyValues(values) {
784
789
  return sum.plus(toMoneyNumber(value));
785
790
  }, new Decimal(0));
786
791
  }
792
+ function resolveCombinationBasePrice(combination) {
793
+ var _combination$metadata;
794
+ var preferOriginalPrice = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
795
+ var fallbackPrices = preferOriginalPrice ? [combination.original_price, combination.product_price, combination.price] : [combination.price, combination.original_price, combination.product_price];
796
+ return firstPresentValue.apply(void 0, [combination.base_price, (_combination$metadata = combination.metadata) === null || _combination$metadata === void 0 ? void 0 : _combination$metadata.source_product_price].concat(fallbackPrices));
797
+ }
787
798
  function sumNormalizedOptionTotals(options, currencySymbol) {
788
799
  return formatCalculatedMoney(sumMoneyValues(options.map(function (option) {
789
800
  return option.total_price;
@@ -1058,12 +1069,6 @@ function buildFees(params) {
1058
1069
  });
1059
1070
  var isPriceIncludeTax = firstPresentValue(summary.is_price_include_tax, order.is_price_include_tax, shopInfo.is_price_include_tax);
1060
1071
  var roundingAmount = firstPresentValue(summary.rounding_amount, order.rounding_amount);
1061
- if (isNonZero(roundingAmount)) {
1062
- fees.push({
1063
- item: label(locale, 'rounding'),
1064
- value: formatMoney(roundingAmount, currencySymbol)
1065
- });
1066
- }
1067
1072
  var payProcessingFee = financials.payProcessingFee;
1068
1073
  if (isNonZero(payProcessingFee)) {
1069
1074
  fees.push({
@@ -1539,18 +1544,34 @@ function getPointCardSnapshotRemainingPoints(snapshot) {
1539
1544
  }
1540
1545
  function buildVoucherAssets(params) {
1541
1546
  var seenVoucherKeys = new Set();
1547
+ var fallbackAssetTime = firstPresentValue(params.order.updated_at, params.order.created_at);
1542
1548
  return normalizeArray(params.order.vouchers).flatMap(function (voucher, index) {
1543
1549
  if (!voucher || _typeof(voucher) !== 'object' || Array.isArray(voucher)) return [];
1544
1550
  var voucherKey = getVoucherAssetKey(voucher, index);
1545
1551
  if (seenVoucherKeys.has(voucherKey)) return [];
1546
1552
  seenVoucherKeys.add(voucherKey);
1547
1553
  var name = getVoucherAssetName(voucher, params.locale);
1554
+ var assetTime = firstPresentValue(voucher.updated_at, voucher.created_at, voucher.collection_time, fallbackAssetTime);
1555
+ var timeRow = isPresentId(assetTime) ? {
1556
+ item: formatDateTime(assetTime, params.locale),
1557
+ value: ''
1558
+ } : null;
1559
+ if (isTicketVoucher(voucher)) {
1560
+ var validity = getVoucherValidity(voucher, params.locale);
1561
+ return [[{
1562
+ item: name,
1563
+ value: ''
1564
+ }].concat(_toConsumableArray(validity ? [{
1565
+ item: label(params.locale, 'validity'),
1566
+ value: validity
1567
+ }] : []))];
1568
+ }
1548
1569
  var percent = getVoucherDiscountPercent(voucher);
1549
1570
  if (percent) {
1550
1571
  return [[{
1551
1572
  item: appendPercentToVoucherName(name, percent),
1552
1573
  value: formatVoucherDiscount(percent, params.locale)
1553
- }]];
1574
+ }].concat(_toConsumableArray(timeRow ? [timeRow] : []))];
1554
1575
  }
1555
1576
  var balance = getVoucherBalance(voucher);
1556
1577
  return [[{
@@ -1559,9 +1580,71 @@ function buildVoucherAssets(params) {
1559
1580
  }, {
1560
1581
  item: label(params.locale, 'balance'),
1561
1582
  value: formatMoney(balance, params.currencySymbol)
1562
- }]];
1583
+ }].concat(_toConsumableArray(timeRow ? [timeRow] : []))];
1563
1584
  });
1564
1585
  }
1586
+ function isTicketVoucher(voucher) {
1587
+ return stringify(voucher.tag).trim().toLowerCase() === 'ticket';
1588
+ }
1589
+ function getVoucherValidity(voucher, locale) {
1590
+ var _voucher$metadata, _voucher$metadata2, _voucher$metadata3, _voucher$metadata4, _voucher$metadata5, _voucher$metadata6, _voucher$metadata7, _voucher$metadata8, _voucher$metadata9, _voucher$metadata10, _voucher$start_time, _voucher$metadata11, _voucher$end_time, _voucher$metadata12;
1591
+ var availableTime = firstPresentValue(voucher.available_time, voucher.avaliable_time, (_voucher$metadata = voucher.metadata) === null || _voucher$metadata === void 0 ? void 0 : _voucher$metadata.available_time, (_voucher$metadata2 = voucher.metadata) === null || _voucher$metadata2 === void 0 ? void 0 : _voucher$metadata2.avaliable_time);
1592
+ var availableTimeText = formatVoucherAvailableTime(availableTime, locale);
1593
+ if (availableTimeText) return availableTimeText;
1594
+ var startDate = firstPresentValue(voucher.valid_from, voucher.start_at, voucher.start_date_time, voucher.start_date, (_voucher$metadata3 = voucher.metadata) === null || _voucher$metadata3 === void 0 ? void 0 : _voucher$metadata3.valid_from, (_voucher$metadata4 = voucher.metadata) === null || _voucher$metadata4 === void 0 ? void 0 : _voucher$metadata4.start_at, (_voucher$metadata5 = voucher.metadata) === null || _voucher$metadata5 === void 0 ? void 0 : _voucher$metadata5.start_date);
1595
+ var endDate = firstPresentValue(voucher.valid_to, voucher.end_at, voucher.end_date_time, voucher.expire_date, voucher.end_date, voucher.expire_time, (_voucher$metadata6 = voucher.metadata) === null || _voucher$metadata6 === void 0 ? void 0 : _voucher$metadata6.valid_to, (_voucher$metadata7 = voucher.metadata) === null || _voucher$metadata7 === void 0 ? void 0 : _voucher$metadata7.end_at, (_voucher$metadata8 = voucher.metadata) === null || _voucher$metadata8 === void 0 ? void 0 : _voucher$metadata8.expire_date, (_voucher$metadata9 = voucher.metadata) === null || _voucher$metadata9 === void 0 ? void 0 : _voucher$metadata9.end_date, (_voucher$metadata10 = voucher.metadata) === null || _voucher$metadata10 === void 0 ? void 0 : _voucher$metadata10.expire_time);
1596
+ return formatVoucherValidityRange(startDate, endDate, locale, {
1597
+ startTime: (_voucher$start_time = voucher.start_time) !== null && _voucher$start_time !== void 0 ? _voucher$start_time : (_voucher$metadata11 = voucher.metadata) === null || _voucher$metadata11 === void 0 ? void 0 : _voucher$metadata11.start_time,
1598
+ endTime: (_voucher$end_time = voucher.end_time) !== null && _voucher$end_time !== void 0 ? _voucher$end_time : (_voucher$metadata12 = voucher.metadata) === null || _voucher$metadata12 === void 0 ? void 0 : _voucher$metadata12.end_time
1599
+ });
1600
+ }
1601
+ function formatVoucherAvailableTime(value, locale) {
1602
+ if (!isPresentId(value)) return '';
1603
+ if (Array.isArray(value)) {
1604
+ return value.map(function (item) {
1605
+ return formatVoucherAvailableTime(item, locale);
1606
+ }).filter(Boolean).join(', ');
1607
+ }
1608
+ if (_typeof(value) !== 'object') return stringify(value).trim();
1609
+ var start = firstPresentValue(value.start, value.start_at, value.start_date_time, value.start_date);
1610
+ var end = firstPresentValue(value.end, value.end_at, value.end_date_time, value.expire_time, value.expire_date, value.end_date);
1611
+ if (isPresentId(start) || isPresentId(end)) {
1612
+ return formatVoucherValidityRange(start, end, locale, {
1613
+ startTime: value.start_time,
1614
+ endTime: value.end_time
1615
+ });
1616
+ }
1617
+ return getLocalizedValue(value, locale).trim();
1618
+ }
1619
+ function formatVoucherValidityRange(startValue, endValue, locale) {
1620
+ var times = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
1621
+ var start = combineVoucherDateAndTime(startValue, times.startTime);
1622
+ var end = combineVoucherDateAndTime(endValue, times.endTime);
1623
+ var startText = formatVoucherValidityDate(start, locale);
1624
+ var endText = formatVoucherValidityDate(end, locale);
1625
+ if (startText && endText) {
1626
+ var parsedStart = dayjs(start);
1627
+ var parsedEnd = dayjs(end);
1628
+ var sameDay = parsedStart.isValid() && parsedEnd.isValid() && parsedStart.isSame(parsedEnd, 'day');
1629
+ return "".concat(startText, " - ").concat(sameDay && /\d{1,2}:\d{2}/.test(stringify(end)) ? parsedEnd.format('HH:mm') : endText);
1630
+ }
1631
+ return startText || endText;
1632
+ }
1633
+ function combineVoucherDateAndTime(dateValue, timeValue) {
1634
+ if (!isPresentId(dateValue) || !isPresentId(timeValue)) return dateValue;
1635
+ var dateText = stringify(dateValue).trim();
1636
+ if (/\d{1,2}:\d{2}/.test(dateText)) return dateValue;
1637
+ return "".concat(dateText, " ").concat(stringify(timeValue).trim());
1638
+ }
1639
+ function formatVoucherValidityDate(value, locale) {
1640
+ if (!isPresentId(value)) return '';
1641
+ var source = stringify(value).trim();
1642
+ var parsed = dayjs(source);
1643
+ if (!parsed.isValid()) return source;
1644
+ var hasTime = /\d{1,2}:\d{2}/.test(source);
1645
+ if (locale === 'en') return parsed.format(hasTime ? 'DD/MM/YYYY HH:mm' : 'DD/MM/YYYY');
1646
+ return parsed.format(hasTime ? 'YYYY/MM/DD HH:mm' : 'YYYY/MM/DD');
1647
+ }
1565
1648
  function getVoucherAssetKey(voucher, index) {
1566
1649
  var identity = firstPresentValue(voucher.voucher_id, voucher.id, voucher.code, voucher.encoded);
1567
1650
  return identity === undefined ? "voucher-index:".concat(index) : "voucher:".concat(String(identity));
@@ -1570,8 +1653,8 @@ function getVoucherAssetName(voucher, locale) {
1570
1653
  return getLocalizedValue(voucher.product_name || voucher.name || voucher.title, locale) || stringify(voucher.encoded || voucher.code || label(locale, 'giftCard'));
1571
1654
  }
1572
1655
  function getVoucherDiscountPercent(voucher) {
1573
- var _voucher$metadata;
1574
- var discountType = stringify(((_voucher$metadata = voucher.metadata) === null || _voucher$metadata === void 0 ? void 0 : _voucher$metadata.discount_card_type) || voucher.discount_card_type).toLowerCase();
1656
+ var _voucher$metadata13;
1657
+ var discountType = stringify(((_voucher$metadata13 = voucher.metadata) === null || _voucher$metadata13 === void 0 ? void 0 : _voucher$metadata13.discount_card_type) || voucher.discount_card_type).toLowerCase();
1575
1658
  if (discountType !== 'percent' && discountType !== 'percentage') return null;
1576
1659
  var percent = new Decimal(toMoneyNumber(voucher.par_value));
1577
1660
  if (!percent.isFinite() || percent.lte(0) || percent.gt(100)) return null;
@@ -326,7 +326,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
326
326
  date: string;
327
327
  status: string;
328
328
  week: string;
329
- weekNum: 0 | 1 | 2 | 3 | 4 | 5 | 6;
329
+ weekNum: 0 | 1 | 2 | 5 | 4 | 3 | 6;
330
330
  }[]>;
331
331
  submitTimeSlot(timeSlots: TimeSliceItem): void;
332
332
  private getScheduleDataByIds;
@@ -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";
@@ -535,7 +535,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
535
535
  generateIdempotencyToken(): string;
536
536
  syncPaymentsToOrder<T = any>(params: SyncPaymentsToOrderParams): Promise<SyncPaymentsToOrderResult<T>>;
537
537
  createOrder(params: CommitOrderParams['query']): {
538
- type: "virtual" | "appointment_booking";
538
+ type: "appointment_booking" | "virtual";
539
539
  platform: string;
540
540
  sales_channel: string;
541
541
  order_sales_channel: string;
@@ -29,6 +29,7 @@ const LABELS = {
29
29
  giftCard: 'Gift card',
30
30
  pointCard: 'Point card',
31
31
  balance: 'Balance',
32
+ validity: 'Validity',
32
33
  remainingAmount: 'Remaining amount',
33
34
  redeemPoints: 'Redeem points',
34
35
  remainingPoints: 'Points balance',
@@ -67,6 +68,7 @@ const LABELS = {
67
68
  giftCard: '礼品卡',
68
69
  pointCard: '积分卡',
69
70
  balance: '余额',
71
+ validity: '有效期',
70
72
  remainingAmount: '剩余金额',
71
73
  redeemPoints: '本次使用积分',
72
74
  remainingPoints: '积分余额',
@@ -105,6 +107,7 @@ const LABELS = {
105
107
  giftCard: '禮品卡',
106
108
  pointCard: '積分卡',
107
109
  balance: '餘額',
110
+ validity: '有效期',
108
111
  remainingAmount: '剩餘金額',
109
112
  redeemPoints: '本次使用積分',
110
113
  remainingPoints: '積分餘額',
@@ -141,6 +144,7 @@ const LABELS = {
141
144
  giftCard: 'ギフトカード',
142
145
  pointCard: 'ポイントカード',
143
146
  balance: '残高',
147
+ validity: '有効期限',
144
148
  remainingAmount: '残高',
145
149
  redeemPoints: '利用ポイント',
146
150
  remainingPoints: 'ポイント残高',
@@ -178,6 +182,7 @@ const LABELS = {
178
182
  giftCard: 'Cartão-presente',
179
183
  pointCard: 'Cartão de pontos',
180
184
  balance: 'Saldo',
185
+ validity: 'Validade',
181
186
  remainingAmount: 'Saldo restante',
182
187
  redeemPoints: 'Pontos utilizados',
183
188
  remainingPoints: 'Saldo de pontos',
@@ -658,7 +663,7 @@ function normalizeProductCombinations(params) {
658
663
  const quantity = toNumber(bundle.num ?? bundle.quantity ?? 1, 1);
659
664
  const formattedPrice = formatBundlePrice(bundle, currencySymbol);
660
665
  const optionsTotal = sumNormalizedOptionTotals(combinationsOptions, currencySymbol);
661
- const explicitBasePrice = firstPresentValue(bundle.base_price, bundle.metadata?.source_product_price);
666
+ const explicitBasePrice = resolveCombinationBasePrice(bundle);
662
667
  const basePrice = isPresentId(explicitBasePrice) ? explicitBasePrice : 0;
663
668
  const extensionList = buildProductExtensionList({
664
669
  product: bundle,
@@ -719,7 +724,7 @@ function normalizeExistingCombinations(combinations, locale, currencySymbol) {
719
724
  const quantity = toNumber(combination.product_quantity ?? combination.num ?? combination.quantity ?? 1, 1);
720
725
  const unitPrice = firstPresentValue(combination.selling_price, combination.price, combination.original_price) ?? 0;
721
726
  const optionsAmount = sumMoneyValues(normalizedOptions.map(option => option.total_price));
722
- const explicitBasePrice = firstPresentValue(combination.base_price);
727
+ const explicitBasePrice = resolveCombinationBasePrice(combination, true);
723
728
  const basePrice = isPresentId(explicitBasePrice) ? explicitBasePrice : 0;
724
729
  const extensionList = buildProductExtensionList({
725
730
  product: combination,
@@ -762,6 +767,10 @@ function normalizeExistingCombinations(combinations, locale, currencySymbol) {
762
767
  function sumMoneyValues(values) {
763
768
  return values.reduce((sum, value) => sum.plus(toMoneyNumber(value)), new _decimal.default(0));
764
769
  }
770
+ function resolveCombinationBasePrice(combination, preferOriginalPrice = false) {
771
+ const fallbackPrices = preferOriginalPrice ? [combination.original_price, combination.product_price, combination.price] : [combination.price, combination.original_price, combination.product_price];
772
+ return firstPresentValue(combination.base_price, combination.metadata?.source_product_price, ...fallbackPrices);
773
+ }
765
774
  function sumNormalizedOptionTotals(options, currencySymbol) {
766
775
  return formatCalculatedMoney(sumMoneyValues(options.map(option => option.total_price)), currencySymbol);
767
776
  }
@@ -998,12 +1007,6 @@ function buildFees(params) {
998
1007
  });
999
1008
  const isPriceIncludeTax = firstPresentValue(summary.is_price_include_tax, order.is_price_include_tax, shopInfo.is_price_include_tax);
1000
1009
  const roundingAmount = firstPresentValue(summary.rounding_amount, order.rounding_amount);
1001
- if (isNonZero(roundingAmount)) {
1002
- fees.push({
1003
- item: label(locale, 'rounding'),
1004
- value: formatMoney(roundingAmount, currencySymbol)
1005
- });
1006
- }
1007
1010
  const payProcessingFee = financials.payProcessingFee;
1008
1011
  if (isNonZero(payProcessingFee)) {
1009
1012
  fees.push({
@@ -1428,18 +1431,34 @@ function getPointCardSnapshotRemainingPoints(snapshot) {
1428
1431
  }
1429
1432
  function buildVoucherAssets(params) {
1430
1433
  const seenVoucherKeys = new Set();
1434
+ const fallbackAssetTime = firstPresentValue(params.order.updated_at, params.order.created_at);
1431
1435
  return normalizeArray(params.order.vouchers).flatMap((voucher, index) => {
1432
1436
  if (!voucher || typeof voucher !== 'object' || Array.isArray(voucher)) return [];
1433
1437
  const voucherKey = getVoucherAssetKey(voucher, index);
1434
1438
  if (seenVoucherKeys.has(voucherKey)) return [];
1435
1439
  seenVoucherKeys.add(voucherKey);
1436
1440
  const name = getVoucherAssetName(voucher, params.locale);
1441
+ const assetTime = firstPresentValue(voucher.updated_at, voucher.created_at, voucher.collection_time, fallbackAssetTime);
1442
+ const timeRow = isPresentId(assetTime) ? {
1443
+ item: formatDateTime(assetTime, params.locale),
1444
+ value: ''
1445
+ } : null;
1446
+ if (isTicketVoucher(voucher)) {
1447
+ const validity = getVoucherValidity(voucher, params.locale);
1448
+ return [[{
1449
+ item: name,
1450
+ value: ''
1451
+ }, ...(validity ? [{
1452
+ item: label(params.locale, 'validity'),
1453
+ value: validity
1454
+ }] : [])]];
1455
+ }
1437
1456
  const percent = getVoucherDiscountPercent(voucher);
1438
1457
  if (percent) {
1439
1458
  return [[{
1440
1459
  item: appendPercentToVoucherName(name, percent),
1441
1460
  value: formatVoucherDiscount(percent, params.locale)
1442
- }]];
1461
+ }, ...(timeRow ? [timeRow] : [])]];
1443
1462
  }
1444
1463
  const balance = getVoucherBalance(voucher);
1445
1464
  return [[{
@@ -1448,9 +1467,67 @@ function buildVoucherAssets(params) {
1448
1467
  }, {
1449
1468
  item: label(params.locale, 'balance'),
1450
1469
  value: formatMoney(balance, params.currencySymbol)
1451
- }]];
1470
+ }, ...(timeRow ? [timeRow] : [])]];
1452
1471
  });
1453
1472
  }
1473
+ function isTicketVoucher(voucher) {
1474
+ return stringify(voucher.tag).trim().toLowerCase() === 'ticket';
1475
+ }
1476
+ function getVoucherValidity(voucher, locale) {
1477
+ const availableTime = firstPresentValue(voucher.available_time, voucher.avaliable_time, voucher.metadata?.available_time, voucher.metadata?.avaliable_time);
1478
+ const availableTimeText = formatVoucherAvailableTime(availableTime, locale);
1479
+ if (availableTimeText) return availableTimeText;
1480
+ const startDate = firstPresentValue(voucher.valid_from, voucher.start_at, voucher.start_date_time, voucher.start_date, voucher.metadata?.valid_from, voucher.metadata?.start_at, voucher.metadata?.start_date);
1481
+ const endDate = firstPresentValue(voucher.valid_to, voucher.end_at, voucher.end_date_time, voucher.expire_date, voucher.end_date, voucher.expire_time, voucher.metadata?.valid_to, voucher.metadata?.end_at, voucher.metadata?.expire_date, voucher.metadata?.end_date, voucher.metadata?.expire_time);
1482
+ return formatVoucherValidityRange(startDate, endDate, locale, {
1483
+ startTime: voucher.start_time ?? voucher.metadata?.start_time,
1484
+ endTime: voucher.end_time ?? voucher.metadata?.end_time
1485
+ });
1486
+ }
1487
+ function formatVoucherAvailableTime(value, locale) {
1488
+ if (!isPresentId(value)) return '';
1489
+ if (Array.isArray(value)) {
1490
+ return value.map(item => formatVoucherAvailableTime(item, locale)).filter(Boolean).join(', ');
1491
+ }
1492
+ if (typeof value !== 'object') return stringify(value).trim();
1493
+ const start = firstPresentValue(value.start, value.start_at, value.start_date_time, value.start_date);
1494
+ const end = firstPresentValue(value.end, value.end_at, value.end_date_time, value.expire_time, value.expire_date, value.end_date);
1495
+ if (isPresentId(start) || isPresentId(end)) {
1496
+ return formatVoucherValidityRange(start, end, locale, {
1497
+ startTime: value.start_time,
1498
+ endTime: value.end_time
1499
+ });
1500
+ }
1501
+ return getLocalizedValue(value, locale).trim();
1502
+ }
1503
+ function formatVoucherValidityRange(startValue, endValue, locale, times = {}) {
1504
+ const start = combineVoucherDateAndTime(startValue, times.startTime);
1505
+ const end = combineVoucherDateAndTime(endValue, times.endTime);
1506
+ const startText = formatVoucherValidityDate(start, locale);
1507
+ const endText = formatVoucherValidityDate(end, locale);
1508
+ if (startText && endText) {
1509
+ const parsedStart = (0, _dayjs.default)(start);
1510
+ const parsedEnd = (0, _dayjs.default)(end);
1511
+ const sameDay = parsedStart.isValid() && parsedEnd.isValid() && parsedStart.isSame(parsedEnd, 'day');
1512
+ return `${startText} - ${sameDay && /\d{1,2}:\d{2}/.test(stringify(end)) ? parsedEnd.format('HH:mm') : endText}`;
1513
+ }
1514
+ return startText || endText;
1515
+ }
1516
+ function combineVoucherDateAndTime(dateValue, timeValue) {
1517
+ if (!isPresentId(dateValue) || !isPresentId(timeValue)) return dateValue;
1518
+ const dateText = stringify(dateValue).trim();
1519
+ if (/\d{1,2}:\d{2}/.test(dateText)) return dateValue;
1520
+ return `${dateText} ${stringify(timeValue).trim()}`;
1521
+ }
1522
+ function formatVoucherValidityDate(value, locale) {
1523
+ if (!isPresentId(value)) return '';
1524
+ const source = stringify(value).trim();
1525
+ const parsed = (0, _dayjs.default)(source);
1526
+ if (!parsed.isValid()) return source;
1527
+ const hasTime = /\d{1,2}:\d{2}/.test(source);
1528
+ if (locale === 'en') return parsed.format(hasTime ? 'DD/MM/YYYY HH:mm' : 'DD/MM/YYYY');
1529
+ return parsed.format(hasTime ? 'YYYY/MM/DD HH:mm' : 'YYYY/MM/DD');
1530
+ }
1454
1531
  function getVoucherAssetKey(voucher, index) {
1455
1532
  const identity = firstPresentValue(voucher.voucher_id, voucher.id, voucher.code, voucher.encoded);
1456
1533
  return identity === undefined ? `voucher-index:${index}` : `voucher:${String(identity)}`;
@@ -326,7 +326,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
326
326
  date: string;
327
327
  status: string;
328
328
  week: string;
329
- weekNum: 0 | 1 | 2 | 3 | 4 | 5 | 6;
329
+ weekNum: 0 | 1 | 2 | 5 | 4 | 3 | 6;
330
330
  }[]>;
331
331
  submitTimeSlot(timeSlots: TimeSliceItem): void;
332
332
  private getScheduleDataByIds;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "private": false,
3
3
  "name": "@pisell/pisellos",
4
- "version": "0.10.37",
4
+ "version": "0.10.38",
5
5
  "description": "一个可扩展的前端模块化SDK框架,支持插件系统",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",