# 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`