refactor(import): Decimal arithmetic goes through the kernel (K-U12)

The raw-decimal-arith detector counted 18 places in ledger-import before
and counts 0 after. No figure changes.

Signs (bank_csv, iif, invoice_pdf, report) go through money::neg and
money::signed_amount; sums and differences of figures from the books
(report, xlsx) through total_of, add_in_range and sub_in_range, which
are exact and panic only where the raw operator panicked.

Not a plain sum or sign: equal_shares (templates) now divides through
Amount::checked_div, rounds half-to-even to two places through
round_places, and gives the last owner a hundred minus the shares
given. Same numbers as before for every n >= 1; for n = 0 it returns no
shares where the raw division panicked (its one caller passes the
owners of a partnership, at least two).

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
swaitsandClaude committed 2026-11-09 23:55:32 -07:00
1 parent 0de906e9ed
commit 0fb19b4b25
6 files changed
+43 -20

No files matched your search

+2 -2
View File
@@ -387,11 +387,11 @@ fn general_journal(
match line.side {
ledger_core::Side::Debit => {
number(sheet, row, 5, line.amount.amount, &f.plain)?;
debits += line.amount.amount;
debits = ledger_core::money::add_in_range(debits, line.amount.amount);
}
ledger_core::Side::Credit => {
number(sheet, row, 6, line.amount.amount, &f.plain)?;
credits += line.amount.amount;
credits = ledger_core::money::add_in_range(credits, line.amount.amount);
}
}
row += 1;