From 15477bc076d84a4b7c4864b5634e4b787b8eeb08 Mon Sep 17 00:00:00 2001 From: Scott Kiener Date: Fri, 16 Feb 2024 10:54:02 -0500 Subject: [PATCH] CSR-1971 | Update line item ID syncing to avoid duplicate IDs --- src/store/index.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/store/index.js b/src/store/index.js index 02eca9806..6387e5e3f 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -2831,12 +2831,18 @@ function syncLineItemIds(lineItemsWithoutIds, lineItemsWithIds) { if (!lineItemsWithIds || !lineItemsWithoutIds) { return; } + var clonedLineItemsWithIds = deepClone(lineItemsWithIds); lineItemsWithoutIds.forEach((noId) => { - lineItemsWithIds.forEach((withId) => { + var matchedLineItemIndex = -1; + clonedLineItemsWithIds.forEach((withId, index) => { if (noId.partNumber === withId.partNumber && noId.partType === withId.partType) { + matchedLineItemIndex = index; noId.id = withId.id; } }); + if (matchedLineItemIndex > -1) { + clonedLineItemsWithIds.splice(matchedLineItemIndex, 1); + } }); }