Merge branch 'develop' into feature/CSR-2237
This commit is contained in:
commit
2b69271d4d
13 changed files with 234 additions and 53 deletions
|
|
@ -84,6 +84,10 @@ const endpoints = {
|
|||
url: "/parts/api/v1/parts/supporting-items",
|
||||
method: "POST",
|
||||
},
|
||||
GetRecalPart: {
|
||||
url: "/parts/api/v1/parts/recal-parts",
|
||||
method: "GET",
|
||||
},
|
||||
GetAlertReasons: {
|
||||
url: "/location/api/v1/location/alert-reasons",
|
||||
method: "GET",
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ const partTypeStrings = {
|
|||
FRONT_WIPER: "FRONT WIPER",
|
||||
REAR_WIPER: "REAR WIPER",
|
||||
RAIN_DEFENSE: "RAIN DEFENSE",
|
||||
ADAS_RECALIBRATION: "ADAS RECALIBRATION",
|
||||
RECALIBRATION: "RECALIBRATION",
|
||||
REPLACE_FEE: "REPLACE FEE",
|
||||
RECYCLE_FEE: "RECYCLE FEE",
|
||||
|
|
|
|||
|
|
@ -54,6 +54,7 @@ const storeActions = {
|
|||
REVALIDATE_ORDER_PROMOS_AND_SAVE_SERVER_DATA: "revalidateOrderPromosAndSaveServerData",
|
||||
GET_INSURANCE_COMPANY_LIST: "getInsuranceCompanyList",
|
||||
GET_BILL_TO_ACCOUNT_NUMBER: "getBillToAccountNumber",
|
||||
GET_RECAL_PARTS_AND_SAVE_TO_LINE_ITEMS: "getRecalPartsAndSaveToLineItems",
|
||||
|
||||
// DEPENDENCY MUTATIONS
|
||||
RESET_DAMAGE_STATE_AND_DEPENDENCIES: "resetDamageAndDependencies",
|
||||
|
|
|
|||
|
|
@ -305,8 +305,8 @@ export default {
|
|||
if (!this.lineItems || this.lineItems.length < 1) return;
|
||||
|
||||
const lineItemsCopy = deepClone(this.lineItems);
|
||||
lineItemsCopy.supportingItems = lineItemsCopy.supportingItems
|
||||
? baseMixin.methods.filterOutRecalibration(lineItemsCopy?.supportingItems)
|
||||
lineItemsCopy.glassParts = lineItemsCopy.glassParts
|
||||
? baseMixin.methods.filterOutRecalibration(lineItemsCopy?.glassParts)
|
||||
: [];
|
||||
return lineItemsCopy;
|
||||
},
|
||||
|
|
|
|||
52
src/helpers/recal-helper.js
Normal file
52
src/helpers/recal-helper.js
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
import { deepClone } from "@/helpers/object-helper";
|
||||
import { partTypeStrings } from "@/constants/part-type-strings";
|
||||
|
||||
const recalPartTypes = [partTypeStrings.RECALIBRATION, partTypeStrings.ADAS_RECALIBRATION];
|
||||
|
||||
export function isRecalPartOrHasChildRecalPart(lineItem) {
|
||||
if (lineItem.childParts && lineItem.childParts.length > 0) {
|
||||
return isRecalPart(lineItem) || containsRecalParts(lineItem.childParts);
|
||||
} else {
|
||||
return isRecalPart(lineItem);
|
||||
}
|
||||
}
|
||||
|
||||
export function isRecalPart(lineItem) {
|
||||
return recalPartTypes.some((type) => lineItem.partType === type);
|
||||
}
|
||||
|
||||
export function containsRecalParts(lineItems) {
|
||||
if (!lineItems) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (Array.isArray(lineItems)) {
|
||||
return lineItems.some((li) => isRecalPartOrHasChildRecalPart(li));
|
||||
} else {
|
||||
// complex object form -- flatten and re-call.
|
||||
const flattened = [
|
||||
...(lineItems.glassParts ?? []),
|
||||
...(lineItems.supportingItems ?? []),
|
||||
...(lineItems.vaps ?? []),
|
||||
...(lineItems.promos ?? []),
|
||||
];
|
||||
|
||||
return flattened.some((li) => isRecalPartOrHasChildRecalPart(li));
|
||||
}
|
||||
}
|
||||
|
||||
export function getItemsWithoutRecalParts(lineItems) {
|
||||
const copy = deepClone(lineItems);
|
||||
|
||||
const firstLevelFiltered = copy.filter((li) => !isRecalPart(li));
|
||||
|
||||
const childrenFiltered = firstLevelFiltered.map((li) => {
|
||||
if (li.childParts && li.childParts.length > 0) {
|
||||
li.childParts = getItemsWithoutRecalParts(li.childParts);
|
||||
}
|
||||
|
||||
return li;
|
||||
});
|
||||
|
||||
return childrenFiltered;
|
||||
}
|
||||
|
|
@ -108,6 +108,7 @@ import { getDisplayTextForDurationLength } from "@/helpers/duration-length-helpe
|
|||
import { experimentSettings } from "@/constants/experiments";
|
||||
import { partTypeStrings } from "@/constants/part-type-strings";
|
||||
import { containsLineItemWithPartType } from "@/helpers/service-package-helper";
|
||||
import { containsRecalParts } from "@/helpers/recal-helper.js";
|
||||
|
||||
export default {
|
||||
name: "confirmation",
|
||||
|
|
@ -170,10 +171,7 @@ export default {
|
|||
},
|
||||
computed: {
|
||||
isRecalibrationOnOrder() {
|
||||
return containsLineItemWithPartType(
|
||||
partTypeStrings.RECALIBRATION,
|
||||
this?.lineItems?.supportingItems
|
||||
);
|
||||
return containsRecalParts(this?.lineItems);
|
||||
},
|
||||
shouldHideRecalibration() {
|
||||
return (
|
||||
|
|
|
|||
|
|
@ -153,6 +153,7 @@ import { partTypeStrings } from "@/constants/part-type-strings";
|
|||
import { mapTaxedLineItemsToStoreFormat } from "../../store";
|
||||
import { coverageStatus } from "@/constants/insurance";
|
||||
import { containsLineItemWithPartType } from "@/helpers/service-package-helper";
|
||||
import { containsRecalParts } from "@/helpers/recal-helper";
|
||||
|
||||
defineRule("payment-method-required", required(errorMessages.OPTION_REQUIRED));
|
||||
defineRule("recal-ack-required", required(errorMessages.RECAL_ACK_REQUIRED));
|
||||
|
|
@ -586,10 +587,11 @@ export default {
|
|||
},
|
||||
computed: {
|
||||
isRecalibrationOnOrder() {
|
||||
return containsLineItemWithPartType(
|
||||
partTypeStrings.RECALIBRATION,
|
||||
this.$store.getters.order.lineItems?.supportingItems
|
||||
);
|
||||
const order = baseMixin.methods.hasSubmittedOrder()
|
||||
? baseMixin.methods.getSubmittedOrder()
|
||||
: this.$store.getters.order;
|
||||
|
||||
return containsRecalParts(order.lineItems);
|
||||
},
|
||||
shouldHideRecalibration() {
|
||||
return (
|
||||
|
|
|
|||
|
|
@ -135,6 +135,7 @@ import {
|
|||
import { nextTick } from "vue";
|
||||
import { packageNames } from "@/constants/package-names";
|
||||
import { navigateToHeritageFunnel } from "@/helpers/heritage-integration/navigation-helper";
|
||||
import { containsRecalParts } from "@/helpers/recal-helper";
|
||||
defineRule("option-required", required(errorMessages.OPTION_REQUIRED));
|
||||
|
||||
const INSURANCE_TAB_TO_DISPLAY_THRESHOLD_DEFAULT = 300;
|
||||
|
|
@ -399,10 +400,7 @@ export default {
|
|||
return Object.assign({}, this.lineItems);
|
||||
},
|
||||
isRecalibrationOnOrder() {
|
||||
return containsLineItemWithPartType(
|
||||
partTypeStrings.RECALIBRATION,
|
||||
this?.availableLineItems
|
||||
);
|
||||
return containsRecalParts(this.lineItems);
|
||||
},
|
||||
isServicePackageDiscountOnOrder() {
|
||||
return containsLineItemWithPartType(
|
||||
|
|
@ -585,9 +583,8 @@ export default {
|
|||
if (tier) {
|
||||
let lineItemsToPrice = this.availableLineItems;
|
||||
if (this.isRecalibrationOnOrder && this.shouldHideRecalibration) {
|
||||
lineItemsToPrice = lineItemsToPrice?.filter((item) => {
|
||||
return item.partType != partTypeStrings.RECALIBRATION;
|
||||
});
|
||||
lineItemsToPrice =
|
||||
baseMixin.methods.filterOutRecalibration(lineItemsToPrice);
|
||||
}
|
||||
if (this.isServicePackageDiscountOnOrder) {
|
||||
lineItemsToPrice = lineItemsToPrice?.filter((item) => {
|
||||
|
|
|
|||
|
|
@ -35,6 +35,7 @@ import {
|
|||
getPromosWithAddableVaps,
|
||||
getLineItemsThatMatchPromos,
|
||||
} from "@/helpers/promotions-helper";
|
||||
import { containsRecalParts, getItemsWithoutRecalParts } from "@/helpers/recal-helper";
|
||||
|
||||
export default {
|
||||
name: "servicePackageQuestion",
|
||||
|
|
@ -239,9 +240,7 @@ export default {
|
|||
let lineItemsToPrice = [...this.nullSafeAvailableLineItems];
|
||||
|
||||
if (this.isRecalibrationOnOrder && this.shouldHideRecalibration) {
|
||||
lineItemsToPrice = lineItemsToPrice.filter((item) => {
|
||||
return item.partType != partTypeStrings.RECALIBRATION;
|
||||
});
|
||||
lineItemsToPrice = getItemsWithoutRecalParts(lineItemsToPrice);
|
||||
}
|
||||
|
||||
//remove service package discount part
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ import { queryStrings } from "@/constants/query-strings";
|
|||
import { dynamicStrings } from "@/constants/dynamic-strings";
|
||||
import { partTypeStrings } from "../constants/part-type-strings";
|
||||
import { showFmgLoadingModal } from "@/helpers/loading-modal-helper";
|
||||
import { getItemsWithoutRecalParts } from "@/helpers/recal-helper";
|
||||
|
||||
export default {
|
||||
data() {
|
||||
|
|
@ -103,10 +104,7 @@ export default {
|
|||
return filteredLineItems;
|
||||
},
|
||||
filterOutRecalibration(lineItems) {
|
||||
const filteredLineItems = lineItems.filter((item) => {
|
||||
return !item.partType.includes(partTypeStrings.RECALIBRATION);
|
||||
});
|
||||
return filteredLineItems;
|
||||
return getItemsWithoutRecalParts(lineItems);
|
||||
},
|
||||
getTotalPriceOfAllLineItemsAndChildParts(lineItems, includeTax) {
|
||||
let totalPrice = 0;
|
||||
|
|
|
|||
|
|
@ -450,7 +450,17 @@ export default {
|
|||
const collectedGlassParts = this.reducedGlassPartsArray(partsOrQuestions);
|
||||
|
||||
// save to store lineItems.glassParts
|
||||
self.dispatchStoreAction(storeActions.SAVE_GLASS_PARTS, collectedGlassParts, false);
|
||||
await self.dispatchStoreAction(
|
||||
storeActions.SAVE_GLASS_PARTS,
|
||||
collectedGlassParts,
|
||||
false
|
||||
);
|
||||
|
||||
await self.dispatchStoreActionWithLogging(
|
||||
storeActions.GET_RECAL_PARTS_AND_SAVE_TO_LINE_ITEMS,
|
||||
null,
|
||||
currentPage
|
||||
);
|
||||
|
||||
const payment = store.getters.payment;
|
||||
|
||||
|
|
|
|||
|
|
@ -41,6 +41,7 @@ import {
|
|||
coverageTypeValue,
|
||||
coverageTypeEnum,
|
||||
} from "@/constants/insurance";
|
||||
import { containsRecalParts } from "@/helpers/recal-helper";
|
||||
|
||||
// Export State
|
||||
const getDefaultState = () => {
|
||||
|
|
@ -2946,6 +2947,46 @@ export const actions = {
|
|||
externalParameterMMS.externalParameterStyle
|
||||
);
|
||||
},
|
||||
|
||||
async getRecalPartsAndSaveToLineItems(context, { pageNameToLog }) {
|
||||
// identify each part that needs recal
|
||||
const glassParts = context.state.order?.lineItems?.glassParts ?? [];
|
||||
|
||||
for (let i = 0; i < glassParts.length; i++) {
|
||||
// does this part need recal?
|
||||
const needsRecal =
|
||||
!!glassParts[i].requiresRecalibration && !!glassParts[i].recalibrationType;
|
||||
|
||||
if (needsRecal) {
|
||||
const recalType = glassParts[i].recalibrationType;
|
||||
const parentAccountNumber =
|
||||
context.state.order.payment.parentAccountNumber ??
|
||||
applicationConfig.CASH_PARENT_ACCOUNT_NUMBER;
|
||||
|
||||
// Get part from API
|
||||
const urlExtension = `${context.state.order.vehicle.carId}/${glassParts[i].partNumber}/${recalType}/${parentAccountNumber}/${context.state.order.serviceLocation.zipCode}/${applicationConfig.ANALYTICS_APPLICATION_NAME}/${context.state.order.referralSequenceNumber}`;
|
||||
|
||||
const recalPartResponse = await globalMethods.callHttpClient({
|
||||
method: endpoints.GetRecalPart.method,
|
||||
endpoint: `${endpoints.GetRecalPart.url}/${urlExtension}`,
|
||||
payload: {},
|
||||
pageNameToLog: pageNameToLog,
|
||||
});
|
||||
|
||||
// If any parts retrieved, add as children to the glass part.
|
||||
if (
|
||||
recalPartResponse.status === 200 &&
|
||||
recalPartResponse.data.recalibrationParts?.length > 0
|
||||
) {
|
||||
if (!glassParts[i].childParts) {
|
||||
glassParts[i].childParts = [];
|
||||
}
|
||||
|
||||
glassParts[i].childParts.push(...recalPartResponse.data.recalibrationParts);
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
export default createStore({
|
||||
|
|
@ -2968,34 +3009,7 @@ export default createStore({
|
|||
// Private Functions
|
||||
|
||||
function getHasRecalibrationPart(state) {
|
||||
var hasRequiresRecalibration =
|
||||
getNonFalseValuesOfPropertyInArrayOfObjects(
|
||||
state.order.lineItems.glassParts,
|
||||
"requiresRecalibration"
|
||||
)?.length > 0;
|
||||
var hasRecalibrationType =
|
||||
getNonFalseValuesOfPropertyInArrayOfObjects(
|
||||
state.order.lineItems.glassParts,
|
||||
"recalibrationType"
|
||||
)?.length > 0;
|
||||
|
||||
if (hasRequiresRecalibration) {
|
||||
if (hasRecalibrationType) {
|
||||
// Has both 'requiresRecalibration' and 'recalibrationType' and 'recalibrationType'
|
||||
return (
|
||||
getNonFalseValuesOfPropertyInArrayOfObjects(
|
||||
state.order.lineItems.glassParts,
|
||||
"recalibrationType"
|
||||
)[0].toLowerCase() != "unknown"
|
||||
);
|
||||
} else {
|
||||
// Has 'requiresRecalibration' but no 'recalibrationType' at all
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
// Does not have 'requiresRecalibration'
|
||||
return false;
|
||||
}
|
||||
return containsRecalParts(state.order.lineItems);
|
||||
}
|
||||
|
||||
function sortArrayOfObjectsByPropertyValue(arrayOfObjects, propertyName) {
|
||||
|
|
|
|||
|
|
@ -3950,6 +3950,111 @@ describe("Getters", () => {
|
|||
mutations.updateVaps(storeState, mockStateValues.funnelVaps);
|
||||
mutations.updateGlassToReplace(storeState, mockStateValues.glassToReplace);
|
||||
|
||||
//Assert
|
||||
expect(getters.experimentOrder(storeState)).toEqual({
|
||||
funnelVehicleYear: mockStateValues.vehicleYear,
|
||||
funnelVehicleMake: mockStateValues.vehicleMake,
|
||||
funnelVehicleModel: mockStateValues.vehicleModel,
|
||||
funnelVehicleStyle: mockStateValues.vehicleStyle,
|
||||
funnelIsRepair: mockStateValues.isRepair,
|
||||
funnelNumberOfChips: mockStateValues.numberOfChips,
|
||||
funnelCarId: mockStateValues.carId,
|
||||
funnelServiceCity: mockStateValues.serviceCity,
|
||||
funnelServiceState: mockStateValues.serviceState,
|
||||
funnelServiceZipCode: mockStateValues.serviceZipCode,
|
||||
funnelParentAccountNumber: mockStateValues.parentAccountNumber,
|
||||
funnelIsCoverageVerified: mockStateValues.isCoverageVerified,
|
||||
funnelOrderPartNumbers: ["WINDSHIELDPARTNUMBER"],
|
||||
funnelOrderPartTypes: ["ADAS, maybe"],
|
||||
funnelHasRecalibrationPart: false,
|
||||
funnelSelectedMultiGlass: false,
|
||||
funnelSelectedWindshieldGlass: true,
|
||||
funnelSelectedBackGlass: false,
|
||||
funnelSelectedDriverSideGlass: false,
|
||||
funnelSelectedPassengerSideGlass: false,
|
||||
funnelProviderNumber: mockStateValues.funnelProviderNumber,
|
||||
funnelReferralType: mockStateValues.funnelReferralType,
|
||||
funnelServiceZipCodeCtu: mockStateValues.funnelServiceZipCodeCtu,
|
||||
});
|
||||
});
|
||||
|
||||
test("Single windshield with recalibration child part > return correct experimentOrder values", () => {
|
||||
// Arrange
|
||||
const storeState = state;
|
||||
const mockStateValues = {
|
||||
vehicleYear: 1000,
|
||||
vehicleMake: "CarMake",
|
||||
vehicleModel: "CarModel",
|
||||
vehicleStyle: "SuperCoolStyle",
|
||||
isRepair: false,
|
||||
numberOfChips: 0,
|
||||
carId: "Gibberish",
|
||||
serviceCity: "Columbus",
|
||||
serviceState: "OH-IO",
|
||||
serviceZipCode: 43215,
|
||||
parentAccountNumber: "999999",
|
||||
isCoverageVerified: false,
|
||||
glassParts: [
|
||||
{
|
||||
partNumber: "WINDSHIELDPARTNUMBER",
|
||||
description: "This is a windshield",
|
||||
recalibrationType: "ADAS, maybe",
|
||||
requiresRecalibration: true,
|
||||
requiresCapabilityQuestions: false,
|
||||
childParts: [
|
||||
{
|
||||
partNumber: "THIRD RECAL",
|
||||
description: "Additional Static Recal",
|
||||
recalibrationType:
|
||||
"DUAL & RECAL THIRD & HC FUNCTION TEST & RL SENSOR",
|
||||
ribCode: "RL",
|
||||
safelitePartNumber: "THIRD RECAL",
|
||||
status: "ACTIVE",
|
||||
partType: "ADAS RECALIBRATION",
|
||||
childParts: [],
|
||||
recalibrationFees: [],
|
||||
salesTax: null,
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
otherParts: [],
|
||||
glassToReplace: [
|
||||
{
|
||||
glassLocation: "Windshield",
|
||||
glassName: "Single",
|
||||
},
|
||||
],
|
||||
funnelProviderNumber: "1",
|
||||
funnelReferralType: "CASH QUOTE",
|
||||
funnelServiceZipCodeCtu: "11111",
|
||||
};
|
||||
|
||||
//Act
|
||||
mutations.updateYear(storeState, mockStateValues.vehicleYear);
|
||||
mutations.updateMake(storeState, mockStateValues.vehicleMake);
|
||||
mutations.updateModel(storeState, mockStateValues.vehicleModel);
|
||||
mutations.updateStyle(storeState, mockStateValues.vehicleStyle);
|
||||
mutations.updateIsRepair(storeState, mockStateValues.isRepair);
|
||||
mutations.updateNumberOfChips(storeState, mockStateValues.numberOfChips);
|
||||
mutations.updateCarId(storeState, mockStateValues.carId);
|
||||
mutations.updateServiceLocation(storeState, {
|
||||
city: mockStateValues.serviceCity,
|
||||
state: mockStateValues.serviceState,
|
||||
zipCode: mockStateValues.serviceZipCode,
|
||||
zipCodeCtu: mockStateValues.funnelServiceZipCodeCtu,
|
||||
provider: {
|
||||
providerNumber: mockStateValues.funnelProviderNumber,
|
||||
},
|
||||
});
|
||||
mutations.updateParentAcctNumber(storeState, mockStateValues.parentAccountNumber);
|
||||
mutations.updateInsuranceVerifiedStatus(storeState, mockStateValues.isCoverageVerified);
|
||||
mutations.updateIsInsurance(storeState, false);
|
||||
mutations.updateGlassParts(storeState, mockStateValues.glassParts);
|
||||
mutations.updateSupportingItems(storeState, mockStateValues.funnelSupportingItems);
|
||||
mutations.updateVaps(storeState, mockStateValues.funnelVaps);
|
||||
mutations.updateGlassToReplace(storeState, mockStateValues.glassToReplace);
|
||||
|
||||
//Assert
|
||||
expect(getters.experimentOrder(storeState)).toEqual({
|
||||
funnelVehicleYear: mockStateValues.vehicleYear,
|
||||
|
|
|
|||
Loading…
Reference in a new issue