Skip to main content

Crate pactole_core

Crate pactole_core 

Source
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§

AccountName
An account name: colon-separated segments, the first one starting with an uppercase letter, each made of letters, digits, _ or - (see the account rule in grammar.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.
CommodityName
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 the commodity_name rule in grammar.js).
Journal
A collection of top-level Pactole directives.
MetadataKey
A metadata key: only lowercase letters, _ or - (see the key rule in grammar.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.
RegisterEntry
A single line of a register listing: one matched posting, along with the transaction it belongs to and the running balance of the register up to (and including) this line.
RegisterFilter
Filters used to select which postings are included in a register listing.
Transaction
A balanced financial transaction with one or more postings.
ValidationIssue
A validation error together with the index of the offending entry in the journal passed to validate_journal_all, before chronological sorting.
ValidationReport
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.
ModelError
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.
TransactionStatus
Reconciliation status of a transaction.
ValidationError
Errors raised when validating a crate::Journal as a whole: checks that require knowing about other entries of the journal, as opposed to the purely grammatical checks reported as ModelError.

Traits§

ReadableStorage
Reads a complete journal from a storage backend.

Functions§

register
Lists the postings of journal matching filter, in chronological order (the journal is expected to already be sorted, e.g. by crate::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.