Merge pull request #1758 from Safelite/feature/CSR-1971

CSR-1971 | Update line item ID syncing to avoid duplicates
This commit is contained in:
scottkiener 2024-02-16 11:01:50 -05:00 committed by GitHub
commit 8f8a1fe308
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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);
}
});
}