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:
1 parent
71a4e7e59d
commit
e6c0d0d51b
2 files changed
+11
-19
No files matched your search
@@ -203,12 +203,12 @@ impl Books<'_> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// The terms a document's example gives, and the due date the books take
|
/// 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
|
/// them to (BS-arap-3): the engine's own `Terms::due_date` for every
|
||||||
/// date the parties agreed ("Due 2026-11-15"), which that call leaves to
|
/// kind, a date the parties agreed ("Due 2026-11-15") included. The
|
||||||
/// its caller (the engine's contract: the caller passes the agreed date,
|
/// example's spelling is the canonical one, so the engine must print it
|
||||||
/// which the terms' canonical text carries). The example's spelling is
|
/// back as written. Nothing of the date is read out of the text here:
|
||||||
/// the canonical one, so the engine must print it back as written.
|
/// the example can only pass if the engine computes it. Without terms a
|
||||||
/// Without terms a document is due on its own date.
|
/// document is due on its own date.
|
||||||
pub(crate) fn terms_due(
|
pub(crate) fn terms_due(
|
||||||
&self,
|
&self,
|
||||||
terms: Option<&str>,
|
terms: Option<&str>,
|
||||||
@@ -224,17 +224,9 @@ impl Books<'_> {
|
|||||||
text,
|
text,
|
||||||
"{what}: the engine prints terms {text:?} back as written"
|
"{what}: the engine prints terms {text:?} back as written"
|
||||||
);
|
);
|
||||||
let due = match parsed.kind() {
|
let due = parsed
|
||||||
TermsKind::Custom => {
|
.due_date(date)
|
||||||
let agreed = text.strip_prefix("Due ").unwrap_or_else(|| {
|
.unwrap_or_else(|e| panic!("{what}: terms {text:?} on {date}: {e}"));
|
||||||
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}")),
|
|
||||||
};
|
|
||||||
(due, Some(parsed))
|
(due, Some(parsed))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -55,8 +55,8 @@ pub(crate) use ledger_core::{
|
|||||||
InstrumentId, InstrumentKind, InvoiceFields, Ledger, LedgerError, MemberCapital, MemberClose,
|
InstrumentId, InstrumentKind, InvoiceFields, Ledger, LedgerError, MemberCapital, MemberClose,
|
||||||
Money, NewAsset, NewSchedule, PartyId, PartyMember, PartyShare, PaymentAccounts,
|
Money, NewAsset, NewSchedule, PartyId, PartyMember, PartyShare, PaymentAccounts,
|
||||||
ReconcilingKind, Role, ScheduleConvention, ScheduleId, ScheduleKind, Share, Side, Terms,
|
ReconcilingKind, Role, ScheduleConvention, ScheduleId, ScheduleKind, Share, Side, Terms,
|
||||||
TermsKind, TinFacts, TinType, VendorId, W9Facts, cash_flow, members_equity,
|
TinFacts, TinType, VendorId, W9Facts, cash_flow, members_equity, profit_and_loss_for_period,
|
||||||
profit_and_loss_for_period, trial_balance_as_of, vendor_1099_report,
|
trial_balance_as_of, vendor_1099_report,
|
||||||
};
|
};
|
||||||
pub(crate) use ledger_store::{DepreciationRun, DisposalPreview, Store, StoreError};
|
pub(crate) use ledger_store::{DepreciationRun, DisposalPreview, Store, StoreError};
|
||||||
pub(crate) use rust_decimal::Decimal;
|
pub(crate) use rust_decimal::Decimal;
|
||||||
|
|||||||
Reference in new issue
Block a user