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: DocumentHeaderDocument header
invoice_type: CustomerInvoiceTypeInvoice type
items: Vec<CustomerInvoiceItem>Line items
customer_id: StringCustomer ID
bill_to: Option<String>Bill-to party (if different)
payer: Option<String>Payer (if different)
sales_org: StringSales organization
distribution_channel: StringDistribution channel
division: StringDivision
total_net_amount: DecimalTotal net amount
total_tax_amount: DecimalTotal tax amount
total_gross_amount: DecimalTotal gross amount
total_discount: DecimalTotal discount amount
total_cogs: DecimalTotal COGS
payment_terms: StringPayment terms
due_date: NaiveDateDue 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: DecimalAmount paid
amount_open: DecimalAmount open (remaining)
payment_status: InvoicePaymentStatusPayment 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: boolIs invoice posted?
is_output_complete: boolIs invoice printed/sent?
is_intercompany: boolIs this an intercompany invoice?
ic_partner: Option<String>Intercompany partner (company code)
dispute_reason: Option<String>Dispute reason (if in dispute)
write_off_amount: DecimalWrite-off amount
write_off_reason: Option<String>Write-off reason
dunning_level: u8Dunning level (0 = not dunned)
last_dunning_date: Option<NaiveDate>Last dunning date
is_cancelled: boolIs invoice cancelled/reversed?
cancellation_invoice: Option<String>Cancellation invoice reference
Implementations§
Source§impl CustomerInvoice
impl CustomerInvoice
Sourcepub 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
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.
Sourcepub 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
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.
Sourcepub 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
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.
Sourcepub fn with_invoice_type(self, invoice_type: CustomerInvoiceType) -> Self
pub fn with_invoice_type(self, invoice_type: CustomerInvoiceType) -> Self
Set invoice type.
Sourcepub fn with_sales_org(
self,
sales_org: impl Into<String>,
dist_channel: impl Into<String>,
division: impl Into<String>,
) -> Self
pub fn with_sales_org( self, sales_org: impl Into<String>, dist_channel: impl Into<String>, division: impl Into<String>, ) -> Self
Set sales organization.
Sourcepub fn with_partners(
self,
bill_to: impl Into<String>,
payer: impl Into<String>,
) -> Self
pub fn with_partners( self, bill_to: impl Into<String>, payer: impl Into<String>, ) -> Self
Set partner functions.
Sourcepub fn with_payment_terms(
self,
terms: impl Into<String>,
discount_days_1: Option<u16>,
discount_percent_1: Option<Decimal>,
) -> Self
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.
Sourcepub fn with_customer_po(self, po_number: impl Into<String>) -> Self
pub fn with_customer_po(self, po_number: impl Into<String>) -> Self
Set customer PO reference.
Sourcepub fn as_intercompany(self, partner_company: impl Into<String>) -> Self
pub fn as_intercompany(self, partner_company: impl Into<String>) -> Self
Set as intercompany.
Sourcepub fn add_item(&mut self, item: CustomerInvoiceItem)
pub fn add_item(&mut self, item: CustomerInvoiceItem)
Add a line item.
Sourcepub fn recalculate_totals(&mut self)
pub fn recalculate_totals(&mut self)
Recalculate totals.
Sourcepub fn record_payment(&mut self, amount: Decimal, discount_taken: Decimal)
pub fn record_payment(&mut self, amount: Decimal, discount_taken: Decimal)
Record a payment.
Sourcepub fn resolve_dispute(&mut self)
pub fn resolve_dispute(&mut self)
Resolve dispute.
Sourcepub fn write_off(&mut self, amount: Decimal, reason: impl Into<String>)
pub fn write_off(&mut self, amount: Decimal, reason: impl Into<String>)
Write off remaining amount.
Sourcepub fn record_dunning(&mut self, dunning_date: NaiveDate)
pub fn record_dunning(&mut self, dunning_date: NaiveDate)
Record dunning.
Sourcepub fn cancel(
&mut self,
user: impl Into<String>,
cancellation_invoice: impl Into<String>,
)
pub fn cancel( &mut self, user: impl Into<String>, cancellation_invoice: impl Into<String>, )
Cancel the invoice.
Sourcepub fn is_overdue(&self, as_of_date: NaiveDate) -> bool
pub fn is_overdue(&self, as_of_date: NaiveDate) -> bool
Check if invoice is overdue.
Sourcepub fn days_past_due(&self, as_of_date: NaiveDate) -> i64
pub fn days_past_due(&self, as_of_date: NaiveDate) -> i64
Days past due.
Sourcepub fn aging_bucket(&self, as_of_date: NaiveDate) -> AgingBucket
pub fn aging_bucket(&self, as_of_date: NaiveDate) -> AgingBucket
Get aging bucket.
Sourcepub fn cash_discount_available(&self, as_of_date: NaiveDate) -> Decimal
pub fn cash_discount_available(&self, as_of_date: NaiveDate) -> Decimal
Cash discount available.
Sourcepub fn gross_margin(&self) -> Decimal
pub fn gross_margin(&self) -> Decimal
Calculate gross margin.
Trait Implementations§
Source§impl Clone for CustomerInvoice
impl Clone for CustomerInvoice
Source§fn clone(&self) -> CustomerInvoice
fn clone(&self) -> CustomerInvoice
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more