refactor(package): exported totals are exact or say so

The K-1 members' total row, the receipts index amount and the 1099
worksheet's payments text summed with a raw .sum(); they use
kernel::total_of and print 'too large to compute' if a sum is past exact
arithmetic (text::total_text), so an export of restored books never
crashes. Unchanged text for every ordinary input.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
swaitsandClaude Sonnet 5.5 committed 2026-11-08 12:23:11 -07:00
1 parent 7aa0cc68f3
commit afc7c545da
3 files changed
+20 -15

No files matched your search

+3 -3
View File
@@ -34,7 +34,7 @@ use ledger_core::{Decision1099, EntryId, Ledger, PartyId, Payment1099, Status109
use rust_decimal::Decimal;
use crate::reports::Settings;
use crate::text::{csv_escape, money};
use crate::text::{csv_escape, money, total_text};
use crate::tins::{TinSource, tin_type_key};
/// Where payments to vendors come from, for the 1099 worksheet: the
@@ -193,12 +193,12 @@ fn entries_text(ids: &[EntryId]) -> String {
/// "1 payment" or "3 payments", with their total.
fn payments_text(list: &[Payment1099]) -> String {
let total: Decimal = list.iter().map(|p| p.amount).sum();
let total = ledger_core::kernel::total_of(list, |p| p.amount);
let n = list.len();
format!(
"{n} payment{} totaling {}",
if n == 1 { "" } else { "s" },
money(total)
total_text(total)
)
}