FEA: added total money to billing csv
This commit is contained in:
parent
e8e20f57ae
commit
e19f2bc765
|
@ -1,8 +1,10 @@
|
|||
use std::fmt;
|
||||
use std::fs::File;
|
||||
use std::io::Write;
|
||||
use std::ops::Add;
|
||||
use std::path::Path;
|
||||
|
||||
use bigdecimal::{BigDecimal, FromPrimitive};
|
||||
use rocket::State;
|
||||
|
||||
use crate::database::controller::billing::personnel_billing_rates::get_billing_rate;
|
||||
|
@ -13,6 +15,7 @@ use crate::database::controller::groups::get_group;
|
|||
use crate::database::controller::members::get_member_by_uuid;
|
||||
use crate::helper::bigdecimal_to_string::convert;
|
||||
use crate::helper::time::{get_timezone, utc_to_local_user_time};
|
||||
use crate::schema::personnel_billing::money_for_time;
|
||||
use crate::Settings;
|
||||
|
||||
#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
|
||||
|
@ -102,6 +105,10 @@ 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_lump_sum = BigDecimal::from(0);
|
||||
let mut sum_money_for_time = BigDecimal::from(0);
|
||||
|
||||
for instance in instances {
|
||||
res.push_str(&format!("Einheit:,{}\n", sanitize(instance.name)));
|
||||
if let Some(billing_rate_id) = instance.billing_rate_id {
|
||||
|
@ -128,7 +135,10 @@ pub fn generate_billing_csv(settings: &State<Settings>, event_id: uuid::Uuid) ->
|
|||
None => return Err(CSVGeneratorError::Generator(CSVGeneratorErrorKind::MissingTimes))
|
||||
};
|
||||
|
||||
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(convert(personnel.money_from_lump_sum.clone(), 2, ',', Some('.'))), sanitize(convert(personnel.money_for_time.clone(), 2, ',', Some('.'))), sanitize(convert(personnel.money_from_lump_sum+personnel.money_for_time, 2, ',', Some('.')))));
|
||||
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(convert(personnel.money_from_lump_sum.clone(), 2, ',', Some('.'))), sanitize(convert(personnel.money_for_time.clone(), 2, ',', Some('.'))), sanitize(convert(personnel.money_from_lump_sum.clone()+personnel.money_for_time.clone(), 2, ',', Some('.')))));
|
||||
|
||||
sum_lump_sum = sum_lump_sum.clone()+personnel.money_from_lump_sum;
|
||||
sum_money_for_time = sum_money_for_time.clone()+personnel.money_for_time;
|
||||
}
|
||||
None => {
|
||||
return Err(CSVGeneratorError::Generator(CSVGeneratorErrorKind::MissingMember));
|
||||
|
@ -137,6 +147,10 @@ pub fn generate_billing_csv(settings: &State<Settings>, event_id: uuid::Uuid) ->
|
|||
}
|
||||
}
|
||||
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('\n');
|
||||
|
||||
let billing_states = get_billing_states(settings)?;
|
||||
res.push_str("Freigaben:\n");
|
||||
|
|
Loading…
Reference in New Issue