Merge pull request #2903 from Safelite/feature/CASH-1713
CASH-1713 | Insurance pricing error (tax refactor)
This commit is contained in:
commit
2a2e3383d2
3 changed files with 37 additions and 39 deletions
|
|
@ -99,3 +99,23 @@ 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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -155,7 +155,6 @@ 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";
|
||||
|
|
@ -163,18 +162,10 @@ 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 {
|
||||
getDisplayAmountDue,
|
||||
getAmountDue,
|
||||
getSubTotal,
|
||||
getSalesTax,
|
||||
} from "@/helpers/pricing-helper.js";
|
||||
import { getAmountDue, addPricesToLineItems } 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";
|
||||
|
|
@ -231,21 +222,28 @@ export default {
|
|||
|
||||
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,
|
||||
{
|
||||
availableLineItems: availableVaps,
|
||||
availableLineItems: lineItemsOnOrderAndAvailableVaps,
|
||||
},
|
||||
"payment-method",
|
||||
false
|
||||
);
|
||||
|
||||
const lineItemsOnOrderAndAvailableVaps = [
|
||||
...pricedAvailableVaps,
|
||||
...glassParts,
|
||||
...supportingItems,
|
||||
...vaps,
|
||||
];
|
||||
// Add prices to the availableVaps
|
||||
const pricedAvailableVaps = addPricesToLineItems(availableVaps, pricedLineItems);
|
||||
|
||||
// Promo logic
|
||||
// Populate the previous state of promos for toast message usage in "next()"
|
||||
|
|
@ -265,7 +263,6 @@ export default {
|
|||
delete lineItemsForCart.serverData;
|
||||
|
||||
// End of promo logic
|
||||
//
|
||||
|
||||
const vapsToAddToCart = getVapsThatNeedToBeAddedToSatisfyPromos(
|
||||
lineItemsForCart.promos ?? [],
|
||||
|
|
|
|||
|
|
@ -59,6 +59,7 @@ 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 = () => {
|
||||
|
|
@ -3701,26 +3702,6 @@ 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(
|
||||
|
|
|
|||
Loading…
Reference in a new issue