From bfb6bea4e1771ba52aa5550bc0952986e9944557 Mon Sep 17 00:00:00 2001 From: Benedict Börger Date: Wed, 26 Jun 2019 23:52:40 +0200 Subject: [banking] add category parsing from asset.ini --- src/banking/account.rs | 9 ++++++--- src/banking/asset.rs | 10 +++++++++- 2 files changed, 15 insertions(+), 4 deletions(-) (limited to 'src/banking') diff --git a/src/banking/account.rs b/src/banking/account.rs index 1783e63..baaccec 100644 --- a/src/banking/account.rs +++ b/src/banking/account.rs @@ -5,11 +5,13 @@ pub struct Account { pub iban : String, pub transactions : Vec, pub institute : String, - pub groupFile : String + pub groupFile : String, + pub category : String + } impl Account { - pub fn new(name : String, iban : String, transactions : Vec, institute : String, groupFile : String) -> Account { + pub fn new(name : String, iban : String, transactions : Vec, institute : String, groupFile : String, category : String) -> Account { let mut trans = Vec::new(); if institute == "Sparkasse" { // TODO als function/lambda übergeben die konvertierung.. @@ -23,7 +25,8 @@ impl Account { } } } - Account { name : name, iban : iban, transactions : trans, institute : institute, groupFile : groupFile } + Account { name : name, iban : iban, transactions : trans, institute : institute, groupFile : groupFile, category : category } + } } } diff --git a/src/banking/asset.rs b/src/banking/asset.rs index 1cbcbc4..590d8e7 100644 --- a/src/banking/asset.rs +++ b/src/banking/asset.rs @@ -31,6 +31,14 @@ impl Asset { Some(i) => trans_files = i, None => panic!("asset: ini file: no \"TransactionFile\" for account: {}", account_name) } + match config.get("Category") { + Some(i) => tmp = i, + None => panic!("asset: ini file: no \"Category\" for account: {}", account_name) + } + let mut category = String::from(""); + if let Some(i) = tmp.get(0) { + category = i.to_string(); + } match config.get("IBAN") { Some(i) => tmp = i, None => panic!("asset: no name for account {}", account_name) @@ -47,7 +55,7 @@ impl Asset { if let Some(i) = tmp.get(0) { groupFile = i.to_string(); } - accounts.push(Account::new(account_name, iban, trans_files.to_vec(), institute, groupFile)); + accounts.push(Account::new(account_name, iban, trans_files.to_vec(), institute, groupFile, category)); } -- cgit v1.2.3-70-g09d2