Backing transaction ledger: Postings replace the applied field #20
Loading…
Reference in a new issue
No description provided.
Delete branch "feat/19-posting-ledger"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Closes #19 (will be manually closed on merge).
Summary
The
appliedcolumn onmonth_entryis gone. Each entry now owns a ledger of Postings (transactions). Applied is a derived sum. Existing applied values migrate into one opening-balance posting per entry.postingtable (id, month_entry_id FK CASCADE, occurred_on, amount, description NULL, payee NULL, timestamps).month_entry.applieddropped.cc60e7f73a1c: creates the posting table, seeds opening-balance rows from every non-zero applied, then drops the column. Downgrade re-adds and populates fromSUM(posting.amount).add_posting,update_posting,delete_posting, all behindensure_editable.update_month_entryloses theappliedkwarg (removed; callers should post).POST /month/{ym}/entries/{entry_id}/postingsaddPOST /month/{ym}/postings/{posting_id}edit (date / amount / description / payee, any subset)DELETE /month/{ym}/postings/{posting_id}delete<details>block with a leading caret. Collapsed view adds no horizontal space; applied cell shows$412.33 · 7 txnswhen postings exist. Expanded body holds the notes input, a transactions table (date / description / payee / amount / delete, ordered newest-first), and an inline add-posting form. Closed months render read-only spans instead of inputs and omit delete buttons and forms.Test plan
uv run pytestpasses (117/117, +15 new intest_postings.py)uv run alembic upgrade headapplies cleanly;alembic downgrade -1reverses correctly<details>entry blocks with caret, applied cell, transactions table, add formPOST .../postingsadds a transaction; applied cell and zero widget update via OOBDELETE .../postings/{id}removes a posting; applied recomputesOut of scope
add_posting / update_posting / delete_posting all go through ensure_editable(month), so closed months reject posting mutations with the same lifecycle guard as every other mutation. Negative amounts are allowed for refunds / corrections. Dates are parsed as ISO (YYYY-MM-DD) but not constrained to the month for now. update_month_entry loses the applied keyword; the route no longer accepts an applied form field. applied is derived only from now on. Three new routes wire the ledger: POST /month/{ym}/entries/{entry_id}/postings POST /month/{ym}/postings/{posting_id} DELETE /month/{ym}/postings/{posting_id} Each returns the updated section partial plus OOB swaps for the zero widget and all four group totals, same pattern the existing mutations use. Refs #19 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>Each month entry becomes a <details> block. The summary is the same dense row (name, planned, applied, delete) plus a leading caret and an applied cell that shows the transaction count ("$412.33 · 7 txns") when postings exist. Expansion adds no horizontal space. Expanded body holds: the entry's notes input, a transactions table with date / description / payee / amount / delete per posting, and an inline add-transaction form (date, description, payee, amount, submit). Every field is HTMX-wired so editing any cell triggers the section partial re-render with fresh derived totals. Closed month: name / planned / notes / posting fields all collapse to read-only spans, delete buttons and add forms are omitted. The existing editable flag controls the branching. Refs #19 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>Every section used to end with a wide horizontal add form (name input, amount input, button, notes input spanning the row). It took up more horizontal real estate than the entries themselves. Now the form is wrapped in a <details class="add-entry"> whose summary is a small tracked-caps link ("+ add fixed amount bills"). Click to reveal the same form below; HTMX submission still resets and hides on success. Same treatment on the budget page sections and the month page sections. Refs #19 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>