CASH-1713 | Insurance pricing error (tax refactor)
Moved helper function to a helper file Price all line items on payment-method just in case something isn't in serverData yet
This commit is contained in:
parent
dbcf5351ae
commit
bb293cf0fc
3 changed files with 37 additions and 36 deletions
|
|
@ -99,3 +99,23 @@ export async function getPricingByDayPartWithPrice(pageNameToLog) {
|
||||||
|
|
||||||
return pricingResults[0];
|
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;
|
||||||
|
}
|
||||||
|
|
@ -155,7 +155,6 @@ import {
|
||||||
getNewlyInactivatedPromos,
|
getNewlyInactivatedPromos,
|
||||||
} from "@/helpers/promotions-helper";
|
} from "@/helpers/promotions-helper";
|
||||||
import { queryStrings } from "@/constants/query-strings";
|
import { queryStrings } from "@/constants/query-strings";
|
||||||
import { getQuerystringParameter } from "@/helpers/querystring-helper";
|
|
||||||
import { deepClone } from "@/helpers/object-helper";
|
import { deepClone } from "@/helpers/object-helper";
|
||||||
|
|
||||||
import { Form } from "vee-validate";
|
import { Form } from "vee-validate";
|
||||||
|
|
@ -163,17 +162,12 @@ import { defineRule } from "vee-validate";
|
||||||
import { required } from "@/helpers/validation-rules";
|
import { required } from "@/helpers/validation-rules";
|
||||||
import { errorMessages } from "@/constants/error-messages";
|
import { errorMessages } from "@/constants/error-messages";
|
||||||
import { AppointmentTypeStrings } from "@/constants/schedule-constants";
|
import { AppointmentTypeStrings } from "@/constants/schedule-constants";
|
||||||
import { partTypeStrings } from "@/constants/part-type-strings";
|
|
||||||
import { mapTaxedLineItemsToStoreFormat } from "../../store";
|
|
||||||
import { coverageStatus } from "@/constants/insurance";
|
import { coverageStatus } from "@/constants/insurance";
|
||||||
import { containsLineItemWithPartType } from "@/helpers/service-package-helper";
|
|
||||||
import { containsRecalParts } from "@/helpers/recal-helper";
|
import { containsRecalParts } from "@/helpers/recal-helper";
|
||||||
import { getBoolFromString } from "@/helpers/boolean-helper";
|
import { getBoolFromString } from "@/helpers/boolean-helper";
|
||||||
import {
|
import {
|
||||||
getDisplayAmountDue,
|
|
||||||
getAmountDue,
|
getAmountDue,
|
||||||
getSubTotal,
|
addPricesToLineItems
|
||||||
getSalesTax,
|
|
||||||
} from "@/helpers/pricing-helper.js";
|
} from "@/helpers/pricing-helper.js";
|
||||||
import { consumeQueryFromStash } from "@/router/methods/helpers/querystring-stash";
|
import { consumeQueryFromStash } from "@/router/methods/helpers/querystring-stash";
|
||||||
import { debugLog } from "@/helpers/debug-log-helper";
|
import { debugLog } from "@/helpers/debug-log-helper";
|
||||||
|
|
@ -231,21 +225,28 @@ export default {
|
||||||
|
|
||||||
const availableVaps = [resultMap.rainRepel, ...resultMap.wipers];
|
const availableVaps = [resultMap.rainRepel, ...resultMap.wipers];
|
||||||
|
|
||||||
const pricedAvailableVaps = await baseMixin.methods.dispatchStoreActionWithLogging(
|
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(
|
||||||
storeActions.PRICE_ORDER_ITEMS_AND_SAVE_SERVER_DATA,
|
storeActions.PRICE_ORDER_ITEMS_AND_SAVE_SERVER_DATA,
|
||||||
{
|
{
|
||||||
availableLineItems: availableVaps,
|
availableLineItems: lineItemsOnOrderAndAvailableVaps,
|
||||||
},
|
},
|
||||||
"payment-method",
|
"payment-method",
|
||||||
false
|
false
|
||||||
);
|
);
|
||||||
|
|
||||||
const lineItemsOnOrderAndAvailableVaps = [
|
// Add prices to the availableVaps
|
||||||
...pricedAvailableVaps,
|
const pricedAvailableVaps = addPricesToLineItems(availableVaps, pricedLineItems);
|
||||||
...glassParts,
|
|
||||||
...supportingItems,
|
|
||||||
...vaps,
|
|
||||||
];
|
|
||||||
|
|
||||||
// Promo logic
|
// Promo logic
|
||||||
// Populate the previous state of promos for toast message usage in "next()"
|
// Populate the previous state of promos for toast message usage in "next()"
|
||||||
|
|
@ -265,7 +266,6 @@ export default {
|
||||||
delete lineItemsForCart.serverData;
|
delete lineItemsForCart.serverData;
|
||||||
|
|
||||||
// End of promo logic
|
// End of promo logic
|
||||||
//
|
|
||||||
|
|
||||||
const vapsToAddToCart = getVapsThatNeedToBeAddedToSatisfyPromos(
|
const vapsToAddToCart = getVapsThatNeedToBeAddedToSatisfyPromos(
|
||||||
lineItemsForCart.promos ?? [],
|
lineItemsForCart.promos ?? [],
|
||||||
|
|
|
||||||
|
|
@ -59,6 +59,7 @@ import {
|
||||||
} from "@/helpers/recal-helper";
|
} from "@/helpers/recal-helper";
|
||||||
import { externalParameterStatus } from "@/constants/external-parameters";
|
import { externalParameterStatus } from "@/constants/external-parameters";
|
||||||
import { experimentSettings } from "@/constants/experiments";
|
import { experimentSettings } from "@/constants/experiments";
|
||||||
|
import { addPricesToLineItems } from "@/helpers/pricing-helper";
|
||||||
|
|
||||||
// Export State
|
// Export State
|
||||||
const getDefaultState = () => {
|
const getDefaultState = () => {
|
||||||
|
|
@ -3701,26 +3702,6 @@ function convertGlassPieceNamingFromApi(glassArray) {
|
||||||
return 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 = []) {
|
function addTaxesToPricedLineItems(pricedLineItems, taxingLineItems = []) {
|
||||||
pricedLineItems.forEach((pricedLineItem) => {
|
pricedLineItems.forEach((pricedLineItem) => {
|
||||||
const lineItemIndex = taxingLineItems.findIndex(
|
const lineItemIndex = taxingLineItems.findIndex(
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue