Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/marek-g/rust-ledger-utils
Ledger-cli (https://www.ledger-cli.org/) file processing Rust library, useful for calculating balances, creating reports etc.
https://github.com/marek-g/rust-ledger-utils
Last synced: about 2 months ago
JSON representation
Ledger-cli (https://www.ledger-cli.org/) file processing Rust library, useful for calculating balances, creating reports etc.
- Host: GitHub
- URL: https://github.com/marek-g/rust-ledger-utils
- Owner: marek-g
- License: unlicense
- Created: 2022-01-04T12:16:41.000Z (about 3 years ago)
- Default Branch: master
- Last Pushed: 2024-03-14T10:10:17.000Z (10 months ago)
- Last Synced: 2024-10-31T11:53:33.474Z (2 months ago)
- Language: Rust
- Homepage:
- Size: 77.1 KB
- Stars: 3
- Watchers: 2
- Forks: 1
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
Awesome Lists containing this project
README
# ledger-utils
[![Crates.io Version](https://img.shields.io/crates/v/ledger-utils.svg)](https://crates.io/crates/ledger-utils)
[![Docs.rs Version](https://docs.rs/ledger-utils/badge.svg)](https://docs.rs/ledger-utils)
[![License Unlicense](https://img.shields.io/crates/l/ledger-utils.svg)](http://unlicense.org/UNLICENSE)[Ledger-cli](https://www.ledger-cli.org/) file processing Rust library, useful for calculating balances, creating reports etc.
```rust
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(())
}
```