DOT D&A binder: editable DOCX output, all 6 forms each full-page, service-aware delivery email

- Rewrite dot_da_binder_generator.py to emit an editable .docx (was reportlab PDF)
  so carriers/counsel can review and adapt the program. ~4000 words, 10 sections.
- Render all six required forms (A-F); previously only A, D, E existed. Each form
  starts on its own page (page break) and fills a page.
- Mode-aware policy text for FMCSA/FRA/PHMSA/FTA/FAA/USCG with correct CFR parts
  and random-testing rates; optional single-state Drug-Free Workplace addendum
  (federal DOT program is nationwide; only the optional DFWP addendum is state-keyed).
- Handler now outputs .docx instead of .pdf.
- job_server instant-delivery: attach DOCX (correct MIME) as well as PDF, and use
  DOT-specific email copy + CTA instead of the FCC/telecom boilerplate.
This commit is contained in:
justin 2026-06-02 21:27:44 -05:00
parent 06e59965cc
commit 9718ab9ffa
4 changed files with 1138 additions and 672 deletions

View file

@ -2,20 +2,24 @@
DOT Drug & Alcohol Compliance Program handler ($149).
Instant-delivery service: when a motor carrier orders the program we
generate a complete, print-ready PDF "binder" and email it to them
automatically (no admin step). The binder bundles the written testing
policy, program-management instructions, supervisor-training materials and
access, EAP / rehab / SAP resources, regulation citations, random-testing
instructions, required forms, and recordkeeping guidance.
generate a complete, editable Word (.docx) "binder" and email it to them
automatically (no admin step). DOCX is used so the carrier and its counsel
can review and adapt the program before adopting it. The binder bundles the
written testing policy, program-management instructions, supervisor-training
materials and access, EAP / rehab / SAP resources, regulation citations,
random-testing instructions, all required forms (A-F, each on its own page),
and recordkeeping guidance.
Policy variant (DOT operating administration) selection:
For a trucking carrier the program is FMCSA (49 CFR Part 382) that is
the default. If the customer's operation falls under a different DOT mode
(FRA, PHMSA, FTA, FAA, USCG) we honor an explicit ``dot_da_mode`` value in
the intake data. An optional ``state_dfwp`` value appends a state
Drug-Free Workplace addendum.
Drug-Free Workplace addendum (keyed to the carrier's home/principal state,
not per-employee the federal DOT program itself is nationwide and not
state-specific).
Returns the local PDF path so job_server uploads it to MinIO and the
Returns the local DOCX path so job_server uploads it to MinIO and the
INSTANT_DELIVERY path emails it to the customer.
"""
from __future__ import annotations
@ -92,7 +96,7 @@ class DrugAlcoholProgramHandler(BaseServiceHandler):
c for c in carrier_name if c.isalnum() or c in (" ", "-", "_")
).strip().replace(" ", "_")[:40] or "carrier"
out_path = os.path.join(
work_dir, f"DOT_DA_Compliance_Binder_{safe_name}_{date_str}.pdf"
work_dir, f"DOT_DA_Compliance_Binder_{safe_name}_{date_str}.docx"
)
from scripts.document_gen.templates.dot_da_binder_generator import (