only add sales tax from amountDue
This commit is contained in:
CarlNation 2023-11-01 12:37:30 -04:00
parent 18ce344af3
commit 2a81d3fbe1

View file

@ -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;
},