Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OBPIH-6365 Add import validation on quantity available when item is picked #4664

Merged
merged 3 commits into from
Jun 14, 2024

Conversation

drodzewicz
Copy link
Collaborator

No description provided.

@@ -1165,7 +1165,10 @@ class StockMovementService {
)
}

if (availableItem && AvailableItemStatus.listUnavailable().contains(availableItem.status)) {
Boolean hasUnavailableStatus = availableItem && AvailableItemStatus.listUnavailable().contains(availableItem.status)
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think it would be better to create a method in AvailableItemStatus for checking whether the status passed as argument is in the list

@@ -1165,7 +1165,10 @@ class StockMovementService {
)
}

if (availableItem && AvailableItemStatus.listUnavailable().contains(availableItem.status)) {
Boolean hasUnavailableStatus = availableItem && AvailableItemStatus.listUnavailable().contains(availableItem.status)
Boolean isPickedItemPickable = availableItem?.status == AvailableItemStatus.PICKED && !availableItem.isPickable(data?.quantityAsNumber)
Copy link
Collaborator

Choose a reason for hiding this comment

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

I am not sure about a few things here plus the wording might be off. Could you explain the context to me? Are you checking in there that item is not available or it is already picked by other requisition items but still available to pick?

Overall thoughts I had looking at it, but depending on a context it might evolve so these are not yet change requests:

  1. isPickedItemPickable in the context of requested quantity does not make sense, because you already have it picked, so it should rather be isPickedItemValid or something like that (if it is picked, then it should not be "pickable" for others). However if it is rather "is it still available to pick" it should be already covered by hasUnavailableStatus and if it is
  2. Initial AvailableItem.isPickable() was checking if the specific item can be picked = if inventory item is not with recalled lot and it is not in hold bin, hence I would not mix "pickable" with "available".
  3. I would add a separate method returning quantityRequested <= quantityAvailable, but could you explain the context to me as asked above?

Copy link
Collaborator Author

@drodzewicz drodzewicz Jun 13, 2024

Choose a reason for hiding this comment

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

you are right, looking at the code something doesn't logically add up.
So the case that this part is trying to solve is to return an error for picked quantity if:

  • item is on hold
  • item is recalled
  • item is unavailable (qty available < 0 )
  • quantity available is less than what we are trying to pick
Boolean isPickable() {
    return (inventoryItem ? inventoryItem.pickable : true) && (binLocation ? binLocation.pickable : true)
}

I did not look into the isPickable function too deep inside and based my logic on the statuses but it looks like isPickable actually covers a lot of these cases
The isPickable for inventory item

Boolean isPickable() {
    return !recalled
}

and isPickable for on Location

Boolean isPickable() {
    return !onHold
}

so one more case that I need to add is checking if the quantity that we are trying to pick is <= quantity available which should resolve to this logic in the end

if (availableItem && (!availableItem.isPickable() || data?.quantityAsNumber <= availableItem.quantityAvailable)) {
}

also I can add a method on AvailabeItem something like availableItem.isRequestedAmoundAvailable(data?.quantityAsNumber )

Boolean hasUnavailableStatus = availableItem && AvailableItemStatus.listUnavailable().contains(availableItem.status)
Boolean isPickedItemPickable = availableItem?.status == AvailableItemStatus.PICKED && !availableItem.isPickable(data?.quantityAsNumber)

if (hasUnavailableStatus || isPickedItemPickable) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I am not sure if I understand it. If it is still pickable then why do you want to throw an error that it is unavailable?

Comment on lines 386 to 389

static listUnavailable() {
[RECALLED, HOLD, NOT_AVAILABLE]
}
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Decided to remove this list since it is not used anywhere and I was the one who introduces both list and listUnavailable

Copy link
Collaborator

Choose a reason for hiding this comment

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

@jmiranda uses it in his PR

Comment on lines 386 to 389

static listUnavailable() {
[RECALLED, HOLD, NOT_AVAILABLE]
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

@jmiranda uses it in his PR

return quantityAvailable > 0
}

Boolean isPickableQuantity(Integer quantity) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nitpicky, but I would call it isQuantityPickable

…available items has enought availabel quantity to be picked
@drodzewicz drodzewicz force-pushed the OBPIH-6365-after-review-fixes branch from add1406 to 63f9372 Compare June 14, 2024 09:59
@awalkowiak awalkowiak merged commit 50613ce into develop Jun 14, 2024
2 checks passed
@awalkowiak awalkowiak deleted the OBPIH-6365-after-review-fixes branch June 14, 2024 14:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants