@pisell/pisellos 2.1.170 → 2.1.172

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (231) hide show
  1. package/dist/index.d.ts +1 -1
  2. package/dist/index.js +1 -3
  3. package/dist/model/strategy/adapter/index.d.ts +0 -4
  4. package/dist/model/strategy/adapter/index.js +1 -5
  5. package/dist/model/strategy/adapter/promotion/evaluator.js +99 -26
  6. package/dist/model/strategy/adapter/promotion/index.js +0 -9
  7. package/dist/model/strategy/adapter/walletPass/evaluator.d.ts +2 -0
  8. package/dist/model/strategy/adapter/walletPass/evaluator.js +61 -8
  9. package/dist/model/strategy/adapter/walletPass/locales.js +12 -3
  10. package/dist/model/strategy/engine.d.ts +18 -5
  11. package/dist/model/strategy/engine.js +145 -45
  12. package/dist/model/strategy/type.d.ts +17 -0
  13. package/dist/model/strategy/type.js +4 -0
  14. package/dist/modules/Cart/types.d.ts +2 -0
  15. package/dist/modules/Cart/utils/cartProduct.js +56 -25
  16. package/dist/modules/Cart/utils/changePrice.js +9 -16
  17. package/dist/modules/Discount/index.d.ts +4 -13
  18. package/dist/modules/Discount/index.js +12 -124
  19. package/dist/modules/Discount/types.d.ts +18 -13
  20. package/dist/modules/Order/index.d.ts +1 -67
  21. package/dist/modules/Order/index.js +30 -918
  22. package/dist/modules/Order/types.d.ts +12 -176
  23. package/dist/modules/Order/types.js +0 -2
  24. package/dist/modules/Order/utils.d.ts +0 -118
  25. package/dist/modules/Order/utils.js +2 -586
  26. package/dist/modules/Payment/index.d.ts +2 -1
  27. package/dist/modules/Payment/index.js +10 -7
  28. package/dist/modules/Payment/utils.js +3 -0
  29. package/dist/modules/Payment/walletpass.d.ts +23 -0
  30. package/dist/modules/Payment/walletpass.js +191 -95
  31. package/dist/modules/Product/utils.js +2 -2
  32. package/dist/modules/ProductList/index.d.ts +2 -4
  33. package/dist/modules/ProductList/index.js +12 -24
  34. package/dist/modules/Rules/index.d.ts +9 -5
  35. package/dist/modules/Rules/index.js +669 -173
  36. package/dist/modules/Rules/types.d.ts +2 -0
  37. package/dist/modules/Schedule/getDateIsInSchedule.js +18 -16
  38. package/dist/modules/Schedule/utils.d.ts +1 -1
  39. package/dist/modules/Summary/types.d.ts +2 -0
  40. package/dist/modules/Summary/utils.d.ts +9 -3
  41. package/dist/modules/Summary/utils.js +57 -67
  42. package/dist/modules/index.d.ts +0 -4
  43. package/dist/modules/index.js +1 -5
  44. package/dist/plugins/window.d.ts +2 -0
  45. package/dist/solution/BookingByStep/index.d.ts +3 -2
  46. package/dist/solution/BookingByStep/index.js +43 -46
  47. package/dist/solution/BookingByStep/types.d.ts +1 -3
  48. package/dist/solution/BookingByStep/types.js +1 -5
  49. package/dist/solution/BookingByStep/utils/timeslots.d.ts +1 -3
  50. package/dist/solution/BookingByStep/utils/timeslots.js +12 -19
  51. package/dist/solution/Checkout/index.js +2 -0
  52. package/dist/solution/ShopDiscount/index.d.ts +2 -3
  53. package/dist/solution/ShopDiscount/index.js +60 -62
  54. package/dist/solution/ShopDiscount/types.d.ts +1 -1
  55. package/dist/solution/ShopDiscount/types.js +2 -1
  56. package/dist/solution/ShopDiscount/utils.js +26 -12
  57. package/dist/solution/index.d.ts +0 -2
  58. package/dist/solution/index.js +1 -3
  59. package/lib/index.d.ts +1 -1
  60. package/lib/index.js +3 -4
  61. package/lib/model/strategy/adapter/index.d.ts +0 -4
  62. package/lib/model/strategy/adapter/index.js +2 -13
  63. package/lib/model/strategy/adapter/promotion/evaluator.js +57 -8
  64. package/lib/model/strategy/adapter/walletPass/evaluator.d.ts +2 -0
  65. package/lib/model/strategy/adapter/walletPass/evaluator.js +34 -3
  66. package/lib/model/strategy/adapter/walletPass/locales.js +12 -3
  67. package/lib/model/strategy/engine.d.ts +18 -5
  68. package/lib/model/strategy/engine.js +85 -21
  69. package/lib/model/strategy/type.d.ts +17 -0
  70. package/lib/modules/Cart/types.d.ts +2 -0
  71. package/lib/modules/Cart/utils/cartProduct.js +39 -12
  72. package/lib/modules/Cart/utils/changePrice.js +9 -13
  73. package/lib/modules/Discount/index.d.ts +4 -13
  74. package/lib/modules/Discount/index.js +5 -76
  75. package/lib/modules/Discount/types.d.ts +18 -13
  76. package/lib/modules/Order/index.d.ts +1 -67
  77. package/lib/modules/Order/index.js +1 -525
  78. package/lib/modules/Order/types.d.ts +12 -176
  79. package/lib/modules/Order/utils.d.ts +0 -118
  80. package/lib/modules/Order/utils.js +2 -483
  81. package/lib/modules/Payment/index.d.ts +2 -1
  82. package/lib/modules/Payment/index.js +1 -0
  83. package/lib/modules/Payment/utils.js +3 -0
  84. package/lib/modules/Payment/walletpass.d.ts +23 -0
  85. package/lib/modules/Payment/walletpass.js +94 -17
  86. package/lib/modules/Product/utils.js +2 -2
  87. package/lib/modules/ProductList/index.d.ts +2 -4
  88. package/lib/modules/ProductList/index.js +39 -46
  89. package/lib/modules/Rules/index.d.ts +9 -5
  90. package/lib/modules/Rules/index.js +776 -292
  91. package/lib/modules/Rules/types.d.ts +2 -0
  92. package/lib/modules/Schedule/getDateIsInSchedule.js +11 -13
  93. package/lib/modules/Schedule/utils.d.ts +1 -1
  94. package/lib/modules/Summary/types.d.ts +2 -0
  95. package/lib/modules/Summary/utils.d.ts +9 -3
  96. package/lib/modules/Summary/utils.js +34 -45
  97. package/lib/modules/index.d.ts +0 -4
  98. package/lib/modules/index.js +1 -9
  99. package/lib/plugins/window.d.ts +2 -0
  100. package/lib/solution/BookingByStep/index.d.ts +3 -2
  101. package/lib/solution/BookingByStep/index.js +4 -6
  102. package/lib/solution/BookingByStep/types.d.ts +1 -3
  103. package/lib/solution/BookingByStep/types.js +0 -10
  104. package/lib/solution/BookingByStep/utils/timeslots.d.ts +1 -3
  105. package/lib/solution/BookingByStep/utils/timeslots.js +11 -19
  106. package/lib/solution/Checkout/index.js +2 -0
  107. package/lib/solution/ShopDiscount/index.d.ts +2 -3
  108. package/lib/solution/ShopDiscount/index.js +27 -22
  109. package/lib/solution/ShopDiscount/types.d.ts +1 -1
  110. package/lib/solution/ShopDiscount/utils.js +10 -6
  111. package/lib/solution/index.d.ts +0 -2
  112. package/lib/solution/index.js +1 -5
  113. package/package.json +2 -2
  114. package/dist/apis/picoding.d.ts +0 -0
  115. package/dist/apis/picoding.js +0 -1
  116. package/dist/model/strategy/adapter/dataVariant/adapter.d.ts +0 -50
  117. package/dist/model/strategy/adapter/dataVariant/adapter.js +0 -167
  118. package/dist/model/strategy/adapter/dataVariant/evaluator.d.ts +0 -89
  119. package/dist/model/strategy/adapter/dataVariant/evaluator.js +0 -867
  120. package/dist/model/strategy/adapter/dataVariant/examples.d.ts +0 -39
  121. package/dist/model/strategy/adapter/dataVariant/examples.js +0 -277
  122. package/dist/model/strategy/adapter/dataVariant/index.d.ts +0 -4
  123. package/dist/model/strategy/adapter/dataVariant/index.js +0 -4
  124. package/dist/model/strategy/adapter/dataVariant/type.d.ts +0 -149
  125. package/dist/model/strategy/adapter/dataVariant/type.js +0 -54
  126. package/dist/modules/OpenData/index.d.ts +0 -24
  127. package/dist/modules/OpenData/index.js +0 -173
  128. package/dist/modules/OpenData/types.d.ts +0 -73
  129. package/dist/modules/OpenData/types.js +0 -1
  130. package/dist/modules/OpenData/utils.d.ts +0 -2
  131. package/dist/modules/OpenData/utils.js +0 -75
  132. package/dist/modules/Quotation/index.d.ts +0 -48
  133. package/dist/modules/Quotation/index.js +0 -248
  134. package/dist/modules/Quotation/types.d.ts +0 -42
  135. package/dist/modules/Quotation/types.js +0 -1
  136. package/dist/modules/SalesSummary/index.d.ts +0 -63
  137. package/dist/modules/SalesSummary/index.js +0 -174
  138. package/dist/modules/SalesSummary/types.d.ts +0 -60
  139. package/dist/modules/SalesSummary/types.js +0 -1
  140. package/dist/modules/SalesSummary/utils.d.ts +0 -30
  141. package/dist/modules/SalesSummary/utils.js +0 -480
  142. package/dist/modules/ScanOrderLogger/index.d.ts +0 -23
  143. package/dist/modules/ScanOrderLogger/index.js +0 -174
  144. package/dist/modules/ScanOrderLogger/providers/feishu.d.ts +0 -2
  145. package/dist/modules/ScanOrderLogger/providers/feishu.js +0 -221
  146. package/dist/modules/ScanOrderLogger/providers/grafana.d.ts +0 -2
  147. package/dist/modules/ScanOrderLogger/providers/grafana.js +0 -50
  148. package/dist/modules/ScanOrderLogger/types.d.ts +0 -53
  149. package/dist/modules/ScanOrderLogger/types.js +0 -1
  150. package/dist/solution/ScanOrder/index.d.ts +0 -158
  151. package/dist/solution/ScanOrder/index.js +0 -3474
  152. package/dist/solution/ScanOrder/types.d.ts +0 -306
  153. package/dist/solution/ScanOrder/types.js +0 -35
  154. package/dist/solution/ScanOrder/utils.d.ts +0 -172
  155. package/dist/solution/ScanOrder/utils.js +0 -796
  156. package/dist/solution/VenueBooking/index.d.ts +0 -252
  157. package/dist/solution/VenueBooking/index.js +0 -3769
  158. package/dist/solution/VenueBooking/sales-section-4-annotated.json +0 -343
  159. package/dist/solution/VenueBooking/types.d.ts +0 -156
  160. package/dist/solution/VenueBooking/types.js +0 -22
  161. package/dist/solution/VenueBooking/utils/dateSummary.d.ts +0 -11
  162. package/dist/solution/VenueBooking/utils/dateSummary.js +0 -91
  163. package/dist/solution/VenueBooking/utils/resource.d.ts +0 -14
  164. package/dist/solution/VenueBooking/utils/resource.js +0 -131
  165. package/dist/solution/VenueBooking/utils/slotMerge.d.ts +0 -32
  166. package/dist/solution/VenueBooking/utils/slotMerge.js +0 -233
  167. package/dist/solution/VenueBooking/utils/smartPricing.d.ts +0 -71
  168. package/dist/solution/VenueBooking/utils/smartPricing.js +0 -302
  169. package/dist/solution/VenueBooking/utils/timeSlot.d.ts +0 -34
  170. package/dist/solution/VenueBooking/utils/timeSlot.js +0 -458
  171. package/dist/solution/VenueBooking/utils.d.ts +0 -1
  172. package/dist/solution/VenueBooking/utils.js +0 -1
  173. package/lib/apis/picoding.d.ts +0 -0
  174. package/lib/apis/picoding.js +0 -0
  175. package/lib/model/strategy/adapter/dataVariant/adapter.d.ts +0 -50
  176. package/lib/model/strategy/adapter/dataVariant/adapter.js +0 -149
  177. package/lib/model/strategy/adapter/dataVariant/evaluator.d.ts +0 -89
  178. package/lib/model/strategy/adapter/dataVariant/evaluator.js +0 -666
  179. package/lib/model/strategy/adapter/dataVariant/examples.d.ts +0 -39
  180. package/lib/model/strategy/adapter/dataVariant/examples.js +0 -293
  181. package/lib/model/strategy/adapter/dataVariant/index.d.ts +0 -4
  182. package/lib/model/strategy/adapter/dataVariant/index.js +0 -38
  183. package/lib/model/strategy/adapter/dataVariant/type.d.ts +0 -149
  184. package/lib/model/strategy/adapter/dataVariant/type.js +0 -31
  185. package/lib/modules/OpenData/index.d.ts +0 -24
  186. package/lib/modules/OpenData/index.js +0 -119
  187. package/lib/modules/OpenData/types.d.ts +0 -73
  188. package/lib/modules/OpenData/types.js +0 -17
  189. package/lib/modules/OpenData/utils.d.ts +0 -2
  190. package/lib/modules/OpenData/utils.js +0 -111
  191. package/lib/modules/Quotation/index.d.ts +0 -48
  192. package/lib/modules/Quotation/index.js +0 -152
  193. package/lib/modules/Quotation/types.d.ts +0 -42
  194. package/lib/modules/Quotation/types.js +0 -17
  195. package/lib/modules/SalesSummary/index.d.ts +0 -63
  196. package/lib/modules/SalesSummary/index.js +0 -105
  197. package/lib/modules/SalesSummary/types.d.ts +0 -60
  198. package/lib/modules/SalesSummary/types.js +0 -17
  199. package/lib/modules/SalesSummary/utils.d.ts +0 -30
  200. package/lib/modules/SalesSummary/utils.js +0 -420
  201. package/lib/modules/ScanOrderLogger/index.d.ts +0 -23
  202. package/lib/modules/ScanOrderLogger/index.js +0 -147
  203. package/lib/modules/ScanOrderLogger/providers/feishu.d.ts +0 -2
  204. package/lib/modules/ScanOrderLogger/providers/feishu.js +0 -157
  205. package/lib/modules/ScanOrderLogger/providers/grafana.d.ts +0 -2
  206. package/lib/modules/ScanOrderLogger/providers/grafana.js +0 -52
  207. package/lib/modules/ScanOrderLogger/types.d.ts +0 -53
  208. package/lib/modules/ScanOrderLogger/types.js +0 -17
  209. package/lib/solution/ScanOrder/index.d.ts +0 -158
  210. package/lib/solution/ScanOrder/index.js +0 -2135
  211. package/lib/solution/ScanOrder/types.d.ts +0 -306
  212. package/lib/solution/ScanOrder/types.js +0 -36
  213. package/lib/solution/ScanOrder/utils.d.ts +0 -172
  214. package/lib/solution/ScanOrder/utils.js +0 -658
  215. package/lib/solution/VenueBooking/index.d.ts +0 -252
  216. package/lib/solution/VenueBooking/index.js +0 -2204
  217. package/lib/solution/VenueBooking/sales-section-4-annotated.json +0 -343
  218. package/lib/solution/VenueBooking/types.d.ts +0 -156
  219. package/lib/solution/VenueBooking/types.js +0 -45
  220. package/lib/solution/VenueBooking/utils/dateSummary.d.ts +0 -11
  221. package/lib/solution/VenueBooking/utils/dateSummary.js +0 -105
  222. package/lib/solution/VenueBooking/utils/resource.d.ts +0 -14
  223. package/lib/solution/VenueBooking/utils/resource.js +0 -92
  224. package/lib/solution/VenueBooking/utils/slotMerge.d.ts +0 -32
  225. package/lib/solution/VenueBooking/utils/slotMerge.js +0 -236
  226. package/lib/solution/VenueBooking/utils/smartPricing.d.ts +0 -71
  227. package/lib/solution/VenueBooking/utils/smartPricing.js +0 -225
  228. package/lib/solution/VenueBooking/utils/timeSlot.d.ts +0 -34
  229. package/lib/solution/VenueBooking/utils/timeSlot.js +0 -343
  230. package/lib/solution/VenueBooking/utils.d.ts +0 -1
  231. package/lib/solution/VenueBooking/utils.js +0 -69
@@ -1,60 +0,0 @@
1
- export interface SalesSummaryProduct {
2
- product_id: number | null;
3
- product_variant_id: number;
4
- num: number;
5
- /** 券后单品单价(订单域成交单价),由 OrderModule 维护。 */
6
- selling_price: string;
7
- /** 券前单品单价(店铺售价)。 */
8
- original_price: string;
9
- tax_fee: string;
10
- is_charge_tax?: number;
11
- product_option_item?: any[];
12
- discount_list?: any[];
13
- product_bundle?: any[];
14
- metadata?: Record<string, any>;
15
- _origin?: Record<string, any>;
16
- }
17
- export interface DepositPolicyData {
18
- id: number;
19
- title: string;
20
- }
21
- export interface DepositInfo {
22
- total: string;
23
- deposit_policy_ids: number[];
24
- deposit_policy_data: DepositPolicyData[];
25
- hasDeposit: boolean;
26
- }
27
- export interface SalesSummaryData {
28
- product_quantity: number;
29
- product_original_amount: string;
30
- product_amount: string;
31
- product_expect_amount: string;
32
- product_tax_fee: string;
33
- shipping_fee: string;
34
- shipping_tax_fee: string;
35
- tax_fee: string;
36
- surcharge_fee: string;
37
- surcharges: any[];
38
- discount_amount: string;
39
- deposit_amount: string;
40
- deposit?: DepositInfo;
41
- expect_amount: string;
42
- total_amount: string;
43
- amount_gap: string;
44
- rounding_amount: string;
45
- pay_service_charge_amount: string;
46
- is_price_include_tax?: number;
47
- tax_title?: string;
48
- tax_rate?: number;
49
- }
50
- export interface SalesSummaryState {
51
- surchargeList: any[];
52
- summary: SalesSummaryData;
53
- }
54
- export interface SalesSummaryModuleAPI {
55
- getSummary(params: {
56
- products: SalesSummaryProduct[];
57
- isPriceIncludeTax?: number;
58
- taxRate?: number;
59
- }): Promise<SalesSummaryData>;
60
- }
@@ -1,17 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __copyProps = (to, from, except, desc) => {
6
- if (from && typeof from === "object" || typeof from === "function") {
7
- for (let key of __getOwnPropNames(from))
8
- if (!__hasOwnProp.call(to, key) && key !== except)
9
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
10
- }
11
- return to;
12
- };
13
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
14
-
15
- // src/modules/SalesSummary/types.ts
16
- var types_exports = {};
17
- module.exports = __toCommonJS(types_exports);
@@ -1,30 +0,0 @@
1
- import type { DepositInfo, SalesSummaryData, SalesSummaryProduct } from './types';
2
- export declare function createEmptySalesSummary(): SalesSummaryData;
3
- export declare function calculateSalesSummary(params: {
4
- products: SalesSummaryProduct[];
5
- isPriceIncludeTax: number;
6
- taxRate?: number;
7
- surchargeList: any[];
8
- scheduleById?: Record<string, any>;
9
- isInScheduleByDate?: any;
10
- }): SalesSummaryData | {
11
- product_quantity: number;
12
- product_original_amount: string;
13
- product_amount: string;
14
- product_expect_amount: string;
15
- product_tax_fee: string;
16
- shipping_fee: string;
17
- shipping_tax_fee: string;
18
- tax_fee: string;
19
- surcharge_fee: string;
20
- surcharges: any;
21
- discount_amount: string;
22
- deposit_amount: string;
23
- deposit: DepositInfo | undefined;
24
- expect_amount: string;
25
- total_amount: string;
26
- amount_gap: string;
27
- rounding_amount: string;
28
- pay_service_charge_amount: string;
29
- is_price_include_tax: number;
30
- };
@@ -1,420 +0,0 @@
1
- var __create = Object.create;
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __export = (target, all) => {
8
- for (var name in all)
9
- __defProp(target, name, { get: all[name], enumerable: true });
10
- };
11
- var __copyProps = (to, from, except, desc) => {
12
- if (from && typeof from === "object" || typeof from === "function") {
13
- for (let key of __getOwnPropNames(from))
14
- if (!__hasOwnProp.call(to, key) && key !== except)
15
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
- }
17
- return to;
18
- };
19
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
- // If the importer is in node compatibility mode or this is not an ESM
21
- // file that has been converted to a CommonJS file using a Babel-
22
- // compatible transform (i.e. "__esModule" has not been set), then set
23
- // "default" to the CommonJS "module.exports" for node compatibility.
24
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
- mod
26
- ));
27
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
-
29
- // src/modules/SalesSummary/utils.ts
30
- var utils_exports = {};
31
- __export(utils_exports, {
32
- calculateSalesSummary: () => calculateSalesSummary,
33
- createEmptySalesSummary: () => createEmptySalesSummary
34
- });
35
- module.exports = __toCommonJS(utils_exports);
36
- var import_decimal = __toESM(require("decimal.js"));
37
- var import_utils = require("../Summary/utils");
38
- function toDecimal(value) {
39
- return new import_decimal.default(value || 0);
40
- }
41
- function toFixed2(value) {
42
- return new import_decimal.default(value || 0).toFixed(2);
43
- }
44
- function getSafeNum(num) {
45
- if (!num || Number.isNaN(num))
46
- return 1;
47
- if (num < 1)
48
- return 1;
49
- return Math.floor(num);
50
- }
51
- function getBundleUnitPrice(product, useOriginal = false) {
52
- const bundleItems = product.product_bundle || [];
53
- return bundleItems.reduce((sum, item) => {
54
- const quantity = getSafeNum(item == null ? void 0 : item.num);
55
- const price = useOriginal ? toDecimal((item == null ? void 0 : item.original_price) ?? (item == null ? void 0 : item.product_price) ?? (item == null ? void 0 : item.price)) : toDecimal((item == null ? void 0 : item.bundle_selling_price) ?? (item == null ? void 0 : item.price));
56
- return sum.plus(price.times(quantity));
57
- }, new import_decimal.default(0));
58
- }
59
- function getUnitPaymentTotal(product) {
60
- var _a, _b;
61
- const mainSelling = (_a = product.metadata) == null ? void 0 : _a.main_product_selling_price;
62
- const mainOriginal = (_b = product.metadata) == null ? void 0 : _b.main_product_original_price;
63
- const basePrice = mainSelling !== void 0 ? toDecimal(mainSelling) : mainOriginal !== void 0 ? toDecimal(mainOriginal) : toDecimal(product.selling_price);
64
- return basePrice.plus(getBundleUnitPrice(product));
65
- }
66
- function getUnitOriginalTotal(product) {
67
- var _a, _b;
68
- const mainOriginal = (_a = product.metadata) == null ? void 0 : _a.main_product_original_price;
69
- const mainSelling = (_b = product.metadata) == null ? void 0 : _b.main_product_selling_price;
70
- const basePrice = mainOriginal !== void 0 ? toDecimal(mainOriginal) : mainSelling !== void 0 ? toDecimal(mainSelling) : toDecimal(product.original_price || product.selling_price);
71
- return basePrice.plus(getBundleUnitPrice(product, true));
72
- }
73
- function buildSurchargeServiceItems(products) {
74
- return products.map((product) => {
75
- var _a, _b;
76
- const quantity = getSafeNum(product.num);
77
- const unitTotal = getUnitPaymentTotal(product);
78
- return {
79
- id: product.product_id,
80
- num: quantity,
81
- total: unitTotal.toNumber(),
82
- price: unitTotal.toNumber(),
83
- is_charge_tax: product.is_charge_tax ?? 0,
84
- isCustomItem: product.product_id === null,
85
- _origin: product._origin || {
86
- product: {
87
- discount_list: product.discount_list || [],
88
- product_bundle: product.product_bundle || [],
89
- product_option_item: product.product_option_item || []
90
- }
91
- },
92
- bundle: product.product_bundle || [],
93
- option: product.product_option_item || [],
94
- options: product.product_option_item || [],
95
- relation_details: [],
96
- metadata: product.metadata || {},
97
- start_date: ((_a = product.metadata) == null ? void 0 : _a.start_date) || "",
98
- start_time: ((_b = product.metadata) == null ? void 0 : _b.start_time) || ""
99
- };
100
- });
101
- }
102
- function getProductDepositData(product) {
103
- var _a, _b, _c;
104
- const rootDepositData = (_a = product._origin) == null ? void 0 : _a.custom_deposit_data;
105
- if (rootDepositData && typeof rootDepositData === "object")
106
- return rootDepositData;
107
- const nestedDepositData = (_c = (_b = product._origin) == null ? void 0 : _b.product) == null ? void 0 : _c.custom_deposit_data;
108
- if (nestedDepositData && typeof nestedDepositData === "object")
109
- return nestedDepositData;
110
- return void 0;
111
- }
112
- function collectDepositPolicyIds(depositData) {
113
- const rawIds = [
114
- ...Array.isArray(depositData == null ? void 0 : depositData.self_deposit_policy_ids) ? depositData.self_deposit_policy_ids : [],
115
- ...Array.isArray(depositData == null ? void 0 : depositData.deposit_policy_ids) ? depositData.deposit_policy_ids : []
116
- ];
117
- return rawIds.reduce((result, id) => {
118
- const normalizedId = Number(id);
119
- if (!Number.isFinite(normalizedId))
120
- return result;
121
- result.push(Math.floor(normalizedId));
122
- return result;
123
- }, []);
124
- }
125
- function collectDepositPolicyData(depositData) {
126
- const rawPolicyData = Array.isArray(depositData == null ? void 0 : depositData.deposit_policy_data) ? depositData.deposit_policy_data : [];
127
- return rawPolicyData.reduce((result, policy) => {
128
- const normalizedId = Number(policy == null ? void 0 : policy.id);
129
- if (!Number.isFinite(normalizedId))
130
- return result;
131
- result.push({
132
- id: Math.floor(normalizedId),
133
- title: String((policy == null ? void 0 : policy.title) || "")
134
- });
135
- return result;
136
- }, []);
137
- }
138
- function calculateProductsDeposit(products) {
139
- let totalDeposit = new import_decimal.default(0);
140
- let hasDeposit = false;
141
- const policyIds = /* @__PURE__ */ new Set();
142
- const policyDataMap = /* @__PURE__ */ new Map();
143
- for (const product of products) {
144
- const depositData = getProductDepositData(product);
145
- if (!depositData || depositData.has_deposit != 1)
146
- continue;
147
- const num = getSafeNum(product.num);
148
- const unitTotal = getUnitPaymentTotal(product);
149
- const productTotal = unitTotal.times(num);
150
- const { deposit_fixed, deposit_percentage } = depositData;
151
- const fixed = toDecimal(deposit_fixed);
152
- const percentage = toDecimal(deposit_percentage);
153
- const itemDeposit = fixed.plus(percentage.times(productTotal));
154
- totalDeposit = totalDeposit.plus(itemDeposit);
155
- hasDeposit = true;
156
- for (const id of collectDepositPolicyIds(depositData)) {
157
- policyIds.add(id);
158
- }
159
- for (const policy of collectDepositPolicyData(depositData)) {
160
- if (!policyDataMap.has(policy.id)) {
161
- policyDataMap.set(policy.id, policy);
162
- }
163
- policyIds.add(policy.id);
164
- }
165
- }
166
- if (!hasDeposit)
167
- return void 0;
168
- for (const id of policyIds) {
169
- if (!policyDataMap.has(id)) {
170
- policyDataMap.set(id, {
171
- id,
172
- title: ""
173
- });
174
- }
175
- }
176
- return {
177
- total: totalDeposit.toFixed(2),
178
- deposit_policy_ids: [...policyIds],
179
- deposit_policy_data: [...policyDataMap.values()],
180
- hasDeposit: true
181
- };
182
- }
183
- function isBundleOriginalPrice(item) {
184
- return (item == null ? void 0 : item.price_type) === "markup" && (item == null ? void 0 : item.price_type_ext) === "product_price";
185
- }
186
- function isBundleMarkupOrDiscount(item) {
187
- const isMarkup = (item == null ? void 0 : item.price_type) === "markup" && ((item == null ? void 0 : item.price_type_ext) === "" || !(item == null ? void 0 : item.price_type_ext));
188
- const isDiscount = (item == null ? void 0 : item.price_type) === "markdown" && ((item == null ? void 0 : item.price_type_ext) === "" || !(item == null ? void 0 : item.price_type_ext));
189
- return isMarkup || isDiscount;
190
- }
191
- function calculateSingleItemTax(params) {
192
- const { price, taxRate, isPriceIncludeTax, isChargeTax } = params;
193
- if (price.lte(0))
194
- return new import_decimal.default(0);
195
- if (isChargeTax === 0 || !isChargeTax)
196
- return new import_decimal.default(0);
197
- const rate = taxRate.div(100);
198
- if (isPriceIncludeTax === 0) {
199
- return price.times(rate);
200
- }
201
- const divisor = new import_decimal.default(1).plus(rate);
202
- if (divisor.lte(0))
203
- return new import_decimal.default(0);
204
- return price.dividedBy(divisor).times(rate);
205
- }
206
- function getMainProductPaymentTotal(product) {
207
- var _a, _b;
208
- const mainSelling = ((_a = product.metadata) == null ? void 0 : _a.main_product_selling_price) ?? ((_b = product.metadata) == null ? void 0 : _b.main_product_original_price) ?? 0;
209
- let total = toDecimal(mainSelling);
210
- const bundleItems = product.product_bundle || [];
211
- for (const bundleItem of bundleItems) {
212
- if (isBundleMarkupOrDiscount(bundleItem)) {
213
- const unit = toDecimal(bundleItem.bundle_selling_price ?? bundleItem.price ?? 0);
214
- const qty = getSafeNum(bundleItem.num ?? bundleItem.quantity);
215
- total = total.plus(unit.times(qty));
216
- }
217
- }
218
- return import_decimal.default.max(total, 0);
219
- }
220
- function calculateProductsTax(products, taxRate, isPriceIncludeTax) {
221
- const rate = new import_decimal.default(taxRate);
222
- let preciseTax = new import_decimal.default(0);
223
- let roundedTax = new import_decimal.default(0);
224
- let preciseOriginTax = new import_decimal.default(0);
225
- let roundedOriginTax = new import_decimal.default(0);
226
- let lastTaxableItem = null;
227
- for (const product of products) {
228
- const quantity = new import_decimal.default(getSafeNum(product.num));
229
- const mainTotal = getMainProductPaymentTotal(product);
230
- const surchargeFee = toDecimal(product.surcharge_fee);
231
- const mainTaxableBase = mainTotal.lte(0) ? surchargeFee : mainTotal.plus(surchargeFee);
232
- const mainTaxPrecise = calculateSingleItemTax({
233
- price: mainTaxableBase,
234
- taxRate: rate,
235
- isPriceIncludeTax,
236
- isChargeTax: product.is_charge_tax ?? 0
237
- });
238
- const mainTaxRounded = mainTaxPrecise.toDecimalPlaces(2, import_decimal.default.ROUND_HALF_UP);
239
- if (mainTaxPrecise.gt(0)) {
240
- lastTaxableItem = { type: "main", item: product };
241
- }
242
- const originalTotal = getUnitOriginalTotal(product);
243
- const originalTaxableBase = originalTotal.lte(0) ? surchargeFee : originalTotal.plus(surchargeFee);
244
- const originalTaxPrecise = calculateSingleItemTax({
245
- price: originalTaxableBase,
246
- taxRate: rate,
247
- isPriceIncludeTax,
248
- isChargeTax: product.is_charge_tax ?? 0
249
- });
250
- let bundlePreciseTax = new import_decimal.default(0);
251
- let bundleRoundedTax = new import_decimal.default(0);
252
- let bundlePreciseOriginTax = new import_decimal.default(0);
253
- let bundleRoundedOriginTax = new import_decimal.default(0);
254
- const bundleItems = product.product_bundle || [];
255
- for (const bundleItem of bundleItems) {
256
- if (!isBundleOriginalPrice(bundleItem))
257
- continue;
258
- const bundleQuantity = new import_decimal.default(getSafeNum(bundleItem.num ?? bundleItem.quantity));
259
- const bundlePrice = toDecimal(bundleItem.bundle_selling_price ?? bundleItem.price ?? 0);
260
- const bundleOriginalPrice = toDecimal(bundleItem.original_price ?? bundleItem.product_price ?? bundleItem.price ?? 0);
261
- const bundleTaxPrecise = calculateSingleItemTax({
262
- price: bundlePrice,
263
- taxRate: rate,
264
- isPriceIncludeTax,
265
- isChargeTax: bundleItem.is_charge_tax ?? product.is_charge_tax ?? 0
266
- });
267
- const bundleTaxRounded = bundleTaxPrecise.toDecimalPlaces(2, import_decimal.default.ROUND_HALF_UP);
268
- const bundleOrigTaxPrecise = calculateSingleItemTax({
269
- price: bundleOriginalPrice,
270
- taxRate: rate,
271
- isPriceIncludeTax,
272
- isChargeTax: bundleItem.is_charge_tax ?? product.is_charge_tax ?? 0
273
- });
274
- const bundleOrigTaxRounded = bundleOrigTaxPrecise.toDecimalPlaces(2, import_decimal.default.ROUND_HALF_UP);
275
- bundleItem.tax_fee = bundleTaxRounded.toNumber();
276
- bundleItem.original_tax_fee = bundleOrigTaxRounded.toNumber();
277
- bundlePreciseTax = bundlePreciseTax.plus(bundleTaxPrecise.times(bundleQuantity));
278
- bundleRoundedTax = bundleRoundedTax.plus(bundleTaxRounded.times(bundleQuantity));
279
- bundlePreciseOriginTax = bundlePreciseOriginTax.plus(bundleOrigTaxPrecise.times(bundleQuantity));
280
- bundleRoundedOriginTax = bundleRoundedOriginTax.plus(bundleOrigTaxRounded.times(bundleQuantity));
281
- if (bundleTaxPrecise.gt(0)) {
282
- lastTaxableItem = { type: "bundle", item: bundleItem };
283
- }
284
- }
285
- const itemTaxPrecise = mainTaxPrecise.plus(bundlePreciseTax);
286
- const itemTaxRounded = mainTaxRounded.plus(bundleRoundedTax);
287
- const itemOriginTaxPrecise = originalTaxPrecise.plus(bundlePreciseOriginTax);
288
- const itemOriginTaxRounded = originalTaxPrecise.toDecimalPlaces(2, import_decimal.default.ROUND_HALF_UP).plus(bundleRoundedOriginTax);
289
- product.tax_fee = itemTaxRounded.toDecimalPlaces(2, import_decimal.default.ROUND_HALF_UP).toFixed(2);
290
- product.original_tax_fee = itemOriginTaxRounded.toDecimalPlaces(2, import_decimal.default.ROUND_HALF_UP).toNumber();
291
- preciseTax = preciseTax.plus(itemTaxPrecise.times(quantity));
292
- roundedTax = roundedTax.plus(itemTaxRounded.times(quantity));
293
- preciseOriginTax = preciseOriginTax.plus(itemOriginTaxPrecise.times(quantity));
294
- roundedOriginTax = roundedOriginTax.plus(itemOriginTaxRounded.times(quantity));
295
- }
296
- const expectedTax = preciseTax.toDecimalPlaces(2, import_decimal.default.ROUND_HALF_UP);
297
- const expectedOriginTax = preciseOriginTax.toDecimalPlaces(2, import_decimal.default.ROUND_HALF_UP);
298
- const taxRemainder = expectedTax.minus(roundedTax).toNumber();
299
- const originTaxRemainder = expectedOriginTax.minus(roundedOriginTax).toNumber();
300
- if (lastTaxableItem) {
301
- if (taxRemainder !== 0) {
302
- lastTaxableItem.item.tax_fee_rounding_remainder = taxRemainder;
303
- }
304
- if (originTaxRemainder !== 0) {
305
- lastTaxableItem.item.original_tax_fee_rounding_remainder = originTaxRemainder;
306
- }
307
- }
308
- return { tax: expectedTax, originTax: expectedOriginTax };
309
- }
310
- function createEmptySalesSummary() {
311
- return {
312
- product_quantity: 0,
313
- product_original_amount: "0.00",
314
- product_amount: "0.00",
315
- product_expect_amount: "0.00",
316
- product_tax_fee: "0.00",
317
- shipping_fee: "0.00",
318
- shipping_tax_fee: "0.00",
319
- tax_fee: "0.00",
320
- surcharge_fee: "0.00",
321
- surcharges: [],
322
- discount_amount: "0.00",
323
- deposit_amount: "0.00",
324
- expect_amount: "0.00",
325
- total_amount: "0.00",
326
- amount_gap: "0.00",
327
- rounding_amount: "0.00",
328
- pay_service_charge_amount: "0.00"
329
- };
330
- }
331
- function calculateSalesSummary(params) {
332
- var _a;
333
- const {
334
- products,
335
- isPriceIncludeTax,
336
- taxRate,
337
- surchargeList,
338
- scheduleById = {},
339
- isInScheduleByDate
340
- } = params;
341
- if (!(products == null ? void 0 : products.length))
342
- return createEmptySalesSummary();
343
- const productQuantity = products.reduce(
344
- (sum, item) => sum + getSafeNum(item.num),
345
- 0
346
- );
347
- const productOriginalAmount = products.reduce(
348
- (sum, item) => sum.plus(getUnitOriginalTotal(item).times(getSafeNum(item.num))),
349
- new import_decimal.default(0)
350
- );
351
- const productAmount = products.reduce(
352
- (sum, item) => sum.plus(getUnitPaymentTotal(item).times(getSafeNum(item.num))),
353
- new import_decimal.default(0)
354
- );
355
- const surchargeServiceItems = buildSurchargeServiceItems(products);
356
- const surcharge = (0, import_utils.getSurcharge)(
357
- {
358
- service: surchargeServiceItems,
359
- addons: [],
360
- bookingDetail: null,
361
- bookingId: void 0
362
- },
363
- {
364
- isEdit: false,
365
- isInScheduleByDate,
366
- surcharge_list: surchargeList,
367
- scheduleById
368
- }
369
- );
370
- const surchargeAmount = new import_decimal.default(
371
- (0, import_utils.getSurchargeAmount)(
372
- { bookingDetail: null, bookingId: void 0 },
373
- surcharge,
374
- { isEdit: false }
375
- ) || 0
376
- );
377
- for (let i = 0; i < products.length; i++) {
378
- products[i].surcharge_fee = ((_a = surchargeServiceItems[i]) == null ? void 0 : _a.surcharge_fee) || 0;
379
- }
380
- const hasTaxRate = taxRate !== void 0 && taxRate !== null && taxRate > 0;
381
- let productTaxFee;
382
- if (hasTaxRate) {
383
- const taxResult = calculateProductsTax(products, taxRate, isPriceIncludeTax);
384
- productTaxFee = taxResult.tax;
385
- } else {
386
- productTaxFee = products.reduce(
387
- (sum, item) => sum.plus(toDecimal(item.tax_fee).times(getSafeNum(item.num))),
388
- new import_decimal.default(0)
389
- );
390
- }
391
- const expectAmount = productAmount.plus(surchargeAmount);
392
- const totalAmount = isPriceIncludeTax === 1 ? expectAmount : expectAmount.plus(productTaxFee);
393
- const deposit = calculateProductsDeposit(products);
394
- return {
395
- product_quantity: productQuantity,
396
- product_original_amount: toFixed2(productOriginalAmount),
397
- product_amount: toFixed2(productAmount),
398
- product_expect_amount: toFixed2(productAmount),
399
- product_tax_fee: toFixed2(productTaxFee),
400
- shipping_fee: "0.00",
401
- shipping_tax_fee: "0.00",
402
- tax_fee: toFixed2(productTaxFee),
403
- surcharge_fee: toFixed2(surchargeAmount),
404
- surcharges: surcharge,
405
- discount_amount: toFixed2(import_decimal.default.max(productOriginalAmount.minus(productAmount), 0)),
406
- deposit_amount: deposit ? deposit.total : "0.00",
407
- deposit,
408
- expect_amount: toFixed2(expectAmount),
409
- total_amount: toFixed2(totalAmount),
410
- amount_gap: "0.00",
411
- rounding_amount: "0.00",
412
- pay_service_charge_amount: "0.00",
413
- is_price_include_tax: isPriceIncludeTax
414
- };
415
- }
416
- // Annotate the CommonJS export names for ESM import in node:
417
- 0 && (module.exports = {
418
- calculateSalesSummary,
419
- createEmptySalesSummary
420
- });
@@ -1,23 +0,0 @@
1
- import { BaseModule } from '../BaseModule';
2
- import { Module, ModuleOptions, PisellCore } from '../../types';
3
- import { ScanOrderLogInput, ScanOrderLoggerContext, ScanOrderLoggerProviderConfig, ScanOrderLoggerProviderType } from './types';
4
- export interface ScanOrderLoggerModuleAPI {
5
- addLog: (params: ScanOrderLogInput) => Promise<void>;
6
- setContext: (context: ScanOrderLoggerContext) => void;
7
- setProvider: (provider: ScanOrderLoggerProviderType) => void;
8
- setProviderConfig: (providerConfig: ScanOrderLoggerProviderConfig) => void;
9
- }
10
- export declare class ScanOrderLoggerModule extends BaseModule implements Module, ScanOrderLoggerModuleAPI {
11
- protected defaultName: string;
12
- protected defaultVersion: string;
13
- private store;
14
- private window?;
15
- initialize(core: PisellCore, options?: ModuleOptions): Promise<void>;
16
- setContext(context: ScanOrderLoggerContext): void;
17
- setProvider(provider: ScanOrderLoggerProviderType): void;
18
- setProviderConfig(providerConfig: ScanOrderLoggerProviderConfig): void;
19
- private getCurrentHost;
20
- private buildRecord;
21
- addLog(params: ScanOrderLogInput): Promise<void>;
22
- }
23
- export * from './types';