Back to Home

Load Lifecycle & State Machine

Canonical states, transitions, and money behavior for Krane's load lifecycle from BOOKED to ARCHIVED.

Search lifecycle concepts
Find states, transitions, or behaviors by name or description.
1) Lifecycle Overview
End-to-end view of a load from booked through archived, including how ops and finance think about it.
BOOKED → LOGGED → DISPATCHED_FOR_PICKUP
operational pipeline
Lifecycle

Ops: Intake and pre-movement staging. Load is agreed, keyed, and a plan exists.

Dev: Transitions driven by UI actions / API endpoints; do NOT mutate arbitrarily from random forms.

AT_ORIGIN_YARD → YARD_HANDLING → OTR_IN_TRANSIT
yard + linehaul pipeline
Lifecycle

Ops: Freight enters your control, may be reloaded or repowered, then moves over the road to next node.

Dev: Each change should be tied to a physical event (check-in, gate move, hook/unhook, depart).

AT_DESTINATION_YARD → DELIVERED
destination pipeline
Lifecycle

Ops: Freight arrives near consignee (yard or warehouse) and then delivers to final receiver with POD.

Dev: Delivery should be tied to POD capture; avoid 'manual delivered' without docs unless forced.

WAITING_INVOICE → WAITING_PAYMENT → PAID → ARCHIVED
financial pipeline
Lifecycle

Ops: Commercial lifecycle after freight movement: invoicing, collection, and eventual archival for history.

Dev: These states should be driven by accounting flows (invoicing, bank sync, reconciliations).

CANCELLED / TONU / on_hold
exceptions
Lifecycle

Ops: Non-happy-path outcomes (kill, truck-ordered-not-used, paused). Can occur at multiple points.

Dev: Represented as explicit statuses or flags, never as free-text comments alone.

Lifecycle Patterns & Conventions
How statuses, flags, timestamps, and money should behave together.
Separation of Concerns

Operational state lives in load_status. Overlays like on_hold, payment_status, and tonu_amount express exceptions and money without inventing new states.

Timestamps Drive Truth

Events like booked_at, dispatched_at, picked_up_at, delivered_at, invoice_date, and paid_date are the real audit log. load_status is the current summary.

Money is Computed

Detention, layover, lumper, and TONU roll into accessorial_total_amount and ultimately invoice_amount. Reporting should derive a single final_revenue value per load from those components.