summaryrefslogtreecommitdiff
path: root/src/main.rs
blob: 5350945b89003e97fddf94184e62290477c5ec1d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
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);
        }
    }
}