mirror of
https://git.meshkee.com/Meshkee/dashboards.git
synced 2026-08-11 22:30:58 +04:30
Add business Finance hub with invoices and templates.
Ship invoice issue/list/templates under Finance, fix tenant theme reset and owner role badge, and show customers-joined charts by Persian months. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
co-authored by
Cursor
parent
722933dda9
commit
917b840ee5
+37
-29
@@ -3,7 +3,7 @@
|
||||
> **For AI agents:** Read this file at the start of a new chat before making changes.
|
||||
> Update this document when a major feature is completed or architecture changes.
|
||||
|
||||
Last updated: August 9, 2026
|
||||
Last updated: August 11, 2026
|
||||
|
||||
---
|
||||
|
||||
@@ -188,6 +188,13 @@ Add to `/etc/hosts` (one line per tenant):
|
||||
| `/store/items` | Store items (product variants) | Yes |
|
||||
| `/store/settings` | Online sell + order process steps | Yes |
|
||||
| `/customers` | Business customers list | Yes |
|
||||
| `/finance` | Finance hub (Invoices + Transactions tiles) | Yes |
|
||||
| `/invoices` | Business-issued invoices list (`?userId=` filter) | Yes |
|
||||
| `/invoices/new` | Issue invoice to a user | Yes |
|
||||
| `/invoices/:invoiceId/edit` | Edit invoice (locked when approved) | Yes |
|
||||
| `/invoices/templates` | Invoice templates + item templates | Yes |
|
||||
| `/invoices/templates/new` | Create invoice template | Yes |
|
||||
| `/invoices/templates/:templateId` | Edit invoice template | Yes |
|
||||
| `/customer-products` | Customer user-product listings (admin API) | Yes |
|
||||
| `/customer-products/new` | Admin create user product (under admin name) | Yes |
|
||||
| `/customer-products/:id` | Customer user-product details | Yes |
|
||||
@@ -352,49 +359,50 @@ Run in order from `MeshkeeApp Backend/database/migrations/`:
|
||||
| `038_invoice_templates.sql` | Full invoice templates + key points / accounts |
|
||||
| `039_invoice_account_holder.sql` | Account holder name on bank accounts |
|
||||
| `040_invoice_public_id.sql` | Opaque 12-digit `public_id` for public links |
|
||||
| `041_invoice_status_approved.sql` | Invoice status `approved` |
|
||||
| `058_invoice_user_id.sql` | `invoices.user_id` billed user |
|
||||
|
||||
After schema changes: `npx prisma generate` and restart the backend.
|
||||
|
||||
### Invoices (super-admin)
|
||||
### Invoices (super-admin + business)
|
||||
|
||||
Two template layers + issued invoices:
|
||||
Billed party is always a **User** (`user_id`). `business_id` is tenant/context. Platform invoices: `owner_scope=platform` (super-admin). Business-issued: `owner_scope=business` + `issuer_business_id`.
|
||||
|
||||
| Layer | Purpose |
|
||||
|-------|---------|
|
||||
| **Invoice item templates** | Reusable line items (title, duration, worktime, desc, price, discounted) |
|
||||
| **Invoice templates** | Full blueprints: name, top text, items (from item templates or custom), duplicatable key points, duplicatable bank accounts (bank name, account holder, card, IBAN) |
|
||||
| **Invoices** | Issued to a business — start from an invoice template (editable) or blank |
|
||||
| **Invoice templates** | Full blueprints: name, top text, items, key points, bank accounts |
|
||||
| **Invoices** | Issued **to a user** — from template or blank |
|
||||
|
||||
| Endpoint | Purpose |
|
||||
|----------|---------|
|
||||
| `GET/POST /invoice-item-templates` | Platform line-item presets |
|
||||
| `PATCH/DELETE /invoice-item-templates/:id` | Update/remove line-item preset |
|
||||
| `GET/POST /invoice-item-templates` | Platform line-item presets (super-admin) |
|
||||
| `PATCH/DELETE /invoice-item-templates/:id` | Update/remove platform preset |
|
||||
| `GET/POST /invoice-templates` | Platform full invoice templates |
|
||||
| `GET/PATCH/DELETE /invoice-templates/:id` | Get / update / delete invoice template |
|
||||
| `GET/POST /businesses/:businessId/invoices` | List / issue invoices for a business |
|
||||
| `GET/PATCH/DELETE /businesses/:businessId/invoices/:invoiceId` | Detail, status update, delete |
|
||||
| `GET /public/invoices/:id` | Public show payload (issued/paid, no auth) |
|
||||
| `GET/PATCH/DELETE /invoice-templates/:id` | Platform template CRUD |
|
||||
| `GET/POST /businesses/:businessId/invoice-item-templates` | Business item templates |
|
||||
| `PATCH/DELETE .../invoice-item-templates/:id` | Business item template CRUD |
|
||||
| `GET/POST /businesses/:businessId/invoice-templates` | Business invoice templates |
|
||||
| `GET/PATCH/DELETE .../invoice-templates/:id` | Business invoice template CRUD |
|
||||
| `GET/POST /businesses/:businessId/invoices` | List / issue (`?userId=` filter; body `userId` required for business) |
|
||||
| `GET/PUT/PATCH/DELETE .../invoices/:invoiceId` | Detail, content, status, delete |
|
||||
| `GET /public/invoices/:publicId` | Public show (platform or business; issued/approved/paid) |
|
||||
| `POST /public/invoices/:publicId/approve` | Public approve (`issued` → `approved`) |
|
||||
|
||||
**Invoice fields:** optional `name`, `topText`, `notes`, `invoiceTemplateId`, `status`, `publicUrl`, nested `items`, `keyPoints`, `accounts` (bank name, account holder, card, IBAN).
|
||||
Auth: platform template routes → super-admin. Business routes → `BusinessPermissionGuard` (`invoices.*` / `invoice_templates.*`); super-admin on invoice paths still sees **platform** invoices for that business.
|
||||
|
||||
**Public invoice viewer (platform):**
|
||||
- Route: super-admin SPA `/invoices/:id` (`PublicInvoicePage`) — glass layout, print-to-PDF, Approve (`issued` → `approved`), “Issued by” Meshkee footer
|
||||
- Status `approved`: set from public show page; content becomes immutable for admins
|
||||
- Edit: list pencil → `/businesses/:businessId/invoices/:invoiceId/edit` (hidden when approved)
|
||||
- Links use opaque **12-digit `publicId`** (not sequential PK) — `GET /public/invoices/:publicId`
|
||||
- Local/dev link: current Vite origin (e.g. `https://meshkee.app:5174/invoices/{publicId}`)
|
||||
- Production link domain: `VITE_INVOICE_PUBLIC_DOMAIN` / `INVOICE_PUBLIC_DOMAIN` (default `meshkee.com`) — optional full origin override via `*_PUBLIC_BASE_URL`
|
||||
- Until `meshkee.com` proxies or hosts `/invoices/*`, production links may need that DNS/nginx wiring (viewer code ships with super-admin build)
|
||||
**Invoice fields:** `userId` + nested `user`, optional `name`, `topText`, `notes`, `invoiceTemplateId`, `status`, `publicUrl`, nested `items`, `keyPoints`, `accounts`.
|
||||
|
||||
**Migrations:** `036_invoices.sql` … `040_invoice_public_id.sql`
|
||||
**Public invoice viewer:**
|
||||
- Super-admin SPA `/invoices/:publicId` (`PublicInvoicePage`) — print-to-PDF; opaque 12-digit `publicId`
|
||||
- Platform invoices: `https://{INVOICE_PUBLIC_DOMAIN}/invoices/{publicId}` (default `meshkee.com`)
|
||||
- Business invoices: `https://{primaryBusinessDomain}/invoices/{publicId}` (e.g. `sanihome.ir`)
|
||||
|
||||
**Super Admin UI:**
|
||||
- `/settings` — Invoice templates list + item templates (top text preview = one-line ellipsis)
|
||||
- `/settings/invoice-templates/new` · `/settings/invoice-templates/:id` — full-page template editor (not modal)
|
||||
- `/businesses/:businessId/invoices` — list + view modal
|
||||
- `/businesses/:businessId/invoices/new` — full-page issue form
|
||||
- `/invoices/:id` — public viewer (no auth)
|
||||
- Schema supports future `owner_scope=business` (business-owned templates)
|
||||
**Migrations:** `036_invoices.sql` … `041_invoice_status_approved.sql`, `058_invoice_user_id.sql`
|
||||
|
||||
**Super Admin UI:** `/settings` templates; `/businesses/:id/invoices` list/issue/edit; public `/invoices/:publicId`
|
||||
|
||||
**Business UI:** sidebar Finance group → `/finance` (hub), `/invoices`, `/transactions`; home Finance tile; Users row Receipt icon → `/invoices?userId=`; i18n en/fa via `useT`
|
||||
|
||||
---
|
||||
|
||||
@@ -569,7 +577,6 @@ Products overview page uses the same i18n + theme-aware `ProductActivityChart` (
|
||||
## Suggested next work
|
||||
|
||||
- Point `meshkee.com/invoices/*` at the public invoice viewer (proxy or dedicated host)
|
||||
- Business-dashboard invoice templates + issue flow (`owner_scope=business`)
|
||||
- Migrate business and super-admin fully onto `@meshkee/dashboard-core` / `@meshkee/dashboard-ui` (LocaleProvider already shared)
|
||||
- Finish FA/EN coverage on remaining business form pages (many labels still English)
|
||||
- Connect product comments to backend
|
||||
@@ -577,6 +584,7 @@ Products overview page uses the same i18n + theme-aware `ProductActivityChart` (
|
||||
- Enforce `onlineSellEnabled` on public website checkout
|
||||
- Postman collection updates for variants endpoints
|
||||
- Add `sanihome.ir` (and other tenants) in production Super Admin so tenant APIs resolve
|
||||
- Customer dashboard “my invoices” view
|
||||
|
||||
---
|
||||
|
||||
|
||||
Reference in New Issue
Block a user