feat(core): new schedules round to the currency's minor unit (D-72)

The owner's decision D-72: a new monthly-even schedule rounds each month
to its currency's minor unit (yen whole, dinar to the thousandth), where
the cent rule gave two places to every currency; a schedule written
earlier replays under the cent rule, so nothing journaled moves
(BS-prepaid-4, BS-entry-8).

The rule is the schedule's own flag, journaled on its schedule.registered
line ("rounding": "minor_unit", absent for the cent rule), not the
sequence position of the journal feature: a flag survives a snapshot, a
copy and a replay that starts mid-journal. The new feature
schedule_minor_unit gates it (KNOWN_FEATURES, ensure_feature in
Store::register_schedule): books that haven't declared it keep the cent
rule and write nothing new, and an older reader stops at the declaration
as newer books (BS-format-1); an unknown rounding is newer, never
corrupt. A dollar schedule plans the same under both rules.

Tests: a dinar schedule written before the feature replays to the same
plan and the same posted line after the owner's upgrade, while one written
after plans 0.333, 0.333, 0.334. WB-prepaid-2 becomes yes.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
swaitsandClaude Sonnet 5.5 committed 2026-11-09 03:33:15 -07:00
1 parent 768ed7d92b
commit 09308d5528
5 files changed
+449 -35

No files matched your search

+50
View File
@@ -55,6 +55,7 @@ pub const KNOWN_FEATURES: &[&str] = &[
VENDOR_1099_DECISIONS,
MONTH_REPOSTING,
SCHEDULE_CONVENTION,
SCHEDULE_MINOR_UNIT,
ASSET_BASIS,
TAX_CATEGORIES_GAIN_EXEMPT,
DISPOSAL_BEFORE_SERVICE,
@@ -167,6 +168,18 @@ pub const MONTH_REPOSTING: &str = "month_reposting";
/// months (P3 defect 9, plan/served.md D-11).
pub const SCHEDULE_CONVENTION: &str = "schedule_convention";
/// Feature: `schedule.registered` carries `rounding` (`minor_unit`): a
/// monthly_even schedule written after this feature rounds each month to
/// its currency's minor unit (a yen schedule in whole yen, a dinar one in
/// thousandths); one with no `rounding` is the cent rule, two places for
/// every currency, as every schedule before it is (BS-prepaid-4, D-72).
/// An older version would read the schedule under the cent rule and
/// refuse its first month as a posting that doesn't match its plan, or,
/// replaying a month it can derive, post ¥33,333.33 where the books say
/// ¥33,333. The flag rides on the schedule, never on where the feature
/// was declared: a schedule written before it replays as it was posted.
pub const SCHEDULE_MINOR_UNIT: &str = "schedule_minor_unit";
/// Feature: `asset.basis_set`, a new event type: an asset's basis facts
/// with the value at contribution and the §704(c) method (P3, defect 13).
pub const ASSET_BASIS: &str = "asset_basis";
@@ -1088,6 +1101,43 @@ mod tests {
assert_eq!(up.adds(), vec!["the journal feature audits"]);
}
/// The version before K-U5 (every feature but `schedule_minor_unit`)
/// stops at the declaration as newer, so it never reads a ¥33,333
/// month under the cent rule (and refuses, or posts ¥33,333.33 where
/// the books say ¥33,333); and a `schedule.registered` naming a
/// rounding this version doesn't know is newer, never corrupt
/// (BS-prepaid-4, D-72, BS-format-1). Books that declared every
/// earlier feature still wait for it.
#[test]
fn schedule_minor_unit_is_its_own_feature() {
assert!(KNOWN_FEATURES.contains(&SCHEDULE_MINOR_UNIT));
let before: Vec<&str> = KNOWN_FEATURES
.iter()
.copied()
.filter(|f| *f != SCHEDULE_MINOR_UNIT)
.collect();
let l = line(
FORMAT_SET,
json!({"format": 2, "features": [SCHEDULE_CONVENTION, SCHEDULE_MINOR_UNIT]}),
);
match declared_knowing(&l, &before) {
Err(StoreError::NewerJournal { need, .. }) => {
assert_eq!(need, "journal features schedule_minor_unit")
}
other => panic!("expected NewerJournal, got {other:?}"),
}
let older = JournalFormat {
format: 2,
features: before.iter().map(|f| f.to_string()).collect(),
};
assert!(matches!(
older.require_feature(SCHEDULE_MINOR_UNIT),
Err(StoreError::FormatUpgradePending { .. })
));
let up = older.upgrade().expect("waits for it");
assert_eq!(up.adds(), vec!["the journal feature schedule_minor_unit"]);
}
/// This version's format: the newest it reads, every feature it
/// knows, each once, sorted (what new books and an upgrade declare).
#[test]