OBLS-582 Incorrect qty on pick task, when more than 1 task created an…#5876
OBLS-582 Incorrect qty on pick task, when more than 1 task created an…#5876adambalcerzak wants to merge 3 commits into
Conversation
…d short one with bigger qty
| } | ||
|
|
||
| // undo quantityAvailable modification from getAvailableItems--calculateQuantityAvailableToPromise | ||
| availableItems.forEach {if (it.quantityAvailable > it.quantityOnHand) it.quantityAvailable = it.quantityOnHand} |
There was a problem hiding this comment.
I think this should be adjusted in the getAvailableItems -> calculateQuantityAvailableToPromise.
There was a problem hiding this comment.
How do you think it should be done? From this task point of view I think calling calculateQuantityAvailableToPromise is not needed inside getAvailableItems. I don't understand why to add quantity already picked to the available quantity. It breaks following calculations. But maybe it makes sense in different contexts? Is it safe to remove it in getAvailableItems? Should it be behind some if-check?
There was a problem hiding this comment.
@adambalcerzak I meant that in the getAvailableItems there is already calculateQuantityAvailableToPromise called, and that I think the fix should be inside that function. Here: https://github.com/openboxes/openboxes/blob/bug/OBLS-582/grails-app/services/org/pih/warehouse/inventory/StockMovementService.groovy#L2070-L2091. However, if you think this is the wrong place, we can further discuss it on Monday
There was a problem hiding this comment.
I looked at the code, and I still believe that this should be changed for this part:
else {
availableItem.quantityAvailable += picklistItem.quantity
}
And I think this should be rather be something like (to be confirmed):
if there is shortage reason code for that picklist item (picklistItem.isShortage)
add remaining qty (quantity - quantityPicked) to the available quantity (picklistItem.quantityCanceled)
no shortage reason code for that picklist itme
availableItem.quantityAvailable += picklistItem.quantity
Because if the picklist item was shorted, then the remaining quantity should still be available for picking, and should be included when building the available items.
There was a problem hiding this comment.
I think there is a misunderstanding here about which item quantity is important in this modification.
The scenario is as follow. There are 2 items:
- item-A, 5 pieces
- item-B, 8 pieces
We want to move 10 pieces and create 2 pick tasks:
- 2 pieces of item-A
- 8 pieces of item-B
First we complete the pick for 2 items of item-A. Then we start the second task, but we only pick 4 pieces.
A short pick happens and system tries to create a replacement pick task.
Now the getAvailableItems is called from StockMovementService#createPicklistAfterShortage. It finds the two items and modifies available quantity back with the picked quantity:
- item-A, 3+2 pieces
- item-B, 4+4 pieces
But inside createPicklist (from createPicklistAfterShortage) we exclude current item item-B. The only item left is item-A and system thinks 5 pieces are still available.
System creates new pick task for 4 pieces of item-A.
There was a problem hiding this comment.
@adambalcerzak Ok, I think I understand it. But still, it should be resolved on the level where the quantity available to promise is being calculated. No point in calculating it once and then changing it afterwards in a loop again. I think you could add a parameter like includeQuantityAllocated that is by default true, and disable it for creating a new pick task after a short pick.
There was a problem hiding this comment.
You could just do
Integer suggestedItemsQuantity = suggestedItems?.sum { it.quantityPicked } ?: 0…d short one with bigger qty - apply pr comments
…d short one with bigger qty - add a parameter includeQuantityAllocated

…d short one with bigger qty
✨ Description of Change
Link to GitHub issue or Jira ticket:
Description:
📷 Screenshots & Recordings (optional)