From 3c33c79a75b43ec8763b9e9f5a3806df0ec0a4e8 Mon Sep 17 00:00:00 2001 From: Stephen Waits <1+swaits@noreply.git.swaits.com> Date: Sun, 11 Oct 2026 01:37:03 +0000 Subject: [PATCH] First slice: ledger-store (journal+blobs+sqlite) and ledger-mcp (18 tools, receipt policy) --- crates/ledger-core/src/ledger.rs | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/crates/ledger-core/src/ledger.rs b/crates/ledger-core/src/ledger.rs index ccb1e9a..1aa3c4e 100644 --- a/crates/ledger-core/src/ledger.rs +++ b/crates/ledger-core/src/ledger.rs @@ -39,6 +39,21 @@ impl Ledger { } } + /// The id the next account added will receive. + /// + /// Exposed for journaling stores that record the id before mutating. + /// The value is only stable if no other mutation intervenes. + pub fn next_account_id(&self) -> AccountId { + self.next_account_id + } + + /// The id the next journal entry created will receive. + /// + /// See [`Self::next_account_id`]. + pub fn next_entry_id(&self) -> EntryId { + self.next_entry_id + } + /// The currency every account and line in this ledger uses. pub fn base_currency(&self) -> Currency { self.base_currency @@ -76,10 +91,8 @@ impl Ledger { pub fn create_entry(&mut self, date: NaiveDate, description: &str) -> EntryId { let id = self.next_entry_id; self.next_entry_id += 1; - self.entries.insert( - id, - JournalEntry::draft(id, date, description.to_string()), - ); + self.entries + .insert(id, JournalEntry::draft(id, date, description.to_string())); id }