feat: pending/cleared two-phase + available balance (#7) #18
Loading…
Reference in a new issue
No description provided.
Delete branch "feat/issue-7-pending-cleared"
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?
Pending / cleared two-phase + available balance
Fifth and final server item of the P1 double-entry tier (#7): two-phase settlement
(TigerBeetle two-phase / Modern Treasury pending/posted).
A transaction now carries a
pendingflag (default false = settled). The available balanceexcludes pending transactions; the existing
currentBalance(ledger balance) still includeseverything. A
settleoperation flips a pending transaction to settled.Terminology:
pending/settled is a TRANSACTION-level settlement status, distinct from thesplit-level
cleared_in_event_id(reconciliation against a bank statement) and frompostedBy/committed_at— documented in the domain type.Purely additive — ledger-balance behavior unchanged
currentBalance, running-balance, statements, andcontent_hash/idempotency are untouched;pending is a separate axis surfaced via a new available-balance query.
Surfaces
ALTER TABLE transactions ADD COLUMN pending INTEGER NOT NULL DEFAULT 0.DoubleEntryTransaction.pending.pending;transactionsByAccountSettled;Commands.availableBalance(settled-only);
settleTransaction(flips pending→0, notFound guard).pendingon post + detail + register; newSettleTransaction(write) +GetAvailableBalance(read) RPCs.pendingon post + view models;settleTransaction,availableBalance.pendingon propose/commit_post_transaction;settle_transaction(write) +get_available_balance(read) tools.PendingTransactionTests), gRPC (PendingTransactionRPCTests), MCP.Correction/edit preserves settlement status (effective-date lesson applied)
The correction reversal (
Correction.swift) and the superseding replacement(
Commands.txnEdit) both carry the original'spending, soavailableBalancenets to zerocorrectly across an edit of a pending transaction — covered by a regression test.
⚠️ Migration version — cross-branch coordination
Numbered version 12 (main at 8; v9=attachments #15, v10=effective-date #16, v11=budgets #17 on
their still-open branches). Per-recorded-version migrator → gap-safe. When merging the migration
PRs, order the
Schema.migrationsarray by version and set the count assertion accordingly.Scope
Completes the #7 P1 server tier (5/5 items). Note (like effective-date's app path): the gRPC/app
edit path preserves pending only via the store correction machinery; wiring an explicit pending
override onto the gRPC
EditTransactionis a documented follow-up. Does not close #7.fee0079a4cedf0b4f31aView command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.