Skip to content

OBPIH-7074 bugfix. Prevent stack trace when adding to count items list within loop#5127

Merged
awalkowiak merged 1 commit intodevelopfrom
bug/OBPIH-7074-fix
Mar 14, 2025
Merged

OBPIH-7074 bugfix. Prevent stack trace when adding to count items list within loop#5127
awalkowiak merged 1 commit intodevelopfrom
bug/OBPIH-7074-fix

Conversation

@ewaterman
Copy link
Member

@ewaterman ewaterman commented Mar 13, 2025

✨ Description of Change

Link to GitHub issue or Jira ticket: https://pihemr.atlassian.net/browse/OBPIH-7074

Description: Follow up fix to #5125

Submitting a count with a custom item threw an error because we were adding to the customItemsOfLastCount list while looping through it:

for (CycleCountItem customCycleCountItem : customItemsOfLastCount) {
    ...
    cycleCount.addToCycleCountItems(cycleCountItem)  // adds to customItemsOfLastCount. Errors!
}

I tested the following scenario:

  • add custom item to count
  • submit count
  • start recount successfully, it has QoH == 0

and:

  • add custom item to count
  • submit count
  • record stock, adding 20 quantity to the bin + lot of the custom item
  • start recount successfully, it has QoH == 20

@ewaterman ewaterman self-assigned this Mar 13, 2025
@github-actions github-actions bot added type: bug Addresses unintended behaviours of the app domain: backend Changes or discussions relating to the backend server labels Mar 13, 2025
/**
* @return the cycle count item matching the given input (which uniquely identifies the item within the count).
*/
CycleCountItem getCycleCountItem(Location binLocation, InventoryItem inventoryItem, int countIndex) {
Copy link
Member Author

Choose a reason for hiding this comment

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

// a product availability record) so make sure to create new recount items for them as well.
// "Most recent count" in this scenario is the previous count.
Set<CycleCountItem> customItemsOfLastCount = cycleCount.itemsOfMostRecentCount.findAll{ it.custom }
for (CycleCountItem customCycleCountItem : customItemsOfLastCount) {
Copy link
Member Author

Choose a reason for hiding this comment

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

This is the real fix. Don't loop the same list that we add to. Everything else is just formatting or variable renames

@codecov
Copy link

codecov bot commented Mar 13, 2025

Codecov Report

Attention: Patch coverage is 0% with 10 lines in your changes missing coverage. Please review.

Project coverage is 8.08%. Comparing base (a9ae2be) to head (8206a7f).
Report is 169 commits behind head on develop.

Files with missing lines Patch % Lines
...g/pih/warehouse/inventory/CycleCountService.groovy 0.00% 9 Missing ⚠️
...main/org/pih/warehouse/inventory/CycleCount.groovy 0.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             develop   #5127      +/-   ##
============================================
- Coverage       8.15%   8.08%   -0.07%     
+ Complexity       945     934      -11     
============================================
  Files            636     636              
  Lines          43123   43121       -2     
  Branches       10486   10483       -3     
============================================
- Hits            3518    3488      -30     
- Misses         39058   39091      +33     
+ Partials         547     542       -5     

☔ 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 1d43878 into develop Mar 14, 2025
9 checks passed
@awalkowiak awalkowiak deleted the bug/OBPIH-7074-fix branch March 14, 2025 09:55
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 type: bug Addresses unintended behaviours of the app

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants