pub struct BookingEngine { /* private fields */ }Expand description
Booking engine that tracks inventory across transactions.
Implementations§
Source§impl BookingEngine
impl BookingEngine
Sourcepub fn with_method(method: BookingMethod) -> Self
pub fn with_method(method: BookingMethod) -> Self
Create a booking engine with a specific default booking method.
Sourcepub fn set_account_method(
&mut self,
account: InternedStr,
method: BookingMethod,
)
pub fn set_account_method( &mut self, account: InternedStr, method: BookingMethod, )
Register the booking method for a specific account.
Call this for each open directive before booking transactions for
that account, so the engine uses the per-account method (e.g. FIFO,
LIFO, NONE) rather than the engine-wide default. Subsequent calls
overwrite the previous method for the account.
Sourcepub fn register_account_methods<'a, I>(&mut self, directives: I)where
I: IntoIterator<Item = &'a Directive>,
pub fn register_account_methods<'a, I>(&mut self, directives: I)where
I: IntoIterator<Item = &'a Directive>,
Scan a sequence of directives and register any per-account booking
methods found on open directives. Open directives whose booking
method is absent or fails to parse are silently ignored (they fall
back to the engine-wide default).
This is a convenience wrapper around Self::set_account_method for
the common pipeline pattern of scanning all directives once before
the booking loop. Call this before booking any transactions so the
engine uses each account’s declared method rather than the
engine-wide default for every account.
Sourcepub fn inventory(&self, account: &InternedStr) -> Option<&Inventory>
pub fn inventory(&self, account: &InternedStr) -> Option<&Inventory>
Get the inventory for an account.
Sourcepub fn book(&self, txn: &Transaction) -> Result<BookedTransaction, BookingError>
pub fn book(&self, txn: &Transaction) -> Result<BookedTransaction, BookingError>
Book a transaction: fill in empty cost specs and calculate gains.
This does NOT modify the internal inventories - call apply for that.
When a reduction matches multiple lots (e.g., selling shares that were purchased across multiple buy transactions), the posting is expanded into multiple postings, one for each matched lot. This matches Python beancount’s behavior.
Sourcepub fn apply(&mut self, txn: &Transaction)
pub fn apply(&mut self, txn: &Transaction)
Apply a transaction to the inventories (update balances).
Sourcepub fn book_and_interpolate(
&self,
txn: &Transaction,
) -> Result<InterpolationResult, BookingError>
pub fn book_and_interpolate( &self, txn: &Transaction, ) -> Result<InterpolationResult, BookingError>
Book and interpolate a transaction.
This fills in empty cost specs, then interpolates any missing amounts.
Trait Implementations§
Source§impl Debug for BookingEngine
impl Debug for BookingEngine
Source§impl Default for BookingEngine
impl Default for BookingEngine
Source§fn default() -> BookingEngine
fn default() -> BookingEngine
Auto Trait Implementations§
impl Freeze for BookingEngine
impl RefUnwindSafe for BookingEngine
impl Send for BookingEngine
impl Sync for BookingEngine
impl Unpin for BookingEngine
impl UnsafeUnpin for BookingEngine
impl UnwindSafe for BookingEngine
Blanket Implementations§
Source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
Source§type ArchivedMetadata = ()
type ArchivedMetadata = ()
Source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> LayoutRaw for T
impl<T> LayoutRaw for T
Source§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
Source§impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
Source§unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
Source§fn resolve_niched(out: Place<NichedOption<T, N1>>)
fn resolve_niched(out: Place<NichedOption<T, N1>>)
out indicating that a T is niched.