Merge remote-tracking branch 'origin/develop' into feature/skiener/CSR-1520
This commit is contained in:
commit
8601f61442
3 changed files with 91 additions and 0 deletions
|
|
@ -146,6 +146,10 @@ const endpoints = {
|
|||
url: "/price/api/v1/price/revalidated-order-promos",
|
||||
method: "POST",
|
||||
},
|
||||
TaxOrderItems: {
|
||||
url: "/price/api/v1/price/taxed-order-items",
|
||||
method: "GET",
|
||||
},
|
||||
LogExperimentExposureIfAssigned: {
|
||||
url: "/experiments/api/v1/experiments/log-exposure",
|
||||
method: "POST",
|
||||
|
|
|
|||
|
|
@ -41,6 +41,7 @@ const storeActions = {
|
|||
UPDATE_STORE_WITH_SAVE_SESSION_RESPONSE: "updateStoreWithSaveSessionResponse",
|
||||
VALIDATE_ZIP: "validateZip",
|
||||
PRICE_ORDER_ITEMS_AND_SAVE_SERVER_DATA: "priceOrderItemsAndSaveServerData",
|
||||
TAX_ORDER_ITEMS_AND_SAVE_SERVER_DATA: "taxOrderItemsAndSaveServerData",
|
||||
LOG_EXPERIMENT_EXPOSURE: "logExperimentExposure",
|
||||
LOG_PAGE_VIEW: "logPageView",
|
||||
LOG_CUSTOM_EVENT: "logCustomEvent",
|
||||
|
|
|
|||
|
|
@ -2046,14 +2046,18 @@ export const actions = {
|
|||
const zipCodeToUse = serviceZipCode
|
||||
? serviceZipCode
|
||||
: context.getters.order.serviceLocation.zipCode;
|
||||
|
||||
const ctuToUse = serviceZipCodeCtu
|
||||
? serviceZipCodeCtu
|
||||
: context.getters.order.serviceLocation.zipCodeCtu;
|
||||
|
||||
const flattenedLineItemsWithChildParts =
|
||||
getFlattenedArrayOfLineItemsWithChildParts(availableLineItems);
|
||||
|
||||
const lineItemsWithOnlyPartNumbers = flattenedLineItemsWithChildParts.map((lineItem) => ({
|
||||
partNumber: lineItem.partNumber,
|
||||
}));
|
||||
|
||||
const availableLineItemsFormattedForRequest =
|
||||
buildQueryStringParameterFromArrayOfComplexObjects(
|
||||
lineItemsWithOnlyPartNumbers,
|
||||
|
|
@ -2092,6 +2096,68 @@ export const actions = {
|
|||
return pricedLineItems;
|
||||
},
|
||||
|
||||
// Tax order actions
|
||||
async taxOrderItemsAndSaveServerData(
|
||||
context,
|
||||
{
|
||||
payload: {
|
||||
billToAccountNumber,
|
||||
providerNumber,
|
||||
appointmentType,
|
||||
serviceLocationState,
|
||||
serviceLocationZipCode,
|
||||
pricedLineItems,
|
||||
},
|
||||
pageNameToLog,
|
||||
}
|
||||
) {
|
||||
const flattenedLineItemsWithChildParts =
|
||||
getFlattenedArrayOfLineItemsWithChildParts(pricedLineItems);
|
||||
|
||||
const lineItemsWithOnlyPriceInfo = flattenedLineItemsWithChildParts.map((lineItem) => ({
|
||||
partNumber: lineItem.partNumber,
|
||||
laborAmount: lineItem.laborAmount,
|
||||
kitPrice: lineItem.kitPrice,
|
||||
sellingPrice: lineItem.sellingPrice,
|
||||
}));
|
||||
|
||||
const pricedLineItemsFormattedForRequest =
|
||||
buildQueryStringParameterFromArrayOfComplexObjects(
|
||||
lineItemsWithOnlyPriceInfo,
|
||||
"lineItems"
|
||||
);
|
||||
|
||||
let queryString =
|
||||
`ParentAccountNumber=${applicationConfig.CASH_PARENT_ACCOUNT_NUMBER}` +
|
||||
`&BillToAccountNumber=${billToAccountNumber}` +
|
||||
`&ProviderNumber=${providerNumber}` +
|
||||
`&AppointmentType=${appointmentType}` +
|
||||
`&ServiceLocation.State=${serviceLocationState}` +
|
||||
`&ServiceLocation.ZipCode=${serviceLocationZipCode}` +
|
||||
`&${pricedLineItemsFormattedForRequest}`;
|
||||
|
||||
const lineItemServerData = context.getters.order.lineItems.serverData;
|
||||
if (lineItemServerData) {
|
||||
queryString += `&ServerData=${encodeURIComponent(lineItemServerData)}`;
|
||||
}
|
||||
|
||||
const response = await globalMethods.callHttpClient({
|
||||
method: endpoints.TaxOrderItems.method,
|
||||
endpoint: `${endpoints.TaxOrderItems.url}?${queryString}`,
|
||||
logApiCall: true,
|
||||
pageNameToLog: pageNameToLog,
|
||||
});
|
||||
|
||||
context.commit(storeMutations.UPDATE_LINE_ITEMS_SERVER_DATA, response.data.serverData);
|
||||
|
||||
const taxedLineItems = addTaxesToPricedLineItems(
|
||||
pricedLineItems,
|
||||
response.data.taxedLineItems
|
||||
);
|
||||
|
||||
return taxedLineItems;
|
||||
},
|
||||
|
||||
async validateOrderPromoAndSaveServerData(
|
||||
context,
|
||||
{ payload: { promoCode, addableVaps }, pageNameToLog }
|
||||
|
|
@ -2391,17 +2457,37 @@ function addPricesToLineItems(lineItems, pricingLineItems) {
|
|||
let lineItemIndex = pricingLineItems.findIndex(
|
||||
(pricingLineItem) => pricingLineItem.partNumber === lineItem.partNumber
|
||||
);
|
||||
|
||||
if (lineItem.childParts) {
|
||||
addPricesToLineItems(lineItem.childParts, pricingLineItems);
|
||||
}
|
||||
|
||||
let pricedLineItem = pricingLineItems.splice(lineItemIndex, 1)[0];
|
||||
lineItem.laborAmount = pricedLineItem.laborAmount;
|
||||
lineItem.sellingPrice = pricedLineItem.sellingPrice;
|
||||
lineItem.kitPrice = pricedLineItem.kitPrice;
|
||||
});
|
||||
|
||||
return pricedLineItems;
|
||||
}
|
||||
|
||||
function addTaxesToPricedLineItems(lineItems, taxingLineItems) {
|
||||
lineItems.forEach((lineItem) => {
|
||||
let lineItemIndex = taxingLineItems.findIndex(
|
||||
(taxingLineItem) => taxingLineItem.partNumber === lineItem.partNumber
|
||||
);
|
||||
|
||||
if (lineItem.childParts) {
|
||||
addTaxesToPricedLineItems(lineItem.childParts, taxingLineItems);
|
||||
}
|
||||
|
||||
let taxedLineItem = taxingLineItems.splice(lineItemIndex, 1)[0];
|
||||
lineItem.SalesTax = taxedLineItem.SalesTax;
|
||||
});
|
||||
|
||||
return lineItems;
|
||||
}
|
||||
|
||||
function getArrayOfAllLineItems(lineItems) {
|
||||
let consolidatedLineItemsArray = [];
|
||||
if (lineItems.glassParts != null)
|
||||
|
|
|
|||
Loading…
Reference in a new issue