pactole_core/models/balance.rs
1use crate::models::names::{AccountName, CommodityName, Metadata};
2use chrono::NaiveDate;
3use rust_decimal::Decimal;
4
5// -------------------------------------------------
6// Assertions
7// -------------------------------------------------
8
9/// Expected balance of an account on a date.
10#[derive(Debug, Clone, PartialEq)]
11pub struct Balance {
12 /// Date of the assertion.
13 pub date: NaiveDate,
14 /// Account whose balance is asserted.
15 pub account: AccountName,
16 /// Expected amount.
17 pub amount: Amount,
18 /// Optional allowed difference. Without it, the assertion must match
19 /// exactly.
20 pub tolerance: Option<Decimal>,
21 /// Metadata attached to the directive.
22 pub meta: Metadata,
23}
24
25// -------------------------------------------------
26// Misc
27// -------------------------------------------------
28
29/// A decimal quantity paired with its commodity.
30#[derive(Debug, Clone, PartialEq)]
31pub struct Amount {
32 /// Numeric quantity, represented exactly as a decimal.
33 pub number: Decimal,
34 /// Commodity in which the quantity is expressed.
35 pub commodity: CommodityName,
36}