♛ HotWax OMS: Order Routing Architectural Specification
Fulfillment Optimization, Inventory Topology, and Gap Analysis
I. Scenario Overview & Architectural Context
This document provides a comprehensive technical and functional evaluation of the HotWax Order Routing Engine (OrderRouting) against the operational specifications of a Premium Disposable Aluminum Products Business.
The business relies on a high-velocity, bulky-product supply chain utilizing two primary US warehouses:
- East Coast Warehouse (NJ, serving primary East Zone density)
- West Coast Warehouse (CA, serving primary West Zone density)
As online sales expand to retail customers, the company requires a routing framework that minimizes shipping distances, enforces single-facility fulfillment, gracefully handles inventory depletion fallbacks, scales automatically to new warehouses, and supports an intelligent Transfer Order Suggestion (TOS) model.
II. Action -> Reaction -> Workflow Sequence
This sequence outlines how an ingested customer order is processed, filtered, evaluated, and assigned to a fulfillment facility.
Action-Reaction Matrix
| Phase | System / Actor | Action | System Reaction | Entity State Change |
|---|---|---|---|---|
| 1. Ingest | Shopify Store | Places order containing multiple items | OMS ingests order; marks ship group for routing | OrderHeader.statusId ➔ ORDER_APPROVEDOrderItem.statusId ➔ ITEM_APPROVEDOrderItemShipGroup.facilityId ➔ HQ_QUEUE (Virtual Queue) |
| 2. Trigger | Scheduler / Admin | Triggers Routing Run for OrderRoutingGroup | Engine queries database for unbrokered orders | Creates OrderRoutingRun & OrderRoutingBatch records tracking run metadata |
| 3. Proximity | Routing SQL | Calculates sphere distance to all active warehouses | Sorts warehouses in ascending order of distance | Computes dynamic distance field using ST_Distance_Sphere between customer address & facility address |
| 4. Enforce | Routing SQL | Applies ORA_SINGLE constraint for single-facility check | Excludes any warehouse that cannot fulfill 100% of items in ship group | Filters results where rank_by_order_at_facility = 'Y' or rank_by_order_above_facility_threshold = 'Y' |
| 5. Allocate | Routing Engine | Selects highest-ranked warehouse | Calls process#OrderFacilityAllocation to commit selection | Updates OrderItemShipGroup.facilityId ➔ WAREHOUSE_ID (e.g., East Coast WH) |
| 6. Reserve | Inventory System | Creates physical stock reservations | Deducts from Available-to-Promise (ATP) at chosen facility | Creates OrderItemShipGrpInvRes mapping item to facility inventory item |
| 7. Handle | Rule Engine | If OOS at all warehouses, applies "Unfillable" rule action | Moves order to unfillable queue or leaves unrouted | Updates OrderItemShipGroup.facilityId ➔ UNFILLABLE_QUEUE (if ORA_MV_TO_QUEUE is active) |
🎮 Interactive Routing Simulator
Try out real-time routing runs using our high-fidelity sandboxed simulator. Configure order payloads, toggle constraints, and analyze step-by-step Moqui engine execution logs.
Core Workflow Sequence Diagram
III. State Transition Model
The state of an order during brokering is driven primarily by the facilityId field of its OrderItemShipGroup entity, while its administrative statuses remain ORDER_APPROVED and ITEM_APPROVED.
IV. Entity Relationship Diagram (ERD)
The order routing engine sits as a hybrid intelligence layer. Core transaction data rests in Apache OFBiz entities, while routing rules, configurations, and run statistics reside in Moqui entities.
V. Feasibility Analysis (Achievable vs. Gaps)
Based on an exhaustive review of the OrderRouting component's source code, SQL templates (InventorySourceSelector.sql.ftl, EligibleOrdersQuery.sql.ftl), and services (OrderRoutingServices.xml), we have analyzed the feasibility of your specific fulfillment rules.
1. What is Achievable (Out-of-the-Box)
- Proximity-Based Routing (Rule 1 - Nearest Warehouse Serving Order):
- Implementation: Fully supported. The SQL engine calculates geographical distance using:
It compares the customer's delivery postal address
ST_Distance_Sphere(point(fpa.LONGITUDE, fpa.LATITUDE), point(opa.LONGITUDE, opa.LATITUDE)) * conversionFactor AS distancecontactMechIdwith the facility's primary location coordinates. If the rule'sinventorySortByListcontainsdistance, warehouses are automatically sorted by proximity.
- Implementation: Fully supported. The SQL engine calculates geographical distance using:
- Single Facility Fulfillment / No Partial Shipments (Rule 2):
- Implementation: Fully supported. By configuring the routing rule with
assignmentEnumId = 'ORA_SINGLE', the query utilizes:The routing engine filters out any warehouse that cannot fulfill 100% of the ship group items. No partial shipments are allowed; the order will either route in full to a single facility or fail brokering.ifnull((select distinct 'N' from order_item oi1 LEFT join product_facility pf1 ... where pf1.last_inventory_count < quantity ...),'Y') as rank_by_order_at_facility
- Implementation: Fully supported. By configuring the routing rule with
- Depletion Fallback (NY/East Coast to West Coast):
- Implementation: Fully supported. Because the query sorts by
distance ASCbut filters byrank_by_order_at_facility = 'Y', if the closest warehouse (East Coast) is missing even one item, it is excluded. The fallback warehouse (West Coast) is automatically selected as it is next in proximity that satisfies 100% stock availability.
- Implementation: Fully supported. Because the query sorts by
- Warehouse Scaling (Rule 4 - Adding Warehouses with Same Activities):
- Implementation: Fully supported. The proximity calculation is dynamic and spatial. Adding an arbitrary number of warehouses requires zero code changes. You only need to create a
Facilityrecord, map it to a primaryPostalAddresswith latitude/longitude coordinates, and register it to theProductStoreFacilityassociation.
- Implementation: Fully supported. The proximity calculation is dynamic and spatial. Adding an arbitrary number of warehouses requires zero code changes. You only need to create a
2. What is NOT Achievable (Gaps & Functional Debt)
While the core brokering features exist, your specific constraints reveal two major functional gaps:
❌ Gap A: Rule 3 (Prioritizing LOWER Inventory Turnover Ratio)
- The Conflict: The existing system contains a
weekOfSupplysorting mechanism. However, it is hardcoded to sort in descending order:This standard design prioritizes facilities with the maximum weeks of supply left (to prevent fast stockouts at high-demand facilities). Your rule explicitly asks for the opposite: prioritize warehouses with lower rollover days (fewer weeks of supply left) to clean out stock or balance inventory turnout.week_of_supply is null asc, week_of_supply desc - The Solution: This is a minor code customization gap. We must introduce a new sort parameter or modify the template to support
weekOfSupplyAsc(orlowerInventoryTurnover).
pf.SALES_VELOCITY IS NULL ASC,pf.SALES_VELOCITY ASC
<#elseif 'weekOfSupply' == inventorySortByList>
<#if weekOfSupply?has_content && weekOfSupply > 0>
week_of_supply is null asc,week_of_supply desc
</#if>
+ <#elseif 'lowerInventoryTurnover' == inventorySortByList>
+ <#if weekOfSupply?has_content && weekOfSupply > 0>
+ week_of_supply is null asc,week_of_supply asc
+ </#if>
<#else>
${inventorySortBy!}
❌ Gap B: Weekly inter-facility Transfer Order Suggestion (TOS)
- The Conflict: The
OrderRoutingcomponent is strictly an Order Brokering Engine. It does not possess a predictive replenishment or transfer suggestion engine out of the box. It cannot natively analyze multi-item unfillable backlogs in theUNFILLABLE_QUEUEand calculate optimal SKU-level bulk transfer suggestions between warehouses. - The Solution (Proposed Architecture): We must design a standalone weekly batch service (
suggest#InterWarehouseTransfers) leveraging existing Apache OFBiz entities:Requirement(typeINTERNAL_REQ),InventoryTransfer, andShipment.
VI. Antigravity Challenge: Thinking Around Corners
5 Critical Critiques of the Proposed Fulfillment Strategy
[!IMPORTANT] The requested design is functionally direct, but structurally flawed under real-world operating conditions. Below are 5 "around-the-corners" critiques challenging your core operational assumptions to protect margins and customer experience.
1. The Risk of the "LOWER Inventory Supply Sort"
- The Fallacy: Prioritizing warehouses with lower weeks of supply (Rule 3) means you are deliberately routing orders to the facility that is fastest to deplete.
- The Trap: If both East and West coast warehouses are equal days away from a customer, but the East Coast warehouse only has 10 days of supply remaining while the West Coast has 50 days of supply, Rule 3 will force fulfillment from the East Coast. This will trigger premature stockouts on the East Coast for orders that cannot be served by the West Coast (due to proximity limits or delivery day SLAs), forcing costly cross-country shipments for future orders.
- Strategic Recommendation: Turn this rule upside down. Sort by
week_of_supply DESC(standard HotWax behavior) to maintain balanced regional buffers, unless you are running a specific clearance sale or warehouse decommissioning event.
2. The Bulky-Margin Paradox of weekly Inter-Warehouse TOS
- The Fallacy: Assuming that suggesting weekly SKU-level transfers between warehouses is an optimal way to fulfill unfillable multi-item orders.
- The Trap: Aluminum disposable products (trays, foil pans, containers) are low-margin, high-volume, and extremely bulky. Inter-warehouse freight is priced by volume (freight class / dimensional weight). If you transfer 2 pallets of aluminum lids from West Coast to East Coast just to resolve 15 unfillable orders that were stuck due to the "No Partial Shipments" rule, the freight and handling cost of the transfer will far exceed the profit margins of those orders.
- Strategic Recommendation: Rather than relying on constant, costly inter-facility transfers, utilize the TOS engine only for high-value items, or implement a regional demand-driven safety stock threshold directly in
ProductFacility.minimumStockto prevent these imbalances from happening in the first place.
3. The Unfillable Queue Churn Trap
- The Fallacy: Orders that cannot be fulfilled from a single warehouse are pushed to the
UNFILLABLE_QUEUEuntil a weekly TOS is executed. - The Trap: In modern e-commerce, a customer order sitting unfulfilled in a backlog for up to a week waiting for an inter-warehouse truck to arrive will result in massive customer churn and cancelled orders.
- Strategic Recommendation: Implement an SLA-based bypass. If an order sits in the
UNFILLABLE_QUEUEfor more than 48 hours, override the "No Partial Shipments" rule, split the order into two ship groups, ship them from both warehouses, and absorb the split shipping cost as a customer retention measure.
4. The Proximity vs. SLA Carrier Blindspot
- The Fallacy: Proximity-based routing (
ST_Distance_Sphere) is a direct proxy for shipping speed and cost. - The Trap: Geographical distance does not equal shipping transit time or carrier zone costs. A warehouse that is geographically closer to a customer might not have a direct carrier route, resulting in 3 days transit, whereas a warehouse slightly further away sits next to an FedEx/UPS regional hub and can deliver in 1 day at a lower zone rate.
- Strategic Recommendation: Transition from static coordinate distance sorting to dynamic carrier API zone pricing and SLA transit-time lookup in your routing rule configurations.
5. Dual Database Synchronization Lag
- The Fallacy: The system can seamlessly manage real-time inventory queries across Apache OFBiz and Moqui.
- The Trap: HotWax OMS utilizes a split architecture where core inventory transactions (shipments, receipts, adjustments) update the OFBiz database, but the Moqui Order Routing engine runs asynchronously on cached or synchronized views. If high-velocity online sales are running, a lag in inventory synchronization between OFBiz and Moqui can lead to double-brokering (allocating the same physical stock to different orders at both warehouses), leading to rejection loops and inventory variance write-offs.
- Strategic Recommendation: Enforce strict real-time transactional inventory checks (
entity-findwithout cache) for high-velocity SKUs inside theInventorySourceSelectorrouting run.
Design, Diagrams, and Critiques provided by Antigravity Core AI. Under review for Premium Operations.