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.
-
Nested Class Summary
Nested classes/interfaces inherited from interface net.tangly.core.HasMutableDate
net.tangly.core.HasMutableDate.IntervalFilter<T extends net.tangly.core.HasMutableDate>
-
Field Summary
Modifier and TypeFieldDescriptionThe name is a human-readable identifier of the invoice.Fields inherited from interface net.tangly.core.HasDate
DATE
Fields inherited from interface net.tangly.core.HasId
ID
Fields inherited from interface net.tangly.core.HasMutableName
NAME
Fields inherited from interface net.tangly.core.HasText
TEXT
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
add
(InvoiceLine item) Returns the amount of the invoice without the VAT tax.Returns the amount of the invoice including VAT tax.boolean
check()
void
contractId
(String contractId) currency()
void
date()
void
void
deliveryDate
(LocalDate deliveryDate) dueDate()
void
expenses()
getAt
(int position) boolean
Return true if the invoice has multiple VAT rates different from 0%.id()
void
void
invoicedEntity
(InvoiceLegalEntity invoicedEntity) net.tangly.core.BankConnection
void
invoicingConnection
(net.tangly.core.BankConnection invoicingConnection) void
invoicingEntity
(InvoiceLegalEntity invoicingEntity) items()
Returns all invoice items defined in the invoice.lines()
Returns all positions defined in the invoice either invoice items or subtotals.locale()
void
name()
void
void
paymentConditions
(String paymentConditions) text()
void
toString()
Return the unique VAT rate if defined otherwise empty optional.vat()
Returns the VAT tax amount for the whole invoice.Returns a map of VAT rates and associated VAT amounts for the whole invoice.
-
Field Details
-
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
- Specified by:
id
in interfacenet.tangly.core.HasId
-
id
- Specified by:
id
in interfacenet.tangly.core.HasMutableId
-
name
- Specified by:
name
in interfacenet.tangly.core.HasName
-
name
- Specified by:
name
in interfacenet.tangly.core.HasMutableName
-
text
- Specified by:
text
in interfacenet.tangly.core.HasText
-
text
- Specified by:
text
in interfacenet.tangly.core.HasMutableText
-
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
-
amountWithVat
Returns the amount of the invoice including VAT tax.- Returns:
- invoice amount with VAT tax
-
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
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
-
invoicingEntity
-
invoicingEntity
-
invoicedEntity
-
invoicedEntity
-
invoicingConnection
public net.tangly.core.BankConnection invoicingConnection() -
invoicingConnection
public void invoicingConnection(net.tangly.core.BankConnection invoicingConnection) -
contractId
-
contractId
-
deliveryDate
-
deliveryDate
-
date
- Specified by:
date
in interfacenet.tangly.core.HasDate
-
date
- Specified by:
date
in interfacenet.tangly.core.HasMutableDate
-
dueDate
-
dueDate
-
currency
-
currency
-
locale
-
locale
-
paymentConditions
-
paymentConditions
-
add
-
lines
Returns all positions defined in the invoice either invoice items or subtotals.- Returns:
- list of invoice lines
-
items
Returns all invoice items defined in the invoice.- Returns:
- list of invoice items
-
getAt
-
check
public boolean check() -
toString
-