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 <noreply@anthropic.com>
This commit is contained in:
swaitsandClaude Sonnet 5.5 committed 2026-11-08 21:25:16 -07:00
1 parent 71a4e7e59d
commit e6c0d0d51b
2 files changed
+11 -19

No files matched your search

+9 -17
View File
@@ -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))
}
+2 -2
View File
@@ -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;