From d4fbc1f791aa3c18cf098cfe7accf6d38fe88d91 Mon Sep 17 00:00:00 2001 From: Keanu D?lle Date: Wed, 4 May 2022 12:49:45 +0200 Subject: [PATCH] FIX: billing csv generation --- src/modules/api/personnel_billing/calculation.rs | 2 +- src/modules/event_billing/generate_billing_csv.rs | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/modules/api/personnel_billing/calculation.rs b/src/modules/api/personnel_billing/calculation.rs index 661001e..422d987 100644 --- a/src/modules/api/personnel_billing/calculation.rs +++ b/src/modules/api/personnel_billing/calculation.rs @@ -43,7 +43,7 @@ mod tests { fn minutes_eq() { let start = Utc.ymd(2022, 2, 2).and_hms_milli(14, 15, 1, 444); let end = Utc.ymd(2022, 2, 2).and_hms_milli(16, 15, 1, 444); - assert_eq!(3, calculate_hours(start, end).unwrap()) + assert_eq!(2, calculate_hours(start, end).unwrap()) } #[test] diff --git a/src/modules/event_billing/generate_billing_csv.rs b/src/modules/event_billing/generate_billing_csv.rs index c4deaf5..0c80273 100644 --- a/src/modules/event_billing/generate_billing_csv.rs +++ b/src/modules/event_billing/generate_billing_csv.rs @@ -105,7 +105,7 @@ pub fn generate_billing_csv(settings: &State, event_id: uuid::Uuid) -> let instances = get_instances(settings, event_id)?; - let sum_total = BigDecimal::from_u8(0).unwrap(); + let mut sum_total = BigDecimal::from_u8(0).unwrap(); let mut sum_lump_sum = BigDecimal::from(0); let mut sum_money_for_time = BigDecimal::from(0); @@ -114,7 +114,7 @@ pub fn generate_billing_csv(settings: &State, event_id: uuid::Uuid) -> if let Some(billing_rate_id) = instance.billing_rate_id { let billing_rate = get_billing_rate(settings, billing_rate_id)?; - res.push_str(&format!("Abrechnungssatz:,{},{},Pauschale:,{},€/Stunde:,{}\n", sanitize(billing_rate.name), sanitize(billing_rate.description.unwrap_or(String::from(""))), sanitize(format!("{} €", billing_rate.lump_sum)), sanitize(format!("{} €", billing_rate.payment_per_hour)))); + res.push_str(&format!("Abrechnungssatz:,{},{},Pauschale:,{},€/Stunde:,{}\n", sanitize(billing_rate.name), sanitize(billing_rate.description.unwrap_or(String::from(""))), sanitize(format!("{} €", convert(billing_rate.lump_sum.clone(), 2, ',', Some('.')))),sanitize(format!("{} €", convert(billing_rate.payment_per_hour.clone(), 2, ',', Some('.')))))); } res.push_str(&format!("{},{},{},{},{},{},{},{},{}\n", String::from("Personalnummer"), String::from("Vorname"), String::from("Nachname"), String::from("Von"), String::from("Bis"), String::from("Stunden"), settings.billing.lump_sum_name, settings.billing.money_for_time_name, String::from("Gesamt"))); @@ -146,10 +146,11 @@ pub fn generate_billing_csv(settings: &State, event_id: uuid::Uuid) -> }; } } + sum_total = sum_lump_sum.clone()+sum_money_for_time.clone(); res.push('\n'); res.push_str("SUMME:\n"); res.push_str(&format!("{},{},Gesamt\n", settings.billing.lump_sum_name, settings.billing.money_for_time_name)); - res.push_str(&format!("{},{},{}\n", convert(sum_lump_sum.clone(), 2, ',', Some('.')), convert(sum_money_for_time.clone(), 2, ',', Some('.')), convert(sum_lump_sum.clone().add(sum_money_for_time.clone()).clone(), 2, ',', Some('.')))); + res.push_str(&format!("{},{},{}\n", convert(sum_lump_sum.clone(), 2, ',', Some('.')), convert(sum_money_for_time.clone(), 2, ',', Some('.')), convert(sum_total, 2, ',', Some('.')))); res.push('\n'); let billing_states = get_billing_states(settings)?;