Class DefaultOndemandTaxCalculationService

  • All Implemented Interfaces:
    OndemandTaxCalculationService

    public class DefaultOndemandTaxCalculationService
    extends java.lang.Object
    implements OndemandTaxCalculationService
    Implementation of OndemandTaxCalculationService to return the exact tax values for each unit of a line entry. It is important to note that the tax values may not be perfectly divisible by the quantity which would result in a loss of cents. The rounding scale is set to two as this is what the third parties will accept.
    • Constructor Detail

      • DefaultOndemandTaxCalculationService

        public DefaultOndemandTaxCalculationService()
    • Method Detail

      • calculatePreciseUnitTax

        public java.math.BigDecimal calculatePreciseUnitTax​(java.util.Collection<TaxValue> taxValues,
                                                            double quantity,
                                                            boolean isNet)
        Calculate the unit tax to send with a precision of 2.
        Specified by:
        calculatePreciseUnitTax in interface OndemandTaxCalculationService
        Parameters:
        taxValues - - taxValues associated with the order or order entry
        quantity - - quantity to determine the unit tax value
        isNet - - boolean to determine which tax values need to be summed
        Returns:
        - value of unit tax of an item
      • calculateShippingTax

        public java.math.BigDecimal calculateShippingTax​(AbstractOrderModel abstractOrder)
        Calculates the shipping tax. If the order is net returns the total of the taxValues stored on the order, otherwise returns the tax amount of total taxes
        Specified by:
        calculateShippingTax in interface OndemandTaxCalculationService
        Parameters:
        abstractOrder - - the order for which to calculate the shipping costs
      • calculateShippingCost

        public java.lang.Double calculateShippingCost​(AbstractOrderModel abstractOrder)
        If the order is net the shipping cost is the delivery cost of the order otherwise the shipping cost is the delivery cost of the order minus the difference of the order's total tax and all entry's tax.
        Specified by:
        calculateShippingCost in interface OndemandTaxCalculationService
      • getGrossCalculatedTotalTax

        protected java.math.BigDecimal getGrossCalculatedTotalTax​(AbstractOrderModel abstractOrder)
        Method to calculate the total tax of the gross order entries' taxes that contributes to the order's total tax.
        Parameters:
        abstractOrder -
        Returns:
      • getOrderEntriesTotalTax

        protected java.math.BigDecimal getOrderEntriesTotalTax​(AbstractOrderModel abstractOrder)
        Method to calculate the precise sum of the order entries' taxes. This takes into account the loss of precision that will be applied when breaking down the taxes to the unit level.
        Parameters:
        abstractOrder -
        Returns: