Enrich invoice line items and previews, migrate several CRM surfaces to Ant, and wire shared money/picker helpers.
4.6 KiB
4.6 KiB
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
- Five visually distinct invoice templates available in the preview modal.
- Template choice applies to both on-screen preview and print HTML.
- Reduce clutter: fewer competing labels, clearer hierarchy, calmer table/totals.
- 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)
- Emerald: thin emerald top bar; soft emerald table header; totals box with emerald payable.
- Noir: ~18% navy sidebar (org + doc type); navy table header / white text; gold payable; notes with thin gold rule.
- Pearl: oversized org name; no color bars; thick rule under column headers; totals as typography only (no bordered card).
- Sand: soft beige top third; editorial title; muted brown labels; warm beige totals column.
- 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-segmentedfor 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
emeraldwhen modal opens is acceptable; optionally remember last choice insessionStorage— 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/webpasses; Ant control rules on modal chrome unchanged (no manualsize).
Out of scope follow-ups
- Org setting “default invoice template”
- Persist template on invoice record
- PDF generation service (server-side)