Merge pull request #1866 from Safelite/feature/CSR-1742-ajc-r2
CSR-1742-r2: have cart use base-mixin shared logic
This commit is contained in:
commit
f634b58edc
2 changed files with 25 additions and 41 deletions
|
|
@ -915,48 +915,16 @@ export default {
|
|||
return this.getCmsContent("SubtotalTextWidget", "Text");
|
||||
},
|
||||
subTotal() {
|
||||
let subTotal = 0;
|
||||
|
||||
if (this.showCoverageAsVerified || this.showCoverageAsPending) {
|
||||
// only include items NOT covered by insurance
|
||||
this.cartItems.forEach((cartItem) => {
|
||||
if (!cartItem.isCoveredByInsurance) {
|
||||
subTotal += cartItem.subTotal ?? 0;
|
||||
}
|
||||
});
|
||||
// add deductible amount still to pay
|
||||
subTotal += this.deductibleLineItem.subTotal ?? 0;
|
||||
} else {
|
||||
this.cartItems.forEach((cartItem) => {
|
||||
subTotal += cartItem.subTotal ?? 0;
|
||||
});
|
||||
}
|
||||
|
||||
return subTotal;
|
||||
return baseMixin.methods.getSubTotal(this.lineItems);
|
||||
},
|
||||
salesTax() {
|
||||
let salesTax = 0;
|
||||
|
||||
if (this.showCoverageAsVerified || this.showCoverageAsPending) {
|
||||
// only include items NOT covered by insurance
|
||||
this.cartItems.forEach((cartItem) => {
|
||||
if (!cartItem.isCoveredByInsurance) {
|
||||
salesTax += cartItem.salesTax ?? 0;
|
||||
}
|
||||
});
|
||||
} else {
|
||||
this.cartItems.forEach((cartItem) => {
|
||||
salesTax += cartItem.salesTax ?? 0;
|
||||
});
|
||||
}
|
||||
|
||||
return salesTax;
|
||||
return baseMixin.methods.getSalesTax(this.lineItems);
|
||||
},
|
||||
amountDue() {
|
||||
if (this.showAsPaid) {
|
||||
return 0;
|
||||
}
|
||||
return this.subTotal + this.salesTax;
|
||||
return baseMixin.methods.getAmountDue(this.lineItems);
|
||||
},
|
||||
amountPaid() {
|
||||
if (!this.showAsPaid) {
|
||||
|
|
|
|||
|
|
@ -132,27 +132,32 @@ export default {
|
|||
currency: "USD",
|
||||
});
|
||||
},
|
||||
getAmountDue(lineItems) {
|
||||
getAmountDue(lineItems, includeTax = true) {
|
||||
var amountDue = 0;
|
||||
if (lineItems.glassParts) {
|
||||
amountDue += this.getTotalPriceOfAllLineItemsAndChildParts(
|
||||
lineItems.glassParts,
|
||||
true
|
||||
includeTax
|
||||
);
|
||||
}
|
||||
if (lineItems.supportingItems) {
|
||||
amountDue += this.getTotalPriceOfAllLineItemsAndChildParts(
|
||||
lineItems.supportingItems,
|
||||
true
|
||||
includeTax
|
||||
);
|
||||
}
|
||||
if (lineItems.vaps) {
|
||||
amountDue += this.getTotalPriceOfAllLineItemsAndChildParts(lineItems.vaps, true);
|
||||
amountDue += this.getTotalPriceOfAllLineItemsAndChildParts(
|
||||
lineItems.vaps,
|
||||
includeTax
|
||||
);
|
||||
}
|
||||
if (lineItems.promos) {
|
||||
amountDue += this.getTotalPriceOfAllLineItemsAndChildParts(lineItems.promos, true);
|
||||
amountDue += this.getTotalPriceOfAllLineItemsAndChildParts(
|
||||
lineItems.promos,
|
||||
includeTax
|
||||
);
|
||||
}
|
||||
|
||||
if (
|
||||
store.getters.payment.insuranceCoverage.isVerified &&
|
||||
!store.getters.policy.isNoComp &&
|
||||
|
|
@ -163,6 +168,17 @@ export default {
|
|||
|
||||
return ((amountDue * 100) / 100).toFixed(2);
|
||||
},
|
||||
getSubTotal(lineItems) {
|
||||
// this is amountDue without sales tax
|
||||
return this.getAmountDue(lineItems, false);
|
||||
},
|
||||
getSalesTax(lineItems) {
|
||||
// this is amountDue minus subTotal
|
||||
return (
|
||||
((this.getAmountDue(lineItems) - this.getSubTotal(lineItems)) * 100) /
|
||||
100
|
||||
).toFixed(2);
|
||||
},
|
||||
scrollToPageTop() {
|
||||
const container = document.getElementsByClassName("page-container-grouped-styles")[0];
|
||||
container.scrollTo({ top: 0, left: 0, behavior: "smooth" });
|
||||
|
|
|
|||
Loading…
Reference in a new issue