MIFOSX-1632 : corrected accruals(intriduced with fine tune) for specific due date

This commit is contained in:
Pramod Nuthakki
2014-10-31 11:11:44 +05:30
parent 8a9c05e212
commit 1164bf40a3
3 changed files with 8 additions and 8 deletions
@@ -867,7 +867,7 @@ public class AccountingScenarioIntegrationTest {
runOndate = dateFormat.format(todayDate.getTime());
this.periodicAccrualAccountingHelper.runPeriodicAccrualAccounting(runOndate);
float interestPerDay = totalInterest / totalDaysInPeriod;
float interestPerDay = (totalInterest / totalDaysInPeriod *4) - INTEREST_3_DAYS ;
interestPerDay = new Float(numberFormat.format(interestPerDay));
this.loanTransactionHelper.checkAccrualTransactionForRepayment(getDateAsLocalDate(runOndate), interestPerDay, NEXT_FEE_PORTION,
NEXT_PENALTY_PORTION, loanID);
@@ -152,7 +152,7 @@ public class LoanAccrualWritePlatformServiceImpl implements LoanAccrualWritePlat
updateCharges(loanChargeMap.get(accrualData.getLoanId()), accrualData, accrualData.getFromDateAsLocaldate(),
tilldate);
updateInterestIncome(accrualData, loanWaiverTansactions, loanWaiverSchedules, tilldate);
addAccrualTillSpecificDate(tilldate, accrualData, accruredTill);
addAccrualTillSpecificDate(tilldate, accrualData);
}
} else {
updateCharges(loanChargeMap.get(accrualData.getLoanId()), accrualData, accrualData.getFromDateAsLocaldate(),
@@ -176,8 +176,7 @@ public class LoanAccrualWritePlatformServiceImpl implements LoanAccrualWritePlat
return sb.toString();
}
private void addAccrualTillSpecificDate(final LocalDate tilldate, final LoanScheduleAccrualData accrualData,
final LocalDate accruredTill) throws Exception {
private void addAccrualTillSpecificDate(final LocalDate tilldate, final LoanScheduleAccrualData accrualData) throws Exception {
LocalDate interestStartDate = accrualData.getFromDateAsLocaldate();
if (accrualData.getInterestCalculatedFrom() != null
&& accrualData.getFromDateAsLocaldate().isBefore(accrualData.getInterestCalculatedFrom())) {
@@ -189,10 +188,7 @@ public class LoanAccrualWritePlatformServiceImpl implements LoanAccrualWritePlat
}
int totalNumberOfDays = Days.daysBetween(interestStartDate, accrualData.getDueDateAsLocaldate()).getDays();
LocalDate startDate = accruredTill;
if (startDate == null) {
startDate = accrualData.getFromDateAsLocaldate();
}
LocalDate startDate = accrualData.getFromDateAsLocaldate();
if (accrualData.getInterestCalculatedFrom() != null && startDate.isBefore(accrualData.getInterestCalculatedFrom())) {
if (accrualData.getInterestCalculatedFrom().isBefore(tilldate)) {
startDate = accrualData.getInterestCalculatedFrom();
@@ -222,6 +218,7 @@ public class LoanAccrualWritePlatformServiceImpl implements LoanAccrualWritePlat
if (totalAccInterest == null) {
totalAccInterest = BigDecimal.ZERO;
}
interestportion = interestportion.subtract(totalAccInterest);
amount = amount.add(interestportion);
totalAccInterest = totalAccInterest.add(interestportion);
if (interestportion.compareTo(BigDecimal.ZERO) == 0) {
@@ -1183,6 +1183,9 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
final String defaultUserMessage = "Installment charge cannot be added to the loan.";
throw new LoanChargeCannotBeAddedException("loanCharge", "overdue.charge", defaultUserMessage, null, chargeDefinition.getName());
} else if(loanCharge.getDueLocalDate() != null && loanCharge.getDueLocalDate().isBefore(loan.getLastUserTransactionForChargeCalc())){
final String defaultUserMessage = "charge after last transaction date can not be added to loan.";
throw new LoanChargeCannotBeAddedException("loanCharge", "date.is.after.last.transaction.date", defaultUserMessage, null, chargeDefinition.getName());
}
final List<Long> existingTransactionIds = new ArrayList<>(loan.findExistingTransactionIds());