Skip to content

OBPIH-6679 Fix inferring bin location when providing a lot number#4848

Merged
awalkowiak merged 3 commits intorelease/0.9.2-hotfix1from
OBPIH-6679-fix-inferring-bin-location-when-lotnumber-provided
Sep 19, 2024
Merged

OBPIH-6679 Fix inferring bin location when providing a lot number#4848
awalkowiak merged 3 commits intorelease/0.9.2-hotfix1from
OBPIH-6679-fix-inferring-bin-location-when-lotnumber-provided

Conversation

@drodzewicz
Copy link
Collaborator

@drodzewicz drodzewicz commented Sep 19, 2024

✨ 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: OBPIH-6679

Description: Had to modify the inferring bin location logic a bit due to following problem.

  • inferring would work on out of stock bins, which is why I had to sue the product availability service which handles this search properly
  • Were some issues with inferring default bin location
  • providing a wrong bin location with correct lot would result in the algorithm trying to infer the bin location based on lot which we do not want in this situation and want to display the incorrect bin

📷 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 19, 2024
@github-actions github-actions bot added the domain: backend Changes or discussions relating to the backend server label Sep 19, 2024
@drodzewicz drodzewicz changed the title Obpih 6679 fix inferring bin location when lotnumber provided OBPIH-6679 Fix inferring bin location when providing a lot number Sep 19, 2024
Product product = Product.findByProductCode(source['product'])
List<ProductAvailability> items = ProductAvailability.findAllByProductAndBinLocationAndLocation(product, internalLocation, obj.origin)
List<ProductAvailability> items = productAvailabilityService.getAvailableBinLocations(obj.origin, product?.productCode)
.findAll { it?.binLocation?.name == source['binLocation'] }
Copy link
Collaborator

Choose a reason for hiding this comment

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

since there is a lot of those methods in the product availability service, I won't force that, but I would prefer to have this filtering in the query itself, instead of calling .findAll just after doing the fetch.
Please take a look if there is a method that would return product availability for pair: origin, product, binLocation and use it if possible.
Otherwise, if the performance is OK for an item, that has stock in a lot of bins, I'm fine with that, not to implement another comprehensive method in that service.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't think we have a one right now that does a search for specific bin locaitons

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

yeah, we don't and I would need to implement a new service method for that.
I don't think we are dealing with too much data at this point and maybe a simple findAll search should be enough

Copy link
Collaborator

Choose a reason for hiding this comment

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

ok, I guess we can just monitor and live with it for now, but I wanted to make a point, that this usually should not be the way to go.

if (items.size() > 0 && items.any { it.binLocation == null }) {
// null value assumes that this is a default bin location
return null
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

is this check needed, if you return null below anyway?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

yeah, you are right, I had a little different approach before and this was necessary there.

binLocation(nullable: true, validator: { Location binLocation, ImportPackingListItem item ->
if (!item.binLocationFound) {
return ['binLocationNotFound', binLocation.name]
return ['binLocationNotFound', binLocation?.name]
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't mind it, but I'm wondering if you had run into the nullpointer here? I think it's not possible, because the only possible option to execute this code is if you return the dummy location

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

you are right, I had a NPE but I had used a different approach before where I returned a a null value with setting this flag as false which resulted in a NPE.
I can remove this nullsafe operator now


Product product = Product.findByProductCode(source['product'])
List<ProductAvailability> items = productAvailabilityService.getAvailableBinLocations(obj.origin, product?.productCode)
.findAll { it?.inventoryItem?.lotNumber == source['lotNumber']}
Copy link
Collaborator

Choose a reason for hiding this comment

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

a similar comment like above

Copy link
Collaborator

@awalkowiak awalkowiak left a comment

Choose a reason for hiding this comment

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

Beside the one unnecessary if with return null that Kacper already mentioned it LGTM.

@awalkowiak awalkowiak merged commit 318b0c8 into release/0.9.2-hotfix1 Sep 19, 2024
@awalkowiak awalkowiak deleted the OBPIH-6679-fix-inferring-bin-location-when-lotnumber-provided branch September 19, 2024 11:24
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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants