Skip to main content

APInvoice

Struct APInvoice 

Source
pub struct APInvoice {
Show 31 fields pub invoice_number: String, pub vendor_invoice_number: String, pub company_code: String, pub vendor_id: String, pub vendor_name: String, pub invoice_date: NaiveDate, pub posting_date: NaiveDate, pub document_date: NaiveDate, pub due_date: NaiveDate, pub baseline_date: NaiveDate, pub invoice_type: APInvoiceType, pub status: SubledgerDocumentStatus, pub lines: Vec<APInvoiceLine>, pub net_amount: CurrencyAmount, pub tax_amount: CurrencyAmount, pub gross_amount: CurrencyAmount, pub amount_paid: Decimal, pub amount_remaining: Decimal, pub payment_terms: PaymentTerms, pub tax_details: Vec<TaxInfo>, pub gl_reference: Option<GLReference>, pub clearing_info: Vec<ClearingInfo>, pub match_status: MatchStatus, pub reference_po: Option<String>, pub reference_gr: Option<String>, pub payment_block: Option<PaymentBlockReason>, pub withholding_tax: Option<WithholdingTax>, pub created_at: DateTime<Utc>, pub created_by: Option<String>, pub modified_at: Option<DateTime<Utc>>, pub notes: Option<String>,
}
Expand description

AP Invoice (vendor invoice).

Fields§

§invoice_number: String

Unique invoice number (internal).

§vendor_invoice_number: String

Vendor’s invoice number.

§company_code: String

Company code.

§vendor_id: String

Vendor ID.

§vendor_name: String

Vendor name.

§invoice_date: NaiveDate

Invoice date (vendor’s date).

§posting_date: NaiveDate

Posting date.

§document_date: NaiveDate

Document date (receipt date).

§due_date: NaiveDate

Due date.

§baseline_date: NaiveDate

Baseline date for payment terms.

§invoice_type: APInvoiceType

Invoice type.

§status: SubledgerDocumentStatus

Invoice status.

§lines: Vec<APInvoiceLine>

Invoice lines.

§net_amount: CurrencyAmount

Net amount (before tax).

§tax_amount: CurrencyAmount

Tax amount.

§gross_amount: CurrencyAmount

Gross amount (after tax).

§amount_paid: Decimal

Amount paid.

§amount_remaining: Decimal

Amount remaining.

§payment_terms: PaymentTerms

Payment terms.

§tax_details: Vec<TaxInfo>

Tax details.

§gl_reference: Option<GLReference>

GL reference.

§clearing_info: Vec<ClearingInfo>

Clearing information.

§match_status: MatchStatus

Three-way match status.

§reference_po: Option<String>

Reference purchase order.

§reference_gr: Option<String>

Reference goods receipt.

§payment_block: Option<PaymentBlockReason>

Payment block reason.

§withholding_tax: Option<WithholdingTax>

Withholding tax applicable.

§created_at: DateTime<Utc>

Created timestamp.

§created_by: Option<String>

Created by user.

§modified_at: Option<DateTime<Utc>>

Last modified timestamp.

§notes: Option<String>

Notes.

Implementations§

Source§

impl APInvoice

Source

pub fn new( invoice_number: String, vendor_invoice_number: String, company_code: String, vendor_id: String, vendor_name: String, invoice_date: NaiveDate, payment_terms: PaymentTerms, currency: String, ) -> Self

Creates a new AP invoice.

Source

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

Adds an invoice line.

Source

pub fn recalculate_totals(&mut self)

Recalculates totals from lines.

Source

pub fn apply_payment(&mut self, amount: Decimal, clearing: ClearingInfo)

Applies a payment to the invoice.

Source

pub fn is_overdue(&self, as_of_date: NaiveDate) -> bool

Checks if invoice is overdue.

Source

pub fn days_overdue(&self, as_of_date: NaiveDate) -> i64

Calculates days overdue.

Source

pub fn available_discount(&self, payment_date: NaiveDate) -> Decimal

Gets discount amount if paid by discount date.

Source

pub fn with_po_reference(self, po_number: String) -> Self

Sets purchase order reference.

Source

pub fn with_gr_reference(self, gr_number: String) -> Self

Sets goods receipt reference.

Source

pub fn block_payment(&mut self, reason: PaymentBlockReason)

Sets payment block.

Source

pub fn unblock_payment(&mut self)

Removes payment block.

Source

pub fn is_blocked(&self) -> bool

Checks if payment is blocked.

Source

pub fn set_match_status(&mut self, status: MatchStatus)

Sets three-way match status.

Source

pub fn is_payable(&self) -> bool

Checks if ready for payment.

Source

pub fn with_withholding_tax(self, wht: WithholdingTax) -> Self

Sets withholding tax.

Source

pub fn net_payable(&self) -> Decimal

Gets net payable amount (after withholding).

Source

pub fn reverse(&mut self, reversal_date: NaiveDate, reason: String)

Reverses the invoice.

Trait Implementations§

Source§

impl Clone for APInvoice

Source§

fn clone(&self) -> APInvoice

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 APInvoice

Source§

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

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

impl<'de> Deserialize<'de> for APInvoice

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 APInvoice

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>,