org.kuali.kfs.module.endow.util
Class KEMCalculationRoundingHelper
java.lang.Object
org.kuali.kfs.module.endow.util.KEMCalculationRoundingHelper
public class KEMCalculationRoundingHelper
- extends Object
This class will ensure Calculation Rounding Rules in KEM: - No calculated value will ever be truncated to the decimals set for
the field. - Every calculation made by the system must always round to the proper decimal for the field. - Each field has a
decimal value and the calculation results carry past the expected decimals and if the next decimal value is greater than or equal
to 5, the last decimal value will be incremented by 1. - If the calculation results carry past the expected decimals and if the
next decimal value is less than 5, the last decimal value will not be incremented.
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
KEMCalculationRoundingHelper
public KEMCalculationRoundingHelper()
divide
public static BigDecimal divide(BigDecimal dividend,
BigDecimal divisor,
int scale)
- Divides two decimals and applies the given scale and a ROUND_HALF_UP. This method should be used only for the final result
calculation. For example if we have something like this: (axb)/c the rules should be applied to the result of the division
only and not all the computations that give us the final result.
- Parameters:
dividend
- the dividenddivisor
- the divisorscale
- the scale for the result
- Returns:
- the result of the division after the scale and rounding are applied
multiply
public static BigDecimal multiply(BigDecimal multiplier1,
BigDecimal multiplier2,
int scale)
- Multiplies two decimals and applies the given scale and a ROUND_HALF_UP. This method should be used only for the final result
calculation.For example if we have something like this: (axb)/c the rules should be applied to the result of the division
only and not all the computations that give us the final result.
- Parameters:
multiplier1
- first multipliermultiplier2
- second multiplierscale
- the scale fo the result
- Returns:
- the result of the multiplication after scale and rounding are applied
Copyright © 2005-2012 The Kuali Foundation. All Rights Reserved.