CASH-1713 | Send in flattened priced items
This commit is contained in:
parent
72a30a3083
commit
7c59a8d0e5
1 changed files with 19 additions and 1 deletions
|
|
@ -174,6 +174,23 @@ import { Field } from "vee-validate";
|
|||
defineRule("payment-method-required", required(errorMessages.OPTION_REQUIRED));
|
||||
defineRule("recal-ack-required", required(errorMessages.RECAL_ACK_REQUIRED));
|
||||
|
||||
function getFlattenedArrayOfLineItemsWithChildParts(lineItems, childPartRecursiveCall = false) {
|
||||
let flattenedArray = [];
|
||||
lineItems?.forEach((lineItem) => {
|
||||
// this assumes childparts will never be a glass part
|
||||
lineItem.isChildPart = childPartRecursiveCall;
|
||||
flattenedArray.push(lineItem);
|
||||
if (lineItem.childParts) {
|
||||
flattenedArray = [
|
||||
...flattenedArray,
|
||||
...getFlattenedArrayOfLineItemsWithChildParts(lineItem.childParts, true),
|
||||
];
|
||||
}
|
||||
});
|
||||
|
||||
return flattenedArray;
|
||||
}
|
||||
|
||||
export default {
|
||||
name: "paymentMethod",
|
||||
props: {
|
||||
|
|
@ -233,7 +250,7 @@ export default {
|
|||
// 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(
|
||||
let pricedLineItems = await baseMixin.methods.dispatchStoreActionWithLogging(
|
||||
storeActions.PRICE_ORDER_ITEMS_AND_SAVE_SERVER_DATA,
|
||||
{
|
||||
availableLineItems: lineItemsOnOrderAndAvailableVaps,
|
||||
|
|
@ -241,6 +258,7 @@ export default {
|
|||
"payment-method",
|
||||
false
|
||||
);
|
||||
pricedLineItems = getFlattenedArrayOfLineItemsWithChildParts(pricedLineItems);
|
||||
|
||||
// Add prices to the availableVaps
|
||||
const pricedAvailableVaps = addPricesToLineItems(availableVaps, pricedLineItems);
|
||||
|
|
|
|||
Loading…
Reference in a new issue