bookspec split the CHOICEs embedded in BS-partner-1..4, BS-asset-1, BS-asset-4, BS-1099-1 and BS-format-2 into records of their own (S-C7b). Wanderbooks' decisions are unchanged; each is now recorded against the id an engine declares it by: - partner: BS-partner-5 largest-remainder-first-listed (owner, 2026-10-13), -6 cumulative-from-first-close (D-10, 2026-10-16), -7 running-split (D-38, 2026-10-20), -8 outside-the-books and -9 tin-facts-then-w9 (2026-10-15), -10..-13 money, entry flow, books' carrying amount, labelled basis (2026-10-15, 2026-10-20), -14 tax-basis-beside-book (D-41), -15 running-cumulative (D-38's rule, 2026-10-22) - asset: BS-asset-5 straight-line-by-days, -6 lesser-of-value-and-basis, -7 books-recorded-amounts, -8 register-carries-tax-figures - 1099: BS-1099-2 refuse-an-unknown-year, -3 presumed-a-check-ach-or-transfer, -4 dated-by-the-payments-date - format: BS-format-3..7 (D-36, 2026-10-20) Each is a `**Pick (BS-..):**` line in docs/spec/claims/<area>.md and a `with_choice` in the adapter's claims(). The rules_md test no longer expects a B-n row for a rule born without one (a split-out CHOICE has none): it requires the pick line, that the pick is one of the record's options, and that the adapter declares the same option. The pin is not moved here: this needs bookspec's s-c7b to be merged and the pin moved to it. Verified with ledger-core's bookspec test patched to the s-c7b checker and runner (53 passed). Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
72 lines
2.6 KiB
Rust
72 lines
2.6 KiB
Rust
use crate::*;
|
|
|
|
/// The `Engine` adapter: the wanderbooks implementation over `Store`, as
|
|
/// the bookspec runner drives any engine (`plan/served.md` P13 step 2).
|
|
impl Engine for Books<'_> {
|
|
fn load(&mut self, setup: &Setup) -> Result<(), Refusal> {
|
|
if setup != &self.ex.setup {
|
|
return Err(Refusal::new(
|
|
RuleId::new(Area::Ledger, 1),
|
|
"the setup handed over is not the example's",
|
|
));
|
|
}
|
|
self.setup();
|
|
Ok(())
|
|
}
|
|
|
|
fn apply(&mut self, event: &Event) -> Result<(), Refusal> {
|
|
let n = self.posted.len() + 1;
|
|
self.apply_event(n, event)
|
|
.map_err(|e| store_refusal_obj(&e))
|
|
}
|
|
|
|
fn change(&mut self, change: &ChangeSpec) -> Result<(), Refusal> {
|
|
self.try_change(change)
|
|
}
|
|
|
|
fn query(&self, q: &Query) -> Result<Value, Refusal> {
|
|
self.answer(q)
|
|
}
|
|
|
|
fn claims(&self) -> Claims {
|
|
let mut claims = Claims::new(
|
|
bookspec_checker::covered_rules()
|
|
.into_iter()
|
|
.map(|r| r.id.clone()),
|
|
);
|
|
for &(area, n, option) in PICKS_S_C7B {
|
|
claims = claims.with_choice(RuleId::new(area, n), option);
|
|
}
|
|
claims
|
|
}
|
|
}
|
|
|
|
/// The option wanderbooks picks for each CHOICE record split out of the
|
|
/// partner, asset, 1099 and format rules (P14 unit S-C7b); each is recorded
|
|
/// in `docs/spec/claims/<area>.md` as `**Pick (BS-<area>-<n>):**`.
|
|
pub(crate) const PICKS_S_C7B: &[(Area, u32, &str)] = &[
|
|
(Area::Partner, 5, "largest-remainder-first-listed"),
|
|
(Area::Partner, 6, "cumulative-from-first-close"),
|
|
(Area::Partner, 7, "running-split"),
|
|
(Area::Partner, 8, "outside-the-books"),
|
|
(Area::Partner, 9, "tin-facts-then-w9"),
|
|
(Area::Partner, 10, "cash-cards-and-financing"),
|
|
(Area::Partner, 11, "capital-movement-counted-once"),
|
|
(Area::Partner, 12, "books-carrying-amount"),
|
|
(Area::Partner, 13, "labelled-cash-default-or-all"),
|
|
(Area::Partner, 14, "tax-basis-beside-book"),
|
|
(Area::Partner, 15, "running-cumulative"),
|
|
(Area::Asset, 5, "straight-line-by-days"),
|
|
(Area::Asset, 6, "lesser-of-value-and-basis"),
|
|
(Area::Asset, 7, "books-recorded-amounts"),
|
|
(Area::Asset, 8, "register-carries-tax-figures"),
|
|
(Area::Tax1099, 2, "refuse-an-unknown-year"),
|
|
(Area::Tax1099, 3, "presumed-a-check-ach-or-transfer"),
|
|
(Area::Tax1099, 4, "dated-by-the-payments-date"),
|
|
(Area::Format, 3, "plain-ascii-transliterated-and-listed"),
|
|
(Area::Format, 4, "cr-lf"),
|
|
(Area::Format, 5, "docnum-is-the-entry-id"),
|
|
(Area::Format, 6, "everything-through-as-of"),
|
|
(Area::Format, 7, "journal-sample-columns"),
|
|
];
|