From d6c1e7cd06c35f3608bcf3381829f227fafa9a81 Mon Sep 17 00:00:00 2001 From: Alex Humphries Date: Wed, 15 Jul 2026 10:48:12 -0400 Subject: [PATCH] INSR-523: If flag is on, includes memberNumber in all coverage requests Also adds new (currently unused) flag to move claim registration to end of flow --- src/layouts/entry-page/entry-page.vue | 4 + src/store/index.js | 186 ++++++++++++++------------ src/store/store.spec.js | 40 ++++++ 3 files changed, 143 insertions(+), 87 deletions(-) diff --git a/src/layouts/entry-page/entry-page.vue b/src/layouts/entry-page/entry-page.vue index 9cea64bc..f177cd53 100644 --- a/src/layouts/entry-page/entry-page.vue +++ b/src/layouts/entry-page/entry-page.vue @@ -226,6 +226,10 @@ export default { this.mainStore.issConfig.hiddenFields.phoneNumber = true; } } + + if (clientFlags.CallClaimRegistrationAtEnd) { + this.mainStore.issConfig.callClaimRegistrationAtEnd = true; + } } }, combineClientParameters(configParams, queryStringParams) { diff --git a/src/store/index.js b/src/store/index.js index eef5e5d6..3da801c2 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -279,7 +279,8 @@ export const getDefaultState = () => ({ buildInfo: (typeof __BUILD_INFO__ !== 'undefined') ? __BUILD_INFO__ : null, // Contains the build info for the website, set during the build process. Version, Time, Git info etc.... siteType: null, // SiteType / SubType the site is set to (Essential/Advanced). enableNoCompQuote: false, - useMemberNumber: false // Indicates if member number should be included for policy lookup purposes + useMemberNumber: false, // Indicates if member number should be included for policy lookup purposes + callClaimRegistrationAtEnd: false, // Indicates if claim registration should be called at the end of the flow. } }); @@ -646,72 +647,76 @@ export const useMainStore = defineStore({ const { isITAC } = this; try { + const payload = { + referralCorrelationId: this.order.referralCorrelationId, + referralDate: this.order.referralDate, + referralNumber: this.order.referralNumber, + accountNumber: this.order.parentAccountNumber?.toString() ?? '', + policyData: this.order.policy.policyData, + // TODO: Remove this isRepair flag from the payload after coverage service updates are deployed. + // This is here in case we have to deploy site for other fixes before coverage service gets updated. + isRepair: this.order.damage.isRepair, + isItac: isITAC, + sourceSystem: applicationConfig.APPLICATION_NAME, + insured: { + firstName: this.order.customer.firstName, + lastName: this.order.customer.lastName, + address: { + addressLine1: this.order.customer.address.streetAddress, + addressLine2: this.order.customer.address.streetAddress2, + city: this.order.customer.address.city, + state: this.order.customer.address.state, + zipCode: this.order.customer.address.zipCode, + country: 'US' // TODO set from store + }, + homePhone: { + number: this.contactInfo.homePhone?.replaceAll(nonNumberCharRegex, '') ?? '' + } + }, + driver: { + firstName: this.order.customer.firstName, + lastName: this.order.customer.lastName + }, + caller: { + homePhone: {} + }, + policyInfo: { + policyNumber: this.order.policy.policyNumber, + safelitePolicy: { + policies: [] + }, + actualDeductible: this.currentDeductible.toString() ?? '', + currentRepairDeductible: this.order.currentDeductible.repair, + currentReplaceDeductible: this.order.currentDeductible.replace, + company: this.order.customer.companyCode + }, + lossInfo: { + dateOfLoss: this.order.policy.dateOfLoss, + isRepair: this.order.damage.isRepair, + location: { + city: this.order.policy.damageCity, + state: this.order.policy.damageState, + country: 'US' // TODO set from store + }, + vehicle: { + id: this.order.vehicle.policyVehicleId?.toString() ?? '', + year: this.order.vehicle.year?.toString() ?? '', + make: this.order.vehicle.make, + model: this.order.vehicle.model, + vin: this.order.vehicle.vin + }, + cause: this.order.policy.damageCause, + damageDescription: this.order.policy.damageCause + } + }; + // Clients (i.e. USAA) may sometimes use member number, which is just policy number by a different name + if (this.issConfig.useMemberNumber) { + payload.memberNumber = this.order.policy.policyNumber; + } const response = await globalMethods.callHttpClient({ method: endpoints.RegisterClaim.method, endpoint: endpoints.RegisterClaim.url, - payload: - { - referralCorrelationId: this.order.referralCorrelationId, - referralDate: this.order.referralDate, - referralNumber: this.order.referralNumber, - accountNumber: this.order.parentAccountNumber?.toString() ?? '', - policyData: this.order.policy.policyData, - // TODO: Remove this isRepair flag from the payload after coverage service updates are deployed. - // This is here in case we have to deploy site for other fixes before coverage service gets updated. - isRepair: this.order.damage.isRepair, - isItac: isITAC, - sourceSystem: applicationConfig.APPLICATION_NAME, - insured: { - firstName: this.order.customer.firstName, - lastName: this.order.customer.lastName, - address: { - addressLine1: this.order.customer.address.streetAddress, - addressLine2: this.order.customer.address.streetAddress2, - city: this.order.customer.address.city, - state: this.order.customer.address.state, - zipCode: this.order.customer.address.zipCode, - country: 'US' // TODO set from store - }, - homePhone: { - number: this.contactInfo.homePhone?.replaceAll(nonNumberCharRegex, '') ?? '' - } - }, - driver: { - firstName: this.order.customer.firstName, - lastName: this.order.customer.lastName - }, - caller: { - homePhone: {} - }, - policyInfo: { - policyNumber: this.order.policy.policyNumber, - safelitePolicy: { - policies: [] - }, - actualDeductible: this.currentDeductible.toString() ?? '', - currentRepairDeductible: this.order.currentDeductible.repair, - currentReplaceDeductible: this.order.currentDeductible.replace, - company: this.order.customer.companyCode - }, - lossInfo: { - dateOfLoss: this.order.policy.dateOfLoss, - isRepair: this.order.damage.isRepair, - location: { - city: this.order.policy.damageCity, - state: this.order.policy.damageState, - country: 'US' // TODO set from store - }, - vehicle: { - id: this.order.vehicle.policyVehicleId?.toString() ?? '', - year: this.order.vehicle.year?.toString() ?? '', - make: this.order.vehicle.make, - model: this.order.vehicle.model, - vin: this.order.vehicle.vin - }, - cause: this.order.policy.damageCause, - damageDescription: this.order.policy.damageCause - } - }, + payload, bailoutOnError: false }); this.order.insuranceCoverage.claimNumber = response.data.claimNumber; @@ -741,33 +746,39 @@ export const useMainStore = defineStore({ glassInformation?.forEach((glassPiece) => { manualGlassNamesArray.push(glassPiece?.glassLocation?.toUpperCase()); }); - + + const payload = { + referralCorrelationId: this.order.referralCorrelationId, + accountNumber: this.order.parentAccountNumber?.toString() ?? '', + endorsements: endorsementAnswersForPayload, + manualGlassNames: manualGlassNamesArray, + policyState: this.order.customer.address.state, + status: this.order.policy.status, + originalDeductible: this.originalDeductible, + currentDeductible: this.currentDeductible, + currentRepairDeductible: this.order.currentDeductible.repair, + currentReplaceDeductible: this.order.currentDeductible.replace, + noCoverage: false, + isRepair: this.order.damage.isRepair, + policyNumber: this.order.policy.policyNumber, + insuredFirstName: this.order.customer.firstName, + insuredLastName: this.order.customer.lastName, + insuredZipCode: this.order.customer.address.zipCode, + policyVehicleId: this.order.vehicle.policyVehicleId?.toString() ?? '', + vehicleVin: this.order.vehicle.vin, + policyData: this.order.policy.policyData, + isItac: this.isITAC + } + // Clients (i.e. USAA) may sometimes use member number, which is just policy number by a different name + if (this.issConfig.useMemberNumber) { + payload.memberNumber = this.order.policy.policyNumber; + } + try { const r = await globalMethods.callHttpClient({ method: endpoints.FinalDeductible.method, endpoint: endpoints.FinalDeductible.url, - payload: { - referralCorrelationId: this.order.referralCorrelationId, - accountNumber: this.order.parentAccountNumber?.toString() ?? '', - endorsements: endorsementAnswersForPayload, - manualGlassNames: manualGlassNamesArray, - policyState: this.order.customer.address.state, - status: this.order.policy.status, - originalDeductible: this.originalDeductible, - currentDeductible: this.currentDeductible, - currentRepairDeductible: this.order.currentDeductible.repair, - currentReplaceDeductible: this.order.currentDeductible.replace, - noCoverage: false, - isRepair: this.order.damage.isRepair, - policyNumber: this.order.policy.policyNumber, - insuredFirstName: this.order.customer.firstName, - insuredLastName: this.order.customer.lastName, - insuredZipCode: this.order.customer.address.zipCode, - policyVehicleId: this.order.vehicle.policyVehicleId?.toString() ?? '', - vehicleVin: this.order.vehicle.vin, - policyData: this.order.policy.policyData, - isItac: this.isITAC - }, + payload, bailoutOnError: false }); this.order.policy.policyData = r.data.policyData; @@ -2308,6 +2319,7 @@ export const useMainStore = defineStore({ this.issConfig.enableNoCompQuote = false; this.issConfig.billToAccountNumber = null; this.issConfig.useMemberNumber = false; + this.issConfig.callClaimRegistrationAtEnd = false; // NOTE: Do not wipe out build info. }, diff --git a/src/store/store.spec.js b/src/store/store.spec.js index 61813d5c..0798bb36 100644 --- a/src/store/store.spec.js +++ b/src/store/store.spec.js @@ -518,6 +518,46 @@ describe('Store', () => { }) })); }); + + it('calls api with memberNumber when useMemberNumber is true', async () => { + // Arrange + store.issConfig.useMemberNumber = true; + const companyCode = getRandomString(6, 6); + const policyNumber = getRandomString(6, 6); + const originalDeductible = { + replace: 500, + repair: 0 + }; + const currentDeductible = { + replace: 500, + repair: 0 + }; + store.order.originalDeductible = { + replace: originalDeductible.replace, + repair: originalDeductible.repair + }; + store.order.currentDeductible = { + replace: currentDeductible.replace, + repair: currentDeductible.repair + }; + store.order.customer.companyCode = companyCode; + store.order.policy.policyNumber = policyNumber; + globalMethods.callHttpClient = jest.fn().mockReturnValue(Promise.resolve({})); + + // Act + await store.registerClaim(); + + // Asserts + expect(globalMethods.callHttpClient).toHaveBeenCalledWith(expect.objectContaining({ + payload: expect.objectContaining({ + sourceSystem: applicationConfig.APPLICATION_NAME, + memberNumber: policyNumber, + policyInfo: expect.objectContaining({ + company: companyCode + }) + }) + })); + }); }); describe('updateContactInfo method', () => {