Skip to content

OBPIH-7506 allow blank lot numbers when updating product availability#5513

Merged
ewaterman merged 1 commit intodevelopfrom
bug/OBPIH-7506-blank-lot-prod-avail-dupe
Sep 29, 2025
Merged

OBPIH-7506 allow blank lot numbers when updating product availability#5513
ewaterman merged 1 commit intodevelopfrom
bug/OBPIH-7506-blank-lot-prod-avail-dupe

Conversation

@ewaterman
Copy link
Member

✨ Description of Change

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

OBS tickets that this resolves:

Description: There's a detailed explanation of the issue in the OBS tickets but in brief, when an inventory snapshot refresh is triggered for an inventory item (which was happening during putaway creation), it also triggers a product availability refresh on that inventory item. The product availability refresh logic wasn't differentiating between null and blank lot numbers and so it'd try to update both to the same default lot number, causing duplicate key errors. This change simply allows product availability refresh records to contain rows for blank lots as well.

Note that we rarely experience this because this particular refresh logic is only triggered by inventory snapshot refreshes. I assume the "regular" product availability refresh logic already handles this case properly (otherwise we'd see this error everywhere)

@ewaterman ewaterman self-assigned this Sep 25, 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 Sep 25, 2025
@ewaterman
Copy link
Member Author

ewaterman commented Sep 29, 2025

This PR triggered a discussion about how we handle lot numbers in general in the application. I won't handle the following in this PR since it'll require a proper design/discovery, but some ideas for future improvements include:

  • bonus: consider renaming the current InventoryItem entity to ProductLot and then creating a separate InventoryItem entity that has a Location facility field so that it represents a product lot at some facility.
  • add getOrCreateProductLot(String lotNumber, LocalDate expirationDate) and getProductLot(String lotNumber) methods somewhere that standardizes how we handle lots in our system
    • should blank string lots be allowed or should we trim input? (probably trim but would need a data migration...)
    • should we treat "" as the null lot? (probably but again we'd need a data migration, which might be more trouble than is worth)
  • standardizing data-binding for lots in imports. Use the above getOrCreateProductLot method!
  • standardizing data-binding for lots in APIs. Use the above getOrCreateProductLot method!
    • I'd be great if we could do this automatically: create a value converter for ProductLot/InventoryItem that if given a String lotNumber, LocalDate expirationDate combo will resolve the class by calling getOrCreateProductLot
  • create a lot picker component on the frontend that we can use anywhere that a lot can be selected. It selects from a dropdown list of existing lots on the product and there's a button to add a new lot.
    • This would simplify our APIs that use lots since they can always expect that the given lot exists. Importers would be the only ones that still need to support getOrCreateProductLot (at least until we refactor those flows. Maybe we could have a middle step that notifies the user what lots are going to be created so they can make a more informed decision about it)

@ewaterman ewaterman merged commit 908746d into develop Sep 29, 2025
2 of 5 checks passed
@ewaterman ewaterman deleted the bug/OBPIH-7506-blank-lot-prod-avail-dupe branch September 29, 2025 19:37
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.

2 participants