FIX: removed whitespaces from generated csv files to improve Excel compability

This commit is contained in:
Keanu D?lle 2022-04-05 22:02:51 +02:00
parent f02c963e62
commit 78109686f2
2 changed files with 10 additions and 10 deletions

View File

@ -262,7 +262,7 @@ pub async fn approve(
};
debug!("Generated CSV: {}", csv);
if settings.billing.send_personnel_billing_to_email {
let attachement = Attachment::new(String::from("Einsatzabrechnung.csv")).body(csv, ContentType::parse("text/csv").unwrap());
let attachement = Attachment::new(String::from("Einsatzabrechnung.txt")).body(csv, ContentType::parse("text/csv").unwrap());
let msg = Message::builder()
.from(settings.mail.from.clone().parse().unwrap())
.reply_to(settings.mail.reply_to.clone().parse().unwrap())

View File

@ -84,32 +84,32 @@ pub fn generate_billing_csv(settings: &State<Settings>, event_id: uuid::Uuid) ->
let mut res = String::new();
let event_data = get_event(settings, event_id)?;
res.push_str(&format!("{}, {}\n", sanitize(String::from("Einsatz: ")), sanitize(event_data.name.clone())));
res.push_str(&format!("{},{}\n", sanitize(String::from("Einsatz: ")), sanitize(event_data.name.clone())));
if let Some(related_group) = event_data.related_group {
let group = get_group(settings, related_group)?;
res.push_str(&format!("{}, {}\n", sanitize(String::from("Gruppe:")), sanitize(group.name)));
res.push_str(&format!("{},{}\n", sanitize(String::from("Gruppe:")), sanitize(group.name)));
}
if let Some(member_responsible) = event_data.member_responsible {
if let Some(member) = get_member_by_uuid(member_responsible, settings) {
res.push_str(&format!("{}, {}\n", sanitize(String::from("Verantwortliches Mitglied:")), sanitize(format!("{} {}", member.firstname, member.lastname))))
res.push_str(&format!("{},{}\n", sanitize(String::from("Verantwortliches Mitglied:")), sanitize(format!("{} {}", member.firstname, member.lastname))))
}
}
res.push_str("\n");
res.push('\n');
let instances = get_instances(settings, event_id)?;
for instance in instances {
res.push_str(&format!("Einheit:, {}\n", sanitize(instance.name)));
res.push_str(&format!("Einheit:,{}\n", sanitize(instance.name)));
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!("{}", billing_rate.lump_sum)), sanitize(format!("{}", billing_rate.payment_per_hour))));
}
res.push_str(&format!("{}, {}, {}, {}, {}, {}, {}, {}, {}\n", String::from("Personalnummer"), String::from("Vorname"), String::from("Nachname"), String::from("Von"), String::from("Bis"), String::from("Stunden"), String::from("Pauschale"), String::from("Stundengeld"), String::from("Gesamt")));
res.push_str(&format!("{},{}, {},{},{},{},{},{},{}\n", String::from("Personalnummer"), String::from("Vorname"), String::from("Nachname"), String::from("Von"), String::from("Bis"), String::from("Stunden"), String::from("Pauschale"), String::from("Stundengeld"), String::from("Gesamt")));
let position_instances = get_position_instances(settings, instance.instance_id)?;
@ -127,7 +127,7 @@ pub fn generate_billing_csv(settings: &State<Settings>, event_id: uuid::Uuid) ->
};
res.push_str(&format!("{}, {}, {}, {}, {}, {}, {}, {}, {}\n", sanitize(member.personnel_number.unwrap_or(0).to_string()), sanitize(member.firstname), sanitize(member.lastname), sanitize(begin), sanitize(end), sanitize(personnel.fulfilled_time.to_string()), sanitize(personnel.money_from_lump_sum.to_string()), sanitize(personnel.money_for_time.to_string()), sanitize(personnel.total_money.to_string())));
res.push_str(&format!("{},{},{},{},{},{},{},{},{}\n", sanitize(member.personnel_number.unwrap_or(0).to_string()), sanitize(member.firstname), sanitize(member.lastname), sanitize(begin), sanitize(end), sanitize(personnel.fulfilled_time.to_string()), sanitize(personnel.money_from_lump_sum.to_string()), sanitize(personnel.money_for_time.to_string()), sanitize(personnel.total_money.to_string())));
}
None => {
return Err(CSVGeneratorError::Generator(CSVGeneratorErrorKind::MissingMember));
@ -135,7 +135,7 @@ pub fn generate_billing_csv(settings: &State<Settings>, event_id: uuid::Uuid) ->
};
}
}
res.push_str("\n");
res.push('\n');
}
Ok(res)
}