CSR-1994
fix pricing issue when service package discount not available
This commit is contained in:
parent
d7bc92ec0a
commit
e90d4c4246
2 changed files with 43 additions and 38 deletions
|
|
@ -160,27 +160,26 @@ export default {
|
|||
lineItems.vaps = lineItems.vaps ?? [];
|
||||
const nullSafeGlassParts = lineItems.glassParts ?? [];
|
||||
const servicePackageDiscountSettingValue = experimentMixin.methods.getSettingValue(
|
||||
experimentSettings.SERVICE_PACKAGE_DISCOUNT
|
||||
);
|
||||
const isServicePackageDiscount = servicePackageDiscountSettingValue === "True";
|
||||
if (isServicePackageDiscount) {
|
||||
const servicePackageDiscount = await baseMixin.methods.dispatchStoreActionWithLogging(
|
||||
experimentSettings.SERVICE_PACKAGE_DISCOUNT
|
||||
);
|
||||
const isServicePackageDiscount = servicePackageDiscountSettingValue === "True";
|
||||
if (isServicePackageDiscount) {
|
||||
const servicePackageDiscount = await baseMixin.methods.dispatchStoreActionWithLogging(
|
||||
storeActions.CASH_SERVICE_PACKAGE_DISCOUNT,
|
||||
null,
|
||||
"quote"
|
||||
);
|
||||
lineItems.supportingItems = [...resultMap.supportingItems,servicePackageDiscount.data];
|
||||
}
|
||||
else{
|
||||
lineItems.supportingItems = [...resultMap.supportingItems, servicePackageDiscount.data];
|
||||
} else {
|
||||
lineItems.supportingItems = resultMap.supportingItems;
|
||||
}
|
||||
}
|
||||
const availableLineItems = [
|
||||
resultMap.rainDefense,
|
||||
...lineItems.supportingItems,
|
||||
...resultMap.wipers,
|
||||
...nullSafeGlassParts,
|
||||
];
|
||||
|
||||
|
||||
const pricingResults = await baseMixin.methods.dispatchStoreActionWithLogging(
|
||||
storeActions.PRICE_ORDER_ITEMS_AND_SAVE_SERVER_DATA,
|
||||
{
|
||||
|
|
@ -249,7 +248,7 @@ export default {
|
|||
availableLineItems: null,
|
||||
lineItems: [],
|
||||
addableVaps: [],
|
||||
servicePackageDiscountLineItems:[]
|
||||
servicePackageDiscountLineItems: [],
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
|
|
|
|||
|
|
@ -101,12 +101,15 @@ export default {
|
|||
buttonLabel: this.getHeaderTextFromCms(answer.SubWidgetName),
|
||||
buttonLabelSubCopy: this.getSubheaderTextFromCms(answer.SubWidgetName),
|
||||
buttonBodyCopy: this.getBodyTextFromCms(answer.SubWidgetName),
|
||||
buttonAuxillaryCopy: this.getDiscountedPackagePriceString(answer.Name,this.isServicePackageDiscount && answer.Text != ""),
|
||||
buttonAuxillaryCopy: this.getDiscountedPackagePriceString(
|
||||
answer.Name,
|
||||
this.isServicePackageDiscount && answer.Text != ""
|
||||
),
|
||||
buttonFooterCopy: this.getFooterTextFromCms(answer.SubWidgetName),
|
||||
additionalButtonData: {
|
||||
strikeThroughPrice: this.getPackagePriceString(answer.Name),
|
||||
servicePackageDiscount: this.isServicePackageDiscount && answer.Text != "",
|
||||
Text: answer.Text+this.getServicePackageDiscountPrice(),
|
||||
Text: answer.Text + this.getServicePackageDiscountPrice(),
|
||||
},
|
||||
}));
|
||||
return modifiedAnswers;
|
||||
|
|
@ -182,35 +185,36 @@ export default {
|
|||
},
|
||||
getPackagePriceString(packageName) {
|
||||
const formattedPriceFloat = parseFloat(
|
||||
this.getPackagePrice(packageName, { discountedPrice: false,servicePackageDiscount:false })
|
||||
this.getPackagePrice(packageName, {
|
||||
discountedPrice: false,
|
||||
servicePackageDiscount: false,
|
||||
})
|
||||
).toFixed(2);
|
||||
return "$" + formattedPriceFloat;
|
||||
},
|
||||
getDiscountedPackagePriceString(packageName,servicePackageDiscount) {
|
||||
getDiscountedPackagePriceString(packageName, servicePackageDiscount) {
|
||||
const formattedPriceFloat = parseFloat(
|
||||
this.getPackagePrice(packageName, { discountedPrice: true, servicePackageDiscount })
|
||||
).toFixed(2);
|
||||
return (this.isInsuranceSelected ? "As little as $" : "$") + formattedPriceFloat;
|
||||
},
|
||||
getPackagePrice(packageName, { discountedPrice = false , servicePackageDiscount = false}) {
|
||||
|
||||
//remove service package discount part
|
||||
const servicePackageDiscountParts = findLineItemsWithPartType(
|
||||
partTypeStrings.SERVICE_PACKAGE_DISCOUNT,
|
||||
this.nullSafeAvailableLineItems
|
||||
);
|
||||
const parts = this.nullSafeAvailableLineItems.filter((item) => {
|
||||
return item.partType != servicePackageDiscountParts?.[0].partType;
|
||||
});
|
||||
|
||||
|
||||
var lineItemsToPrice = [...parts];
|
||||
getPackagePrice(packageName, { discountedPrice = false, servicePackageDiscount = false }) {
|
||||
var lineItemsToPrice = [...this.nullSafeAvailableLineItems];
|
||||
//remove service package discount part
|
||||
const servicePackageDiscountParts = findLineItemsWithPartType(
|
||||
partTypeStrings.SERVICE_PACKAGE_DISCOUNT,
|
||||
this.nullSafeAvailableLineItems
|
||||
);
|
||||
if (servicePackageDiscountParts?.length > 0) {
|
||||
lineItemsToPrice = this.nullSafeAvailableLineItems.filter((item) => {
|
||||
return item.partType != servicePackageDiscountParts[0].partType;
|
||||
});
|
||||
}
|
||||
|
||||
if (discountedPrice) {
|
||||
lineItemsToPrice.push(...removeVapsPromosFromPromoArray(this.activePromos));
|
||||
}
|
||||
if(servicePackageDiscount)
|
||||
{
|
||||
}
|
||||
if (servicePackageDiscount) {
|
||||
lineItemsToPrice.push(...servicePackageDiscountParts);
|
||||
}
|
||||
let priceFloat = this.isInsuranceSelected
|
||||
|
|
@ -223,14 +227,16 @@ export default {
|
|||
|
||||
return priceFloat;
|
||||
},
|
||||
getServicePackageDiscountPrice(){
|
||||
getServicePackageDiscountPrice() {
|
||||
const servicePackageDiscountParts = findLineItemsWithPartType(
|
||||
partTypeStrings.SERVICE_PACKAGE_DISCOUNT,
|
||||
this.nullSafeAvailableLineItems
|
||||
);
|
||||
let price = 0;
|
||||
price += baseMixin.methods.getTotalLineItemPrice(servicePackageDiscountParts?.[0]);
|
||||
return Math.abs(price);
|
||||
partTypeStrings.SERVICE_PACKAGE_DISCOUNT,
|
||||
this.nullSafeAvailableLineItems
|
||||
);
|
||||
if (servicePackageDiscountParts?.length > 0) {
|
||||
let price = 0;
|
||||
price += baseMixin.methods.getTotalLineItemPrice(servicePackageDiscountParts[0]);
|
||||
return Math.abs(price);
|
||||
} else return 0;
|
||||
},
|
||||
getVapsPrice(packageName, applyPromoDiscounts = false) {
|
||||
const vapsItems = this.getVapsLineItemsForSelectedPackage(packageName);
|
||||
|
|
|
|||
Loading…
Reference in a new issue