@pisell/private-materials 6.6.78 → 6.6.80

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.
@@ -4,6 +4,6 @@ declare const useSendModal: (bookingId?: number) => {
4
4
  setOpen: import("react").Dispatch<import("react").SetStateAction<boolean>>;
5
5
  handleOpen: () => void;
6
6
  handleValuesChange: (val: any) => void;
7
- handleOk: (values: SendModalValues) => Promise<boolean | undefined>;
7
+ handleOk: (values: SendModalValues) => Promise<any>;
8
8
  };
9
9
  export default useSendModal;
@@ -90,6 +90,7 @@ var Info = function Info(_, ref) {
90
90
  dispatch = _useContext.dispatch;
91
91
  var resourcesRef = useRef(null);
92
92
  var isChangeTotal = useRef(false);
93
+ var shouldReallocateBundlePriceRef = useRef(false);
93
94
  var _useState3 = useState(false),
94
95
  _useState4 = _slicedToArray(_useState3, 2),
95
96
  noteModalOpen = _useState4[0],
@@ -361,7 +362,8 @@ var Info = function Info(_, ref) {
361
362
  _extend.startDate = startDate;
362
363
  _extend.endDate = endDate;
363
364
  }
364
- if (isChangeTotal.current) {
365
+ var shouldReallocatePrice = isChangeTotal.current || shouldReallocateBundlePriceRef.current;
366
+ if (shouldReallocatePrice) {
365
367
  var _extend$other, _extend$other2;
366
368
  // 计算折扣比例
367
369
  var discountRatio = new Decimal(values.total).div(_item._extend.origin_total);
@@ -437,8 +439,8 @@ var Info = function Info(_, ref) {
437
439
 
438
440
  if (groupId) {
439
441
  // 手动改价时移除优惠券使用
440
- if (isChangeTotal.current) {
441
- _item = deleteDiscountList(_item);
442
+ if (shouldReallocatePrice) {
443
+ _item = deleteDiscountList(_item, true);
442
444
  }
443
445
  _list = _list.filter(function (d) {
444
446
  var _d$_extend;
@@ -459,8 +461,8 @@ var Info = function Info(_, ref) {
459
461
  return isSameBookingServiceItem(d, _item);
460
462
  });
461
463
  if (matchById || matchByBooking) {
462
- if (isChangeTotal.current) {
463
- _item = deleteDiscountList(_item);
464
+ if (shouldReallocatePrice) {
465
+ _item = deleteDiscountList(_item, true);
464
466
  }
465
467
  if (matchById) {
466
468
  _list = _list.map(function (d) {
@@ -540,6 +542,7 @@ var Info = function Info(_, ref) {
540
542
  console.log('setEditDatasetEditData', _cacheItem, open);
541
543
  setCurrentTab('batch_edit');
542
544
  isChangeTotal.current = false;
545
+ shouldReallocateBundlePriceRef.current = false;
543
546
  // 重置编辑标记
544
547
  isEditedRef.current = false;
545
548
  var cacheItem = _cacheItem || state.service.cacheItem;
@@ -731,6 +734,7 @@ var Info = function Info(_, ref) {
731
734
  var _cacheItem$metadata, _cacheItem$_extend, _cacheItem$_extend2;
732
735
  // 标记已执行过编辑操作
733
736
  isEditedRef.current = true;
737
+ shouldReallocateBundlePriceRef.current = false;
734
738
  var _detail = detail || item;
735
739
  var other = JSON.parse(JSON.stringify(e));
736
740
 
@@ -791,10 +795,12 @@ var Info = function Info(_, ref) {
791
795
  return (discountItem === null || discountItem === void 0 ? void 0 : discountItem.type) !== 'product';
792
796
  });
793
797
  if (previousOriginTotal > 0 && Number.isFinite(previousOriginTotal) && Number.isFinite(previousTotal) && !hasNonManualDiscount) {
794
- // 手动折扣编辑套餐时只延续旧折后比例,不改子商品单价,避免后续重复折扣。
798
+ // 手动折扣编辑套餐时延续旧折后比例,保存时再按新原价分摊,避免重复折扣。
795
799
  var sellingRatio = new Decimal(previousTotal).div(previousOriginTotal);
796
800
  _total = new Decimal(origin_total).mul(sellingRatio).toDecimalPlaces(2, Decimal.ROUND_HALF_UP).toNumber();
797
801
  cacheItem._extend.total = _total;
802
+ // 套餐变化后,即使折后总价未触发 onChange,也需要重新分摊子商品售价。
803
+ shouldReallocateBundlePriceRef.current = true;
798
804
  }
799
805
  }
800
806
 
@@ -1270,11 +1276,16 @@ var Info = function Info(_, ref) {
1270
1276
  };
1271
1277
  var deleteDiscountList = function deleteDiscountList(cacheItem) {
1272
1278
  var _cacheItem$_extend$ot, _cacheItem$_extend$ot2;
1279
+ var preserveBundleSellingPrice = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
1273
1280
  delete cacheItem.discount_list;
1274
1281
  (_cacheItem$_extend$ot = cacheItem._extend.other) === null || _cacheItem$_extend$ot === void 0 || (_cacheItem$_extend$ot = _cacheItem$_extend$ot.bundle) === null || _cacheItem$_extend$ot === void 0 || (_cacheItem$_extend$ot2 = _cacheItem$_extend$ot.forEach) === null || _cacheItem$_extend$ot2 === void 0 || _cacheItem$_extend$ot2.call(_cacheItem$_extend$ot, function (bundle) {
1275
1282
  var _bundle$metadata;
1283
+ var bundleSellingPrice = Number(bundle === null || bundle === void 0 ? void 0 : bundle.bundle_selling_price);
1284
+ var hasBundleSellingPrice = preserveBundleSellingPrice && (bundle === null || bundle === void 0 ? void 0 : bundle.bundle_selling_price) != null && Number.isFinite(bundleSellingPrice);
1276
1285
  var restoredPrice = getBundleOriginalSellingPrice(bundle);
1277
- if (restoredPrice !== undefined) {
1286
+ if (hasBundleSellingPrice) {
1287
+ bundle.price = bundleSellingPrice;
1288
+ } else if (restoredPrice !== undefined) {
1278
1289
  bundle.price = restoredPrice;
1279
1290
  bundle.original_price = restoredPrice;
1280
1291
  bundle.original_total = restoredPrice;
@@ -109,6 +109,18 @@ var renderKeyValue = function renderKeyValue(name, value, width) {
109
109
  if (nameWidth + valueWidth + 1 <= width) {
110
110
  return ["".concat(name).concat(' '.repeat(width - nameWidth - valueWidth)).concat(value)];
111
111
  }
112
+
113
+ // Keep the label visible on the first line for long values (for example,
114
+ // Adyen's Reference UUID), then align continuation lines with the value.
115
+ var gapWidth = 3;
116
+ var valueLineWidth = width - nameWidth - gapWidth;
117
+ if (valueLineWidth > 0) {
118
+ var prefix = "".concat(name).concat(' '.repeat(gapWidth));
119
+ var continuationPrefix = ' '.repeat(nameWidth + gapWidth);
120
+ return wrapText(value, valueLineWidth).map(function (line, index) {
121
+ return index === 0 ? "".concat(prefix).concat(line) : "".concat(continuationPrefix).concat(line);
122
+ });
123
+ }
112
124
  return [].concat(_toConsumableArray(wrapText(name, width)), _toConsumableArray(rightAlignText(value, width)));
113
125
  };
114
126
  var renderReceiptLine = function renderReceiptLine(receiptLine, width) {
@@ -19,7 +19,7 @@ export declare const useStoreRef: <T extends {
19
19
  readonly netRef: React.MutableRefObject<boolean | undefined>;
20
20
  readonly symbolRef: React.MutableRefObject<string>;
21
21
  readonly amountRef: React.MutableRefObject<string | number>;
22
- readonly eftposRef: React.MutableRefObject<"stripe" | "tyro" | "mx51" | "payo" | "windcave" | "linkly" | "huifu" | "adyenpos" | "adyenalipay" | "adyenwechat">;
22
+ readonly eftposRef: React.MutableRefObject<"stripe" | "tyro" | "windcave" | "mx51" | "payo" | "linkly" | "huifu" | "adyenpos" | "adyenalipay" | "adyenwechat">;
23
23
  readonly clientRef: React.MutableRefObject<ClientEnum>;
24
24
  readonly dataRef: React.MutableRefObject<import("./store").State>;
25
25
  };
@@ -301,7 +301,7 @@ export declare const backUpFree: (payload: Partial<State>) => {
301
301
  amount?: string | number | undefined;
302
302
  mode?: "pay" | "refund" | "fullPay" | "query" | undefined;
303
303
  order_id?: string | number | undefined;
304
- eftpos?: "stripe" | "tyro" | "mx51" | "payo" | "windcave" | "linkly" | "huifu" | "adyenpos" | "adyenalipay" | "adyenwechat" | undefined;
304
+ eftpos?: "stripe" | "tyro" | "windcave" | "mx51" | "payo" | "linkly" | "huifu" | "adyenpos" | "adyenalipay" | "adyenwechat" | undefined;
305
305
  action?: "pay" | "amount" | "deviceList" | undefined;
306
306
  key?: number | undefined;
307
307
  step?: number | undefined;
@@ -10,7 +10,7 @@ export default {
10
10
  'zh-CN': {
11
11
  'pisell-adyen-dashboard.menu.transactions': '交易',
12
12
  'pisell-adyen-dashboard.menu.reports': '报表',
13
- 'pisell-adyen-dashboard.menu.payouts': '付款',
13
+ 'pisell-adyen-dashboard.menu.payouts': '打款',
14
14
  'pisell-adyen-dashboard.menu.disputes': '争议',
15
15
  'pisell-adyen-dashboard.menu.paymentLinks': '支付链接',
16
16
  'pisell-adyen-dashboard.loading': '正在加载 Adyen 看板...'
@@ -18,7 +18,7 @@ export default {
18
18
  'zh-HK': {
19
19
  'pisell-adyen-dashboard.menu.transactions': '交易',
20
20
  'pisell-adyen-dashboard.menu.reports': '報表',
21
- 'pisell-adyen-dashboard.menu.payouts': '付款',
21
+ 'pisell-adyen-dashboard.menu.payouts': '打款',
22
22
  'pisell-adyen-dashboard.menu.disputes': '爭議',
23
23
  'pisell-adyen-dashboard.menu.paymentLinks': '付款連結',
24
24
  'pisell-adyen-dashboard.loading': '正在載入 Adyen 看板...'
@@ -26,7 +26,7 @@ export default {
26
26
  'zh-TW': {
27
27
  'pisell-adyen-dashboard.menu.transactions': '交易',
28
28
  'pisell-adyen-dashboard.menu.reports': '報表',
29
- 'pisell-adyen-dashboard.menu.payouts': '付款',
29
+ 'pisell-adyen-dashboard.menu.payouts': '打款',
30
30
  'pisell-adyen-dashboard.menu.disputes': '爭議',
31
31
  'pisell-adyen-dashboard.menu.paymentLinks': '付款連結',
32
32
  'pisell-adyen-dashboard.loading': '正在載入 Adyen 看板...'
@@ -4,6 +4,6 @@ declare const useSendModal: (bookingId?: number) => {
4
4
  setOpen: import("react").Dispatch<import("react").SetStateAction<boolean>>;
5
5
  handleOpen: () => void;
6
6
  handleValuesChange: (val: any) => void;
7
- handleOk: (values: SendModalValues) => Promise<boolean | undefined>;
7
+ handleOk: (values: SendModalValues) => Promise<any>;
8
8
  };
9
9
  export default useSendModal;
@@ -91,6 +91,7 @@ var Info = (_, ref) => {
91
91
  const { state, dispatch } = (0, import_react.useContext)(import_model.Context);
92
92
  const resourcesRef = (0, import_react.useRef)(null);
93
93
  const isChangeTotal = (0, import_react.useRef)(false);
94
+ const shouldReallocateBundlePriceRef = (0, import_react.useRef)(false);
94
95
  const [noteModalOpen, setNoteModalOpen] = (0, import_react.useState)(false);
95
96
  const [open, setOpen] = (0, import_react.useState)(false);
96
97
  const [currentTab, setCurrentTab] = (0, import_react.useState)("batch_edit");
@@ -280,7 +281,8 @@ var Info = (_, ref) => {
280
281
  _extend.startDate = startDate;
281
282
  _extend.endDate = endDate;
282
283
  }
283
- if (isChangeTotal.current) {
284
+ const shouldReallocatePrice = isChangeTotal.current || shouldReallocateBundlePriceRef.current;
285
+ if (shouldReallocatePrice) {
284
286
  const discountRatio = new import_decimal.default(values.total).div(_item._extend.origin_total);
285
287
  const bundles2 = ((_c2 = _extend == null ? void 0 : _extend.other) == null ? void 0 : _c2.bundle) || [];
286
288
  let childProductsTotal = new import_decimal.default(0);
@@ -326,8 +328,8 @@ var Info = (_, ref) => {
326
328
  let groupId = (_j2 = _item == null ? void 0 : _item._extend) == null ? void 0 : _j2.groupId;
327
329
  const origin_total = (_n2 = (_m2 = (_l2 = (_k2 = _item._extend) == null ? void 0 : _k2.items) == null ? void 0 : _l2[0]) == null ? void 0 : _m2._extend) == null ? void 0 : _n2.origin_total;
328
330
  if (groupId) {
329
- if (isChangeTotal.current) {
330
- _item = deleteDiscountList(_item);
331
+ if (shouldReallocatePrice) {
332
+ _item = deleteDiscountList(_item, true);
331
333
  }
332
334
  _list = _list.filter((d) => {
333
335
  var _a3;
@@ -342,8 +344,8 @@ var Info = (_, ref) => {
342
344
  const matchById = _list.some((d) => d._id === _id);
343
345
  const matchByBooking = !matchById && _list.some((d) => isSameBookingServiceItem(d, _item));
344
346
  if (matchById || matchByBooking) {
345
- if (isChangeTotal.current) {
346
- _item = deleteDiscountList(_item);
347
+ if (shouldReallocatePrice) {
348
+ _item = deleteDiscountList(_item, true);
347
349
  }
348
350
  if (matchById) {
349
351
  _list = _list.map((d) => d._id === _id ? { ..._item, new: 0 } : d);
@@ -415,6 +417,7 @@ var Info = (_, ref) => {
415
417
  console.log("setEditDatasetEditData", _cacheItem, open2);
416
418
  setCurrentTab("batch_edit");
417
419
  isChangeTotal.current = false;
420
+ shouldReallocateBundlePriceRef.current = false;
418
421
  isEditedRef.current = false;
419
422
  let cacheItem = _cacheItem || state.service.cacheItem;
420
423
  let values = cacheItem._extend;
@@ -561,6 +564,7 @@ var Info = (_, ref) => {
561
564
  callback: (e2, extension_type, detail) => {
562
565
  var _a3, _b3, _c3, _d3, _e3, _f2, _g2;
563
566
  isEditedRef.current = true;
567
+ shouldReallocateBundlePriceRef.current = false;
564
568
  const _detail = detail || item;
565
569
  let other = JSON.parse(JSON.stringify(e2));
566
570
  if (item.discount_amount) {
@@ -617,6 +621,7 @@ var Info = (_, ref) => {
617
621
  const sellingRatio = new import_decimal.default(previousTotal).div(previousOriginTotal);
618
622
  _total = new import_decimal.default(origin_total).mul(sellingRatio).toDecimalPlaces(2, import_decimal.default.ROUND_HALF_UP).toNumber();
619
623
  cacheItem._extend.total = _total;
624
+ shouldReallocateBundlePriceRef.current = true;
620
625
  }
621
626
  }
622
627
  cacheItem._extend.origin_total = origin_total;
@@ -1056,13 +1061,17 @@ var Info = (_, ref) => {
1056
1061
  }
1057
1062
  }
1058
1063
  };
1059
- const deleteDiscountList = (cacheItem) => {
1064
+ const deleteDiscountList = (cacheItem, preserveBundleSellingPrice = false) => {
1060
1065
  var _a2, _b2, _c2;
1061
1066
  delete cacheItem.discount_list;
1062
1067
  (_c2 = (_b2 = (_a2 = cacheItem._extend.other) == null ? void 0 : _a2.bundle) == null ? void 0 : _b2.forEach) == null ? void 0 : _c2.call(_b2, (bundle) => {
1063
1068
  var _a3;
1069
+ const bundleSellingPrice = Number(bundle == null ? void 0 : bundle.bundle_selling_price);
1070
+ const hasBundleSellingPrice = preserveBundleSellingPrice && (bundle == null ? void 0 : bundle.bundle_selling_price) != null && Number.isFinite(bundleSellingPrice);
1064
1071
  const restoredPrice = getBundleOriginalSellingPrice(bundle);
1065
- if (restoredPrice !== void 0) {
1072
+ if (hasBundleSellingPrice) {
1073
+ bundle.price = bundleSellingPrice;
1074
+ } else if (restoredPrice !== void 0) {
1066
1075
  bundle.price = restoredPrice;
1067
1076
  bundle.original_price = restoredPrice;
1068
1077
  bundle.original_total = restoredPrice;
@@ -127,6 +127,15 @@ var renderKeyValue = (name, value, width) => {
127
127
  if (nameWidth + valueWidth + 1 <= width) {
128
128
  return [`${name}${" ".repeat(width - nameWidth - valueWidth)}${value}`];
129
129
  }
130
+ const gapWidth = 3;
131
+ const valueLineWidth = width - nameWidth - gapWidth;
132
+ if (valueLineWidth > 0) {
133
+ const prefix = `${name}${" ".repeat(gapWidth)}`;
134
+ const continuationPrefix = " ".repeat(nameWidth + gapWidth);
135
+ return wrapText(value, valueLineWidth).map(
136
+ (line, index) => index === 0 ? `${prefix}${line}` : `${continuationPrefix}${line}`
137
+ );
138
+ }
130
139
  return [...wrapText(name, width), ...rightAlignText(value, width)];
131
140
  };
132
141
  var renderReceiptLine = (receiptLine, width) => {
@@ -19,7 +19,7 @@ export declare const useStoreRef: <T extends {
19
19
  readonly netRef: React.MutableRefObject<boolean | undefined>;
20
20
  readonly symbolRef: React.MutableRefObject<string>;
21
21
  readonly amountRef: React.MutableRefObject<string | number>;
22
- readonly eftposRef: React.MutableRefObject<"stripe" | "tyro" | "mx51" | "payo" | "windcave" | "linkly" | "huifu" | "adyenpos" | "adyenalipay" | "adyenwechat">;
22
+ readonly eftposRef: React.MutableRefObject<"stripe" | "tyro" | "windcave" | "mx51" | "payo" | "linkly" | "huifu" | "adyenpos" | "adyenalipay" | "adyenwechat">;
23
23
  readonly clientRef: React.MutableRefObject<ClientEnum>;
24
24
  readonly dataRef: React.MutableRefObject<import("./store").State>;
25
25
  };
@@ -301,7 +301,7 @@ export declare const backUpFree: (payload: Partial<State>) => {
301
301
  amount?: string | number | undefined;
302
302
  mode?: "pay" | "refund" | "fullPay" | "query" | undefined;
303
303
  order_id?: string | number | undefined;
304
- eftpos?: "stripe" | "tyro" | "mx51" | "payo" | "windcave" | "linkly" | "huifu" | "adyenpos" | "adyenalipay" | "adyenwechat" | undefined;
304
+ eftpos?: "stripe" | "tyro" | "windcave" | "mx51" | "payo" | "linkly" | "huifu" | "adyenpos" | "adyenalipay" | "adyenwechat" | undefined;
305
305
  action?: "pay" | "amount" | "deviceList" | undefined;
306
306
  key?: number | undefined;
307
307
  step?: number | undefined;
@@ -34,7 +34,7 @@ var locales_default = {
34
34
  "zh-CN": {
35
35
  "pisell-adyen-dashboard.menu.transactions": "交易",
36
36
  "pisell-adyen-dashboard.menu.reports": "报表",
37
- "pisell-adyen-dashboard.menu.payouts": "付款",
37
+ "pisell-adyen-dashboard.menu.payouts": "打款",
38
38
  "pisell-adyen-dashboard.menu.disputes": "争议",
39
39
  "pisell-adyen-dashboard.menu.paymentLinks": "支付链接",
40
40
  "pisell-adyen-dashboard.loading": "正在加载 Adyen 看板..."
@@ -42,7 +42,7 @@ var locales_default = {
42
42
  "zh-HK": {
43
43
  "pisell-adyen-dashboard.menu.transactions": "交易",
44
44
  "pisell-adyen-dashboard.menu.reports": "報表",
45
- "pisell-adyen-dashboard.menu.payouts": "付款",
45
+ "pisell-adyen-dashboard.menu.payouts": "打款",
46
46
  "pisell-adyen-dashboard.menu.disputes": "爭議",
47
47
  "pisell-adyen-dashboard.menu.paymentLinks": "付款連結",
48
48
  "pisell-adyen-dashboard.loading": "正在載入 Adyen 看板..."
@@ -50,7 +50,7 @@ var locales_default = {
50
50
  "zh-TW": {
51
51
  "pisell-adyen-dashboard.menu.transactions": "交易",
52
52
  "pisell-adyen-dashboard.menu.reports": "報表",
53
- "pisell-adyen-dashboard.menu.payouts": "付款",
53
+ "pisell-adyen-dashboard.menu.payouts": "打款",
54
54
  "pisell-adyen-dashboard.menu.disputes": "爭議",
55
55
  "pisell-adyen-dashboard.menu.paymentLinks": "付款連結",
56
56
  "pisell-adyen-dashboard.loading": "正在載入 Adyen 看板..."
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pisell/private-materials",
3
- "version": "6.6.78",
3
+ "version": "6.6.80",
4
4
  "main": "./lib/index.js",
5
5
  "module": "./es/index.js",
6
6
  "types": "./lib/index.d.ts",
@@ -65,8 +65,8 @@
65
65
  "@use-gesture/react": "^10.3.1",
66
66
  "@pisell/utils": "3.0.2",
67
67
  "@pisell/materials": "6.6.18",
68
- "@pisell/icon": "0.0.11",
69
- "@pisell/date-picker": "3.0.7"
68
+ "@pisell/date-picker": "3.0.7",
69
+ "@pisell/icon": "0.0.11"
70
70
  },
71
71
  "peerDependencies": {
72
72
  "react": "^18.0.0",