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

+1 -4
View File
@@ -994,10 +994,7 @@ pub fn journal_to_iif(
/// Debit positive, credit negative (Intuit: "Debit amounts are always
/// positive, credit amounts are always negative").
fn signed(side: Side, amount: Decimal) -> Decimal {
match side {
Side::Debit => amount,
Side::Credit => -amount,
}
ledger_core::money::signed_amount(side, amount)
}
/// Two decimal places, no thousands separators.