u
This commit is contained in:
16
README.md
16
README.md
@@ -434,7 +434,16 @@ Errors: `No company selected`, `Company not found`, `Not authorized`, `Order not
|
||||
|
||||
## `ledger`
|
||||
|
||||
Append-only SQL Server ledger table (`WITH (LEDGER = ON (APPEND_ONLY = ON))`). Rows cannot be updated or deleted. References `manifestarticle` with `ON DELETE NO ACTION` (a line with ledger entries cannot be removed). No store API yet — INSERT only via future store methods / direct SQL.
|
||||
Append-only SQL Server ledger table (`WITH (LEDGER = ON (APPEND_ONLY = ON))`). Rows cannot be updated or deleted. References `manifestarticle` with `ON DELETE NO ACTION` (a line with ledger entries cannot be removed). Auth via selected company (`google_auth.selected_company` + membership; line must belong to company).
|
||||
|
||||
| Method | Signature | Returns |
|
||||
| --- | --- | --- |
|
||||
| `add` | `(googleAuthId, { manifestarticle_id, transaction_type, amount, transaction_text })` | `{ id, manifestarticle_id, transaction_type, amount, transaction_text, hash_version, prev_hash, created_at }` |
|
||||
| `listByManifestarticleId` | `(googleAuthId, manifestarticleId, [transactionType])` | `{ id, manifestarticle_id, sku, transaction_type, amount, transaction_text, hash_version, prev_hash, created_at }[]` |
|
||||
| `listBySku` | `(googleAuthId, sku, [transactionType])` | `{ id, manifestarticle_id, sku, transaction_type, amount, transaction_text, hash_version, prev_hash, created_at }[]` |
|
||||
|
||||
- `hash_version`: 1
|
||||
- `prev_hash`: For the first entry in the database, `TODO_TSE_BASED_INITHASH`. For subsequent entries, SHA-512 hex of canonical JSON `JSON.stringify({ id, manifestarticle_id, transaction_type, amount, transaction_text, hash_version, prev_hash, created_at })` of the entry with the highest `id`.
|
||||
|
||||
| Column | Type | Notes |
|
||||
| --- | --- | --- |
|
||||
@@ -443,8 +452,9 @@ Append-only SQL Server ledger table (`WITH (LEDGER = ON (APPEND_ONLY = ON))`). R
|
||||
| `transaction_type` | `NVARCHAR(100)` | |
|
||||
| `amount` | `FLOAT` | |
|
||||
| `transaction_text` | `NVARCHAR(MAX)` | |
|
||||
| `hash_version` | `INT` | hash algorithm / payload version |
|
||||
| `prev_hash` | `NVARCHAR(128)` | nullable (genesis row) |
|
||||
| `hash_version` | `INT` | hash algorithm / payload version (1) |
|
||||
| `prev_hash` | `NVARCHAR(128)` | SHA-512 hex of previous row or init hash |
|
||||
| `created_at` | `DATETIME2` | Creation timestamp |
|
||||
|
||||
Engine also maintains `ledger_start_transaction_id` / `ledger_start_sequence_number`. `purge`/`reset-db` soft-drops the table (`MSSQL_DroppedLedgerTable_*` remains; a new `ledger` can still be created).
|
||||
|
||||
|
||||
Reference in New Issue
Block a user