OBPIH-7178 Fix creating cycle count items in batch with the same inve…#5256
OBPIH-7178 Fix creating cycle count items in batch with the same inve…#5256awalkowiak merged 1 commit intodevelopfrom
Conversation
…ntory item properties
| InventoryItem inventoryItem = InventoryItem.findByProductAndLotNumber(command.inventoryItem.product, command.inventoryItem.lotNumber) | ||
| if (inventoryItem){ | ||
| command.inventoryItem = inventoryItem | ||
| } |
There was a problem hiding this comment.
Since we do the binding in the @BindUsing and don't save the inventoryItem there, but here, in the service, in 620th line, if items share the same inventory item, instead of re-using the one created in e.g. 2nd item for 10th item, we would create a brand new one for 10th item, what in the end would fail, due to the lot number/product unique constraint.
To prevent that, and re-use the inventory item, we need an additional lookup before actually saving any inventory item + flush the save, so that a brand new created inventory item is visible while doing the findBy* for further iterations.
There was a problem hiding this comment.
good catch. Unfortunate that this is required but it makes sense and I can't immediately think of a better solution...
I suppose you could pass an "isBatch" boolean that's true if you're coming from createCycleCountItems, and false if you're coming from the non-batch create item API. Then you could skip the lookup and flush if !isBatch, but maybe that's not needed
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #5256 +/- ##
============================================
- Coverage 8.27% 8.27% -0.01%
Complexity 965 965
============================================
Files 641 641
Lines 43288 43291 +3
Branches 10520 10521 +1
============================================
Hits 3583 3583
- Misses 39155 39158 +3
Partials 550 550 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
…ntory item properties
✨ Description of Change
Link to GitHub issue or Jira ticket:
Description:
📷 Screenshots & Recordings (optional)