diff options
Diffstat (limited to 'src/database.rs')
-rw-r--r-- | src/database.rs | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/src/database.rs b/src/database.rs index 14f04d9..8752255 100644 --- a/src/database.rs +++ b/src/database.rs @@ -48,7 +48,7 @@ impl Database { pub fn view_history(filepath: &PathBuf, filter: Option<String>) -> Result<()> { let conn = Connection::open(filepath)?; let mut hist_query: String = " - SELECT date(r.register_date, 'auto'), a.name, r.amount + SELECT date(r.register_date, 'auto'), a.name, r.amount, r.note FROM Registers r INNER JOIN Agents a ON a.id = r.agent_id @@ -69,20 +69,21 @@ impl Database { } }; let mut total = 0; - println!("+{:-<10}+{:-<20}+{:-<10}+", "", "", ""); - println!("|{:^10}|{:^20}|{:^10}|", "date", "name", "amount"); - println!("+{:-<10}+{:-<20}+{:-<10}+", "", "", ""); + println!("+{:-<10}+{:-<20}+{:-<10}+{:-<20}+", "", "", "", ""); + println!("|{:^10}|{:^20}|{:^10}|{:^20}|", "date", "name", "amount", "note"); + println!("+{:-<10}+{:-<20}+{:-<10}+{:-<20}+", "", "", "", ""); while let Some(row) = regs.next()? { let date: String = row.get(0)?; let name: String = row.get(1)?; let amount: i32 = row.get(2)?; + let note: Option<String> = row.get(3)?; - println!("|{}|{:>20}|{:>10}|", date, name, amount); + println!("|{}|{:>20}|{:>10}|{:>20}|", date, name, amount, note.unwrap_or("".to_string())); total += amount; } - println!("+{:-<10}+{:-<20}+{:-<10}+", "", "", ""); - println!("|{:^10}{:>32}|", "total", total); - println!("+{:-<10}+{:-<20}+{:-<10}+", "", "", ""); + println!("+{:-<10}+{:-<20}+{:-<10}+{:-<20}+", "", "", "", ""); + println!("|{:^10}|{:>52}|", "total", total); + println!("+{:-<10}+{:-<52}+", "", ""); Ok(()) } |