OBLS-513 Transfer Shortage Qty to Under Receipt Location on UI by adambalcerzak · Pull Request #5923 · openboxes/openboxes · GitHub
Skip to content

OBLS-513 Transfer Shortage Qty to Under Receipt Location on UI#5923

Open
adambalcerzak wants to merge 8 commits into
feature/obaf-integrationfrom
feature/OBLS-513
Open

OBLS-513 Transfer Shortage Qty to Under Receipt Location on UI#5923
adambalcerzak wants to merge 8 commits into
feature/obaf-integrationfrom
feature/OBLS-513

Conversation

@adambalcerzak

Copy link
Copy Markdown
Collaborator

✨ Description of Change

Link to GitHub issue or Jira ticket:

Description:


📷 Screenshots & Recordings (optional)

@github-actions github-actions Bot added type: feature A new piece of functionality for the app domain: frontend Changes or discussions relating to the frontend UI domain: backend Changes or discussions relating to the backend server domain: l10n Changes or discussions relating to localization & Internationalization stakeholder: vvg Issues or topics relating to VVG (velocity vehicle group) labels May 18, 2026
@codecov

codecov Bot commented May 18, 2026

Copy link
Copy Markdown

Copilot AI left a comment

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.

Pull request overview

Adds “reason for shortage” support to Stock Transfer UI/API by introducing new reason codes and exposing them via the existing reason-codes endpoint, then wiring selection/display into stock transfer pages and persisting the selected code onto OrderItem.discrepancyReasonCode.

Changes:

  • Added new ReasonCode values and a dedicated list for “shortage qty under receipt” reason codes.
  • Added a “Reason for Shortage” column to Stock Transfer (edit + check) pages and plumbed the selected reason code through the Stock Transfer API model.
  • Introduced new role/activity-code entries related to stock transfer notifications (not yet implemented).

Reviewed changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
src/main/groovy/org/pih/warehouse/core/RoleType.groovy Adds a new stock-transfer notification role type.
src/main/groovy/org/pih/warehouse/core/ReasonCode.groovy Adds new reason codes + a new list method for under-receipt shortage.
src/main/groovy/org/pih/warehouse/core/ActivityCode.groovy Adds new activity codes for stock-transfer notifications + under-receipt shortage reason selection.
src/main/groovy/org/pih/warehouse/api/StockTransferItem.groovy Adds reasonCode field and serializes it to/from OrderItem.
src/js/consts/activityCode.js Adds JS constant for SHORTAGE_QTY_UNDER_RECEIPT.
src/js/components/stock-transfer/utils.jsx Propagates reasonCode through extracted items/split items.
src/js/components/stock-transfer/StockTransferSecondPage.jsx Fetches reason codes and adds editable “Reason for Shortage” column.
src/js/components/stock-transfer/StockTransferCheckPage.jsx Fetches reason codes and displays “Reason for Shortage” column.
grails-app/services/org/pih/warehouse/stockTransfer/StockTransferService.groovy Persists shortage reason onto OrderItem.discrepancyReasonCode; contains TODO comments for future notifications.
grails-app/i18n/messages.properties Adds labels for new reason codes + new stock transfer UI label.
grails-app/controllers/org/pih/warehouse/api/StockTransferApiController.groovy Binds reasonCode from request payload into StockTransferItem.
grails-app/controllers/org/pih/warehouse/api/ReasonCodeApiController.groovy Adds activity-code branch for returning the under-receipt shortage reason codes.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread grails-app/controllers/org/pih/warehouse/api/ReasonCodeApiController.groovy Outdated
Comment thread grails-app/i18n/messages.properties Outdated
enum.ReasonCode.OVERAGE=More stock than expected
enum.ReasonCode.WRONG_ITEM=Item does not match the expected product
enum.ReasonCode.DELIVERED_SHORT=Delivered short
enum.ReasonCode.PUTAWAY_DISCREPANCY=putaway discrepancy
Comment on lines +356 to +358
// if (location is under receipt)
// sendStockTransferNotification() -> fetch users with Stocktransfer notification role -> send

Comment on lines 49 to 57
// Notifications
ENABLE_NOTIFICATIONS('ENABLE_NOTIFICATIONS'),
ENABLE_WEBHOOKS('ENABLE_WEBHOOKS'),
// Approval notifications (if requestor should get the notification about approval or rejection)
ENABLE_REQUESTOR_APPROVAL_NOTIFICATIONS('ENABLE_REQUESTOR_APPROVAL_NOTIFICATIONS'),
// Approval notifications (if fulfiller should get the notification about submited requests)
ENABLE_FULFILLER_APPROVAL_NOTIFICATIONS('ENABLE_FULFILLER_APPROVAL_NOTIFICATIONS'),
ENABLE_STOCK_TRANSFER_NOTIFICATIONS('ENABLE_STOCK_TRANSFER_NOTIFICATIONS'),

ROLE_SHIPMENT_OUTBOUND_SHIPPED_NOTIFICATION('Shipment Outbound Shipped Notifications', 100),
ROLE_SHIPMENT_INBOUND_RECEIVED_NOTIFICATION('Shipment Inbound Received Notifications', 100),
ROLE_SHIPMENT_OUTBOUND_RECEIVED_NOTIFICATION('Shipment Outbound Received Notifications', 100),
ROLE_STOCK_TRANSFER_NOTIFICATIONS('Stock Transfer Notifications', 100),
@github-actions github-actions Bot added the flag: schema change Hilights a pull request that contains a change to the database schema label May 27, 2026
@adambalcerzak adambalcerzak marked this pull request as ready for review May 27, 2026 09:42

@awalkowiak awalkowiak left a comment

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.

Few change requests and please fix the conflicts

if (recipientList) {
def g = grailsApplication.mainContext.getBean('org.grails.plugins.web.taglib.ApplicationTagLib')
// try to find StockTransferItem with destinationBinLocation that supports ENABLE_STOCK_TRANSFER_NOTIFICATIONS activity
StockTransferItem stockTransferItemWithSupportedLocation = stockTransfer?.stockTransferItems?.find {

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 we can just send it in case any of the items have a destinationBinLocation or originBinLocation with ENABLE_STOCK_TRANSFER_NOTIFICATIONS enabled

}
String subject
if (stockTransferItemWithSupportedLocation) {
subject = g.message(code: 'email.stockTransfer.message.toLocation', args: [stockTransferItemWithSupportedLocation?.destinationBinLocation?.name])

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.

Subject can be a generic Stock transfer in ${item?.destinationBinLocation?.name ?: item?.originBinLocation?.name} no need to split into two cases.

createStockTransferTransaction(stockTransfer, order)


if (stockTransfer?.stockTransferItems?.any {

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.

As it is done with the recently developed PRs, we should emit the event here, and the event service would sendStockTransferNotification()


Side note: I started debating with myself if this should not be published inside the createStockTransferTransaction (line 360) after each transaction is created, and later on, the message would be based on the Transaction data or even published to the webhook. But for now, we can skip it.

<h2>${warehouse.message(code:'default.summary.label', default:'Summary') }</h2>
<div style="margin: 10px;">

<g:if test="${stockTransferItem?.destinationBinLocation?.supports('ENABLE_STOCK_TRANSFER_NOTIFICATIONS')}">

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.

Let's change the message structure a bit.

  1. Let's add a title above the table with transfer items -> There was a transfer in the <list of unique bin names from stock transfer items that support ENABLE_STOCK_TRANSFER_NOTIFICATIONS, in case there is another such location in other items> location. See details below.

  2. "Header" with data:
    a. Transfer Number: <stockTransafer.stockTransferNumber> with "View details" link next to it (like this one https://github.com/openboxes/openboxes/pull/5923/changes#diff-c29c819a35d3d11ec6625785eaf7e71aa6bd751618fc4e0f86b80471ee07be5aR19-R21)
    b. Origin Facility: <origin.name>
    c. Destination Facility: <destination.name>
    d. Transfered by: <orderedBy.name>

  3. Let's display all items in the table (product, origin bin, destination bin, quantity, reason code), and if the origin or the destination is a location that supports ENABLE_STOCK_TRANSFER_NOTIFICATIONS lets bold the name of it

]
}

static listShortageQtyUnderReceiptReasonCodes() {

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.

Move these to the listPickingShortageReasonCodes, and use the listPickingShortageReasonCodes instead of this one

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.

No need for this one, you can use reason codes for the PICKING_SHORTAGE for now on the front end.

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 domain: frontend Changes or discussions relating to the frontend UI domain: l10n Changes or discussions relating to localization & Internationalization flag: schema change Hilights a pull request that contains a change to the database schema stakeholder: vvg Issues or topics relating to VVG (velocity vehicle group) type: feature A new piece of functionality for the app

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants