SSR-1385 Don't call ITAC pricing for repairs

This commit is contained in:
Josh Dassinger 2024-06-19 10:44:49 -05:00
parent 49c5a4a241
commit ae0da7749e

View file

@ -125,6 +125,7 @@ import { formatAmountInDollars } from '@/helpers/text-helper.js';
import showIssLoadingModal from '@/helpers/loading-modal-helper'; import showIssLoadingModal from '@/helpers/loading-modal-helper';
import { getPriceOfLineItems } from '@/helpers/price-calculator'; import { getPriceOfLineItems } from '@/helpers/price-calculator';
import coverageStatuses from '@/constants/coverage-statuses'; import coverageStatuses from '@/constants/coverage-statuses';
import coverageType from '@/constants/coverage-type';
const SAFELITE_PROVIDER = 'Safelite'; const SAFELITE_PROVIDER = 'Safelite';
@ -309,6 +310,9 @@ export default {
&& isClaimRegistrationRequired && isClaimRegistrationRequired
&& isPendingClaimRegistration && isPendingClaimRegistration
); );
},
isRepair() {
return this.mainStore.order.damage.isRepair;
} }
}, },
watch: { watch: {
@ -341,33 +345,51 @@ export default {
} }
if (this.mainStore.isVerified) { if (this.mainStore.isVerified) {
const clonedGlassParts = useMainStore().lineItems.glassParts await this.getPricedParts();
? JSON.parse(JSON.stringify(useMainStore().lineItems.glassParts))
: [];
const availableLineItems = [
...(this.supportingItems ?? []),
...(clonedGlassParts ?? [])
];
const pricingResults = await useMainStore() // Repairs will never be ITAC
.getITACPriceOrderItems(availableLineItems) if (this.isRepair && this.mainStore.isITAC) {
.catch((err) => { this.mainStore.updateCoverageType(coverageType.Deductible);
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);
} }
showIssLoadingModal(false); 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() { async navigateForward() {
if (this.isUnverifiedVisible || this.isDeductibleVisible) { if (this.isUnverifiedVisible || this.isDeductibleVisible) {
useMainStore().updateSupportingItems(this.supportingItems); useMainStore().updateSupportingItems(this.supportingItems);