Class Invoice

java.lang.Object
net.tangly.erp.invoices.domain.Invoice
All Implemented Interfaces:
net.tangly.core.HasDate, net.tangly.core.HasId, net.tangly.core.HasMutableDate, net.tangly.core.HasMutableId, net.tangly.core.HasMutableName, net.tangly.core.HasMutableText, net.tangly.core.HasName, net.tangly.core.HasText

public class Invoice extends Object implements net.tangly.core.HasMutableId, net.tangly.core.HasMutableName, net.tangly.core.HasMutableDate, net.tangly.core.HasMutableText

The abstraction of an invoice with a set of positions, subtotals, and a total. The items and the subtotals have a position to order them in the invoice to provide human readable outputs. An invoice and its components have no dependencies to external entities. Therefore, an invoice is complete and can be archived. For example, you can change the VAT percentage or a product price without any consequence on existing invoices.

The invoice assumes that a VAT rate applies to a given invoice item. The rate is dependent on the service sold and the customer. For example educational services are VAT free in Switzerland.

Each item line has an associated article and a VAT rate. A subtotal does not have an article or a VAT rate. This assumption is reasonable for quite a lot of businesses, in particular in the service industry.

Often an invoice references only one VAT rate, convenience methods are provided to streamline this scenario.

  • Field Details

    • name

      public String name
      The name is a human-readable identifier of the invoice. The name is also used as a file name if the invoice is stored in a JSON file or an artifact is generated. Humans can associate the invoice with the various artifacts generated out of it.
  • Constructor Details

    • Invoice

      public Invoice()
  • Method Details

    • id

      public String id()
      Specified by:
      id in interface net.tangly.core.HasId
    • id

      public void id(String id)
      Specified by:
      id in interface net.tangly.core.HasMutableId
    • name

      public String name()
      Specified by:
      name in interface net.tangly.core.HasName
    • name

      public void name(String name)
      Specified by:
      name in interface net.tangly.core.HasMutableName
    • text

      public String text()
      Specified by:
      text in interface net.tangly.core.HasText
    • text

      public void text(String text)
      Specified by:
      text in interface net.tangly.core.HasMutableText
    • amountWithoutVat

      public BigDecimal amountWithoutVat()
      Returns the amount of the invoice without the VAT tax. The amount is the sum of all invoice items. Subtotals are not considered in the amount.
      Returns:
      invoice amount without VAT tax
    • vat

      public BigDecimal vat()
      Returns the VAT tax amount for the whole invoice.
      Returns:
      invoice VAT tax
    • amountWithVat

      public BigDecimal amountWithVat()
      Returns the amount of the invoice including VAT tax.
      Returns:
      invoice amount with VAT tax
    • vatAmounts

      public Map<BigDecimal,BigDecimal> vatAmounts()
      Returns a map of VAT rates and associated VAT amounts for the whole invoice. An invoice line has a VAT rate and a computed VAT amount. A subtotal does not have a VAT rate but has an aggregated VAT amount
      Returns:
      map of entries VAT rate and associated VAT amounts
    • hasMultipleVatRates

      public boolean hasMultipleVatRates()
      Return true if the invoice has multiple VAT rates different from 0%.
      Returns:
      flag if the invoice has multiple VAT rates
    • uniqueVatRate

      public Optional<BigDecimal> uniqueVatRate()
      Return the unique VAT rate if defined otherwise empty optional. It is a convenience method to support service companies having exactly one VAT rate for all their products.
      Returns:
      unique VAT rate if defined
    • expenses

      public BigDecimal expenses()
    • invoicingEntity

      public InvoiceLegalEntity invoicingEntity()
    • invoicingEntity

      public void invoicingEntity(InvoiceLegalEntity invoicingEntity)
    • invoicedEntity

      public InvoiceLegalEntity invoicedEntity()
    • invoicedEntity

      public void invoicedEntity(InvoiceLegalEntity invoicedEntity)
    • invoicingConnection

      public net.tangly.core.BankConnection invoicingConnection()
    • invoicingConnection

      public void invoicingConnection(net.tangly.core.BankConnection invoicingConnection)
    • contractId

      public String contractId()
    • contractId

      public void contractId(String contractId)
    • deliveryDate

      public LocalDate deliveryDate()
    • deliveryDate

      public void deliveryDate(LocalDate deliveryDate)
    • date

      public LocalDate date()
      Specified by:
      date in interface net.tangly.core.HasDate
    • date

      public void date(LocalDate invoicedDate)
      Specified by:
      date in interface net.tangly.core.HasMutableDate
    • dueDate

      public LocalDate dueDate()
    • dueDate

      public void dueDate(LocalDate dueDate)
    • currency

      public Currency currency()
    • currency

      public void currency(Currency currency)
    • locale

      public Locale locale()
    • locale

      public void locale(Locale locale)
    • paymentConditions

      public String paymentConditions()
    • paymentConditions

      public void paymentConditions(String paymentConditions)
    • add

      public void add(InvoiceLine item)
    • lines

      public List<InvoiceLine> lines()
      Returns all positions defined in the invoice either invoice items or subtotals.
      Returns:
      list of invoice lines
    • items

      public List<InvoiceItem> items()
      Returns all invoice items defined in the invoice.
      Returns:
      list of invoice items
    • getAt

      public InvoiceLine getAt(int position)
    • check

      public boolean check()
    • toString

      public String toString()
      Overrides:
      toString in class Object