Merge branch 'develop' into feature/CSR-1392

This commit is contained in:
CarlNation 2023-10-30 15:56:54 -04:00
commit fc0a21aa95
4 changed files with 98 additions and 68 deletions

View file

@ -1,11 +1,12 @@
const cartItemTypes = { const cartItemTypes = {
FRONT_WIPER: "FRONT WIPER", FRONT_WIPERS: "FRONT WIPERS",
REAR_WIPER: "REAR WIPER", REAR_WIPERS: "REAR WIPERS",
SUPPORTING_ITEMS: "SUPPORTING ITEMS", SUPPORTING_ITEMS: "SUPPORTING ITEMS",
GLASS_PARTS: "GLASS PARTS", GLASS_PARTS: "GLASS PARTS",
RAIN_DEFENSE: "RAIN DEFENSE", RAIN_DEFENSE: "RAIN DEFENSE",
RECYCLE_FEE: "RECYCLE FEE", RECYCLE_FEE: "RECYCLE FEE",
MOBILE_FEE: "MOBILE FEE", MOBILE_FEE: "MOBILE FEE",
PROMOS: "PROMOS",
}; };
export { cartItemTypes }; export { cartItemTypes };

View file

@ -131,7 +131,7 @@ export default {
this.cartItems.forEach((cartItem) => { this.cartItems.forEach((cartItem) => {
packageContentTypes.forEach((vapType) => { packageContentTypes.forEach((vapType) => {
if (vapType == cartItem.cartItemType) { if (cartItem.cartItemType.includes(vapType)) {
vapsCartItemsForSelectedPackage.push(cartItem); vapsCartItemsForSelectedPackage.push(cartItem);
} }
}); });
@ -179,8 +179,8 @@ export default {
cartItems.push(this.glassPartsCartItem); cartItems.push(this.glassPartsCartItem);
} }
if (this.supportingItemsCartItem) { if (this.otherSupportingItemsCartItem) {
cartItems.push(this.supportingItemsCartItem); cartItems.push(this.otherSupportingItemsCartItem);
} }
if (this.recycleFeeCartItem) { if (this.recycleFeeCartItem) {
@ -191,6 +191,25 @@ export default {
cartItems.push(this.mobileFeeCartItem); cartItems.push(this.mobileFeeCartItem);
} }
// Create a cart item for each promo
this.promos.forEach((promoLineItem) => {
let cartItem = null;
cartItem = {
name: "Some Kind of Promo", // get from CMS?
category: cartItemCategories.PROMOS,
cartItemType: promoLineItem.partType,
isDisplayed: true,
subTotal:
(promoLineItem.kitPrice ?? 0) +
(promoLineItem.laborAmount ?? 0) +
(promoLineItem.sellingPrice ?? 0),
salesTax: promoLineItem.salesTax,
};
cartItems.push(cartItem);
});
return cartItems; return cartItems;
}, },
}, },
@ -253,6 +272,10 @@ export default {
const supportingItems = this.lineItems?.supportingItems; const supportingItems = this.lineItems?.supportingItems;
return supportingItems?.length > 0 ? supportingItems : []; return supportingItems?.length > 0 ? supportingItems : [];
}, },
promos() {
const promos = this.lineItems?.promos;
return promos?.length > 0 ? promos : [];
},
// Cart Items // Cart Items
packageCartItems() { packageCartItems() {
return this.getVapsCartItemsForSelectedPackage(this.packageLevel); return this.getVapsCartItemsForSelectedPackage(this.packageLevel);
@ -288,7 +311,7 @@ export default {
cartItem = { cartItem = {
name: this.frontWiperCartItemName, name: this.frontWiperCartItemName,
category: cartItemCategories.VAPS, category: cartItemCategories.VAPS,
cartItemType: cartItemTypes.FRONT_WIPER, cartItemType: cartItemTypes.FRONT_WIPERS,
isDisplayed: true, isDisplayed: true,
subTotal: 0, subTotal: 0,
salesTax: 0, salesTax: 0,
@ -324,7 +347,7 @@ export default {
cartItem = { cartItem = {
name: this.rearWiperCartItemName, name: this.rearWiperCartItemName,
category: cartItemCategories.VAPS, category: cartItemCategories.VAPS,
cartItemType: cartItemTypes.REAR_WIPER, cartItemType: cartItemTypes.REAR_WIPERS,
isDisplayed: true, isDisplayed: true,
subTotal: 0, subTotal: 0,
salesTax: 0, salesTax: 0,
@ -383,61 +406,31 @@ export default {
glassPartsCartItem() { glassPartsCartItem() {
let cartItem = null; let cartItem = null;
const flattenedGlassPartsLineItems = if (this.lineItems?.glassParts?.length > 0) {
this.lineItemUtilities.getFlattenedArrayOfLineItemsWithChildParts( this.lineItems?.glassParts?.forEach((lineItem) => {
this.lineItems.glassParts cartItem = {
); 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 (flattenedGlassPartsLineItems.length > 0) { if (lineItem.childParts?.length > 0) {
cartItem = { lineItem.childParts.forEach((childPartLineItem) => {
name: null, cartItem.subTotal +=
category: cartItemCategories.GLASS_PARTS, (childPartLineItem.kitPrice ?? 0) +
cartItemType: cartItemTypes.GLASS_PARTS, (childPartLineItem.laborAmount ?? 0) +
isDisplayed: false, (childPartLineItem.sellingPrice ?? 0);
subTotal: 0,
salesTax: 0,
lineItems: [],
};
flattenedGlassPartsLineItems.forEach((lineItem) => { cartItem.salesTax += childPartLineItem.salesTax;
lineItem.cartItemType = cartItem.cartItemType; });
cartItem.lineItems.push(lineItem); }
cartItem.subTotal +=
(lineItem.kitPrice ?? 0) +
(lineItem.laborAmount ?? 0) +
(lineItem.sellingPrice ?? 0);
cartItem.salesTax += lineItem.salesTax ?? 0;
});
}
return cartItem;
},
supportingItemsCartItem() {
let cartItem = null;
if (this.supportingItems.length > 0) {
cartItem = {
name: null,
category: cartItemCategories.SUPPORTING_ITEMS,
cartItemType: cartItemTypes.SUPPORTING_ITEMS,
isDisplayed: false,
subTotal: 0,
salesTax: 0,
lineItems: [],
};
this.supportingItems.forEach((lineItem) => {
lineItem.cartItemType = cartItem.cartItemType;
cartItem.lineItems.push(lineItem);
cartItem.subTotal +=
(lineItem.kitPrice ?? 0) +
(lineItem.laborAmount ?? 0) +
(lineItem.sellingPrice ?? 0);
cartItem.salesTax += lineItem.salesTax ?? 0;
}); });
} }
@ -464,15 +457,15 @@ export default {
lineItems: [], lineItems: [],
}; };
recycleFeeLineItem.cartItemType = cartItem.cartItemType; //recycleFeeLineItem.cartItemType = cartItem.cartItemType;
cartItem.lineItems.push(recycleFeeLineItem); //cartItem.lineItems.push(recycleFeeLineItem);
cartItem.subTotal += cartItem.subTotal +=
(recycleFeeLineItem.kitPrice ?? 0) + (recycleFeeLineItem.kitPrice ?? 0) +
(recycleFeeLineItem.laborAmount ?? 0) + (recycleFeeLineItem.laborAmount ?? 0) +
(recycleFeeLineItem.sellingPrice ?? 0); (recycleFeeLineItem.sellingPrice ?? 0);
cartItem.salesTax += recycleFeeLineItem.salesTax ?? 0; cartItem.salesTax = recycleFeeLineItem.salesTax ?? 0;
} }
return cartItem; return cartItem;
@ -511,6 +504,41 @@ export default {
return cartItem; return cartItem;
}, },
otherSupportingItemsCartItem() {
let cartItem = null;
const otherSupportingItemsLineItems = this.supportingItems.filter(
(lineItem) =>
lineItem.partNumber != partTypeStrings.MOBILE_FEE &&
lineItem.partNumber != partTypeStrings.RECYCLE_FEE
);
if (otherSupportingItemsLineItems.length > 0) {
cartItem = {
name: null,
category: cartItemCategories.SUPPORTING_ITEMS,
cartItemType: cartItemTypes.SUPPORTING_ITEMS,
isDisplayed: false,
subTotal: 0,
salesTax: 0,
lineItems: [],
};
otherSupportingItemsLineItems.forEach((lineItem) => {
lineItem.cartItemType = cartItem.cartItemType;
cartItem.lineItems.push(lineItem);
cartItem.subTotal +=
(lineItem.kitPrice ?? 0) +
(lineItem.laborAmount ?? 0) +
(lineItem.sellingPrice ?? 0);
cartItem.salesTax += lineItem.salesTax ?? 0;
});
}
return cartItem;
},
removeLinkText() { removeLinkText() {
return this.getCmsContent("RemoveCartItemTextWidget", "Text"); return this.getCmsContent("RemoveCartItemTextWidget", "Text");
}, },

View file

@ -90,7 +90,7 @@ import { defineRule } from "vee-validate";
import { required } from "@/helpers/validation-rules"; import { required } from "@/helpers/validation-rules";
import { errorMessages } from "@/constants/error-messages"; import { errorMessages } from "@/constants/error-messages";
import { AppointmentTypeStrings } from "@/constants/schedule-constants"; import { AppointmentTypeStrings } from "@/constants/schedule-constants";
import { LineItemUtilities, mapTaxedAvailableLineItemsToStoreFormat } from "../../store"; import { mapTaxedAvailableLineItemsToStoreFormat } from "../../store";
defineRule("option-required", required(errorMessages.OPTION_REQUIRED)); defineRule("option-required", required(errorMessages.OPTION_REQUIRED));
@ -174,9 +174,6 @@ export default {
false false
); );
const lineItemUtilities = new LineItemUtilities();
lineItemUtilities.addGuidToLineItemsIfNotAlreadyThere(availableLineItems);
const lineItems = mapTaxedAvailableLineItemsToStoreFormat( const lineItems = mapTaxedAvailableLineItemsToStoreFormat(
availableLineItems, availableLineItems,
lineItemsFromStore lineItemsFromStore

View file

@ -1291,6 +1291,7 @@ export const actions = {
}); });
syncLineItemIds(response.data, context.getters.order.lineItems.vaps); syncLineItemIds(response.data, context.getters.order.lineItems.vaps);
return response; return response;
}, },
@ -2172,7 +2173,10 @@ export const actions = {
pageNameToLog, pageNameToLog,
} }
) { ) {
const lineItemsWithOnlyPriceInfo = pricedAvailableLineItems.map((lineItem) => ({ const flattenedLineItemsWithChildParts =
getFlattenedArrayOfLineItemsWithChildParts(pricedAvailableLineItems);
const lineItemsWithOnlyPriceInfo = flattenedLineItemsWithChildParts.map((lineItem) => ({
partNumber: lineItem.partNumber, partNumber: lineItem.partNumber,
laborAmount: lineItem.laborAmount ?? 0, laborAmount: lineItem.laborAmount ?? 0,
kitPrice: lineItem.kitPrice ?? 0, kitPrice: lineItem.kitPrice ?? 0,