Merge pull request #759 from Safelite/defect/digital/SSR-1385

SSR-1385 Don't call ITAC pricing for repairs
This commit is contained in:
Josh Dassinger 2024-06-19 11:05:54 -05:00 committed by GitHub
commit 5bd08b0e79
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -125,6 +125,7 @@ import { formatAmountInDollars } from '@/helpers/text-helper.js';
import showIssLoadingModal from '@/helpers/loading-modal-helper';
import { getPriceOfLineItems } from '@/helpers/price-calculator';
import coverageStatuses from '@/constants/coverage-statuses';
import coverageType from '@/constants/coverage-type';
const SAFELITE_PROVIDER = 'Safelite';
@ -309,6 +310,9 @@ export default {
&& isClaimRegistrationRequired
&& isPendingClaimRegistration
);
},
isRepair() {
return this.mainStore.order.damage.isRepair;
}
},
watch: {
@ -341,33 +345,51 @@ export default {
}
if (this.mainStore.isVerified) {
const clonedGlassParts = useMainStore().lineItems.glassParts
? JSON.parse(JSON.stringify(useMainStore().lineItems.glassParts))
: [];
const availableLineItems = [
...(this.supportingItems ?? []),
...(clonedGlassParts ?? [])
];
await this.getPricedParts();
const pricingResults = await useMainStore()
.getITACPriceOrderItems(availableLineItems)
.catch((err) => {
useMainStore().setBailout(bailoutMessage.pricingResponseError(
availableLineItems.map((li) => li.partNumber),
{
code: err.code,
message: err.message,
data: err.data
}
));
this.navigateWithScenario(navigationScenarios.PRICING_LOOKUP_ERROR);
});
this.setBaseServiceLineItems(pricingResults);
// Repairs will never be ITAC
if (this.isRepair && this.mainStore.isITAC) {
this.mainStore.updateCoverageType(coverageType.Deductible);
}
}
showIssLoadingModal(false);
},
async getPricedParts() {
const clonedGlassParts = useMainStore().lineItems.glassParts
? JSON.parse(JSON.stringify(useMainStore().lineItems.glassParts))
: [];
const availableLineItems = [
...(this.supportingItems ?? []),
...(clonedGlassParts ?? [])
];
let pricingRequest;
if (!this.isRepair) {
// If we are NOT a repair we call the ITAC pricing service
pricingRequest = useMainStore().getITACPriceOrderItems(availableLineItems);
} else if (this.mainStore.isNoComp) {
// If we are a repair and are NoComp we call the insurance pricing service.
pricingRequest = useMainStore().getInsurancePriceOrderItems(availableLineItems);
} else {
// We don't price parts if we are repair and is Deductible
return;
}
const pricingResults = await pricingRequest.catch((err) => {
useMainStore().setBailout(bailoutMessage.pricingResponseError(
availableLineItems.map((li) => li.partNumber),
{
code: err.code,
message: err.message,
data: err.data
}
));
this.navigateWithScenario(navigationScenarios.PRICING_LOOKUP_ERROR);
});
this.setBaseServiceLineItems(pricingResults);
},
async navigateForward() {
if (this.isUnverifiedVisible || this.isDeductibleVisible) {
useMainStore().updateSupportingItems(this.supportingItems);