-- 099: Government-fee child orders for at-cost compliance services. -- -- At-cost services (IRP, IFTA, intrastate authority, etc.) collect only our -- SERVICE fee at checkout; the actual government/state fee is variable and -- "billed at cost" afterward. To collect it we create a CHILD compliance_orders -- row (service_fee_cents = 0, gov_fee_cents = the quoted state fee) that flows -- through the EXISTING checkout/payment-picker/webhook machinery unchanged, and -- email the customer a payment link with every payment method + correct -- surcharges. parent_order_number links that child back to the original order so -- the worker can resume filing once the fee is paid. -- -- Idempotent. ALTER TABLE compliance_orders ADD COLUMN IF NOT EXISTS parent_order_number text; -- Look up a parent's gov-fee children quickly (and vice-versa). CREATE INDEX IF NOT EXISTS idx_compliance_orders_parent ON compliance_orders (parent_order_number) WHERE parent_order_number IS NOT NULL;