app.approval_instances
TableRow level security on
A spend document going through its approval policy. Created only by app.request_approval, which reads the amount, currency and project from the document; decided step by step through app.decide_approval.
Primary key: id
| Column | Type | Nullable | Description |
|---|---|---|---|
| id | uuid | No | Primary key, UUID v7. |
| org_id | uuid | No | Owning org, derived from app.approval_policies on insert; never accepted from the caller and never changed.References app.organizations.id |
| approval_policy_id | uuid | No | Policy the document goes through.References app.approval_policies.id |
| document_type | app.spend_document_type | No | Spend document type. |
| document_id | uuid | No | Id of the document in subject_table. |
| subject_table | text | No | Table of the document: purchase_orders, po_change_orders, change_orders, invoices, requisitions, expenses or payroll_runs. |
| subject_reference | text | Yes | The document's own number or name when requested, for display. |
| project_id | uuid | Yes | Project of the document; NULL for org-level documents such as payroll runs.References app.projects.id |
| amount_minor | bigint | No | Amount submitted for approval, in minor units; the approval covers the document only while its amount stays at or below it. |
| currency_code | character(3) | No | ISO 4217 currency of the amount.References private.currencies.currency_code |
| requested_by | uuid | No | Person who requested the approval; never an approver of it (sod_approval_requester).References app.people.id |
| approval_state | app.approval_state | No | In Review, Approved, Rejected or Canceled. Changes only through the approval RPCs. |
| current_step | smallint | No | Step order waiting for a decision while In Review; the last step decided afterwards. |
| decided_at | timestamp with time zone | Yes | When the approval was approved, rejected or canceled; NULL while In Review. |
| deleted_at | timestamp with time zone | Yes | Soft delete time. A row with deleted_at set is ignored by every access helper. |
| created_at | timestamp with time zone | No | When the row was inserted. Set by the database. |
| created_by | uuid | Yes | Person who inserted the row, or null for a platform process. Set by the database.References app.people.id |
| updated_at | timestamp with time zone | No | When the row last changed. Set by the database. |
| updated_by | uuid | Yes | Person who last changed the row, or null for a platform process. Set by the database.References app.people.id |