Class DefaultOndemandTaxCalculationService
- java.lang.Object
-
- de.hybris.platform.integration.commons.services.impl.DefaultOndemandTaxCalculationService
-
- All Implemented Interfaces:
OndemandTaxCalculationService
public class DefaultOndemandTaxCalculationService extends java.lang.Object implements OndemandTaxCalculationService
Implementation ofOndemandTaxCalculationServiceto 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 Summary
Constructors Constructor Description DefaultOndemandTaxCalculationService()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.math.BigDecimalcalculatePreciseUnitTax(java.util.Collection<TaxValue> taxValues, double quantity, boolean isNet)Calculate the unit tax to send with a precision of 2.java.lang.DoublecalculateShippingCost(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.java.math.BigDecimalcalculateShippingTax(AbstractOrderModel abstractOrder)Calculates the shipping tax.java.math.BigDecimalcalculateTotalTax(AbstractOrderModel abstractOrder)protected java.math.BigDecimalgetGrossCalculatedTotalTax(AbstractOrderModel abstractOrder)Method to calculate the total tax of the gross order entries' taxes that contributes to the order's total tax.protected java.math.BigDecimalgetOrderEntriesTotalTax(AbstractOrderModel abstractOrder)Method to calculate the precise sum of the order entries' taxes.
-
-
-
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:
calculatePreciseUnitTaxin interfaceOndemandTaxCalculationService- Parameters:
taxValues- - taxValues associated with the order or order entryquantity- - quantity to determine the unit tax valueisNet- - boolean to determine which tax values need to be summed- Returns:
- - value of unit tax of an item
-
calculateTotalTax
public java.math.BigDecimal calculateTotalTax(AbstractOrderModel abstractOrder)
- Specified by:
calculateTotalTaxin interfaceOndemandTaxCalculationService
-
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:
calculateShippingTaxin interfaceOndemandTaxCalculationService- 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:
calculateShippingCostin interfaceOndemandTaxCalculationService
-
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:
-
-