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