Files
delphi-database-v2/docs/next-section-prompt.md

2.4 KiB

Next Section Prompt — Reports: Envelope, Phone Book (variants), Rolodex Info

Implement the next set of reports building on existing report infrastructure.

Context:

  • Phone Book HTML/CSV/PDF is already implemented at /reports/phone-book using build_phone_book_pdf and report_phone_book.html.
  • Bulk selection from rolodex.html posts to /reports/phone-book.

Goals:

  1. Envelope report (PDF)
  • Endpoint: GET /reports/envelope?client_ids=...&q=...&format=pdf
  • Input: either selected client_ids (from rolodex bulk) or current filter q.
  • Output: PDF of #10 envelope mailing blocks, one per client, paginated. Address format:
    • Line 1: First Last (or Company if present and person name is blank)
    • Line 2: Company (optional if name already used)
    • Line 3: Address
    • Line 4: City, ST ZIP
  • Implementation: build_envelope_pdf(clients) in app/reporting.py using fpdf2 with sensible margins and font sizes.
  1. Phone Book — Address & Phone variant (HTML/CSV/PDF)
  • Extend existing GET /reports/phone-book to support variant=address_phone.
  • Columns: Name, Company, Address, City, State, Zip, Phone Type, Phone Number.
  • CSV: include all columns above.
  • PDF: tabular layout similar to current phone book, trimmed to fit page width.
  1. Rolodex Info report (PDF)
  • Endpoint: GET /reports/rolodex-info?client_ids=...&q=...&format=pdf
  • Output: Per-client summary blocks showing key details:
    • Name (Last, First), Company
    • Address, City/State/Zip
    • All phone numbers (type + number)
  • Implementation: build_rolodex_info_pdf(clients) in app/reporting.py, multi-column or stacked blocks with clear headings and light separators.

UI wiring:

  • In rolodex.html bulk actions, add buttons/links for:
    • Envelope (Selected) → POST to /reports/envelope or GET with client_ids
    • Phone Book CSV/PDF (Current Filter) with variant=address_phone
    • Rolodex Info (Selected)

Acceptance Criteria:

  • All endpoints require auth; respect client_ids or q filtering similar to phone book.
  • CSV downloads set Content-Disposition with meaningful filenames.
  • PDFs render at least one page with legible typography and pagination.
  • Logging: add structured logs for render/export start/end with counts.

Non-goals (for this pass):

  • Advanced formatting (duplex, custom fonts), i18n, or bulk email generation.

Test notes:

  • Use existing seed/import flows to populate clients and phones.
  • Validate downloads via browser and ensure no server errors in logs.