From e6c0d0d51b43b5d06ab724acae0827399cc211e2 Mon Sep 17 00:00:00 2001 From: Stephen Waits Date: Sun, 8 Nov 2026 21:25:16 -0700 Subject: [PATCH] test(core): the adapter reads due dates from the engine The bookspec adapter took a custom terms' due date by parsing the example's terms text, which sidestepped the engine bug that custom terms were due on the document's own date, so no example could catch it. It now takes every due date, custom included, from Terms::due_date; an example on "Due 2026-11-15" passes only if the engine computes 2026-11-15 (BS-arap-3). Co-Authored-By: Claude Sonnet 5.5 --- crates/ledger-core/tests/bookspec/events.rs | 26 +++++++-------------- crates/ledger-core/tests/bookspec/main.rs | 4 ++-- 2 files changed, 11 insertions(+), 19 deletions(-) diff --git a/crates/ledger-core/tests/bookspec/events.rs b/crates/ledger-core/tests/bookspec/events.rs index 4153c2e5..00eba781 100644 --- a/crates/ledger-core/tests/bookspec/events.rs +++ b/crates/ledger-core/tests/bookspec/events.rs @@ -203,12 +203,12 @@ impl Books<'_> { } /// The terms a document's example gives, and the due date the books take - /// them to (BS-arap-3): the engine's own `Terms::due_date`, except for a - /// date the parties agreed ("Due 2026-11-15"), which that call leaves to - /// its caller (the engine's contract: the caller passes the agreed date, - /// which the terms' canonical text carries). The example's spelling is - /// the canonical one, so the engine must print it back as written. - /// Without terms a document is due on its own date. + /// them to (BS-arap-3): the engine's own `Terms::due_date` for every + /// kind, a date the parties agreed ("Due 2026-11-15") included. The + /// example's spelling is the canonical one, so the engine must print it + /// back as written. Nothing of the date is read out of the text here: + /// the example can only pass if the engine computes it. Without terms a + /// document is due on its own date. pub(crate) fn terms_due( &self, terms: Option<&str>, @@ -224,17 +224,9 @@ impl Books<'_> { text, "{what}: the engine prints terms {text:?} back as written" ); - let due = match parsed.kind() { - TermsKind::Custom => { - let agreed = text.strip_prefix("Due ").unwrap_or_else(|| { - panic!("{what}: custom terms {text:?} carry their date after \"Due \"") - }); - crate::date(agreed, what) - } - _ => parsed - .due_date(date) - .unwrap_or_else(|e| panic!("{what}: terms {text:?} on {date}: {e}")), - }; + let due = parsed + .due_date(date) + .unwrap_or_else(|e| panic!("{what}: terms {text:?} on {date}: {e}")); (due, Some(parsed)) } diff --git a/crates/ledger-core/tests/bookspec/main.rs b/crates/ledger-core/tests/bookspec/main.rs index e0f9c456..f835ecaf 100644 --- a/crates/ledger-core/tests/bookspec/main.rs +++ b/crates/ledger-core/tests/bookspec/main.rs @@ -55,8 +55,8 @@ pub(crate) use ledger_core::{ InstrumentId, InstrumentKind, InvoiceFields, Ledger, LedgerError, MemberCapital, MemberClose, Money, NewAsset, NewSchedule, PartyId, PartyMember, PartyShare, PaymentAccounts, ReconcilingKind, Role, ScheduleConvention, ScheduleId, ScheduleKind, Share, Side, Terms, - TermsKind, TinFacts, TinType, VendorId, W9Facts, cash_flow, members_equity, - profit_and_loss_for_period, trial_balance_as_of, vendor_1099_report, + TinFacts, TinType, VendorId, W9Facts, cash_flow, members_equity, profit_and_loss_for_period, + trial_balance_as_of, vendor_1099_report, }; pub(crate) use ledger_store::{DepreciationRun, DisposalPreview, Store, StoreError}; pub(crate) use rust_decimal::Decimal;