From f7b645895d050a8006057f38edfb118dbece37fe Mon Sep 17 00:00:00 2001 From: James McDonald Date: Wed, 3 Jun 2026 09:20:12 +0200 Subject: [PATCH] Format transaction amounts on output This might want to use the same YNAB CSV format as `convert`. --- src/main.rs | 2 +- src/transaction.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main.rs b/src/main.rs index 5c5ae0d..03bb212 100644 --- a/src/main.rs +++ b/src/main.rs @@ -171,7 +171,7 @@ async fn main() -> anyhow::Result<()> { }; println!("Transactions{} in the last 30 days:", accountstr); for t in transactions { - println!("{},{},{}", t.date, t.payee, t.amount); + println!("{},{},{}", t.date, t.payee, t.format_amount()); } Ok(()) diff --git a/src/transaction.rs b/src/transaction.rs index 7eae797..055ef56 100644 --- a/src/transaction.rs +++ b/src/transaction.rs @@ -32,7 +32,7 @@ impl Transaction { }) } - fn format_amount(&self) -> String { + pub fn format_amount(&self) -> String { let whole = self.amount / 10 / 100; let frac = if self.amount < 0 { -1 } else { 1 } * (self.amount / 10) % 100; format!("{}.{:02}", whole, frac)