Expand description
Single source of truth for record envelopes, double-entry finance, and cooperative projects. Personal and cooperative double-entry finance ledger — signed, replay-safe entries with derived balances, integer banker’s rounding, and multi-book journal envelopes.
Implements the master plan’s money-safety rules (§5 SyncService, §17 risk table): ledger and journal entries merge add-wins by stable entry id and never by raw sum, and balances are a pure derivation over the unique-id set, so duplicate, reordered, or replayed sync operations can never duplicate money.
Structs§
- Balance
Report - Derived balance across all currencies present in the ledger.
- Currency
Balance - Net position and entry count for a single currency.
- Journal
Entry Record - An immutable double-entry journal entry record assigned to a
LedgerBook. - Journal
Line - A single double-entry journal line denominated in integer minor units (cents).
- Ledger
Entry - A single immutable ledger entry. Amount is signed minor units (cents): positive = credit/income, negative = debit/expense. Entries are never mutated; a correction is a new entry, so the id is a stable content anchor for dedup.
Enums§
- Ledger
Book - Canonical ledger books across personal, cooperative project, and finite compensation accounting.
Functions§
- build_
ledger_ entry_ envelope - Builds ledger-entry-envelope.
- derived_
balance - Derive the balance purely from the unique-id set. Duplicate ids in the input are collapsed first, so the result is invariant under duplication/reordering.
- div_
round_ bankers - Integer division with round-half-to-even (banker’s rounding) for minor-unit (
i64) and basis-point (i128) monetary arithmetic. Zero heap allocation, zero float math. - ledger_
entry_ record_ id ledger-entry-recordID.- ledger_
entry_ summary - Lossless JSON summary of a
LedgerEntryfor journal storage and sync. - ledger_
summary - Alias for
ledger_entry_summary. - merge_
journal_ entries - Replay-safe, order-independent union of double-entry
JournalEntryRecords by stableid. Unbalanced entries are rejected so corrupted frames cannot poison the ledger. - merge_
ledger - Merge two ledger sets add-wins by stable entry id (never sum-merge), returning a deterministically ordered union.
- parse_
ledger_ entry_ summary - Reconstruct a full
LedgerEntryfrom a summary JSON string (preservingcounterparty,project_id,category,description, andoccurred_at_instantlosslessly). - parse_
ledger_ summary - Parse a ledger summary JSON back into a full
LedgerEntry.