OBLS-513 Transfer Shortage Qty to Under Receipt Location on UI#5923
OBLS-513 Transfer Shortage Qty to Under Receipt Location on UI#5923adambalcerzak wants to merge 8 commits into
Conversation
There was a problem hiding this comment.
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
ReasonCodevalues 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.
| 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 |
| // if (location is under receipt) | ||
| // sendStockTransferNotification() -> fetch users with Stocktransfer notification role -> send | ||
|
|
| // 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), |
awalkowiak
left a comment
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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]) |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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')}"> |
There was a problem hiding this comment.
Let's change the message structure a bit.
-
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. -
"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> -
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() { |
There was a problem hiding this comment.
Move these to the listPickingShortageReasonCodes, and use the listPickingShortageReasonCodes instead of this one
There was a problem hiding this comment.
No need for this one, you can use reason codes for the PICKING_SHORTAGE for now on the front end.
TODO for the future
fix filtering and displaying new reason value
send notification email
add suggestions from pr Copilot
change sending email as suggested in pr
494d36d to
04d732b
Compare

✨ Description of Change
Link to GitHub issue or Jira ticket:
Description:
📷 Screenshots & Recordings (optional)