From 2a81d3fbe10f195e8b438bf67904845862775cc4 Mon Sep 17 00:00:00 2001 From: CarlNation <32103961+CarlNation@users.noreply.github.com> Date: Wed, 1 Nov 2023 12:37:30 -0400 Subject: [PATCH] CSR-1932 only add sales tax from amountDue --- src/mixins/base-mixin.js | 34 +++++++++++++++++++++++----------- 1 file changed, 23 insertions(+), 11 deletions(-) diff --git a/src/mixins/base-mixin.js b/src/mixins/base-mixin.js index 02f1ed960..33682416e 100644 --- a/src/mixins/base-mixin.js +++ b/src/mixins/base-mixin.js @@ -89,7 +89,7 @@ export default { ); }); - let totalPrice = this.getTotalPriceOfAllLineItemsAndChildParts(lineItemsToPrice); + let totalPrice = this.getTotalPriceOfAllLineItemsAndChildParts(lineItemsToPrice, false); return totalPrice; }, filterOutFees(lineItems) { @@ -101,22 +101,30 @@ export default { }); return filteredLineItems; }, - getTotalPriceOfAllLineItemsAndChildParts(lineItems) { + getTotalPriceOfAllLineItemsAndChildParts(lineItems, includeTax) { let totalPrice = 0; lineItems.forEach((lineItem) => { - totalPrice += this.getTotalLineItemPrice(lineItem); + totalPrice += this.getTotalLineItemPrice(lineItem, includeTax); if (lineItem.childParts) { totalPrice += this.getTotalPriceOfAllLineItemsAndChildParts( - lineItem.childParts + lineItem.childParts, + includeTax ); } }); return totalPrice; }, - getTotalLineItemPrice(lineItem) { - return ( - lineItem.kitPrice + lineItem.laborAmount + lineItem.sellingPrice + lineItem.salesTax - ); + getTotalLineItemPrice(lineItem, includeTax) { + if (includeTax) { + return ( + lineItem.kitPrice + + lineItem.laborAmount + + lineItem.sellingPrice + + lineItem.salesTax + ); + } else { + return lineItem.kitPrice + lineItem.laborAmount + lineItem.sellingPrice; + } }, getDisplayAmountDue(lineItems) { return this.getAmountDue(lineItems).toLocaleString("en-US", { @@ -127,15 +135,19 @@ export default { getAmountDue(lineItems) { var amountDue = 0; if (lineItems.glassParts) { - amountDue = this.getTotalPriceOfAllLineItemsAndChildParts(lineItems.glassParts); + amountDue = this.getTotalPriceOfAllLineItemsAndChildParts( + lineItems.glassParts, + true + ); } if (lineItems.supportingItems) { amountDue += this.getTotalPriceOfAllLineItemsAndChildParts( - lineItems.supportingItems + lineItems.supportingItems, + true ); } if (lineItems.vaps) { - amountDue += this.getTotalPriceOfAllLineItemsAndChildParts(lineItems.vaps); + amountDue += this.getTotalPriceOfAllLineItemsAndChildParts(lineItems.vaps, true); } return amountDue; },