Skip to content

OBPIH-7178 Fix creating cycle count items in batch with the same inve…#5256

Merged
awalkowiak merged 1 commit intodevelopfrom
OBPIH-7178-fix
May 16, 2025
Merged

OBPIH-7178 Fix creating cycle count items in batch with the same inve…#5256
awalkowiak merged 1 commit intodevelopfrom
OBPIH-7178-fix

Conversation

@kchelstowski
Copy link
Collaborator

…ntory item properties

✨ Description of Change

Link to GitHub issue or Jira ticket:

Description:


📷 Screenshots & Recordings (optional)

@kchelstowski kchelstowski self-assigned this May 15, 2025
@github-actions github-actions bot added the domain: backend Changes or discussions relating to the backend server label May 15, 2025
InventoryItem inventoryItem = InventoryItem.findByProductAndLotNumber(command.inventoryItem.product, command.inventoryItem.lotNumber)
if (inventoryItem){
command.inventoryItem = inventoryItem
}
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Member

@ewaterman ewaterman May 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link

codecov bot commented May 15, 2025

Codecov Report

❌ Patch coverage is 0% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 8.27%. Comparing base (352f7a1) to head (295c3cd).
⚠️ Report is 137 commits behind head on develop.

Files with missing lines Patch % Lines
...g/pih/warehouse/inventory/CycleCountService.groovy 0.00% 4 Missing ⚠️
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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@awalkowiak awalkowiak merged commit e30d164 into develop May 16, 2025
9 checks passed
@awalkowiak awalkowiak deleted the OBPIH-7178-fix branch May 16, 2025 15:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

domain: backend Changes or discussions relating to the backend server

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants