aboutsummaryrefslogtreecommitdiff
path: root/src/database.rs
diff options
context:
space:
mode:
authorjvech <jmvalenciae@unal.edu.co>2024-04-30 07:45:28 -0500
committerjvech <jmvalenciae@unal.edu.co>2024-04-30 07:45:28 -0500
commitce3bbcd183bcf505b525396db3ba4b9e71c83f55 (patch)
treee4987cf3f390c783c8ce269e112eaaf70331b988 /src/database.rs
parenta361eb833f516befe79b45a8b6ed3162a21bc06a (diff)
add: note field implemented
Diffstat (limited to 'src/database.rs')
-rw-r--r--src/database.rs17
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(())
}
Feel free to download, copy and edit any repo