Skip to content

OBPIH-6676 Fix binding of inferred lot expiration date#4836

Merged
awalkowiak merged 1 commit intorelease/0.9.2-hotfix1from
feature/OBPIH-6676-recognize-lot-expiry-date-when-inventory-item-not-available
Sep 12, 2024
Merged

OBPIH-6676 Fix binding of inferred lot expiration date#4836
awalkowiak merged 1 commit intorelease/0.9.2-hotfix1from
feature/OBPIH-6676-recognize-lot-expiry-date-when-inventory-item-not-available

Conversation

@drodzewicz
Copy link
Collaborator

✨ Description of Change

A concise summary of what is being changed. Please provide enough context for reviewers to be able to understand the change and why it is necessary. If the issue/ticket already provides enough information, you can put "See ticket" as the description.

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

Description:
There was a case where user provided a non existing binLocation and as a result the expiration date for existing lot was not populated. To fix this issue I just changed the order of the validation and if the inventoryItem existing then bind the expiration date and only after that we validate for bin location


📷 Screenshots & Recordings (optional)

If this PR contains a UI change, consider adding one or more screenshots here or link to a screen recording to help reviewers visualize the change. Otherwise, you can remove this section.

@drodzewicz drodzewicz self-assigned this Sep 11, 2024
@github-actions github-actions bot added type: feature A new piece of functionality for the app domain: backend Changes or discussions relating to the backend server labels Sep 11, 2024
@ewaterman ewaterman added type: bug Addresses unintended behaviours of the app and removed type: feature A new piece of functionality for the app labels Sep 11, 2024
@ewaterman
Copy link
Member

for bugfixes, if you want the autolabeler to work your branch needs to be bug/OBPIH-XXXX or bugfix/OBPIH-XXXX

return ['inventoryItemNotFound']
}
// Associate inventory item's expiration date with expirationDateToDisplay, to display the date in the table
item.expirationDateToDisplay = inventoryItem.expirationDate
Copy link
Member

Choose a reason for hiding this comment

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

I'll approve the PR because this does seem to fix the issue, but I'm curious why we're setting values like this in the validator. It seems outside of the functionality of what a validator should do

Copy link
Collaborator

Choose a reason for hiding this comment

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

@ewaterman it's due to the fact, that the expiration date comes from an inventory item, and we do not provide the inventory item's id to be bound, but we rely on product/lotNumber pair that is used to find an inventory item.
The assignment of the expirationDateToDisplay is used only in order to display that date in the table - it is not persisted anywhere and validated.
On regular basis, in the toTableJson() we would just do:

expirationDate: inventoryItem?.expirationDate

but as I wrote earlier - we don't bind the InventoryItem to the ImportPackingListItem, but we rely on product/lotNumber pair.

Copy link
Member

Choose a reason for hiding this comment

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

it just feels weird for a validation step to be setting any fields on the object, even if they're not persisted. IMO once we hit the validation step, the object should already be fully constructed and so all we should need to do is simple checks on the fields. Embedded validators like this should be small. If we need to do other complex lookups or call other service methods, it signals to me that either we're missing important references in the object, or we might need a more deliberate validation step that happens outside of the object (via a XValidator.validate(x) call or something).

Anyways, the code is already merged and this is not new code, but it does feel to me like this validator is taking on too much responsability.

@awalkowiak awalkowiak merged commit a71051d into release/0.9.2-hotfix1 Sep 12, 2024
@awalkowiak awalkowiak deleted the feature/OBPIH-6676-recognize-lot-expiry-date-when-inventory-item-not-available branch September 12, 2024 14:21
jwalbers pushed a commit to jwalbers/openboxes that referenced this pull request Oct 29, 2024
jwalbers pushed a commit to jwalbers/openboxes that referenced this pull request Oct 31, 2024
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.

5 participants