Skip to main content

Invoice

Struct Invoice 

Source
pub struct Invoice {
Show 38 fields pub profile: Profile, pub specification_id: Option<String>, pub kind: DocumentKind, pub number: String, pub currency: String, pub issue_date: Option<Date>, pub type_code: Option<Code>, pub tax_currency: Option<Code>, pub due_date: Option<Date>, pub tax_point_date: Option<Date>, pub tax_point_code: Option<Code>, pub business_process: Option<String>, pub buyer_reference: Option<DocumentReference>, pub project: Option<DocumentReference>, pub contract: Option<DocumentReference>, pub purchase_order: Option<DocumentReference>, pub sales_order: Option<DocumentReference>, pub receiving_advice: Option<DocumentReference>, pub despatch: Option<DocumentReference>, pub tender: Option<DocumentReference>, pub invoiced_object: Option<Identifier>, pub buyer_accounting: Option<String>, pub payment_terms: Option<String>, pub notes: Vec<InvoiceNote>, pub preceding: Vec<PrecedingInvoice>, pub seller: Party, pub buyer: Party, pub payee: Option<Payee>, pub tax_representative: Option<TaxRepresentative>, pub delivery: Option<Delivery>, pub period: Option<Period>, pub payment: Option<PaymentInstructions>, pub document_allowances: Vec<AllowanceCharge>, pub document_charges: Vec<AllowanceCharge>, pub tax_breakdown: Vec<TaxBreakdown>, pub totals: Option<DocumentTotals>, pub supporting_documents: Vec<SupportingDocument>, pub lines: Vec<Line>,
}
Expand description

Semantic invoice. Fields are pub on 2.x so embedders can Invoice::blank then set terms. Do not match on the struct layout — #[non_exhaustive] would be a 3.0 break. A proved document is crate::Validated.

Fields§

§profile: Profile

In-memory rule set used by crate::validate(). Not BT-24; BT-24 is Self::specification_id.

§specification_id: Option<String>

BT-24 specification identifier.

§kind: DocumentKind

Syntax root analogue. Not derived from BT-3.

§number: String

BT-1 invoice number.

§currency: String

BT-5 invoice currency.

§issue_date: Option<Date>

BT-2 issue date.

§type_code: Option<Code>

BT-3 invoice type code.

§tax_currency: Option<Code>

BT-6 VAT accounting currency.

§due_date: Option<Date>

BT-9 payment due date.

§tax_point_date: Option<Date>

BT-7 / BT-8. BR-CO-03 when both the date and the code rules apply.

§tax_point_code: Option<Code>

BT-8 VAT point date code.

§business_process: Option<String>

BT-23 business process type.

§buyer_reference: Option<DocumentReference>

BT-10 buyer reference. Do not overload with BT-13.

§project: Option<DocumentReference>

BT-11 project reference.

§contract: Option<DocumentReference>

BT-12 contract reference.

§purchase_order: Option<DocumentReference>

BT-13 purchase order reference (Peppol R003 with BT-10).

§sales_order: Option<DocumentReference>

BT-14 sales order reference.

§receiving_advice: Option<DocumentReference>

BT-15 receiving advice reference.

§despatch: Option<DocumentReference>

BT-16 despatch advice reference.

§tender: Option<DocumentReference>

BT-17 tender or lot reference.

§invoiced_object: Option<Identifier>

BT-18 invoiced object identifier (not a BG-24 supporting document).

§buyer_accounting: Option<String>

BT-19 buyer accounting reference.

§payment_terms: Option<String>

BT-20 payment terms.

§notes: Vec<InvoiceNote>

BG-1 notes (BT-21/22).

§preceding: Vec<PrecedingInvoice>

BG-3 preceding invoice reference.

§seller: Party

BG-4 seller.

§buyer: Party

BG-7 buyer.

§payee: Option<Payee>

BG-10 payee.

§tax_representative: Option<TaxRepresentative>

BG-11 seller tax representative.

§delivery: Option<Delivery>

BG-13 delivery.

§period: Option<Period>

BG-14 invoicing period.

§payment: Option<PaymentInstructions>

BG-16 payment instructions.

§document_allowances: Vec<AllowanceCharge>

BG-20 document level allowances.

§document_charges: Vec<AllowanceCharge>

BG-21 document level charges.

§tax_breakdown: Vec<TaxBreakdown>

BG-23 VAT/GST/SST breakdown.

§totals: Option<DocumentTotals>

BG-22 document totals.

§supporting_documents: Vec<SupportingDocument>

BG-24 additional supporting documents.

§lines: Vec<Line>

BG-25 invoice lines.

Implementations§

Source§

impl Invoice

Source

pub fn blank( profile: Profile, number: impl Into<String>, currency: impl Into<String>, seller: Party, buyer: Party, ) -> Self

2.x constructor. Stamps BT-24 from Profile::specification_id. Then set pub fields.

Source

pub fn payable(&self) -> Option<Amount>

BT-115 from DocumentTotals. Absent BG-22 or absent PayableAmount is not 0.00 (BR-15).

Source

pub fn tax_total(&self) -> Option<Amount>

BT-110 from DocumentTotals. Absent totals is not 0.00.

Source

pub fn stamp_profile(&mut self, profile: Profile)

BT-24 and BT-23 come from the proved profile, not leftover fields on Invoice.

EN 16931 has no required ProfileID: BT-23 is left as-is (the UBL writer omits it).

Source

pub fn line_net_sum(&self) -> Option<Amount>

Sum of line BT-131. Overflow is None. Not BT-106 unless totals exist.

Source

pub fn to_credit_note( &self, new_number: impl Into<String>, new_issue_date: Date, ) -> Self

Credit note: new number/date, BG-3 to the original, amounts not negated.

Trait Implementations§

Source§

impl Clone for Invoice

Source§

fn clone(&self) -> Invoice

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Invoice

Source§

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

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

impl Eq for Invoice

Source§

impl PartialEq for Invoice

Source§

fn eq(&self, other: &Invoice) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Invoice

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 = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.