Skip to main content

VendorInvoice

Struct VendorInvoice 

Source
pub struct VendorInvoice {
Show 26 fields pub header: DocumentHeader, pub invoice_type: VendorInvoiceType, pub vendor_id: String, pub vendor_invoice_number: String, pub invoice_date: NaiveDate, pub items: Vec<VendorInvoiceItem>, pub net_amount: Decimal, pub tax_amount: Decimal, pub gross_amount: Decimal, pub withholding_tax_amount: Decimal, pub payable_amount: Decimal, pub payment_terms: String, pub due_date: NaiveDate, pub discount_due_date: Option<NaiveDate>, pub cash_discount_percent: Decimal, pub cash_discount_amount: Decimal, pub verification_status: InvoiceVerificationStatus, pub payment_block: bool, pub payment_block_reason: Option<String>, pub purchase_order_id: Option<String>, pub goods_receipt_id: Option<String>, pub is_paid: bool, pub amount_paid: Decimal, pub balance: Decimal, pub payment_references: Vec<String>, pub baseline_date: NaiveDate,
}
Expand description

Vendor Invoice document.

Fields§

§header: DocumentHeader

Document header

§invoice_type: VendorInvoiceType

Invoice type

§vendor_id: String

Vendor ID

§vendor_invoice_number: String

Vendor invoice number (external reference)

§invoice_date: NaiveDate

Invoice date from vendor

§items: Vec<VendorInvoiceItem>

Line items

§net_amount: Decimal

Net amount

§tax_amount: Decimal

Tax amount

§gross_amount: Decimal

Gross amount

§withholding_tax_amount: Decimal

Withholding tax amount

§payable_amount: Decimal

Amount to pay (gross - withholding)

§payment_terms: String

Payment terms

§due_date: NaiveDate

Due date for payment

§discount_due_date: Option<NaiveDate>

Discount due date (for early payment)

§cash_discount_percent: Decimal

Cash discount percentage

§cash_discount_amount: Decimal

Cash discount amount

§verification_status: InvoiceVerificationStatus

Verification status

§payment_block: bool

Is blocked for payment?

§payment_block_reason: Option<String>

Payment block reason

§purchase_order_id: Option<String>

Reference PO (primary)

§goods_receipt_id: Option<String>

Reference GR (primary)

§is_paid: bool

Is this invoice paid?

§amount_paid: Decimal

Amount paid

§balance: Decimal

Remaining balance

§payment_references: Vec<String>

Payment document references

§baseline_date: NaiveDate

Baseline date for payment

Implementations§

Source§

impl VendorInvoice

Source

pub fn new( invoice_id: impl Into<String>, company_code: impl Into<String>, vendor_id: impl Into<String>, vendor_invoice_number: impl Into<String>, fiscal_year: u16, fiscal_period: u8, invoice_date: NaiveDate, created_by: impl Into<String>, ) -> Self

Create a new vendor invoice.

Source

pub fn from_po_gr( invoice_id: impl Into<String>, company_code: impl Into<String>, vendor_id: impl Into<String>, vendor_invoice_number: impl Into<String>, po_id: impl Into<String>, gr_id: impl Into<String>, fiscal_year: u16, fiscal_period: u8, invoice_date: NaiveDate, created_by: impl Into<String>, ) -> Self

Create invoice referencing PO and GR.

Source

pub fn with_invoice_type(self, invoice_type: VendorInvoiceType) -> Self

Set invoice type.

Source

pub fn with_payment_terms(self, terms: impl Into<String>, due_days: i64) -> Self

Set payment terms.

Source

pub fn with_cash_discount(self, percent: Decimal, discount_days: i64) -> Self

Set cash discount.

Source

pub fn block_payment(&mut self, reason: impl Into<String>)

Block payment.

Source

pub fn unblock_payment(&mut self)

Unblock payment.

Source

pub fn add_item(&mut self, item: VendorInvoiceItem)

Add a line item.

Source

pub fn recalculate_totals(&mut self)

Recalculate totals.

Source

pub fn record_payment( &mut self, amount: Decimal, payment_doc_id: impl Into<String>, )

Record payment.

Source

pub fn post(&mut self, user: impl Into<String>, posting_date: NaiveDate)

Post the invoice.

Source

pub fn verify(&mut self, passed: bool)

Verify the invoice (three-way match).

Source

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

Check if discount is still available.

Source

pub fn discounted_amount(&self, as_of_date: NaiveDate) -> Decimal

Get amount with discount.

Source

pub fn generate_gl_entries( &self, ) -> Vec<(String, Decimal, Decimal, Option<String>)>

Generate GL entries for invoice posting. DR Expense/GR-IR Clearing CR AP (Vendor)

Trait Implementations§

Source§

impl Clone for VendorInvoice

Source§

fn clone(&self) -> VendorInvoice

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 VendorInvoice

Source§

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

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

impl<'de> Deserialize<'de> for VendorInvoice

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 VendorInvoice

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