Corrected bug where page would crash if part wasn't found in pricing because it was in the child parts
This commit is contained in:
parent
40ed6033ae
commit
a1eeb4e733
2 changed files with 12 additions and 43 deletions
|
|
@ -191,8 +191,6 @@ methods: {
|
|||
throw new Error("Could not match any parts to the selected parts");
|
||||
}
|
||||
|
||||
await this.mainStore.resetMoldingAndCapabilityQuestionAnswersIfNeeded(matchedParts);
|
||||
|
||||
this.navigateForward(matchedParts, null);
|
||||
},
|
||||
|
||||
|
|
|
|||
|
|
@ -734,28 +734,6 @@ export const useMainStore = defineStore({
|
|||
this.order.damage.glassToReplace = null;
|
||||
},
|
||||
|
||||
resetMoldingAndCapabilityQuestionAnswersIfNeeded(matchedParts) {
|
||||
const partsOrQuestionsDataToCompareWith =
|
||||
this.pageData(issPageValues.MOLDING_QUESTIONS)?.partsOrQuestions ??
|
||||
this.pageData(issPageValues.CAPABILITY_QUESTIONS)?.partsOrQuestions ??
|
||||
[];
|
||||
|
||||
const previouslySelectedPartNumbers = getAllPartNumbers(partsOrQuestionsDataToCompareWith);
|
||||
const currentlySelectedPartNumbers = getAllPartNumbers(matchedParts);
|
||||
|
||||
const haveSelectedVehiclePartsChanged =
|
||||
previouslySelectedPartNumbers !== currentlySelectedPartNumbers;
|
||||
|
||||
if (haveSelectedVehiclePartsChanged) {
|
||||
//was updateGlassParts, added dependencies for SSR-290
|
||||
this.resetPartsAndDependencies();
|
||||
this.updateMoldingQuestionAnswers(null);
|
||||
this.updateCapabilityQuestionAnswers(null);
|
||||
this.updatePageData({ page: issPageValues.MOLDING_QUESTIONS, data: null });
|
||||
this.updatePageData({ page: issPageValues.CAPABILITY_QUESTIONS, data: null });
|
||||
}
|
||||
},
|
||||
|
||||
resetISSConfigState() {
|
||||
this.issConfig.clientName = 'Generic Insurance';
|
||||
this.issConfig.clientDisplayName = 'Generic Insurance';
|
||||
|
|
@ -1358,30 +1336,23 @@ function convertGlassPieceNamingFromApi(glassArray) {
|
|||
return glassArray;
|
||||
}
|
||||
|
||||
function getAllPartNumbers(partsOrQuestions) {
|
||||
return partsOrQuestions[0]?.parts
|
||||
? [...partsOrQuestions]
|
||||
.map((glass) => glass.parts)
|
||||
.flat()
|
||||
.map((part) => part.partNumber)
|
||||
.filter((partNumber) => !partNumber.toUpperCase().includes('FEE'))
|
||||
.sort()
|
||||
.join(',')
|
||||
: [];
|
||||
}
|
||||
|
||||
function addPricesToLineItems(lineItems, pricingLineItems) {
|
||||
lineItems.forEach((lineItem) => {
|
||||
const lineItemIndex = pricingLineItems.findIndex(
|
||||
(pricingLineItem) => pricingLineItem.partNumber === lineItem.partNumber
|
||||
);
|
||||
if (lineItem.childParts) {
|
||||
addPricesToLineItems(lineItem.childParts, pricingLineItems);
|
||||
}
|
||||
const pricedLineItem = pricingLineItems.splice(lineItemIndex, 1)[0];
|
||||
lineItem.laborAmount = pricedLineItem.laborAmount;
|
||||
lineItem.sellingPrice = pricedLineItem.sellingPrice;
|
||||
lineItem.kitPrice = pricedLineItem.kitPrice;
|
||||
|
||||
const lineItemIndex = pricingLineItems.findIndex(
|
||||
(pricingLineItem) => pricingLineItem.partNumber === lineItem.partNumber
|
||||
);
|
||||
|
||||
if(lineItemIndex > -1)
|
||||
{
|
||||
const pricedLineItem = pricingLineItems[lineItemIndex];
|
||||
lineItem.laborAmount = pricedLineItem.laborAmount;
|
||||
lineItem.sellingPrice = pricedLineItem.sellingPrice;
|
||||
lineItem.kitPrice = pricedLineItem.kitPrice;
|
||||
}
|
||||
});
|
||||
return lineItems;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue