acc/lib.rs
1//! Pipeline:
2//!
3//! ```text
4//! load: parser → resolver → booker → indexer ─────────────────────► Journal
5//! enrich: expander → realizer → lotter → translator → revaluator (journal-global)
6//! report: filter → rebalancer → sorter → commands (CLI-driven)
7//! ```
8//!
9//! [`load`] builds a validated `Journal`. [`pipeline::enrich`] runs the
10//! journal-global phases that must see every transaction (realizer and
11//! translator only under `-X`; the revaluator only under `-X` with
12//! `--unrealized`; lotter needs capital accounts). The report phases are
13//! driven by CLI flags and run last, per command.
14
15pub mod booker;
16pub mod commands;
17pub mod date;
18pub mod decimal;
19pub mod error;
20pub mod expander;
21pub mod filter;
22pub mod indexer;
23pub mod loader;
24pub mod lotter;
25pub mod parser;
26pub mod pipeline;
27pub mod realizer;
28pub mod rebalancer;
29pub mod resolver;
30pub mod revaluator;
31pub mod sorter;
32pub mod translator;
33
34pub(crate) mod i256;
35
36pub use error::Error;
37pub use loader::{load, Journal, LoadError};
38
39/// Extension treated as a journal file when walking a directory.
40/// Only `.ledger` is picked up by the recursive walk, so non-journal
41/// files that happen to live in the tree (`.txt` meter readings, notes,
42/// data dumps) are left alone. Explicit `-f FILE` arguments bypass this
43/// filter entirely — when the user names a path directly, acc reads it
44/// whatever the extension.
45pub const JOURNAL_EXTENSIONS: &[&str] = &["ledger"];
46
47/// True if `path` has the recognised journal extension.
48/// Used by directory walkers; never used to reject explicit `-f` paths.
49pub fn is_journal_file(path: &std::path::Path) -> bool {
50 path.extension()
51 .and_then(|e| e.to_str())
52 .is_some_and(|ext| JOURNAL_EXTENSIONS.contains(&ext))
53}