Merge pull request #1523 from Safelite/feature/CSR-1388

Feature/csr 1388
This commit is contained in:
Leah Schumann 2023-11-14 09:00:28 -05:00 committed by GitHub
commit 0be1ed3a94
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -52,7 +52,15 @@
:text="recycleFeeCartItem.name"
href="#!"
@click-event="openModal(recyclingModalCmsWidgetName)" />
<span>{{ currencyFormatter.format(cartItem.subTotal) }}</span>
<span
>{{
`${
cartItem.category == "promos"
? "(" + currencyFormatter.format(cartItem.subTotal * -1) + ")"
: currencyFormatter.format(cartItem.subTotal)
}`
}}
</span>
</div>
<!-- Sub total, sales tax, total columns -->
@ -88,6 +96,7 @@ import baseMixin from "@/mixins/base-mixin.js";
// Helpers
import { deepClone } from "@/helpers/object-helper";
import { getHighestFullySatisfiedTier, getPackageContents } from "@/helpers/service-package-helper";
import { getPromoCodeWithoutBundleIdentifier } from "@/helpers/promotions-helper";
// Constants
import { partTypeStrings } from "@/constants/part-type-strings";
@ -216,33 +225,16 @@ export default {
cartItems.push(this.mobileFeeCartItem);
}
// Create a cart item for each promo
this.promos.forEach((promoLineItem) => {
let cartItem = null;
cartItem = {
name: promoLineItem?.promoCode, // get from CMS?
category: cartItemCategories.PROMOS,
cartItemType: promoLineItem?.partType,
isDisplayed: true,
subTotal:
(promoLineItem?.kitPrice ?? 0) +
(promoLineItem?.laborAmount ?? 0) +
(promoLineItem?.sellingPrice ?? 0),
salesTax: promoLineItem?.salesTax,
lineItems: [],
};
promoLineItem.cartItemType = cartItem.cartItemType;
cartItem.lineItems.push(promoLineItem);
cartItems.push(cartItem);
});
if (this.premiumAppointmentDiscountCartItem) {
cartItems.push(this.premiumAppointmentDiscountCartItem);
}
if (this.promoCartItems) {
this.promoCartItems.forEach((promoCartItem) => {
cartItems.push(promoCartItem);
});
}
return cartItems;
},
},
@ -346,6 +338,7 @@ export default {
category: cartItemCategories.VAPS,
cartItemType: cartItemTypes.FRONT_WIPERS,
isDisplayed: true,
isRemovable: true,
subTotal: 0,
salesTax: 0,
lineItems: [],
@ -382,6 +375,7 @@ export default {
category: cartItemCategories.VAPS,
cartItemType: cartItemTypes.REAR_WIPERS,
isDisplayed: true,
isRemovable: true,
subTotal: 0,
salesTax: 0,
lineItems: [],
@ -547,10 +541,7 @@ export default {
otherSupportingItemsCartItem() {
let cartItem = null;
let otherSupportingItemsLineItems = baseMixin.methods.filterOutFees(
this.supportingItems
);
otherSupportingItemsLineItems = otherSupportingItemsLineItems.filter(
const otherSupportingItemsLineItems = this.supportingItems.filter(
(lineItem) => lineItem.partType != partTypeStrings.EARLY_BIRD
);
@ -597,6 +588,7 @@ export default {
category: cartItemCategories.SUPPORTING_ITEMS,
cartItemType: cartItemTypes.EARLY_BIRD,
isDisplayed: true,
isRemovable: true,
subTotal: 0,
salesTax: 0,
lineItems: [],
@ -615,6 +607,57 @@ export default {
return cartItem;
},
promoCartItems() {
const promoCartItems = [];
// clone the promos array
const promosClone = deepClone(this.promo);
// get unique promo codes
const uniquePromoCodes = [
...new Set(
this.promos.map((promo) => getPromoCodeWithoutBundleIdentifier(promo.promoCode))
),
];
uniquePromoCodes.forEach((promoCode) => {
// get the codes with the prefix from the promo array
const promoLineItems = this.promos.filter(
(promo) => getPromoCodeWithoutBundleIdentifier(promo.promoCode) == promoCode
);
// Create a cart item for each promo
let cartItem = null;
cartItem = {
name: promoCode,
category: cartItemCategories.PROMOS,
cartItemType: promoCode,
isDisplayed: true,
isRemovable: true,
subTotal: 0,
salesTax: 0,
lineItems: [],
};
promoLineItems.forEach((promoLineItem) => {
promoLineItem.cartItemType = cartItem.cartItemType;
cartItem.subTotal +=
(promoLineItem.kitPrice ?? 0) +
(promoLineItem.laborAmount ?? 0) +
(promoLineItem.sellingPrice ?? 0);
cartItem.salesTax += promoLineItem.salesTax ?? 0;
cartItem.lineItems.push(promoLineItem);
});
promoCartItems.push(cartItem);
});
return promoCartItems;
},
removeLinkText() {
return this.getCmsContent("RemoveCartItemTextWidget", "Text");
},