diff --git a/src/main.rs b/src/main.rs index de70f5f..2085f59 100644 --- a/src/main.rs +++ b/src/main.rs @@ -149,11 +149,6 @@ 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 { @@ -187,6 +182,11 @@ 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),