MIFOSX-2148 : cleanup
This commit is contained in:
+6
-2
@@ -20,21 +20,25 @@ public class GlobalConfigurationPropertyData {
|
|||||||
private final Long id;
|
private final Long id;
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
private final String description;
|
private final String description;
|
||||||
|
@SuppressWarnings("unused")
|
||||||
|
private final boolean trapDoor;
|
||||||
|
|
||||||
public GlobalConfigurationPropertyData(final String name, final boolean enabled, final Long value, final String description) {
|
public GlobalConfigurationPropertyData(final String name, final boolean enabled, final Long value, final String description, final boolean trapDoor) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.enabled = enabled;
|
this.enabled = enabled;
|
||||||
this.value = value;
|
this.value = value;
|
||||||
this.id = null;
|
this.id = null;
|
||||||
this.description = description;
|
this.description = description;
|
||||||
|
this.trapDoor = trapDoor;
|
||||||
}
|
}
|
||||||
|
|
||||||
public GlobalConfigurationPropertyData(final String name, final boolean enabled, final Long value, final Long id,
|
public GlobalConfigurationPropertyData(final String name, final boolean enabled, final Long value, final Long id,
|
||||||
final String description) {
|
final String description, final boolean isTrapDoor) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.enabled = enabled;
|
this.enabled = enabled;
|
||||||
this.value = value;
|
this.value = value;
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.description = description;
|
this.description = description;
|
||||||
|
this.trapDoor = isTrapDoor;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+2
-4
@@ -43,10 +43,8 @@ public class ConfigurationReadPlatformServiceImpl implements ConfigurationReadPl
|
|||||||
|
|
||||||
if (survey) {
|
if (survey) {
|
||||||
sql += " JOIN x_registered_table on x_registered_table.registered_table_name = c.name ";
|
sql += " JOIN x_registered_table on x_registered_table.registered_table_name = c.name ";
|
||||||
sql += " WHERE x_registered_table.category =" + DataTableApiConstant.CATEGORY_PPI + " and c.is_trap_door=0";
|
sql += " WHERE x_registered_table.category =" + DataTableApiConstant.CATEGORY_PPI;
|
||||||
|
|
||||||
} else {
|
|
||||||
sql += " WHERE c.is_trap_door=0";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sql += " order by c.id";
|
sql += " order by c.id";
|
||||||
@@ -80,7 +78,7 @@ public class ConfigurationReadPlatformServiceImpl implements ConfigurationReadPl
|
|||||||
final String description = rs.getString("description");
|
final String description = rs.getString("description");
|
||||||
final Long id = rs.getLong("id");
|
final Long id = rs.getLong("id");
|
||||||
final boolean isTrapDoor = rs.getBoolean("is_trap_door");
|
final boolean isTrapDoor = rs.getBoolean("is_trap_door");
|
||||||
return new GlobalConfigurationPropertyData(name, enabled, value, id, description);
|
return new GlobalConfigurationPropertyData(name, enabled, value, id, description, isTrapDoor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -76,7 +76,7 @@ public class Money implements Comparable<Money> {
|
|||||||
final double existingVal = amountScaled.doubleValue();
|
final double existingVal = amountScaled.doubleValue();
|
||||||
amountScaled = BigDecimal.valueOf(roundToMultiplesOf(existingVal, inMultiplesOf));
|
amountScaled = BigDecimal.valueOf(roundToMultiplesOf(existingVal, inMultiplesOf));
|
||||||
}
|
}
|
||||||
this.amount = amountScaled.setScale(this.currencyDigitsAfterDecimal, RoundingMode.valueOf(MoneyHelper.getRoundingMode()));
|
this.amount = amountScaled.setScale(this.currencyDigitsAfterDecimal, MoneyHelper.getRoundingMode());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static double roundToMultiplesOf(final double existingVal, final Integer inMultiplesOf) {
|
public static double roundToMultiplesOf(final double existingVal, final Integer inMultiplesOf) {
|
||||||
|
|||||||
+7
-5
@@ -5,6 +5,8 @@
|
|||||||
*/
|
*/
|
||||||
package org.mifosplatform.organisation.monetary.domain;
|
package org.mifosplatform.organisation.monetary.domain;
|
||||||
|
|
||||||
|
import java.math.RoundingMode;
|
||||||
|
|
||||||
import javax.annotation.PostConstruct;
|
import javax.annotation.PostConstruct;
|
||||||
|
|
||||||
import org.mifosplatform.infrastructure.configuration.domain.ConfigurationDomainService;
|
import org.mifosplatform.infrastructure.configuration.domain.ConfigurationDomainService;
|
||||||
@@ -14,7 +16,7 @@ import org.springframework.stereotype.Component;
|
|||||||
@Component
|
@Component
|
||||||
public class MoneyHelper {
|
public class MoneyHelper {
|
||||||
|
|
||||||
private static int roundingModeIntValue = -1;
|
private static RoundingMode roundingMode = null;
|
||||||
private static ConfigurationDomainService staticConfigurationDomainService;
|
private static ConfigurationDomainService staticConfigurationDomainService;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
@@ -26,11 +28,11 @@ public class MoneyHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static int getRoundingMode() {
|
public static RoundingMode getRoundingMode() {
|
||||||
if (roundingModeIntValue == -1) {
|
if (roundingMode == null) {
|
||||||
roundingModeIntValue = staticConfigurationDomainService.getRoundingMode();
|
roundingMode = RoundingMode.valueOf(staticConfigurationDomainService.getRoundingMode());
|
||||||
}
|
}
|
||||||
return roundingModeIntValue;
|
return roundingMode;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-3
@@ -2323,7 +2323,7 @@ public class Loan extends AbstractPersistable<Long> {
|
|||||||
final InterestMethod interestMethod = this.loanRepaymentScheduleDetail.getInterestMethod();
|
final InterestMethod interestMethod = this.loanRepaymentScheduleDetail.getInterestMethod();
|
||||||
final LoanScheduleGenerator loanScheduleGenerator = scheduleGeneratorDTO.getLoanScheduleFactory().create(interestMethod);
|
final LoanScheduleGenerator loanScheduleGenerator = scheduleGeneratorDTO.getLoanScheduleFactory().create(interestMethod);
|
||||||
|
|
||||||
final RoundingMode roundingMode = RoundingMode.valueOf(MoneyHelper.getRoundingMode());
|
final RoundingMode roundingMode = MoneyHelper.getRoundingMode();
|
||||||
final MathContext mc = new MathContext(8, roundingMode);
|
final MathContext mc = new MathContext(8, roundingMode);
|
||||||
|
|
||||||
final Integer loanTermFrequency = this.termFrequency;
|
final Integer loanTermFrequency = this.termFrequency;
|
||||||
@@ -4682,7 +4682,7 @@ public class Loan extends AbstractPersistable<Long> {
|
|||||||
final InterestMethod interestMethod = this.loanRepaymentScheduleDetail.getInterestMethod();
|
final InterestMethod interestMethod = this.loanRepaymentScheduleDetail.getInterestMethod();
|
||||||
final LoanScheduleGenerator loanScheduleGenerator = generatorDTO.getLoanScheduleFactory().create(interestMethod);
|
final LoanScheduleGenerator loanScheduleGenerator = generatorDTO.getLoanScheduleFactory().create(interestMethod);
|
||||||
|
|
||||||
final RoundingMode roundingMode = RoundingMode.valueOf(MoneyHelper.getRoundingMode());
|
final RoundingMode roundingMode = MoneyHelper.getRoundingMode();
|
||||||
final MathContext mc = new MathContext(8, roundingMode);
|
final MathContext mc = new MathContext(8, roundingMode);
|
||||||
|
|
||||||
final LoanApplicationTerms loanApplicationTerms = constructLoanApplicationTerms(generatorDTO.getApplicationCurrency(),
|
final LoanApplicationTerms loanApplicationTerms = constructLoanApplicationTerms(generatorDTO.getApplicationCurrency(),
|
||||||
@@ -4745,7 +4745,7 @@ public class Loan extends AbstractPersistable<Long> {
|
|||||||
final InterestMethod interestMethod = this.loanRepaymentScheduleDetail.getInterestMethod();
|
final InterestMethod interestMethod = this.loanRepaymentScheduleDetail.getInterestMethod();
|
||||||
final LoanScheduleGenerator loanScheduleGenerator = loanScheduleFactory.create(interestMethod);
|
final LoanScheduleGenerator loanScheduleGenerator = loanScheduleFactory.create(interestMethod);
|
||||||
|
|
||||||
final RoundingMode roundingMode = RoundingMode.valueOf(MoneyHelper.getRoundingMode());
|
final RoundingMode roundingMode = MoneyHelper.getRoundingMode();
|
||||||
final MathContext mc = new MathContext(8, roundingMode);
|
final MathContext mc = new MathContext(8, roundingMode);
|
||||||
|
|
||||||
final Integer loanTermFrequency = this.termFrequency;
|
final Integer loanTermFrequency = this.termFrequency;
|
||||||
|
|||||||
+1
-1
@@ -553,7 +553,7 @@ public class LoanCharge extends AbstractPersistable<Long> {
|
|||||||
BigDecimal percentageOf = BigDecimal.ZERO;
|
BigDecimal percentageOf = BigDecimal.ZERO;
|
||||||
|
|
||||||
if (isGreaterThanZero(value)) {
|
if (isGreaterThanZero(value)) {
|
||||||
final MathContext mc = new MathContext(8, RoundingMode.valueOf(MoneyHelper.getRoundingMode()));
|
final MathContext mc = new MathContext(8, MoneyHelper.getRoundingMode());
|
||||||
final BigDecimal multiplicand = percentage.divide(BigDecimal.valueOf(100l), mc);
|
final BigDecimal multiplicand = percentage.divide(BigDecimal.valueOf(100l), mc);
|
||||||
percentageOf = value.multiply(multiplicand, mc);
|
percentageOf = value.multiply(multiplicand, mc);
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-3
@@ -239,7 +239,7 @@ public class GuarantorDomainServiceImpl implements GuarantorDomainService {
|
|||||||
BigDecimal remainingAmount = guarantorFundingDetails.getAmountRemaining();
|
BigDecimal remainingAmount = guarantorFundingDetails.getAmountRemaining();
|
||||||
if (loan.getGuaranteeAmount().compareTo(loan.getPrincpal().getAmount()) == 1) {
|
if (loan.getGuaranteeAmount().compareTo(loan.getPrincpal().getAmount()) == 1) {
|
||||||
remainingAmount = remainingAmount.multiply(loan.getPrincpal().getAmount()).divide(loan.getGuaranteeAmount(),
|
remainingAmount = remainingAmount.multiply(loan.getPrincpal().getAmount()).divide(loan.getGuaranteeAmount(),
|
||||||
RoundingMode.valueOf(MoneyHelper.getRoundingMode()));
|
MoneyHelper.getRoundingMode());
|
||||||
}
|
}
|
||||||
AccountTransferDTO accountTransferDTO = new AccountTransferDTO(transactionDate, remainingAmount, fromAccountType,
|
AccountTransferDTO accountTransferDTO = new AccountTransferDTO(transactionDate, remainingAmount, fromAccountType,
|
||||||
toAccountType, fromAccountId, toAccountId, description, locale, fmt, paymentDetail, fromTransferType,
|
toAccountType, fromAccountId, toAccountId, description, locale, fmt, paymentDetail, fromTransferType,
|
||||||
@@ -381,7 +381,7 @@ public class GuarantorDomainServiceImpl implements GuarantorDomainService {
|
|||||||
BigDecimal totalGuaranteeAmount = loan.getGuaranteeAmount();
|
BigDecimal totalGuaranteeAmount = loan.getGuaranteeAmount();
|
||||||
BigDecimal principal = loan.getPrincpal().getAmount();
|
BigDecimal principal = loan.getPrincpal().getAmount();
|
||||||
if ((amountForRelease != null) && (totalGuaranteeAmount != null)) {
|
if ((amountForRelease != null) && (totalGuaranteeAmount != null)) {
|
||||||
amountForRelease = amountForRelease.multiply(totalGuaranteeAmount).divide(principal, RoundingMode.valueOf(MoneyHelper.getRoundingMode()));
|
amountForRelease = amountForRelease.multiply(totalGuaranteeAmount).divide(principal, MoneyHelper.getRoundingMode());
|
||||||
List<DepositAccountOnHoldTransaction> accountOnHoldTransactions = new ArrayList<>();
|
List<DepositAccountOnHoldTransaction> accountOnHoldTransactions = new ArrayList<>();
|
||||||
|
|
||||||
BigDecimal amountLeft = calculateAndRelaseGuarantorFunds(externalGuarantorList, guarantorGuarantee, amountForRelease,
|
BigDecimal amountLeft = calculateAndRelaseGuarantorFunds(externalGuarantorList, guarantorGuarantee, amountForRelease,
|
||||||
@@ -467,7 +467,7 @@ public class GuarantorDomainServiceImpl implements GuarantorDomainService {
|
|||||||
BigDecimal amountLeft = amountForRelease;
|
BigDecimal amountLeft = amountForRelease;
|
||||||
for (GuarantorFundingDetails fundingDetails : guarantorList) {
|
for (GuarantorFundingDetails fundingDetails : guarantorList) {
|
||||||
BigDecimal guarantorAmount = amountForRelease.multiply(fundingDetails.getAmountRemaining()).divide(totalGuaranteeAmount,
|
BigDecimal guarantorAmount = amountForRelease.multiply(fundingDetails.getAmountRemaining()).divide(totalGuaranteeAmount,
|
||||||
RoundingMode.valueOf(MoneyHelper.getRoundingMode()));
|
MoneyHelper.getRoundingMode());
|
||||||
if (fundingDetails.getAmountRemaining().compareTo(guarantorAmount) < 1) {
|
if (fundingDetails.getAmountRemaining().compareTo(guarantorAmount) < 1) {
|
||||||
guarantorAmount = fundingDetails.getAmountRemaining();
|
guarantorAmount = fundingDetails.getAmountRemaining();
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -403,7 +403,7 @@ public final class LoanApplicationTerms {
|
|||||||
} else if (this.actualFixedEmiAmount != null) {
|
} else if (this.actualFixedEmiAmount != null) {
|
||||||
final Money difference = this.principal.minus(totalCumulativePrincipalToDate);
|
final Money difference = this.principal.minus(totalCumulativePrincipalToDate);
|
||||||
final Money principalThreshold = principalForPeriod.multipliedBy(this.principalThresholdForLastInstalment).dividedBy(100,
|
final Money principalThreshold = principalForPeriod.multipliedBy(this.principalThresholdForLastInstalment).dividedBy(100,
|
||||||
RoundingMode.valueOf(MoneyHelper.getRoundingMode()));
|
MoneyHelper.getRoundingMode());
|
||||||
if (difference.isLessThan(principalThreshold)) {
|
if (difference.isLessThan(principalThreshold)) {
|
||||||
adjusted = principalForPeriod.plus(difference.abs());
|
adjusted = principalForPeriod.plus(difference.abs());
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-3
@@ -444,7 +444,7 @@ public class LoanScheduleAssembler {
|
|||||||
|
|
||||||
final LoanScheduleGenerator loanScheduleGenerator = this.loanScheduleFactory.create(loanApplicationTerms.getInterestMethod());
|
final LoanScheduleGenerator loanScheduleGenerator = this.loanScheduleFactory.create(loanApplicationTerms.getInterestMethod());
|
||||||
|
|
||||||
final RoundingMode roundingMode = RoundingMode.valueOf(MoneyHelper.getRoundingMode());
|
final RoundingMode roundingMode = MoneyHelper.getRoundingMode();
|
||||||
final MathContext mc = new MathContext(8, roundingMode);
|
final MathContext mc = new MathContext(8, roundingMode);
|
||||||
|
|
||||||
HolidayDetailDTO detailDTO = new HolidayDetailDTO(isHolidayEnabled, holidays, workingDays);
|
HolidayDetailDTO detailDTO = new HolidayDetailDTO(isHolidayEnabled, holidays, workingDays);
|
||||||
@@ -455,7 +455,7 @@ public class LoanScheduleAssembler {
|
|||||||
public LoanScheduleModel assembleForInterestRecalculation(final LoanApplicationTerms loanApplicationTerms, final Long officeId,
|
public LoanScheduleModel assembleForInterestRecalculation(final LoanApplicationTerms loanApplicationTerms, final Long officeId,
|
||||||
List<LoanTransaction> transactions, final Set<LoanCharge> loanCharges,
|
List<LoanTransaction> transactions, final Set<LoanCharge> loanCharges,
|
||||||
final LoanRepaymentScheduleTransactionProcessor loanRepaymentScheduleTransactionProcessor) {
|
final LoanRepaymentScheduleTransactionProcessor loanRepaymentScheduleTransactionProcessor) {
|
||||||
final RoundingMode roundingMode = RoundingMode.valueOf(MoneyHelper.getRoundingMode());
|
final RoundingMode roundingMode = MoneyHelper.getRoundingMode();
|
||||||
final MathContext mc = new MathContext(8, roundingMode);
|
final MathContext mc = new MathContext(8, roundingMode);
|
||||||
final boolean isHolidayEnabled = this.configurationDomainService.isRescheduleRepaymentsOnHolidaysEnabled();
|
final boolean isHolidayEnabled = this.configurationDomainService.isRescheduleRepaymentsOnHolidaysEnabled();
|
||||||
|
|
||||||
@@ -474,7 +474,7 @@ public class LoanScheduleAssembler {
|
|||||||
final Long officeId, List<LoanTransaction> loanTransactions,
|
final Long officeId, List<LoanTransaction> loanTransactions,
|
||||||
final LoanRepaymentScheduleTransactionProcessor loanRepaymentScheduleTransactionProcessor) {
|
final LoanRepaymentScheduleTransactionProcessor loanRepaymentScheduleTransactionProcessor) {
|
||||||
final LoanScheduleGenerator loanScheduleGenerator = this.loanScheduleFactory.create(loanApplicationTerms.getInterestMethod());
|
final LoanScheduleGenerator loanScheduleGenerator = this.loanScheduleFactory.create(loanApplicationTerms.getInterestMethod());
|
||||||
final RoundingMode roundingMode = RoundingMode.valueOf(MoneyHelper.getRoundingMode());
|
final RoundingMode roundingMode = MoneyHelper.getRoundingMode();
|
||||||
final MathContext mc = new MathContext(8, roundingMode);
|
final MathContext mc = new MathContext(8, roundingMode);
|
||||||
|
|
||||||
final boolean isHolidayEnabled = this.configurationDomainService.isRescheduleRepaymentsOnHolidaysEnabled();
|
final boolean isHolidayEnabled = this.configurationDomainService.isRescheduleRepaymentsOnHolidaysEnabled();
|
||||||
|
|||||||
+1
-1
@@ -81,7 +81,7 @@ public class LoanReschedulePreviewPlatformServiceImpl implements LoanRescheduleP
|
|||||||
final ApplicationCurrency applicationCurrency = this.applicationCurrencyRepository.findOneWithNotFoundDetection(currency);
|
final ApplicationCurrency applicationCurrency = this.applicationCurrencyRepository.findOneWithNotFoundDetection(currency);
|
||||||
|
|
||||||
final InterestMethod interestMethod = loan.getLoanRepaymentScheduleDetail().getInterestMethod();
|
final InterestMethod interestMethod = loan.getLoanRepaymentScheduleDetail().getInterestMethod();
|
||||||
final RoundingMode roundingMode = RoundingMode.valueOf(MoneyHelper.getRoundingMode());
|
final RoundingMode roundingMode = MoneyHelper.getRoundingMode();
|
||||||
final MathContext mathContext = new MathContext(8, roundingMode);
|
final MathContext mathContext = new MathContext(8, roundingMode);
|
||||||
List<LoanRepaymentScheduleHistory> oldPeriods = this.loanScheduleHistoryWritePlatformService
|
List<LoanRepaymentScheduleHistory> oldPeriods = this.loanScheduleHistoryWritePlatformService
|
||||||
.createLoanScheduleArchive(loan.getRepaymentScheduleInstallments(), loan, loanRescheduleRequest);
|
.createLoanScheduleArchive(loan.getRepaymentScheduleInstallments(), loan, loanRescheduleRequest);
|
||||||
|
|||||||
+1
-1
@@ -292,7 +292,7 @@ public class LoanRescheduleRequestWritePlatformServiceImpl implements LoanResche
|
|||||||
final ApplicationCurrency applicationCurrency = this.applicationCurrencyRepository.findOneWithNotFoundDetection(currency);
|
final ApplicationCurrency applicationCurrency = this.applicationCurrencyRepository.findOneWithNotFoundDetection(currency);
|
||||||
|
|
||||||
final InterestMethod interestMethod = loan.getLoanRepaymentScheduleDetail().getInterestMethod();
|
final InterestMethod interestMethod = loan.getLoanRepaymentScheduleDetail().getInterestMethod();
|
||||||
final RoundingMode roundingMode = RoundingMode.valueOf(MoneyHelper.getRoundingMode());
|
final RoundingMode roundingMode = MoneyHelper.getRoundingMode();
|
||||||
final MathContext mathContext = new MathContext(8, roundingMode);
|
final MathContext mathContext = new MathContext(8, roundingMode);
|
||||||
|
|
||||||
Collection<LoanRepaymentScheduleHistory> loanRepaymentScheduleHistoryList = this.loanScheduleHistoryWritePlatformService
|
Collection<LoanRepaymentScheduleHistory> loanRepaymentScheduleHistoryList = this.loanScheduleHistoryWritePlatformService
|
||||||
|
|||||||
+1
-1
@@ -141,7 +141,7 @@ public class LoanAccrualWritePlatformServiceImpl implements LoanAccrualWritePlat
|
|||||||
double iterest = interestPerDay * daysToBeAccrued;
|
double iterest = interestPerDay * daysToBeAccrued;
|
||||||
interestportion = BigDecimal.valueOf(iterest);
|
interestportion = BigDecimal.valueOf(iterest);
|
||||||
}
|
}
|
||||||
interestportion = interestportion.setScale(accrualData.getCurrencyData().decimalPlaces(), RoundingMode.valueOf(MoneyHelper.getRoundingMode()));
|
interestportion = interestportion.setScale(accrualData.getCurrencyData().decimalPlaces(), MoneyHelper.getRoundingMode());
|
||||||
|
|
||||||
BigDecimal totalAccInterest = accrualData.getAccruedInterestIncome();
|
BigDecimal totalAccInterest = accrualData.getAccruedInterestIncome();
|
||||||
BigDecimal totalAccPenalty = accrualData.getAccruedPenaltyIncome();
|
BigDecimal totalAccPenalty = accrualData.getAccruedPenaltyIncome();
|
||||||
|
|||||||
+1
-1
@@ -528,7 +528,7 @@ public class SavingsAccountCharge extends AbstractPersistable<Long> {
|
|||||||
BigDecimal percentageOf = BigDecimal.ZERO;
|
BigDecimal percentageOf = BigDecimal.ZERO;
|
||||||
|
|
||||||
if (isGreaterThanZero(value)) {
|
if (isGreaterThanZero(value)) {
|
||||||
final MathContext mc = new MathContext(8, RoundingMode.valueOf(MoneyHelper.getRoundingMode()));
|
final MathContext mc = new MathContext(8, MoneyHelper.getRoundingMode());
|
||||||
final BigDecimal multiplicand = percentage.divide(BigDecimal.valueOf(100l), mc);
|
final BigDecimal multiplicand = percentage.divide(BigDecimal.valueOf(100l), mc);
|
||||||
percentageOf = value.multiply(multiplicand, mc);
|
percentageOf = value.multiply(multiplicand, mc);
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -72,14 +72,14 @@ public class AnnualCompoundingPeriod implements CompoundingPeriod {
|
|||||||
BigDecimal interestEarned = BigDecimal.ZERO;
|
BigDecimal interestEarned = BigDecimal.ZERO;
|
||||||
if (cumulativeBalance.compareTo(BigDecimal.ZERO) != 0 && numberOfDays > 0) {
|
if (cumulativeBalance.compareTo(BigDecimal.ZERO) != 0 && numberOfDays > 0) {
|
||||||
final BigDecimal averageDailyBalance = cumulativeBalance.divide(BigDecimal.valueOf(numberOfDays), MathContext.DECIMAL64)
|
final BigDecimal averageDailyBalance = cumulativeBalance.divide(BigDecimal.valueOf(numberOfDays), MathContext.DECIMAL64)
|
||||||
.setScale(9, RoundingMode.valueOf(MoneyHelper.getRoundingMode()));
|
.setScale(9, MoneyHelper.getRoundingMode());
|
||||||
|
|
||||||
final BigDecimal multiplicand = BigDecimal.ONE.divide(BigDecimal.valueOf(daysInYear), MathContext.DECIMAL64);
|
final BigDecimal multiplicand = BigDecimal.ONE.divide(BigDecimal.valueOf(daysInYear), MathContext.DECIMAL64);
|
||||||
final BigDecimal dailyInterestRate = interestRateAsFraction.multiply(multiplicand, MathContext.DECIMAL64);
|
final BigDecimal dailyInterestRate = interestRateAsFraction.multiply(multiplicand, MathContext.DECIMAL64);
|
||||||
final BigDecimal periodicInterestRate = dailyInterestRate.multiply(BigDecimal.valueOf(numberOfDays), MathContext.DECIMAL64);
|
final BigDecimal periodicInterestRate = dailyInterestRate.multiply(BigDecimal.valueOf(numberOfDays), MathContext.DECIMAL64);
|
||||||
if (averageDailyBalance.compareTo(minBalanceForInterestCalculation) >= 0) {
|
if (averageDailyBalance.compareTo(minBalanceForInterestCalculation) >= 0) {
|
||||||
interestEarned = averageDailyBalance.multiply(periodicInterestRate, MathContext.DECIMAL64).setScale(9,
|
interestEarned = averageDailyBalance.multiply(periodicInterestRate, MathContext.DECIMAL64).setScale(9,
|
||||||
RoundingMode.valueOf(MoneyHelper.getRoundingMode()));
|
MoneyHelper.getRoundingMode());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -72,14 +72,14 @@ public class BiAnnualCompoundingPeriod implements CompoundingPeriod {
|
|||||||
BigDecimal interestEarned = BigDecimal.ZERO;
|
BigDecimal interestEarned = BigDecimal.ZERO;
|
||||||
if (cumulativeBalance.compareTo(BigDecimal.ZERO) != 0 && numberOfDays > 0) {
|
if (cumulativeBalance.compareTo(BigDecimal.ZERO) != 0 && numberOfDays > 0) {
|
||||||
final BigDecimal averageDailyBalance = cumulativeBalance.divide(BigDecimal.valueOf(numberOfDays), MathContext.DECIMAL64)
|
final BigDecimal averageDailyBalance = cumulativeBalance.divide(BigDecimal.valueOf(numberOfDays), MathContext.DECIMAL64)
|
||||||
.setScale(9, RoundingMode.valueOf(MoneyHelper.getRoundingMode()));
|
.setScale(9, MoneyHelper.getRoundingMode());
|
||||||
|
|
||||||
final BigDecimal multiplicand = BigDecimal.ONE.divide(BigDecimal.valueOf(daysInYear), MathContext.DECIMAL64);
|
final BigDecimal multiplicand = BigDecimal.ONE.divide(BigDecimal.valueOf(daysInYear), MathContext.DECIMAL64);
|
||||||
final BigDecimal dailyInterestRate = interestRateAsFraction.multiply(multiplicand, MathContext.DECIMAL64);
|
final BigDecimal dailyInterestRate = interestRateAsFraction.multiply(multiplicand, MathContext.DECIMAL64);
|
||||||
final BigDecimal periodicInterestRate = dailyInterestRate.multiply(BigDecimal.valueOf(numberOfDays), MathContext.DECIMAL64);
|
final BigDecimal periodicInterestRate = dailyInterestRate.multiply(BigDecimal.valueOf(numberOfDays), MathContext.DECIMAL64);
|
||||||
if (averageDailyBalance.compareTo(minBalanceForInterestCalculation) >= 0) {
|
if (averageDailyBalance.compareTo(minBalanceForInterestCalculation) >= 0) {
|
||||||
interestEarned = averageDailyBalance.multiply(periodicInterestRate, MathContext.DECIMAL64).setScale(9,
|
interestEarned = averageDailyBalance.multiply(periodicInterestRate, MathContext.DECIMAL64).setScale(9,
|
||||||
RoundingMode.valueOf(MoneyHelper.getRoundingMode()));
|
MoneyHelper.getRoundingMode());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+5
-5
@@ -45,7 +45,7 @@ public class EndOfDayBalance {
|
|||||||
final BigDecimal daysAsBigDecimal = BigDecimal.valueOf(this.numberOfDays);
|
final BigDecimal daysAsBigDecimal = BigDecimal.valueOf(this.numberOfDays);
|
||||||
final BigDecimal realBalanceForInterestCalculation = this.endOfDayBalance.getAmount().add(interestToCompound);
|
final BigDecimal realBalanceForInterestCalculation = this.endOfDayBalance.getAmount().add(interestToCompound);
|
||||||
return realBalanceForInterestCalculation.multiply(daysAsBigDecimal, MathContext.DECIMAL64).setScale(9,
|
return realBalanceForInterestCalculation.multiply(daysAsBigDecimal, MathContext.DECIMAL64).setScale(9,
|
||||||
RoundingMode.valueOf(MoneyHelper.getRoundingMode()));
|
MoneyHelper.getRoundingMode());
|
||||||
}
|
}
|
||||||
|
|
||||||
public BigDecimal calculateInterestOnBalance(final BigDecimal interestToCompound, final BigDecimal interestRateAsFraction,
|
public BigDecimal calculateInterestOnBalance(final BigDecimal interestToCompound, final BigDecimal interestRateAsFraction,
|
||||||
@@ -56,10 +56,10 @@ public class EndOfDayBalance {
|
|||||||
final BigDecimal periodicInterestRate = dailyInterestRate.multiply(BigDecimal.valueOf(this.numberOfDays), MathContext.DECIMAL64);
|
final BigDecimal periodicInterestRate = dailyInterestRate.multiply(BigDecimal.valueOf(this.numberOfDays), MathContext.DECIMAL64);
|
||||||
|
|
||||||
final BigDecimal realBalanceForInterestCalculation = this.endOfDayBalance.getAmount().add(interestToCompound);
|
final BigDecimal realBalanceForInterestCalculation = this.endOfDayBalance.getAmount().add(interestToCompound);
|
||||||
BigDecimal interest = BigDecimal.ZERO.setScale(9, RoundingMode.valueOf(MoneyHelper.getRoundingMode()));
|
BigDecimal interest = BigDecimal.ZERO.setScale(9, MoneyHelper.getRoundingMode());
|
||||||
if (realBalanceForInterestCalculation.compareTo(minBalanceForInterestCalculation) >= 0) {
|
if (realBalanceForInterestCalculation.compareTo(minBalanceForInterestCalculation) >= 0) {
|
||||||
interest = realBalanceForInterestCalculation.multiply(periodicInterestRate, MathContext.DECIMAL64).setScale(9,
|
interest = realBalanceForInterestCalculation.multiply(periodicInterestRate, MathContext.DECIMAL64).setScale(9,
|
||||||
RoundingMode.valueOf(MoneyHelper.getRoundingMode()));
|
MoneyHelper.getRoundingMode());
|
||||||
}
|
}
|
||||||
return interest;
|
return interest;
|
||||||
}
|
}
|
||||||
@@ -83,10 +83,10 @@ public class EndOfDayBalance {
|
|||||||
|
|
||||||
final double interestRateForCompoundingPeriodPowered = Math.pow(interestRateForCompoundingPeriodPlusOne.doubleValue(),
|
final double interestRateForCompoundingPeriodPowered = Math.pow(interestRateForCompoundingPeriodPlusOne.doubleValue(),
|
||||||
Integer.valueOf(this.numberOfDays).doubleValue());
|
Integer.valueOf(this.numberOfDays).doubleValue());
|
||||||
BigDecimal futureValue = presentValue.setScale(9, RoundingMode.valueOf(MoneyHelper.getRoundingMode()));
|
BigDecimal futureValue = presentValue.setScale(9, MoneyHelper.getRoundingMode());
|
||||||
if (presentValue.compareTo(minBalanceForInterestCalculation) >= 0) {
|
if (presentValue.compareTo(minBalanceForInterestCalculation) >= 0) {
|
||||||
futureValue = presentValue.multiply(BigDecimal.valueOf(interestRateForCompoundingPeriodPowered), MathContext.DECIMAL64)
|
futureValue = presentValue.multiply(BigDecimal.valueOf(interestRateForCompoundingPeriodPowered), MathContext.DECIMAL64)
|
||||||
.setScale(9, RoundingMode.valueOf(MoneyHelper.getRoundingMode()));
|
.setScale(9, MoneyHelper.getRoundingMode());
|
||||||
}
|
}
|
||||||
return futureValue.subtract(presentValue);
|
return futureValue.subtract(presentValue);
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -72,14 +72,14 @@ public class MonthlyCompoundingPeriod implements CompoundingPeriod {
|
|||||||
BigDecimal interestEarned = BigDecimal.ZERO;
|
BigDecimal interestEarned = BigDecimal.ZERO;
|
||||||
if (cumulativeBalance.compareTo(BigDecimal.ZERO) != 0 && numberOfDays > 0) {
|
if (cumulativeBalance.compareTo(BigDecimal.ZERO) != 0 && numberOfDays > 0) {
|
||||||
final BigDecimal averageDailyBalance = cumulativeBalance.divide(BigDecimal.valueOf(numberOfDays), MathContext.DECIMAL64)
|
final BigDecimal averageDailyBalance = cumulativeBalance.divide(BigDecimal.valueOf(numberOfDays), MathContext.DECIMAL64)
|
||||||
.setScale(9, RoundingMode.valueOf(MoneyHelper.getRoundingMode()));
|
.setScale(9, MoneyHelper.getRoundingMode());
|
||||||
|
|
||||||
final BigDecimal multiplicand = BigDecimal.ONE.divide(BigDecimal.valueOf(daysInYear), MathContext.DECIMAL64);
|
final BigDecimal multiplicand = BigDecimal.ONE.divide(BigDecimal.valueOf(daysInYear), MathContext.DECIMAL64);
|
||||||
final BigDecimal dailyInterestRate = interestRateAsFraction.multiply(multiplicand, MathContext.DECIMAL64);
|
final BigDecimal dailyInterestRate = interestRateAsFraction.multiply(multiplicand, MathContext.DECIMAL64);
|
||||||
final BigDecimal periodicInterestRate = dailyInterestRate.multiply(BigDecimal.valueOf(numberOfDays), MathContext.DECIMAL64);
|
final BigDecimal periodicInterestRate = dailyInterestRate.multiply(BigDecimal.valueOf(numberOfDays), MathContext.DECIMAL64);
|
||||||
if (averageDailyBalance.compareTo(minBalanceForInterestCalculation) >= 0) {
|
if (averageDailyBalance.compareTo(minBalanceForInterestCalculation) >= 0) {
|
||||||
interestEarned = averageDailyBalance.multiply(periodicInterestRate, MathContext.DECIMAL64).setScale(9,
|
interestEarned = averageDailyBalance.multiply(periodicInterestRate, MathContext.DECIMAL64).setScale(9,
|
||||||
RoundingMode.valueOf(MoneyHelper.getRoundingMode()));
|
MoneyHelper.getRoundingMode());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -72,14 +72,14 @@ public class QuarterlyCompoundingPeriod implements CompoundingPeriod {
|
|||||||
BigDecimal interestEarned = BigDecimal.ZERO;
|
BigDecimal interestEarned = BigDecimal.ZERO;
|
||||||
if (cumulativeBalance.compareTo(BigDecimal.ZERO) != 0 && numberOfDays > 0) {
|
if (cumulativeBalance.compareTo(BigDecimal.ZERO) != 0 && numberOfDays > 0) {
|
||||||
final BigDecimal averageDailyBalance = cumulativeBalance.divide(BigDecimal.valueOf(numberOfDays), MathContext.DECIMAL64)
|
final BigDecimal averageDailyBalance = cumulativeBalance.divide(BigDecimal.valueOf(numberOfDays), MathContext.DECIMAL64)
|
||||||
.setScale(9, RoundingMode.valueOf(MoneyHelper.getRoundingMode()));
|
.setScale(9, MoneyHelper.getRoundingMode());
|
||||||
|
|
||||||
final BigDecimal multiplicand = BigDecimal.ONE.divide(BigDecimal.valueOf(daysInYear), MathContext.DECIMAL64);
|
final BigDecimal multiplicand = BigDecimal.ONE.divide(BigDecimal.valueOf(daysInYear), MathContext.DECIMAL64);
|
||||||
final BigDecimal dailyInterestRate = interestRateAsFraction.multiply(multiplicand, MathContext.DECIMAL64);
|
final BigDecimal dailyInterestRate = interestRateAsFraction.multiply(multiplicand, MathContext.DECIMAL64);
|
||||||
final BigDecimal periodicInterestRate = dailyInterestRate.multiply(BigDecimal.valueOf(numberOfDays), MathContext.DECIMAL64);
|
final BigDecimal periodicInterestRate = dailyInterestRate.multiply(BigDecimal.valueOf(numberOfDays), MathContext.DECIMAL64);
|
||||||
if (averageDailyBalance.compareTo(minBalanceForInterestCalculation) >= 0) {
|
if (averageDailyBalance.compareTo(minBalanceForInterestCalculation) >= 0) {
|
||||||
interestEarned = averageDailyBalance.multiply(periodicInterestRate, MathContext.DECIMAL64).setScale(9,
|
interestEarned = averageDailyBalance.multiply(periodicInterestRate, MathContext.DECIMAL64).setScale(9,
|
||||||
RoundingMode.valueOf(MoneyHelper.getRoundingMode()));
|
MoneyHelper.getRoundingMode());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+3
-3
@@ -467,7 +467,7 @@ public class DepositAccountWritePlatformServiceJpaRepositoryImpl implements Depo
|
|||||||
checkClientOrGroupActive(account);
|
checkClientOrGroupActive(account);
|
||||||
|
|
||||||
final LocalDate today = DateUtils.getLocalDateOfTenant();
|
final LocalDate today = DateUtils.getLocalDateOfTenant();
|
||||||
final MathContext mc = new MathContext(15, RoundingMode.valueOf(MoneyHelper.getRoundingMode()));
|
final MathContext mc = new MathContext(15, MoneyHelper.getRoundingMode());
|
||||||
boolean isInterestTransfer = false;
|
boolean isInterestTransfer = false;
|
||||||
|
|
||||||
account.calculateInterestUsing(mc, today, isInterestTransfer, isSavingsInterestPostingAtCurrentPeriodEnd,
|
account.calculateInterestUsing(mc, today, isInterestTransfer, isSavingsInterestPostingAtCurrentPeriodEnd,
|
||||||
@@ -511,7 +511,7 @@ public class DepositAccountWritePlatformServiceJpaRepositoryImpl implements Depo
|
|||||||
final Set<Long> existingReversedTransactionIds = new HashSet<>();
|
final Set<Long> existingReversedTransactionIds = new HashSet<>();
|
||||||
updateExistingTransactionsDetails(account, existingTransactionIds, existingReversedTransactionIds);
|
updateExistingTransactionsDetails(account, existingTransactionIds, existingReversedTransactionIds);
|
||||||
final LocalDate today = DateUtils.getLocalDateOfTenant();
|
final LocalDate today = DateUtils.getLocalDateOfTenant();
|
||||||
final MathContext mc = new MathContext(10, RoundingMode.valueOf(MoneyHelper.getRoundingMode()));
|
final MathContext mc = new MathContext(10, MoneyHelper.getRoundingMode());
|
||||||
boolean isInterestTransfer = false;
|
boolean isInterestTransfer = false;
|
||||||
account.postInterest(mc, today, isInterestTransfer, isSavingsInterestPostingAtCurrentPeriodEnd, financialYearBeginningMonth);
|
account.postInterest(mc, today, isInterestTransfer, isSavingsInterestPostingAtCurrentPeriodEnd, financialYearBeginningMonth);
|
||||||
this.savingAccountRepository.save(account);
|
this.savingAccountRepository.save(account);
|
||||||
@@ -660,7 +660,7 @@ public class DepositAccountWritePlatformServiceJpaRepositoryImpl implements Depo
|
|||||||
final Map<String, Object> changes = new LinkedHashMap<>();
|
final Map<String, Object> changes = new LinkedHashMap<>();
|
||||||
final PaymentDetail paymentDetail = this.paymentDetailWritePlatformService.createAndPersistPaymentDetail(command, changes);
|
final PaymentDetail paymentDetail = this.paymentDetailWritePlatformService.createAndPersistPaymentDetail(command, changes);
|
||||||
|
|
||||||
final MathContext mc = new MathContext(10, RoundingMode.valueOf(MoneyHelper.getRoundingMode()));
|
final MathContext mc = new MathContext(10, MoneyHelper.getRoundingMode());
|
||||||
account.undoTransaction(transactionId);
|
account.undoTransaction(transactionId);
|
||||||
|
|
||||||
SavingsAccountTransaction transaction = null;
|
SavingsAccountTransaction transaction = null;
|
||||||
|
|||||||
+4
-4
@@ -322,7 +322,7 @@ public class SavingsAccountWritePlatformServiceJpaRepositoryImpl implements Savi
|
|||||||
checkClientOrGroupActive(account);
|
checkClientOrGroupActive(account);
|
||||||
|
|
||||||
final LocalDate today = DateUtils.getLocalDateOfTenant();
|
final LocalDate today = DateUtils.getLocalDateOfTenant();
|
||||||
final MathContext mc = new MathContext(15, RoundingMode.valueOf(MoneyHelper.getRoundingMode()));
|
final MathContext mc = new MathContext(15, MoneyHelper.getRoundingMode());
|
||||||
boolean isInterestTransfer = false;
|
boolean isInterestTransfer = false;
|
||||||
account.calculateInterestUsing(mc, today, isInterestTransfer, isSavingsInterestPostingAtCurrentPeriodEnd,
|
account.calculateInterestUsing(mc, today, isInterestTransfer, isSavingsInterestPostingAtCurrentPeriodEnd,
|
||||||
financialYearBeginningMonth);
|
financialYearBeginningMonth);
|
||||||
@@ -367,7 +367,7 @@ public class SavingsAccountWritePlatformServiceJpaRepositoryImpl implements Savi
|
|||||||
final Set<Long> existingReversedTransactionIds = new HashSet<>();
|
final Set<Long> existingReversedTransactionIds = new HashSet<>();
|
||||||
updateExistingTransactionsDetails(account, existingTransactionIds, existingReversedTransactionIds);
|
updateExistingTransactionsDetails(account, existingTransactionIds, existingReversedTransactionIds);
|
||||||
final LocalDate today = DateUtils.getLocalDateOfTenant();
|
final LocalDate today = DateUtils.getLocalDateOfTenant();
|
||||||
final MathContext mc = new MathContext(10, RoundingMode.valueOf(MoneyHelper.getRoundingMode()));
|
final MathContext mc = new MathContext(10, MoneyHelper.getRoundingMode());
|
||||||
boolean isInterestTransfer = false;
|
boolean isInterestTransfer = false;
|
||||||
account.postInterest(mc, today, isInterestTransfer, isSavingsInterestPostingAtCurrentPeriodEnd, financialYearBeginningMonth);
|
account.postInterest(mc, today, isInterestTransfer, isSavingsInterestPostingAtCurrentPeriodEnd, financialYearBeginningMonth);
|
||||||
|
|
||||||
@@ -415,7 +415,7 @@ public class SavingsAccountWritePlatformServiceJpaRepositoryImpl implements Savi
|
|||||||
"Savings account transaction:" + transactionId + " update not allowed for this savings type", transactionId); }
|
"Savings account transaction:" + transactionId + " update not allowed for this savings type", transactionId); }
|
||||||
|
|
||||||
final LocalDate today = DateUtils.getLocalDateOfTenant();
|
final LocalDate today = DateUtils.getLocalDateOfTenant();
|
||||||
final MathContext mc = new MathContext(15, RoundingMode.valueOf(MoneyHelper.getRoundingMode()));
|
final MathContext mc = new MathContext(15, MoneyHelper.getRoundingMode());
|
||||||
|
|
||||||
if (account.isNotActive()) {
|
if (account.isNotActive()) {
|
||||||
throwValidationForActiveStatus(SavingsApiConstants.undoTransactionAction);
|
throwValidationForActiveStatus(SavingsApiConstants.undoTransactionAction);
|
||||||
@@ -497,7 +497,7 @@ public class SavingsAccountWritePlatformServiceJpaRepositoryImpl implements Savi
|
|||||||
final Map<String, Object> changes = new LinkedHashMap<>();
|
final Map<String, Object> changes = new LinkedHashMap<>();
|
||||||
final PaymentDetail paymentDetail = this.paymentDetailWritePlatformService.createAndPersistPaymentDetail(command, changes);
|
final PaymentDetail paymentDetail = this.paymentDetailWritePlatformService.createAndPersistPaymentDetail(command, changes);
|
||||||
|
|
||||||
final MathContext mc = new MathContext(10, RoundingMode.valueOf(MoneyHelper.getRoundingMode()));
|
final MathContext mc = new MathContext(10, MoneyHelper.getRoundingMode());
|
||||||
account.undoTransaction(transactionId);
|
account.undoTransaction(transactionId);
|
||||||
|
|
||||||
// for undo withdrawal fee
|
// for undo withdrawal fee
|
||||||
|
|||||||
+3
-2
@@ -6,6 +6,7 @@
|
|||||||
package org.mifosplatform.portfolio.loanaccount;
|
package org.mifosplatform.portfolio.loanaccount;
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
|
import java.math.RoundingMode;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.joda.time.LocalDate;
|
import org.joda.time.LocalDate;
|
||||||
@@ -33,9 +34,9 @@ public class AdhikarLoanRepaymentScheduleTransactionProcessorTest {
|
|||||||
@Before
|
@Before
|
||||||
public void setUpForEachTestCase() throws Exception {
|
public void setUpForEachTestCase() throws Exception {
|
||||||
|
|
||||||
Field field = MoneyHelper.class.getDeclaredField("roundingModeIntValue");
|
Field field = MoneyHelper.class.getDeclaredField("roundingMode");
|
||||||
field.setAccessible(true);
|
field.setAccessible(true);
|
||||||
field.setInt(null, 6);
|
field.set(null, RoundingMode.HALF_EVEN);
|
||||||
this.installments = LoanScheduleTestDataHelper.createSimpleLoanSchedule(this.july2nd, this.usDollars);
|
this.installments = LoanScheduleTestDataHelper.createSimpleLoanSchedule(this.july2nd, this.usDollars);
|
||||||
|
|
||||||
this.processor = new RBILoanRepaymentScheduleTransactionProcessor();
|
this.processor = new RBILoanRepaymentScheduleTransactionProcessor();
|
||||||
|
|||||||
Reference in New Issue
Block a user