Merge branch 't3/split-embedded-choices-s-c7b' into t3/s-c7-split-embedded-choices
This commit is contained in:
commit
75758b250c
6 files changed
+142
-47
No files matched your search
@@ -29,47 +29,78 @@ impl Engine for Books<'_> {
|
||||
}
|
||||
|
||||
fn claims(&self) -> Claims {
|
||||
// The picks for the CHOICE records split out of embedded choices
|
||||
// (P14 unit S-C7a: entry, ledger, period, statement, prepaid).
|
||||
Claims::new(
|
||||
let mut claims = Claims::new(
|
||||
bookspec_checker::covered_rules()
|
||||
.into_iter()
|
||||
.map(|r| r.id.clone()),
|
||||
)
|
||||
.with_choice(RuleId::new(Area::Entry, 6), "check-when-line-added")
|
||||
.with_choice(RuleId::new(Area::Entry, 7), "refuse-rather-than-crash")
|
||||
.with_choice(
|
||||
RuleId::new(Area::Entry, 8),
|
||||
"bounds-bind-commands-never-replay",
|
||||
)
|
||||
.with_choice(RuleId::new(Area::Ledger, 14), "book-in-the-smallest-unit")
|
||||
.with_choice(RuleId::new(Area::Ledger, 15), "child-has-its-parents-type")
|
||||
.with_choice(RuleId::new(Area::Ledger, 16), "on-or-after-the-original")
|
||||
.with_choice(
|
||||
RuleId::new(Area::Ledger, 17),
|
||||
"reversal-evidence-is-originals",
|
||||
)
|
||||
.with_choice(
|
||||
RuleId::new(Area::Ledger, 18),
|
||||
"assignment-is-a-fact-in-the-books",
|
||||
)
|
||||
.with_choice(RuleId::new(Area::Ledger, 19), "refuse-rather-than-renumber")
|
||||
.with_choice(RuleId::new(Area::Ledger, 20), "warn-by-default")
|
||||
.with_choice(RuleId::new(Area::Ledger, 21), "round-once-on-the-total")
|
||||
.with_choice(RuleId::new(Area::Period, 4), "nest-never-partially-overlap")
|
||||
.with_choice(
|
||||
RuleId::new(Area::Period, 5),
|
||||
"fiscal-year-to-date-by-default",
|
||||
)
|
||||
.with_choice(RuleId::new(Area::Statement, 6), "direct")
|
||||
.with_choice(RuleId::new(Area::Statement, 7), "constructive")
|
||||
.with_choice(RuleId::new(Area::Statement, 8), "year-through-as-of")
|
||||
.with_choice(RuleId::new(Area::Statement, 9), "one-project-per-line")
|
||||
.with_choice(RuleId::new(Area::Prepaid, 2), "daily")
|
||||
.with_choice(RuleId::new(Area::Prepaid, 3), "start-on-the-first")
|
||||
.with_choice(
|
||||
RuleId::new(Area::Prepaid, 4),
|
||||
"minor-unit-for-new-schedules",
|
||||
)
|
||||
);
|
||||
for &(area, n, option) in PICKS {
|
||||
claims = claims.with_choice(RuleId::new(area, n), option);
|
||||
}
|
||||
claims
|
||||
}
|
||||
}
|
||||
|
||||
/// The option wanderbooks picks for each CHOICE record split out of an
|
||||
/// embedded choice (P14 unit S-C7); each is recorded in
|
||||
/// `docs/spec/claims/<area>.md` as `**Pick (BS-<area>-<n>):**`.
|
||||
pub(crate) const PICKS: &[(Area, u32, &str)] = &[
|
||||
(Area::Entry, 6, "check-when-line-added"),
|
||||
(Area::Entry, 7, "refuse-rather-than-crash"),
|
||||
(Area::Entry, 8, "bounds-bind-commands-never-replay"),
|
||||
(Area::Ledger, 14, "book-in-the-smallest-unit"),
|
||||
(Area::Ledger, 15, "child-has-its-parents-type"),
|
||||
(Area::Ledger, 16, "on-or-after-the-original"),
|
||||
(Area::Ledger, 17, "reversal-evidence-is-originals"),
|
||||
(Area::Ledger, 18, "assignment-is-a-fact-in-the-books"),
|
||||
(Area::Ledger, 19, "refuse-rather-than-renumber"),
|
||||
(Area::Ledger, 20, "warn-by-default"),
|
||||
(Area::Ledger, 21, "round-once-on-the-total"),
|
||||
(Area::Period, 4, "nest-never-partially-overlap"),
|
||||
(Area::Period, 5, "fiscal-year-to-date-by-default"),
|
||||
(Area::Statement, 6, "direct"),
|
||||
(Area::Statement, 7, "constructive"),
|
||||
(Area::Statement, 8, "year-through-as-of"),
|
||||
(Area::Statement, 9, "one-project-per-line"),
|
||||
(Area::Prepaid, 2, "daily"),
|
||||
(Area::Prepaid, 3, "start-on-the-first"),
|
||||
(Area::Prepaid, 4, "minor-unit-for-new-schedules"),
|
||||
(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, 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::Partner, 16, "contract-is-property-vendor-paid-is-cash"),
|
||||
(Area::Partner, 17, "close-at-the-change"),
|
||||
(Area::Partner, 18, "book-amount-with-note"),
|
||||
(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::Asset, 9, "traditional"),
|
||||
(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::Tax1099, 5, "payees-share-only"),
|
||||
(Area::Arap, 7, "due-today-is-current"),
|
||||
(Area::Arap, 8, "as-of-the-day"),
|
||||
(Area::Arap, 9, "refuse-a-payment-before-its-document"),
|
||||
(Area::Arap, 10, "ignore-case-and-spaces"),
|
||||
(Area::Arap, 11, "reverse-then-plain-entry"),
|
||||
(Area::Arap, 12, "gross-when-taken"),
|
||||
(Area::Arap, 13, "gross"),
|
||||
(Area::Arap, 14, "refuse-with-the-remedy"),
|
||||
(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"),
|
||||
(Area::Format, 8, "closes-left-out"),
|
||||
(Area::Format, 9, "no-customer-or-vendor-name"),
|
||||
(Area::Format, 10, "refuse-the-entry"),
|
||||
];
|
||||
@@ -25,15 +25,33 @@ pub(crate) fn rules_md_carries_every_id() {
|
||||
}
|
||||
|
||||
for rule in bookspec_checker::rules().iter() {
|
||||
if rule.is_retired() {
|
||||
continue;
|
||||
}
|
||||
if rule.b == 0 {
|
||||
// Born after the B-n numbering ended (P14 unit S-C7): no index
|
||||
// row and no B-n section; its pick is recorded in the claims
|
||||
// file of its parent.
|
||||
assert!(
|
||||
all.contains(&format!("**Pick ({}):**", rule.id)),
|
||||
"{} carries its pick in its claims file",
|
||||
rule.id
|
||||
);
|
||||
// A rule born after the B numbering has no row in the index.
|
||||
// A CHOICE record split out of another rule (P14 unit S-C7)
|
||||
// has its pick recorded in its claims file, and the engine's
|
||||
// adapter declares the same option, which the record names.
|
||||
if rule.status == Some(bookspec_checker::Status::Choice) {
|
||||
let marker = format!("**Pick ({}):** `", rule.id);
|
||||
let at = all
|
||||
.find(&marker)
|
||||
.unwrap_or_else(|| panic!("{} carries its pick in its claims file", rule.id));
|
||||
let option = all[at + marker.len()..].split('`').next().unwrap();
|
||||
assert!(
|
||||
rule.record().options.iter().any(|o| o.name == option),
|
||||
"{}'s pick {option:?} is one of its options",
|
||||
rule.id
|
||||
);
|
||||
assert!(
|
||||
engine::PICKS
|
||||
.iter()
|
||||
.any(|&(area, n, o)| RuleId::new(area, n) == rule.id && o == option),
|
||||
"{}'s pick {option:?} is declared in the adapter's claims()",
|
||||
rule.id
|
||||
);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
assert!(
|
||||
|
||||
Reference in new issue
Block a user