Merge pull request #1118 from pramodn02/develop

Develop
This commit is contained in:
Vishwas Babu A J
2014-10-31 00:49:05 -07:00
5 changed files with 10 additions and 10 deletions
@@ -867,7 +867,7 @@ public class AccountingScenarioIntegrationTest {
runOndate = dateFormat.format(todayDate.getTime()); runOndate = dateFormat.format(todayDate.getTime());
this.periodicAccrualAccountingHelper.runPeriodicAccrualAccounting(runOndate); this.periodicAccrualAccountingHelper.runPeriodicAccrualAccounting(runOndate);
float interestPerDay = totalInterest / totalDaysInPeriod; float interestPerDay = (totalInterest / totalDaysInPeriod *4) - INTEREST_3_DAYS ;
interestPerDay = new Float(numberFormat.format(interestPerDay)); interestPerDay = new Float(numberFormat.format(interestPerDay));
this.loanTransactionHelper.checkAccrualTransactionForRepayment(getDateAsLocalDate(runOndate), interestPerDay, NEXT_FEE_PORTION, this.loanTransactionHelper.checkAccrualTransactionForRepayment(getDateAsLocalDate(runOndate), interestPerDay, NEXT_FEE_PORTION,
NEXT_PENALTY_PORTION, loanID); NEXT_PENALTY_PORTION, loanID);
@@ -569,7 +569,7 @@ public class SchedulerJobsTestResults {
DateFormat monthDayFormat = new SimpleDateFormat("dd MMMM", Locale.US); DateFormat monthDayFormat = new SimpleDateFormat("dd MMMM", Locale.US);
Calendar todaysDate = Calendar.getInstance(); Calendar todaysDate = Calendar.getInstance();
todaysDate.add(Calendar.MONTH, -1); todaysDate.add(Calendar.WEEK_OF_YEAR, -1);
final String VALID_FROM = dateFormat.format(todaysDate.getTime()); final String VALID_FROM = dateFormat.format(todaysDate.getTime());
final String MONTH_DAY = monthDayFormat.format(todaysDate.getTime()); final String MONTH_DAY = monthDayFormat.format(todaysDate.getTime());
@@ -77,7 +77,7 @@ public class StandingInstructionsHelper {
map.put("validTill", validTo); map.put("validTill", validTo);
map.put("recurrenceType", RECURRENCE_TYPE_PERIODIC); map.put("recurrenceType", RECURRENCE_TYPE_PERIODIC);
map.put("recurrenceInterval", "1"); map.put("recurrenceInterval", "1");
map.put("recurrenceFrequency", RECURRENCE_FREQUENCY_MONTHS); map.put("recurrenceFrequency", RECURRENCE_FREQUENCY_WEEKS);
map.put("recurrenceOnMonthDay", monthDay); map.put("recurrenceOnMonthDay", monthDay);
String savingsApplicationJSON = new Gson().toJson(map); String savingsApplicationJSON = new Gson().toJson(map);
System.out.println(savingsApplicationJSON); System.out.println(savingsApplicationJSON);
@@ -152,7 +152,7 @@ public class LoanAccrualWritePlatformServiceImpl implements LoanAccrualWritePlat
updateCharges(loanChargeMap.get(accrualData.getLoanId()), accrualData, accrualData.getFromDateAsLocaldate(), updateCharges(loanChargeMap.get(accrualData.getLoanId()), accrualData, accrualData.getFromDateAsLocaldate(),
tilldate); tilldate);
updateInterestIncome(accrualData, loanWaiverTansactions, loanWaiverSchedules, tilldate); updateInterestIncome(accrualData, loanWaiverTansactions, loanWaiverSchedules, tilldate);
addAccrualTillSpecificDate(tilldate, accrualData, accruredTill); addAccrualTillSpecificDate(tilldate, accrualData);
} }
} else { } else {
updateCharges(loanChargeMap.get(accrualData.getLoanId()), accrualData, accrualData.getFromDateAsLocaldate(), updateCharges(loanChargeMap.get(accrualData.getLoanId()), accrualData, accrualData.getFromDateAsLocaldate(),
@@ -176,8 +176,7 @@ public class LoanAccrualWritePlatformServiceImpl implements LoanAccrualWritePlat
return sb.toString(); return sb.toString();
} }
private void addAccrualTillSpecificDate(final LocalDate tilldate, final LoanScheduleAccrualData accrualData, private void addAccrualTillSpecificDate(final LocalDate tilldate, final LoanScheduleAccrualData accrualData) throws Exception {
final LocalDate accruredTill) throws Exception {
LocalDate interestStartDate = accrualData.getFromDateAsLocaldate(); LocalDate interestStartDate = accrualData.getFromDateAsLocaldate();
if (accrualData.getInterestCalculatedFrom() != null if (accrualData.getInterestCalculatedFrom() != null
&& accrualData.getFromDateAsLocaldate().isBefore(accrualData.getInterestCalculatedFrom())) { && accrualData.getFromDateAsLocaldate().isBefore(accrualData.getInterestCalculatedFrom())) {
@@ -189,10 +188,7 @@ public class LoanAccrualWritePlatformServiceImpl implements LoanAccrualWritePlat
} }
int totalNumberOfDays = Days.daysBetween(interestStartDate, accrualData.getDueDateAsLocaldate()).getDays(); int totalNumberOfDays = Days.daysBetween(interestStartDate, accrualData.getDueDateAsLocaldate()).getDays();
LocalDate startDate = accruredTill; LocalDate startDate = accrualData.getFromDateAsLocaldate();
if (startDate == null) {
startDate = accrualData.getFromDateAsLocaldate();
}
if (accrualData.getInterestCalculatedFrom() != null && startDate.isBefore(accrualData.getInterestCalculatedFrom())) { if (accrualData.getInterestCalculatedFrom() != null && startDate.isBefore(accrualData.getInterestCalculatedFrom())) {
if (accrualData.getInterestCalculatedFrom().isBefore(tilldate)) { if (accrualData.getInterestCalculatedFrom().isBefore(tilldate)) {
startDate = accrualData.getInterestCalculatedFrom(); startDate = accrualData.getInterestCalculatedFrom();
@@ -222,6 +218,7 @@ public class LoanAccrualWritePlatformServiceImpl implements LoanAccrualWritePlat
if (totalAccInterest == null) { if (totalAccInterest == null) {
totalAccInterest = BigDecimal.ZERO; totalAccInterest = BigDecimal.ZERO;
} }
interestportion = interestportion.subtract(totalAccInterest);
amount = amount.add(interestportion); amount = amount.add(interestportion);
totalAccInterest = totalAccInterest.add(interestportion); totalAccInterest = totalAccInterest.add(interestportion);
if (interestportion.compareTo(BigDecimal.ZERO) == 0) { 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."; final String defaultUserMessage = "Installment charge cannot be added to the loan.";
throw new LoanChargeCannotBeAddedException("loanCharge", "overdue.charge", defaultUserMessage, null, chargeDefinition.getName()); 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()); final List<Long> existingTransactionIds = new ArrayList<>(loan.findExistingTransactionIds());