Skip to main content

CustomerInvoice

Struct CustomerInvoice 

Source
pub struct CustomerInvoice {
Show 38 fields pub header: DocumentHeader, pub invoice_type: CustomerInvoiceType, pub items: Vec<CustomerInvoiceItem>, pub customer_id: String, pub bill_to: Option<String>, pub payer: Option<String>, pub sales_org: String, pub distribution_channel: String, pub division: String, pub total_net_amount: Decimal, pub total_tax_amount: Decimal, pub total_gross_amount: Decimal, pub total_discount: Decimal, pub total_cogs: Decimal, pub payment_terms: String, pub due_date: NaiveDate, pub discount_date_1: Option<NaiveDate>, pub discount_percent_1: Option<Decimal>, pub discount_date_2: Option<NaiveDate>, pub discount_percent_2: Option<Decimal>, pub amount_paid: Decimal, pub amount_open: Decimal, pub payment_status: InvoicePaymentStatus, pub sales_order_id: Option<String>, pub delivery_id: Option<String>, pub external_reference: Option<String>, pub customer_po_number: Option<String>, pub is_posted: bool, pub is_output_complete: bool, pub is_intercompany: bool, pub ic_partner: Option<String>, pub dispute_reason: Option<String>, pub write_off_amount: Decimal, pub write_off_reason: Option<String>, pub dunning_level: u8, pub last_dunning_date: Option<NaiveDate>, pub is_cancelled: bool, pub cancellation_invoice: Option<String>,
}
Expand description

Customer Invoice document.

Fields§

§header: DocumentHeader

Document header

§invoice_type: CustomerInvoiceType

Invoice type

§items: Vec<CustomerInvoiceItem>

Line items

§customer_id: String

Customer ID

§bill_to: Option<String>

Bill-to party (if different)

§payer: Option<String>

Payer (if different)

§sales_org: String

Sales organization

§distribution_channel: String

Distribution channel

§division: String

Division

§total_net_amount: Decimal

Total net amount

§total_tax_amount: Decimal

Total tax amount

§total_gross_amount: Decimal

Total gross amount

§total_discount: Decimal

Total discount amount

§total_cogs: Decimal

Total COGS

§payment_terms: String

Payment terms

§due_date: NaiveDate

Due date

§discount_date_1: Option<NaiveDate>

Cash discount date 1

§discount_percent_1: Option<Decimal>

Cash discount percent 1

§discount_date_2: Option<NaiveDate>

Cash discount date 2

§discount_percent_2: Option<Decimal>

Cash discount percent 2

§amount_paid: Decimal

Amount paid

§amount_open: Decimal

Amount open (remaining)

§payment_status: InvoicePaymentStatus

Payment status

§sales_order_id: Option<String>

Reference sales order (primary)

§delivery_id: Option<String>

Reference delivery (primary)

§external_reference: Option<String>

External invoice number (for customer)

§customer_po_number: Option<String>

Customer PO number

§is_posted: bool

Is invoice posted?

§is_output_complete: bool

Is invoice printed/sent?

§is_intercompany: bool

Is this an intercompany invoice?

§ic_partner: Option<String>

Intercompany partner (company code)

§dispute_reason: Option<String>

Dispute reason (if in dispute)

§write_off_amount: Decimal

Write-off amount

§write_off_reason: Option<String>

Write-off reason

§dunning_level: u8

Dunning level (0 = not dunned)

§last_dunning_date: Option<NaiveDate>

Last dunning date

§is_cancelled: bool

Is invoice cancelled/reversed?

§cancellation_invoice: Option<String>

Cancellation invoice reference

Implementations§

Source§

impl CustomerInvoice

Source

pub fn new( invoice_id: impl Into<String>, company_code: impl Into<String>, customer_id: impl Into<String>, fiscal_year: u16, fiscal_period: u8, document_date: NaiveDate, due_date: NaiveDate, created_by: impl Into<String>, ) -> Self

Create a new customer invoice.

Source

pub fn from_delivery( invoice_id: impl Into<String>, company_code: impl Into<String>, delivery_id: impl Into<String>, customer_id: impl Into<String>, fiscal_year: u16, fiscal_period: u8, document_date: NaiveDate, due_date: NaiveDate, created_by: impl Into<String>, ) -> Self

Create from delivery reference.

Source

pub fn credit_memo( invoice_id: impl Into<String>, company_code: impl Into<String>, customer_id: impl Into<String>, fiscal_year: u16, fiscal_period: u8, document_date: NaiveDate, created_by: impl Into<String>, ) -> Self

Create a credit memo.

Source

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

Set invoice type.

Source

pub fn with_sales_org( self, sales_org: impl Into<String>, dist_channel: impl Into<String>, division: impl Into<String>, ) -> Self

Set sales organization.

Source

pub fn with_partners( self, bill_to: impl Into<String>, payer: impl Into<String>, ) -> Self

Set partner functions.

Source

pub fn with_payment_terms( self, terms: impl Into<String>, discount_days_1: Option<u16>, discount_percent_1: Option<Decimal>, ) -> Self

Set payment terms with cash discount.

Source

pub fn with_customer_po(self, po_number: impl Into<String>) -> Self

Set customer PO reference.

Source

pub fn as_intercompany(self, partner_company: impl Into<String>) -> Self

Set as intercompany.

Source

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

Add a line item.

Source

pub fn recalculate_totals(&mut self)

Recalculate totals.

Source

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

Post the invoice.

Source

pub fn record_payment(&mut self, amount: Decimal, discount_taken: Decimal)

Record a payment.

Source

pub fn clear(&mut self)

Clear the invoice.

Source

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

Put invoice in dispute.

Source

pub fn resolve_dispute(&mut self)

Resolve dispute.

Source

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

Write off remaining amount.

Source

pub fn record_dunning(&mut self, dunning_date: NaiveDate)

Record dunning.

Source

pub fn cancel( &mut self, user: impl Into<String>, cancellation_invoice: impl Into<String>, )

Cancel the invoice.

Source

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

Check if invoice is overdue.

Source

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

Days past due.

Source

pub fn aging_bucket(&self, as_of_date: NaiveDate) -> AgingBucket

Get aging bucket.

Source

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

Cash discount available.

Source

pub fn gross_margin(&self) -> Decimal

Calculate gross margin.

Source

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

Generate GL entries. DR Accounts Receivable, CR Revenue, CR Tax Payable

Trait Implementations§

Source§

impl Clone for CustomerInvoice

Source§

fn clone(&self) -> CustomerInvoice

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 CustomerInvoice

Source§

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

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

impl<'de> Deserialize<'de> for CustomerInvoice

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 CustomerInvoice

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