@pisell/pisellos 2.2.57 → 2.2.58
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.
|
@@ -3128,13 +3128,14 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3128
3128
|
return payment.status !== 'voided';
|
|
3129
3129
|
}) // 只计算未撤销的支付项
|
|
3130
3130
|
.reduce(function (sum, payment) {
|
|
3131
|
-
|
|
3132
|
-
|
|
3133
|
-
|
|
3134
|
-
//
|
|
3135
|
-
//
|
|
3136
|
-
|
|
3137
|
-
var
|
|
3131
|
+
// const amount = new Decimal(payment.amount || '0');
|
|
3132
|
+
// 计算有效支付金额:支付金额 + 抹零金额的绝对值
|
|
3133
|
+
// 当 rounding_amount 为负数时,表示抹掉的金额,按绝对值计算有效支付
|
|
3134
|
+
// 例如:amount=15, rounding_amount=-0.2,有效支付=15.2(抹掉0.2元零头)
|
|
3135
|
+
// 例2:amount=15,rounding_amount=0.2,有效支付 14.8
|
|
3136
|
+
var paymentAmount = new Decimal(payment.amount || 0);
|
|
3137
|
+
var roundingAmount = new Decimal(payment.rounding_amount || 0);
|
|
3138
|
+
var effectiveAmount = paymentAmount.minus(roundingAmount);
|
|
3138
3139
|
return sum.add(effectiveAmount);
|
|
3139
3140
|
}, new Decimal(0));
|
|
3140
3141
|
return paidAmount.toFixed(2);
|
|
@@ -2029,9 +2029,9 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
2029
2029
|
*/
|
|
2030
2030
|
calculatePaidAmountFromItems(payments) {
|
|
2031
2031
|
const paidAmount = payments.filter((payment) => payment.status !== "voided").reduce((sum, payment) => {
|
|
2032
|
-
const
|
|
2033
|
-
const roundingAmount = new import_decimal.default(payment.rounding_amount ||
|
|
2034
|
-
const effectiveAmount =
|
|
2032
|
+
const paymentAmount = new import_decimal.default(payment.amount || 0);
|
|
2033
|
+
const roundingAmount = new import_decimal.default(payment.rounding_amount || 0);
|
|
2034
|
+
const effectiveAmount = paymentAmount.minus(roundingAmount);
|
|
2035
2035
|
return sum.add(effectiveAmount);
|
|
2036
2036
|
}, new import_decimal.default(0));
|
|
2037
2037
|
return paidAmount.toFixed(2);
|