Merge pull request #1005 from pramodn02/develop
MIFOSX-1415 : Modified loan to capture last accrued date
This commit is contained in:
+2
@@ -0,0 +1,2 @@
|
||||
ALTER TABLE `m_loan`
|
||||
ADD COLUMN `accrued_till` DATE NULL DEFAULT NULL AFTER `total_recovered_derived`;
|
||||
+10
-1
@@ -3,9 +3,11 @@ package org.mifosplatform.portfolio.loanaccount.service;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
|
||||
@@ -50,10 +52,14 @@ public class LoanAccrualWritePlatformServiceImpl implements LoanAccrualWritePlat
|
||||
public void addAccrualAccounting() throws JobExecutionException {
|
||||
Collection<LoanScheduleAccrualData> loanScheduleAccrualDatas = this.loanReadPlatformService.retriveScheduleAccrualData();
|
||||
StringBuilder sb = new StringBuilder();
|
||||
Set<Long> loansIds = new HashSet<>();
|
||||
for (final LoanScheduleAccrualData accrualData : loanScheduleAccrualDatas) {
|
||||
try {
|
||||
addAccrualAccounting(accrualData);
|
||||
if (!loansIds.contains(accrualData.getLoanId())) {
|
||||
addAccrualAccounting(accrualData);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
loansIds.add(accrualData.getLoanId());
|
||||
Throwable realCause = e;
|
||||
if (e.getCause() != null) {
|
||||
realCause = e.getCause();
|
||||
@@ -127,6 +133,9 @@ public class LoanAccrualWritePlatformServiceImpl implements LoanAccrualWritePlat
|
||||
+ "accrual_penalty_charges_derived=? WHERE id=?";
|
||||
this.jdbcTemplate.update(repaymetUpdatesql, totalAccInterest, totalAccFee, totalAccPenalty,
|
||||
scheduleAccrualData.getRepaymentScheduleId());
|
||||
|
||||
String updateLoan = "UPDATE m_loan SET accrued_till=? WHERE id=?";
|
||||
this.jdbcTemplate.update(updateLoan, scheduleAccrualData.getDueDate(), scheduleAccrualData.getLoanId());
|
||||
final Map<String, Object> accountingBridgeData = deriveAccountingBridgeData(scheduleAccrualData, transactionMap);
|
||||
this.journalEntryWritePlatformService.createJournalEntriesForLoan(accountingBridgeData);
|
||||
} catch (Exception e) {
|
||||
|
||||
+1
-1
@@ -1323,7 +1323,7 @@ public class LoanReadPlatformServiceImpl implements LoanReadPlatformService {
|
||||
.append(" where ((if(ls.fee_charges_waived_derived is null , ls.fee_charges_amount,(ls.fee_charges_amount-ls.fee_charges_waived_derived)) <> if(ls.accrual_fee_charges_derived is null,0, ls.accrual_fee_charges_derived))")
|
||||
.append(" or (if(ls.penalty_charges_waived_derived is null , ls.penalty_charges_amount,(ls.penalty_charges_amount-ls.penalty_charges_waived_derived)) <> if(ls.accrual_penalty_charges_derived is null,0,ls.accrual_penalty_charges_derived))")
|
||||
.append(" or (if(ls.interest_waived_derived is null , ls.interest_amount,(ls.interest_amount-ls.interest_waived_derived)) <> if(ls.accrual_interest_derived is null,0,ls.accrual_interest_derived)))")
|
||||
.append(" and loan.loan_status_id=? and mpl.accounting_type=? and loan.is_npa=0 and ls.duedate <= CURDATE()");
|
||||
.append(" and loan.loan_status_id=? and mpl.accounting_type=? and loan.is_npa=0 and ls.duedate <= CURDATE() order by loan.id,ls.duedate");
|
||||
return this.jdbcTemplate.query(sqlBuilder.toString(), mapper, new Object[] { LoanStatus.ACTIVE.getValue(),
|
||||
AccountingRuleType.ACCRUAL_PERIODIC.getValue() });
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user