VVD Glazing Router

How a glazing order (frame + lens) is routed to one of four portals: DC, HUB-A, HUB-B or TOG.

The logic in brief

Checks run in this order. The first match wins.

  1. DC: enough frame stock for the order and open jobs within max cap. The lens never blocks DC.
  2. Client's HUB: each client has one HUB or none. That HUB needs enough frame and lens stock for the order, and capacity.
  3. TOG: TOG lenses only. TOG needs enough frame stock and capacity. It makes its lenses on demand.
  4. Not enough frame stock anywhere: the client sends their own frame to their HUB if it can take the order (lens shipped from DC), otherwise to DC.
  5. Any usable portal within cap: yes means a transfer, no means overflow to DC.

On every assignment, the order's frame and lens quantities are deducted from real stock and the portal's open jobs go up by one.