Add USAC Filer ID Deactivation Letter template

Formal letter addressed to USAC Contributor Operations requesting
deactivation of a 499 Filer ID. Covers:
- Entity identification (name, Filer ID, FRN, EIN)
- Reason for deactivation + termination date
- Final 499-A status (zero-revenue included OR filed separately)
- Successor entity info (if applicable)
- Outstanding balance acknowledgment
- Related filings confirmation (RMD, CPNI, BDC)
- Officer signature block
- Entity summary box

Handler updated to:
- Generate the letter via document_gen template
- Upload DOCX to MinIO (compliance/{order_number}/)
- Reference the letter in admin todo

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
justin 2026-05-03 06:15:26 -05:00
parent eee2aa497b
commit a404cb1b57
2 changed files with 341 additions and 3 deletions

View file

@ -40,11 +40,53 @@ class Form499ADiscontinuanceHandler(BaseComplianceHandler):
discontinuance_reason = intake_data.get("discontinuance_reason", "Ceased providing telecommunications services")
last_service_date = intake_data.get("last_service_date", "")
# If ordered as standalone discontinuance ($299), includes a zero-revenue
# final filing. If ordered with a full 499-A ($499+$299), the 499-A handler
# files the revenue report separately — we just handle the deactivation.
includes_zero_filing = not intake_data.get("has_separate_499a", False)
# ── Generate USAC deactivation letter ──────────────────────────
letter_path = None
try:
from scripts.document_gen.templates.form_499a_discontinuance_letter_generator import (
generate_discontinuance_letter,
)
import tempfile
work_dir = tempfile.mkdtemp(prefix=f"disc_{order_number}_")
date_str = datetime.now().strftime("%Y%m%d")
docx_path = os.path.join(
work_dir,
f"usac_deactivation_letter_{order_number}_{date_str}.docx",
)
letter_path = generate_discontinuance_letter(
entity_name=legal_name,
filer_id=filer_id,
frn=frn,
ein=entity.get("ein", ""),
address=entity.get("address", intake_data.get("address", "")),
officer_name=intake_data.get("officer_name") or entity.get("contact_name", ""),
officer_title=intake_data.get("officer_title") or entity.get("contact_title", ""),
officer_email=entity.get("contact_email") or order_data.get("customer_email", ""),
officer_phone=entity.get("contact_phone") or order_data.get("customer_phone", ""),
termination_date=last_service_date,
discontinuance_reason=discontinuance_reason,
successor_entity=intake_data.get("successor_entity", ""),
successor_filer_id=intake_data.get("successor_filer_id", ""),
last_filing_year=int(entity.get("last_filing_year") or 0),
includes_final_zero_filing=includes_zero_filing,
outstanding_balances=intake_data.get("outstanding_balances", False),
output_path=docx_path,
)
if letter_path:
logger.info("Discontinuance letter generated: %s", letter_path)
# Upload to MinIO
try:
from scripts.workers.minio_client import upload_file
minio_key = f"compliance/{order_number}/usac_deactivation_letter_{date_str}.docx"
upload_file(letter_path, minio_key)
logger.info("Uploaded to MinIO: %s", minio_key)
except Exception as exc:
logger.warning("MinIO upload failed: %s", exc)
except Exception as exc:
logger.warning("Discontinuance letter generation failed: %s", exc)
# Per FCC 499-A Instructions: discontinuance requires TWO steps:
# 1. File the final 499-A (may have actual revenue from the portion
# of the year the company operated — NOT required to be zero)
@ -79,6 +121,7 @@ class Form499ADiscontinuanceHandler(BaseComplianceHandler):
f" Update FCC CORES registration to reflect inactive status.\n\n"
f"STEP 4 — Related Filings:\n"
f" Confirm CPNI, RMD, and BDC filings are also discontinued.\n\n"
f"DEACTIVATION LETTER: {'Generated — check MinIO compliance/' + order_number + '/' if letter_path else 'GENERATION FAILED — draft manually'}\n\n"
f"Client email: {entity.get('contact_email') or order_data.get('customer_email', '')}",
)