Skip to content

OBLS-845 Added new fields to requisition, code refactor of allocation…#6014

Open
druchniewicz wants to merge 4 commits into
feature/obaf-integrationfrom
front-counter-path-b
Open

OBLS-845 Added new fields to requisition, code refactor of allocation…#6014
druchniewicz wants to merge 4 commits into
feature/obaf-integrationfrom
front-counter-path-b

Conversation

@druchniewicz

@druchniewicz druchniewicz commented Jul 7, 2026

Copy link
Copy Markdown
Collaborator

It covers OBLS-842, OBLS-843, OBLS-844, OBLS-845, OBLS-846

@github-actions github-actions Bot added domain: backend Changes or discussions relating to the backend server flag: schema change Hilights a pull request that contains a change to the database schema flag: config change Hilights a pull request that contains a change to the app config stakeholder: vvg Issues or topics relating to VVG (velocity vehicle group) labels Jul 7, 2026
@codecov

codecov Bot commented Jul 7, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 24.07407% with 82 lines in your changes missing coverage. Please review.
✅ Project coverage is 10.58%. Comparing base (5f61d78) to head (60ca612).
⚠️ Report is 28 commits behind head on feature/obaf-integration.

Files with missing lines Patch % Lines
.../pih/warehouse/allocation/AllocationService.groovy 3.03% 32 Missing ⚠️
...ih/warehouse/allocation/AvailableItemGroups.groovy 0.00% 12 Missing ⚠️
...g/pih/warehouse/jobs/AutomaticAllocationJob.groovy 30.00% 7 Missing ⚠️
...vy/org/pih/warehouse/allocation/FefoHandler.groovy 22.22% 7 Missing ⚠️
...ih/warehouse/inventory/StockMovementService.groovy 0.00% 4 Missing ⚠️
.../groovy/org/pih/warehouse/api/StockMovement.groovy 0.00% 4 Missing ⚠️
...ih/warehouse/allocation/DisplayFirstHandler.groovy 40.00% 3 Missing ⚠️
.../warehouse/allocation/WarehouseFirstHandler.groovy 40.00% 3 Missing ⚠️
...h/warehouse/allocation/WarehouseOnlyHandler.groovy 40.00% 3 Missing ⚠️
...llocation/AbstractAllocationStrategyHandler.groovy 33.33% 2 Missing ⚠️
... and 4 more
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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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

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, and allowNegativeInventory fields to Requisition and API representations (StockMovement / OutboundStockMovement), plus persistence migrations.
  • Refactored allocation ordering into pluggable AllocationStrategyHandler implementations with a resolver, and updated AllocationService to 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.

Comment on lines +224 to 235
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}")
}

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.

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 jmiranda left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Sorry, I messed up on the naming here. Let's follow the convention above.

negativeInventoryAllowed

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.

updated

@druchniewicz

Copy link
Copy Markdown
Collaborator Author

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

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)

@druchniewicz

Copy link
Copy Markdown
Collaborator Author

Do not merge yet - we'll combine this PR with another PR first

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

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

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 flag: config change Hilights a pull request that contains a change to the app config 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)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants