Uecko_ERP/docs/customer-invoices/proforma-archive-contract.md
david a264f43b95 feat: enhance proforma listing and archiving functionality
- Updated proforma listing behavior to utilize `Criteria filters[]` for managing archived and active proformas.
- Removed `archived` query parameter from backend; frontend now manages `archiveView` state.
- Implemented new filters for `archived_at` and `status` in the proforma listing API.
- Adjusted proforma creation and deletion contracts to reflect changes in archiving logic.
- Introduced new utility functions for building proforma listing criteria based on UI state.
- Updated frontend components to support new filtering options and maintain state in the URL.
- Added SQL index for improved performance on proforma queries.
- Created new TypeScript types for managing proforma list filters and criteria.
2026-07-29 22:24:53 +02:00

40 lines
1.6 KiB
Markdown

# Proforma archive contract
## Rules
- Archive uses `archived_at` and does not change `status`.
- Only `draft` and `rejected` proformas can be archived in V1.
- Only `draft` and `rejected` archived proformas can be unarchived in V1.
- Archived proformas remain available through `GET /proformas/:id`.
- Deleted proformas remain excluded from every flow.
- Numbering is never reused and `document_series.next_number` is untouched.
- Archived `draft` proformas can be deleted directly without unarchiving.
## Endpoints
- `PATCH /proformas/:proforma_id/archive`
- `PATCH /proformas/:proforma_id/unarchive`
Both endpoints:
- return `200` with the updated proforma snapshot
- return `404` when the proforma does not exist, belongs to another company, or is deleted
- return `409` when the state is not allowed, when the proforma is already archived/non-archived, or when it is linked to an issued invoice
## Listing behavior
- `GET /proformas` excludes archived proformas by default through `filters[]=archived_at IS_NULL`
- the backend does not expose `archive_view` as a query param
- the frontend keeps `archiveView=active|archived|all` only as UI state and translates it to `Criteria filters[]`
- active view sends `archived_at IS_NULL`
- archived view sends `archived_at IS_NOT_NULL`
- all view sends no `archived_at` filter
- `q` always applies inside the scope produced by `filters[]`
## Notes
- `archived` is a visibility dimension, not a business status
- V1 does not support archiving `sent`, `approved`, or `issued`
- V1 does not add `archived_by` or `archive_reason`
- soft-deleted proformas stay excluded structurally by `deleted_at`