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 }}