FIX: billing csv generation

This commit is contained in:
Keanu D?lle 2022-05-04 12:49:45 +02:00
parent 395d11c8bc
commit d4fbc1f791
2 changed files with 5 additions and 4 deletions

View File

@ -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]

View File

@ -105,7 +105,7 @@ pub fn generate_billing_csv(settings: &State<Settings>, 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<Settings>, 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<Settings>, 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)?;