Record Class Subtotal

java.lang.Object
java.lang.Record
net.tangly.erp.invoices.domain.Subtotal
All Implemented Interfaces:
net.tangly.core.HasText, InvoiceLine

public record Subtotal(int position, String text, @NotNull List<InvoiceLine> items) extends Record implements InvoiceLine
The subtotal defines the sum for a set of positions in the invoice. A subtotal groups a set of related positions, such as belonging to the same accounting position or project booking, or to the same amount of VAT percentage for mixed VAT invoices.
  • Field Summary

    Fields inherited from interface net.tangly.core.HasText

    TEXT
  • Constructor Summary

    Constructors
    Constructor
    Description
    Subtotal(int position, String text, @NotNull List<InvoiceLine> items)
    Creates an instance of a Subtotal record class.
  • Method Summary

    Modifier and Type
    Method
    Description
    Return the amount associated with the line.
    final boolean
    Indicates whether some other object is "equal to" this one.
    final int
    Returns a hash code value for this object.
    boolean
    Return true if the line contains items.
    @NotNull List<InvoiceLine>
    Returns the value of the items record component.
    int
    Returns the value of the position record component.
    Return the list of positions part of the subtotal aggregate.
    Return the quantity of items associated with an invoice line.
    Returns the value of the text record component.
    final String
    Returns a string representation of this record class.
    Return the unit price of items associated with an invoice line.
    vat()
    Return the VAT amount associated with the line.
    Return the VAT rate associated with the line.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait

    Methods inherited from interface net.tangly.erp.invoices.domain.InvoiceLine

    isAggregate
  • Constructor Details

    • Subtotal

      public Subtotal(int position, String text, @NotNull @NotNull List<InvoiceLine> items)
      Creates an instance of a Subtotal record class.
      Parameters:
      position - the value for the position record component
      text - the value for the text record component
      items - the value for the items record component
  • Method Details

    • amount

      public BigDecimal amount()
      Description copied from interface: InvoiceLine
      Return the amount associated with the line.
      Specified by:
      amount in interface InvoiceLine
      Returns:
      the amount of the line
    • vat

      public BigDecimal vat()
      Description copied from interface: InvoiceLine
      Return the VAT amount associated with the line.
      Specified by:
      vat in interface InvoiceLine
      Returns:
      the VAT amount of the line
    • quantity

      public BigDecimal quantity()
      Description copied from interface: InvoiceLine
      Return the quantity of items associated with an invoice line.
      Specified by:
      quantity in interface InvoiceLine
      Returns:
      the quantity of items if defined otherwise zero
    • unitPrice

      public BigDecimal unitPrice()
      Description copied from interface: InvoiceLine
      Return the unit price of items associated with an invoice line.
      Specified by:
      unitPrice in interface InvoiceLine
      Returns:
      the unit price of the items for the line
    • vatRate

      public BigDecimal vatRate()
      Description copied from interface: InvoiceLine
      Return the VAT rate associated with the line.
      Specified by:
      vatRate in interface InvoiceLine
      Returns:
      the VAT rate of the line
    • isItem

      public boolean isItem()
      Description copied from interface: InvoiceLine
      Return true if the line contains items.
      Specified by:
      isItem in interface InvoiceLine
      Returns:
      flag indicating the line contains items
    • positions

      public List<InvoiceLine> positions()
      Return the list of positions part of the subtotal aggregate.
      Returns:
      positions associated with the subtotal
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with the compare method from their corresponding wrapper classes.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • position

      public int position()
      Returns the value of the position record component.
      Specified by:
      position in interface InvoiceLine
      Returns:
      the value of the position record component
    • text

      public String text()
      Returns the value of the text record component.
      Specified by:
      text in interface net.tangly.core.HasText
      Specified by:
      text in interface InvoiceLine
      Returns:
      the value of the text record component
    • items

      @NotNull public @NotNull List<InvoiceLine> items()
      Returns the value of the items record component.
      Returns:
      the value of the items record component