@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.
- package/dist/apis/picoding.d.ts +0 -0
- package/dist/apis/picoding.js +1 -0
- package/dist/model/index.d.ts +1 -0
- package/dist/model/index.js +1 -0
- package/dist/model/strategy/adapter/index.d.ts +7 -0
- package/dist/model/strategy/adapter/index.js +7 -0
- package/dist/model/strategy/adapter/itemRule/adapter.d.ts +59 -0
- package/dist/model/strategy/adapter/itemRule/adapter.js +439 -0
- package/dist/model/strategy/adapter/itemRule/evaluator.d.ts +43 -0
- package/dist/model/strategy/adapter/itemRule/evaluator.js +169 -0
- package/dist/model/strategy/adapter/itemRule/examples.d.ts +64 -0
- package/dist/model/strategy/adapter/itemRule/examples.js +315 -0
- package/dist/model/strategy/adapter/itemRule/index.d.ts +5 -0
- package/dist/model/strategy/adapter/itemRule/index.js +5 -0
- package/dist/model/strategy/adapter/itemRule/type.d.ts +206 -0
- package/dist/model/strategy/adapter/itemRule/type.js +101 -0
- package/dist/model/strategy/adapter/promotion/adapter.d.ts +66 -0
- package/dist/model/strategy/adapter/promotion/adapter.js +271 -0
- package/dist/model/strategy/adapter/promotion/evaluator.d.ts +213 -0
- package/dist/model/strategy/adapter/promotion/evaluator.js +1206 -0
- package/dist/model/strategy/adapter/promotion/examples.d.ts +138 -0
- package/dist/model/strategy/adapter/promotion/examples.js +166 -0
- package/dist/model/strategy/adapter/promotion/index.d.ts +4 -0
- package/dist/model/strategy/adapter/promotion/index.js +0 -0
- package/dist/model/strategy/adapter/promotion/type.d.ts +447 -0
- package/dist/model/strategy/adapter/promotion/type.js +209 -0
- package/dist/model/strategy/adapter/type.d.ts +28 -0
- package/dist/model/strategy/adapter/type.js +1 -0
- package/dist/model/strategy/adapter/walletPass/evaluator.d.ts +84 -0
- package/dist/model/strategy/adapter/walletPass/evaluator.js +502 -0
- package/dist/model/strategy/adapter/walletPass/example.d.ts +4 -0
- package/dist/model/strategy/adapter/walletPass/example.js +258 -0
- package/dist/model/strategy/adapter/walletPass/index.d.ts +32 -0
- package/dist/model/strategy/adapter/walletPass/index.js +182 -0
- package/dist/model/strategy/adapter/walletPass/locales.d.ts +1 -0
- package/dist/model/strategy/adapter/walletPass/locales.js +26 -0
- package/dist/model/strategy/adapter/walletPass/type.d.ts +187 -0
- package/dist/model/strategy/adapter/walletPass/type.js +1 -0
- package/dist/model/strategy/adapter/walletPass/utils.d.ts +50 -0
- package/dist/model/strategy/adapter/walletPass/utils.js +1104 -0
- package/dist/model/strategy/engine.d.ts +106 -0
- package/dist/model/strategy/engine.js +611 -0
- package/dist/model/strategy/index.d.ts +3 -0
- package/dist/model/strategy/index.js +8 -0
- package/dist/model/strategy/strategy-example.d.ts +5 -0
- package/dist/model/strategy/strategy-example.js +331 -0
- package/dist/model/strategy/type.d.ts +228 -0
- package/dist/model/strategy/type.js +94 -0
- package/dist/modules/Cart/utils/cartProduct.js +1 -0
- package/dist/modules/OpenData/index.d.ts +24 -0
- package/dist/modules/OpenData/index.js +173 -0
- package/dist/modules/OpenData/types.d.ts +73 -0
- package/dist/modules/OpenData/types.js +1 -0
- package/dist/modules/OpenData/utils.d.ts +2 -0
- package/dist/modules/OpenData/utils.js +75 -0
- package/dist/modules/Order/index.d.ts +58 -1
- package/dist/modules/Order/index.js +796 -29
- package/dist/modules/Order/types.d.ts +144 -12
- package/dist/modules/Order/utils.d.ts +28 -0
- package/dist/modules/Order/utils.js +250 -1
- package/dist/modules/Product/index.d.ts +1 -1
- package/dist/modules/Product/utils.js +2 -2
- package/dist/modules/ProductList/index.d.ts +1 -1
- package/dist/modules/ProductList/index.js +2 -1
- package/dist/modules/Quotation/index.d.ts +48 -0
- package/dist/modules/Quotation/index.js +245 -0
- package/dist/modules/Quotation/types.d.ts +42 -0
- package/dist/modules/Quotation/types.js +1 -0
- package/dist/modules/Rules/index.js +4 -1
- package/dist/modules/SalesSummary/index.d.ts +63 -0
- package/dist/modules/SalesSummary/index.js +174 -0
- package/dist/modules/SalesSummary/types.d.ts +59 -0
- package/dist/modules/SalesSummary/types.js +1 -0
- package/dist/modules/SalesSummary/utils.d.ts +30 -0
- package/dist/modules/SalesSummary/utils.js +513 -0
- package/dist/modules/ScanOrderLogger/index.d.ts +21 -0
- package/dist/modules/ScanOrderLogger/index.js +161 -0
- package/dist/modules/ScanOrderLogger/providers/feishu.d.ts +2 -0
- package/dist/modules/ScanOrderLogger/providers/feishu.js +95 -0
- package/dist/modules/ScanOrderLogger/providers/grafana.d.ts +2 -0
- package/dist/modules/ScanOrderLogger/providers/grafana.js +50 -0
- package/dist/modules/ScanOrderLogger/types.d.ts +46 -0
- package/dist/modules/ScanOrderLogger/types.js +1 -0
- package/dist/modules/Schedule/getDateIsInSchedule.js +11 -18
- package/dist/modules/Summary/utils.d.ts +3 -3
- package/dist/modules/Summary/utils.js +4 -4
- package/dist/modules/index.d.ts +4 -0
- package/dist/modules/index.js +5 -1
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/BookingByStep/types.d.ts +3 -1
- package/dist/solution/BookingByStep/types.js +5 -1
- package/dist/solution/BookingTicket/index.d.ts +1 -1
- package/dist/solution/ScanOrder/index.d.ts +90 -0
- package/dist/solution/ScanOrder/index.js +1853 -0
- package/dist/solution/ScanOrder/types.d.ts +210 -0
- package/dist/solution/ScanOrder/types.js +16 -0
- package/dist/solution/ScanOrder/utils.d.ts +93 -0
- package/dist/solution/ScanOrder/utils.js +397 -0
- package/dist/solution/VenueBooking/index.d.ts +163 -0
- package/dist/solution/VenueBooking/index.js +2931 -0
- package/dist/solution/VenueBooking/sales-section-4-annotated.json +343 -0
- package/dist/solution/VenueBooking/types.d.ts +130 -0
- package/dist/solution/VenueBooking/types.js +21 -0
- package/dist/solution/VenueBooking/utils/dateSummary.d.ts +10 -0
- package/dist/solution/VenueBooking/utils/dateSummary.js +102 -0
- package/dist/solution/VenueBooking/utils/resource.d.ts +4 -0
- package/dist/solution/VenueBooking/utils/resource.js +94 -0
- package/dist/solution/VenueBooking/utils/slotMerge.d.ts +29 -0
- package/dist/solution/VenueBooking/utils/slotMerge.js +203 -0
- package/dist/solution/VenueBooking/utils/timeSlot.d.ts +32 -0
- package/dist/solution/VenueBooking/utils/timeSlot.js +256 -0
- package/dist/solution/VenueBooking/utils.d.ts +1 -0
- package/dist/solution/VenueBooking/utils.js +1 -0
- package/dist/solution/index.d.ts +2 -0
- package/dist/solution/index.js +3 -1
- package/lib/apis/picoding.d.ts +0 -0
- package/lib/apis/picoding.js +0 -0
- package/lib/model/index.d.ts +1 -0
- package/lib/model/index.js +23 -0
- package/lib/model/strategy/adapter/index.d.ts +7 -0
- package/lib/model/strategy/adapter/index.js +57 -0
- package/lib/model/strategy/adapter/itemRule/adapter.d.ts +59 -0
- package/lib/model/strategy/adapter/itemRule/adapter.js +338 -0
- package/lib/model/strategy/adapter/itemRule/evaluator.d.ts +43 -0
- package/lib/model/strategy/adapter/itemRule/evaluator.js +124 -0
- package/lib/model/strategy/adapter/itemRule/examples.d.ts +64 -0
- package/lib/model/strategy/adapter/itemRule/examples.js +269 -0
- package/lib/model/strategy/adapter/itemRule/index.d.ts +5 -0
- package/lib/model/strategy/adapter/itemRule/index.js +58 -0
- package/lib/model/strategy/adapter/itemRule/type.d.ts +206 -0
- package/lib/model/strategy/adapter/itemRule/type.js +46 -0
- package/lib/model/strategy/adapter/promotion/adapter.d.ts +66 -0
- package/lib/model/strategy/adapter/promotion/adapter.js +217 -0
- package/lib/model/strategy/adapter/promotion/evaluator.d.ts +213 -0
- package/lib/model/strategy/adapter/promotion/evaluator.js +844 -0
- package/lib/model/strategy/adapter/promotion/examples.d.ts +138 -0
- package/lib/model/strategy/adapter/promotion/examples.js +192 -0
- package/lib/model/strategy/adapter/promotion/index.d.ts +4 -0
- package/lib/model/strategy/adapter/promotion/index.js +49 -0
- package/lib/model/strategy/adapter/promotion/type.d.ts +447 -0
- package/lib/model/strategy/adapter/promotion/type.js +51 -0
- package/lib/model/strategy/adapter/type.d.ts +28 -0
- package/lib/model/strategy/adapter/type.js +17 -0
- package/lib/model/strategy/adapter/walletPass/evaluator.d.ts +84 -0
- package/lib/model/strategy/adapter/walletPass/evaluator.js +424 -0
- package/lib/model/strategy/adapter/walletPass/example.d.ts +4 -0
- package/lib/model/strategy/adapter/walletPass/example.js +207 -0
- package/lib/model/strategy/adapter/walletPass/index.d.ts +32 -0
- package/lib/model/strategy/adapter/walletPass/index.js +142 -0
- package/lib/model/strategy/adapter/walletPass/locales.d.ts +1 -0
- package/lib/model/strategy/adapter/walletPass/locales.js +54 -0
- package/lib/model/strategy/adapter/walletPass/type.d.ts +187 -0
- package/lib/model/strategy/adapter/walletPass/type.js +17 -0
- package/lib/model/strategy/adapter/walletPass/utils.d.ts +50 -0
- package/lib/model/strategy/adapter/walletPass/utils.js +791 -0
- package/lib/model/strategy/engine.d.ts +106 -0
- package/lib/model/strategy/engine.js +450 -0
- package/lib/model/strategy/index.d.ts +3 -0
- package/lib/model/strategy/index.js +38 -0
- package/lib/model/strategy/strategy-example.d.ts +5 -0
- package/lib/model/strategy/strategy-example.js +318 -0
- package/lib/model/strategy/type.d.ts +228 -0
- package/lib/model/strategy/type.js +44 -0
- package/lib/modules/Cart/utils/cartProduct.js +1 -0
- package/lib/modules/OpenData/index.d.ts +24 -0
- package/lib/modules/OpenData/index.js +119 -0
- package/lib/modules/OpenData/types.d.ts +73 -0
- package/lib/modules/OpenData/types.js +17 -0
- package/lib/modules/OpenData/utils.d.ts +2 -0
- package/lib/modules/OpenData/utils.js +111 -0
- package/lib/modules/Order/index.d.ts +58 -1
- package/lib/modules/Order/index.js +437 -1
- package/lib/modules/Order/types.d.ts +144 -12
- package/lib/modules/Order/utils.d.ts +28 -0
- package/lib/modules/Order/utils.js +250 -2
- package/lib/modules/Product/index.d.ts +1 -1
- package/lib/modules/Product/utils.js +2 -2
- package/lib/modules/ProductList/index.d.ts +1 -1
- package/lib/modules/ProductList/index.js +2 -1
- package/lib/modules/Quotation/index.d.ts +48 -0
- package/lib/modules/Quotation/index.js +149 -0
- package/lib/modules/Quotation/types.d.ts +42 -0
- package/lib/modules/Quotation/types.js +17 -0
- package/lib/modules/Rules/index.js +4 -1
- package/lib/modules/SalesSummary/index.d.ts +63 -0
- package/lib/modules/SalesSummary/index.js +105 -0
- package/lib/modules/SalesSummary/types.d.ts +59 -0
- package/lib/modules/SalesSummary/types.js +17 -0
- package/lib/modules/SalesSummary/utils.d.ts +30 -0
- package/lib/modules/SalesSummary/utils.js +452 -0
- package/lib/modules/ScanOrderLogger/index.d.ts +21 -0
- package/lib/modules/ScanOrderLogger/index.js +135 -0
- package/lib/modules/ScanOrderLogger/providers/feishu.d.ts +2 -0
- package/lib/modules/ScanOrderLogger/providers/feishu.js +82 -0
- package/lib/modules/ScanOrderLogger/providers/grafana.d.ts +2 -0
- package/lib/modules/ScanOrderLogger/providers/grafana.js +52 -0
- package/lib/modules/ScanOrderLogger/types.d.ts +46 -0
- package/lib/modules/ScanOrderLogger/types.js +17 -0
- package/lib/modules/Schedule/getDateIsInSchedule.js +9 -11
- package/lib/modules/Summary/utils.d.ts +3 -3
- package/lib/modules/Summary/utils.js +4 -4
- package/lib/modules/index.d.ts +4 -0
- package/lib/modules/index.js +9 -1
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/BookingByStep/types.d.ts +3 -1
- package/lib/solution/BookingByStep/types.js +10 -0
- package/lib/solution/BookingTicket/index.d.ts +1 -1
- package/lib/solution/ScanOrder/index.d.ts +90 -0
- package/lib/solution/ScanOrder/index.js +1071 -0
- package/lib/solution/ScanOrder/types.d.ts +210 -0
- package/lib/solution/ScanOrder/types.js +36 -0
- package/lib/solution/ScanOrder/utils.d.ts +93 -0
- package/lib/solution/ScanOrder/utils.js +359 -0
- package/lib/solution/VenueBooking/index.d.ts +163 -0
- package/lib/solution/VenueBooking/index.js +1578 -0
- package/lib/solution/VenueBooking/sales-section-4-annotated.json +343 -0
- package/lib/solution/VenueBooking/types.d.ts +130 -0
- package/lib/solution/VenueBooking/types.js +44 -0
- package/lib/solution/VenueBooking/utils/dateSummary.d.ts +10 -0
- package/lib/solution/VenueBooking/utils/dateSummary.js +101 -0
- package/lib/solution/VenueBooking/utils/resource.d.ts +4 -0
- package/lib/solution/VenueBooking/utils/resource.js +80 -0
- package/lib/solution/VenueBooking/utils/slotMerge.d.ts +29 -0
- package/lib/solution/VenueBooking/utils/slotMerge.js +208 -0
- package/lib/solution/VenueBooking/utils/timeSlot.d.ts +32 -0
- package/lib/solution/VenueBooking/utils/timeSlot.js +200 -0
- package/lib/solution/VenueBooking/utils.d.ts +1 -0
- package/lib/solution/VenueBooking/utils.js +69 -0
- package/lib/solution/index.d.ts +2 -0
- package/lib/solution/index.js +5 -1
- package/package.json +1 -1
|
@@ -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 @@
|
|
|
1
|
+
export {};
|
|
@@ -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,513 @@
|
|
|
1
|
+
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; } } }; }
|
|
2
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
3
|
+
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."); }
|
|
4
|
+
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); }
|
|
5
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
6
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
7
|
+
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; }
|
|
8
|
+
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); }
|
|
9
|
+
import Decimal from 'decimal.js';
|
|
10
|
+
import { getSurcharge, getSurchargeAmount } from "../Summary/utils";
|
|
11
|
+
function toDecimal(value) {
|
|
12
|
+
return new Decimal(value || 0);
|
|
13
|
+
}
|
|
14
|
+
function toFixed2(value) {
|
|
15
|
+
return new Decimal(value || 0).toFixed(2);
|
|
16
|
+
}
|
|
17
|
+
function getSafeNum(num) {
|
|
18
|
+
if (!num || Number.isNaN(num)) return 1;
|
|
19
|
+
if (num < 1) return 1;
|
|
20
|
+
return Math.floor(num);
|
|
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
|
+
function getBundleUnitPrice(product) {
|
|
58
|
+
var useOriginal = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
59
|
+
var bundleItems = product.product_bundle || [];
|
|
60
|
+
return bundleItems.reduce(function (sum, item) {
|
|
61
|
+
var _ref, _item$original_price, _item$bundle_selling_;
|
|
62
|
+
var quantity = getSafeNum(item === null || item === void 0 ? void 0 : item.num);
|
|
63
|
+
var price = useOriginal ? toDecimal((_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) : toDecimal((_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);
|
|
64
|
+
return sum.plus(price.times(quantity));
|
|
65
|
+
}, new Decimal(0));
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// 单商品总价口径:主商品单价 + option + bundle(随后再乘商品数量)
|
|
69
|
+
function getUnitPaymentTotal(product) {
|
|
70
|
+
var variantPrice = getVariantPrice(product);
|
|
71
|
+
var basePrice = variantPrice || toDecimal(product.selling_price || product.payment_price);
|
|
72
|
+
return basePrice.plus(getOptionUnitPrice(product)).plus(getBundleUnitPrice(product));
|
|
73
|
+
}
|
|
74
|
+
function getUnitOriginalTotal(product) {
|
|
75
|
+
var basePrice = toDecimal(product.original_price || product.selling_price);
|
|
76
|
+
return basePrice.plus(getOptionUnitPrice(product)).plus(getBundleUnitPrice(product, true));
|
|
77
|
+
}
|
|
78
|
+
function buildSurchargeServiceItems(products) {
|
|
79
|
+
return products.map(function (product) {
|
|
80
|
+
var _product$is_charge_ta, _product$metadata2, _product$metadata3;
|
|
81
|
+
var quantity = getSafeNum(product.num);
|
|
82
|
+
var unitTotal = getUnitPaymentTotal(product);
|
|
83
|
+
return {
|
|
84
|
+
id: product.product_id,
|
|
85
|
+
num: quantity,
|
|
86
|
+
total: unitTotal.toNumber(),
|
|
87
|
+
price: unitTotal.toNumber(),
|
|
88
|
+
is_charge_tax: (_product$is_charge_ta = product.is_charge_tax) !== null && _product$is_charge_ta !== void 0 ? _product$is_charge_ta : 0,
|
|
89
|
+
isCustomItem: product.product_id === null,
|
|
90
|
+
_origin: product._origin || {
|
|
91
|
+
product: {
|
|
92
|
+
discount_list: product.discount_list || [],
|
|
93
|
+
product_bundle: product.product_bundle || [],
|
|
94
|
+
product_option_item: product.product_option_item || []
|
|
95
|
+
}
|
|
96
|
+
},
|
|
97
|
+
bundle: product.product_bundle || [],
|
|
98
|
+
option: product.product_option_item || [],
|
|
99
|
+
options: product.product_option_item || [],
|
|
100
|
+
relation_details: [],
|
|
101
|
+
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) || ''
|
|
104
|
+
};
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
function getProductDepositData(product) {
|
|
108
|
+
var _product$_origin, _product$_origin2;
|
|
109
|
+
var rootDepositData = (_product$_origin = product._origin) === null || _product$_origin === void 0 ? void 0 : _product$_origin.custom_deposit_data;
|
|
110
|
+
if (rootDepositData && _typeof(rootDepositData) === 'object') return rootDepositData;
|
|
111
|
+
var nestedDepositData = (_product$_origin2 = product._origin) === null || _product$_origin2 === void 0 || (_product$_origin2 = _product$_origin2.product) === null || _product$_origin2 === void 0 ? void 0 : _product$_origin2.custom_deposit_data;
|
|
112
|
+
if (nestedDepositData && _typeof(nestedDepositData) === 'object') return nestedDepositData;
|
|
113
|
+
return undefined;
|
|
114
|
+
}
|
|
115
|
+
function collectDepositPolicyIds(depositData) {
|
|
116
|
+
var rawIds = [].concat(_toConsumableArray(Array.isArray(depositData === null || depositData === void 0 ? void 0 : depositData.self_deposit_policy_ids) ? depositData.self_deposit_policy_ids : []), _toConsumableArray(Array.isArray(depositData === null || depositData === void 0 ? void 0 : depositData.deposit_policy_ids) ? depositData.deposit_policy_ids : []));
|
|
117
|
+
return rawIds.reduce(function (result, id) {
|
|
118
|
+
var normalizedId = Number(id);
|
|
119
|
+
if (!Number.isFinite(normalizedId)) return result;
|
|
120
|
+
result.push(Math.floor(normalizedId));
|
|
121
|
+
return result;
|
|
122
|
+
}, []);
|
|
123
|
+
}
|
|
124
|
+
function collectDepositPolicyData(depositData) {
|
|
125
|
+
var rawPolicyData = Array.isArray(depositData === null || depositData === void 0 ? void 0 : depositData.deposit_policy_data) ? depositData.deposit_policy_data : [];
|
|
126
|
+
return rawPolicyData.reduce(function (result, policy) {
|
|
127
|
+
var normalizedId = Number(policy === null || policy === void 0 ? void 0 : policy.id);
|
|
128
|
+
if (!Number.isFinite(normalizedId)) return result;
|
|
129
|
+
result.push({
|
|
130
|
+
id: Math.floor(normalizedId),
|
|
131
|
+
title: String((policy === null || policy === void 0 ? void 0 : policy.title) || '')
|
|
132
|
+
});
|
|
133
|
+
return result;
|
|
134
|
+
}, []);
|
|
135
|
+
}
|
|
136
|
+
function calculateProductsDeposit(products) {
|
|
137
|
+
var totalDeposit = new Decimal(0);
|
|
138
|
+
var hasDeposit = false;
|
|
139
|
+
var policyIds = new Set();
|
|
140
|
+
var policyDataMap = new Map();
|
|
141
|
+
var _iterator = _createForOfIteratorHelper(products),
|
|
142
|
+
_step;
|
|
143
|
+
try {
|
|
144
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
145
|
+
var product = _step.value;
|
|
146
|
+
var depositData = getProductDepositData(product);
|
|
147
|
+
if (!depositData || depositData.has_deposit != 1) continue;
|
|
148
|
+
var num = getSafeNum(product.num);
|
|
149
|
+
var unitTotal = getUnitPaymentTotal(product);
|
|
150
|
+
var productTotal = unitTotal.times(num);
|
|
151
|
+
var deposit_fixed = depositData.deposit_fixed,
|
|
152
|
+
deposit_percentage = depositData.deposit_percentage;
|
|
153
|
+
var fixed = toDecimal(deposit_fixed);
|
|
154
|
+
var percentage = toDecimal(deposit_percentage);
|
|
155
|
+
var itemDeposit = fixed.plus(percentage.times(productTotal));
|
|
156
|
+
totalDeposit = totalDeposit.plus(itemDeposit);
|
|
157
|
+
hasDeposit = true;
|
|
158
|
+
var _iterator3 = _createForOfIteratorHelper(collectDepositPolicyIds(depositData)),
|
|
159
|
+
_step3;
|
|
160
|
+
try {
|
|
161
|
+
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
162
|
+
var id = _step3.value;
|
|
163
|
+
policyIds.add(id);
|
|
164
|
+
}
|
|
165
|
+
} catch (err) {
|
|
166
|
+
_iterator3.e(err);
|
|
167
|
+
} finally {
|
|
168
|
+
_iterator3.f();
|
|
169
|
+
}
|
|
170
|
+
var _iterator4 = _createForOfIteratorHelper(collectDepositPolicyData(depositData)),
|
|
171
|
+
_step4;
|
|
172
|
+
try {
|
|
173
|
+
for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
|
|
174
|
+
var policy = _step4.value;
|
|
175
|
+
if (!policyDataMap.has(policy.id)) {
|
|
176
|
+
policyDataMap.set(policy.id, policy);
|
|
177
|
+
}
|
|
178
|
+
policyIds.add(policy.id);
|
|
179
|
+
}
|
|
180
|
+
} catch (err) {
|
|
181
|
+
_iterator4.e(err);
|
|
182
|
+
} finally {
|
|
183
|
+
_iterator4.f();
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
} catch (err) {
|
|
187
|
+
_iterator.e(err);
|
|
188
|
+
} finally {
|
|
189
|
+
_iterator.f();
|
|
190
|
+
}
|
|
191
|
+
if (!hasDeposit) return undefined;
|
|
192
|
+
var _iterator2 = _createForOfIteratorHelper(policyIds),
|
|
193
|
+
_step2;
|
|
194
|
+
try {
|
|
195
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
196
|
+
var _id = _step2.value;
|
|
197
|
+
if (!policyDataMap.has(_id)) {
|
|
198
|
+
policyDataMap.set(_id, {
|
|
199
|
+
id: _id,
|
|
200
|
+
title: ''
|
|
201
|
+
});
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
} catch (err) {
|
|
205
|
+
_iterator2.e(err);
|
|
206
|
+
} finally {
|
|
207
|
+
_iterator2.f();
|
|
208
|
+
}
|
|
209
|
+
return {
|
|
210
|
+
total: totalDeposit.toFixed(2),
|
|
211
|
+
deposit_policy_ids: _toConsumableArray(policyIds),
|
|
212
|
+
deposit_policy_data: _toConsumableArray(policyDataMap.values()),
|
|
213
|
+
hasDeposit: true
|
|
214
|
+
};
|
|
215
|
+
}
|
|
216
|
+
function isBundleOriginalPrice(item) {
|
|
217
|
+
return (item === null || item === void 0 ? void 0 : item.price_type) === 'markup' && (item === null || item === void 0 ? void 0 : item.price_type_ext) === 'product_price';
|
|
218
|
+
}
|
|
219
|
+
function isBundleMarkupOrDiscount(item) {
|
|
220
|
+
var isMarkup = (item === null || item === void 0 ? void 0 : item.price_type) === 'markup' && ((item === null || item === void 0 ? void 0 : item.price_type_ext) === '' || !(item !== null && item !== void 0 && item.price_type_ext));
|
|
221
|
+
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
|
+
return isMarkup || isDiscount;
|
|
223
|
+
}
|
|
224
|
+
function getDiscountListAmount(discountList) {
|
|
225
|
+
return (discountList || []).reduce(function (total, d) {
|
|
226
|
+
return total.plus(toDecimal(d.amount));
|
|
227
|
+
}, new Decimal(0));
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
/**
|
|
231
|
+
* 计算单个商品税费(返回精确值,不四舍五入)。
|
|
232
|
+
* 与 Summary/utils.ts 的 getProductItemTax 公式一致,但不依赖 bookingDetail。
|
|
233
|
+
*
|
|
234
|
+
* @param taxRate 百分比税率(如 5 表示 5%),函数内部会 /100
|
|
235
|
+
*/
|
|
236
|
+
function calculateSingleItemTax(params) {
|
|
237
|
+
var price = params.price,
|
|
238
|
+
taxRate = params.taxRate,
|
|
239
|
+
isPriceIncludeTax = params.isPriceIncludeTax,
|
|
240
|
+
isChargeTax = params.isChargeTax;
|
|
241
|
+
if (price.lte(0)) return new Decimal(0);
|
|
242
|
+
if (isChargeTax === 0 || !isChargeTax) return new Decimal(0);
|
|
243
|
+
var rate = taxRate.div(100);
|
|
244
|
+
if (isPriceIncludeTax === 0) {
|
|
245
|
+
return price.times(rate);
|
|
246
|
+
}
|
|
247
|
+
var divisor = new Decimal(1).plus(rate);
|
|
248
|
+
if (divisor.lte(0)) return new Decimal(0);
|
|
249
|
+
return price.dividedBy(divisor).times(rate);
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
/**
|
|
253
|
+
* 获取主商品折扣后总价(主体价格 + option + 加价/减价 bundle)。
|
|
254
|
+
* 与 Summary/utils.ts 的 getMainProductTotal 逻辑对齐,适配 SalesSummaryProduct 结构。
|
|
255
|
+
*/
|
|
256
|
+
function getMainProductPaymentTotal(product) {
|
|
257
|
+
var _ref2, _product$metadata$mai, _product$metadata4, _product$_origin3, _product$_origin4;
|
|
258
|
+
var variantPrice = getVariantPrice(product);
|
|
259
|
+
var total = variantPrice || toDecimal((_ref2 = (_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) !== null && _ref2 !== void 0 ? _ref2 : product.payment_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));
|
|
267
|
+
var bundleItems = product.product_bundle || [];
|
|
268
|
+
var _iterator5 = _createForOfIteratorHelper(bundleItems),
|
|
269
|
+
_step5;
|
|
270
|
+
try {
|
|
271
|
+
for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
|
|
272
|
+
var bundleItem = _step5.value;
|
|
273
|
+
if (isBundleMarkupOrDiscount(bundleItem)) {
|
|
274
|
+
var _ref3, _bundleItem$bundle_se;
|
|
275
|
+
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
|
+
}
|
|
277
|
+
}
|
|
278
|
+
} catch (err) {
|
|
279
|
+
_iterator5.e(err);
|
|
280
|
+
} finally {
|
|
281
|
+
_iterator5.f();
|
|
282
|
+
}
|
|
283
|
+
return Decimal.max(total, 0);
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
/**
|
|
287
|
+
* 遍历所有商品计算税费,回写 tax_fee 到每个商品及 bundle 原价子商品,处理舍入差值。
|
|
288
|
+
* 参照 Summary/utils.ts 的 processItemsTax,适配 SalesSummaryProduct 结构。
|
|
289
|
+
*/
|
|
290
|
+
function calculateProductsTax(products, taxRate, isPriceIncludeTax) {
|
|
291
|
+
var rate = new Decimal(taxRate);
|
|
292
|
+
var preciseTax = new Decimal(0);
|
|
293
|
+
var roundedTax = new Decimal(0);
|
|
294
|
+
var preciseOriginTax = new Decimal(0);
|
|
295
|
+
var roundedOriginTax = new Decimal(0);
|
|
296
|
+
var lastTaxableItem = null;
|
|
297
|
+
var _iterator6 = _createForOfIteratorHelper(products),
|
|
298
|
+
_step6;
|
|
299
|
+
try {
|
|
300
|
+
for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
|
|
301
|
+
var _product$is_charge_ta2, _product$is_charge_ta3;
|
|
302
|
+
var product = _step6.value;
|
|
303
|
+
var quantity = new Decimal(getSafeNum(product.num));
|
|
304
|
+
|
|
305
|
+
// --- 主商品折后税费 ---
|
|
306
|
+
var mainTotal = getMainProductPaymentTotal(product);
|
|
307
|
+
var surchargeFee = toDecimal(product.surcharge_fee);
|
|
308
|
+
var mainTaxableBase = mainTotal.lte(0) ? surchargeFee : mainTotal.plus(surchargeFee);
|
|
309
|
+
var mainTaxPrecise = calculateSingleItemTax({
|
|
310
|
+
price: mainTaxableBase,
|
|
311
|
+
taxRate: rate,
|
|
312
|
+
isPriceIncludeTax: isPriceIncludeTax,
|
|
313
|
+
isChargeTax: (_product$is_charge_ta2 = product.is_charge_tax) !== null && _product$is_charge_ta2 !== void 0 ? _product$is_charge_ta2 : 0
|
|
314
|
+
});
|
|
315
|
+
var mainTaxRounded = mainTaxPrecise.toDecimalPlaces(2, Decimal.ROUND_HALF_UP);
|
|
316
|
+
if (mainTaxPrecise.gt(0)) {
|
|
317
|
+
lastTaxableItem = {
|
|
318
|
+
type: 'main',
|
|
319
|
+
item: product
|
|
320
|
+
};
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
// --- 主商品原价税费 ---
|
|
324
|
+
var originalTotal = getUnitOriginalTotal(product);
|
|
325
|
+
var originalTaxableBase = originalTotal.lte(0) ? surchargeFee : originalTotal.plus(surchargeFee);
|
|
326
|
+
var originalTaxPrecise = calculateSingleItemTax({
|
|
327
|
+
price: originalTaxableBase,
|
|
328
|
+
taxRate: rate,
|
|
329
|
+
isPriceIncludeTax: isPriceIncludeTax,
|
|
330
|
+
isChargeTax: (_product$is_charge_ta3 = product.is_charge_tax) !== null && _product$is_charge_ta3 !== void 0 ? _product$is_charge_ta3 : 0
|
|
331
|
+
});
|
|
332
|
+
|
|
333
|
+
// --- bundle 原价子商品独立计税 ---
|
|
334
|
+
var bundlePreciseTax = new Decimal(0);
|
|
335
|
+
var bundleRoundedTax = new Decimal(0);
|
|
336
|
+
var bundlePreciseOriginTax = new Decimal(0);
|
|
337
|
+
var bundleRoundedOriginTax = new Decimal(0);
|
|
338
|
+
var bundleItems = product.product_bundle || [];
|
|
339
|
+
var _iterator7 = _createForOfIteratorHelper(bundleItems),
|
|
340
|
+
_step7;
|
|
341
|
+
try {
|
|
342
|
+
for (_iterator7.s(); !(_step7 = _iterator7.n()).done;) {
|
|
343
|
+
var _bundleItem$num, _ref4, _bundleItem$bundle_se2, _ref5, _ref6, _bundleItem$original_, _ref7, _bundleItem$is_charge, _ref8, _bundleItem$is_charge2;
|
|
344
|
+
var bundleItem = _step7.value;
|
|
345
|
+
if (!isBundleOriginalPrice(bundleItem)) continue;
|
|
346
|
+
var bundleQuantity = new Decimal(getSafeNum((_bundleItem$num = bundleItem.num) !== null && _bundleItem$num !== void 0 ? _bundleItem$num : bundleItem.quantity));
|
|
347
|
+
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);
|
|
348
|
+
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
|
+
var bundleTaxPrecise = calculateSingleItemTax({
|
|
350
|
+
price: bundlePrice,
|
|
351
|
+
taxRate: rate,
|
|
352
|
+
isPriceIncludeTax: isPriceIncludeTax,
|
|
353
|
+
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
|
+
});
|
|
355
|
+
var bundleTaxRounded = bundleTaxPrecise.toDecimalPlaces(2, Decimal.ROUND_HALF_UP);
|
|
356
|
+
var bundleOrigTaxPrecise = calculateSingleItemTax({
|
|
357
|
+
price: bundleOriginalPrice,
|
|
358
|
+
taxRate: rate,
|
|
359
|
+
isPriceIncludeTax: isPriceIncludeTax,
|
|
360
|
+
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
|
+
});
|
|
362
|
+
var bundleOrigTaxRounded = bundleOrigTaxPrecise.toDecimalPlaces(2, Decimal.ROUND_HALF_UP);
|
|
363
|
+
bundleItem.tax_fee = bundleTaxRounded.toNumber();
|
|
364
|
+
bundleItem.original_tax_fee = bundleOrigTaxRounded.toNumber();
|
|
365
|
+
bundlePreciseTax = bundlePreciseTax.plus(bundleTaxPrecise.times(bundleQuantity));
|
|
366
|
+
bundleRoundedTax = bundleRoundedTax.plus(bundleTaxRounded.times(bundleQuantity));
|
|
367
|
+
bundlePreciseOriginTax = bundlePreciseOriginTax.plus(bundleOrigTaxPrecise.times(bundleQuantity));
|
|
368
|
+
bundleRoundedOriginTax = bundleRoundedOriginTax.plus(bundleOrigTaxRounded.times(bundleQuantity));
|
|
369
|
+
if (bundleTaxPrecise.gt(0)) {
|
|
370
|
+
lastTaxableItem = {
|
|
371
|
+
type: 'bundle',
|
|
372
|
+
item: bundleItem
|
|
373
|
+
};
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
// --- 汇总到商品级 ---
|
|
378
|
+
} catch (err) {
|
|
379
|
+
_iterator7.e(err);
|
|
380
|
+
} finally {
|
|
381
|
+
_iterator7.f();
|
|
382
|
+
}
|
|
383
|
+
var itemTaxPrecise = mainTaxPrecise.plus(bundlePreciseTax);
|
|
384
|
+
var itemTaxRounded = mainTaxRounded.plus(bundleRoundedTax);
|
|
385
|
+
var itemOriginTaxPrecise = originalTaxPrecise.plus(bundlePreciseOriginTax);
|
|
386
|
+
var itemOriginTaxRounded = originalTaxPrecise.toDecimalPlaces(2, Decimal.ROUND_HALF_UP).plus(bundleRoundedOriginTax);
|
|
387
|
+
product.tax_fee = itemTaxRounded.toDecimalPlaces(2, Decimal.ROUND_HALF_UP).toFixed(2);
|
|
388
|
+
product.original_tax_fee = itemOriginTaxRounded.toDecimalPlaces(2, Decimal.ROUND_HALF_UP).toNumber();
|
|
389
|
+
preciseTax = preciseTax.plus(itemTaxPrecise.times(quantity));
|
|
390
|
+
roundedTax = roundedTax.plus(itemTaxRounded.times(quantity));
|
|
391
|
+
preciseOriginTax = preciseOriginTax.plus(itemOriginTaxPrecise.times(quantity));
|
|
392
|
+
roundedOriginTax = roundedOriginTax.plus(itemOriginTaxRounded.times(quantity));
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
// --- 舍入差值处理 ---
|
|
396
|
+
} catch (err) {
|
|
397
|
+
_iterator6.e(err);
|
|
398
|
+
} finally {
|
|
399
|
+
_iterator6.f();
|
|
400
|
+
}
|
|
401
|
+
var expectedTax = preciseTax.toDecimalPlaces(2, Decimal.ROUND_HALF_UP);
|
|
402
|
+
var expectedOriginTax = preciseOriginTax.toDecimalPlaces(2, Decimal.ROUND_HALF_UP);
|
|
403
|
+
var taxRemainder = expectedTax.minus(roundedTax).toNumber();
|
|
404
|
+
var originTaxRemainder = expectedOriginTax.minus(roundedOriginTax).toNumber();
|
|
405
|
+
if (lastTaxableItem) {
|
|
406
|
+
if (taxRemainder !== 0) {
|
|
407
|
+
lastTaxableItem.item.tax_fee_rounding_remainder = taxRemainder;
|
|
408
|
+
}
|
|
409
|
+
if (originTaxRemainder !== 0) {
|
|
410
|
+
lastTaxableItem.item.original_tax_fee_rounding_remainder = originTaxRemainder;
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
return {
|
|
414
|
+
tax: expectedTax,
|
|
415
|
+
originTax: expectedOriginTax
|
|
416
|
+
};
|
|
417
|
+
}
|
|
418
|
+
export function createEmptySalesSummary() {
|
|
419
|
+
return {
|
|
420
|
+
product_quantity: 0,
|
|
421
|
+
product_original_amount: '0.00',
|
|
422
|
+
product_amount: '0.00',
|
|
423
|
+
product_expect_amount: '0.00',
|
|
424
|
+
product_tax_fee: '0.00',
|
|
425
|
+
shipping_fee: '0.00',
|
|
426
|
+
shipping_tax_fee: '0.00',
|
|
427
|
+
tax_fee: '0.00',
|
|
428
|
+
surcharge_fee: '0.00',
|
|
429
|
+
surcharges: [],
|
|
430
|
+
discount_amount: '0.00',
|
|
431
|
+
deposit_amount: '0.00',
|
|
432
|
+
expect_amount: '0.00',
|
|
433
|
+
total_amount: '0.00',
|
|
434
|
+
amount_gap: '0.00',
|
|
435
|
+
rounding_amount: '0.00',
|
|
436
|
+
pay_service_charge_amount: '0.00'
|
|
437
|
+
};
|
|
438
|
+
}
|
|
439
|
+
export function calculateSalesSummary(params) {
|
|
440
|
+
var products = params.products,
|
|
441
|
+
isPriceIncludeTax = params.isPriceIncludeTax,
|
|
442
|
+
taxRate = params.taxRate,
|
|
443
|
+
surchargeList = params.surchargeList,
|
|
444
|
+
_params$scheduleById = params.scheduleById,
|
|
445
|
+
scheduleById = _params$scheduleById === void 0 ? {} : _params$scheduleById,
|
|
446
|
+
isInScheduleByDate = params.isInScheduleByDate;
|
|
447
|
+
if (!(products !== null && products !== void 0 && products.length)) return createEmptySalesSummary();
|
|
448
|
+
var productQuantity = products.reduce(function (sum, item) {
|
|
449
|
+
return sum + getSafeNum(item.num);
|
|
450
|
+
}, 0);
|
|
451
|
+
var productOriginalAmount = products.reduce(function (sum, item) {
|
|
452
|
+
return sum.plus(getUnitOriginalTotal(item).times(getSafeNum(item.num)));
|
|
453
|
+
}, new Decimal(0));
|
|
454
|
+
var productAmount = products.reduce(function (sum, item) {
|
|
455
|
+
return sum.plus(getUnitPaymentTotal(item).times(getSafeNum(item.num)));
|
|
456
|
+
}, new Decimal(0));
|
|
457
|
+
var surchargeServiceItems = buildSurchargeServiceItems(products);
|
|
458
|
+
var surcharge = getSurcharge({
|
|
459
|
+
service: surchargeServiceItems,
|
|
460
|
+
addons: [],
|
|
461
|
+
bookingDetail: null,
|
|
462
|
+
bookingId: undefined
|
|
463
|
+
}, {
|
|
464
|
+
isEdit: false,
|
|
465
|
+
isInScheduleByDate: isInScheduleByDate,
|
|
466
|
+
surcharge_list: surchargeList,
|
|
467
|
+
scheduleById: scheduleById
|
|
468
|
+
});
|
|
469
|
+
var surchargeAmount = new Decimal(getSurchargeAmount({
|
|
470
|
+
bookingDetail: null,
|
|
471
|
+
bookingId: undefined
|
|
472
|
+
}, surcharge, {
|
|
473
|
+
isEdit: false
|
|
474
|
+
}) || 0);
|
|
475
|
+
for (var i = 0; i < products.length; i++) {
|
|
476
|
+
var _surchargeServiceItem;
|
|
477
|
+
products[i].surcharge_fee = ((_surchargeServiceItem = surchargeServiceItems[i]) === null || _surchargeServiceItem === void 0 ? void 0 : _surchargeServiceItem.surcharge_fee) || 0;
|
|
478
|
+
}
|
|
479
|
+
var hasTaxRate = taxRate !== undefined && taxRate !== null && taxRate > 0;
|
|
480
|
+
var productTaxFee;
|
|
481
|
+
if (hasTaxRate) {
|
|
482
|
+
var taxResult = calculateProductsTax(products, taxRate, isPriceIncludeTax);
|
|
483
|
+
productTaxFee = taxResult.tax;
|
|
484
|
+
} else {
|
|
485
|
+
productTaxFee = products.reduce(function (sum, item) {
|
|
486
|
+
return sum.plus(toDecimal(item.tax_fee).times(getSafeNum(item.num)));
|
|
487
|
+
}, new Decimal(0));
|
|
488
|
+
}
|
|
489
|
+
var expectAmount = productAmount.plus(surchargeAmount);
|
|
490
|
+
var totalAmount = isPriceIncludeTax === 1 ? expectAmount : expectAmount.plus(productTaxFee);
|
|
491
|
+
var deposit = calculateProductsDeposit(products);
|
|
492
|
+
return {
|
|
493
|
+
product_quantity: productQuantity,
|
|
494
|
+
product_original_amount: toFixed2(productOriginalAmount),
|
|
495
|
+
product_amount: toFixed2(productAmount),
|
|
496
|
+
product_expect_amount: toFixed2(productAmount),
|
|
497
|
+
product_tax_fee: toFixed2(productTaxFee),
|
|
498
|
+
shipping_fee: '0.00',
|
|
499
|
+
shipping_tax_fee: '0.00',
|
|
500
|
+
tax_fee: toFixed2(productTaxFee),
|
|
501
|
+
surcharge_fee: toFixed2(surchargeAmount),
|
|
502
|
+
surcharges: surcharge,
|
|
503
|
+
discount_amount: toFixed2(Decimal.max(productOriginalAmount.minus(productAmount), 0)),
|
|
504
|
+
deposit_amount: deposit ? deposit.total : '0.00',
|
|
505
|
+
deposit: deposit,
|
|
506
|
+
expect_amount: toFixed2(expectAmount),
|
|
507
|
+
total_amount: toFixed2(totalAmount),
|
|
508
|
+
amount_gap: '0.00',
|
|
509
|
+
rounding_amount: '0.00',
|
|
510
|
+
pay_service_charge_amount: '0.00',
|
|
511
|
+
is_price_include_tax: isPriceIncludeTax
|
|
512
|
+
};
|
|
513
|
+
}
|
|
@@ -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';
|