feat: add invoice builder with line detail, address, and person picker.

Enrich invoice line items and previews, migrate several CRM surfaces to Ant, and wire shared money/picker helpers.
This commit is contained in:
2026-11-30 14:34:47 +03:30
parent f1bcb232ee
commit 33c95d72a8
64 changed files with 5813 additions and 2737 deletions
@@ -0,0 +1,89 @@
# Invoice Preview Templates — Design Spec
**Date:** 2026-11-30
**Status:** Approved in conversation (preview-only selection; approach C; 5 distinct moods)
## Problem
Current `InvoiceDocPreview` looks cluttered: repeated doc-type labels, a dense 6-field metadata grid, weak hierarchy, and a generic “wireframe” look. Users need multiple luxurious, professional invoice looks they can switch in preview/print.
## Goals
1. Five visually distinct invoice templates available in the preview modal.
2. Template choice applies to both on-screen preview and print HTML.
3. Reduce clutter: fewer competing labels, clearer hierarchy, calmer table/totals.
4. Keep Ant Design Vue governance for modal chrome (segmented, buttons); sheet itself is print-oriented HTML/CSS.
## Non-goals
- Org-level default template persistence (settings / API) — later.
- Per-invoice template stored on Invoice model — later.
- Changing invoice data model, builder grid, or totals logic.
- Migrating other pages or legacy print paths outside `InvoiceDocPreview`.
## Approach
**Shared skeleton + distinct layouts/themes (approach C):**
- One data/render pipeline (props → line rows → totals).
- Three layout families reused across five moods:
- Wide colored header band
- Dark sidebar + light body
- Minimal / editorial / modern header variants
- Five named themes with different color, typography weight, and chrome — not five fully forked HTML trees.
## Templates
| Id | Label (FA) | Mood | Accent | Layout family |
|----|------------|------|--------|---------------|
| `emerald` | کلاسیک زمردی | Brand / professional | Emerald green | Wide header band |
| `noir` | اجرایی تیره | Luxury corporate | Navy + soft gold | Dark sidebar |
| `pearl` | مرواریدی | Luxury minimal | Near-black on white | Minimal lines only |
| `sand` | ادیتوریال شنی | Editorial / magazine | Warm beige + brown | Soft top wash + asymmetric meta |
| `slate` | مدرن اسلیت | Modern technical | Slate + teal accent | Two-column header + chip meta |
**Default:** `emerald`
### Shared content rules (all templates)
- Show doc type **once** (no duplicate “فاکتور فروش” in header corners).
- Primary meta in header: customer, issue date, due/valid, title (max 4). Status and currency move to compact chips or footer strip — not a 6-cell dense grid.
- Table: calm header, generous row padding, amount column emphasized; optional unit/discount/tax columns only when data needs them (existing logic).
- Totals: one clear block (bottom-start in RTL); notes opposite side when present.
- Paper sizes A4 / A5 remain; template scales typography slightly for A5.
### Per-template chrome (summary)
1. **Emerald:** thin emerald top bar; soft emerald table header; totals box with emerald payable.
2. **Noir:** ~18% navy sidebar (org + doc type); navy table header / white text; gold payable; notes with thin gold rule.
3. **Pearl:** oversized org name; no color bars; thick rule under column headers; totals as typography only (no bordered card).
4. **Sand:** soft beige top third; editorial title; muted brown labels; warm beige totals column.
5. **Slate:** aligned two-column header; meta as chips; slate table header; payable in teal strip / soft card.
## UX (preview modal)
- Header/footer chrome stays Ant: `a-segmented` for **template** (5 short FA labels) + existing A4/A5 segmented + print/close.
- Selected template drives both preview sheet and `printSheet()` CSS/HTML.
- No persistence beyond the open modal session (reset to `emerald` when modal opens is acceptable; optionally remember last choice in `sessionStorage` — nice-to-have, not required).
## Implementation touchpoints
| Area | Change |
|------|--------|
| `apps/web/src/components/InvoiceDocPreview.vue` | Template state, preview markup per layout/theme, print HTML/CSS parity |
| Call sites | No prop API change required unless we later expose `defaultTemplate` |
Prefer extracting shared helpers (escape, money, row HTML, col visibility) inside the same file or a small colocated module if the SFC grows too large — avoid premature split.
## Success criteria
- User can switch among 5 looks in preview without leaving the modal.
- Print matches the selected look (colors with `print-color-adjust: exact`).
- Preview feels less cluttered than current (no duplicate titles; meta ≤ 4 primary fields).
- `npm run build -w @mento/web` passes; Ant control rules on modal chrome unchanged (no manual `size`).
## Out of scope follow-ups
- Org setting “default invoice template”
- Persist template on invoice record
- PDF generation service (server-side)