""" Generate the FCC Form 499-A Reseller Certification Attestation. Produces a DOCX that a filer sends to its reseller customer for the reseller's authorized officer to sign. The signed attestation establishes that the purchased service is being resold into a telecommunications or interconnected VoIP offering, and that USF contribution is flowing (per 2026 Form 499-A Section IV.C.4). The sample certification text is reproduced verbatim from ``site/src/lib/fcc_constants.ts::RESELLER_CERTIFICATION_SAMPLE_TEXT`` and mirrored in the constant ``RESELLER_CERTIFICATION_SAMPLE_TEXT`` below. If upstream source text changes, update both locations. Usage: from scripts.document_gen.templates.reseller_cert_attestation_generator import ( generate_reseller_cert_attestation, ) path = generate_reseller_cert_attestation( output_path="/tmp/reseller_cert.docx", filer_legal_name="Acme Telco LLC", filer_filer_id_499="812345", reseller_legal_name="Beta Reseller Corp", reseller_filer_id_499="812999", reporting_year=2025, ) """ from __future__ import annotations import logging from datetime import datetime from pathlib import Path from typing import Optional LOG = logging.getLogger("document_gen.reseller_cert_attestation") try: from docx import Document from docx.shared import Pt, Inches, RGBColor from docx.enum.text import WD_ALIGN_PARAGRAPH except ImportError: LOG.warning("python-docx not installed — reseller cert attestation unavailable") Document = None # type: ignore[assignment,misc] _NAVY = RGBColor(0x1A, 0x27, 0x44) if Document else None # Verbatim from site/src/lib/fcc_constants.ts (RESELLER_CERTIFICATION_SAMPLE_TEXT). RESELLER_CERTIFICATION_SAMPLE_TEXT = ( "I certify under penalty of perjury that the company is purchasing " "service(s) for resale, at least in part, and that the company is " "incorporating the purchased services into its own offerings which " "are, at least in part, assessable U.S. telecommunications or " "interconnected Voice over Internet Protocol services. I also " "certify under penalty of perjury that the company either directly " "contributes or has a reasonable expectation that another entity in " "the downstream chain of resellers directly contributes to the " "federal universal service support mechanisms on the assessable " "portion of revenues from offerings that incorporate the purchased " "services." ) def _sp(p, after=6, before=0): p.paragraph_format.space_after = Pt(after) if before: p.paragraph_format.space_before = Pt(before) def _h(doc, text): p = doc.add_paragraph(); r = p.add_run(text) r.font.size = Pt(12); r.bold = True; r.font.color.rgb = _NAVY _sp(p, after=4, before=8) def _b(doc, text, bold=False, size=10): p = doc.add_paragraph(); p.alignment = WD_ALIGN_PARAGRAPH.LEFT r = p.add_run(text); r.font.size = Pt(size); r.bold = bold _sp(p, after=6) def generate_reseller_cert_attestation( output_path: str, filer_legal_name: str, filer_filer_id_499: str, reseller_legal_name: str, reseller_filer_id_499: str = "", reporting_year: int = 0, effective_date: str = "", filer_contact_name: str = "", filer_contact_email: str = "", filer_contact_phone: str = "", **_: dict, ) -> Optional[str]: """ Produce the Reseller Certification Attestation DOCX for signature by the reseller's authorized officer. """ if Document is None: LOG.error("python-docx not installed") return None if reporting_year == 0: reporting_year = datetime.now().year effective = effective_date or datetime.now().strftime("%B %d, %Y") doc = Document() for s in doc.sections: s.top_margin = Inches(1); s.bottom_margin = Inches(1) s.left_margin = Inches(1.25); s.right_margin = Inches(1.25) # Title tp = doc.add_paragraph(); tp.alignment = WD_ALIGN_PARAGRAPH.CENTER t = tp.add_run("Reseller Certification Attestation") t.font.size = Pt(15); t.bold = True; t.font.color.rgb = _NAVY _sp(tp, after=2) sp = doc.add_paragraph(); sp.alignment = WD_ALIGN_PARAGRAPH.CENTER s = sp.add_run( f"FCC Form 499-A Section IV.C.4 \u2014 Reporting Year {reporting_year}" ) s.font.size = Pt(10); s.font.color.rgb = RGBColor(0x55, 0x55, 0x55) _sp(sp, after=8) # ── 1. Parties ──────────────────────────────────────────────── _h(doc, "1. Parties") _b(doc, ( f"Filer (upstream wholesaler): {filer_legal_name}" + (f" | Filer 499 ID: {filer_filer_id_499}" if filer_filer_id_499 else "") )) _b(doc, ( f"Reseller (purchaser): {reseller_legal_name}" + (f" | Filer 499 ID: {reseller_filer_id_499}" if reseller_filer_id_499 else " | Filer 499 ID: _______________") )) _b(doc, f"Effective Reporting Year: {reporting_year}") _b(doc, f"Date of Attestation: {effective}") # ── 2. Purpose ──────────────────────────────────────────────── _h(doc, "2. Purpose") _b(doc, ( f"Pursuant to Section IV.C.4 of the FCC Form 499-A Instructions " f"({reporting_year}), {filer_legal_name} is required to obtain from " f"{reseller_legal_name} a signed certification that the services " f"purchased by the reseller are being incorporated into assessable " f"U.S. telecommunications or interconnected Voice over Internet " f"Protocol offerings, and that federal universal-service " f"contributions are flowing on those resold services. This " f"Attestation satisfies that requirement." )) # ── 3. Certification Language (verbatim) ────────────────────── _h(doc, "3. Certification") _b(doc, RESELLER_CERTIFICATION_SAMPLE_TEXT) # ── 4. Annual Renewal Notice ────────────────────────────────── _h(doc, "4. Annual Renewal") _b(doc, ( "This Attestation is effective for the reporting year stated " f"above and must be renewed annually. {filer_legal_name} will " f"request an updated, signed Attestation from {reseller_legal_name} " f"on or about January 1 of each subsequent reporting year. A " f"current signed Attestation must be on file at the time " f"{filer_legal_name} submits its Form 499-A for the reporting " f"year." )) # ── 5. Reseller Authorized Officer Signature ────────────────── _h(doc, "5. Signature — Reseller Authorized Officer") _b(doc, ( f"By signing below, the undersigned officer of {reseller_legal_name} " f"certifies that he or she is an authorized officer of the company, " f"has personal knowledge of the matters certified above, and " f"executes this Attestation on behalf of the company." )) # Blank signature block sig = doc.add_paragraph(); sig.add_run("_" * 55).font.size = Pt(10) _sp(sig, after=2) nm = doc.add_paragraph() nm.add_run("Name (printed): ").font.size = Pt(10) nm.add_run("_" * 40).font.size = Pt(10) _sp(nm, after=4) tt = doc.add_paragraph() tt.add_run("Title: ").font.size = Pt(10) tt.add_run("_" * 48).font.size = Pt(10) _sp(tt, after=4) co = doc.add_paragraph() co.add_run("Company: ").font.size = Pt(10) co.add_run(reseller_legal_name).font.size = Pt(10) _sp(co, after=4) dt = doc.add_paragraph() dt.add_run("Date: ").font.size = Pt(10) dt.add_run("_" * 20).font.size = Pt(10) _sp(dt, after=10) # ── 6. Filer Contact (for returning the signed form) ────────── _h(doc, "6. Return Signed Attestation To") _b(doc, filer_legal_name) if filer_contact_name: _b(doc, f"Attention: {filer_contact_name}") if filer_contact_email: _b(doc, f"Email: {filer_contact_email}") if filer_contact_phone: _b(doc, f"Phone: {filer_contact_phone}") out = Path(output_path) out.parent.mkdir(parents=True, exist_ok=True) doc.save(str(out)) LOG.info("Reseller Certification Attestation generated: %s", out) return str(out)