From bf5c84891b3e49c3236738cf1143ced4b7323daa Mon Sep 17 00:00:00 2001 From: Josh Dassinger Date: Mon, 3 Jun 2024 11:00:22 -0500 Subject: [PATCH] SSR-1341 Bill to API update --- src/constants/endpoints.js | 4 ++-- src/store/index.js | 46 ++++++++++++-------------------------- src/store/store.spec.js | 29 ------------------------ 3 files changed, 16 insertions(+), 63 deletions(-) diff --git a/src/constants/endpoints.js b/src/constants/endpoints.js index 4fe98061..e6ad5cdd 100644 --- a/src/constants/endpoints.js +++ b/src/constants/endpoints.js @@ -25,8 +25,8 @@ const endpoints = Object.freeze({ method: 'GET' }, GetBillToInfo: { - url: `${ACCOUNT_BASE_URL}/bill-to-info`, - method: 'POST' + url: `${ACCOUNT_BASE_URL}/bill-to-account-number`, + method: 'GET' }, GetAlertReasons: { url: `${LOCATION_BASE_URL}/alert-reasons`, diff --git a/src/store/index.js b/src/store/index.js index 450e902d..4e859a18 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -233,8 +233,6 @@ export const getDefaultState = () => ({ styleSheet: '', // Stylesheet used by the client. parentAccountNumber: 0, // Parent account number used by the client. billToAccountNumber: null, - itacCashBillToNumber: null, - itacFnrBillToNumber: null, isCoverageEnabled: false, // Indicates if we should be calling coverage on this flow. isClaimRegistrationRequired: false, // Indicates if the claim registration call needs to be made for a client to complete coverage verification. isAuthenticated: false, // Indicates if user is authenticated or not. @@ -257,17 +255,7 @@ export const useMainStore = defineStore({ id: storeId, state: () => state, getters: { - billToNumberToUse(storeState) { - if (this.isITAC) { - return storeState.issConfig.itacCashBillToNumber; - } - - if (this.isNoComp) { - return storeState.issConfig.itacFnrBillToNumber; - } - - return storeState.issConfig.billToAccountNumber; - }, + billToAccountNumber: (storeState) => storeState.issConfig.billToAccountNumber, hasRecalibrationPart: (storeState) => getHasRecalibrationPart(storeState), vehicle: (storeState) => storeState.order.vehicle, damage: (storeState) => storeState.order.damage, @@ -871,7 +859,7 @@ export const useMainStore = defineStore({ startDate, endDate, applicationName: applicationConfig.APPLICATION_NAME, - billToAccountNumber: this.billToNumberToUse, + billToAccountNumber: this.billToAccountNumber, parentAccountNumber: this.issConfig.parentAccountNumber, // this.payment.parentAccountNumber, carId: vehicle.carId, lineItems, @@ -935,7 +923,7 @@ export const useMainStore = defineStore({ endDate, shopAppointmentType, applicationName: applicationConfig.APPLICATION_NAME, - billToAccountNumber: this.billToNumberToUse, + billToAccountNumber: this.billToAccountNumber, parentAccountNumber: this.issConfig.parentAccountNumber, // this.payment.parentAccountNumber, carId: vehicle.carId, lineItems, @@ -1061,7 +1049,7 @@ export const useMainStore = defineStore({ let queryString = `ParentAccountNumber=${this.order.parentAccountNumber}` - + `&BillToAccountNumber=${this.billToNumberToUse}` + + `&BillToAccountNumber=${this.billToAccountNumber}` + `&CTU=${ctuToUse}` + `&Deductible=${deductibleToUse}` + `&ZipCode=${zipCodeToUse}` @@ -1098,7 +1086,7 @@ export const useMainStore = defineStore({ return globalMethods.callHttpClient({ method: endpoints.GetMobileFeePart.method, - endpoint: `${endpoints.GetMobileFeePart.url}/${damageType}/${this.order.parentAccountNumber}/${this.billToNumberToUse}` + endpoint: `${endpoints.GetMobileFeePart.url}/${damageType}/${this.order.parentAccountNumber}/${this.billToAccountNumber}` }); }, @@ -1843,8 +1831,6 @@ export const useMainStore = defineStore({ this.issConfig.siteType = null; this.issConfig.enableNoCompQuote = false; this.issConfig.billToAccountNumber = null; - this.issConfig.itacCashBillToNumber = null; - this.issConfig.itacFnrBillToNumber = null; }, disableKeyFields() { @@ -2045,7 +2031,7 @@ export const useMainStore = defineStore({ || appointmentType === AppointmentTypeStrings.MOBILE_NOT_ITAC_AND_NOT_NOCOMP) { queryString = `ParentAccountNumber=${this.order.parentAccountNumber}` - + `&BillToAccountNumber=${this.billToNumberToUse}` + + `&BillToAccountNumber=${this.billToAccountNumber}` + `&ProviderNumber=${providerNumber}` + `&AppointmentType=${appointmentType}` + `&ServiceLocation.City=${serviceLocationCity}` @@ -2055,7 +2041,7 @@ export const useMainStore = defineStore({ } else { queryString = `ParentAccountNumber=${this.order.parentAccountNumber}` - + `&BillToAccountNumber=${this.billToNumberToUse}` + + `&BillToAccountNumber=${this.billToAccountNumber}` + `&ProviderNumber=${providerNumber}` + `&AppointmentType=${appointmentType}` + `${lineItemsQueryString}`; @@ -2304,26 +2290,22 @@ export const useMainStore = defineStore({ async getBillToInfo() { const { order, issConfig } = this; try { - const payload = { + const params = new URLSearchParams({ parentAccountNumber: issConfig.parentAccountNumber.toString(), providerNumber: order.serviceLocation.zipCodeCtu.toString(), - billToSelectionCriteria: { - typeOfClaim: 'GLASS ONLY', - lineOfBusiness: 'PERSONAL' - } - }; + typeOfClaim: 'GLASS ONLY', + lineOfBusiness: 'PERSONAL', + isItac: false + }); const response = await globalMethods.callHttpClient({ method: endpoints.GetBillToInfo.method, - endpoint: endpoints.GetBillToInfo.url, - payload + endpoint: `${endpoints.GetBillToInfo.url}?${params.toString()}` }); const billToInfo = response.data; if (billToInfo != null) { - issConfig.billToAccountNumber = billToInfo.billToAccountNumber; - issConfig.itacCashBillToNumber = billToInfo.itacCashBillToNumber; - issConfig.itacFnrBillToNumber = billToInfo.itacFnrBillToNumber; + issConfig.billToAccountNumber = billToInfo.toString(); return Promise.resolve(); } diff --git a/src/store/store.spec.js b/src/store/store.spec.js index ed870bf0..83978c76 100644 --- a/src/store/store.spec.js +++ b/src/store/store.spec.js @@ -2096,33 +2096,4 @@ describe('Store', () => { expect(store.order.payment.paypalToken).toEqual(paypalToken); }); }); - - describe('billToNumberToUse getter', () => { - it('returns itacCashBillToNumber when coverageType is ITAC', () => { - // Arrange - store.order.insuranceCoverage.coverageType = coverageType.ITAC; - store.issConfig.itacCashBillToNumber = '12345'; - - // Assert - expect(store.billToNumberToUse).toEqual(store.issConfig.itacCashBillToNumber); - }); - - it('returns itacFnrBillToNumber when coverageType is No Comp', () => { - // Arrange - store.order.insuranceCoverage.coverageType = coverageType.NO_COMP; - store.issConfig.itacFnrBillToNumber = '12345'; - - // Assert - expect(store.billToNumberToUse).toEqual(store.issConfig.itacFnrBillToNumber); - }); - - it('returns billToAccountNumber when coverageType is Deductible', () => { - // Arrange - store.order.insuranceCoverage.coverageType = coverageType.Deductible; - store.issConfig.billToAccountNumber = '12345'; - - // Assert - expect(store.billToNumberToUse).toEqual(store.issConfig.billToAccountNumber); - }); - }); });