From 5aacb6ec2ac9efa0bc5ae70c0fe1a1543818bf07 Mon Sep 17 00:00:00 2001 From: Minojhini Valaiyapathi Date: Wed, 7 May 2025 12:57:30 -0400 Subject: [PATCH] CASH-535 - updated 'cashSubTotal' to be 'cashPriceSubTotal' and to match the logic of 'priceSubTotal' --- src/constants/analytics.js | 14 +------------- src/constants/store-mutations.js | 2 +- src/helpers/heritage-integration/order-helper.js | 16 ++++++++++++++++ .../service-package-question.vue | 8 +------- src/mixins/analytics-mixin.js | 12 ++++++++++++ src/store/index.js | 7 ++++--- 6 files changed, 35 insertions(+), 24 deletions(-) diff --git a/src/constants/analytics.js b/src/constants/analytics.js index 3461d82d1..fe43be06d 100644 --- a/src/constants/analytics.js +++ b/src/constants/analytics.js @@ -42,16 +42,4 @@ const ValueToLogTypes = { LAST_5: "last_5", }; -const Variables = { - CASH_SUBTOTAL: "cashSubTotal", -}; - -export { - analyticsPageEvents, - GaCategories, - GaActions, - GaLabels, - GaEvents, - ValueToLogTypes, - Variables, -}; +export { analyticsPageEvents, GaCategories, GaActions, GaLabels, GaEvents, ValueToLogTypes }; diff --git a/src/constants/store-mutations.js b/src/constants/store-mutations.js index 89c82e3c9..5064864d0 100644 --- a/src/constants/store-mutations.js +++ b/src/constants/store-mutations.js @@ -69,7 +69,7 @@ const storeMutations = { UPDATE_SETTLED_TENDER_AMOUNT: "updateSettledTenderAmount", UPDATE_IS_RECAL_ACK_OPT_IN: "updateIsRecalAckOptIn", UPDATE_IS_MSR_FEE_APPLICABLE: "updateIsMSRFeeApplicable", - UPDATE_CASH_SUBTOTAL: "updateCashSubTotal", + UPDATE_CASH_PRICE_SUBTOTAL: "updateCashPriceSubTotal", // EVENT BUS MUTATIONS ADD_EVENT_TO_BUS: "addEventToBus", diff --git a/src/helpers/heritage-integration/order-helper.js b/src/helpers/heritage-integration/order-helper.js index 76729e49f..11750108c 100644 --- a/src/helpers/heritage-integration/order-helper.js +++ b/src/helpers/heritage-integration/order-helper.js @@ -83,6 +83,22 @@ export async function saveSession({ if (!store.getters.applicationUser.savedSessionId || shouldAwaitSaveSessionQueue) { await saveSessionPromise; } + + const lineItems = store.getters.order?.lineItems ?? {}; + const combinedLineItems = [ + ...(lineItems.glassParts || []), + ...(lineItems.supportingItems || []), + ...(lineItems.vaps || []), + ...(lineItems.promos || []), + ]; + + const cashPriceSubtotal = combinedLineItems.length + ? baseMixin.methods + .getTotalPriceOfAllLineItemsAndChildParts(combinedLineItems, false) + .toFixed(2) + : ""; + + store.commit(storeMutations.UPDATE_CASH_PRICE_SUBTOTAL, cashPriceSubtotal); } export async function submitWorkOrder({ diff --git a/src/layouts/quote/service-package-question/service-package-question.vue b/src/layouts/quote/service-package-question/service-package-question.vue index 10dfb2724..546bb573a 100644 --- a/src/layouts/quote/service-package-question/service-package-question.vue +++ b/src/layouts/quote/service-package-question/service-package-question.vue @@ -163,13 +163,7 @@ export default { isInsuranceSelected: this.isInsuranceSelected, }, })); - if (availablePackages.length > 1 || availablePackages.length == 1) { - let price = this.getPackagePrice(availablePackages[0].packageName, { - discountedPrice: false, - servicePackageDiscount: false, - }); - store.commit(storeMutations.UPDATE_CASH_SUBTOTAL, price?.toFixed(2)); - } + this.$emit("currentNumberOfPackages", modifiedAnswers.length); return modifiedAnswers; }, diff --git a/src/mixins/analytics-mixin.js b/src/mixins/analytics-mixin.js index 05d6f2632..b1df7156c 100644 --- a/src/mixins/analytics-mixin.js +++ b/src/mixins/analytics-mixin.js @@ -311,6 +311,18 @@ export default { } else { payload.priceSubTotal = ""; } + + // Cash Quote or Cash Price Sub Total + if (isPricingAvailable) { + const subtotal = baseMixin.methods + .getTotalPriceOfAllLineItemsAndChildParts(combinedLineItems, false) + .toFixed(2); + + payload.cashPriceSubTotal = parseFloat(subtotal); + } else { + payload.cashPriceSubTotal = ""; + } + //unverified (in scenarios we don’t display the price) if ( order.payment.isInsurance && diff --git a/src/store/index.js b/src/store/index.js index 973108d3f..53ec6864e 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -340,8 +340,9 @@ export const mutations = { updateIsMSRFeeApplicable(state, isMSRFeeApplicable) { state.order.isMSRFeeApplicable = isMSRFeeApplicable; }, - updateCashSubTotal(state, cashSubTotal) { - state.order.cashSubTotal = cashSubTotal; + updateCashPriceSubTotal(state, cashPriceSubTotal) { + state.order.cashPriceSubTotal = + cashPriceSubTotal === "" ? null : cashPriceSubTotal.toString(); }, updateCCToken(state, ccToken) { state.order.payment.ccToken.subscriptionId = ccToken.subscriptionId; @@ -2342,7 +2343,7 @@ export const actions = { lockToken: order.lockToken, isRecalAckOptIn: order.isRecalAckOptIn, isMSRFeeApplicable: order.isMSRFeeApplicable, - cashSubTotal: order.cashSubTotal, + cashPriceSubTotal: order.cashPriceSubTotal, }, }, logApiCall: true,