Refactor for clarity and consistency
This commit is contained in:
parent
5b9c47111b
commit
1e998ee748
2 changed files with 21 additions and 50 deletions
|
|
@ -179,42 +179,14 @@ export default {
|
|||
cartItems.push(this.rainDefenseCartItem);
|
||||
}
|
||||
|
||||
let glassPartsCartItem;
|
||||
if (this.lineItems?.glassParts?.length > 0) {
|
||||
this.lineItems?.glassParts?.forEach((lineItem) => {
|
||||
glassPartsCartItem = {
|
||||
name: null,
|
||||
category: cartItemCategories.GLASS_PARTS,
|
||||
cartItemType: cartItemTypes.GLASS_PARTS,
|
||||
isDisplayed: false,
|
||||
subTotal:
|
||||
(lineItem.kitPrice ?? 0) +
|
||||
(lineItem.laborAmount ?? 0) +
|
||||
(lineItem.sellingPrice ?? 0),
|
||||
|
||||
salesTax: lineItem.salesTax ?? 0,
|
||||
lineItems: [],
|
||||
};
|
||||
|
||||
if (lineItem.childParts?.length > 0) {
|
||||
lineItem.childParts.forEach((childPartLineItem) => {
|
||||
glassPartsCartItem.subTotal +=
|
||||
(childPartLineItem.kitPrice ?? 0) +
|
||||
(childPartLineItem.laborAmount ?? 0) +
|
||||
(childPartLineItem.sellingPrice ?? 0);
|
||||
|
||||
glassPartsCartItem.salesTax += childPartLineItem.salesTax;
|
||||
});
|
||||
}
|
||||
|
||||
cartItems.push(glassPartsCartItem);
|
||||
});
|
||||
if (this.glassPartCartItems) {
|
||||
this.glassPartCartItems.forEach((glassPartCartItem) => {
|
||||
cartItems.push(glassPartCartItem);
|
||||
})
|
||||
}
|
||||
|
||||
// if (this.glassPartsCartItem) {
|
||||
// cartItems.push(this.glassPartsCartItem);
|
||||
// }
|
||||
|
||||
if (this.otherSupportingItemsCartItem) {
|
||||
cartItems.push(this.otherSupportingItemsCartItem);
|
||||
}
|
||||
|
|
@ -282,12 +254,6 @@ export default {
|
|||
baseMixin.methods.filterOutFees(this.availableLineItems)
|
||||
);
|
||||
|
||||
console.log(this.availableLineItems)
|
||||
const feesFilteredOut = baseMixin.methods.filterOutFees(this.availableLineItems);
|
||||
const tierOnePackagePrice = baseMixin.methods.getTierOnePackagePrice(feesFilteredOut);
|
||||
console.log(feesFilteredOut)
|
||||
console.log(tierOnePackagePrice)
|
||||
|
||||
packagePrice += this.getVapsPrice(this.packageLevel);
|
||||
|
||||
return packagePrice;
|
||||
|
|
@ -306,6 +272,10 @@ export default {
|
|||
|
||||
return this.damage.glassToReplace;
|
||||
},
|
||||
glassParts() {
|
||||
const glassParts = this.lineItems?.glassParts;
|
||||
return glassParts?.length > 0 ? glassParts : [];
|
||||
},
|
||||
vaps() {
|
||||
const vaps = this.lineItems?.vaps;
|
||||
return vaps?.length > 0 ? vaps : [];
|
||||
|
|
@ -445,12 +415,12 @@ export default {
|
|||
|
||||
return cartItem;
|
||||
},
|
||||
glassPartsCartItem() {
|
||||
let cartItem = null;
|
||||
glassPartCartItems() {
|
||||
const glassPartCartItems = []
|
||||
|
||||
if (this.lineItems?.glassParts?.length > 0) {
|
||||
this.lineItems?.glassParts?.forEach((lineItem) => {
|
||||
cartItem = {
|
||||
if (this.glassParts.length > 0) {
|
||||
this.glassParts.forEach((lineItem) => {
|
||||
let glassPartCartItem = {
|
||||
name: null,
|
||||
category: cartItemCategories.GLASS_PARTS,
|
||||
cartItemType: cartItemTypes.GLASS_PARTS,
|
||||
|
|
@ -459,24 +429,28 @@ export default {
|
|||
(lineItem.kitPrice ?? 0) +
|
||||
(lineItem.laborAmount ?? 0) +
|
||||
(lineItem.sellingPrice ?? 0),
|
||||
|
||||
salesTax: lineItem.salesTax ?? 0,
|
||||
lineItems: [],
|
||||
};
|
||||
|
||||
if (lineItem.childParts?.length > 0) {
|
||||
lineItem.childParts.forEach((childPartLineItem) => {
|
||||
cartItem.subTotal +=
|
||||
glassPartCartItem.subTotal +=
|
||||
(childPartLineItem.kitPrice ?? 0) +
|
||||
(childPartLineItem.laborAmount ?? 0) +
|
||||
(childPartLineItem.sellingPrice ?? 0);
|
||||
|
||||
cartItem.salesTax += childPartLineItem.salesTax;
|
||||
glassPartCartItem.salesTax += childPartLineItem.salesTax;
|
||||
});
|
||||
}
|
||||
|
||||
glassPartCartItems.push(glassPartCartItem);
|
||||
});
|
||||
}
|
||||
|
||||
return cartItem;
|
||||
return glassPartCartItems;
|
||||
|
||||
},
|
||||
recycleFeeCartItemName() {
|
||||
return this.getCmsContent("RecycleFeeTextWidget", "Text");
|
||||
|
|
|
|||
|
|
@ -102,7 +102,6 @@ export default {
|
|||
return filteredLineItems;
|
||||
},
|
||||
getTotalPriceOfAllLineItemsAndChildParts(lineItems) {
|
||||
console.log(lineItems)
|
||||
let totalPrice = 0;
|
||||
lineItems.forEach((lineItem) => {
|
||||
totalPrice += this.getTotalLineItemPrice(lineItem);
|
||||
|
|
@ -115,9 +114,7 @@ export default {
|
|||
return totalPrice;
|
||||
},
|
||||
getTotalLineItemPrice(lineItem) {
|
||||
return (
|
||||
lineItem.kitPrice + lineItem.laborAmount + lineItem.sellingPrice
|
||||
);
|
||||
return lineItem.kitPrice + lineItem.laborAmount + lineItem.sellingPrice;
|
||||
},
|
||||
getDisplayAmountDue(lineItems) {
|
||||
return this.getAmountDue(lineItems).toLocaleString("en-US", {
|
||||
|
|
|
|||
Loading…
Reference in a new issue