refactor(display): one rounding for presentation
Move format_amount's rounding half (half away from zero, never a negative zero) into ledger-import::format::round_display, through the kernel's round_places. format_amount, amount_parts, the PDF percent column, xlsx's exact_f64 and ledger-package's text padding all call it, so a display change never changes a booked figure. Co-Authored-By: Muse Wonder 1.0
This commit is contained in:
1 parent
4da1c5b30f
commit
a414462be7
6 files changed
+81
-5
No files matched your search
@@ -83,7 +83,7 @@ pub fn template_data(st: &Statement, meta: &ReportMeta) -> serde_json::Value {
|
||||
"currency": r.currency,
|
||||
"amounts": r.amounts.iter().enumerate().map(|(i, a)| a.map(|a| {
|
||||
if st.percent_from.is_some_and(|f| i >= f) {
|
||||
let a = a.round_dp(1);
|
||||
let a = crate::format::round_display(a, 1);
|
||||
let negative = a.is_sign_negative() && !a.is_zero();
|
||||
return serde_json::json!({
|
||||
"digits": format!("{}%", a.abs().normalize()),
|
||||
|
||||
Reference in new issue
Block a user