@pisell/pisellos 2.1.119 → 2.1.121

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/apis/picoding.d.ts +0 -0
  2. package/dist/apis/picoding.js +1 -0
  3. package/dist/model/index.d.ts +1 -0
  4. package/dist/model/index.js +1 -0
  5. package/dist/model/strategy/adapter/index.d.ts +7 -0
  6. package/dist/model/strategy/adapter/index.js +7 -0
  7. package/dist/model/strategy/adapter/itemRule/adapter.d.ts +59 -0
  8. package/dist/model/strategy/adapter/itemRule/adapter.js +439 -0
  9. package/dist/model/strategy/adapter/itemRule/evaluator.d.ts +43 -0
  10. package/dist/model/strategy/adapter/itemRule/evaluator.js +169 -0
  11. package/dist/model/strategy/adapter/itemRule/examples.d.ts +64 -0
  12. package/dist/model/strategy/adapter/itemRule/examples.js +315 -0
  13. package/dist/model/strategy/adapter/itemRule/index.d.ts +5 -0
  14. package/dist/model/strategy/adapter/itemRule/index.js +5 -0
  15. package/dist/model/strategy/adapter/itemRule/type.d.ts +206 -0
  16. package/dist/model/strategy/adapter/itemRule/type.js +101 -0
  17. package/dist/model/strategy/adapter/promotion/adapter.d.ts +66 -0
  18. package/dist/model/strategy/adapter/promotion/adapter.js +271 -0
  19. package/dist/model/strategy/adapter/promotion/evaluator.d.ts +213 -0
  20. package/dist/model/strategy/adapter/promotion/evaluator.js +1206 -0
  21. package/dist/model/strategy/adapter/promotion/examples.d.ts +138 -0
  22. package/dist/model/strategy/adapter/promotion/examples.js +166 -0
  23. package/dist/model/strategy/adapter/promotion/index.d.ts +4 -0
  24. package/dist/model/strategy/adapter/promotion/index.js +0 -0
  25. package/dist/model/strategy/adapter/promotion/type.d.ts +447 -0
  26. package/dist/model/strategy/adapter/promotion/type.js +209 -0
  27. package/dist/model/strategy/adapter/type.d.ts +28 -0
  28. package/dist/model/strategy/adapter/type.js +1 -0
  29. package/dist/model/strategy/adapter/walletPass/evaluator.d.ts +84 -0
  30. package/dist/model/strategy/adapter/walletPass/evaluator.js +502 -0
  31. package/dist/model/strategy/adapter/walletPass/example.d.ts +4 -0
  32. package/dist/model/strategy/adapter/walletPass/example.js +258 -0
  33. package/dist/model/strategy/adapter/walletPass/index.d.ts +32 -0
  34. package/dist/model/strategy/adapter/walletPass/index.js +182 -0
  35. package/dist/model/strategy/adapter/walletPass/locales.d.ts +1 -0
  36. package/dist/model/strategy/adapter/walletPass/locales.js +26 -0
  37. package/dist/model/strategy/adapter/walletPass/type.d.ts +187 -0
  38. package/dist/model/strategy/adapter/walletPass/type.js +1 -0
  39. package/dist/model/strategy/adapter/walletPass/utils.d.ts +50 -0
  40. package/dist/model/strategy/adapter/walletPass/utils.js +1104 -0
  41. package/dist/model/strategy/engine.d.ts +106 -0
  42. package/dist/model/strategy/engine.js +611 -0
  43. package/dist/model/strategy/index.d.ts +3 -0
  44. package/dist/model/strategy/index.js +8 -0
  45. package/dist/model/strategy/strategy-example.d.ts +5 -0
  46. package/dist/model/strategy/strategy-example.js +331 -0
  47. package/dist/model/strategy/type.d.ts +228 -0
  48. package/dist/model/strategy/type.js +94 -0
  49. package/dist/modules/Cart/utils/cartProduct.js +1 -0
  50. package/dist/modules/OpenData/index.d.ts +24 -0
  51. package/dist/modules/OpenData/index.js +173 -0
  52. package/dist/modules/OpenData/types.d.ts +73 -0
  53. package/dist/modules/OpenData/types.js +1 -0
  54. package/dist/modules/OpenData/utils.d.ts +2 -0
  55. package/dist/modules/OpenData/utils.js +75 -0
  56. package/dist/modules/Order/index.d.ts +58 -1
  57. package/dist/modules/Order/index.js +796 -29
  58. package/dist/modules/Order/types.d.ts +144 -12
  59. package/dist/modules/Order/utils.d.ts +28 -0
  60. package/dist/modules/Order/utils.js +250 -1
  61. package/dist/modules/Product/index.d.ts +1 -1
  62. package/dist/modules/Product/utils.js +2 -2
  63. package/dist/modules/ProductList/index.d.ts +1 -1
  64. package/dist/modules/ProductList/index.js +2 -1
  65. package/dist/modules/Quotation/index.d.ts +48 -0
  66. package/dist/modules/Quotation/index.js +245 -0
  67. package/dist/modules/Quotation/types.d.ts +42 -0
  68. package/dist/modules/Quotation/types.js +1 -0
  69. package/dist/modules/Rules/index.js +4 -1
  70. package/dist/modules/SalesSummary/index.d.ts +63 -0
  71. package/dist/modules/SalesSummary/index.js +174 -0
  72. package/dist/modules/SalesSummary/types.d.ts +59 -0
  73. package/dist/modules/SalesSummary/types.js +1 -0
  74. package/dist/modules/SalesSummary/utils.d.ts +30 -0
  75. package/dist/modules/SalesSummary/utils.js +513 -0
  76. package/dist/modules/ScanOrderLogger/index.d.ts +21 -0
  77. package/dist/modules/ScanOrderLogger/index.js +161 -0
  78. package/dist/modules/ScanOrderLogger/providers/feishu.d.ts +2 -0
  79. package/dist/modules/ScanOrderLogger/providers/feishu.js +95 -0
  80. package/dist/modules/ScanOrderLogger/providers/grafana.d.ts +2 -0
  81. package/dist/modules/ScanOrderLogger/providers/grafana.js +50 -0
  82. package/dist/modules/ScanOrderLogger/types.d.ts +46 -0
  83. package/dist/modules/ScanOrderLogger/types.js +1 -0
  84. package/dist/modules/Schedule/getDateIsInSchedule.js +11 -18
  85. package/dist/modules/Summary/utils.d.ts +3 -3
  86. package/dist/modules/Summary/utils.js +4 -4
  87. package/dist/modules/index.d.ts +4 -0
  88. package/dist/modules/index.js +5 -1
  89. package/dist/solution/BookingByStep/index.d.ts +1 -1
  90. package/dist/solution/BookingByStep/types.d.ts +3 -1
  91. package/dist/solution/BookingByStep/types.js +5 -1
  92. package/dist/solution/BookingTicket/index.d.ts +1 -1
  93. package/dist/solution/ScanOrder/index.d.ts +90 -0
  94. package/dist/solution/ScanOrder/index.js +1853 -0
  95. package/dist/solution/ScanOrder/types.d.ts +210 -0
  96. package/dist/solution/ScanOrder/types.js +16 -0
  97. package/dist/solution/ScanOrder/utils.d.ts +93 -0
  98. package/dist/solution/ScanOrder/utils.js +397 -0
  99. package/dist/solution/VenueBooking/index.d.ts +163 -0
  100. package/dist/solution/VenueBooking/index.js +2931 -0
  101. package/dist/solution/VenueBooking/sales-section-4-annotated.json +343 -0
  102. package/dist/solution/VenueBooking/types.d.ts +130 -0
  103. package/dist/solution/VenueBooking/types.js +21 -0
  104. package/dist/solution/VenueBooking/utils/dateSummary.d.ts +10 -0
  105. package/dist/solution/VenueBooking/utils/dateSummary.js +102 -0
  106. package/dist/solution/VenueBooking/utils/resource.d.ts +4 -0
  107. package/dist/solution/VenueBooking/utils/resource.js +94 -0
  108. package/dist/solution/VenueBooking/utils/slotMerge.d.ts +29 -0
  109. package/dist/solution/VenueBooking/utils/slotMerge.js +203 -0
  110. package/dist/solution/VenueBooking/utils/timeSlot.d.ts +32 -0
  111. package/dist/solution/VenueBooking/utils/timeSlot.js +256 -0
  112. package/dist/solution/VenueBooking/utils.d.ts +1 -0
  113. package/dist/solution/VenueBooking/utils.js +1 -0
  114. package/dist/solution/index.d.ts +2 -0
  115. package/dist/solution/index.js +3 -1
  116. package/lib/apis/picoding.d.ts +0 -0
  117. package/lib/apis/picoding.js +0 -0
  118. package/lib/model/index.d.ts +1 -0
  119. package/lib/model/index.js +23 -0
  120. package/lib/model/strategy/adapter/index.d.ts +7 -0
  121. package/lib/model/strategy/adapter/index.js +57 -0
  122. package/lib/model/strategy/adapter/itemRule/adapter.d.ts +59 -0
  123. package/lib/model/strategy/adapter/itemRule/adapter.js +338 -0
  124. package/lib/model/strategy/adapter/itemRule/evaluator.d.ts +43 -0
  125. package/lib/model/strategy/adapter/itemRule/evaluator.js +124 -0
  126. package/lib/model/strategy/adapter/itemRule/examples.d.ts +64 -0
  127. package/lib/model/strategy/adapter/itemRule/examples.js +269 -0
  128. package/lib/model/strategy/adapter/itemRule/index.d.ts +5 -0
  129. package/lib/model/strategy/adapter/itemRule/index.js +58 -0
  130. package/lib/model/strategy/adapter/itemRule/type.d.ts +206 -0
  131. package/lib/model/strategy/adapter/itemRule/type.js +46 -0
  132. package/lib/model/strategy/adapter/promotion/adapter.d.ts +66 -0
  133. package/lib/model/strategy/adapter/promotion/adapter.js +217 -0
  134. package/lib/model/strategy/adapter/promotion/evaluator.d.ts +213 -0
  135. package/lib/model/strategy/adapter/promotion/evaluator.js +844 -0
  136. package/lib/model/strategy/adapter/promotion/examples.d.ts +138 -0
  137. package/lib/model/strategy/adapter/promotion/examples.js +192 -0
  138. package/lib/model/strategy/adapter/promotion/index.d.ts +4 -0
  139. package/lib/model/strategy/adapter/promotion/index.js +49 -0
  140. package/lib/model/strategy/adapter/promotion/type.d.ts +447 -0
  141. package/lib/model/strategy/adapter/promotion/type.js +51 -0
  142. package/lib/model/strategy/adapter/type.d.ts +28 -0
  143. package/lib/model/strategy/adapter/type.js +17 -0
  144. package/lib/model/strategy/adapter/walletPass/evaluator.d.ts +84 -0
  145. package/lib/model/strategy/adapter/walletPass/evaluator.js +424 -0
  146. package/lib/model/strategy/adapter/walletPass/example.d.ts +4 -0
  147. package/lib/model/strategy/adapter/walletPass/example.js +207 -0
  148. package/lib/model/strategy/adapter/walletPass/index.d.ts +32 -0
  149. package/lib/model/strategy/adapter/walletPass/index.js +142 -0
  150. package/lib/model/strategy/adapter/walletPass/locales.d.ts +1 -0
  151. package/lib/model/strategy/adapter/walletPass/locales.js +54 -0
  152. package/lib/model/strategy/adapter/walletPass/type.d.ts +187 -0
  153. package/lib/model/strategy/adapter/walletPass/type.js +17 -0
  154. package/lib/model/strategy/adapter/walletPass/utils.d.ts +50 -0
  155. package/lib/model/strategy/adapter/walletPass/utils.js +791 -0
  156. package/lib/model/strategy/engine.d.ts +106 -0
  157. package/lib/model/strategy/engine.js +450 -0
  158. package/lib/model/strategy/index.d.ts +3 -0
  159. package/lib/model/strategy/index.js +38 -0
  160. package/lib/model/strategy/strategy-example.d.ts +5 -0
  161. package/lib/model/strategy/strategy-example.js +318 -0
  162. package/lib/model/strategy/type.d.ts +228 -0
  163. package/lib/model/strategy/type.js +44 -0
  164. package/lib/modules/Cart/utils/cartProduct.js +1 -0
  165. package/lib/modules/OpenData/index.d.ts +24 -0
  166. package/lib/modules/OpenData/index.js +119 -0
  167. package/lib/modules/OpenData/types.d.ts +73 -0
  168. package/lib/modules/OpenData/types.js +17 -0
  169. package/lib/modules/OpenData/utils.d.ts +2 -0
  170. package/lib/modules/OpenData/utils.js +111 -0
  171. package/lib/modules/Order/index.d.ts +58 -1
  172. package/lib/modules/Order/index.js +437 -1
  173. package/lib/modules/Order/types.d.ts +144 -12
  174. package/lib/modules/Order/utils.d.ts +28 -0
  175. package/lib/modules/Order/utils.js +250 -2
  176. package/lib/modules/Product/index.d.ts +1 -1
  177. package/lib/modules/Product/utils.js +2 -2
  178. package/lib/modules/ProductList/index.d.ts +1 -1
  179. package/lib/modules/ProductList/index.js +2 -1
  180. package/lib/modules/Quotation/index.d.ts +48 -0
  181. package/lib/modules/Quotation/index.js +149 -0
  182. package/lib/modules/Quotation/types.d.ts +42 -0
  183. package/lib/modules/Quotation/types.js +17 -0
  184. package/lib/modules/Rules/index.js +4 -1
  185. package/lib/modules/SalesSummary/index.d.ts +63 -0
  186. package/lib/modules/SalesSummary/index.js +105 -0
  187. package/lib/modules/SalesSummary/types.d.ts +59 -0
  188. package/lib/modules/SalesSummary/types.js +17 -0
  189. package/lib/modules/SalesSummary/utils.d.ts +30 -0
  190. package/lib/modules/SalesSummary/utils.js +452 -0
  191. package/lib/modules/ScanOrderLogger/index.d.ts +21 -0
  192. package/lib/modules/ScanOrderLogger/index.js +135 -0
  193. package/lib/modules/ScanOrderLogger/providers/feishu.d.ts +2 -0
  194. package/lib/modules/ScanOrderLogger/providers/feishu.js +82 -0
  195. package/lib/modules/ScanOrderLogger/providers/grafana.d.ts +2 -0
  196. package/lib/modules/ScanOrderLogger/providers/grafana.js +52 -0
  197. package/lib/modules/ScanOrderLogger/types.d.ts +46 -0
  198. package/lib/modules/ScanOrderLogger/types.js +17 -0
  199. package/lib/modules/Schedule/getDateIsInSchedule.js +9 -11
  200. package/lib/modules/Summary/utils.d.ts +3 -3
  201. package/lib/modules/Summary/utils.js +4 -4
  202. package/lib/modules/index.d.ts +4 -0
  203. package/lib/modules/index.js +9 -1
  204. package/lib/solution/BookingByStep/index.d.ts +1 -1
  205. package/lib/solution/BookingByStep/types.d.ts +3 -1
  206. package/lib/solution/BookingByStep/types.js +10 -0
  207. package/lib/solution/BookingTicket/index.d.ts +1 -1
  208. package/lib/solution/ScanOrder/index.d.ts +90 -0
  209. package/lib/solution/ScanOrder/index.js +1071 -0
  210. package/lib/solution/ScanOrder/types.d.ts +210 -0
  211. package/lib/solution/ScanOrder/types.js +36 -0
  212. package/lib/solution/ScanOrder/utils.d.ts +93 -0
  213. package/lib/solution/ScanOrder/utils.js +359 -0
  214. package/lib/solution/VenueBooking/index.d.ts +163 -0
  215. package/lib/solution/VenueBooking/index.js +1578 -0
  216. package/lib/solution/VenueBooking/sales-section-4-annotated.json +343 -0
  217. package/lib/solution/VenueBooking/types.d.ts +130 -0
  218. package/lib/solution/VenueBooking/types.js +44 -0
  219. package/lib/solution/VenueBooking/utils/dateSummary.d.ts +10 -0
  220. package/lib/solution/VenueBooking/utils/dateSummary.js +101 -0
  221. package/lib/solution/VenueBooking/utils/resource.d.ts +4 -0
  222. package/lib/solution/VenueBooking/utils/resource.js +80 -0
  223. package/lib/solution/VenueBooking/utils/slotMerge.d.ts +29 -0
  224. package/lib/solution/VenueBooking/utils/slotMerge.js +208 -0
  225. package/lib/solution/VenueBooking/utils/timeSlot.d.ts +32 -0
  226. package/lib/solution/VenueBooking/utils/timeSlot.js +200 -0
  227. package/lib/solution/VenueBooking/utils.d.ts +1 -0
  228. package/lib/solution/VenueBooking/utils.js +69 -0
  229. package/lib/solution/index.d.ts +2 -0
  230. package/lib/solution/index.js +5 -1
  231. package/package.json +1 -1
@@ -0,0 +1,105 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/modules/SalesSummary/index.ts
21
+ var SalesSummary_exports = {};
22
+ __export(SalesSummary_exports, {
23
+ SalesSummaryModule: () => SalesSummaryModule
24
+ });
25
+ module.exports = __toCommonJS(SalesSummary_exports);
26
+ var import_BaseModule = require("../BaseModule");
27
+ var import_Schedule = require("../Schedule");
28
+ var import_utils = require("./utils");
29
+ __reExport(SalesSummary_exports, require("./types"), module.exports);
30
+ var SalesSummaryModule = class extends import_BaseModule.BaseModule {
31
+ constructor(name, version) {
32
+ super(name, version);
33
+ this.defaultName = "salesSummary";
34
+ this.defaultVersion = "1.0.0";
35
+ }
36
+ async initialize(core, options) {
37
+ var _a, _b;
38
+ this.core = core;
39
+ this.store = options.store;
40
+ this.shopStore = this.core.getPlugin("shopStore");
41
+ this.request = this.core.getPlugin("request");
42
+ this.store.surchargeList = ((_a = options.initialState) == null ? void 0 : _a.surchargeList) || [];
43
+ this.store.summary = ((_b = options.initialState) == null ? void 0 : _b.summary) || (0, import_utils.createEmptySalesSummary)();
44
+ if (!this.shopStore) {
45
+ throw new Error("SalesSummaryModule 需要 shopStore 插件支持");
46
+ }
47
+ if (!this.request) {
48
+ throw new Error("SalesSummaryModule 需要 request 插件支持");
49
+ }
50
+ await this.getSurchargeList();
51
+ }
52
+ async getSurchargeList() {
53
+ try {
54
+ const surchargeList = await this.request.get(
55
+ "/order/custom-surcharge/available/v2",
56
+ {
57
+ channel: "online-store",
58
+ is_assemble_product_data: 1,
59
+ is_assemble_schedule_data: 1,
60
+ with: ["relationSchedule"]
61
+ }
62
+ );
63
+ this.store.surchargeList = (surchargeList == null ? void 0 : surchargeList.data) || [];
64
+ } catch (error) {
65
+ console.warn("[SalesSummaryModule] 加载附加费配置失败", error);
66
+ this.store.surchargeList = [];
67
+ }
68
+ }
69
+ async getSummary(params) {
70
+ var _a, _b;
71
+ const { products = [], isPriceIncludeTax, taxRate } = params;
72
+ const shopInfo = ((_b = (_a = this.shopStore.get("core")) == null ? void 0 : _a.core) == null ? void 0 : _b.shop) || {};
73
+ const summarySchedule = this.core.getModule(
74
+ `${this.name.split("_")[0]}_schedule`
75
+ );
76
+ const needScheduleIds = this.store.surchargeList.map((item) => item.available_schedule_ids).flat();
77
+ const scheduleList = summarySchedule == null ? void 0 : summarySchedule.getScheduleListByIds(needScheduleIds);
78
+ const scheduleById = {};
79
+ if (Array.isArray(scheduleList)) {
80
+ for (const item of scheduleList) {
81
+ scheduleById[item.id] = item;
82
+ }
83
+ }
84
+ const summary = (0, import_utils.calculateSalesSummary)({
85
+ products,
86
+ isPriceIncludeTax: isPriceIncludeTax ?? (shopInfo == null ? void 0 : shopInfo.is_price_include_tax) ?? 1,
87
+ taxRate: taxRate ?? (shopInfo == null ? void 0 : shopInfo.tax_rate),
88
+ surchargeList: this.store.surchargeList,
89
+ scheduleById,
90
+ isInScheduleByDate: import_Schedule.ScheduleModule.isInScheduleByDate
91
+ });
92
+ const summaryWithTaxMeta = {
93
+ ...summary,
94
+ tax_title: (shopInfo == null ? void 0 : shopInfo.tax_title) || "",
95
+ tax_rate: taxRate ?? (shopInfo == null ? void 0 : shopInfo.tax_rate)
96
+ };
97
+ this.store.summary = summaryWithTaxMeta;
98
+ return summaryWithTaxMeta;
99
+ }
100
+ };
101
+ // Annotate the CommonJS export names for ESM import in node:
102
+ 0 && (module.exports = {
103
+ SalesSummaryModule,
104
+ ...require("./types")
105
+ });
@@ -0,0 +1,59 @@
1
+ export interface SalesSummaryProduct {
2
+ product_id: number | null;
3
+ product_variant_id: number;
4
+ num: number;
5
+ selling_price: string;
6
+ original_price: string;
7
+ payment_price: string;
8
+ tax_fee: string;
9
+ is_charge_tax?: number;
10
+ product_option_item?: any[];
11
+ discount_list?: any[];
12
+ product_bundle?: any[];
13
+ metadata?: Record<string, any>;
14
+ _origin?: Record<string, any>;
15
+ }
16
+ export interface DepositPolicyData {
17
+ id: number;
18
+ title: string;
19
+ }
20
+ export interface DepositInfo {
21
+ total: string;
22
+ deposit_policy_ids: number[];
23
+ deposit_policy_data: DepositPolicyData[];
24
+ hasDeposit: boolean;
25
+ }
26
+ export interface SalesSummaryData {
27
+ product_quantity: number;
28
+ product_original_amount: string;
29
+ product_amount: string;
30
+ product_expect_amount: string;
31
+ product_tax_fee: string;
32
+ shipping_fee: string;
33
+ shipping_tax_fee: string;
34
+ tax_fee: string;
35
+ surcharge_fee: string;
36
+ surcharges: any[];
37
+ discount_amount: string;
38
+ deposit_amount: string;
39
+ deposit?: DepositInfo;
40
+ expect_amount: string;
41
+ total_amount: string;
42
+ amount_gap: string;
43
+ rounding_amount: string;
44
+ pay_service_charge_amount: string;
45
+ is_price_include_tax?: number;
46
+ tax_title?: string;
47
+ tax_rate?: number;
48
+ }
49
+ export interface SalesSummaryState {
50
+ surchargeList: any[];
51
+ summary: SalesSummaryData;
52
+ }
53
+ export interface SalesSummaryModuleAPI {
54
+ getSummary(params: {
55
+ products: SalesSummaryProduct[];
56
+ isPriceIncludeTax?: number;
57
+ taxRate?: number;
58
+ }): Promise<SalesSummaryData>;
59
+ }
@@ -0,0 +1,17 @@
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);
@@ -0,0 +1,30 @@
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
+ };
@@ -0,0 +1,452 @@
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 getVariantPrice(product) {
52
+ var _a, _b;
53
+ const variantId = Number(product.product_variant_id || 0);
54
+ if (!variantId)
55
+ return null;
56
+ const metadataVariantList = (_b = (_a = product.metadata) == null ? void 0 : _a.origin) == null ? void 0 : _b.variant;
57
+ if (Array.isArray(metadataVariantList)) {
58
+ const variant = metadataVariantList.find(
59
+ (item) => Number(item.id) === variantId
60
+ );
61
+ if ((variant == null ? void 0 : variant.price) !== void 0 && (variant == null ? void 0 : variant.price) !== null) {
62
+ return toDecimal(variant.price);
63
+ }
64
+ }
65
+ return null;
66
+ }
67
+ function getOptionUnitPrice(product) {
68
+ const optionItems = product.product_option_item || [];
69
+ return optionItems.reduce((sum, item) => {
70
+ const quantity = getSafeNum(item == null ? void 0 : item.num);
71
+ const itemPrice = toDecimal(item == null ? void 0 : item.price);
72
+ return sum.plus(itemPrice.times(quantity));
73
+ }, new import_decimal.default(0));
74
+ }
75
+ function getBundleUnitPrice(product, useOriginal = false) {
76
+ const bundleItems = product.product_bundle || [];
77
+ return bundleItems.reduce((sum, item) => {
78
+ const quantity = getSafeNum(item == null ? void 0 : item.num);
79
+ 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));
80
+ return sum.plus(price.times(quantity));
81
+ }, new import_decimal.default(0));
82
+ }
83
+ function getUnitPaymentTotal(product) {
84
+ const variantPrice = getVariantPrice(product);
85
+ const basePrice = variantPrice || toDecimal(product.selling_price || product.payment_price);
86
+ return basePrice.plus(getOptionUnitPrice(product)).plus(getBundleUnitPrice(product));
87
+ }
88
+ function getUnitOriginalTotal(product) {
89
+ const basePrice = toDecimal(product.original_price || product.selling_price);
90
+ return basePrice.plus(getOptionUnitPrice(product)).plus(getBundleUnitPrice(product, true));
91
+ }
92
+ function buildSurchargeServiceItems(products) {
93
+ return products.map((product) => {
94
+ var _a, _b;
95
+ const quantity = getSafeNum(product.num);
96
+ const unitTotal = getUnitPaymentTotal(product);
97
+ return {
98
+ id: product.product_id,
99
+ num: quantity,
100
+ total: unitTotal.toNumber(),
101
+ price: unitTotal.toNumber(),
102
+ is_charge_tax: product.is_charge_tax ?? 0,
103
+ isCustomItem: product.product_id === null,
104
+ _origin: product._origin || {
105
+ product: {
106
+ discount_list: product.discount_list || [],
107
+ product_bundle: product.product_bundle || [],
108
+ product_option_item: product.product_option_item || []
109
+ }
110
+ },
111
+ bundle: product.product_bundle || [],
112
+ option: product.product_option_item || [],
113
+ options: product.product_option_item || [],
114
+ relation_details: [],
115
+ metadata: product.metadata || {},
116
+ start_date: ((_a = product.metadata) == null ? void 0 : _a.start_date) || "",
117
+ start_time: ((_b = product.metadata) == null ? void 0 : _b.start_time) || ""
118
+ };
119
+ });
120
+ }
121
+ function getProductDepositData(product) {
122
+ var _a, _b, _c;
123
+ const rootDepositData = (_a = product._origin) == null ? void 0 : _a.custom_deposit_data;
124
+ if (rootDepositData && typeof rootDepositData === "object")
125
+ return rootDepositData;
126
+ const nestedDepositData = (_c = (_b = product._origin) == null ? void 0 : _b.product) == null ? void 0 : _c.custom_deposit_data;
127
+ if (nestedDepositData && typeof nestedDepositData === "object")
128
+ return nestedDepositData;
129
+ return void 0;
130
+ }
131
+ function collectDepositPolicyIds(depositData) {
132
+ const rawIds = [
133
+ ...Array.isArray(depositData == null ? void 0 : depositData.self_deposit_policy_ids) ? depositData.self_deposit_policy_ids : [],
134
+ ...Array.isArray(depositData == null ? void 0 : depositData.deposit_policy_ids) ? depositData.deposit_policy_ids : []
135
+ ];
136
+ return rawIds.reduce((result, id) => {
137
+ const normalizedId = Number(id);
138
+ if (!Number.isFinite(normalizedId))
139
+ return result;
140
+ result.push(Math.floor(normalizedId));
141
+ return result;
142
+ }, []);
143
+ }
144
+ function collectDepositPolicyData(depositData) {
145
+ const rawPolicyData = Array.isArray(depositData == null ? void 0 : depositData.deposit_policy_data) ? depositData.deposit_policy_data : [];
146
+ return rawPolicyData.reduce((result, policy) => {
147
+ const normalizedId = Number(policy == null ? void 0 : policy.id);
148
+ if (!Number.isFinite(normalizedId))
149
+ return result;
150
+ result.push({
151
+ id: Math.floor(normalizedId),
152
+ title: String((policy == null ? void 0 : policy.title) || "")
153
+ });
154
+ return result;
155
+ }, []);
156
+ }
157
+ function calculateProductsDeposit(products) {
158
+ let totalDeposit = new import_decimal.default(0);
159
+ let hasDeposit = false;
160
+ const policyIds = /* @__PURE__ */ new Set();
161
+ const policyDataMap = /* @__PURE__ */ new Map();
162
+ for (const product of products) {
163
+ const depositData = getProductDepositData(product);
164
+ if (!depositData || depositData.has_deposit != 1)
165
+ continue;
166
+ const num = getSafeNum(product.num);
167
+ const unitTotal = getUnitPaymentTotal(product);
168
+ const productTotal = unitTotal.times(num);
169
+ const { deposit_fixed, deposit_percentage } = depositData;
170
+ const fixed = toDecimal(deposit_fixed);
171
+ const percentage = toDecimal(deposit_percentage);
172
+ const itemDeposit = fixed.plus(percentage.times(productTotal));
173
+ totalDeposit = totalDeposit.plus(itemDeposit);
174
+ hasDeposit = true;
175
+ for (const id of collectDepositPolicyIds(depositData)) {
176
+ policyIds.add(id);
177
+ }
178
+ for (const policy of collectDepositPolicyData(depositData)) {
179
+ if (!policyDataMap.has(policy.id)) {
180
+ policyDataMap.set(policy.id, policy);
181
+ }
182
+ policyIds.add(policy.id);
183
+ }
184
+ }
185
+ if (!hasDeposit)
186
+ return void 0;
187
+ for (const id of policyIds) {
188
+ if (!policyDataMap.has(id)) {
189
+ policyDataMap.set(id, {
190
+ id,
191
+ title: ""
192
+ });
193
+ }
194
+ }
195
+ return {
196
+ total: totalDeposit.toFixed(2),
197
+ deposit_policy_ids: [...policyIds],
198
+ deposit_policy_data: [...policyDataMap.values()],
199
+ hasDeposit: true
200
+ };
201
+ }
202
+ function isBundleOriginalPrice(item) {
203
+ return (item == null ? void 0 : item.price_type) === "markup" && (item == null ? void 0 : item.price_type_ext) === "product_price";
204
+ }
205
+ function isBundleMarkupOrDiscount(item) {
206
+ 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));
207
+ 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));
208
+ return isMarkup || isDiscount;
209
+ }
210
+ function getDiscountListAmount(discountList) {
211
+ return (discountList || []).reduce(
212
+ (total, d) => total.plus(toDecimal(d.amount)),
213
+ new import_decimal.default(0)
214
+ );
215
+ }
216
+ function calculateSingleItemTax(params) {
217
+ const { price, taxRate, isPriceIncludeTax, isChargeTax } = params;
218
+ if (price.lte(0))
219
+ return new import_decimal.default(0);
220
+ if (isChargeTax === 0 || !isChargeTax)
221
+ return new import_decimal.default(0);
222
+ const rate = taxRate.div(100);
223
+ if (isPriceIncludeTax === 0) {
224
+ return price.times(rate);
225
+ }
226
+ const divisor = new import_decimal.default(1).plus(rate);
227
+ if (divisor.lte(0))
228
+ return new import_decimal.default(0);
229
+ return price.dividedBy(divisor).times(rate);
230
+ }
231
+ function getMainProductPaymentTotal(product) {
232
+ var _a, _b, _c, _d;
233
+ const variantPrice = getVariantPrice(product);
234
+ let total = variantPrice || toDecimal(((_a = product.metadata) == null ? void 0 : _a.main_product_selling_price) ?? product.selling_price ?? product.payment_price);
235
+ const mainDiscountList = ((_c = (_b = product._origin) == null ? void 0 : _b.product) == null ? void 0 : _c.discount_list) || ((_d = product._origin) == null ? void 0 : _d.discount_list) || [];
236
+ const mainDiscountAmount = getDiscountListAmount(
237
+ mainDiscountList.filter((d) => {
238
+ var _a2;
239
+ return !((_a2 = d == null ? void 0 : d.metadata) == null ? void 0 : _a2.custom_product_bundle_map_id);
240
+ })
241
+ );
242
+ total = total.minus(mainDiscountAmount);
243
+ total = total.plus(getOptionUnitPrice(product));
244
+ const bundleItems = product.product_bundle || [];
245
+ for (const bundleItem of bundleItems) {
246
+ if (isBundleMarkupOrDiscount(bundleItem)) {
247
+ total = total.plus(toDecimal(bundleItem.bundle_selling_price ?? bundleItem.price ?? 0));
248
+ }
249
+ }
250
+ return import_decimal.default.max(total, 0);
251
+ }
252
+ function calculateProductsTax(products, taxRate, isPriceIncludeTax) {
253
+ const rate = new import_decimal.default(taxRate);
254
+ let preciseTax = new import_decimal.default(0);
255
+ let roundedTax = new import_decimal.default(0);
256
+ let preciseOriginTax = new import_decimal.default(0);
257
+ let roundedOriginTax = new import_decimal.default(0);
258
+ let lastTaxableItem = null;
259
+ for (const product of products) {
260
+ const quantity = new import_decimal.default(getSafeNum(product.num));
261
+ const mainTotal = getMainProductPaymentTotal(product);
262
+ const surchargeFee = toDecimal(product.surcharge_fee);
263
+ const mainTaxableBase = mainTotal.lte(0) ? surchargeFee : mainTotal.plus(surchargeFee);
264
+ const mainTaxPrecise = calculateSingleItemTax({
265
+ price: mainTaxableBase,
266
+ taxRate: rate,
267
+ isPriceIncludeTax,
268
+ isChargeTax: product.is_charge_tax ?? 0
269
+ });
270
+ const mainTaxRounded = mainTaxPrecise.toDecimalPlaces(2, import_decimal.default.ROUND_HALF_UP);
271
+ if (mainTaxPrecise.gt(0)) {
272
+ lastTaxableItem = { type: "main", item: product };
273
+ }
274
+ const originalTotal = getUnitOriginalTotal(product);
275
+ const originalTaxableBase = originalTotal.lte(0) ? surchargeFee : originalTotal.plus(surchargeFee);
276
+ const originalTaxPrecise = calculateSingleItemTax({
277
+ price: originalTaxableBase,
278
+ taxRate: rate,
279
+ isPriceIncludeTax,
280
+ isChargeTax: product.is_charge_tax ?? 0
281
+ });
282
+ let bundlePreciseTax = new import_decimal.default(0);
283
+ let bundleRoundedTax = new import_decimal.default(0);
284
+ let bundlePreciseOriginTax = new import_decimal.default(0);
285
+ let bundleRoundedOriginTax = new import_decimal.default(0);
286
+ const bundleItems = product.product_bundle || [];
287
+ for (const bundleItem of bundleItems) {
288
+ if (!isBundleOriginalPrice(bundleItem))
289
+ continue;
290
+ const bundleQuantity = new import_decimal.default(getSafeNum(bundleItem.num ?? bundleItem.quantity));
291
+ const bundlePrice = toDecimal(bundleItem.bundle_selling_price ?? bundleItem.price ?? 0);
292
+ const bundleOriginalPrice = toDecimal(bundleItem.original_price ?? bundleItem.product_price ?? bundleItem.price ?? 0);
293
+ const bundleTaxPrecise = calculateSingleItemTax({
294
+ price: bundlePrice,
295
+ taxRate: rate,
296
+ isPriceIncludeTax,
297
+ isChargeTax: bundleItem.is_charge_tax ?? product.is_charge_tax ?? 0
298
+ });
299
+ const bundleTaxRounded = bundleTaxPrecise.toDecimalPlaces(2, import_decimal.default.ROUND_HALF_UP);
300
+ const bundleOrigTaxPrecise = calculateSingleItemTax({
301
+ price: bundleOriginalPrice,
302
+ taxRate: rate,
303
+ isPriceIncludeTax,
304
+ isChargeTax: bundleItem.is_charge_tax ?? product.is_charge_tax ?? 0
305
+ });
306
+ const bundleOrigTaxRounded = bundleOrigTaxPrecise.toDecimalPlaces(2, import_decimal.default.ROUND_HALF_UP);
307
+ bundleItem.tax_fee = bundleTaxRounded.toNumber();
308
+ bundleItem.original_tax_fee = bundleOrigTaxRounded.toNumber();
309
+ bundlePreciseTax = bundlePreciseTax.plus(bundleTaxPrecise.times(bundleQuantity));
310
+ bundleRoundedTax = bundleRoundedTax.plus(bundleTaxRounded.times(bundleQuantity));
311
+ bundlePreciseOriginTax = bundlePreciseOriginTax.plus(bundleOrigTaxPrecise.times(bundleQuantity));
312
+ bundleRoundedOriginTax = bundleRoundedOriginTax.plus(bundleOrigTaxRounded.times(bundleQuantity));
313
+ if (bundleTaxPrecise.gt(0)) {
314
+ lastTaxableItem = { type: "bundle", item: bundleItem };
315
+ }
316
+ }
317
+ const itemTaxPrecise = mainTaxPrecise.plus(bundlePreciseTax);
318
+ const itemTaxRounded = mainTaxRounded.plus(bundleRoundedTax);
319
+ const itemOriginTaxPrecise = originalTaxPrecise.plus(bundlePreciseOriginTax);
320
+ const itemOriginTaxRounded = originalTaxPrecise.toDecimalPlaces(2, import_decimal.default.ROUND_HALF_UP).plus(bundleRoundedOriginTax);
321
+ product.tax_fee = itemTaxRounded.toDecimalPlaces(2, import_decimal.default.ROUND_HALF_UP).toFixed(2);
322
+ product.original_tax_fee = itemOriginTaxRounded.toDecimalPlaces(2, import_decimal.default.ROUND_HALF_UP).toNumber();
323
+ preciseTax = preciseTax.plus(itemTaxPrecise.times(quantity));
324
+ roundedTax = roundedTax.plus(itemTaxRounded.times(quantity));
325
+ preciseOriginTax = preciseOriginTax.plus(itemOriginTaxPrecise.times(quantity));
326
+ roundedOriginTax = roundedOriginTax.plus(itemOriginTaxRounded.times(quantity));
327
+ }
328
+ const expectedTax = preciseTax.toDecimalPlaces(2, import_decimal.default.ROUND_HALF_UP);
329
+ const expectedOriginTax = preciseOriginTax.toDecimalPlaces(2, import_decimal.default.ROUND_HALF_UP);
330
+ const taxRemainder = expectedTax.minus(roundedTax).toNumber();
331
+ const originTaxRemainder = expectedOriginTax.minus(roundedOriginTax).toNumber();
332
+ if (lastTaxableItem) {
333
+ if (taxRemainder !== 0) {
334
+ lastTaxableItem.item.tax_fee_rounding_remainder = taxRemainder;
335
+ }
336
+ if (originTaxRemainder !== 0) {
337
+ lastTaxableItem.item.original_tax_fee_rounding_remainder = originTaxRemainder;
338
+ }
339
+ }
340
+ return { tax: expectedTax, originTax: expectedOriginTax };
341
+ }
342
+ function createEmptySalesSummary() {
343
+ return {
344
+ product_quantity: 0,
345
+ product_original_amount: "0.00",
346
+ product_amount: "0.00",
347
+ product_expect_amount: "0.00",
348
+ product_tax_fee: "0.00",
349
+ shipping_fee: "0.00",
350
+ shipping_tax_fee: "0.00",
351
+ tax_fee: "0.00",
352
+ surcharge_fee: "0.00",
353
+ surcharges: [],
354
+ discount_amount: "0.00",
355
+ deposit_amount: "0.00",
356
+ expect_amount: "0.00",
357
+ total_amount: "0.00",
358
+ amount_gap: "0.00",
359
+ rounding_amount: "0.00",
360
+ pay_service_charge_amount: "0.00"
361
+ };
362
+ }
363
+ function calculateSalesSummary(params) {
364
+ var _a;
365
+ const {
366
+ products,
367
+ isPriceIncludeTax,
368
+ taxRate,
369
+ surchargeList,
370
+ scheduleById = {},
371
+ isInScheduleByDate
372
+ } = params;
373
+ if (!(products == null ? void 0 : products.length))
374
+ return createEmptySalesSummary();
375
+ const productQuantity = products.reduce(
376
+ (sum, item) => sum + getSafeNum(item.num),
377
+ 0
378
+ );
379
+ const productOriginalAmount = products.reduce(
380
+ (sum, item) => sum.plus(getUnitOriginalTotal(item).times(getSafeNum(item.num))),
381
+ new import_decimal.default(0)
382
+ );
383
+ const productAmount = products.reduce(
384
+ (sum, item) => sum.plus(getUnitPaymentTotal(item).times(getSafeNum(item.num))),
385
+ new import_decimal.default(0)
386
+ );
387
+ const surchargeServiceItems = buildSurchargeServiceItems(products);
388
+ const surcharge = (0, import_utils.getSurcharge)(
389
+ {
390
+ service: surchargeServiceItems,
391
+ addons: [],
392
+ bookingDetail: null,
393
+ bookingId: void 0
394
+ },
395
+ {
396
+ isEdit: false,
397
+ isInScheduleByDate,
398
+ surcharge_list: surchargeList,
399
+ scheduleById
400
+ }
401
+ );
402
+ const surchargeAmount = new import_decimal.default(
403
+ (0, import_utils.getSurchargeAmount)(
404
+ { bookingDetail: null, bookingId: void 0 },
405
+ surcharge,
406
+ { isEdit: false }
407
+ ) || 0
408
+ );
409
+ for (let i = 0; i < products.length; i++) {
410
+ products[i].surcharge_fee = ((_a = surchargeServiceItems[i]) == null ? void 0 : _a.surcharge_fee) || 0;
411
+ }
412
+ const hasTaxRate = taxRate !== void 0 && taxRate !== null && taxRate > 0;
413
+ let productTaxFee;
414
+ if (hasTaxRate) {
415
+ const taxResult = calculateProductsTax(products, taxRate, isPriceIncludeTax);
416
+ productTaxFee = taxResult.tax;
417
+ } else {
418
+ productTaxFee = products.reduce(
419
+ (sum, item) => sum.plus(toDecimal(item.tax_fee).times(getSafeNum(item.num))),
420
+ new import_decimal.default(0)
421
+ );
422
+ }
423
+ const expectAmount = productAmount.plus(surchargeAmount);
424
+ const totalAmount = isPriceIncludeTax === 1 ? expectAmount : expectAmount.plus(productTaxFee);
425
+ const deposit = calculateProductsDeposit(products);
426
+ return {
427
+ product_quantity: productQuantity,
428
+ product_original_amount: toFixed2(productOriginalAmount),
429
+ product_amount: toFixed2(productAmount),
430
+ product_expect_amount: toFixed2(productAmount),
431
+ product_tax_fee: toFixed2(productTaxFee),
432
+ shipping_fee: "0.00",
433
+ shipping_tax_fee: "0.00",
434
+ tax_fee: toFixed2(productTaxFee),
435
+ surcharge_fee: toFixed2(surchargeAmount),
436
+ surcharges: surcharge,
437
+ discount_amount: toFixed2(import_decimal.default.max(productOriginalAmount.minus(productAmount), 0)),
438
+ deposit_amount: deposit ? deposit.total : "0.00",
439
+ deposit,
440
+ expect_amount: toFixed2(expectAmount),
441
+ total_amount: toFixed2(totalAmount),
442
+ amount_gap: "0.00",
443
+ rounding_amount: "0.00",
444
+ pay_service_charge_amount: "0.00",
445
+ is_price_include_tax: isPriceIncludeTax
446
+ };
447
+ }
448
+ // Annotate the CommonJS export names for ESM import in node:
449
+ 0 && (module.exports = {
450
+ calculateSalesSummary,
451
+ createEmptySalesSummary
452
+ });
@@ -0,0 +1,21 @@
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
+ initialize(core: PisellCore, options?: ModuleOptions): Promise<void>;
15
+ setContext(context: ScanOrderLoggerContext): void;
16
+ setProvider(provider: ScanOrderLoggerProviderType): void;
17
+ setProviderConfig(providerConfig: ScanOrderLoggerProviderConfig): void;
18
+ private buildRecord;
19
+ addLog(params: ScanOrderLogInput): Promise<void>;
20
+ }
21
+ export * from './types';