adamsaghy commented on code in PR #4783:
URL: https://github.com/apache/fineract/pull/4783#discussion_r2155211777
##########
fineract-core/src/main/java/org/apache/fineract/portfolio/savings/domain/interest/EndOfDayBalance.java:
##########
@@ -60,30 +63,66 @@ public BigDecimal cumulativeBalance(final BigDecimal
interestToCompound) {
MoneyHelper.getRoundingMode());
}
+ public void setDecimales(int decimales) {
+ this.decimales = decimales;
+ }
+
public BigDecimal calculateInterestOnBalance(final BigDecimal
interestToCompound, final BigDecimal interestRateAsFraction,
final long daysInYear, final BigDecimal
minBalanceForInterestCalculation, final BigDecimal
overdraftInterestRateAsFraction,
final BigDecimal minOverdraftForInterestCalculation) {
- BigDecimal interest = BigDecimal.ZERO.setScale(9,
MoneyHelper.getRoundingMode());
+ BigDecimal interest = BigDecimal.ZERO.setScale(this.decimales,
MoneyHelper.getRoundingMode());
final BigDecimal realBalanceForInterestCalculation =
this.endOfDayBalance.getAmount().add(interestToCompound);
if (realBalanceForInterestCalculation.compareTo(BigDecimal.ZERO) >= 0)
{
if
(realBalanceForInterestCalculation.compareTo(minBalanceForInterestCalculation)
>= 0) {
final BigDecimal multiplicand =
BigDecimal.ONE.divide(BigDecimal.valueOf(daysInYear), MathContext.DECIMAL64);
final BigDecimal dailyInterestRate =
interestRateAsFraction.multiply(multiplicand, MathContext.DECIMAL64);
final BigDecimal periodicInterestRate =
dailyInterestRate.multiply(BigDecimal.valueOf(this.numberOfDays),
MathContext.DECIMAL64);
- interest =
realBalanceForInterestCalculation.multiply(periodicInterestRate,
MathContext.DECIMAL64).setScale(9,
+ interest =
realBalanceForInterestCalculation.multiply(periodicInterestRate,
MathContext.DECIMAL64).setScale(this.decimales,
MoneyHelper.getRoundingMode());
}
- } else {
+ } else {// entro en el acrrual
if
(realBalanceForInterestCalculation.compareTo(minOverdraftForInterestCalculation.negate())
< 0) {
final BigDecimal multiplicand =
BigDecimal.ONE.divide(BigDecimal.valueOf(daysInYear), MathContext.DECIMAL64);
final BigDecimal dailyInterestRate =
overdraftInterestRateAsFraction.multiply(multiplicand, MathContext.DECIMAL64);
final BigDecimal periodicInterestRate =
dailyInterestRate.multiply(BigDecimal.valueOf(this.numberOfDays),
MathContext.DECIMAL64);
- interest =
realBalanceForInterestCalculation.multiply(periodicInterestRate,
MathContext.DECIMAL64).setScale(9,
+ interest =
realBalanceForInterestCalculation.multiply(periodicInterestRate,
MathContext.DECIMAL64).setScale(this.decimales,
+ MoneyHelper.getRoundingMode());
+ }
+ }
+ return interest;
+ }
+
+ public BigDecimal calculateInterestOnBalanceNegative(final BigDecimal
interestToCompound, final BigDecimal interestRateAsFraction,
+ final long daysInYear, final BigDecimal
minBalanceForInterestCalculation, final BigDecimal
overdraftInterestRateAsFraction,
+ final BigDecimal minOverdraftForInterestCalculation) {
+
+ BigDecimal interest = BigDecimal.ZERO.setScale(this.decimales,
MoneyHelper.getRoundingMode());
+ final BigDecimal realBalanceForInterestCalculation =
this.endOfDayBalance.getAmount().add(interestToCompound);
+ if (realBalanceForInterestCalculation.compareTo(BigDecimal.ZERO) >= 0)
{
+ if
(realBalanceForInterestCalculation.compareTo(minBalanceForInterestCalculation)
>= 0) {
+ final BigDecimal multiplicand =
BigDecimal.ONE.divide(BigDecimal.valueOf(daysInYear), MathContext.DECIMAL64);
+ final BigDecimal dailyInterestRate =
interestRateAsFraction.multiply(multiplicand, MathContext.DECIMAL64);
+ final BigDecimal periodicInterestRate =
dailyInterestRate.multiply(BigDecimal.valueOf(this.numberOfDays),
+ MathContext.DECIMAL64);
+ interest =
realBalanceForInterestCalculation.multiply(periodicInterestRate,
MathContext.DECIMAL64).setScale(this.decimales,
MoneyHelper.getRoundingMode());
}
+ } else {// entro en el acrrual de validacion
Review Comment:
>
##########
fineract-core/src/main/java/org/apache/fineract/portfolio/savings/domain/interest/EndOfDayBalance.java:
##########
@@ -60,30 +63,66 @@ public BigDecimal cumulativeBalance(final BigDecimal
interestToCompound) {
MoneyHelper.getRoundingMode());
}
+ public void setDecimales(int decimales) {
+ this.decimales = decimales;
+ }
+
public BigDecimal calculateInterestOnBalance(final BigDecimal
interestToCompound, final BigDecimal interestRateAsFraction,
final long daysInYear, final BigDecimal
minBalanceForInterestCalculation, final BigDecimal
overdraftInterestRateAsFraction,
final BigDecimal minOverdraftForInterestCalculation) {
- BigDecimal interest = BigDecimal.ZERO.setScale(9,
MoneyHelper.getRoundingMode());
+ BigDecimal interest = BigDecimal.ZERO.setScale(this.decimales,
MoneyHelper.getRoundingMode());
final BigDecimal realBalanceForInterestCalculation =
this.endOfDayBalance.getAmount().add(interestToCompound);
if (realBalanceForInterestCalculation.compareTo(BigDecimal.ZERO) >= 0)
{
if
(realBalanceForInterestCalculation.compareTo(minBalanceForInterestCalculation)
>= 0) {
final BigDecimal multiplicand =
BigDecimal.ONE.divide(BigDecimal.valueOf(daysInYear), MathContext.DECIMAL64);
final BigDecimal dailyInterestRate =
interestRateAsFraction.multiply(multiplicand, MathContext.DECIMAL64);
final BigDecimal periodicInterestRate =
dailyInterestRate.multiply(BigDecimal.valueOf(this.numberOfDays),
MathContext.DECIMAL64);
- interest =
realBalanceForInterestCalculation.multiply(periodicInterestRate,
MathContext.DECIMAL64).setScale(9,
+ interest =
realBalanceForInterestCalculation.multiply(periodicInterestRate,
MathContext.DECIMAL64).setScale(this.decimales,
MoneyHelper.getRoundingMode());
}
- } else {
+ } else {// entro en el acrrual
if
(realBalanceForInterestCalculation.compareTo(minOverdraftForInterestCalculation.negate())
< 0) {
final BigDecimal multiplicand =
BigDecimal.ONE.divide(BigDecimal.valueOf(daysInYear), MathContext.DECIMAL64);
final BigDecimal dailyInterestRate =
overdraftInterestRateAsFraction.multiply(multiplicand, MathContext.DECIMAL64);
final BigDecimal periodicInterestRate =
dailyInterestRate.multiply(BigDecimal.valueOf(this.numberOfDays),
MathContext.DECIMAL64);
- interest =
realBalanceForInterestCalculation.multiply(periodicInterestRate,
MathContext.DECIMAL64).setScale(9,
+ interest =
realBalanceForInterestCalculation.multiply(periodicInterestRate,
MathContext.DECIMAL64).setScale(this.decimales,
+ MoneyHelper.getRoundingMode());
+ }
+ }
+ return interest;
+ }
+
+ public BigDecimal calculateInterestOnBalanceNegative(final BigDecimal
interestToCompound, final BigDecimal interestRateAsFraction,
+ final long daysInYear, final BigDecimal
minBalanceForInterestCalculation, final BigDecimal
overdraftInterestRateAsFraction,
+ final BigDecimal minOverdraftForInterestCalculation) {
+
+ BigDecimal interest = BigDecimal.ZERO.setScale(this.decimales,
MoneyHelper.getRoundingMode());
+ final BigDecimal realBalanceForInterestCalculation =
this.endOfDayBalance.getAmount().add(interestToCompound);
+ if (realBalanceForInterestCalculation.compareTo(BigDecimal.ZERO) >= 0)
{
+ if
(realBalanceForInterestCalculation.compareTo(minBalanceForInterestCalculation)
>= 0) {
+ final BigDecimal multiplicand =
BigDecimal.ONE.divide(BigDecimal.valueOf(daysInYear), MathContext.DECIMAL64);
+ final BigDecimal dailyInterestRate =
interestRateAsFraction.multiply(multiplicand, MathContext.DECIMAL64);
+ final BigDecimal periodicInterestRate =
dailyInterestRate.multiply(BigDecimal.valueOf(this.numberOfDays),
+ MathContext.DECIMAL64);
+ interest =
realBalanceForInterestCalculation.multiply(periodicInterestRate,
MathContext.DECIMAL64).setScale(this.decimales,
MoneyHelper.getRoundingMode());
}
+ } else {// entro en el acrrual de validacion
Review Comment:
?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]