Expand description
Pure domain models, validation and reporting for Pactole journals.
This crate performs no I/O and has no dependency on the parser or storage
layers. A typical consumer builds a Journal, validates it with
validate_journal or validate_journal_all, then produces a register
report with register. Monetary values use rust_decimal::Decimal.
Structs§
- Account
Name - An account name: colon-separated segments, the first one starting with
an uppercase letter, each made of letters, digits,
_or-(see theaccountrule ingrammar.js). - Amount
- A decimal quantity paired with its commodity.
- Balance
- Expected balance of an account on a date.
- Close
- Closes an account on a given date.
- Commodity
- Declares a commodity on a given date.
- Commodity
Name - A commodity name: a Beancount-like currency code of 2 to 24 characters,
starting with an uppercase letter, ending with an uppercase letter or
digit, and made of uppercase letters, digits,
',.,_or-in between (see thecommodity_namerule ingrammar.js). - Journal
- A collection of top-level Pactole directives.
- Metadata
Key - A metadata key: only lowercase letters,
_or-(see thekeyrule ingrammar.js). - Open
- Opens an account on a given date.
- Payee
- Declares a payee as “known” (see
ValidationError::PayeeNotDeclared). - Posting
- One account-side movement within a transaction.
- Register
Entry - A single line of a
registerlisting: one matched posting, along with the transaction it belongs to and the running balance of the register up to (and including) this line. - Register
Filter - Filters used to select which postings are included in a
registerlisting. - Transaction
- A balanced financial transaction with one or more postings.
- Validation
Issue - A validation error together with the index of the offending entry in the
journal passed to
validate_journal_all, before chronological sorting. - Validation
Report - A complete validation result, including the normalized journal and all non-cascading issues found while walking it.
Enums§
- Entry
- A top-level directive in a Pactole journal.
- Model
Error - Errors raised when building core model values: purely grammatical / structural checks (e.g. the shape of a name), with no knowledge of the rest of the journal.
- Transaction
Status - Reconciliation status of a transaction.
- Validation
Error - Errors raised when validating a
crate::Journalas a whole: checks that require knowing about other entries of the journal, as opposed to the purely grammatical checks reported asModelError.
Traits§
- Readable
Storage - Reads a complete journal from a storage backend.
Functions§
- register
- Lists the postings of
journalmatchingfilter, in chronological order (the journal is expected to already be sorted, e.g. bycrate::validate_journal), together with a running balance kept per commodity across the whole listing. - validate_
journal - Validates a journal and returns the first business error, if any.
- validate_
journal_ all - Validates every entry and returns all errors that can be diagnosed without aborting the journal walk. Invalid entries do not mutate validation state, preventing one error from causing a cascade of misleading later errors.
Type Aliases§
- Metadata
- Metadata attached to a directive or posting.