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);
|
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;
|
if (this.glassPartCartItems) {
|
||||||
});
|
this.glassPartCartItems.forEach((glassPartCartItem) => {
|
||||||
}
|
cartItems.push(glassPartCartItem);
|
||||||
|
})
|
||||||
cartItems.push(glassPartsCartItem);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// if (this.glassPartsCartItem) {
|
|
||||||
// cartItems.push(this.glassPartsCartItem);
|
|
||||||
// }
|
|
||||||
|
|
||||||
if (this.otherSupportingItemsCartItem) {
|
if (this.otherSupportingItemsCartItem) {
|
||||||
cartItems.push(this.otherSupportingItemsCartItem);
|
cartItems.push(this.otherSupportingItemsCartItem);
|
||||||
}
|
}
|
||||||
|
|
@ -282,12 +254,6 @@ export default {
|
||||||
baseMixin.methods.filterOutFees(this.availableLineItems)
|
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);
|
packagePrice += this.getVapsPrice(this.packageLevel);
|
||||||
|
|
||||||
return packagePrice;
|
return packagePrice;
|
||||||
|
|
@ -306,6 +272,10 @@ export default {
|
||||||
|
|
||||||
return this.damage.glassToReplace;
|
return this.damage.glassToReplace;
|
||||||
},
|
},
|
||||||
|
glassParts() {
|
||||||
|
const glassParts = this.lineItems?.glassParts;
|
||||||
|
return glassParts?.length > 0 ? glassParts : [];
|
||||||
|
},
|
||||||
vaps() {
|
vaps() {
|
||||||
const vaps = this.lineItems?.vaps;
|
const vaps = this.lineItems?.vaps;
|
||||||
return vaps?.length > 0 ? vaps : [];
|
return vaps?.length > 0 ? vaps : [];
|
||||||
|
|
@ -445,12 +415,12 @@ export default {
|
||||||
|
|
||||||
return cartItem;
|
return cartItem;
|
||||||
},
|
},
|
||||||
glassPartsCartItem() {
|
glassPartCartItems() {
|
||||||
let cartItem = null;
|
const glassPartCartItems = []
|
||||||
|
|
||||||
if (this.lineItems?.glassParts?.length > 0) {
|
if (this.glassParts.length > 0) {
|
||||||
this.lineItems?.glassParts?.forEach((lineItem) => {
|
this.glassParts.forEach((lineItem) => {
|
||||||
cartItem = {
|
let glassPartCartItem = {
|
||||||
name: null,
|
name: null,
|
||||||
category: cartItemCategories.GLASS_PARTS,
|
category: cartItemCategories.GLASS_PARTS,
|
||||||
cartItemType: cartItemTypes.GLASS_PARTS,
|
cartItemType: cartItemTypes.GLASS_PARTS,
|
||||||
|
|
@ -459,24 +429,28 @@ export default {
|
||||||
(lineItem.kitPrice ?? 0) +
|
(lineItem.kitPrice ?? 0) +
|
||||||
(lineItem.laborAmount ?? 0) +
|
(lineItem.laborAmount ?? 0) +
|
||||||
(lineItem.sellingPrice ?? 0),
|
(lineItem.sellingPrice ?? 0),
|
||||||
|
|
||||||
salesTax: lineItem.salesTax ?? 0,
|
salesTax: lineItem.salesTax ?? 0,
|
||||||
lineItems: [],
|
lineItems: [],
|
||||||
};
|
};
|
||||||
|
|
||||||
if (lineItem.childParts?.length > 0) {
|
if (lineItem.childParts?.length > 0) {
|
||||||
lineItem.childParts.forEach((childPartLineItem) => {
|
lineItem.childParts.forEach((childPartLineItem) => {
|
||||||
cartItem.subTotal +=
|
glassPartCartItem.subTotal +=
|
||||||
(childPartLineItem.kitPrice ?? 0) +
|
(childPartLineItem.kitPrice ?? 0) +
|
||||||
(childPartLineItem.laborAmount ?? 0) +
|
(childPartLineItem.laborAmount ?? 0) +
|
||||||
(childPartLineItem.sellingPrice ?? 0);
|
(childPartLineItem.sellingPrice ?? 0);
|
||||||
|
|
||||||
cartItem.salesTax += childPartLineItem.salesTax;
|
glassPartCartItem.salesTax += childPartLineItem.salesTax;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
glassPartCartItems.push(glassPartCartItem);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
return cartItem;
|
return glassPartCartItems;
|
||||||
|
|
||||||
},
|
},
|
||||||
recycleFeeCartItemName() {
|
recycleFeeCartItemName() {
|
||||||
return this.getCmsContent("RecycleFeeTextWidget", "Text");
|
return this.getCmsContent("RecycleFeeTextWidget", "Text");
|
||||||
|
|
|
||||||
|
|
@ -102,7 +102,6 @@ export default {
|
||||||
return filteredLineItems;
|
return filteredLineItems;
|
||||||
},
|
},
|
||||||
getTotalPriceOfAllLineItemsAndChildParts(lineItems) {
|
getTotalPriceOfAllLineItemsAndChildParts(lineItems) {
|
||||||
console.log(lineItems)
|
|
||||||
let totalPrice = 0;
|
let totalPrice = 0;
|
||||||
lineItems.forEach((lineItem) => {
|
lineItems.forEach((lineItem) => {
|
||||||
totalPrice += this.getTotalLineItemPrice(lineItem);
|
totalPrice += this.getTotalLineItemPrice(lineItem);
|
||||||
|
|
@ -115,9 +114,7 @@ export default {
|
||||||
return totalPrice;
|
return totalPrice;
|
||||||
},
|
},
|
||||||
getTotalLineItemPrice(lineItem) {
|
getTotalLineItemPrice(lineItem) {
|
||||||
return (
|
return lineItem.kitPrice + lineItem.laborAmount + lineItem.sellingPrice;
|
||||||
lineItem.kitPrice + lineItem.laborAmount + lineItem.sellingPrice
|
|
||||||
);
|
|
||||||
},
|
},
|
||||||
getDisplayAmountDue(lineItems) {
|
getDisplayAmountDue(lineItems) {
|
||||||
return this.getAmountDue(lineItems).toLocaleString("en-US", {
|
return this.getAmountDue(lineItems).toLocaleString("en-US", {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue