pub struct JournalEntryRecord {
pub id: String,
pub book: LedgerBook,
pub currency: String,
pub memo: String,
pub lines: Vec<JournalLine>,
pub occurred_at_unix: u32,
pub occurred_at_instant: Option<InstantBridge>,
pub project_id: Option<String>,
pub reversal_of_id: Option<String>,
}Expand description
An immutable double-entry journal entry record assigned to a LedgerBook.
Fields§
§id: String§book: LedgerBook§currency: String§memo: String§lines: Vec<JournalLine>§occurred_at_unix: u32§occurred_at_instant: Option<InstantBridge>§project_id: Option<String>§reversal_of_id: Option<String>Implementations§
Source§impl JournalEntryRecord
impl JournalEntryRecord
Sourcepub fn new(
book: LedgerBook,
currency: impl Into<String>,
memo: impl Into<String>,
lines: Vec<JournalLine>,
occurred_at_unix: u32,
) -> Self
pub fn new( book: LedgerBook, currency: impl Into<String>, memo: impl Into<String>, lines: Vec<JournalLine>, occurred_at_unix: u32, ) -> Self
Create a new double-entry journal record.
Sourcepub fn total_debits(&self) -> i64
pub fn total_debits(&self) -> i64
Total debits in integer minor units (cents).
Sourcepub fn total_credits(&self) -> i64
pub fn total_credits(&self) -> i64
Total credits in integer minor units (cents).
Sourcepub fn is_balanced(&self) -> bool
pub fn is_balanced(&self) -> bool
Returns true if the entry has at least two valid lines and total debits equal total credits.
Sourcepub fn validate_balance(&self) -> Result<(), String>
pub fn validate_balance(&self) -> Result<(), String>
Validate that the journal entry is balanced (total_debits == total_credits).
Sourcepub fn compile_to_quins(&self, out: &mut [NQuin]) -> usize
pub fn compile_to_quins(&self, out: &mut [NQuin]) -> usize
Zero-heap compilation of a JournalEntryRecord into 48-byte NQuins.
Trait Implementations§
Source§impl Clone for JournalEntryRecord
impl Clone for JournalEntryRecord
Source§impl Debug for JournalEntryRecord
impl Debug for JournalEntryRecord
Source§impl<'de> Deserialize<'de> for JournalEntryRecord
impl<'de> Deserialize<'de> for JournalEntryRecord
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl Eq for JournalEntryRecord
Source§impl PartialEq for JournalEntryRecord
impl PartialEq for JournalEntryRecord
Source§impl Serialize for JournalEntryRecord
impl Serialize for JournalEntryRecord
impl StructuralPartialEq for JournalEntryRecord
Auto Trait Implementations§
impl Freeze for JournalEntryRecord
impl RefUnwindSafe for JournalEntryRecord
impl Send for JournalEntryRecord
impl Sync for JournalEntryRecord
impl Unpin for JournalEntryRecord
impl UnsafeUnpin for JournalEntryRecord
impl UnwindSafe for JournalEntryRecord
Blanket Implementations§
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
Mutably borrows from an owned value. Read more