rerobe-js-orm 4.3.8 → 4.3.9
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.
|
@@ -45,20 +45,28 @@ class RefundFormState extends FormState_1.default {
|
|
|
45
45
|
}
|
|
46
46
|
updateDiscountsAndSubtotals() {
|
|
47
47
|
const calculated = this.fields.refundLineItems.selectedValues.reduce((total, item) => {
|
|
48
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
48
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
49
49
|
const lineItemPriceAmount = Number(item.lineItem.isOnSale === 'yes' ? item.lineItem.salePrice || 0 : (_a = item.lineItem.originalUnitPrice) === null || _a === void 0 ? void 0 : _a.amount);
|
|
50
50
|
const lineItemPricePresentmentAmount = Number(item.lineItem.isOnSale === 'yes'
|
|
51
51
|
? ((_b = item.lineItem.presentmentSalePrice) === null || _b === void 0 ? void 0 : _b.amount) || 0
|
|
52
52
|
: ((_c = item.lineItem.presentmentUnitPrice) === null || _c === void 0 ? void 0 : _c.amount) || 0);
|
|
53
|
+
// Calculate tax-adjusted prices if item is taxable
|
|
54
|
+
const taxAdjustedPriceAmount = item.lineItem.isTaxable && item.lineItem.taxRate
|
|
55
|
+
? Number((lineItemPriceAmount * (1 + Number(item.lineItem.taxRate))).toFixed(2))
|
|
56
|
+
: lineItemPriceAmount;
|
|
57
|
+
const taxAdjustedPresentmentPriceAmount = item.lineItem.isTaxable && ((_d = item.lineItem.presentmentTaxPrice) === null || _d === void 0 ? void 0 : _d.amount)
|
|
58
|
+
? Number((lineItemPricePresentmentAmount +
|
|
59
|
+
Number(item.lineItem.presentmentTaxPrice.amount) / Number(item.lineItem.quantity)).toFixed(2))
|
|
60
|
+
: lineItemPricePresentmentAmount;
|
|
53
61
|
return {
|
|
54
|
-
refundDiscount: total.refundDiscount + Number((
|
|
55
|
-
refundCreditDiscount: total.refundCreditDiscount + Number((
|
|
56
|
-
subtotalRefunded: total.subtotalRefunded + Number(
|
|
62
|
+
refundDiscount: total.refundDiscount + Number((_e = item.discountRefund) === null || _e === void 0 ? void 0 : _e.amount),
|
|
63
|
+
refundCreditDiscount: total.refundCreditDiscount + Number((_f = item.creditDiscountRefund) === null || _f === void 0 ? void 0 : _f.amount),
|
|
64
|
+
subtotalRefunded: total.subtotalRefunded + Number(taxAdjustedPriceAmount * (item.quantityRefund + item.quantityCancel)),
|
|
57
65
|
// Presentment:
|
|
58
|
-
refundDiscountPresentment: total.refundDiscountPresentment + Number((
|
|
59
|
-
refundCreditDiscountPresentment: total.refundCreditDiscountPresentment + Number((
|
|
66
|
+
refundDiscountPresentment: total.refundDiscountPresentment + Number((_g = item.discountRefundPresentment) === null || _g === void 0 ? void 0 : _g.amount),
|
|
67
|
+
refundCreditDiscountPresentment: total.refundCreditDiscountPresentment + Number((_h = item.creditDiscountRefundPresentment) === null || _h === void 0 ? void 0 : _h.amount),
|
|
60
68
|
subtotalRefundedPresentment: total.subtotalRefundedPresentment +
|
|
61
|
-
Number(
|
|
69
|
+
Number(taxAdjustedPresentmentPriceAmount * (item.quantityRefund + item.quantityCancel)),
|
|
62
70
|
};
|
|
63
71
|
}, {
|
|
64
72
|
refundDiscount: 0,
|