From a0df82ab352ba9128d00476a9786fd87fd230e62 Mon Sep 17 00:00:00 2001 From: Jakob Date: Mon, 23 Mar 2026 16:53:02 +0100 Subject: [PATCH] =?UTF-8?q?Rename=20to=20Avrundningsfel,=20add=20=C3=96res?= =?UTF-8?q?utj=C3=A4mning=20row,=20round=20total?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Summary now shows: - Product rows - Avrundningsfel (rounding error) - Totalt (rounded to nearest integer) - Öresutjämning (difference from transactions to rounded total) --- src/main.rs | 8 ++++++-- templates/customer.html | 6 ++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/main.rs b/src/main.rs index 88b0b9d..ef904f0 100644 --- a/src/main.rs +++ b/src/main.rs @@ -86,6 +86,7 @@ struct Summary { total_volume: String, grand_total: String, products: Vec, + avrundningsfel: String, oresutjamning: String, } @@ -192,12 +193,15 @@ impl PreparedCustomer { .map(|p| p.amount.parse::().unwrap()) .sum(); - let oresutjamning = total_from_transactions - grand_total; + let rounded_grand_total = grand_total.round(); + let avrundningsfel = grand_total - rounded_grand_total; + let oresutjamning = total_from_transactions - rounded_grand_total; let summary = Summary { total_volume: fmt(total_volume), - grand_total: fmt(grand_total), + grand_total: fmt(rounded_grand_total), products, + avrundningsfel: fmt(avrundningsfel), oresutjamning: fmt(oresutjamning), }; diff --git a/templates/customer.html b/templates/customer.html index da26257..c4c7af6 100644 --- a/templates/customer.html +++ b/templates/customer.html @@ -165,6 +165,12 @@ {{ product.amount }} Kr {% endfor %} + + Avrundningsfel + + + {{ customer.summary.avrundningsfel }} Kr + Totalt {{ customer.summary.total_volume }}