diff --git a/src/constants/endpoints.js b/src/constants/endpoints.js index 0c75258e9..ed880269c 100644 --- a/src/constants/endpoints.js +++ b/src/constants/endpoints.js @@ -172,6 +172,10 @@ const endpoints = { url: "/account/api/v1/account/insurance-companies", method: "GET", }, + GetBillToAccountNumber: { + url: "/account/api/v1/account/bill-to-account-number", + method: "GET", + }, }; export { endpoints }; diff --git a/src/constants/store-actions.js b/src/constants/store-actions.js index 069079d35..4cd03771e 100644 --- a/src/constants/store-actions.js +++ b/src/constants/store-actions.js @@ -53,6 +53,7 @@ const storeActions = { VALIDATE_ORDER_PROMO_AND_SAVE_SERVER_DATA: "validateOrderPromoAndSaveServerData", REVALIDATE_ORDER_PROMOS_AND_SAVE_SERVER_DATA: "revalidateOrderPromosAndSaveServerData", GET_INSURANCE_COMPANY_LIST: "getInsuranceCompanyList", + GET_BILL_TO_ACCOUNT_NUMBER: "getBillToAccountNumber", // DEPENDENCY MUTATIONS RESET_DAMAGE_STATE_AND_DEPENDENCIES: "resetDamageAndDependencies", diff --git a/src/layouts/service-location/helpers/service-location-helper/service-location-helper.js b/src/layouts/service-location/helpers/service-location-helper/service-location-helper.js index e92349ddf..1e7b6bdb3 100644 --- a/src/layouts/service-location/helpers/service-location-helper/service-location-helper.js +++ b/src/layouts/service-location/helpers/service-location-helper/service-location-helper.js @@ -3,7 +3,7 @@ import baseMixin from "@/mixins/base-mixin.js"; export async function getPricedMobileFeePart(serviceZipCode, pageNameToLog) { if (!serviceZipCode) { - return Promise.resolve(null); + return null; } const zipCodeData = await baseMixin.methods.getZipCodeData(serviceZipCode, pageNameToLog); @@ -36,12 +36,12 @@ export async function getPricedMobileFeePart(serviceZipCode, pageNameToLog) { false ); - return Promise.resolve(pricingResults[0]); + return pricingResults[0]; } export async function getServiceabilityDetails(serviceZipCode, lineItems, pageNameToLog) { // Get the Mobile Fee Part - const serviceabilityDetails = await baseMixin.methods.dispatchStoreActionWithLogging( + return await baseMixin.methods.dispatchStoreActionWithLogging( storeActions.GET_SERVICEABILITY_DETAILS, { serviceZipCode: serviceZipCode, @@ -50,20 +50,26 @@ export async function getServiceabilityDetails(serviceZipCode, lineItems, pageNa pageNameToLog, false ); +} - return Promise.resolve(serviceabilityDetails); +export async function getBillToAccountNumber(providerNumber) { + // Get the BillTo Account Number + return await baseMixin.methods.dispatchStoreActionWithLogging( + storeActions.GET_BILL_TO_ACCOUNT_NUMBER, + { providerNumber: providerNumber }, + "service-location", + false + ); } export async function getShopProviderData(serviceZipCode) { - const shopProviderData = await baseMixin.methods.dispatchStoreActionWithLogging( + return await baseMixin.methods.dispatchStoreActionWithLogging( storeActions.GET_PROVIDERS, { serviceZipCode: serviceZipCode, }, "service-location" ); - - return Promise.resolve(shopProviderData); } export async function getAvailabilityRating( @@ -92,5 +98,5 @@ export async function getAvailabilityRating( const shopStatus = isGoodAvailability ? "high" : "low"; - return Promise.resolve(shopStatus); + return shopStatus; } diff --git a/src/layouts/service-location/mobile-location-modal-questions/mobile-location-modal-questions.vue b/src/layouts/service-location/mobile-location-modal-questions/mobile-location-modal-questions.vue index 4bdc00cb3..40fc698ac 100644 --- a/src/layouts/service-location/mobile-location-modal-questions/mobile-location-modal-questions.vue +++ b/src/layouts/service-location/mobile-location-modal-questions/mobile-location-modal-questions.vue @@ -83,6 +83,7 @@ import { deepClone } from "@/helpers/object-helper"; import { getPricedMobileFeePart, getServiceabilityDetails, + getBillToAccountNumber, } from "@/layouts/service-location/helpers/service-location-helper/service-location-helper"; // Validation @@ -91,7 +92,7 @@ import { v4 as uuidv4 } from "uuid"; export default { name: "mobile-location-modal-questions", - emits: ["update:modelValue", "updated-mobile-fee-part", "updated-contains-military-base"], + emits: ["update:modelValue", "updated-mobile-fee-part", "updated-contains-military-base", "updated-bill-to-account-number"], data() { return { internalModel: deepClone(this.modelValue), @@ -266,11 +267,16 @@ export default { "service-location" ); + const billToAccountNumber = await getBillToAccountNumber( + this.internalModel.zipCodeCtu + ); + // update content related to service zip code this.$emit("updated-mobile-fee-part", mobileFeePart); this.$emit("updated-serviceability", serviceabilityDetails.data); this.$emit("updated-contains-military-base", zipCodeData.containsMilitaryBase); this.$emit("updated-mobile-ctu", zipCodeData.zipCodeCtu); + this.$emit("updated-bill-to-account-number", billToAccountNumber); // update the page level model this.$emit("update:modelValue", this.internalModel); diff --git a/src/layouts/service-location/service-location.vue b/src/layouts/service-location/service-location.vue index f9a2ec240..badd8a204 100644 --- a/src/layouts/service-location/service-location.vue +++ b/src/layouts/service-location/service-location.vue @@ -19,6 +19,7 @@ @updated-mobile-fee-part="setMobileFeePart" @updated-serviceability="setServiceabilityDetails" @updated-contains-military-base="setContainsMilitaryBase" + @updated-bill-to-account-number="setBillToAccountNumber" linkWidgetName="ServiceZipLinkWidget" modalWidgetName="ServiceZipModalWidget" /> @@ -191,6 +192,7 @@ export default { mobileFeePart: null, zipContainsMilitaryBase: false, zipCodeCtu: null, + billToAccountNumber: null, shopProviderData: null, navigatingForward: false, }; @@ -437,6 +439,9 @@ export default { this.zipContainsMilitaryBase = val; } }, + setBillToAccountNumber(val) { + this.billToAccountNumber = val; + }, setCtuForMobile(val) { this.zipCodeCtu = val; }, @@ -601,6 +606,14 @@ export default { }, false ); + console.log(this.billToAccountNumber); + if (this.billToAccountNumber) { + this.dispatchStoreAction( + this.storeActions.SAVE_BILL_TO_ACCOUNT_NUMBER, + this.billToAccountNumber, + false + ); + } this.updateAndSaveSupportingItems(); this.$router.navigateWithSaving(this.navigationScenarios.CLICKED_FORWARD, this.$route); diff --git a/src/layouts/service-location/service-zip-modal-question/service-zip-modal-question.vue b/src/layouts/service-location/service-zip-modal-question/service-zip-modal-question.vue index 841dfe153..5272ab52e 100644 --- a/src/layouts/service-location/service-zip-modal-question/service-zip-modal-question.vue +++ b/src/layouts/service-location/service-zip-modal-question/service-zip-modal-question.vue @@ -46,11 +46,12 @@ import alert from "@/ux-components/alert/alert"; import { getPricedMobileFeePart, getServiceabilityDetails, + getBillToAccountNumber } from "@/layouts/service-location/helpers/service-location-helper/service-location-helper"; export default { name: "service-zip-modal-question", - emits: ["update:modelValue", "updated-mobile-fee-part", "updated-contains-military-base"], + emits: ["update:modelValue", "updated-mobile-fee-part", "updated-contains-military-base", "updated-bill-to-account-number"], data() { return { internalModel: this.copyModel(this.modelValue), @@ -165,10 +166,15 @@ export default { "service-location" ); + const billToAccountNumber = await getBillToAccountNumber( + this.internalModel.zipCodeCtu + ); + // update content related to service zip code this.$emit("updated-mobile-fee-part", mobileFeePart); this.$emit("updated-serviceability", serviceabilityDetails.data); this.$emit("updated-contains-military-base", zipCodeData.containsMilitaryBase); + this.$emit("updated-bill-to-account-number", billToAccountNumber); // update the page level model this.$emit("update:modelValue", this.internalModel); diff --git a/src/store/index.js b/src/store/index.js index 130f1e7c1..6cd534730 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -1881,6 +1881,7 @@ export const actions = { }, isInsurance: order.payment.isInsurance, parentAccountNumber: order.payment.parentAccountNumber, + billToAccountNumber: order.payment.billToAccountNumber, inactivePromos: order.payment.inactivePromos, isCreditCard: order.payment.piaType == paymentMethods.CREDIT_CARD ? true : false, @@ -2669,6 +2670,10 @@ export const actions = { return revalidateResponse?.data; }, + /////////////////////////// + // Account Service Calls // + /////////////////////////// + // List all insurance companies async getInsuranceCompanyList(context, { pageNameToLog }) { const insuranceCompanyList = await globalMethods.callHttpClient({ @@ -2691,6 +2696,40 @@ export const actions = { return 0; }); }, + // Get BillToAccountNumber + async getBillToAccountNumber( + context, + { + payload: { + parentAccountNumber = context.getters.order.payment.parentAccountNumber, + providerNumber = context.getters.order.serviceLocation.zipCodeCtu, + isItac = context.getters.order.policy.isItac, + }, + pageNameToLog, + } + ) { + // Cash orders default to 87291 - update if/when more detailed + // billToAccountNumbers are needed for cash + if (parentAccountNumber == applicationConfig.CASH_PARENT_ACCOUNT_NUMBER) { + return applicationConfig.CASH_DEFAULT_BILL_TO_ACCOUNT_NUMBER; + } + const queryString = + `ParentAccountNumber=${parentAccountNumber}` + + `&ProviderNumber=${providerNumber}` + + `&IsItac=${isItac}`; + + const billToAccountNumberResponse = await globalMethods.callHttpClient({ + method: endpoints.GetBillToAccountNumber.method, + endpoint: `${endpoints.GetBillToAccountNumber.url}?${queryString}`, + logApiCall: true, + pageNameToLog: pageNameToLog, + }); + + return billToAccountNumberResponse.data.toString(); + }, + ////////////////////////////////// + // END OF Account Service Calls // + ////////////////////////////////// // Misc order actions saveSchedule(context, scheduleInfo) {