test(core): the adapter runs refused dates, amounts, periods, roles, exports, 1099 years and returns

The bookspec examples now spell the input an engine has to refuse, and the
adapter takes each through the real books:

- a date past 9999 is refused by `Store::create_entry`'s own
  `try_create_entry` (DateOutOfRange), and a line past one quadrillion by
  `add_line` (AmountOutOfRange), each on a rehearsal so a refused entry
  leaves no draft;
- a close whose period partly overlaps another creates it through
  `Store::create_period` and reads PeriodsOverlap;
- `assign_role` is `Store::assign_role`, the journaled command, so a role
  on a header is refused by `check_assign_role` (ControlAccountMismatch)
  and the chart stays as it was;
- an IIF export with an entry on a receivable and a payable account is
  refused with BS-format-10's word, which is why `export_iif` keeps its
  typed error;
- a 2027 worksheet is refused through `RuleNotKnown` as
  `unknown_1099_year`, never guessed;
- `return_tin` reads the full number from the real `ledger_vault::Vault`
  the example's `setup.vault_tins` fills, and the books' own record keeps
  only the last four.

The adapter skips sixteen examples now (three more, each for an option
wanderbooks did not pick): allow-partial-overlap, carry-the-last-amount
and nowhere. Every one of the 95 it runs passes.

Co-Authored-By: DeepSeek V4.1 Flash <noreply@opencode.ai>
This commit is contained in:
swaitsandDeepSeek V4.1 Flash committed 2026-11-09 07:40:26 -07:00
1 parent 9c299eb768
commit 7ac1e644b2
11 files changed
+178 -14

No files matched your search

@@ -39,6 +39,11 @@ pub(crate) struct Books<'a> {
/// What each disposal took, by asset id, as the engine computed it
/// just before posting it.
pub(crate) disposals: BTreeMap<String, DisposalPreview>,
/// The TIN vault outside the books, when the setup puts a full TIN
/// there (BS-partner-8's outside-the-books option): the real
/// `ledger_vault::Vault`, in the books' own directory, holding only
/// what the example spells.
pub(crate) vault: Option<Vault>,
}
/// A store command's result, unwrapped: the example's books take it.
@@ -289,6 +294,7 @@ impl<'a> Books<'a> {
posted: Vec::new(),
runs: BTreeMap::new(),
disposals: BTreeMap::new(),
vault: None,
}
}
@@ -443,6 +449,34 @@ impl<'a> Books<'a> {
assert_eq!(total, Decimal::ONE, "{}: the shares sum to 1", ex.id);
}
let parties = add_parties(ex, &mut self.store);
// The vault outside the books (BS-partner-8's outside-the-books
// option): the real encrypted store, in the books' own directory,
// holding the full TINs the example puts there and nothing else.
if !s.vault_tins.is_empty() {
let vault = Vault::open(
&self._dir.path().join("vault"),
&self._dir.path().join("vault.key"),
true,
)
.unwrap_or_else(|e| panic!("{}: the TIN vault: {e}", ex.id));
for v in &s.vault_tins {
let id = *parties.get(&v.party).unwrap_or_else(|| {
panic!("{}: vault TIN: party {:?} not in setup", ex.id, v.party)
});
let digits: String = v.tin.chars().filter(|c| *c != '-').collect();
let kind = if digits.starts_with('9') {
ledger_vault::TinType::Itin
} else {
ledger_vault::TinType::Ssn
};
let tin = Tin::new(&v.tin, kind)
.unwrap_or_else(|e| panic!("{}: vault TIN {:?}: {e}", ex.id, v.tin));
vault
.put_tin(id, &tin)
.unwrap_or_else(|e| panic!("{}: vault TIN: {e}", ex.id));
}
self.vault = Some(vault);
}
// A member who is a party (by name, with the member role), as the
// settings' members are (settings::Company::party_members).
let party_members: Vec<PartyMember> = members