@pisell/pisellos 1.0.124 → 1.0.125
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.
|
@@ -193,6 +193,15 @@ export var getTax = function getTax(_ref, options) {
|
|
|
193
193
|
tax: totalTax.toDecimalPlaces(2, Decimal.ROUND_HALF_UP).toNumber()
|
|
194
194
|
};
|
|
195
195
|
};
|
|
196
|
+
function getDiscountedTaxableBase(input) {
|
|
197
|
+
var basePrice = input.basePrice,
|
|
198
|
+
discount = input.discount,
|
|
199
|
+
surchargeFee = input.surchargeFee;
|
|
200
|
+
if (surchargeFee.lte(0) && basePrice.lte(0)) return new Decimal(0);
|
|
201
|
+
var discountedBase = basePrice.minus(discount);
|
|
202
|
+
if (discountedBase.lte(0)) return surchargeFee;
|
|
203
|
+
return discountedBase.plus(surchargeFee);
|
|
204
|
+
}
|
|
196
205
|
|
|
197
206
|
/**
|
|
198
207
|
* 处理商品税费计算(折扣前后)
|
|
@@ -237,8 +246,13 @@ var processItemsTax = function processItemsTax(items, _ref2, options) {
|
|
|
237
246
|
})) || 0);
|
|
238
247
|
|
|
239
248
|
// 计算原始税费(折扣前)- 单个商品(精确值)
|
|
249
|
+
var originalTaxableBase = getDiscountedTaxableBase({
|
|
250
|
+
basePrice: mainProductPrice,
|
|
251
|
+
discount: new Decimal(0),
|
|
252
|
+
surchargeFee: new Decimal((item === null || item === void 0 ? void 0 : item.surcharge_fee) || 0)
|
|
253
|
+
});
|
|
240
254
|
var originalTaxPerItemPrecise = getProductItemTax(_objectSpread(_objectSpread({}, item), {}, {
|
|
241
|
-
total:
|
|
255
|
+
total: originalTaxableBase.toNumber(),
|
|
242
256
|
quantity: 1
|
|
243
257
|
}), {
|
|
244
258
|
bookingDetail: bookingDetail,
|
|
@@ -259,7 +273,11 @@ var processItemsTax = function processItemsTax(items, _ref2, options) {
|
|
|
259
273
|
if (unitPrice.greaterThan(0)) {
|
|
260
274
|
mainItemDiscount = mainProductPrice.dividedBy(productExpectAmount).times(shopDiscount);
|
|
261
275
|
}
|
|
262
|
-
var mainItemDiscountedUnitPrice =
|
|
276
|
+
var mainItemDiscountedUnitPrice = getDiscountedTaxableBase({
|
|
277
|
+
basePrice: mainProductPrice,
|
|
278
|
+
discount: mainItemDiscount,
|
|
279
|
+
surchargeFee: new Decimal((item === null || item === void 0 ? void 0 : item.surcharge_fee) || 0)
|
|
280
|
+
});
|
|
263
281
|
|
|
264
282
|
// 计算折后税费(折扣后)- 主商品的税费(精确值)
|
|
265
283
|
var maxDiscountedTaxPerItemPrecise = getProductItemTax(_objectSpread(_objectSpread({}, item), {}, {
|
|
@@ -299,12 +317,14 @@ var processItemsTax = function processItemsTax(items, _ref2, options) {
|
|
|
299
317
|
var atItem = _step2.value;
|
|
300
318
|
// 计算单件加时商品折扣后价格
|
|
301
319
|
var _originTotal = new Decimal(atItem.selling_price || atItem.price || 0);
|
|
302
|
-
var
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
320
|
+
var addTimeDiscount = productExpectAmount > 0 ? _originTotal.dividedBy(productExpectAmount).times(shopDiscount) : new Decimal(0);
|
|
321
|
+
var _discountedTotal = getDiscountedTaxableBase({
|
|
322
|
+
basePrice: _originTotal,
|
|
323
|
+
discount: addTimeDiscount,
|
|
324
|
+
surchargeFee: new Decimal((atItem === null || atItem === void 0 ? void 0 : atItem.surcharge_fee) || 0)
|
|
325
|
+
});
|
|
306
326
|
var addTimeTaxPerItemPrecise = getProductItemTax(_objectSpread(_objectSpread({}, atItem), {}, {
|
|
307
|
-
total: _discountedTotal.
|
|
327
|
+
total: _discountedTotal.toNumber(),
|
|
308
328
|
quantity: atItem.product_quantity || atItem.num || 1
|
|
309
329
|
}), {
|
|
310
330
|
bookingDetail: bookingDetail,
|
|
@@ -353,8 +373,13 @@ var processItemsTax = function processItemsTax(items, _ref2, options) {
|
|
|
353
373
|
var bundleUnitPrice = new Decimal((_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);
|
|
354
374
|
|
|
355
375
|
// 计算原始税费(折扣前)- 单个商品(精确值)
|
|
376
|
+
var bundleOriginalTaxableBase = getDiscountedTaxableBase({
|
|
377
|
+
basePrice: bundleUnitPrice,
|
|
378
|
+
discount: new Decimal(0),
|
|
379
|
+
surchargeFee: new Decimal((bundleItem === null || bundleItem === void 0 ? void 0 : bundleItem.surcharge_fee) || 0)
|
|
380
|
+
});
|
|
356
381
|
var bundleOriginalTaxPerItemPrecise = getProductItemTax(_objectSpread(_objectSpread({}, bundleItem), {}, {
|
|
357
|
-
total:
|
|
382
|
+
total: bundleOriginalTaxableBase.toNumber(),
|
|
358
383
|
quantity: 1
|
|
359
384
|
}), {
|
|
360
385
|
bookingDetail: bookingDetail,
|
|
@@ -371,7 +396,11 @@ var processItemsTax = function processItemsTax(items, _ref2, options) {
|
|
|
371
396
|
}
|
|
372
397
|
|
|
373
398
|
// bundle商品折后单价
|
|
374
|
-
var bundleDiscountedUnitPrice =
|
|
399
|
+
var bundleDiscountedUnitPrice = getDiscountedTaxableBase({
|
|
400
|
+
basePrice: bundleUnitPrice,
|
|
401
|
+
discount: bundleItemDiscount,
|
|
402
|
+
surchargeFee: new Decimal((bundleItem === null || bundleItem === void 0 ? void 0 : bundleItem.surcharge_fee) || 0)
|
|
403
|
+
});
|
|
375
404
|
|
|
376
405
|
// 计算折后税费(折扣后)- 单个商品(精确值)
|
|
377
406
|
var bundleDiscountedTaxPerItemPrecise = getProductItemTax(_objectSpread(_objectSpread({}, bundleItem), {}, {
|
|
@@ -723,7 +752,6 @@ var getMainProductTotal = function getMainProductTotal(item) {
|
|
|
723
752
|
}
|
|
724
753
|
return total.toNumber();
|
|
725
754
|
};
|
|
726
|
-
|
|
727
755
|
/**
|
|
728
756
|
* 判断商品是否符合附加费条件
|
|
729
757
|
*/
|
|
@@ -115,7 +115,7 @@ export declare class BookingTicketImpl extends BaseModule implements Module {
|
|
|
115
115
|
* 获取当前的客户搜索条件
|
|
116
116
|
* @returns 当前搜索条件
|
|
117
117
|
*/
|
|
118
|
-
getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "
|
|
118
|
+
getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "skip" | "num">;
|
|
119
119
|
/**
|
|
120
120
|
* 获取客户列表状态(包含滚动加载相关状态)
|
|
121
121
|
* @returns 客户状态
|
|
@@ -134,6 +134,15 @@ var getTax = ({ service, addons, bookingDetail, bookingId }, options) => {
|
|
|
134
134
|
tax: totalTax.toDecimalPlaces(2, import_decimal.default.ROUND_HALF_UP).toNumber()
|
|
135
135
|
};
|
|
136
136
|
};
|
|
137
|
+
function getDiscountedTaxableBase(input) {
|
|
138
|
+
const { basePrice, discount, surchargeFee } = input;
|
|
139
|
+
if (surchargeFee.lte(0) && basePrice.lte(0))
|
|
140
|
+
return new import_decimal.default(0);
|
|
141
|
+
const discountedBase = basePrice.minus(discount);
|
|
142
|
+
if (discountedBase.lte(0))
|
|
143
|
+
return surchargeFee;
|
|
144
|
+
return discountedBase.plus(surchargeFee);
|
|
145
|
+
}
|
|
137
146
|
var processItemsTax = (items, { bookingDetail, bookingId }, options) => {
|
|
138
147
|
const { tax_rate, is_price_include_tax, computed } = options;
|
|
139
148
|
const { shopDiscount, productExpectAmount } = computed;
|
|
@@ -150,10 +159,15 @@ var processItemsTax = (items, { bookingDetail, bookingId }, options) => {
|
|
|
150
159
|
option: (item == null ? void 0 : item.option) || (item == null ? void 0 : item.options) || [],
|
|
151
160
|
bundle: (item == null ? void 0 : item.bundle) || (item == null ? void 0 : item.bundles) || []
|
|
152
161
|
}) || 0);
|
|
162
|
+
const originalTaxableBase = getDiscountedTaxableBase({
|
|
163
|
+
basePrice: mainProductPrice,
|
|
164
|
+
discount: new import_decimal.default(0),
|
|
165
|
+
surchargeFee: new import_decimal.default((item == null ? void 0 : item.surcharge_fee) || 0)
|
|
166
|
+
});
|
|
153
167
|
let originalTaxPerItemPrecise = getProductItemTax(
|
|
154
168
|
{
|
|
155
169
|
...item,
|
|
156
|
-
total:
|
|
170
|
+
total: originalTaxableBase.toNumber(),
|
|
157
171
|
quantity: 1
|
|
158
172
|
},
|
|
159
173
|
{ bookingDetail, bookingId },
|
|
@@ -167,7 +181,11 @@ var processItemsTax = (items, { bookingDetail, bookingId }, options) => {
|
|
|
167
181
|
if (unitPrice.greaterThan(0)) {
|
|
168
182
|
mainItemDiscount = mainProductPrice.dividedBy(productExpectAmount).times(shopDiscount);
|
|
169
183
|
}
|
|
170
|
-
const mainItemDiscountedUnitPrice =
|
|
184
|
+
const mainItemDiscountedUnitPrice = getDiscountedTaxableBase({
|
|
185
|
+
basePrice: mainProductPrice,
|
|
186
|
+
discount: mainItemDiscount,
|
|
187
|
+
surchargeFee: new import_decimal.default((item == null ? void 0 : item.surcharge_fee) || 0)
|
|
188
|
+
});
|
|
171
189
|
const maxDiscountedTaxPerItemPrecise = getProductItemTax(
|
|
172
190
|
{
|
|
173
191
|
...item,
|
|
@@ -190,16 +208,16 @@ var processItemsTax = (items, { bookingDetail, bookingId }, options) => {
|
|
|
190
208
|
const _originTotal = new import_decimal.default(
|
|
191
209
|
atItem.selling_price || atItem.price || 0
|
|
192
210
|
);
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
)
|
|
198
|
-
}
|
|
211
|
+
const addTimeDiscount = productExpectAmount > 0 ? _originTotal.dividedBy(productExpectAmount).times(shopDiscount) : new import_decimal.default(0);
|
|
212
|
+
const _discountedTotal = getDiscountedTaxableBase({
|
|
213
|
+
basePrice: _originTotal,
|
|
214
|
+
discount: addTimeDiscount,
|
|
215
|
+
surchargeFee: new import_decimal.default((atItem == null ? void 0 : atItem.surcharge_fee) || 0)
|
|
216
|
+
});
|
|
199
217
|
const addTimeTaxPerItemPrecise = getProductItemTax(
|
|
200
218
|
{
|
|
201
219
|
...atItem,
|
|
202
|
-
total: _discountedTotal.
|
|
220
|
+
total: _discountedTotal.toNumber(),
|
|
203
221
|
quantity: atItem.product_quantity || atItem.num || 1
|
|
204
222
|
},
|
|
205
223
|
{ bookingDetail, bookingId },
|
|
@@ -225,10 +243,15 @@ var processItemsTax = (items, { bookingDetail, bookingId }, options) => {
|
|
|
225
243
|
const bundleUnitPrice = new import_decimal.default(
|
|
226
244
|
bundleItem.bundle_selling_price ?? bundleItem.price ?? 0
|
|
227
245
|
);
|
|
246
|
+
const bundleOriginalTaxableBase = getDiscountedTaxableBase({
|
|
247
|
+
basePrice: bundleUnitPrice,
|
|
248
|
+
discount: new import_decimal.default(0),
|
|
249
|
+
surchargeFee: new import_decimal.default((bundleItem == null ? void 0 : bundleItem.surcharge_fee) || 0)
|
|
250
|
+
});
|
|
228
251
|
const bundleOriginalTaxPerItemPrecise = getProductItemTax(
|
|
229
252
|
{
|
|
230
253
|
...bundleItem,
|
|
231
|
-
total:
|
|
254
|
+
total: bundleOriginalTaxableBase.toNumber(),
|
|
232
255
|
quantity: 1
|
|
233
256
|
},
|
|
234
257
|
{ bookingDetail, bookingId },
|
|
@@ -238,7 +261,11 @@ var processItemsTax = (items, { bookingDetail, bookingId }, options) => {
|
|
|
238
261
|
if (productExpectAmount > 0) {
|
|
239
262
|
bundleItemDiscount = bundleUnitPrice.dividedBy(productExpectAmount).times(shopDiscount);
|
|
240
263
|
}
|
|
241
|
-
const bundleDiscountedUnitPrice =
|
|
264
|
+
const bundleDiscountedUnitPrice = getDiscountedTaxableBase({
|
|
265
|
+
basePrice: bundleUnitPrice,
|
|
266
|
+
discount: bundleItemDiscount,
|
|
267
|
+
surchargeFee: new import_decimal.default((bundleItem == null ? void 0 : bundleItem.surcharge_fee) || 0)
|
|
268
|
+
});
|
|
242
269
|
const bundleDiscountedTaxPerItemPrecise = getProductItemTax(
|
|
243
270
|
{
|
|
244
271
|
...bundleItem,
|
|
@@ -115,7 +115,7 @@ export declare class BookingTicketImpl extends BaseModule implements Module {
|
|
|
115
115
|
* 获取当前的客户搜索条件
|
|
116
116
|
* @returns 当前搜索条件
|
|
117
117
|
*/
|
|
118
|
-
getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "
|
|
118
|
+
getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "skip" | "num">;
|
|
119
119
|
/**
|
|
120
120
|
* 获取客户列表状态(包含滚动加载相关状态)
|
|
121
121
|
* @returns 客户状态
|