summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/banking/account.rs7
-rw-r--r--src/banking/asset.rs10
-rw-r--r--src/web_frontend/chart.rs19
3 files changed, 22 insertions, 14 deletions
diff --git a/src/banking/account.rs b/src/banking/account.rs
index 6994bb4..1783e63 100644
--- a/src/banking/account.rs
+++ b/src/banking/account.rs
@@ -4,11 +4,12 @@ pub struct Account {
pub name : String,
pub iban : String,
pub transactions : Vec<Transaction>,
- pub institute : String
+ pub institute : String,
+ pub groupFile : String
}
impl Account {
- pub fn new(name : String, iban : String, transactions : Vec<String>, institute : String) -> Account {
+ pub fn new(name : String, iban : String, transactions : Vec<String>, institute : String, groupFile : String) -> Account {
let mut trans = Vec::new();
if institute == "Sparkasse" {
// TODO als function/lambda übergeben die konvertierung..
@@ -22,7 +23,7 @@ impl Account {
}
}
}
- Account { name : name, iban : iban, transactions : trans, institute : institute }
+ Account { name : name, iban : iban, transactions : trans, institute : institute, groupFile : groupFile }
}
}
diff --git a/src/banking/asset.rs b/src/banking/asset.rs
index 7b7287b..1cbcbc4 100644
--- a/src/banking/asset.rs
+++ b/src/banking/asset.rs
@@ -39,7 +39,15 @@ impl Asset {
if let Some(i) = tmp.get(0) {
iban = i.to_string();
}
- accounts.push(Account::new(account_name, iban, trans_files.to_vec(), institute));
+ match config.get("GroupFile") {
+ Some(i) => tmp = i,
+ None => println!("no groupfile for account {}", account_name)
+ }
+ let mut groupFile = String::from("");
+ if let Some(i) = tmp.get(0) {
+ groupFile = i.to_string();
+ }
+ accounts.push(Account::new(account_name, iban, trans_files.to_vec(), institute, groupFile));
}
diff --git a/src/web_frontend/chart.rs b/src/web_frontend/chart.rs
index 7065c6d..ed593dd 100644
--- a/src/web_frontend/chart.rs
+++ b/src/web_frontend/chart.rs
@@ -38,9 +38,16 @@ pub fn chart_handler(start : Option<&RawStr>, end : Option<&RawStr>) -> rocket_c
None => Utc::today().naive_utc()
};
let date_range = crate::web_frontend::util::DateRange::new(date_start, date_end);
+ let asset_ini = "data/asset.ini";
+ let asset = crate::banking::asset::Asset::from_ini_file(asset_ini);
+ let account = asset.get_account_by_name("Girokonto");
+ let acc;
+ match account {
+ Some(trans) => acc = trans,
+ None => panic!("could not read file")
+ }
// read group config
- let chart_file = "data/giro";
- let chart_config = IniFile::from_file(chart_file);
+ let chart_config = IniFile::from_file(&acc.groupFile);
let ini_file;
match chart_config {
Ok(file) => ini_file = file,
@@ -48,14 +55,6 @@ pub fn chart_handler(start : Option<&RawStr>, end : Option<&RawStr>) -> rocket_c
}
let mut groups = HashMap::new();
- let asset_ini = "data/asset.ini";
- let asset = crate::banking::asset::Asset::from_ini_file(asset_ini);
- let transactions = asset.get_account_by_name("Girokonto");
- let acc;
- match transactions {
- Some(trans) => acc = trans,
- None => panic!("could not read file")
- }
let t = acc.transactions;
// filter transaction to match only the specified timeframe
println!("unfiltered number: {}", t.len());