Merge pull request #874 from Safelite/feature/CSR-504v2
CSR-504 | Implement pricing endpoint call
This commit is contained in:
commit
f0414816d0
9 changed files with 97 additions and 15 deletions
|
|
@ -96,7 +96,7 @@ const endpoints = {
|
||||||
},
|
},
|
||||||
PriceOrderItems: {
|
PriceOrderItems: {
|
||||||
url: "/price/api/v1/price/order-items",
|
url: "/price/api/v1/price/order-items",
|
||||||
method: "POST",
|
method: "GET",
|
||||||
},
|
},
|
||||||
LogExperimentExposureIfAssigned: {
|
LogExperimentExposureIfAssigned: {
|
||||||
url: "/experiments/api/v1/experiments/log-exposure",
|
url: "/experiments/api/v1/experiments/log-exposure",
|
||||||
|
|
|
||||||
|
|
@ -67,6 +67,7 @@ const storeActions = {
|
||||||
SAVE_CAPABILITY_QUESTION_ANSWERS: "saveCapabilityQuestionAnswers",
|
SAVE_CAPABILITY_QUESTION_ANSWERS: "saveCapabilityQuestionAnswers",
|
||||||
SAVE_QUOTE_PAGE_SELECTIONS: "saveQuotePageSelections",
|
SAVE_QUOTE_PAGE_SELECTIONS: "saveQuotePageSelections",
|
||||||
SAVE_PAYMENT_TYPE: "savePaymentType",
|
SAVE_PAYMENT_TYPE: "savePaymentType",
|
||||||
|
SAVE_ACCOUNT_NUMBER: "saveAccountNumber",
|
||||||
SAVE_SUPPORTING_ITEMS: "saveSupportingItems",
|
SAVE_SUPPORTING_ITEMS: "saveSupportingItems",
|
||||||
SAVE_VAPS: "saveVaps",
|
SAVE_VAPS: "saveVaps",
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,7 @@ const storeMutations = {
|
||||||
UPDATE_GLASS_PARTS: "updateGlassParts",
|
UPDATE_GLASS_PARTS: "updateGlassParts",
|
||||||
UPDATE_VAPS: "updateVaps",
|
UPDATE_VAPS: "updateVaps",
|
||||||
UPDATE_SUPPORTING_ITEMS: "updateSupportingItems",
|
UPDATE_SUPPORTING_ITEMS: "updateSupportingItems",
|
||||||
|
UPDATE_LINE_ITEMS_SERVER_DATA: "updateLineItemsServerData",
|
||||||
|
|
||||||
UPDATE_REGISTRATION_LICENSE_PLATE: "updateRegistrationLicensePlate",
|
UPDATE_REGISTRATION_LICENSE_PLATE: "updateRegistrationLicensePlate",
|
||||||
UPDATE_REGISTRATION_ADDRESS: "updateRegistrationAddress",
|
UPDATE_REGISTRATION_ADDRESS: "updateRegistrationAddress",
|
||||||
|
|
|
||||||
|
|
@ -100,6 +100,7 @@ async function saveSessionHelper() {
|
||||||
accountNumber: savedSessionInfo.data.accountNumber?.toString(),
|
accountNumber: savedSessionInfo.data.accountNumber?.toString(),
|
||||||
savedSessionId: savedSessionInfo.data.savedSessionId,
|
savedSessionId: savedSessionInfo.data.savedSessionId,
|
||||||
crmCustomerId: savedSessionInfo.data.crmCustomerId?.toString(),
|
crmCustomerId: savedSessionInfo.data.crmCustomerId?.toString(),
|
||||||
|
eon: savedSessionInfo.data.eon,
|
||||||
},
|
},
|
||||||
false
|
false
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,9 @@
|
||||||
groupName="ServicePackageQuestion"
|
groupName="ServicePackageQuestion"
|
||||||
:availableLineItems="availableLineItems"
|
:availableLineItems="availableLineItems"
|
||||||
:isInsuranceSelected="isInsuranceSelected"
|
:isInsuranceSelected="isInsuranceSelected"
|
||||||
@vapsItemsSelected="vapsItemsSelectedAction" />
|
@vapsItemsSelected="vapsItemsSelectedAction"
|
||||||
|
validationRules="option-required"
|
||||||
|
isRequired />
|
||||||
|
|
||||||
<textBlock
|
<textBlock
|
||||||
cmsWidgetName="quoteDisclaimer"
|
cmsWidgetName="quoteDisclaimer"
|
||||||
|
|
@ -64,14 +66,19 @@ import { settleAllPromises } from "@/helpers/layout-helper";
|
||||||
import { storeActions } from "@/constants/store-actions";
|
import { storeActions } from "@/constants/store-actions";
|
||||||
import store from "@/store";
|
import store from "@/store";
|
||||||
import { fetchCmsContentForPage } from "@/helpers/cms-content-helper";
|
import { fetchCmsContentForPage } from "@/helpers/cms-content-helper";
|
||||||
import { Form } from "vee-validate";
|
import { required } from "@/helpers/validation-rules";
|
||||||
|
import { errorMessages } from "@/constants/error-messages";
|
||||||
|
import { Form, defineRule } from "vee-validate";
|
||||||
import { navigateToHeritageFunnel } from "@/helpers/heritage-integration/navigation-helper";
|
import { navigateToHeritageFunnel } from "@/helpers/heritage-integration/navigation-helper";
|
||||||
|
import { applicationConfig } from "@/constants/application-config";
|
||||||
|
|
||||||
|
defineRule("option-required", required(errorMessages.OPTION_REQUIRED));
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "quote",
|
name: "quote",
|
||||||
async beforeRouteEnter(to, from, next) {
|
async beforeRouteEnter(to, from, next) {
|
||||||
// Call APIs
|
// Call APIs
|
||||||
const cmsContent = await fetchCmsContentForPage(to.query.fmgPage);
|
const cmsContentPromise = fetchCmsContentForPage(to.query.fmgPage);
|
||||||
const wipersPromise = baseMixin.methods.dispatchStoreAction(storeActions.GET_WIPERS);
|
const wipersPromise = baseMixin.methods.dispatchStoreAction(storeActions.GET_WIPERS);
|
||||||
const rainDefensePromise = baseMixin.methods.dispatchStoreAction(
|
const rainDefensePromise = baseMixin.methods.dispatchStoreAction(
|
||||||
storeActions.GET_RAIN_DEFENSE
|
storeActions.GET_RAIN_DEFENSE
|
||||||
|
|
@ -81,6 +88,10 @@ export default {
|
||||||
);
|
);
|
||||||
|
|
||||||
const promiseResultMap = [
|
const promiseResultMap = [
|
||||||
|
{
|
||||||
|
resultKey: "cmsContent",
|
||||||
|
promise: cmsContentPromise,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
resultKey: "wipers",
|
resultKey: "wipers",
|
||||||
promise: wipersPromise,
|
promise: wipersPromise,
|
||||||
|
|
@ -112,8 +123,7 @@ export default {
|
||||||
|
|
||||||
// Call the "next" function to complete the transition to this page.
|
// Call the "next" function to complete the transition to this page.
|
||||||
next((vm) => {
|
next((vm) => {
|
||||||
vm.setCmsContent(cmsContent);
|
vm.setCmsContent(resultMap.cmsContent);
|
||||||
|
|
||||||
vm.supportingItems = resultMap.supportingItems;
|
vm.supportingItems = resultMap.supportingItems;
|
||||||
vm.availableLineItems = pricingResults;
|
vm.availableLineItems = pricingResults;
|
||||||
vm.isInsuranceSelected = vm.getDefaultIsInsuranceSelectedValue();
|
vm.isInsuranceSelected = vm.getDefaultIsInsuranceSelectedValue();
|
||||||
|
|
@ -150,6 +160,15 @@ export default {
|
||||||
vapsItemsSelectedAction(vapsItemsSelected) {
|
vapsItemsSelectedAction(vapsItemsSelected) {
|
||||||
this.selectedVaps = vapsItemsSelected;
|
this.selectedVaps = vapsItemsSelected;
|
||||||
},
|
},
|
||||||
|
filterOutFees(currentSupportingItems) {
|
||||||
|
const filteredSupportingItems = currentSupportingItems.filter((item) => {
|
||||||
|
return (
|
||||||
|
!item.partType.includes("FEE") ||
|
||||||
|
(item.partType === "REPAIR FEE" && item.partNumber != "SUPPLIES-REPAIR")
|
||||||
|
);
|
||||||
|
});
|
||||||
|
return filteredSupportingItems;
|
||||||
|
},
|
||||||
backButtonAction() {
|
backButtonAction() {
|
||||||
vehicleQuestionsMixin.methods.navigateBack(this);
|
vehicleQuestionsMixin.methods.navigateBack(this);
|
||||||
},
|
},
|
||||||
|
|
@ -159,6 +178,16 @@ export default {
|
||||||
this.isInsuranceSelected,
|
this.isInsuranceSelected,
|
||||||
false
|
false
|
||||||
);
|
);
|
||||||
|
if (!this.isInsuranceSelected) {
|
||||||
|
this.dispatchStoreAction(
|
||||||
|
this.storeActions.SAVE_ACCOUNT_NUMBER,
|
||||||
|
applicationConfig.CASH_ACCOUNT_NUMBER,
|
||||||
|
false
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (this.$store.getters.order.accountNumber != applicationConfig.CASH_ACCOUNT_NUMBER) {
|
||||||
|
this.supportingItems = this.filterOutFees(this.supportingItems);
|
||||||
|
}
|
||||||
this.dispatchStoreAction(
|
this.dispatchStoreAction(
|
||||||
this.storeActions.SAVE_SUPPORTING_ITEMS,
|
this.storeActions.SAVE_SUPPORTING_ITEMS,
|
||||||
this.supportingItems,
|
this.supportingItems,
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,8 @@
|
||||||
buttonTypeString="servicePackageRadio"
|
buttonTypeString="servicePackageRadio"
|
||||||
:buttonTypeObject="servicePackageRadio"
|
:buttonTypeObject="servicePackageRadio"
|
||||||
v-model="selectedPackageName"
|
v-model="selectedPackageName"
|
||||||
isRequired />
|
:validationRules="validationRules"
|
||||||
|
:isRequired="isRequired" />
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
|
@ -28,6 +29,8 @@ export default {
|
||||||
groupName: String,
|
groupName: String,
|
||||||
cashCmsWidgetName: String,
|
cashCmsWidgetName: String,
|
||||||
insuranceCmsWidgetName: String,
|
insuranceCmsWidgetName: String,
|
||||||
|
validationRules: String,
|
||||||
|
isRequired: Boolean,
|
||||||
isInsuranceSelected: Boolean,
|
isInsuranceSelected: Boolean,
|
||||||
availableLineItems: null,
|
availableLineItems: null,
|
||||||
},
|
},
|
||||||
|
|
@ -185,7 +188,7 @@ export default {
|
||||||
item.partType.toUpperCase() === partTypeStrings.FRONT_WIPER) ||
|
item.partType.toUpperCase() === partTypeStrings.FRONT_WIPER) ||
|
||||||
(priceRearWipers && item.partType.toUpperCase() === partTypeStrings.REAR_WIPER)
|
(priceRearWipers && item.partType.toUpperCase() === partTypeStrings.REAR_WIPER)
|
||||||
) {
|
) {
|
||||||
vapsPrice += item.price;
|
vapsPrice += baseMixin.methods.getTotalLineItemPrice(item);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return vapsPrice;
|
return vapsPrice;
|
||||||
|
|
@ -204,7 +207,7 @@ export default {
|
||||||
(priceRainDefense &&
|
(priceRainDefense &&
|
||||||
item.partType.toUpperCase() === partTypeStrings.RAIN_DEFENSE)
|
item.partType.toUpperCase() === partTypeStrings.RAIN_DEFENSE)
|
||||||
) {
|
) {
|
||||||
vapsPrice += item.price;
|
vapsPrice += baseMixin.methods.getTotalLineItemPrice(item);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return vapsPrice;
|
return vapsPrice;
|
||||||
|
|
|
||||||
|
|
@ -72,11 +72,14 @@ export default {
|
||||||
partType != partTypeStrings.REAR_WIPER &&
|
partType != partTypeStrings.REAR_WIPER &&
|
||||||
partType != partTypeStrings.RAIN_DEFENSE
|
partType != partTypeStrings.RAIN_DEFENSE
|
||||||
) {
|
) {
|
||||||
totalPrice += lineItem.price;
|
totalPrice += this.getTotalLineItemPrice(lineItem);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return totalPrice;
|
return totalPrice;
|
||||||
},
|
},
|
||||||
|
getTotalLineItemPrice(lineItem) {
|
||||||
|
return lineItem.kitPrice + lineItem.laborAmount + lineItem.sellingPrice;
|
||||||
|
},
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
storeActions() {
|
storeActions() {
|
||||||
|
|
|
||||||
|
|
@ -42,7 +42,9 @@ export default {
|
||||||
requiresCapabilityQuestions: singlePart.requiresCapabilityQuestions,
|
requiresCapabilityQuestions: singlePart.requiresCapabilityQuestions,
|
||||||
recalibrationType: singlePart.recalibrationType,
|
recalibrationType: singlePart.recalibrationType,
|
||||||
childParts: singlePart.childParts,
|
childParts: singlePart.childParts,
|
||||||
price: singlePart.price,
|
kitPrice: singlePart.kitPrice,
|
||||||
|
sellingPrice: singlePart.sellingPrice,
|
||||||
|
laborAmount: singlePart.laborAmount,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -149,6 +149,9 @@ export const mutations = {
|
||||||
updateSupportingItems(state, partsData) {
|
updateSupportingItems(state, partsData) {
|
||||||
state.order.lineItems.supportingItems = partsData;
|
state.order.lineItems.supportingItems = partsData;
|
||||||
},
|
},
|
||||||
|
updateLineItemsServerData(state, serverData) {
|
||||||
|
state.order.lineItems.serverData = serverData;
|
||||||
|
},
|
||||||
updatePageData(state, pageData) {
|
updatePageData(state, pageData) {
|
||||||
state.applicationUser.pageData[pageData.page] = pageData.data;
|
state.applicationUser.pageData[pageData.page] = pageData.data;
|
||||||
},
|
},
|
||||||
|
|
@ -1022,6 +1025,7 @@ export const actions = {
|
||||||
referralDate: order.referralDate,
|
referralDate: order.referralDate,
|
||||||
referralNumber: order.referralNumber?.toString(), // TODO It'd be nice to save these as strings in the first place
|
referralNumber: order.referralNumber?.toString(), // TODO It'd be nice to save these as strings in the first place
|
||||||
referralSequenceNumber: order.referralNumber?.toString(), // TODO Pass the referralSequence number once insurance flow creates it
|
referralSequenceNumber: order.referralNumber?.toString(), // TODO Pass the referralSequence number once insurance flow creates it
|
||||||
|
eon: order.eon,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
@ -1379,6 +1383,9 @@ export const actions = {
|
||||||
savePaymentType(context, isInsurance) {
|
savePaymentType(context, isInsurance) {
|
||||||
context.commit(storeMutations.UPDATE_IS_INSURANCE, isInsurance);
|
context.commit(storeMutations.UPDATE_IS_INSURANCE, isInsurance);
|
||||||
},
|
},
|
||||||
|
saveAccountNumber(context, accountNumber) {
|
||||||
|
context.commit(storeMutations.UPDATE_PARENT_ACCT_NUMBER, accountNumber);
|
||||||
|
},
|
||||||
saveSupportingItems(context, supportingItems) {
|
saveSupportingItems(context, supportingItems) {
|
||||||
context.commit(storeMutations.UPDATE_SUPPORTING_ITEMS, supportingItems);
|
context.commit(storeMutations.UPDATE_SUPPORTING_ITEMS, supportingItems);
|
||||||
},
|
},
|
||||||
|
|
@ -1386,11 +1393,34 @@ export const actions = {
|
||||||
context.commit(storeMutations.UPDATE_VAPS, vaps);
|
context.commit(storeMutations.UPDATE_VAPS, vaps);
|
||||||
},
|
},
|
||||||
// Price order actions
|
// Price order actions
|
||||||
// PLACEHOLDER, WILL CHANGE WHEN PRICING END POINT IS IMPLEMENTED
|
async priceOrderItems(context, availableLineItems) {
|
||||||
priceOrderItems(context, availableLineItems) {
|
const availableLineItemsFormattedForRequest = availableLineItems
|
||||||
availableLineItems.forEach((lineItem) => {
|
.map((lineItem) => `&LineItems=${lineItem.partNumber}`)
|
||||||
lineItem["price"] = parseFloat((Math.random() * 100).toFixed(2));
|
.join("");
|
||||||
|
const vehicle = context.getters.order.vehicle;
|
||||||
|
let queryString =
|
||||||
|
`ParentAccountNumber=${applicationConfig.CASH_ACCOUNT_NUMBER}` +
|
||||||
|
`&CTU=${context.getters.order.serviceLocation.zipCodeCtu}` +
|
||||||
|
`&CarId=${vehicle.carId}` +
|
||||||
|
`&Make=${vehicle.make}` +
|
||||||
|
`&Model=${vehicle.model}` +
|
||||||
|
`&Year=${vehicle.year}` +
|
||||||
|
`&EON=${context.getters.order.eon}` +
|
||||||
|
`&ZipCode=${context.getters.order.serviceLocation.zipCode}` +
|
||||||
|
`${availableLineItemsFormattedForRequest}`;
|
||||||
|
const lineItemServerData = context.getters.order.lineItems.serverData;
|
||||||
|
if (lineItemServerData) {
|
||||||
|
queryString += `&ServerData=${lineItemServerData}`;
|
||||||
|
}
|
||||||
|
const response = await globalMethods.callHttpClient({
|
||||||
|
method: endpoints.PriceOrderItems.method,
|
||||||
|
endpoint: `${endpoints.PriceOrderItems.url}?${queryString}`,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
context.commit(storeMutations.UPDATE_LINE_ITEMS_SERVER_DATA, response.data.serverData);
|
||||||
|
|
||||||
|
availableLineItems = addPricesToLineItems(availableLineItems, response.data.lineItems);
|
||||||
|
|
||||||
return availableLineItems;
|
return availableLineItems;
|
||||||
},
|
},
|
||||||
// Misc order actions
|
// Misc order actions
|
||||||
|
|
@ -1540,3 +1570,15 @@ function convertGlassPieceNamingFromApi(glassArray) {
|
||||||
});
|
});
|
||||||
return glassArray;
|
return glassArray;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function addPricesToLineItems(lineItems, pricingLineItems) {
|
||||||
|
lineItems.forEach((lineItem) => {
|
||||||
|
let pricedLineItem = pricingLineItems.find(
|
||||||
|
(pricingLineItem) => pricingLineItem.partNumber === lineItem.partNumber
|
||||||
|
);
|
||||||
|
lineItem.laborAmount = pricedLineItem.laborAmount;
|
||||||
|
lineItem.sellingPrice = pricedLineItem.sellingPrice;
|
||||||
|
lineItem.kitPrice = pricedLineItem.kitPrice;
|
||||||
|
});
|
||||||
|
return lineItems;
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue