Skip to main content

Module prelude

Module prelude 

Source
Expand description

The everyday vocabulary in one import: the façades, the one error, the values and drafts of drafting, recording and reading, the five common currencies and the two literal macros.

use doubleentry::prelude::*;

let mut books = Journal::new(LedgerId::new("example.com/acme")?).as_actor("setup");
books.declare_currency(EUR, 2, date!("2026-01-01"))?;
books.open("Assets:Cash", AccountKind::Asset, date!("2026-01-01"))?;
books.open("Income:Sales", AccountKind::Income, date!("2026-01-01"))?;
books.define_months(2026, 3..=3)?;
let recorded: Recorded = books.record(
    Entry::new("invoice-2026-0001", date!("2026-03-15"))
        .debit("Assets:Cash", amount!("1190.00"), EUR)
        .credit("Income:Sales", amount!("1190.00"), EUR),
)?;
assert!(!recorded.replayed);

Everything else — stores, proofs beyond InclusionProof, report types beyond BalanceQuery, transparency, testing — is imported by name from its one path. The prelude is the only second path to any item.

Re-exports§

pub use crate::currency::CHF;
pub use crate::currency::EUR;
pub use crate::currency::GBP;
pub use crate::currency::JPY;
pub use crate::currency::USD;
pub use crate::AccountHandle;
pub use crate::AccountKind;
pub use crate::AccountPath;
pub use crate::Amount;
pub use crate::Balance;
pub use crate::BalanceLimit;
pub use crate::BalanceQuery;
pub use crate::Currency;
pub use crate::Document;
pub use crate::Entry;
pub use crate::EntryId;
pub use crate::Label;
pub use crate::Layer;
pub use crate::LedgerId;
pub use crate::PostingRef;
pub use crate::Rate;
pub use crate::Recorded;
pub use crate::Rounding;
pub use crate::Side;
pub use crate::Error;
pub use crate::Journal;
pub use crate::Ledger;
pub use crate::Rejection;
pub use crate::Result;

Macros§

amount
A compile-checked Amount literal; P is inferred from context.
date
A Date from a YYYY-MM-DD literal, checked at compile time.

Structs§

Date
The calendar date every booking date, value date and effective date is (re-exported from time, so date! needs no dependency of yours). Date in the proleptic Gregorian calendar.