Skip to main content

Create a DRAFT CapacityPlan and compute its shortage

POST 

/capacity-plans

Evaluates the ProcessPath path_id against assigned_demand (orders) for the warehouse's location over [window_start, window_end): loads each step's ProcessCapacity, normalizes it with the WorkloadProfile factors supplied in the body (same shape and validation as GET /process-paths/{id}/capacity -- there is no WorkloadProfile persistence yet), and computes path_capacity (ORDER per HOUR), bottleneck_step, capacity_over_window (path_capacity x window hours) and shortage (max(0, assigned_demand - capacity_over_window), never negative). The window is both the plan's planning window AND the window every step's ProcessCapacity is looked up for: a registered window applies to a step when it COVERS [window_start, window_end), exactly as in GET /process-paths/{id}/capacity (docs/adr/0003). The plan stores its own requested window. site_id is REQUIRED: the canonical site (a facility-layout Site site_code, the same identifier its SiteCapabilityChanged event publishes) the plan is scoped to. It is a stated planning fact, never inferred from warehouse_id or location, and a blank or absent one is rejected with 422 missing-required-field. assigned_demand is OPTIONAL (docs/adr/0004). An explicit value (including 0) is used exactly as stated and the plan's demand_source is "request". When it is OMITTED the demand defaults to the number of orders the local read model -- fed by order-management's published OrderAllocated / OrderPartiallyAllocated events, never by a live call -- expects at location in [window_start, window_end) (see GET /demand), the plan's demand_source is "orders", and assigned_demand in the response is that figure. When the read model has no order for that location and window the request is rejected with 422 missing-assigned-demand: absence never silently means zero demand. demand_source (docs/adr/0024) may name the source instead: "forecast" derives assigned_demand from the workload forecast of (site_id, forecast_path_id, default path_id) -- the units of the buckets whose cpt is in the window over units_per_order, rounded up to orders -- and the plan returns forecast_path_id. labour_requirement (docs/adr/0022) states, per path step, the labour its demand requires: tasks x the standard seconds of the step's task type, read from the local copy of labor-performance's labour standards (fed by its LaborStandardDefined / LaborStandardRevised events, never by a live call) for the plan's site at window_start. The optional tasks_per_order map counts a step's tasks; a step without a standard or without a task count is known false with a reason. It is informational: the shortage, the bottleneck and every published event are unchanged by it. The plan is saved and its CapacityPlanCreated event is queued in the transactional outbox in ONE database transaction.

Request​

Responses​

Plan created (status DRAFT).

Response Headers
    Idempotency-Replayed

    Present, with the value "true", only when the answer is a replay of an earlier request with the same Idempotency-Key.