pub struct JournalEntry {Show 13 fields
pub id: Uuid,
pub organization_id: Uuid,
pub building_id: Option<Uuid>,
pub entry_date: DateTime<Utc>,
pub description: Option<String>,
pub document_ref: Option<String>,
pub journal_type: Option<String>,
pub expense_id: Option<Uuid>,
pub contribution_id: Option<Uuid>,
pub lines: Vec<JournalEntryLine>,
pub created_at: DateTime<Utc>,
pub updated_at: DateTime<Utc>,
pub created_by: Option<Uuid>,
}Expand description
Journal Entry represents a complete accounting transaction with balanced debit and credit lines (double-entry bookkeeping).
Each entry contains multiple lines (JournalEntryLine) where:
- Sum of debits = Sum of credits (enforced by database trigger)
- Each line affects one account
Example: Recording a 1,210€ utility expense (1,000€ + 210€ VAT 21%):
- Debit: 6100 (Utilities) 1,000€
- Debit: 4110 (VAT Recoverable) 210€
- Credit: 4400 (Suppliers) 1,210€
Fields§
§id: Uuid§organization_id: Uuid§building_id: Option<Uuid>Optional link to building for building-specific accounting
entry_date: DateTime<Utc>Date when the transaction occurred (not when recorded)
description: Option<String>Human-readable description (e.g., “Facture eau janvier 2025”)
document_ref: Option<String>Reference to source document (invoice number, receipt, etc.)
journal_type: Option<String>Journal type: ACH (Purchases), VEN (Sales), FIN (Financial), ODS (Miscellaneous) Inspired by Noalyss journal categories
expense_id: Option<Uuid>Optional link to the expense that generated this entry
contribution_id: Option<Uuid>Optional link to the owner contribution that generated this entry
lines: Vec<JournalEntryLine>Lines composing this entry (debits and credits)
created_at: DateTime<Utc>§updated_at: DateTime<Utc>§created_by: Option<Uuid>Implementations§
Source§impl JournalEntry
impl JournalEntry
Sourcepub fn new(
organization_id: Uuid,
building_id: Option<Uuid>,
entry_date: DateTime<Utc>,
description: Option<String>,
document_ref: Option<String>,
journal_type: Option<String>,
expense_id: Option<Uuid>,
contribution_id: Option<Uuid>,
lines: Vec<JournalEntryLine>,
created_by: Option<Uuid>,
) -> Result<Self, String>
pub fn new( organization_id: Uuid, building_id: Option<Uuid>, entry_date: DateTime<Utc>, description: Option<String>, document_ref: Option<String>, journal_type: Option<String>, expense_id: Option<Uuid>, contribution_id: Option<Uuid>, lines: Vec<JournalEntryLine>, created_by: Option<Uuid>, ) -> Result<Self, String>
Create a new journal entry with validation
§Arguments
organization_id: Organization owning this entryentry_date: Transaction datedescription: Human-readable descriptionlines: Debit and credit lines (must balance)
§Returns
Ok(JournalEntry)if lines balance (within 0.01€ tolerance)Err(String)if validation fails
Sourcepub fn total_debits(&self) -> Decimal
pub fn total_debits(&self) -> Decimal
Calculate total debits for this entry
Sourcepub fn total_credits(&self) -> Decimal
pub fn total_credits(&self) -> Decimal
Calculate total credits for this entry
Sourcepub fn is_balanced(&self) -> bool
pub fn is_balanced(&self) -> bool
Check if this entry is balanced (debits = credits)
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 moreSource§impl Debug for JournalEntry
impl Debug for JournalEntry
Source§impl<'de> Deserialize<'de> for JournalEntry
impl<'de> Deserialize<'de> for JournalEntry
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>,
Auto Trait Implementations§
impl Freeze for JournalEntry
impl RefUnwindSafe for JournalEntry
impl Send for JournalEntry
impl Sync for JournalEntry
impl Unpin for JournalEntry
impl UnsafeUnpin for JournalEntry
impl UnwindSafe for JournalEntry
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Fake for T
impl<T> Fake for T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more