beanru 0.1.0

Library to simplify writing read-modify-write scripts for beancount.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
use crate::types::*;

/// Checks if given beancount file is correct.
///
/// TODO: Add other checks, like verifying that accounts are open and verify balance
/// directives.
pub fn check(file: &BeancountFile<rust_decimal::Decimal>) -> anyhow::Result<()> {
    for d in &file.directives {
        let t = match &d.content {
            DirectiveContent::Transaction(t) => t,
            _ => continue,
        };
        if !t.balanced {
            println!("Transaction not balanced:\n{}", d);
        }
    }
    Ok(())
}