pub struct Expense {Show 26 fields
pub id: Uuid,
pub organization_id: Uuid,
pub building_id: Uuid,
pub category: ExpenseCategory,
pub description: String,
pub amount: f64,
pub amount_excl_vat: Option<f64>,
pub vat_rate: Option<f64>,
pub vat_amount: Option<f64>,
pub amount_incl_vat: Option<f64>,
pub expense_date: DateTime<Utc>,
pub invoice_date: Option<DateTime<Utc>>,
pub due_date: Option<DateTime<Utc>>,
pub paid_date: Option<DateTime<Utc>>,
pub approval_status: ApprovalStatus,
pub submitted_at: Option<DateTime<Utc>>,
pub approved_by: Option<Uuid>,
pub approved_at: Option<DateTime<Utc>>,
pub rejection_reason: Option<String>,
pub payment_status: PaymentStatus,
pub supplier: Option<String>,
pub invoice_number: Option<String>,
pub account_code: Option<String>,
pub contractor_report_id: Option<Uuid>,
pub created_at: DateTime<Utc>,
pub updated_at: DateTime<Utc>,
}Expand description
Représente une charge de copropriété / facture
Conforme au PCMN belge (Plan Comptable Minimum Normalisé). Chaque charge peut être liée à un compte comptable via account_code.
Fields§
§id: Uuid§organization_id: Uuid§building_id: Uuid§category: ExpenseCategory§description: String§amount: f64§amount_excl_vat: Option<f64>§vat_rate: Option<f64>§vat_amount: Option<f64>§amount_incl_vat: Option<f64>§expense_date: DateTime<Utc>§invoice_date: Option<DateTime<Utc>>§due_date: Option<DateTime<Utc>>§paid_date: Option<DateTime<Utc>>§approval_status: ApprovalStatus§submitted_at: Option<DateTime<Utc>>§approved_by: Option<Uuid>§approved_at: Option<DateTime<Utc>>§rejection_reason: Option<String>§payment_status: PaymentStatus§supplier: Option<String>§invoice_number: Option<String>§account_code: Option<String>Code du compte comptable PCMN (e.g., “604001” for electricity, “611002” for elevator maintenance) References: accounts.code column in the database
contractor_report_id: Option<Uuid>Link to contractor report for work expenses (Issue #309) Required for category = Works before approval
created_at: DateTime<Utc>§updated_at: DateTime<Utc>Implementations§
Source§impl Expense
impl Expense
pub fn new( organization_id: Uuid, building_id: Uuid, category: ExpenseCategory, description: String, amount: f64, expense_date: DateTime<Utc>, supplier: Option<String>, invoice_number: Option<String>, account_code: Option<String>, ) -> Result<Self, String>
Sourcepub fn new_with_vat(
organization_id: Uuid,
building_id: Uuid,
category: ExpenseCategory,
description: String,
amount_excl_vat: f64,
vat_rate: f64,
invoice_date: DateTime<Utc>,
due_date: Option<DateTime<Utc>>,
supplier: Option<String>,
invoice_number: Option<String>,
account_code: Option<String>,
) -> Result<Self, String>
pub fn new_with_vat( organization_id: Uuid, building_id: Uuid, category: ExpenseCategory, description: String, amount_excl_vat: f64, vat_rate: f64, invoice_date: DateTime<Utc>, due_date: Option<DateTime<Utc>>, supplier: Option<String>, invoice_number: Option<String>, account_code: Option<String>, ) -> Result<Self, String>
Crée une facture avec gestion complète de la TVA
Sourcepub fn recalculate_vat(&mut self) -> Result<(), String>
pub fn recalculate_vat(&mut self) -> Result<(), String>
Recalcule la TVA si le montant HT ou le taux change
Sourcepub fn submit_for_approval(&mut self) -> Result<(), String>
pub fn submit_for_approval(&mut self) -> Result<(), String>
Soumet la facture pour validation (Draft → PendingApproval)
Sourcepub fn approve(&mut self, approved_by_user_id: Uuid) -> Result<(), String>
pub fn approve(&mut self, approved_by_user_id: Uuid) -> Result<(), String>
Approuve la facture (PendingApproval → Approved) Pour les charges de type “Works”, une référence à un rapport contracteur validé est obligatoire
Sourcepub fn reject(
&mut self,
rejected_by_user_id: Uuid,
reason: String,
) -> Result<(), String>
pub fn reject( &mut self, rejected_by_user_id: Uuid, reason: String, ) -> Result<(), String>
Rejette la facture avec une raison (PendingApproval → Rejected)
Sourcepub fn can_be_modified(&self) -> bool
pub fn can_be_modified(&self) -> bool
Vérifie si la facture peut être modifiée (uniquement en Draft ou Rejected)
Sourcepub fn is_approved(&self) -> bool
pub fn is_approved(&self) -> bool
Vérifie si la facture est approuvée
pub fn mark_as_paid(&mut self) -> Result<(), String>
pub fn mark_as_overdue(&mut self) -> Result<(), String>
pub fn cancel(&mut self) -> Result<(), String>
Sourcepub fn set_contractor_report(
&mut self,
contractor_report_id: Uuid,
) -> Result<(), String>
pub fn set_contractor_report( &mut self, contractor_report_id: Uuid, ) -> Result<(), String>
Set the contractor report link for work expenses (Issue #309)
pub fn reactivate(&mut self) -> Result<(), String>
pub fn unpay(&mut self) -> Result<(), String>
pub fn is_paid(&self) -> bool
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Expense
impl<'de> Deserialize<'de> for Expense
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>,
impl StructuralPartialEq for Expense
Auto Trait Implementations§
impl Freeze for Expense
impl RefUnwindSafe for Expense
impl Send for Expense
impl Sync for Expense
impl Unpin for Expense
impl UnwindSafe for Expense
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
§impl<T> Chain<T> for T
impl<T> Chain<T> for 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