pub struct Invoice { /* private fields */ }Expand description
A general invoice with same-currency line totals.
Implementations§
Source§impl Invoice
impl Invoice
Sourcepub fn from_lines(
number: InvoiceNumber,
lines: Vec<InvoiceLine>,
) -> Result<Self, InvoiceError>
pub fn from_lines( number: InvoiceNumber, lines: Vec<InvoiceLine>, ) -> Result<Self, InvoiceError>
Creates an open invoice from same-currency lines.
§Errors
Returns InvoiceError::NoLines when no lines are supplied and InvoiceError::Money
when line totals cannot be added.
Sourcepub fn new(
number: InvoiceNumber,
status: InvoiceStatus,
due_date: Option<DueDate>,
lines: Vec<InvoiceLine>,
) -> Result<Self, InvoiceError>
pub fn new( number: InvoiceNumber, status: InvoiceStatus, due_date: Option<DueDate>, lines: Vec<InvoiceLine>, ) -> Result<Self, InvoiceError>
Creates an invoice from same-currency lines.
§Errors
Returns InvoiceError::NoLines when no lines are supplied and InvoiceError::Money
when line totals cannot be added.
Sourcepub fn with_due_date(self, due_date: DueDate) -> Self
pub fn with_due_date(self, due_date: DueDate) -> Self
Returns a copy of this invoice with a due date.
Sourcepub fn with_amount_paid(self, amount_paid: &Money) -> Result<Self, InvoiceError>
pub fn with_amount_paid(self, amount_paid: &Money) -> Result<Self, InvoiceError>
Returns a copy of this invoice with an amount paid applied to the balance due.
§Errors
Returns InvoiceError::Money when the payment currency or amount scale is incompatible.
Sourcepub const fn number(&self) -> &InvoiceNumber
pub const fn number(&self) -> &InvoiceNumber
Returns the invoice number.
Sourcepub const fn status(&self) -> InvoiceStatus
pub const fn status(&self) -> InvoiceStatus
Returns the invoice status.
Sourcepub fn lines(&self) -> &[InvoiceLine]
pub fn lines(&self) -> &[InvoiceLine]
Returns the invoice lines.
Sourcepub fn iter(&self) -> Iter<'_, InvoiceLine>
pub fn iter(&self) -> Iter<'_, InvoiceLine>
Iterates over invoice lines.
Sourcepub const fn balance_due(&self) -> &BalanceDue
pub const fn balance_due(&self) -> &BalanceDue
Returns the balance due.
Trait Implementations§
impl Eq for Invoice
Source§impl<'a> IntoIterator for &'a Invoice
impl<'a> IntoIterator for &'a Invoice
impl StructuralPartialEq for Invoice
Auto Trait Implementations§
impl Freeze for Invoice
impl RefUnwindSafe for Invoice
impl Send for Invoice
impl Sync for Invoice
impl Unpin for Invoice
impl UnsafeUnpin for Invoice
impl UnwindSafe for Invoice
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more