OBLS-582 Incorrect qty on pick task, when more than 1 task created an… by adambalcerzak · Pull Request #5876 · openboxes/openboxes · GitHub
Skip to content

OBLS-582 Incorrect qty on pick task, when more than 1 task created an…#5876

Draft
adambalcerzak wants to merge 3 commits into
feature/obaf-integrationfrom
bug/OBLS-582
Draft

OBLS-582 Incorrect qty on pick task, when more than 1 task created an…#5876
adambalcerzak wants to merge 3 commits into
feature/obaf-integrationfrom
bug/OBLS-582

Conversation

@adambalcerzak

Copy link
Copy Markdown
Collaborator

…d short one with bigger qty

✨ Description of Change

Link to GitHub issue or Jira ticket:

Description:


📷 Screenshots & Recordings (optional)

@github-actions github-actions Bot added type: bug Addresses unintended behaviours of the app domain: backend Changes or discussions relating to the backend server stakeholder: vvg Issues or topics relating to VVG (velocity vehicle group) labels Apr 8, 2026
@adambalcerzak adambalcerzak marked this pull request as draft April 8, 2026 12:57
@codecov

codecov Bot commented Apr 8, 2026

Copy link
Copy Markdown

}

// undo quantityAvailable modification from getAvailableItems--calculateQuantityAvailableToPromise
availableItems.forEach {if (it.quantityAvailable > it.quantityOnHand) it.quantityAvailable = it.quantityOnHand}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think this should be adjusted in the getAvailableItems -> calculateQuantityAvailableToPromise.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

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?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

@adambalcerzak adambalcerzak Apr 16, 2026

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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
@jmiranda jmiranda self-requested a review May 13, 2026 15:36
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 stakeholder: vvg Issues or topics relating to VVG (velocity vehicle group) type: bug Addresses unintended behaviours of the app

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants