VVD Glazing Router

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

The logic in brief

Checks run in this order. The first match wins.

  1. VVD: frame in stock and open jobs below max cap. The lens never blocks VVD.
  2. Client's HUB: each client has one HUB or none. That HUB needs the frame, the lens and capacity.
  3. TOG: TOG lenses only. TOG needs the frame and capacity. It makes its lenses on demand.
  4. Frame out of stock everywhere: VVD takes the order and the client sends their own frame.
  5. Any usable portal under cap: yes means a transfer, no means overflow to VVD.

On every assignment, real stock is deducted and the portal's open jobs go up by one.