fix(core): the audit checks a close's split at the allocation's unit
audit::closes took its unit as minor_units().unwrap_or(2), while the members allocation splits at allocation_places() (minor_units().unwrap_or(MAX_LINE_SCALE)). For a currency code with no minor unit the audit therefore checked a split made at the finest a line carries against a cent: far looser than the split it checks, so real drift passed. Add Currency::allocation_unit(), the one helper that turns allocation_places() into an amount, and take the audit's unit from it, so the split and its check cannot drift apart (BS-partner-1 statement 4: the allocation is the split to the base currency's smallest unit). A JPY close is now checked at a whole yen. Test: a_jpy_close_is_checked_at_the_allocations_unit (BS-partner-1 statement 4, WB-ledger-16 invariant 8). Co-Authored-By: Muse Wonder 1.0
This commit is contained in:
1 parent
4da1c5b30f
commit
5b1596f977
4 files changed
+96
-2
No files matched your search
@@ -474,7 +474,12 @@ pub fn check_control(checks: &[crate::arap::ControlCheck]) -> Vec<Finding> {
|
||||
}
|
||||
|
||||
fn closes(ledger: &Ledger, through: NaiveDate) -> Vec<Finding> {
|
||||
let unit = Decimal::new(1, ledger.base_currency().minor_units().unwrap_or(2));
|
||||
// The unit the allocation itself splits to, from the one helper both
|
||||
// sides use (`Currency::allocation_unit`, on `allocation_places`):
|
||||
// for a currency with no minor unit the split is far finer than a
|
||||
// cent, and the audit must not check it at a cent (BS-partner-1
|
||||
// statement 4).
|
||||
let unit = ledger.base_currency().allocation_unit();
|
||||
let mut out = Vec::new();
|
||||
for p in ledger.list_periods() {
|
||||
if p.status != PeriodStatus::Closed || p.end > through {
|
||||
|
||||
Reference in new issue
Block a user