new-site/api/migrations/060_multi_year_orders.sql
justin f8cd37ac8c Initial commit — Performance West telecom compliance platform
Includes: API (Express/TypeScript), Astro site, Python workers,
document generators, FCC compliance tools, Canada CRTC formation,
Ansible infrastructure, and deployment scripts.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-27 06:54:22 -05:00

24 lines
1.1 KiB
SQL
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

-- 060: Multi-year filing orders
--
-- When a customer orders the same service slug (typically fcc-499a)
-- for multiple reporting years at once — e.g., catching up on 3 years
-- of past-due 499-A filings simultaneously — they receive a 15%
-- multi-year discount (same magnitude as the existing bundle discount
-- for multi-slug orders).
--
-- We represent this as a single compliance_order with a multi_year_filings
-- array; the handler runs N Playwright sessions against USAC, one per
-- year, and records N confirmation numbers.
ALTER TABLE compliance_orders
ADD COLUMN IF NOT EXISTS multi_year_filings INT[];
-- Per-year confirmation numbers captured after each sub-filing succeeds.
-- Shape: [{"year":2023,"confirmation":"X"},{"year":2024,"confirmation":"Y"}]
ALTER TABLE compliance_orders
ADD COLUMN IF NOT EXISTS multi_year_confirmations JSONB DEFAULT '[]'::jsonb;
-- Discount bookkeeping: when multi_year_filings has 2+ entries, the
-- resolver applies a 15% discount on top of the N × price base.
ALTER TABLE compliance_orders
ADD COLUMN IF NOT EXISTS multi_year_discount_pct NUMERIC(4,1);