@pisell/pisellos 0.0.511 → 0.0.512

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.
@@ -1,39 +1,114 @@
1
1
  var _excluded = ["_origin", "identity_key"],
2
2
  _excluded2 = ["created_at", "summary", "surcharges"],
3
3
  _excluded3 = ["collect_pax", "table_occupancy_duration"];
4
- function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
5
4
  function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
6
5
  function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
7
6
  function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
8
7
  function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
9
8
  function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
10
- function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
11
9
  function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
12
10
  function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
13
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
14
11
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
15
12
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
16
13
  function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
17
14
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
18
15
  function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
16
+ function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
17
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
18
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
19
19
  import dayjs from "dayjs";
20
20
  import Decimal from 'decimal.js';
21
21
  import { buildProductLineFingerprint, createEmptySummary } from "../../solution/ScanOrder/utils";
22
+ /**
23
+ * 把"含 option 的主商品单价"与 bundle 合成"单行 composite 单价"。
24
+ *
25
+ * 新语义 v2 约定:
26
+ * - `mainPrice` 必须是**已经包含 option 的主商品单价**(即 `metadata.main_product_selling_price`
27
+ * 或 `metadata.main_product_original_price`),option 价格不由本函数叠加。
28
+ * - 套餐价:Σ((bundle.bundle_selling_price ?? bundle.price) × (bundle.num ?? bundle.quantity ?? 1))
29
+ * 当 `useOriginalBundle=true` 时,改用 `bundle.original_price ?? bundle.product_price ?? bundle.price`。
30
+ * - 返回值:保留 2 位小数的字符串,方便直接写回 `selling_price` / `original_price` 字段。
31
+ *
32
+ * 被 `normalizeOrderProduct`、Rules setProduct 钩子、各 Solution 的 setDiscountSelected 共用,
33
+ * 保证合成逻辑单点来源。
34
+ */
35
+ export function composeLinePrice(params) {
36
+ var mainPrice = params.mainPrice,
37
+ bundle = params.bundle,
38
+ useOriginalBundle = params.useOriginalBundle;
39
+ var total = new Decimal(Number(mainPrice) || 0);
40
+ if (Array.isArray(bundle)) {
41
+ var _iterator = _createForOfIteratorHelper(bundle),
42
+ _step;
43
+ try {
44
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
45
+ var _ref, _item$original_price, _item$bundle_selling_, _ref2, _item$num;
46
+ var item = _step.value;
47
+ var rawPrice = useOriginalBundle ? (_ref = (_item$original_price = item === null || item === void 0 ? void 0 : item.original_price) !== null && _item$original_price !== void 0 ? _item$original_price : item === null || item === void 0 ? void 0 : item.product_price) !== null && _ref !== void 0 ? _ref : item === null || item === void 0 ? void 0 : item.price : (_item$bundle_selling_ = item === null || item === void 0 ? void 0 : item.bundle_selling_price) !== null && _item$bundle_selling_ !== void 0 ? _item$bundle_selling_ : item === null || item === void 0 ? void 0 : item.price;
48
+ var price = new Decimal(Number(rawPrice) || 0);
49
+ var rawNum = (_ref2 = (_item$num = item === null || item === void 0 ? void 0 : item.num) !== null && _item$num !== void 0 ? _item$num : item === null || item === void 0 ? void 0 : item.quantity) !== null && _ref2 !== void 0 ? _ref2 : 1;
50
+ var num = new Decimal(Number(rawNum) || 0);
51
+ total = total.plus(price.times(num));
52
+ }
53
+ } catch (err) {
54
+ _iterator.e(err);
55
+ } finally {
56
+ _iterator.f();
57
+ }
58
+ }
59
+ return total.toDecimalPlaces(2).toFixed(2);
60
+ }
61
+
62
+ /**
63
+ * 计算 option 单价合计:Σ(option.price × option.num)。
64
+ * 在新语义 v2 下,main_product_original_price = source_product_price + 本函数结果。
65
+ */
66
+ export function sumOptionUnitPrice(options) {
67
+ var total = new Decimal(0);
68
+ if (!Array.isArray(options)) return total;
69
+ var _iterator2 = _createForOfIteratorHelper(options),
70
+ _step2;
71
+ try {
72
+ for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
73
+ var opt = _step2.value;
74
+ var price = new Decimal(Number(opt === null || opt === void 0 ? void 0 : opt.price) || 0);
75
+ var num = new Decimal(Number(opt === null || opt === void 0 ? void 0 : opt.num) || 0);
76
+ total = total.plus(price.times(num));
77
+ }
78
+ } catch (err) {
79
+ _iterator2.e(err);
80
+ } finally {
81
+ _iterator2.f();
82
+ }
83
+ return total;
84
+ }
85
+
22
86
  /**
23
87
  * OrderModule 默认 Rules 钩子工厂。
24
88
  *
25
- * 价格语义约定(订单域):
26
- * - `selling_price`:券后单品单价(实际成交单价)。初次加购 = `original_price`;券应用后由 Rules 引擎更新。
27
- * - `original_price`:券前单品单价(店铺售价)。不承载后台划线价语义。
28
- * - `payment_price`:已从内部字段移除;只在出站 payload 中由 `selling_price` 派生以兼容后端。
89
+ * 价格语义约定(订单域,v2 composite 口径):
90
+ * - `selling_price`:券后 **行 composite 单价**
91
+ * = `metadata.main_product_selling_price` + Σ(bundle_selling_price × num)。
92
+ * - `original_price`:券前 **行 composite 单价**
93
+ * = `metadata.main_product_original_price` + Σ(bundle 原价 × num)。
94
+ * - `metadata.source_product_price`:主商品/variant 基础价(已应用报价单),不含 option、
95
+ * 不含折扣。**权威源**。
96
+ * - `metadata.main_product_original_price` = source + Σ(option.price × option.num)(含 option、不含折扣)。
97
+ * - `metadata.main_product_selling_price` = main_original − 主商品券 per-unit amount(含 option、含折扣)。
98
+ * - `payment_price`:出站 payload 中由 `selling_price` 派生以兼容后端(composite)。
29
99
  *
30
- * Rules 钩子契约:
31
- * - `getProduct.total` = `selling_price × num`(当前成交总价)
32
- * - `getProduct.origin_total` = `original_price × num`(券前总价)
33
- * - `setProduct` 写回 `selling_price` 的优先级:
34
- * 1. `values.main_product_selling_price`(券应用分支,per-unit 券后主价)
35
- * 2. `values.price`(还原分支 `restoredPrice`、good_pass 归零)
36
- * 3. `values.total / num`(仅当 Rules 只给出总价时的兜底)
100
+ * Rules 钩子契约(hook_adapt 方案,Rules 内部保持不变):
101
+ * - `getProduct.price` / `getProduct.original_price` 回传 **source-level 主价**
102
+ * (`metadata.source_product_price`)。Rules 内部 `getProductTotalPrice` /
103
+ * `getProductOriginTotalPrice` 会自行叠加 option + bundle,喂 source 可避免 option 双加。
104
+ * - `getProduct.total` = `selling_price × num`(行 composite × num),与 Rules 内部产出的
105
+ * total(source + option + bundle)对齐。
106
+ * - `setProduct` 反向流程:把 Rules 返回的 source-level `main_product_selling_price` / `price`
107
+ * 加回 Σoptions,重新合成含 option 的 main_product_* 并派生 composite。
108
+ * 优先级:
109
+ * 1. `values.main_product_selling_price`(券应用分支,per-unit 券后 source-level 主价)
110
+ * 2. `values.price`(还原分支 `restoredPrice`、good_pass 归零)
111
+ * 3. `values.total / num`(仅当 Rules 只给出总价时的兜底)
37
112
  *
38
113
  * 导出为纯函数方便单测直接驱动钩子,不依赖 OrderModule 实例。
39
114
  */
@@ -45,6 +120,26 @@ export function createDefaultOrderRulesHooks() {
45
120
  return {
46
121
  getProduct: function getProduct(product) {
47
122
  var _product$_origin, _product$_origin2, _product$_origin3, _product$_origin4;
123
+ // source_product_price 是权威源;兜底链:source → mainSelling − options(反推)→ 行 selling_price
124
+ var metadataAny = product.metadata || {};
125
+ var optionSum = sumOptionUnitPrice(product.product_option_item);
126
+ var sourcePrice;
127
+ if (metadataAny.source_product_price !== undefined) {
128
+ sourcePrice = String(metadataAny.source_product_price);
129
+ } else if (metadataAny.main_product_selling_price !== undefined) {
130
+ sourcePrice = new Decimal(Number(metadataAny.main_product_selling_price) || 0).minus(optionSum).toDecimalPlaces(2).toString();
131
+ } else {
132
+ var _product$selling_pric;
133
+ sourcePrice = String((_product$selling_pric = product.selling_price) !== null && _product$selling_pric !== void 0 ? _product$selling_pric : 0);
134
+ }
135
+ var sourceOriginalPrice;
136
+ if (metadataAny.source_product_price !== undefined) {
137
+ sourceOriginalPrice = String(metadataAny.source_product_price);
138
+ } else if (metadataAny.main_product_original_price !== undefined) {
139
+ sourceOriginalPrice = new Decimal(Number(metadataAny.main_product_original_price) || 0).minus(optionSum).toDecimalPlaces(2).toString();
140
+ } else {
141
+ sourceOriginalPrice = sourcePrice;
142
+ }
48
143
  return {
49
144
  id: product.product_id,
50
145
  // Rules 引擎用 _id 作为 processedProductsMap 键;必须与购物车行级 identity 一致,
@@ -52,10 +147,13 @@ export function createDefaultOrderRulesHooks() {
52
147
  // 不透明 identity 契约下,normalizeOrderProduct / restoreTempOrderFromStorage 已保证 identity_key 必存在;
53
148
  // 留 fingerprint 分支仅作 Rules 单测里直接传裸 product 时的兜底。
54
149
  _id: product.identity_key ? "".concat(product.product_id, "_").concat(product.product_variant_id, "_").concat(product.identity_key) : "".concat(product.product_id, "_").concat(product.product_variant_id, "_").concat(buildProductLineFingerprint(product.product_option_item, product.product_bundle)),
55
- price: product.selling_price,
150
+ // Rules 内部 getProductTotalPrice / getProductOriginTotalPrice 会各自再叠加 bundle + option,
151
+ // 所以这里必须喂 source-level(不含 option、不含 bundle、不含折扣)单价,避免双加 option。
152
+ price: sourcePrice,
153
+ // total / origin_total 使用 composite × num,跟 Rules 内部产出的 total 对齐(含 option + bundle)。
56
154
  total: new Decimal(product.selling_price || 0).times(product.num || 1).toNumber(),
57
155
  origin_total: new Decimal(product.original_price || product.selling_price || 0).times(product.num || 1).toNumber(),
58
- original_price: product.original_price,
156
+ original_price: sourceOriginalPrice,
59
157
  quantity: product.num || 1,
60
158
  num: product.num || 1,
61
159
  discount_list: product.discount_list || [],
@@ -68,18 +166,47 @@ export function createDefaultOrderRulesHooks() {
68
166
  };
69
167
  },
70
168
  setProduct: function setProduct(product, values) {
71
- var _ref, _values$quantity, _values$discount_list, _values$quantity2, _values$bundle;
72
- var nextNum = Number((_ref = (_values$quantity = values.quantity) !== null && _values$quantity !== void 0 ? _values$quantity : product.num) !== null && _ref !== void 0 ? _ref : 1) || 1;
73
- var nextSellingPrice = values.main_product_selling_price !== undefined ? String(values.main_product_selling_price) : values.price !== undefined ? String(values.price) : values.total !== undefined ? toUnitPriceString(values.total, nextNum) : product.selling_price;
169
+ var _ref3, _values$quantity, _ref4, _metadataAny$source_p, _values$bundle, _values$discount_list, _values$quantity2;
170
+ var nextNum = Number((_ref3 = (_values$quantity = values.quantity) !== null && _values$quantity !== void 0 ? _values$quantity : product.num) !== null && _ref3 !== void 0 ? _ref3 : 1) || 1;
171
+ var metadataAny = product.metadata || {};
172
+ var existedSource = (_ref4 = (_metadataAny$source_p = metadataAny.source_product_price) !== null && _metadataAny$source_p !== void 0 ? _metadataAny$source_p : product.selling_price) !== null && _ref4 !== void 0 ? _ref4 : '0';
173
+ var nextOptions = product.product_option_item;
174
+ var optionSum = sumOptionUnitPrice(nextOptions);
175
+
176
+ // Rules 返回的 main_product_selling_price / price / total 均为 source-level。
177
+ // 优先级:main_product_selling_price(per-unit 券后 source)> price(还原/good_pass 分支)>
178
+ // total/num(仅当 Rules 只给 total 时的兜底)> 保留当前 source。
179
+ var nextSourceSellingPrice = values.main_product_selling_price !== undefined ? String(values.main_product_selling_price) : values.price !== undefined ? String(values.price) : values.total !== undefined ? toUnitPriceString(values.total, nextNum) : String(existedSource);
180
+
181
+ // 券前 source:values.original_price 是 source-level(Rules 层本就不含 option),
182
+ // 缺省时保留现有 source(券前 = 当前 source)。
183
+ var nextSourceOriginalPrice = values.original_price !== undefined ? String(values.original_price) : String(existedSource);
184
+
185
+ // 含 option 的 main_product_*
186
+ var nextMainSellingPrice = new Decimal(Number(nextSourceSellingPrice) || 0).plus(optionSum).toDecimalPlaces(2).toFixed(2);
187
+ var nextMainOriginalPrice = new Decimal(Number(nextSourceOriginalPrice) || 0).plus(optionSum).toDecimalPlaces(2).toFixed(2);
188
+ var nextBundle = (_values$bundle = values.bundle) !== null && _values$bundle !== void 0 ? _values$bundle : product.product_bundle;
189
+ var composedSellingPrice = composeLinePrice({
190
+ mainPrice: nextMainSellingPrice,
191
+ bundle: nextBundle
192
+ });
193
+ var composedOriginalPrice = composeLinePrice({
194
+ mainPrice: nextMainOriginalPrice,
195
+ bundle: nextBundle,
196
+ useOriginalBundle: true
197
+ });
74
198
  return _objectSpread(_objectSpread({}, product), {}, {
75
- selling_price: nextSellingPrice,
76
- original_price: values.original_price !== undefined ? String(values.original_price) : product.original_price,
199
+ selling_price: composedSellingPrice,
200
+ original_price: composedOriginalPrice,
77
201
  discount_list: (_values$discount_list = values.discount_list) !== null && _values$discount_list !== void 0 ? _values$discount_list : product.discount_list,
78
202
  num: (_values$quantity2 = values.quantity) !== null && _values$quantity2 !== void 0 ? _values$quantity2 : product.num,
79
- product_bundle: (_values$bundle = values.bundle) !== null && _values$bundle !== void 0 ? _values$bundle : product.product_bundle,
80
- metadata: _objectSpread(_objectSpread({}, product.metadata || {}), values.main_product_selling_price !== undefined ? {
81
- main_product_selling_price: String(values.main_product_selling_price)
82
- } : {})
203
+ product_bundle: nextBundle,
204
+ metadata: _objectSpread(_objectSpread({}, metadataAny), {}, {
205
+ source_product_price: nextSourceSellingPrice,
206
+ main_product_selling_price: nextMainSellingPrice,
207
+ main_product_original_price: nextMainOriginalPrice,
208
+ price_schema_version: 2
209
+ })
83
210
  });
84
211
  }
85
212
  };
@@ -187,14 +314,77 @@ function formatSubmitOptionItems(options) {
187
314
  };
188
315
  });
189
316
  }
317
+ function toBundleNumber(value) {
318
+ var fallback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
319
+ var parsed = Number(value);
320
+ return Number.isFinite(parsed) ? parsed : fallback;
321
+ }
322
+ function toBundleCustomPriceString(value) {
323
+ var parsed = Number(value);
324
+ if (Number.isFinite(parsed)) return parsed.toFixed(2);
325
+ if (value === null || value === undefined || value === '') return '0.00';
326
+ return String(value);
327
+ }
328
+
329
+ // 出站补齐:以 additive 方式把 bundle 项补足为后端 checkout 协议所需的形状,
330
+ // 同时把 Summary / Rules 运行时写到 bundle 顶层的 surcharge_fee / relation_surcharge_ids
331
+ // 和来自 _origin 的 product_discount_difference 汇总到 metadata。
332
+ // 保留原对象上已有字段(如 discount_list、metadata.custom_product_bundle_map_id)
333
+ // 以兼容运行时 bundle 归一化、Rules、Summary 的消费。
190
334
  function formatSubmitBundleItems(bundle) {
191
335
  if (!Array.isArray(bundle)) return [];
192
336
  return bundle.map(function (b) {
193
- return _objectSpread(_objectSpread({}, b), {}, {
194
- option: formatSubmitOptionItems(b === null || b === void 0 ? void 0 : b.option)
337
+ var _rawBundle$bundle_sel, _rawBundle$price_type, _ref5, _rawBundle$custom_pri, _rawBundle$surcharge_, _rawBundle$is_charge_, _rawBundle$bundle_var, _rawBundle$extension_, _rawBundle$extension_2, _rawBundle$price_type2, _ref6, _rawBundle$custom_pri2;
338
+ var rawBundle = b && _typeof(b) === 'object' ? b : {};
339
+ var existedMetadata = rawBundle.metadata && _typeof(rawBundle.metadata) === 'object' ? rawBundle.metadata : {};
340
+ var sellingPriceNum = toBundleNumber((_rawBundle$bundle_sel = rawBundle.bundle_selling_price) !== null && _rawBundle$bundle_sel !== void 0 ? _rawBundle$bundle_sel : rawBundle.price, 0);
341
+ var priceNum = toBundleNumber(rawBundle.price, sellingPriceNum);
342
+ var priceType = (_rawBundle$price_type = rawBundle.price_type) !== null && _rawBundle$price_type !== void 0 ? _rawBundle$price_type : '';
343
+ var customPriceStr = toBundleCustomPriceString((_ref5 = (_rawBundle$custom_pri = rawBundle.custom_price) !== null && _rawBundle$custom_pri !== void 0 ? _rawBundle$custom_pri : rawBundle.bundle_selling_price) !== null && _ref5 !== void 0 ? _ref5 : rawBundle.price);
344
+ var relationSurchargeIds = Array.isArray(rawBundle.relation_surcharge_ids) ? rawBundle.relation_surcharge_ids : Array.isArray(existedMetadata.relation_surcharge_ids) ? existedMetadata.relation_surcharge_ids : [];
345
+ var surchargeFee = toBundleNumber((_rawBundle$surcharge_ = rawBundle.surcharge_fee) !== null && _rawBundle$surcharge_ !== void 0 ? _rawBundle$surcharge_ : existedMetadata.surcharge_fee, 0);
346
+ var productDiscountDifference = toBundleNumber(existedMetadata.product_discount_difference, 0);
347
+ return _objectSpread(_objectSpread({}, rawBundle), {}, {
348
+ is_charge_tax: (_rawBundle$is_charge_ = rawBundle.is_charge_tax) !== null && _rawBundle$is_charge_ !== void 0 ? _rawBundle$is_charge_ : 0,
349
+ tax_fee: toBundleNumber(rawBundle.tax_fee, 0),
350
+ bundle_variant_id: (_rawBundle$bundle_var = rawBundle.bundle_variant_id) !== null && _rawBundle$bundle_var !== void 0 ? _rawBundle$bundle_var : 0,
351
+ num: toBundleNumber(rawBundle.num, 1),
352
+ extension_id: (_rawBundle$extension_ = rawBundle.extension_id) !== null && _rawBundle$extension_ !== void 0 ? _rawBundle$extension_ : 0,
353
+ extension_type: (_rawBundle$extension_2 = rawBundle.extension_type) !== null && _rawBundle$extension_2 !== void 0 ? _rawBundle$extension_2 : 'normal',
354
+ price: priceNum,
355
+ price_type: priceType,
356
+ price_type_ext: (_rawBundle$price_type2 = rawBundle.price_type_ext) !== null && _rawBundle$price_type2 !== void 0 ? _rawBundle$price_type2 : '',
357
+ custom_price: customPriceStr,
358
+ custom_price_type: (_ref6 = (_rawBundle$custom_pri2 = rawBundle.custom_price_type) !== null && _rawBundle$custom_pri2 !== void 0 ? _rawBundle$custom_pri2 : priceType) !== null && _ref6 !== void 0 ? _ref6 : '',
359
+ bundle_selling_price: sellingPriceNum,
360
+ option: formatSubmitOptionItems(rawBundle.option),
361
+ bundle_group_id: rawBundle === null || rawBundle === void 0 ? void 0 : rawBundle.group_id,
362
+ bundle_id: rawBundle === null || rawBundle === void 0 ? void 0 : rawBundle.id,
363
+ metadata: _objectSpread(_objectSpread({}, existedMetadata), {}, {
364
+ surcharge_fee: surchargeFee,
365
+ relation_surcharge_ids: relationSurchargeIds,
366
+ product_discount_difference: productDiscountDifference
367
+ })
195
368
  });
196
369
  });
197
370
  }
371
+
372
+ /**
373
+ * 把 tempOrder product 打包成出站 submit payload。
374
+ *
375
+ * 价格字段语义(出站口径,v2 composite):
376
+ * - `selling_price`:**行 composite 券后单价**
377
+ * = `metadata.main_product_selling_price` + Σ(bundle_selling_price × num)。
378
+ * - `original_price`:**行 composite 券前单价**
379
+ * = `metadata.main_product_original_price` + Σ(bundle 原价 × num)。
380
+ * - `payment_price`:兼容后端的出站字段,直接从 `selling_price` 派生(composite)。
381
+ * - `metadata.source_product_price`:主商品/variant 基础价(不含 option、不含折扣),权威源。
382
+ * - `metadata.main_product_original_price`:含 option、不含折扣。
383
+ * - `metadata.main_product_selling_price`:含 option、含主商品折扣。
384
+ * - `metadata.price_schema_version`:schema 版本号(当前 = 2),用于跨端协商价格口径。
385
+ *
386
+ * 本函数不再改造价格字段形状,仅做字段/metadata 裁剪。
387
+ */
198
388
  function normalizeSubmitProduct(product) {
199
389
  var _origin = product._origin,
200
390
  identity_key = product.identity_key,
@@ -205,7 +395,7 @@ function normalizeSubmitProduct(product) {
205
395
  if (rawMetadata.unique_identification_number) {
206
396
  cleanMetadata.unique_identification_number = rawMetadata.unique_identification_number;
207
397
  }
208
- var priceMetaKeys = ['main_product_original_price', 'main_product_selling_price', 'source_product_price'];
398
+ var priceMetaKeys = ['main_product_original_price', 'main_product_selling_price', 'source_product_price', 'price_schema_version'];
209
399
  for (var _i = 0, _priceMetaKeys = priceMetaKeys; _i < _priceMetaKeys.length; _i++) {
210
400
  var key = _priceMetaKeys[_i];
211
401
  if (rawMetadata[key] !== undefined) {
@@ -225,7 +415,8 @@ function normalizeSubmitProduct(product) {
225
415
  discount_list: submitProduct.discount_list || [],
226
416
  product_bundle: formatSubmitBundleItems(submitProduct.product_bundle),
227
417
  metadata: cleanMetadata,
228
- // 出站兼容:后端仍消费 payment_price 字段,从 selling_price(券后单价)派生。
418
+ // 出站兼容:后端消费 payment_price 字段,这里从 selling_price 直接派生。
419
+ // 新语义下 selling_price 是 composite(含 option/bundle),payment_price 同语义。
229
420
  payment_price: submitProduct.selling_price
230
421
  });
231
422
  }
@@ -233,19 +424,19 @@ var SUBMIT_BOOKING_METADATA_WHITELIST = ['unique_identification_number', 'collec
233
424
  export function normalizeSubmitBooking(booking) {
234
425
  var rawMetadata = booking.metadata || {};
235
426
  var cleanMetadata = {};
236
- var _iterator = _createForOfIteratorHelper(SUBMIT_BOOKING_METADATA_WHITELIST),
237
- _step;
427
+ var _iterator3 = _createForOfIteratorHelper(SUBMIT_BOOKING_METADATA_WHITELIST),
428
+ _step3;
238
429
  try {
239
- for (_iterator.s(); !(_step = _iterator.n()).done;) {
240
- var key = _step.value;
430
+ for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
431
+ var key = _step3.value;
241
432
  if (rawMetadata[key] !== undefined) {
242
433
  cleanMetadata[key] = rawMetadata[key];
243
434
  }
244
435
  }
245
436
  } catch (err) {
246
- _iterator.e(err);
437
+ _iterator3.e(err);
247
438
  } finally {
248
- _iterator.f();
439
+ _iterator3.f();
249
440
  }
250
441
  return _objectSpread(_objectSpread({}, booking), {}, {
251
442
  metadata: cleanMetadata
@@ -326,7 +517,7 @@ export function createDefaultTempOrder(params) {
326
517
  };
327
518
  }
328
519
  export function buildSubmitPayload(params) {
329
- var _ref2, _ref3, _ref4, _tempOrder$is_price_i, _tempOrder$is_deposit;
520
+ var _ref7, _ref8, _ref9, _tempOrder$is_price_i, _tempOrder$is_deposit;
330
521
  var tempOrder = params.tempOrder,
331
522
  cacheId = params.cacheId,
332
523
  _params$now = params.now,
@@ -374,10 +565,10 @@ export function buildSubmitPayload(params) {
374
565
  var payload = _objectSpread(_objectSpread({}, tempOrderRest), {}, {
375
566
  platform: normalizeSubmitPlatform(platform !== null && platform !== void 0 ? platform : tempOrder.platform),
376
567
  request_unique_idempotency_token: cacheId,
377
- type: (_ref2 = type !== null && type !== void 0 ? type : tempOrder.type) !== null && _ref2 !== void 0 ? _ref2 : 'table-order',
378
- business_code: (_ref3 = businessCode !== null && businessCode !== void 0 ? businessCode : tempOrder.business_code) !== null && _ref3 !== void 0 ? _ref3 : 'table-order',
568
+ type: (_ref7 = type !== null && type !== void 0 ? type : tempOrder.type) !== null && _ref7 !== void 0 ? _ref7 : 'table-order',
569
+ business_code: (_ref8 = businessCode !== null && businessCode !== void 0 ? businessCode : tempOrder.business_code) !== null && _ref8 !== void 0 ? _ref8 : 'table-order',
379
570
  sales_channel: tempOrder.sales_channel || 'my_pisel',
380
- order_sales_channel: (_ref4 = channel !== null && channel !== void 0 ? channel : tempOrder.order_sales_channel) !== null && _ref4 !== void 0 ? _ref4 : 'online_store',
571
+ order_sales_channel: (_ref9 = channel !== null && channel !== void 0 ? channel : tempOrder.order_sales_channel) !== null && _ref9 !== void 0 ? _ref9 : 'online_store',
381
572
  status: tempOrder.status || 'normal',
382
573
  payment_status: tempOrder.payment_status || 'payment_processing',
383
574
  // shipping_status: tempOrder.shipping_status || 'unfulfilled',
@@ -401,10 +592,10 @@ export function buildSubmitPayload(params) {
401
592
  // holder: tempOrder.holder || null,
402
593
  // summary,
403
594
  metadata: function () {
404
- var _ref5 = tempOrder.metadata || {},
405
- _collectPax = _ref5.collect_pax,
406
- _tableOccupancyDuration = _ref5.table_occupancy_duration,
407
- rest = _objectWithoutProperties(_ref5, _excluded3);
595
+ var _ref10 = tempOrder.metadata || {},
596
+ _collectPax = _ref10.collect_pax,
597
+ _tableOccupancyDuration = _ref10.table_occupancy_duration,
598
+ rest = _objectWithoutProperties(_ref10, _excluded3);
408
599
  return _objectSpread({}, rest);
409
600
  }(),
410
601
  products: (tempOrder.products || []).map(function (product) {
@@ -425,6 +616,14 @@ export function filterProductsForScanOrderMore(products) {
425
616
  return ((_p$metadata = p.metadata) === null || _p$metadata === void 0 ? void 0 : _p$metadata.is_rule) !== true;
426
617
  });
427
618
  }
619
+
620
+ /**
621
+ * 历史 V1 加餐结构映射器。
622
+ *
623
+ * @deprecated 加餐(`PUT /order/order/product/:id`)已改为与正常 checkout 共用
624
+ * `ScanOrderSubmitProduct` 新结构(见 `OrderModule.submitTempOrder` 的加餐分支)。
625
+ * 本函数仅保留以兼容历史接入方,未来会移除。新代码请勿再调用。
626
+ */
428
627
  export function formatV1Product(products) {
429
628
  return products.map(function (product) {
430
629
  var _product$note;
@@ -19,41 +19,6 @@ function getSafeNum(num) {
19
19
  if (num < 1) return 1;
20
20
  return Math.floor(num);
21
21
  }
22
- function getVariantPrice(product) {
23
- var _product$metadata;
24
- var variantId = Number(product.product_variant_id || 0);
25
- if (!variantId) return null;
26
-
27
- // TODO: callbackData 在 src/ 内无写入方,暂时注释掉观察
28
- // const callbackVariantList = product._origin?.callbackData?.origin?.variant;
29
- // if (Array.isArray(callbackVariantList)) {
30
- // const variant = callbackVariantList.find(
31
- // (item: any) => Number(item.id) === variantId,
32
- // );
33
- // if (variant?.price !== undefined && variant?.price !== null) {
34
- // return toDecimal(variant.price);
35
- // }
36
- // }
37
-
38
- var metadataVariantList = (_product$metadata = product.metadata) === null || _product$metadata === void 0 || (_product$metadata = _product$metadata.origin) === null || _product$metadata === void 0 ? void 0 : _product$metadata.variant;
39
- if (Array.isArray(metadataVariantList)) {
40
- var variant = metadataVariantList.find(function (item) {
41
- return Number(item.id) === variantId;
42
- });
43
- if ((variant === null || variant === void 0 ? void 0 : variant.price) !== undefined && (variant === null || variant === void 0 ? void 0 : variant.price) !== null) {
44
- return toDecimal(variant.price);
45
- }
46
- }
47
- return null;
48
- }
49
- function getOptionUnitPrice(product) {
50
- var optionItems = product.product_option_item || [];
51
- return optionItems.reduce(function (sum, item) {
52
- var quantity = getSafeNum(item === null || item === void 0 ? void 0 : item.num);
53
- var itemPrice = toDecimal(item === null || item === void 0 ? void 0 : item.price);
54
- return sum.plus(itemPrice.times(quantity));
55
- }, new Decimal(0));
56
- }
57
22
  function getBundleUnitPrice(product) {
58
23
  var useOriginal = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
59
24
  var bundleItems = product.product_bundle || [];
@@ -65,19 +30,27 @@ function getBundleUnitPrice(product) {
65
30
  }, new Decimal(0));
66
31
  }
67
32
 
68
- // 单商品总价口径:主商品单价 + option + bundle(随后再乘商品数量)
33
+ // 单商品 composite 单价(随后再乘商品数量):
34
+ // 新语义 v2 下 `metadata.main_product_selling_price` 已经是"含 option、含主商品折扣"的主价,
35
+ // composite 单价 = main_product_selling_price + Σ(bundle_selling_price × num)。
36
+ // 不再叠加 options(会重复计算),也不再用 variant/selling_price 兜底(选项已固化进 metadata)。
69
37
  function getUnitPaymentTotal(product) {
70
- var variantPrice = getVariantPrice(product);
71
- var basePrice = variantPrice || toDecimal(product.selling_price);
72
- return basePrice.plus(getOptionUnitPrice(product)).plus(getBundleUnitPrice(product));
38
+ var _product$metadata, _product$metadata2;
39
+ var mainSelling = (_product$metadata = product.metadata) === null || _product$metadata === void 0 ? void 0 : _product$metadata.main_product_selling_price;
40
+ var mainOriginal = (_product$metadata2 = product.metadata) === null || _product$metadata2 === void 0 ? void 0 : _product$metadata2.main_product_original_price;
41
+ var basePrice = mainSelling !== undefined ? toDecimal(mainSelling) : mainOriginal !== undefined ? toDecimal(mainOriginal) : toDecimal(product.selling_price);
42
+ return basePrice.plus(getBundleUnitPrice(product));
73
43
  }
74
44
  function getUnitOriginalTotal(product) {
75
- var basePrice = toDecimal(product.original_price || product.selling_price);
76
- return basePrice.plus(getOptionUnitPrice(product)).plus(getBundleUnitPrice(product, true));
45
+ var _product$metadata3, _product$metadata4;
46
+ var mainOriginal = (_product$metadata3 = product.metadata) === null || _product$metadata3 === void 0 ? void 0 : _product$metadata3.main_product_original_price;
47
+ var mainSelling = (_product$metadata4 = product.metadata) === null || _product$metadata4 === void 0 ? void 0 : _product$metadata4.main_product_selling_price;
48
+ var basePrice = mainOriginal !== undefined ? toDecimal(mainOriginal) : mainSelling !== undefined ? toDecimal(mainSelling) : toDecimal(product.original_price || product.selling_price);
49
+ return basePrice.plus(getBundleUnitPrice(product, true));
77
50
  }
78
51
  function buildSurchargeServiceItems(products) {
79
52
  return products.map(function (product) {
80
- var _product$is_charge_ta, _product$metadata2, _product$metadata3;
53
+ var _product$is_charge_ta, _product$metadata5, _product$metadata6;
81
54
  var quantity = getSafeNum(product.num);
82
55
  var unitTotal = getUnitPaymentTotal(product);
83
56
  return {
@@ -99,8 +72,8 @@ function buildSurchargeServiceItems(products) {
99
72
  options: product.product_option_item || [],
100
73
  relation_details: [],
101
74
  metadata: product.metadata || {},
102
- start_date: ((_product$metadata2 = product.metadata) === null || _product$metadata2 === void 0 ? void 0 : _product$metadata2.start_date) || '',
103
- start_time: ((_product$metadata3 = product.metadata) === null || _product$metadata3 === void 0 ? void 0 : _product$metadata3.start_time) || ''
75
+ start_date: ((_product$metadata5 = product.metadata) === null || _product$metadata5 === void 0 ? void 0 : _product$metadata5.start_date) || '',
76
+ start_time: ((_product$metadata6 = product.metadata) === null || _product$metadata6 === void 0 ? void 0 : _product$metadata6.start_time) || ''
104
77
  };
105
78
  });
106
79
  }
@@ -221,11 +194,6 @@ function isBundleMarkupOrDiscount(item) {
221
194
  var isDiscount = (item === null || item === void 0 ? void 0 : item.price_type) === 'markdown' && ((item === null || item === void 0 ? void 0 : item.price_type_ext) === '' || !(item !== null && item !== void 0 && item.price_type_ext));
222
195
  return isMarkup || isDiscount;
223
196
  }
224
- function getDiscountListAmount(discountList) {
225
- return (discountList || []).reduce(function (total, d) {
226
- return total.plus(toDecimal(d.amount));
227
- }, new Decimal(0));
228
- }
229
197
 
230
198
  /**
231
199
  * 计算单个商品税费(返回精确值,不四舍五入)。
@@ -250,20 +218,17 @@ function calculateSingleItemTax(params) {
250
218
  }
251
219
 
252
220
  /**
253
- * 获取主商品折扣后总价(主体价格 + option + 加价/减价 bundle)。
254
- * 与 Summary/utils.ts 的 getMainProductTotal 逻辑对齐,适配 SalesSummaryProduct 结构。
221
+ * 获取主商品折扣后总价(含 option、含主商品折扣、含加价/减价 bundle)。
222
+ *
223
+ * 新语义 v2 下:
224
+ * - `metadata.main_product_selling_price` 已是"含 option、含折扣"的主价,直接读即可;
225
+ * - 无需再 `minus(mainDiscountAmount)` 或 `plus(getOptionUnitPrice)`;
226
+ * - 仅需叠加 `markup` / `markdown` 类 bundle(原价 bundle 已由 `calculateProductsTax` 独立处理)。
255
227
  */
256
228
  function getMainProductPaymentTotal(product) {
257
- var _product$metadata$mai, _product$metadata4, _product$_origin3, _product$_origin4;
258
- var variantPrice = getVariantPrice(product);
259
- var total = variantPrice || toDecimal((_product$metadata$mai = (_product$metadata4 = product.metadata) === null || _product$metadata4 === void 0 ? void 0 : _product$metadata4.main_product_selling_price) !== null && _product$metadata$mai !== void 0 ? _product$metadata$mai : product.selling_price);
260
- var mainDiscountList = ((_product$_origin3 = product._origin) === null || _product$_origin3 === void 0 || (_product$_origin3 = _product$_origin3.product) === null || _product$_origin3 === void 0 ? void 0 : _product$_origin3.discount_list) || ((_product$_origin4 = product._origin) === null || _product$_origin4 === void 0 ? void 0 : _product$_origin4.discount_list) || [];
261
- var mainDiscountAmount = getDiscountListAmount(mainDiscountList.filter(function (d) {
262
- var _d$metadata;
263
- return !(d !== null && d !== void 0 && (_d$metadata = d.metadata) !== null && _d$metadata !== void 0 && _d$metadata.custom_product_bundle_map_id);
264
- }));
265
- total = total.minus(mainDiscountAmount);
266
- total = total.plus(getOptionUnitPrice(product));
229
+ var _ref2, _product$metadata$mai, _product$metadata7, _product$metadata8;
230
+ var mainSelling = (_ref2 = (_product$metadata$mai = (_product$metadata7 = product.metadata) === null || _product$metadata7 === void 0 ? void 0 : _product$metadata7.main_product_selling_price) !== null && _product$metadata$mai !== void 0 ? _product$metadata$mai : (_product$metadata8 = product.metadata) === null || _product$metadata8 === void 0 ? void 0 : _product$metadata8.main_product_original_price) !== null && _ref2 !== void 0 ? _ref2 : 0;
231
+ var total = toDecimal(mainSelling);
267
232
  var bundleItems = product.product_bundle || [];
268
233
  var _iterator5 = _createForOfIteratorHelper(bundleItems),
269
234
  _step5;
@@ -271,8 +236,8 @@ function getMainProductPaymentTotal(product) {
271
236
  for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
272
237
  var bundleItem = _step5.value;
273
238
  if (isBundleMarkupOrDiscount(bundleItem)) {
274
- var _ref2, _bundleItem$bundle_se;
275
- total = total.plus(toDecimal((_ref2 = (_bundleItem$bundle_se = bundleItem.bundle_selling_price) !== null && _bundleItem$bundle_se !== void 0 ? _bundleItem$bundle_se : bundleItem.price) !== null && _ref2 !== void 0 ? _ref2 : 0));
239
+ var _ref3, _bundleItem$bundle_se;
240
+ total = total.plus(toDecimal((_ref3 = (_bundleItem$bundle_se = bundleItem.bundle_selling_price) !== null && _bundleItem$bundle_se !== void 0 ? _bundleItem$bundle_se : bundleItem.price) !== null && _ref3 !== void 0 ? _ref3 : 0));
276
241
  }
277
242
  }
278
243
  } catch (err) {
@@ -340,24 +305,24 @@ function calculateProductsTax(products, taxRate, isPriceIncludeTax) {
340
305
  _step7;
341
306
  try {
342
307
  for (_iterator7.s(); !(_step7 = _iterator7.n()).done;) {
343
- var _bundleItem$num, _ref3, _bundleItem$bundle_se2, _ref4, _ref5, _bundleItem$original_, _ref6, _bundleItem$is_charge, _ref7, _bundleItem$is_charge2;
308
+ var _bundleItem$num, _ref4, _bundleItem$bundle_se2, _ref5, _ref6, _bundleItem$original_, _ref7, _bundleItem$is_charge, _ref8, _bundleItem$is_charge2;
344
309
  var bundleItem = _step7.value;
345
310
  if (!isBundleOriginalPrice(bundleItem)) continue;
346
311
  var bundleQuantity = new Decimal(getSafeNum((_bundleItem$num = bundleItem.num) !== null && _bundleItem$num !== void 0 ? _bundleItem$num : bundleItem.quantity));
347
- var bundlePrice = toDecimal((_ref3 = (_bundleItem$bundle_se2 = bundleItem.bundle_selling_price) !== null && _bundleItem$bundle_se2 !== void 0 ? _bundleItem$bundle_se2 : bundleItem.price) !== null && _ref3 !== void 0 ? _ref3 : 0);
348
- var bundleOriginalPrice = toDecimal((_ref4 = (_ref5 = (_bundleItem$original_ = bundleItem.original_price) !== null && _bundleItem$original_ !== void 0 ? _bundleItem$original_ : bundleItem.product_price) !== null && _ref5 !== void 0 ? _ref5 : bundleItem.price) !== null && _ref4 !== void 0 ? _ref4 : 0);
312
+ var bundlePrice = toDecimal((_ref4 = (_bundleItem$bundle_se2 = bundleItem.bundle_selling_price) !== null && _bundleItem$bundle_se2 !== void 0 ? _bundleItem$bundle_se2 : bundleItem.price) !== null && _ref4 !== void 0 ? _ref4 : 0);
313
+ var bundleOriginalPrice = toDecimal((_ref5 = (_ref6 = (_bundleItem$original_ = bundleItem.original_price) !== null && _bundleItem$original_ !== void 0 ? _bundleItem$original_ : bundleItem.product_price) !== null && _ref6 !== void 0 ? _ref6 : bundleItem.price) !== null && _ref5 !== void 0 ? _ref5 : 0);
349
314
  var bundleTaxPrecise = calculateSingleItemTax({
350
315
  price: bundlePrice,
351
316
  taxRate: rate,
352
317
  isPriceIncludeTax: isPriceIncludeTax,
353
- isChargeTax: (_ref6 = (_bundleItem$is_charge = bundleItem.is_charge_tax) !== null && _bundleItem$is_charge !== void 0 ? _bundleItem$is_charge : product.is_charge_tax) !== null && _ref6 !== void 0 ? _ref6 : 0
318
+ isChargeTax: (_ref7 = (_bundleItem$is_charge = bundleItem.is_charge_tax) !== null && _bundleItem$is_charge !== void 0 ? _bundleItem$is_charge : product.is_charge_tax) !== null && _ref7 !== void 0 ? _ref7 : 0
354
319
  });
355
320
  var bundleTaxRounded = bundleTaxPrecise.toDecimalPlaces(2, Decimal.ROUND_HALF_UP);
356
321
  var bundleOrigTaxPrecise = calculateSingleItemTax({
357
322
  price: bundleOriginalPrice,
358
323
  taxRate: rate,
359
324
  isPriceIncludeTax: isPriceIncludeTax,
360
- isChargeTax: (_ref7 = (_bundleItem$is_charge2 = bundleItem.is_charge_tax) !== null && _bundleItem$is_charge2 !== void 0 ? _bundleItem$is_charge2 : product.is_charge_tax) !== null && _ref7 !== void 0 ? _ref7 : 0
325
+ isChargeTax: (_ref8 = (_bundleItem$is_charge2 = bundleItem.is_charge_tax) !== null && _bundleItem$is_charge2 !== void 0 ? _bundleItem$is_charge2 : product.is_charge_tax) !== null && _ref8 !== void 0 ? _ref8 : 0
361
326
  });
362
327
  var bundleOrigTaxRounded = bundleOrigTaxPrecise.toDecimalPlaces(2, Decimal.ROUND_HALF_UP);
363
328
  bundleItem.tax_fee = bundleTaxRounded.toNumber();