pub struct JournalEntry {
pub header: JournalEntryHeader,
pub lines: Vec<JournalEntryLine>,
}Expand description
Complete journal entry with header and line items.
Represents a balanced double-entry bookkeeping transaction where total debits must equal total credits.
Fields§
§header: JournalEntryHeaderHeader with document metadata
lines: Vec<JournalEntryLine>Line items (debit and credit postings)
Implementations§
Source§impl JournalEntry
impl JournalEntry
Sourcepub fn new(header: JournalEntryHeader) -> Self
pub fn new(header: JournalEntryHeader) -> Self
Create a new journal entry with header and empty lines.
Sourcepub fn new_simple(
_document_number: String,
company_code: String,
posting_date: NaiveDate,
description: String,
) -> Self
pub fn new_simple( _document_number: String, company_code: String, posting_date: NaiveDate, description: String, ) -> Self
Create a new journal entry with basic parameters (convenience constructor).
This is a simplified constructor for backwards compatibility that creates a journal entry with the specified document number, company code, posting date, and description.
Sourcepub fn add_line(&mut self, line: JournalEntryLine)
pub fn add_line(&mut self, line: JournalEntryLine)
Add a line item to the journal entry.
Sourcepub fn total_debit(&self) -> Decimal
pub fn total_debit(&self) -> Decimal
Get the total debit amount.
Sourcepub fn total_credit(&self) -> Decimal
pub fn total_credit(&self) -> Decimal
Get the total credit amount.
Sourcepub fn is_balanced(&self) -> bool
pub fn is_balanced(&self) -> bool
Check if the journal entry is balanced (debits = credits).
Sourcepub fn balance_difference(&self) -> Decimal
pub fn balance_difference(&self) -> Decimal
Get the out-of-balance amount (should be zero for valid entries).
Sourcepub fn line_count(&self) -> usize
pub fn line_count(&self) -> usize
Get the number of line items.
Sourcepub fn has_even_line_count(&self) -> bool
pub fn has_even_line_count(&self) -> bool
Check if the line count is even.
Sourcepub fn debit_credit_counts(&self) -> (usize, usize)
pub fn debit_credit_counts(&self) -> (usize, usize)
Get the count of debit and credit lines.
Sourcepub fn has_equal_debit_credit_counts(&self) -> bool
pub fn has_equal_debit_credit_counts(&self) -> bool
Check if debit and credit line counts are equal.
Sourcepub fn unique_accounts(&self) -> Vec<&str>
pub fn unique_accounts(&self) -> Vec<&str>
Get unique GL accounts used in this entry.
Sourcepub fn has_suspense_posting(&self) -> bool
pub fn has_suspense_posting(&self) -> bool
Check if any line posts to a suspense account.
Sourcepub fn company_code(&self) -> &str
pub fn company_code(&self) -> &str
Get the company code.
Sourcepub fn document_number(&self) -> String
pub fn document_number(&self) -> String
Get the document number (document_id as string).
Sourcepub fn posting_date(&self) -> NaiveDate
pub fn posting_date(&self) -> NaiveDate
Get the posting date.
Sourcepub fn document_date(&self) -> NaiveDate
pub fn document_date(&self) -> NaiveDate
Get the document date.
Sourcepub fn fiscal_year(&self) -> u16
pub fn fiscal_year(&self) -> u16
Get the fiscal year.
Sourcepub fn fiscal_period(&self) -> u8
pub fn fiscal_period(&self) -> u8
Get the fiscal period.
Sourcepub fn has_sod_violation(&self) -> bool
pub fn has_sod_violation(&self) -> bool
Check if this entry has a SOD violation.
Sourcepub fn description(&self) -> Option<&str>
pub fn description(&self) -> Option<&str>
Get the description (header text).
Sourcepub fn set_description(&mut self, description: String)
pub fn set_description(&mut self, description: String)
Set the description (header text).
Trait Implementations§
Source§impl Clone for JournalEntry
impl Clone for JournalEntry
Source§fn clone(&self) -> JournalEntry
fn clone(&self) -> JournalEntry
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more