Class TaxValue

    • Constructor Summary

      Constructors 
      Constructor Description
      TaxValue​(java.lang.String code, double value, boolean absolute, double appliedValue, java.lang.String currencyIsoCode)  
      TaxValue​(java.lang.String code, double value, boolean absolute, java.lang.String currencyIsoCode)
      constructs a new TaxValue object.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      TaxValue apply​(double quantity, double price, int digits, boolean priceIsNet, java.lang.String currencyIsoCode)
      creates a copy of this tax value holding the applied value for a given price rounded to given digits.
      static java.util.Collection apply​(double quantity, double price, int digits, java.util.Collection taxValues, boolean priceIsNet, java.lang.String currencyIso)
      creates a collection of applied tax values for a given price and a tax value collection.
      java.lang.Object clone()
      Returns an exact copy of the TaxValue (@see java.lang.Object#clone()).
      boolean equals​(java.lang.Object object)  
      double getAppliedValue()
      Returns the applied value of the TaxValue.
      java.lang.String getCode()
      Returns the code of the TaxValue.
      java.lang.String getCurrencyIsoCode()
      Returns the currency iso code of this absolute TaxValue or null if the tax value is relative.
      double getValue()
      Returns the value of the TaxValue.
      int hashCode()  
      boolean isAbsolute()
      Returns true if this TaxValue is absolute.
      static TaxValue parseTaxValue​(java.lang.String str)
      creates a tax value object from its string representation created via @see #toString().
      static java.util.Collection parseTaxValueCollection​(java.lang.String str)
      creates a tax value collection from its string representation created via @see #toString(Collection).
      static double sumAbsoluteTaxValues​(java.util.Collection taxValues)  
      static double sumAppliedTaxValues​(java.util.Collection taxValues)  
      static double sumRelativeTaxValues​(java.util.Collection taxValues)  
      java.lang.String toString()
      Returns a string representation of this tax value.
      static java.lang.String toString​(java.util.Collection taxValueCollection)
      creates the string representation of a collection of tax values.
      TaxValue unapply()  
      • Methods inherited from class java.lang.Object

        finalize, getClass, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • TaxValue

        public TaxValue​(java.lang.String code,
                        double value,
                        boolean absolute,
                        java.lang.String currencyIsoCode)
        constructs a new TaxValue object.

        Parameters:
        code -
        value -
        absolute -
        currencyIsoCode -
      • TaxValue

        public TaxValue​(java.lang.String code,
                        double value,
                        boolean absolute,
                        double appliedValue,
                        java.lang.String currencyIsoCode)
    • Method Detail

      • getCode

        public java.lang.String getCode()
        Returns the code of the TaxValue.
        Returns:
        the code of the TaxValue.
      • getCurrencyIsoCode

        public java.lang.String getCurrencyIsoCode()
        Returns the currency iso code of this absolute TaxValue or null if the tax value is relative.
      • getValue

        public double getValue()
        Returns the value of the TaxValue.
        Specified by:
        getValue in interface PDTValue
        Returns:
        the value of the TaxValue.
      • getAppliedValue

        public double getAppliedValue()
        Returns the applied value of the TaxValue.
        Returns:
        the applied value of the TaxValue.
      • isAbsolute

        public boolean isAbsolute()
        Returns true if this TaxValue is absolute.
        Returns:
        true if the TaxValue is absolute.
      • clone

        public java.lang.Object clone()
        Returns an exact copy of the TaxValue (@see java.lang.Object#clone()).
        Overrides:
        clone in class java.lang.Object
        Returns:
        an exact copy of the TaxValue:
      • apply

        public TaxValue apply​(double quantity,
                              double price,
                              int digits,
                              boolean priceIsNet,
                              java.lang.String currencyIsoCode)
        creates a copy of this tax value holding the applied value for a given price rounded to given digits.
        Parameters:
        price - the price to apply this tax value to
        digits - the digits to round the value to, if < 0 no rounding is done
        priceIsNet - true if the given price is net.
        Returns:
        returns a copy of this TaxValue holding the applied value for a given price rounded to given digits.
        Since:
        2.20
      • apply

        public static java.util.Collection apply​(double quantity,
                                                 double price,
                                                 int digits,
                                                 java.util.Collection taxValues,
                                                 boolean priceIsNet,
                                                 java.lang.String currencyIso)
        creates a collection of applied tax values for a given price and a tax value collection. all resulting applied values prices are rounded to the given number of digits.
        Parameters:
        price - the price to apply these taxes to
        digits - the number of digits to round, if < 0 no rounding is done
        taxValues - the collection of taxes to apply to the price
        priceIsNet - true if given price is net, false if given price is gross
        Returns:
        the collection of applied tax values for the given parameters.
        Since:
        2.20
      • sumRelativeTaxValues

        public static double sumRelativeTaxValues​(java.util.Collection taxValues)
      • sumAbsoluteTaxValues

        public static double sumAbsoluteTaxValues​(java.util.Collection taxValues)
      • sumAppliedTaxValues

        public static double sumAppliedTaxValues​(java.util.Collection taxValues)
      • toString

        public java.lang.String toString()
        Returns a string representation of this tax value. You may restore this object via @see #parseTaxValue(String).
        Overrides:
        toString in class java.lang.Object
        Returns:
        string representation of this tax value.
      • toString

        public static java.lang.String toString​(java.util.Collection taxValueCollection)
        creates the string representation of a collection of tax values. You may restore this collection via @see #parseTaxValueCollection(String).
        Parameters:
        taxValueCollection - a collection containing StandardTaxValues
        Returns:
        string representation of a collection of tax values.
      • parseTaxValueCollection

        public static java.util.Collection parseTaxValueCollection​(java.lang.String str)
                                                            throws java.lang.IllegalArgumentException
        creates a tax value collection from its string representation created via @see #toString(Collection).
        Parameters:
        str - string representation of a TaxValue.
        Returns:
        a tax value collection from its string representation.
        Throws:
        java.lang.IllegalArgumentException - if a parse error occurred
      • parseTaxValue

        public static TaxValue parseTaxValue​(java.lang.String str)
                                      throws java.lang.IllegalArgumentException
        creates a tax value object from its string representation created via @see #toString().
        Parameters:
        str - string representation of a TaxValue.
        Returns:
        a tax value object from its string representation.
        Throws:
        java.lang.IllegalArgumentException - if the string is not valid
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • equals

        public boolean equals​(java.lang.Object object)
        Overrides:
        equals in class java.lang.Object
      • unapply

        public TaxValue unapply()
        Returns:
        an exact copy of this tax value except its applied value.