From 26fab3ddbaa23b24e76f3308ce33296078305b1d Mon Sep 17 00:00:00 2001 From: Chris Redelinghuys Date: Fri, 28 Feb 2025 15:15:53 -0500 Subject: [PATCH 1/2] CASH-70: Add MSR fee to order for insurance but don't show in cart. --- src/constants/store-actions.js | 1 + src/constants/store-mutations.js | 1 + src/fmg-components/cart/cart.spec.js | 4 ++ src/fmg-components/cart/cart.vue | 19 ++++++++- .../service-location/service-location.vue | 40 +++++++++++++++---- src/store/index.js | 10 +++++ 6 files changed, 65 insertions(+), 10 deletions(-) diff --git a/src/constants/store-actions.js b/src/constants/store-actions.js index 42dc27e4f..6c6ba62b7 100644 --- a/src/constants/store-actions.js +++ b/src/constants/store-actions.js @@ -105,6 +105,7 @@ const storeActions = { SAVE_PAYPAL_TOKEN: "savePaypalToken", SAVE_NEXTGEN_SETTLED_AMOUNT: "saveNextGenSettledAmount", SAVE_IS_RECAL_ACK_OPT_IN: "saveIsRecalAckOptIn", + SAVE_IS_MSR_FEE_APPLICABLE: "saveIsMSRFeeApplicable", CREATE_SUBMITTED_ORDER: "createSubmittedOrder", RESET_SUBMITTED_ORDER: "resetSubmittedOrder", diff --git a/src/constants/store-mutations.js b/src/constants/store-mutations.js index dceeac63e..69e78138b 100644 --- a/src/constants/store-mutations.js +++ b/src/constants/store-mutations.js @@ -64,6 +64,7 @@ const storeMutations = { LOCK_TOKEN: "updateLockToken", UPDATE_SETTLED_TENDER_AMOUNT: "updateSettledTenderAmount", UPDATE_IS_RECAL_ACK_OPT_IN: "updateIsRecalAckOptIn", + UPDATE_IS_MSR_FEE_APPLICABLE: "updateIsMSRFeeApplicable", // EVENT BUS MUTATIONS ADD_EVENT_TO_BUS: "addEventToBus", diff --git a/src/fmg-components/cart/cart.spec.js b/src/fmg-components/cart/cart.spec.js index 5adff3ab3..4734143bf 100644 --- a/src/fmg-components/cart/cart.spec.js +++ b/src/fmg-components/cart/cart.spec.js @@ -5,6 +5,8 @@ import cart from "@/fmg-components/cart/cart.vue"; import { shallowMount } from "@vue/test-utils"; import { getMountOptions } from "@/helpers/unit-test-helper.js"; +import store from "@/store"; + global.$logger = { logInformation: jest.fn(), logWarning: jest.fn(), @@ -266,6 +268,7 @@ describe("cart.vue", () => { // Mobile Fee Cart Item test("if there is mobile fee on the order, a mobile fee cart item should be added to the cart", () => { // Arrange + store.getters.order.isMSRFeeApplicable = false; const lineItems = { glassParts: [], supportingItems: [ @@ -403,6 +406,7 @@ function setupMocks({ options, props }) { if (props) mountOptions.propsData = props; mountOptions.global.mixins = [mockBaseMixin]; + mountOptions.global.mocks["$store"] = store; const wrapper = shallowMount(cart, mountOptions); diff --git a/src/fmg-components/cart/cart.vue b/src/fmg-components/cart/cart.vue index c4a8e4900..c3db8c830 100644 --- a/src/fmg-components/cart/cart.vue +++ b/src/fmg-components/cart/cart.vue @@ -750,7 +750,7 @@ export default { return this.getCmsContent("RecycleFeeTextWidget", "Text"); }, showRecycleFeeCartItem() { - if (!this.isInsurance || this.isItac || this.isNoComp) { + if (this.isCashItacNoComp) { // CASH, ITAC, NOCOMP ORDERS return !this.isRepair; } else { @@ -843,11 +843,18 @@ export default { return cartItem; }, + isCashItacNoComp() { + return !this.isInsurance || this.isITAC || this.isNoComp; + }, + getIsMSRFeeApplicableFromStore() { + return this.$store.getters.order.isMSRFeeApplicable; + }, mobileFeeCartItemName() { return this.getCmsContent("MobileServiceTextWidget", "Text"); }, mobileFeeCartItem() { let cartItem = null; + let showMobileFeeCartItem = false; const mobileFeeLineItem = this.supportingItems.find( (lineItem) => lineItem.partType == partTypeStrings.MOBILE_FEE ); @@ -857,7 +864,15 @@ export default { (mobileFeeLineItem?.laborAmount ?? 0) + (mobileFeeLineItem?.sellingPrice ?? 0); - if (mobileFeeLineItem && mobileTotal > 0) { + if (mobileTotal > 0) { + if (this.getIsMSRFeeApplicableFromStore) { + showMobileFeeCartItem = this.isCashItacNoComp; + } else { + showMobileFeeCartItem = true; + } + } + + if (mobileFeeLineItem && showMobileFeeCartItem) { cartItem = { name: this.mobileFeeCartItemName, category: cartItemCategories.SUPPORTING_ITEMS, diff --git a/src/layouts/service-location/service-location.vue b/src/layouts/service-location/service-location.vue index 7b89b847d..ddb765da3 100644 --- a/src/layouts/service-location/service-location.vue +++ b/src/layouts/service-location/service-location.vue @@ -307,7 +307,7 @@ export default { return ( this.displayMSR && this.mobileFeePart?.partNumber == partNumberStrings.MOBILE_STATIC_RECAL_FEE && - (this.isInsurance && !this.isITAC ? this.mobileFeePart?.isInsurable : true) + (this.isCashItacNoComp || this.mobileFeePart?.isInsurable) ); }, displayMSR() { @@ -317,19 +317,25 @@ export default { ?.toLowerCase() === "true" ); }, - mobileFeeApplies() { - if ( + isCashItacNoComp() { + return !this.isInsurance || this.isITAC || this.isNoComp; + }, + mobileFeeHasPrice() { + return ( this.mobileFeePart?.laborAmount > 0 || this.mobileFeePart?.sellingPrice > 0 || this.mobileFeePart?.kitPrice > 0 - ) { - return true; + ); + }, + mobileFeeApplies() { + if (this.isMobileStaticRecalibrationApplicable && this.mobileFeeHasPrice) { + return this.isCashItacNoComp; } else { - return false; + return this.mobileFeeHasPrice; } }, showMobileFreeAlert() { - if (this.isServiceableMobile && !this.isInsurance && !this.mobileFeeApplies) { + if (this.isServiceableMobile && !this.isInsurance && !this.mobileFeeHasPrice) { return true; } return false; @@ -387,6 +393,9 @@ export default { isITAC() { return store.getters.order.policy.isItac; }, + isNoComp() { + return store.getters.order.policy.isNoComp; + }, }, methods: { arePagePrerequisitesValid() { @@ -572,8 +581,22 @@ export default { ); } }, + updateAndSaveIsMSRFeeApplicable() { + const isMSRFeeApplicable = + this.isMobileStaticRecalibrationApplicable && + this.selectedAppointmentType == "Mobile"; + this.dispatchStoreAction( + this.storeActions.SAVE_IS_MSR_FEE_APPLICABLE, + isMSRFeeApplicable + ); + }, updateAndSaveSupportingItems() { - const supportingItems = store.getters.lineItems.supportingItems; + let supportingItems = store.getters.lineItems.supportingItems; + + supportingItems = + !supportingItems && this.isMobileStaticRecalibrationApplicable + ? [] + : supportingItems; // for insurance orders, fees can get removed causing supportingitems to be null or empty if (!supportingItems) { @@ -676,6 +699,7 @@ export default { } this.updateAndSaveSupportingItems(); + this.updateAndSaveIsMSRFeeApplicable(); this.$router.navigateWithSaving(this.navigationScenarios.CLICKED_FORWARD, this.$route); }, openModalAction(modalName) { diff --git a/src/store/index.js b/src/store/index.js index 3408c0b26..86b57d1f9 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -176,6 +176,7 @@ const getDefaultState = () => { lockToken: null, settledTenderAmount: 0, isRecalAckOptIn: false, + isMSRFeeApplicable: false, }, applicationUser: { eventBus: [], @@ -315,6 +316,9 @@ export const mutations = { updateIsRecalAckOptIn(state, isRecalAckOptIn) { state.order.isRecalAckOptIn = isRecalAckOptIn; }, + updateIsMSRFeeApplicable(state, isMSRFeeApplicable) { + state.order.isMSRFeeApplicable = isMSRFeeApplicable; + }, updateCCToken(state, ccToken) { state.order.payment.ccToken.subscriptionId = ccToken.subscriptionId; state.order.payment.ccToken.expMonth = ccToken.expMonth; @@ -634,6 +638,7 @@ export const mutations = { state.order.eon = sessionInformation.order.eon; state.order.customerPortalLoginToken = sessionInformation.order.CustomerPortalLoginToken; state.order.isRecalAckOptIn = sessionInformation.order.isRecalAckOptIn; + state.order.isMSRFeeApplicable = sessionInformation.order.isMSRFeeApplicable; if (state.order.vehicle.vin !== sessionInformation.order.vehicle?.vin) { state.applicationUser.pageData[fmgPageValues.PART_QUESTIONS] = null; @@ -2233,6 +2238,7 @@ export const actions = { createUnscheduledStatusWorkOrderForPIA: createUnscheduledStatusWorkOrderForPIA, lockToken: order.lockToken, isRecalAckOptIn: order.isRecalAckOptIn, + isMSRFeeApplicable: order.isMSRFeeApplicable, }, }, logApiCall: true, @@ -2631,6 +2637,10 @@ export const actions = { context.commit(storeMutations.UPDATE_IS_RECAL_ACK_OPT_IN, isRecalAckOptIn); }, + saveIsMSRFeeApplicable(context, isMSRFeeApplicable) { + context.commit(storeMutations.UPDATE_IS_MSR_FEE_APPLICABLE, isMSRFeeApplicable); + }, + saveParentAccountNumber(context, parentAccountNumber) { context.commit(storeMutations.UPDATE_PARENT_ACCT_NUMBER, parentAccountNumber); }, From ccd1e372dddca316ca6e9ef7c671faba002011d6 Mon Sep 17 00:00:00 2001 From: Chris Redelinghuys Date: Fri, 28 Feb 2025 16:30:21 -0500 Subject: [PATCH 2/2] CASH-70 --- src/store/index.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/store/index.js b/src/store/index.js index 86b57d1f9..a7e7c6ae9 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -638,7 +638,6 @@ export const mutations = { state.order.eon = sessionInformation.order.eon; state.order.customerPortalLoginToken = sessionInformation.order.CustomerPortalLoginToken; state.order.isRecalAckOptIn = sessionInformation.order.isRecalAckOptIn; - state.order.isMSRFeeApplicable = sessionInformation.order.isMSRFeeApplicable; if (state.order.vehicle.vin !== sessionInformation.order.vehicle?.vin) { state.applicationUser.pageData[fmgPageValues.PART_QUESTIONS] = null;