#ledger #ledger-cli #accounting #file-processing #reports #finance

ledger-utils

Ledger-cli (https://www.ledger-cli.org/) file processing Rust library, useful for calculating balances, creating reports etc

7 releases (breaking)

0.6.0 Mar 14, 2024
0.5.0 Mar 5, 2024
0.4.1 Feb 19, 2022
0.3.0 Jan 25, 2022
0.1.0 Jan 4, 2022

#1063 in Parser implementations

Download history 2/week @ 2024-07-19 12/week @ 2024-07-26 11/week @ 2024-09-20 2/week @ 2024-09-27

257 downloads per month

Unlicense

87KB
2.5K SLoC

ledger-utils

Crates.io Version Docs.rs Version License Unlicense

Ledger-cli file processing Rust library, useful for calculating balances, creating reports etc.

use anyhow::{bail, Result};
use ledger_utils::{balance::Balance, Ledger};

fn main() -> Result<()> {
    let ledger: Ledger = fs::read_to_string("finances.ledger")?.parse()?;

    if ledger.transactions.is_empty() {
        bail!("no transactions found");
    }

    let balance: Balance = (&ledger).into();

    let mut assets: Vec<_> = balance
        .account_balances
        .iter()
        .filter(|(name, _)| name.starts_with("Assets:"))
        .collect();
    assets.sort_by_key(|&(name, _)| name);
    for (name, balance) in assets {
        println!("{}: {}", name, balance);
    }

    Ok(())
}

Dependencies

~3MB
~58K SLoC