From 3bb65ca7f618769c48e4b404ac245b835ad37e11 Mon Sep 17 00:00:00 2001 From: Jakob Date: Mon, 23 Mar 2026 16:21:58 +0100 Subject: [PATCH] Fix grand_total calculation from card totals Calculate grand_total from card totals instead of products to ensure consistency. --- src/main.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main.rs b/src/main.rs index 2085f59..de70f5f 100644 --- a/src/main.rs +++ b/src/main.rs @@ -149,6 +149,11 @@ impl PreparedCustomer { }) .collect(); + let grand_total: f64 = cards + .iter() + .map(|c| c.total_amount.parse::().unwrap()) + .sum(); + let mut product_totals: HashMap = HashMap::new(); for card in &cards { for tx in &card.transactions { @@ -182,11 +187,6 @@ impl PreparedCustomer { .map(|p| p.volume.parse::().unwrap()) .sum(); - let grand_total: f64 = products - .iter() - .map(|p| p.amount.parse::().unwrap()) - .sum(); - let summary = Summary { total_volume: fmt(total_volume), grand_total: fmt(grand_total),