OBLS-845 Added new fields to requisition, code refactor of allocation…#6014
OBLS-845 Added new fields to requisition, code refactor of allocation…#6014druchniewicz wants to merge 4 commits into
Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## feature/obaf-integration #6014 +/- ##
==============================================================
+ Coverage 10.43% 10.58% +0.15%
- Complexity 1711 1740 +29
==============================================================
Files 901 923 +22
Lines 51619 52265 +646
Branches 12239 12376 +137
==============================================================
+ Hits 5384 5530 +146
- Misses 45379 45833 +454
- Partials 856 902 +46 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
This PR introduces new requisition-level controls (allocation strategy, auto-issuance, and allow-negative-inventory) and refactors allocation ordering into dedicated strategy handlers so allocation behavior can be selected per requisition or via configuration.
Changes:
- Added
allocationStrategy,autoIssuanceEnabled, andallowNegativeInventoryfields toRequisitionand API representations (StockMovement / OutboundStockMovement), plus persistence migrations. - Refactored allocation ordering into pluggable
AllocationStrategyHandlerimplementations with a resolver, and updatedAllocationServiceto use them. - Updated automatic allocation to respect requisition/config strategy selection and optionally auto-issue after allocation.
Reviewed changes
Copilot reviewed 19 out of 19 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| src/main/groovy/org/pih/warehouse/api/StockMovement.groovy | Exposes new requisition fields on stock movement API model/output. |
| src/main/groovy/org/pih/warehouse/allocation/WarehouseOnlyHandler.groovy | Adds handler for WAREHOUSE_ONLY ordering. |
| src/main/groovy/org/pih/warehouse/allocation/WarehouseFirstHandler.groovy | Adds handler for WAREHOUSE_FIRST ordering. |
| src/main/groovy/org/pih/warehouse/allocation/FefoHandler.groovy | Adds handler for FEFO ordering. |
| src/main/groovy/org/pih/warehouse/allocation/DisplayFirstHandler.groovy | Adds handler for DISPLAY_FIRST ordering. |
| src/main/groovy/org/pih/warehouse/allocation/AvailableItemGroups.groovy | Centralizes grouping of available items into display/preferred/remaining buckets. |
| src/main/groovy/org/pih/warehouse/allocation/AllocationStrategyHandlerResolver.groovy | Resolves handlers by strategy enum. |
| src/main/groovy/org/pih/warehouse/allocation/AllocationStrategyHandler.groovy | Introduces strategy handler interface. |
| src/main/groovy/org/pih/warehouse/allocation/AbstractAllocationStrategyHandler.groovy | Provides shared grouping-based ordering implementation. |
| grails-app/services/org/pih/warehouse/report/NotificationService.groovy | Adds null-safe grouping for shipment-item notification recipients. |
| grails-app/services/org/pih/warehouse/inventory/StockMovementService.groovy | Propagates new stock movement fields to requisition and tweaks auto-pick behavior for auto-issuance. |
| grails-app/services/org/pih/warehouse/allocation/AllocationService.groovy | Refactors auto-suggestion logic to use resolved allocation strategy handlers. |
| grails-app/migrations/0.9.x/changelog.xml | Includes new migration changelog file. |
| grails-app/migrations/0.9.x/changelog-2026-07-07-1200-add-requisition-allocation-strategy-and-auto-issuance.xml | Adds new requisition columns for allocation strategy and flags. |
| grails-app/jobs/org/pih/warehouse/jobs/AutomaticAllocationJob.groovy | Runs automatic allocation across facilities and optionally auto-issues requisitions. |
| grails-app/init/org/pih/warehouse/BootStrap.groovy | Adds new requisition fields to bootstrap JSON/config output. |
| grails-app/domain/org/pih/warehouse/requisition/Requisition.groovy | Adds new fields + enum mapping + JSON output updates. |
| grails-app/domain/org/pih/warehouse/inventory/OutboundStockMovement.groovy | Exposes new requisition fields in outbound stock movement representation. |
| grails-app/conf/application.yml | Removes the bulkAutoAllocation config entry from automatic allocation job config. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| List<AllocationStrategy> resolvedStrategies = resolveStrategies(requisitionItem.requisition, strategies) | ||
|
|
||
| Integer bestQuantityAvailable = 0 | ||
| for (AllocationStrategy strategy : resolvedStrategies) { | ||
| List<AvailableItem> ordered = orderByStrategy(strategy, facility, product, allAvailableItems) | ||
| List<AvailableItem> includedItems = ordered.findAll { !excludeList.contains(it) } | ||
| Integer quantityAvailable = includedItems.sum { it.quantityAvailable } ?: 0 | ||
| bestQuantityAvailable = Math.max(bestQuantityAvailable, quantityAvailable) | ||
| if (canSatisfy(includedItems, quantityRequired)) { | ||
| return stockMovementService.getSuggestedItems(includedItems, quantityRequired) | ||
| } | ||
| throw new IllegalArgumentException("Insufficient stock. Required: ${quantityRequired}, Available: ${quantityAvailable}") | ||
| } |
There was a problem hiding this comment.
no worry, at least one strategy will always be returned, we have default config openboxes.order.allocation.strategies = [AllocationStrategy.FEFO] as a last resort
jmiranda
left a comment
There was a problem hiding this comment.
@awalkowiak after the small requested fix, feel free to merge. i won't have time to request the changes i want until after the latest RFP has been submitted and i don't want to block progres on this any longer.
| Boolean partialAllocationAllowed | ||
| Boolean partialIssuanceAllowed | ||
| Boolean autoIssuanceEnabled | ||
| Boolean allowNegativeInventory |
There was a problem hiding this comment.
Sorry, I messed up on the naming here. Let's follow the convention above.
negativeInventoryAllowed
I updated PR. Once its merged I will create a new ticket for break it down to rotation and source rules (something like in this PR) |
|
Do not merge yet - we'll combine this PR with another PR first |
awalkowiak
left a comment
There was a problem hiding this comment.
@druchniewicz So far it looks good to me (I don't have any comment to add, at least for now). Let me know when both PRs are combined.
It covers OBLS-842, OBLS-843, OBLS-844, OBLS-845, OBLS-846