Skip to main content

JournalEntry

Struct JournalEntry 

Source
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: JournalEntryHeader

Header with document metadata

§lines: Vec<JournalEntryLine>

Line items (debit and credit postings)

Implementations§

Source§

impl JournalEntry

Source

pub fn new(header: JournalEntryHeader) -> Self

Create a new journal entry with header and empty lines.

Source

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.

Source

pub fn add_line(&mut self, line: JournalEntryLine)

Add a line item to the journal entry.

Source

pub fn total_debit(&self) -> Decimal

Get the total debit amount.

Source

pub fn total_credit(&self) -> Decimal

Get the total credit amount.

Source

pub fn is_balanced(&self) -> bool

Check if the journal entry is balanced (debits = credits).

Source

pub fn balance_difference(&self) -> Decimal

Get the out-of-balance amount (should be zero for valid entries).

Source

pub fn line_count(&self) -> usize

Get the number of line items.

Source

pub fn has_even_line_count(&self) -> bool

Check if the line count is even.

Source

pub fn debit_credit_counts(&self) -> (usize, usize)

Get the count of debit and credit lines.

Source

pub fn has_equal_debit_credit_counts(&self) -> bool

Check if debit and credit line counts are equal.

Source

pub fn unique_accounts(&self) -> Vec<&str>

Get unique GL accounts used in this entry.

Source

pub fn has_suspense_posting(&self) -> bool

Check if any line posts to a suspense account.

Source

pub fn company_code(&self) -> &str

Get the company code.

Source

pub fn document_number(&self) -> String

Get the document number (document_id as string).

Source

pub fn posting_date(&self) -> NaiveDate

Get the posting date.

Source

pub fn document_date(&self) -> NaiveDate

Get the document date.

Source

pub fn fiscal_year(&self) -> u16

Get the fiscal year.

Source

pub fn fiscal_period(&self) -> u8

Get the fiscal period.

Source

pub fn currency(&self) -> &str

Get the currency.

Source

pub fn is_fraud(&self) -> bool

Check if this entry is marked as fraud.

Source

pub fn has_sod_violation(&self) -> bool

Check if this entry has a SOD violation.

Source

pub fn description(&self) -> Option<&str>

Get the description (header text).

Source

pub fn set_description(&mut self, description: String)

Set the description (header text).

Trait Implementations§

Source§

impl Clone for JournalEntry

Source§

fn clone(&self) -> JournalEntry

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for JournalEntry

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for JournalEntry

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for JournalEntry

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,