diff --git a/src/helpers/pricing-helper.js b/src/helpers/pricing-helper.js index 0a8b85d7e..9aa317353 100644 --- a/src/helpers/pricing-helper.js +++ b/src/helpers/pricing-helper.js @@ -99,23 +99,3 @@ export async function getPricingByDayPartWithPrice(pageNameToLog) { return pricingResults[0]; } - -export function addPricesToLineItems(lineItems, pricingLineItems) { - lineItems.forEach((lineItem) => { - const lineItemIndex = pricingLineItems.findIndex( - (pricingLineItem) => pricingLineItem.partNumber === lineItem.partNumber - ); - - if (lineItem.childParts) { - addPricesToLineItems(lineItem.childParts, pricingLineItems); - } - - const pricedLineItem = pricingLineItems.splice(lineItemIndex, 1)[0]; - lineItem.laborAmount = pricedLineItem.laborAmount; - lineItem.sellingPrice = pricedLineItem.sellingPrice; - lineItem.kitPrice = pricedLineItem.kitPrice; - lineItem.salesTax = pricedLineItem.salesTax; - }); - - return lineItems; -} diff --git a/src/layouts/payment-method/payment-method.vue b/src/layouts/payment-method/payment-method.vue index abee992bf..ffb3d2353 100644 --- a/src/layouts/payment-method/payment-method.vue +++ b/src/layouts/payment-method/payment-method.vue @@ -155,6 +155,7 @@ import { getNewlyInactivatedPromos, } from "@/helpers/promotions-helper"; import { queryStrings } from "@/constants/query-strings"; +import { getQuerystringParameter } from "@/helpers/querystring-helper"; import { deepClone } from "@/helpers/object-helper"; import { Form } from "vee-validate"; @@ -162,10 +163,18 @@ import { defineRule } from "vee-validate"; import { required } from "@/helpers/validation-rules"; import { errorMessages } from "@/constants/error-messages"; import { AppointmentTypeStrings } from "@/constants/schedule-constants"; +import { partTypeStrings } from "@/constants/part-type-strings"; +import { mapTaxedLineItemsToStoreFormat } from "../../store"; import { coverageStatus } from "@/constants/insurance"; +import { containsLineItemWithPartType } from "@/helpers/service-package-helper"; import { containsRecalParts } from "@/helpers/recal-helper"; import { getBoolFromString } from "@/helpers/boolean-helper"; -import { getAmountDue, addPricesToLineItems } from "@/helpers/pricing-helper.js"; +import { + getDisplayAmountDue, + getAmountDue, + getSubTotal, + getSalesTax, +} from "@/helpers/pricing-helper.js"; import { consumeQueryFromStash } from "@/router/methods/helpers/querystring-stash"; import { debugLog } from "@/helpers/debug-log-helper"; import { ErrorMessage } from "vee-validate"; @@ -222,28 +231,21 @@ export default { const availableVaps = [resultMap.rainRepel, ...resultMap.wipers]; - const lineItemsOnOrderAndAvailableVaps = [ - ...availableVaps, - ...glassParts, - ...supportingItems, - ...vaps, - ]; - - // All line items are already priced except availableVaps - // Price everything again to ensure that serverData has all values - // Specifically this addresses an error where insurance client glass parts are not in serverData - // See CASH-1713 for details - const pricedLineItems = await baseMixin.methods.dispatchStoreActionWithLogging( + const pricedAvailableVaps = await baseMixin.methods.dispatchStoreActionWithLogging( storeActions.PRICE_ORDER_ITEMS_AND_SAVE_SERVER_DATA, { - availableLineItems: lineItemsOnOrderAndAvailableVaps, + availableLineItems: availableVaps, }, "payment-method", false ); - // Add prices to the availableVaps - const pricedAvailableVaps = addPricesToLineItems(availableVaps, pricedLineItems); + const lineItemsOnOrderAndAvailableVaps = [ + ...pricedAvailableVaps, + ...glassParts, + ...supportingItems, + ...vaps, + ]; // Promo logic // Populate the previous state of promos for toast message usage in "next()" @@ -263,6 +265,7 @@ export default { delete lineItemsForCart.serverData; // End of promo logic + // const vapsToAddToCart = getVapsThatNeedToBeAddedToSatisfyPromos( lineItemsForCart.promos ?? [], diff --git a/src/store/index.js b/src/store/index.js index ef67b84a0..1fa9b4f14 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -59,7 +59,6 @@ import { } from "@/helpers/recal-helper"; import { externalParameterStatus } from "@/constants/external-parameters"; import { experimentSettings } from "@/constants/experiments"; -import { addPricesToLineItems } from "@/helpers/pricing-helper"; // Export State const getDefaultState = () => { @@ -3702,6 +3701,26 @@ function convertGlassPieceNamingFromApi(glassArray) { return glassArray; } +function addPricesToLineItems(lineItems, pricingLineItems) { + lineItems.forEach((lineItem) => { + const lineItemIndex = pricingLineItems.findIndex( + (pricingLineItem) => pricingLineItem.partNumber === lineItem.partNumber + ); + + if (lineItem.childParts) { + addPricesToLineItems(lineItem.childParts, pricingLineItems); + } + + const pricedLineItem = pricingLineItems.splice(lineItemIndex, 1)[0]; + lineItem.laborAmount = pricedLineItem.laborAmount; + lineItem.sellingPrice = pricedLineItem.sellingPrice; + lineItem.kitPrice = pricedLineItem.kitPrice; + lineItem.salesTax = pricedLineItem.salesTax; + }); + + return lineItems; +} + function addTaxesToPricedLineItems(pricedLineItems, taxingLineItems = []) { pricedLineItems.forEach((pricedLineItem) => { const lineItemIndex = taxingLineItems.findIndex(