From 6e521f81ac68e059b89351a4579038fae1381e1a Mon Sep 17 00:00:00 2001 From: sachinkulkarni12 Date: Mon, 7 Mar 2016 16:50:43 +0530 Subject: [PATCH] fix for Junit test cases --- .../service/LoanReadPlatformServiceImpl.java | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanReadPlatformServiceImpl.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanReadPlatformServiceImpl.java index b39aaf77f..3f0e3a17e 100755 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanReadPlatformServiceImpl.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanReadPlatformServiceImpl.java @@ -1564,9 +1564,6 @@ public class LoanReadPlatformServiceImpl implements LoanReadPlatformService { LoanScheduleAccrualMapper mapper = new LoanScheduleAccrualMapper(); Date organisationStartDate = this.configurationDomainService.retrieveOrganisationStartDate(); - if(organisationStartDate == null){ - organisationStartDate = new Date(); - } final StringBuilder sqlBuilder = new StringBuilder(400); sqlBuilder .append("select ") @@ -1574,7 +1571,11 @@ public class LoanReadPlatformServiceImpl implements LoanReadPlatformService { .append(" where ((ls.fee_charges_amount <> if(ls.accrual_fee_charges_derived is null,0, ls.accrual_fee_charges_derived))") .append(" or ( ls.penalty_charges_amount <> if(ls.accrual_penalty_charges_derived is null,0,ls.accrual_penalty_charges_derived))") .append(" or ( ls.interest_amount <> if(ls.accrual_interest_derived is null,0,ls.accrual_interest_derived)))") - .append(" and ls.duedate > :organisationstartdate and loan.loan_status_id=:active and mpl.accounting_type=:type and loan.is_npa=0 and ls.duedate <= CURDATE() order by loan.id,ls.duedate"); + .append(" and loan.loan_status_id=:active and mpl.accounting_type=:type and loan.is_npa=0 and ls.duedate <= CURDATE() "); + if(organisationStartDate != null){ + sqlBuilder.append(" and ls.duedate > :organisationstartdate "); + } + sqlBuilder.append(" order by loan.id,ls.duedate "); Map paramMap = new HashMap<>(3); paramMap.put("active", LoanStatus.ACTIVE.getValue()); paramMap.put("type", AccountingRuleType.ACCRUAL_PERIODIC.getValue()); @@ -1588,9 +1589,6 @@ public class LoanReadPlatformServiceImpl implements LoanReadPlatformService { LoanSchedulePeriodicAccrualMapper mapper = new LoanSchedulePeriodicAccrualMapper(); Date organisationStartDate = this.configurationDomainService.retrieveOrganisationStartDate(); - if(organisationStartDate == null){ - organisationStartDate = new Date(); - } final StringBuilder sqlBuilder = new StringBuilder(400); sqlBuilder .append("select ") @@ -1598,8 +1596,12 @@ public class LoanReadPlatformServiceImpl implements LoanReadPlatformService { .append(" where ((ls.fee_charges_amount <> if(ls.accrual_fee_charges_derived is null,0, ls.accrual_fee_charges_derived))") .append(" or (ls.penalty_charges_amount <> if(ls.accrual_penalty_charges_derived is null,0,ls.accrual_penalty_charges_derived))") .append(" or (ls.interest_amount <> if(ls.accrual_interest_derived is null,0,ls.accrual_interest_derived)))") - .append(" and loan.loan_status_id=:active and mpl.accounting_type=:type and ls.duedate > :organisationstartdate and (loan.closedon_date <= :tilldate or loan.closedon_date is null)") - .append(" and loan.is_npa=0 and (ls.duedate <= :tilldate or (ls.duedate > :tilldate and ls.fromdate < :tilldate)) order by loan.id,ls.duedate"); + .append(" and loan.loan_status_id=:active and mpl.accounting_type=:type and (loan.closedon_date <= :tilldate or loan.closedon_date is null)") + .append(" and loan.is_npa=0 and (ls.duedate <= :tilldate or (ls.duedate > :tilldate and ls.fromdate < :tilldate)) "); + if(organisationStartDate != null){ + sqlBuilder.append(" and ls.duedate > :organisationstartdate "); + } + sqlBuilder.append(" order by loan.id,ls.duedate "); Map paramMap = new HashMap<>(4); paramMap.put("active", LoanStatus.ACTIVE.getValue()); paramMap.put("type", AccountingRuleType.ACCRUAL_PERIODIC.getValue());