diff options
| author | PROINT <> | 2026-07-20 16:24:05 +0900 |
|---|---|---|
| committer | PROINT <> | 2026-07-20 16:24:05 +0900 |
| commit | 8fb895991c8988e21273cc5092f39f28382b777c (patch) | |
| tree | b8392d349ccda196a2cf6cd7d914547f0cf29f8e /src/main.rs | |
Added types for ledger
Diffstat (limited to 'src/main.rs')
| -rw-r--r-- | src/main.rs | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/src/main.rs b/src/main.rs new file mode 100644 index 0000000..5350945 --- /dev/null +++ b/src/main.rs @@ -0,0 +1,46 @@ +mod types; + +use types::*; + +fn main() { + let asset = Account { + account_type: AccountType::Asset, + path: "1".to_string(), + name: "Asset".to_string(), + description: "Asset".to_string() + }; + let revenue = Account { + account_type: AccountType::Revenue, + path: "4".to_string(), + name: "Revenue".to_string(), + description: "Revenue".to_string() + }; + let asset_debit = Transaction { + transaction_type: TransactionType::Debit, + account: asset, + amount: 1000 + }; + let revenue_credit = Transaction { + transaction_type: TransactionType::Credit, + account: revenue, + amount: 1000 + }; + let entry = JournalEntry { + date: chrono::Utc::now(), + transactions: vec![asset_debit, revenue_credit], + balance: 1000, + description: "Paycheck".to_string() + }; + println!("date\t\t\t\t\taccount\tdebit\tcredit"); + print!("{}\t", entry.date); + for t in &entry.transactions { + if t.transaction_type == TransactionType::Debit { + println!("{}\t{}", t.account.name, t.amount); + } + } + for t in entry.transactions { + if t.transaction_type == TransactionType::Credit { + println!("\t\t\t\t\t{}\t\t{}", t.account.name, t.amount); + } + } +} |
