SSR-1167 PR discussions

This commit is contained in:
Josh Dassinger 2024-05-23 13:08:18 -05:00
parent 80873d77d2
commit 072ff84451
5 changed files with 119 additions and 117 deletions

View file

@ -20,6 +20,7 @@ const coverageType = Object.freeze({
/** /**
* We attempted policy lookup and got a success response * We attempted policy lookup and got a success response
* The vehicle policy does not have comprehensive coverage * The vehicle policy does not have comprehensive coverage
* No Comp quotes are enabled by the client
*/ */
NO_COMP: 3 NO_COMP: 3
}); });

View file

@ -157,7 +157,7 @@ const endpoints = Object.freeze({
method: 'POST' method: 'POST'
}, },
ValidateZip: { ValidateZip: {
url: `${LOCATION_BASE_URL}/zip`, url: (zip) => `${LOCATION_BASE_URL}/zip/${zip}`,
method: 'GET' method: 'GET'
}, },
GooglePlaces: { GooglePlaces: {

View file

@ -327,7 +327,6 @@ export default {
const { const {
vehicle, vehicle,
isClaimRegistrationRequired, isClaimRegistrationRequired,
isClaimAlreadyRegistered,
isPolicyLookupSuccessful, isPolicyLookupSuccessful,
isPendingClaimRegistration isPendingClaimRegistration
} = useMainStore(); } = useMainStore();
@ -337,7 +336,6 @@ export default {
&& policyVehicleId != null && policyVehicleId != null
&& policyVehicleId >= 0 && policyVehicleId >= 0
&& isClaimRegistrationRequired && isClaimRegistrationRequired
&& !isClaimAlreadyRegistered
&& isPendingClaimRegistration && isPendingClaimRegistration
); );
} }
@ -365,18 +363,20 @@ export default {
return !!useMainStore().vehicle.carId; return !!useMainStore().vehicle.carId;
}, },
async initializeComponent() { async initializeComponent() {
// TODO this should be determined based on the result of the ITAC price call
// TODO it seems that ITAC now requires claim registration calls. If this call fails
if (this.mainStore.isDeductible && this.deductibleValue > this.totalServicePrice) {
this.mainStore.updateCoverageType(coverageType.ITAC);
}
if (this.shouldRegisterClaim) { if (this.shouldRegisterClaim) {
await this.mainStore.registerClaim(); await this.mainStore.registerClaim();
} else if (!this.mainStore.isClaimRegistrationRequired) { } else if (!this.mainStore.isClaimRegistrationRequired) {
this.mainStore.updateCoverageStatus(coverageStatuses.VERIFIED); this.mainStore.updateCoverageStatus(coverageStatuses.VERIFIED);
} }
// TODO this should be determined based on the result of the ITAC price call
// TODO it seems that ITAC now requires claim registration calls. If this call fails
if (this.mainStore.isVerified
&& this.mainStore.isDeductible
&& this.deductibleValue > this.totalServicePrice) {
this.mainStore.updateCoverageType(coverageType.ITAC);
}
showIssLoadingModal(false); showIssLoadingModal(false);
}, },
async navigateForward() { async navigateForward() {

View file

@ -174,9 +174,6 @@ import states from '@/constants/states';
import globalRules from '@/constants/global-rules'; import globalRules from '@/constants/global-rules';
import routerParams from '@/router/router-constants/router-params'; import routerParams from '@/router/router-constants/router-params';
import MaskaFormattedMasks from '@/constants/maska-masks'; import MaskaFormattedMasks from '@/constants/maska-masks';
import globalMethods from '@/global-methods';
import { endpoints } from '@/constants/endpoints';
import coverageType from '@/constants/coverage-type';
// define validation rules // define validation rules
defineRule( defineRule(
@ -295,81 +292,35 @@ export default {
isDateOfLossDisabled() { isDateOfLossDisabled() {
return !!this.mainStore.issConfig.disabledFields.dateOfLoss; return !!this.mainStore.issConfig.disabledFields.dateOfLoss;
}, },
isCoverageEnabled() {
return this.mainStore.issConfig.isCoverageEnabled;
},
maxCoverageLookupAttemptsReached() {
return this.mainStore.applicationUser.coverageLookupAttempts >= 11;
},
phoneMask() { phoneMask() {
return MaskaFormattedMasks.PHONE_NUMBER; return MaskaFormattedMasks.PHONE_NUMBER;
} }
}, },
methods: { methods: {
async forwardButtonAction() { async forwardButtonAction() {
await this.mainStore
.validateZip({ zip: this.welcomePageModel.policyZipCode })
.then(async (zipInfo) => {
if (zipInfo?.data?.isValid === true) {
this.mainStore.updatePolicyData(this.welcomePageModel);
this.mainStore.order.serviceLocation.zipCodeCtu =
zipInfo.data.zipCodeCtu?.toString();
const billToInfo = await this.getBillToInfo(
this.mainStore.issConfig.parentAccountNumber,
this.mainStore.order.serviceLocation.zipCodeCtu
);
if (billToInfo !== null) {
this.mainStore.issConfig.billToAccountNumber =
billToInfo.billToAccountNumber;
this.mainStore.issConfig.itacCashBillToNumber =
billToInfo.itacCashBillToNumber;
this.mainStore.issConfig.itacFnrBillToNumber =
billToInfo.itacFnrBillToNumber;
}
await this.mainStore
.getDuplicateReferrals()
.catch(() => {})
.finally(async () => {
if (this.isCoverageEnabled
&& !this.maxCoverageLookupAttemptsReached) {
await this.mainStore.getCoveragePolicyInfo()
?.catch(() => this.mainStore.updateCoverageType(coverageType.NONE));
} else {
this.mainStore.updateCoverageType(coverageType.NONE);
}
this.navigateForward();
});
} else {
this.displayInvalidZipAlert = true;
this.$refs.siteFooter.removeLoader();
}
});
},
async getBillToInfo(parentAccountNumber, providerNumber) {
try { try {
const payload = { await this.configureZip();
parentAccountNumber: parentAccountNumber.toString(), this.mainStore.updatePolicyData(this.welcomePageModel);
providerNumber: providerNumber.toString(), await this.mainStore.getBillToInfo();
billToSelectionCriteria: { await this.mainStore.getDuplicateReferrals();
typeOfClaim: 'GLASS ONLY', await this.mainStore.getCoveragePolicyInfo();
lineOfBusiness: 'PERSONAL' } catch (e) {
} console.error(e);
}; // TODO: Bailout?
} finally {
const response = await globalMethods.callHttpClient({ if (!this.displayInvalidZipAlert) {
method: endpoints.GetBillToInfo.method, this.navigateForward();
endpoint: endpoints.GetBillToInfo.url, }
payload }
}); },
async configureZip() {
return response.data; try {
} catch (err) { await this.mainStore.validateZip({ zip: this.welcomePageModel.policyZipCode });
console.error(`Error Status Code: ${err.data?.status}: ${err.data?.title}`); return Promise.resolve();
return null; } catch (e) {
this.displayInvalidZipAlert = true;
this.$refs.siteFooter.removeLoader();
return Promise.reject(e);
} }
}, },
navigateForward() { navigateForward() {

View file

@ -523,13 +523,20 @@ export const useMainStore = defineStore({
}; };
} }
}, },
getCoveragePolicyInfo() { async getCoveragePolicyInfo() {
const { order } = this; const { order, issConfig, applicationUser } = this;
const { policy } = order; const { policy } = order;
if (issConfig.isCoverageEnabled && applicationUser.coverageLookupAttempts > 10) {
this.updateCoverageType(coverageType.NONE);
return Promise.resolve();
}
this.applicationUser.coverageAttempts += 1; this.applicationUser.coverageAttempts += 1;
console.log(`Coverage lookup attempt #${this.applicationUser.coverageAttempts}. Max attempts allowed: 10.`); console.log(`Coverage lookup attempt #${this.applicationUser.coverageAttempts}. Max attempts allowed: 10.`);
return new Promise((resolve, reject) => {
globalMethods.callHttpClient({ try {
const response = await globalMethods.callHttpClient({
method: endpoints.CoveragePolicyInfo.method, method: endpoints.CoveragePolicyInfo.method,
endpoint: endpoints.CoveragePolicyInfo.url, endpoint: endpoints.CoveragePolicyInfo.url,
payload: { payload: {
@ -539,35 +546,35 @@ export const useMainStore = defineStore({
zipCode: policy.policyZipCode, zipCode: policy.policyZipCode,
referralCorrelationId: order.referralCorrelationId referralCorrelationId: order.referralCorrelationId
} }
}).then((r) => {
const responsePolicy = r?.data?.policies?.[0];
if (responsePolicy) {
this.updateCoverageType(coverageType.Deductible);
const insured = responsePolicy.insureds?.[0];
// populate policy holder details from policy lookup
order.customer.address.streetAddress = insured?.address;
order.customer.address.city = insured?.city;
order.customer.address.state = insured?.state;
order.customer.address.zipCode = insured?.zipCode?.toString();
order.customer.firstName = insured?.firstName;
order.customer.lastName = insured?.lastName;
// populate additional fields
order.serviceLocation.zipCode = insured?.zipCode?.toString();
order.policy.policyData = responsePolicy.policyData;
// populate vehicles
order.policy.vehicles = responsePolicy.vehicles ?? [];
} else {
this.updateCoverageType(coverageType.NONE);
}
return resolve(r);
}).catch((error) => {
this.updateCoverageType(coverageType.NONE);
return reject(error);
}); });
});
const responsePolicy = response?.data?.policies?.[0];
if (responsePolicy) {
this.updateCoverageType(coverageType.Deductible);
const insured = responsePolicy.insureds?.[0];
// populate policy holder details from policy lookup
order.customer.address.streetAddress = insured?.address;
order.customer.address.city = insured?.city;
order.customer.address.state = insured?.state;
order.customer.address.zipCode = insured?.zipCode?.toString();
order.customer.firstName = insured?.firstName;
order.customer.lastName = insured?.lastName;
// populate additional fields
order.serviceLocation.zipCode = insured?.zipCode?.toString();
order.policy.policyData = responsePolicy.policyData;
// populate vehicles
order.policy.vehicles = responsePolicy.vehicles ?? [];
} else {
this.updateCoverageType(coverageType.NONE);
}
return Promise.resolve();
} catch (e) {
this.updateCoverageType(coverageType.NONE);
return Promise.reject(e);
}
}, },
updateCoverageStatus(status) { updateCoverageStatus(status) {
this.order.insuranceCoverage.coverageStatus = status; this.order.insuranceCoverage.coverageStatus = status;
@ -682,7 +689,7 @@ export const useMainStore = defineStore({
status: this.order.policy.status, status: this.order.policy.status,
originalDeductible: this.order.originalDeductible, originalDeductible: this.order.originalDeductible,
currentDeductible: this.order.currentDeductible, currentDeductible: this.order.currentDeductible,
noCoverage: this.isNoComp, noCoverage: false,
isRepair: this.order.damage.isRepair, isRepair: this.order.damage.isRepair,
policyNumber: this.order.policy.policyNumber, policyNumber: this.order.policy.policyNumber,
insuredFirstName: this.order.customer.firstName, insuredFirstName: this.order.customer.firstName,
@ -2259,10 +2266,53 @@ export const useMainStore = defineStore({
}, },
async validateZip({ zip }) { async validateZip({ zip }) {
return await globalMethods.callHttpClient({ try {
method: endpoints.ValidateZip.method, const response = await globalMethods.callHttpClient({
endpoint: `${endpoints.ValidateZip.url}/${zip}` method: endpoints.ValidateZip.method,
}); endpoint: endpoints.ValidateZip.url(zip)
});
const zipInfo = response.data;
if (zipInfo?.isValid === true) {
this.order.serviceLocation.zipCodeCtu = zipInfo.zipCodeCtu;
return Promise.resolve();
}
return Promise.reject(new Error('Invalid Zip Info'));
} catch (e) {
return Promise.reject(e);
}
},
async getBillToInfo() {
const { order, issConfig } = this;
try {
const payload = {
parentAccountNumber: issConfig.parentAccountNumber.toString(),
providerNumber: order.serviceLocation.zipCodeCtu.toString(),
billToSelectionCriteria: {
typeOfClaim: 'GLASS ONLY',
lineOfBusiness: 'PERSONAL'
}
};
const response = await globalMethods.callHttpClient({
method: endpoints.GetBillToInfo.method,
endpoint: endpoints.GetBillToInfo.url,
payload
});
const billToInfo = response.data;
if (billToInfo != null) {
issConfig.billToAccountNumber = billToInfo.billToAccountNumber;
issConfig.itacCashBillToNumber = billToInfo.itacCashBillToNumber;
issConfig.itacFnrBillToNumber = billToInfo.itacFnrBillToNumber;
return Promise.resolve();
}
return Promise.reject(new Error('Invalid billToInfo'));
} catch (e) {
return Promise.reject(e);
}
}, },
async validateClientTag(clientTag) { async validateClientTag(clientTag) {