1
- use std:: path:: Path ;
1
+ use std:: { fmt :: Display , path:: Path } ;
2
2
3
3
use crate :: { accounts, currency:: Amount , error:: Result } ;
4
4
@@ -10,14 +10,33 @@ struct Row {
10
10
amount : Amount ,
11
11
}
12
12
13
- pub async fn run ( _token : String , file : String ) -> Result < ( ) > {
13
+ impl Display for Row {
14
+ fn fmt ( & self , f : & mut std:: fmt:: Formatter < ' _ > ) -> std:: fmt:: Result {
15
+ write ! (
16
+ f,
17
+ "account={}, category={}, description={}, amount={}" ,
18
+ self . account. value( ) ,
19
+ self . category,
20
+ self . description,
21
+ self . amount
22
+ )
23
+ }
24
+ }
25
+
26
+ pub async fn run ( token : String , file : String ) -> Result < ( ) > {
14
27
let path = Path :: new ( & file) ;
15
- println ! ( "batch file path : {}" , path. display( ) ) ;
28
+ println ! ( "starting batch run for file : {}" , path. display( ) ) ;
16
29
17
30
let mut reader = csv:: Reader :: from_path ( path) ?;
18
31
for result in reader. deserialize ( ) {
19
32
let row: Row = result?;
20
- dbg ! ( row) ;
33
+
34
+ println ! ( "executing batch row, {}" , row) ;
35
+
36
+ // let pot_name = config::pot_for(row.account, row.category);
37
+ // let deposit = pots::deposit(&token, pot_name, &row.amount).await?;
38
+ // let deposit_tx = transactions::find_transaction(&token, depo).await?;
39
+ // transactions::annotate(&token, &deposit_tx.id, row.description).await?;
21
40
}
22
41
Ok ( ( ) )
23
42
}
0 commit comments