Quick code cleaning for client and loan: around the native queries
This commit is contained in:
committed by
Arnold Gálovics
parent
8c023e74a8
commit
81be863739
+1
-1
@@ -67,7 +67,7 @@ public class ClientAddressReadPlatformServiceImpl implements ClientAddressReadPl
|
||||
final ClientAddrMapper rm = new ClientAddrMapper();
|
||||
final String sql = "select " + rm.schema() + " where fld.entity=?";
|
||||
|
||||
return this.jdbcTemplate.query(sql, rm, new Object[] { entity }); // NOSONAR
|
||||
return this.jdbcTemplate.query(sql, rm, entity); // NOSONAR
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+4
-3
@@ -23,6 +23,7 @@ import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.time.LocalDate;
|
||||
import java.util.Collection;
|
||||
import org.apache.commons.lang3.BooleanUtils;
|
||||
import org.apache.fineract.infrastructure.core.data.EnumOptionData;
|
||||
import org.apache.fineract.infrastructure.core.domain.JdbcSupport;
|
||||
import org.apache.fineract.infrastructure.core.service.Page;
|
||||
@@ -128,7 +129,7 @@ public class ClientChargeReadPlatformServiceImpl implements ClientChargeReadPlat
|
||||
|
||||
final String sql = "select " + rm.schema() + " where cc.client_id=? and cc.id=? ";
|
||||
|
||||
return this.jdbcTemplate.queryForObject(sql, rm, new Object[] { clientId, clientChargeId }); // NOSONAR
|
||||
return this.jdbcTemplate.queryForObject(sql, rm, clientId, clientChargeId); // NOSONAR
|
||||
} catch (final EmptyResultDataAccessException e) {
|
||||
throw new ClientChargeNotFoundException(clientChargeId, clientId, e);
|
||||
}
|
||||
@@ -149,9 +150,9 @@ public class ClientChargeReadPlatformServiceImpl implements ClientChargeReadPlat
|
||||
}
|
||||
|
||||
// filter for paid charges
|
||||
if (pendingPayment != null && pendingPayment) {
|
||||
if (BooleanUtils.isTrue(pendingPayment)) {
|
||||
sqlBuilder.append(" and ( cc.is_paid_derived = false and cc.waived = false) ");
|
||||
} else if (pendingPayment != null && !pendingPayment) {
|
||||
} else if (BooleanUtils.isFalse(pendingPayment)) {
|
||||
sqlBuilder.append(" and (cc.is_paid_derived = true or cc.waived = true) ");
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -98,7 +98,7 @@ public class ClientFamilyMembersReadPlatformServiceImpl implements ClientFamilyM
|
||||
final ClientFamilyMembersMapper rm = new ClientFamilyMembersMapper();
|
||||
final String sql = "select " + rm.schema() + " where fmb.client_id=?";
|
||||
|
||||
return this.jdbcTemplate.query(sql, rm, new Object[] { clientId }); // NOSONAR
|
||||
return this.jdbcTemplate.query(sql, rm, clientId); // NOSONAR
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -109,7 +109,7 @@ public class ClientFamilyMembersReadPlatformServiceImpl implements ClientFamilyM
|
||||
final ClientFamilyMembersMapper rm = new ClientFamilyMembersMapper();
|
||||
final String sql = "select " + rm.schema() + " where fmb.id=? ";
|
||||
|
||||
return this.jdbcTemplate.queryForObject(sql, rm, new Object[] { id }); // NOSONAR
|
||||
return this.jdbcTemplate.queryForObject(sql, rm, id); // NOSONAR
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+2
-2
@@ -54,7 +54,7 @@ public class ClientIdentifierReadPlatformServiceImpl implements ClientIdentifier
|
||||
|
||||
sql += " order by ci.id";
|
||||
|
||||
return this.jdbcTemplate.query(sql, rm, new Object[] { clientId, hierarchySearchString }); // NOSONAR
|
||||
return this.jdbcTemplate.query(sql, rm, clientId, hierarchySearchString); // NOSONAR
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -71,7 +71,7 @@ public class ClientIdentifierReadPlatformServiceImpl implements ClientIdentifier
|
||||
sql += " and ci.id = ?";
|
||||
|
||||
final ClientIdentifierData clientIdentifierData = this.jdbcTemplate.queryForObject(sql, rm, // NOSONAR
|
||||
new Object[] { clientId, hierarchySearchString, clientIdentifierId });
|
||||
clientId, hierarchySearchString, clientIdentifierId);
|
||||
|
||||
return clientIdentifierData;
|
||||
} catch (final EmptyResultDataAccessException e) {
|
||||
|
||||
+8
-8
@@ -297,7 +297,7 @@ public class ClientReadPlatformServiceImpl implements ClientReadPlatformService
|
||||
final String sql = "select " + this.clientMapper.schema()
|
||||
+ " where ( o.hierarchy like ? or transferToOffice.hierarchy like ?) and c.id = ?";
|
||||
final ClientData clientData = this.jdbcTemplate.queryForObject(sql, this.clientMapper, // NOSONAR
|
||||
new Object[] { hierarchySearchString, hierarchySearchString, clientId });
|
||||
hierarchySearchString, hierarchySearchString, clientId);
|
||||
|
||||
// Get client collaterals
|
||||
final Collection<ClientCollateralManagement> clientCollateralManagements = this.clientCollateralManagementRepositoryWrapper
|
||||
@@ -315,7 +315,7 @@ public class ClientReadPlatformServiceImpl implements ClientReadPlatformService
|
||||
final String clientGroupsSql = "select " + this.clientGroupsMapper.parentGroupsSchema();
|
||||
|
||||
final Collection<GroupGeneralData> parentGroups = this.jdbcTemplate.query(clientGroupsSql, this.clientGroupsMapper, // NOSONAR
|
||||
new Object[] { clientId });
|
||||
clientId);
|
||||
|
||||
return ClientData.setParentGroups(clientData, parentGroups, clientCollateralManagementDataSet);
|
||||
|
||||
@@ -341,7 +341,7 @@ public class ClientReadPlatformServiceImpl implements ClientReadPlatformService
|
||||
|
||||
final String sql = "select " + this.lookupMapper.schema() + " where c.office_id = ? and c.status_enum != ?";
|
||||
|
||||
return this.jdbcTemplate.query(sql, this.lookupMapper, new Object[] { officeId, ClientStatus.CLOSED.getValue() }); // NOSONAR
|
||||
return this.jdbcTemplate.query(sql, this.lookupMapper, officeId, ClientStatus.CLOSED.getValue()); // NOSONAR
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -353,7 +353,7 @@ public class ClientReadPlatformServiceImpl implements ClientReadPlatformService
|
||||
|
||||
final String sql = "select " + this.membersOfGroupMapper.schema() + " where o.hierarchy like ? and pgc.group_id = ?";
|
||||
|
||||
return this.jdbcTemplate.query(sql, this.membersOfGroupMapper, new Object[] { hierarchySearchString, groupId }); // NOSONAR
|
||||
return this.jdbcTemplate.query(sql, this.membersOfGroupMapper, hierarchySearchString, groupId); // NOSONAR
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -367,7 +367,7 @@ public class ClientReadPlatformServiceImpl implements ClientReadPlatformService
|
||||
+ " where o.hierarchy like ? and pgc.group_id = ? and c.status_enum = ? ";
|
||||
|
||||
return this.jdbcTemplate.query(sql, this.membersOfGroupMapper, // NOSONAR
|
||||
new Object[] { hierarchySearchString, groupId, ClientStatus.ACTIVE.getValue() });
|
||||
hierarchySearchString, groupId, ClientStatus.ACTIVE.getValue());
|
||||
}
|
||||
|
||||
private static final class ClientMembersOfGroupMapper implements RowMapper<ClientData> {
|
||||
@@ -556,7 +556,7 @@ public class ClientReadPlatformServiceImpl implements ClientReadPlatformService
|
||||
+ " left join m_group g on pgc.group_id=g.id where o.hierarchy like ? and g.parent_id = ? and c.status_enum = ? group by c.id";
|
||||
|
||||
return this.jdbcTemplate.query(sql, this.membersOfGroupMapper, // NOSONAR
|
||||
new Object[] { hierarchySearchString, centerId, ClientStatus.ACTIVE.getValue() });
|
||||
hierarchySearchString, centerId, ClientStatus.ACTIVE.getValue());
|
||||
}
|
||||
|
||||
private static final class ClientMapper implements RowMapper<ClientData> {
|
||||
@@ -788,7 +788,7 @@ public class ClientReadPlatformServiceImpl implements ClientReadPlatformService
|
||||
|
||||
final String sql = "select " + mapper.clientLookupByIdentifierSchema();
|
||||
|
||||
return this.jdbcTemplate.queryForObject(sql, mapper, new Object[] { identifierTypeId, identifierKey }); // NOSONAR
|
||||
return this.jdbcTemplate.queryForObject(sql, mapper, identifierTypeId, identifierKey); // NOSONAR
|
||||
} catch (final EmptyResultDataAccessException e) {
|
||||
return null;
|
||||
}
|
||||
@@ -867,6 +867,6 @@ public class ClientReadPlatformServiceImpl implements ClientReadPlatformService
|
||||
@Override
|
||||
public Collection<Long> retrieveUserClients(Long aUserID) {
|
||||
String sql = "SELECT m.client_id FROM m_selfservice_user_client_mapping m INNER JOIN m_client c ON c.id = m.client_id WHERE m.appuser_id = ?";
|
||||
return jdbcTemplate.queryForList(sql, Long.class, new Object[] { aUserID });
|
||||
return jdbcTemplate.queryForList(sql, Long.class, aUserID);
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -177,7 +177,7 @@ public class ClientTransactionReadPlatformServiceImpl implements ClientTransacti
|
||||
public ClientTransactionData retrieveTransaction(Long clientId, Long transactionId) {
|
||||
try {
|
||||
final String sql = "select " + this.clientTransactionMapper.schema() + " where c.id = ? and tr.id= ?";
|
||||
return this.jdbcTemplate.queryForObject(sql, this.clientTransactionMapper, new Object[] { clientId, transactionId }); // NOSONAR
|
||||
return this.jdbcTemplate.queryForObject(sql, this.clientTransactionMapper, clientId, transactionId); // NOSONAR
|
||||
} catch (final EmptyResultDataAccessException e) {
|
||||
throw new ClientTransactionNotFoundException(clientId, transactionId, e);
|
||||
}
|
||||
|
||||
+6
-8
@@ -214,7 +214,7 @@ public class GuarantorReadPlatformServiceImpl implements GuarantorReadPlatformSe
|
||||
public GuarantorFundingData mapRow(final ResultSet rs, final int rowNum) throws SQLException {
|
||||
GuarantorFundingData guarantorFundingData = null;
|
||||
final Long id = rs.getLong("gfdId");
|
||||
if (id != null && id > 0) {
|
||||
if (id > 0) {
|
||||
final BigDecimal amount = JdbcSupport.getBigDecimalDefaultToZeroIfNull(rs, "amount");
|
||||
final BigDecimal amountReleased = JdbcSupport.getBigDecimalDefaultToZeroIfNull(rs, "amountReleased");
|
||||
final BigDecimal amountRemaining = JdbcSupport.getBigDecimalDefaultToZeroIfNull(rs, "amountRemaining");
|
||||
@@ -231,7 +231,7 @@ public class GuarantorReadPlatformServiceImpl implements GuarantorReadPlatformSe
|
||||
guarantorTransactions.add(guarantorTransactionData);
|
||||
while (rs.next()) {
|
||||
final Long tempFundId = rs.getLong("gfdId");
|
||||
if (tempFundId != null && tempFundId.equals(id)) {
|
||||
if (tempFundId.equals(id)) {
|
||||
guarantorTransactionData = this.guarantorTransactionMapper.mapRow(rs, rowNum);
|
||||
guarantorTransactions.add(guarantorTransactionData);
|
||||
} else {
|
||||
@@ -276,11 +276,9 @@ public class GuarantorReadPlatformServiceImpl implements GuarantorReadPlatformSe
|
||||
EnumOptionData transactionType = SavingsEnumerations.onHoldTransactionType(transactionTypeEnum);
|
||||
final boolean reversed = rs.getBoolean("reversed");
|
||||
final boolean transactionReversed = rs.getBoolean("transactionReversed");
|
||||
if (id != null) {
|
||||
DepositAccountOnHoldTransactionData onHoldTransactionData = DepositAccountOnHoldTransactionData.instance(transactionId,
|
||||
amount, transactionType, date, transactionReversed);
|
||||
guarantorTransactionData = GuarantorTransactionData.instance(id, onHoldTransactionData, null, reversed);
|
||||
}
|
||||
DepositAccountOnHoldTransactionData onHoldTransactionData = DepositAccountOnHoldTransactionData.instance(transactionId, amount,
|
||||
transactionType, date, transactionReversed);
|
||||
guarantorTransactionData = GuarantorTransactionData.instance(id, onHoldTransactionData, null, reversed);
|
||||
return guarantorTransactionData;
|
||||
}
|
||||
|
||||
@@ -305,7 +303,7 @@ public class GuarantorReadPlatformServiceImpl implements GuarantorReadPlatformSe
|
||||
final ObligeeMapper rm = new ObligeeMapper();
|
||||
String sql = rm.schema();
|
||||
try {
|
||||
return this.jdbcTemplate.query(sql, rm, new Object[] { clientId });
|
||||
return this.jdbcTemplate.query(sql, rm, clientId);
|
||||
} catch (final EmptyResultDataAccessException e) {
|
||||
return null;
|
||||
}
|
||||
|
||||
+4
-4
@@ -80,7 +80,7 @@ public class LoanScheduleHistoryReadPlatformServiceImpl implements LoanScheduleH
|
||||
final String sql = "select " + fullResultsetExtractor.schema()
|
||||
+ " where ls.loan_id = ? and ls.version = ? order by ls.loan_id, ls.installment";
|
||||
|
||||
return this.jdbcTemplate.query(sql, fullResultsetExtractor, new Object[] { loanId, versionNumber }); // NOSONAR
|
||||
return this.jdbcTemplate.query(sql, fullResultsetExtractor, loanId, versionNumber); // NOSONAR
|
||||
} catch (final EmptyResultDataAccessException e) {
|
||||
throw new LoanNotFoundException(loanId, e);
|
||||
}
|
||||
@@ -142,7 +142,7 @@ public class LoanScheduleHistoryReadPlatformServiceImpl implements LoanScheduleH
|
||||
totalFeeChargesCharged = totalFeeChargesCharged.plus(disbursementPeriod.feeChargesDue());
|
||||
totalRepaymentExpected = totalRepaymentExpected.plus(disbursementPeriod.feeChargesDue());
|
||||
|
||||
Integer loanTermInDays = Integer.valueOf(0);
|
||||
Integer loanTermInDays = 0;
|
||||
while (rs.next()) {
|
||||
final Integer period = JdbcSupport.getInteger(rs, "period");
|
||||
LocalDate fromDate = JdbcSupport.getLocalDate(rs, "fromDate");
|
||||
@@ -168,10 +168,10 @@ public class LoanScheduleHistoryReadPlatformServiceImpl implements LoanScheduleH
|
||||
totalPrincipalDisbursed = totalPrincipalDisbursed.add(principal);
|
||||
}
|
||||
|
||||
Integer daysInPeriod = Integer.valueOf(0);
|
||||
Integer daysInPeriod = 0;
|
||||
if (fromDate != null) {
|
||||
daysInPeriod = Math.toIntExact(ChronoUnit.DAYS.between(fromDate, dueDate));
|
||||
loanTermInDays = Integer.valueOf(loanTermInDays.intValue() + daysInPeriod.intValue());
|
||||
loanTermInDays = loanTermInDays + daysInPeriod;
|
||||
}
|
||||
|
||||
final BigDecimal principalDue = JdbcSupport.getBigDecimalDefaultToZeroIfNull(rs, "principalDue");
|
||||
|
||||
+6
-8
@@ -182,10 +182,8 @@ public class LoanRescheduleRequestReadPlatformServiceImpl implements LoanResched
|
||||
final boolean isSpecificToInstallment = rs.getBoolean("isSpecificToInstallment");
|
||||
final int termType = rs.getInt("termType");
|
||||
|
||||
final LoanTermVariationsData loanTermVariationsData = new LoanTermVariationsData(id,
|
||||
LoanEnumerations.loanvariationType(termType), variationApplicableFrom, decimalValue, dateValue,
|
||||
isSpecificToInstallment);
|
||||
return loanTermVariationsData;
|
||||
return new LoanTermVariationsData(id, LoanEnumerations.loanvariationType(termType), variationApplicableFrom, decimalValue,
|
||||
dateValue, isSpecificToInstallment);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -229,7 +227,7 @@ public class LoanRescheduleRequestReadPlatformServiceImpl implements LoanResched
|
||||
this.loanRepositoryWrapper.findOneWithNotFoundDetection(loanId);
|
||||
final String sql = "select " + this.loanRescheduleRequestRowMapper.schema() + " where lr.loan_id = ?";
|
||||
|
||||
return this.jdbcTemplate.query(sql, this.loanRescheduleRequestRowMapper, new Object[] { loanId }); // NOSONAR
|
||||
return this.jdbcTemplate.query(sql, this.loanRescheduleRequestRowMapper, loanId); // NOSONAR
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -238,7 +236,7 @@ public class LoanRescheduleRequestReadPlatformServiceImpl implements LoanResched
|
||||
try {
|
||||
final String sql = "select " + this.loanRescheduleRequestRowMapper.schema() + " where lr.id = ?";
|
||||
|
||||
return this.jdbcTemplate.queryForObject(sql, this.loanRescheduleRequestRowMapper, new Object[] { requestId }); // NOSONAR
|
||||
return this.jdbcTemplate.queryForObject(sql, this.loanRescheduleRequestRowMapper, requestId); // NOSONAR
|
||||
}
|
||||
|
||||
catch (final EmptyResultDataAccessException e) {
|
||||
@@ -250,7 +248,7 @@ public class LoanRescheduleRequestReadPlatformServiceImpl implements LoanResched
|
||||
public List<LoanRescheduleRequestData> readLoanRescheduleRequests(Long loanId, Integer statusEnum) {
|
||||
this.loanRepositoryWrapper.findOneWithNotFoundDetection(loanId);
|
||||
final String sql = "select " + this.loanRescheduleRequestRowMapper.schema() + " where lr.loan_id = ?" + " and lr.status_enum = ?";
|
||||
return this.jdbcTemplate.query(sql, this.loanRescheduleRequestRowMapper, new Object[] { loanId, statusEnum }); // NOSONAR
|
||||
return this.jdbcTemplate.query(sql, this.loanRescheduleRequestRowMapper, loanId, statusEnum); // NOSONAR
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -288,7 +286,7 @@ public class LoanRescheduleRequestReadPlatformServiceImpl implements LoanResched
|
||||
} else if (command.equalsIgnoreCase(RescheduleLoansApiConstants.rejectCommandParamName)) {
|
||||
statusParam = 300;
|
||||
}
|
||||
return this.jdbcTemplate.query(sql, loanRescheduleRequestRowMapperForBulkApproval, new Object[] { statusParam }); // NOSONAR
|
||||
return this.jdbcTemplate.query(sql, loanRescheduleRequestRowMapperForBulkApproval, statusParam); // NOSONAR
|
||||
}
|
||||
return this.jdbcTemplate.query(sql, loanRescheduleRequestRowMapperForBulkApproval); // NOSONAR
|
||||
}
|
||||
|
||||
+2
-2
@@ -54,7 +54,7 @@ public class BulkLoansReadPlatformServiceImpl implements BulkLoansReadPlatformSe
|
||||
final String groupSql = "select distinct " + staffGroupMapper.schema() + " and g.status_enum=?";
|
||||
|
||||
final List<StaffAccountSummaryCollectionData.LoanAccountSummary> clientSummaryList = this.jdbcTemplate.query(clientSql, // NOSONAR
|
||||
staffClientMapper, new Object[] { loanOfficerId, ClientStatus.ACTIVE.getValue() });
|
||||
staffClientMapper, loanOfficerId, ClientStatus.ACTIVE.getValue());
|
||||
|
||||
for (final StaffAccountSummaryCollectionData.LoanAccountSummary clientSummary : clientSummaryList) {
|
||||
|
||||
@@ -65,7 +65,7 @@ public class BulkLoansReadPlatformServiceImpl implements BulkLoansReadPlatformSe
|
||||
}
|
||||
|
||||
final List<StaffAccountSummaryCollectionData.LoanAccountSummary> groupSummaryList = this.jdbcTemplate.query(groupSql, // NOSONAR
|
||||
staffGroupMapper, new Object[] { loanOfficerId, GroupingTypeStatus.ACTIVE.getValue() });
|
||||
staffGroupMapper, loanOfficerId, GroupingTypeStatus.ACTIVE.getValue());
|
||||
|
||||
for (final StaffAccountSummaryCollectionData.LoanAccountSummary groupSummary : groupSummaryList) {
|
||||
|
||||
|
||||
+6
-6
@@ -93,7 +93,7 @@ public class GLIMAccountInfoReadPlatformServiceImpl implements GLIMAccountInfoRe
|
||||
final GLIMFieldsMapper rm = new GLIMFieldsMapper();
|
||||
final String sql = "select " + rm.schema() + " and glim.id=?";
|
||||
|
||||
return this.jdbcTemplate.query(sql, rm, new Object[] { glimId }); // NOSONAR
|
||||
return this.jdbcTemplate.query(sql, rm, glimId); // NOSONAR
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -103,7 +103,7 @@ public class GLIMAccountInfoReadPlatformServiceImpl implements GLIMAccountInfoRe
|
||||
final GLIMFieldsMapper rm = new GLIMFieldsMapper();
|
||||
final String sql = "select " + rm.schema() + " and ln.group_id=?";
|
||||
|
||||
return this.jdbcTemplate.query(sql, rm, new Object[] { Long.parseLong(groupId) }); // NOSONAR
|
||||
return this.jdbcTemplate.query(sql, rm, Long.parseLong(groupId)); // NOSONAR
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -114,7 +114,7 @@ public class GLIMAccountInfoReadPlatformServiceImpl implements GLIMAccountInfoRe
|
||||
|
||||
final String sql = "select " + rm.schema() + " where glim.group_id=?";
|
||||
|
||||
return this.jdbcTemplate.query(sql, rm, new Object[] { Long.parseLong(groupId) }); // NOSONAR
|
||||
return this.jdbcTemplate.query(sql, rm, Long.parseLong(groupId)); // NOSONAR
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -124,7 +124,7 @@ public class GLIMAccountInfoReadPlatformServiceImpl implements GLIMAccountInfoRe
|
||||
final GLIMFieldsMapper rm = new GLIMFieldsMapper();
|
||||
final String sql = "select " + rm.schema() + " and glim.accountNumber=?";
|
||||
|
||||
return this.jdbcTemplate.query(sql, rm, new Object[] { parentAccountIds }); // NOSONAR
|
||||
return this.jdbcTemplate.query(sql, rm, parentAccountIds); // NOSONAR
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -135,7 +135,7 @@ public class GLIMAccountInfoReadPlatformServiceImpl implements GLIMAccountInfoRe
|
||||
|
||||
final String sql = "select " + rm.schema() + " where glim.group_id=? and glim.account_number=?";
|
||||
|
||||
return this.jdbcTemplate.query(sql, rm, new Object[] { groupId, accountNo }); // NOSONAR
|
||||
return this.jdbcTemplate.query(sql, rm, groupId, accountNo); // NOSONAR
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -188,7 +188,7 @@ public class GLIMAccountInfoReadPlatformServiceImpl implements GLIMAccountInfoRe
|
||||
|
||||
final String sql = "select " + rm.schema() + " where glim.id=?";
|
||||
|
||||
return this.jdbcTemplate.query(sql, rm, new Object[] { glimId }); // NOSONAR
|
||||
return this.jdbcTemplate.query(sql, rm, glimId); // NOSONAR
|
||||
|
||||
}
|
||||
|
||||
|
||||
+2
-4
@@ -492,10 +492,8 @@ public class LoanAccrualWritePlatformServiceImpl implements LoanAccrualWritePlat
|
||||
if (loan == null) {
|
||||
throw new LoanNotFoundException(loanId);
|
||||
}
|
||||
final List<Long> existingTransactionIds = new ArrayList<>();
|
||||
final List<Long> existingReversedTransactionIds = new ArrayList<>();
|
||||
existingTransactionIds.addAll(loan.findExistingTransactionIds());
|
||||
existingReversedTransactionIds.addAll(loan.findExistingReversedTransactionIds());
|
||||
final List<Long> existingTransactionIds = new ArrayList<>(loan.findExistingTransactionIds());
|
||||
final List<Long> existingReversedTransactionIds = new ArrayList<>(loan.findExistingReversedTransactionIds());
|
||||
loan.processIncomeTransactions();
|
||||
this.loanRepositoryWrapper.saveAndFlush(loan);
|
||||
postJournalEntries(loan, existingTransactionIds, existingReversedTransactionIds);
|
||||
|
||||
+3
-7
@@ -156,7 +156,7 @@ public class LoanArrearsAgingServiceImpl implements LoanArrearsAgingService {
|
||||
this.jdbcTemplate.update(updateStatement.get(0));
|
||||
} else {
|
||||
String deletestatement = "DELETE FROM m_loan_arrears_aging WHERE loan_id=?";
|
||||
this.jdbcTemplate.update(deletestatement, new Object[] { loan.getId() }); // NOSONAR
|
||||
this.jdbcTemplate.update(deletestatement, loan.getId()); // NOSONAR
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -168,7 +168,7 @@ public class LoanArrearsAgingServiceImpl implements LoanArrearsAgingService {
|
||||
String updateStatement = constructUpdateStatement(loan, count == 0);
|
||||
if (updateStatement == null) {
|
||||
String deletestatement = "DELETE FROM m_loan_arrears_aging WHERE loan_id=?";
|
||||
this.jdbcTemplate.update(deletestatement, new Object[] { loan.getId() }); // NOSONAR
|
||||
this.jdbcTemplate.update(deletestatement, loan.getId()); // NOSONAR
|
||||
} else {
|
||||
this.jdbcTemplate.update(updateStatement);
|
||||
}
|
||||
@@ -453,11 +453,7 @@ public class LoanArrearsAgingServiceImpl implements LoanArrearsAgingService {
|
||||
while (rs.next()) {
|
||||
Long loanId = rs.getLong("loanId");
|
||||
|
||||
List<LoanSchedulePeriodData> periodDatas = scheduleDate.get(loanId);
|
||||
if (periodDatas == null) {
|
||||
periodDatas = new ArrayList<>();
|
||||
scheduleDate.put(loanId, periodDatas);
|
||||
}
|
||||
List<LoanSchedulePeriodData> periodDatas = scheduleDate.computeIfAbsent(loanId, k -> new ArrayList<>());
|
||||
|
||||
periodDatas.add(fetchLoanSchedulePeriodData(rs));
|
||||
}
|
||||
|
||||
+1
-1
@@ -48,7 +48,7 @@ public class LoanChargePaidByReadPlatformServiceImpl implements LoanChargePaidBy
|
||||
this.context.authenticatedUser();
|
||||
final LoanChargePaidByMapper rm = new LoanChargePaidByMapper();
|
||||
final String sql = "select " + rm.loanChargePaidBySchema() + " where lcpd.loan_transaction_id = ?";
|
||||
return this.jdbcTemplate.query(sql, rm, new Object[] { transactionId }); // NOSONAR
|
||||
return this.jdbcTemplate.query(sql, rm, transactionId); // NOSONAR
|
||||
}
|
||||
|
||||
private static final class LoanChargePaidByMapper implements RowMapper<LoanChargePaidByData> {
|
||||
|
||||
+8
-15
@@ -76,7 +76,6 @@ public class LoanChargeReadPlatformServiceImpl implements LoanChargeReadPlatform
|
||||
|
||||
@Override
|
||||
public LoanChargeData mapRow(final ResultSet rs, @SuppressWarnings("unused") final int rowNum) throws SQLException {
|
||||
|
||||
final Long id = rs.getLong("id");
|
||||
final Long chargeId = rs.getLong("chargeId");
|
||||
final String name = rs.getString("name");
|
||||
@@ -130,8 +129,6 @@ public class LoanChargeReadPlatformServiceImpl implements LoanChargeReadPlatform
|
||||
|
||||
@Override
|
||||
public ChargeData retrieveLoanChargeTemplate() {
|
||||
this.context.authenticatedUser();
|
||||
|
||||
final List<EnumOptionData> allowedChargeCalculationTypeOptions = this.chargeDropdownReadPlatformService.retrieveCalculationTypes();
|
||||
final List<EnumOptionData> allowedChargeTimeOptions = this.chargeDropdownReadPlatformService.retrieveCollectionTimeTypes();
|
||||
final List<EnumOptionData> loansChargeCalculationTypeOptions = this.chargeDropdownReadPlatformService
|
||||
@@ -164,25 +161,21 @@ public class LoanChargeReadPlatformServiceImpl implements LoanChargeReadPlatform
|
||||
|
||||
@Override
|
||||
public LoanChargeData retrieveLoanChargeDetails(final Long id, final Long loanId) {
|
||||
this.context.authenticatedUser();
|
||||
|
||||
final LoanChargeMapper rm = new LoanChargeMapper();
|
||||
|
||||
final String sql = "select " + rm.schema() + " where lc.id=? and lc.loan_id=?";
|
||||
|
||||
return this.jdbcTemplate.queryForObject(sql, rm, new Object[] { id, loanId }); // NOSONAR
|
||||
return this.jdbcTemplate.queryForObject(sql, rm, id, loanId); // NOSONAR
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<LoanChargeData> retrieveLoanCharges(final Long loanId) {
|
||||
this.context.authenticatedUser();
|
||||
|
||||
final LoanChargeMapper rm = new LoanChargeMapper();
|
||||
|
||||
final String sql = "select " + rm.schema() + " where lc.loan_id=? AND lc.is_active = true"
|
||||
+ " order by coalesce(lc.due_for_collection_as_of_date,date(coalesce(dd.disbursedon_date,dd.expected_disburse_date))),lc.charge_time_enum ASC, lc.due_for_collection_as_of_date ASC, lc.is_penalty ASC";
|
||||
|
||||
return this.jdbcTemplate.query(sql, rm, new Object[] { loanId }); // NOSONAR
|
||||
return this.jdbcTemplate.query(sql, rm, loanId); // NOSONAR
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -190,7 +183,7 @@ public class LoanChargeReadPlatformServiceImpl implements LoanChargeReadPlatform
|
||||
final LoanChargeMapperWithLoanId rm = new LoanChargeMapperWithLoanId();
|
||||
final String sql = "select " + rm.schema()
|
||||
+ "where loan.loan_status_id= ? and lc.charge_payment_mode_enum=? and lc.waived = false and lc.is_paid_derived=false and lc.is_active = true";
|
||||
return this.jdbcTemplate.query(sql, rm, new Object[] { loanStatus, paymentMode }); // NOSONAR
|
||||
return this.jdbcTemplate.query(sql, rm, loanStatus, paymentMode); // NOSONAR
|
||||
}
|
||||
|
||||
private static final class LoanChargeMapperWithLoanId implements RowMapper<LoanChargeData> {
|
||||
@@ -223,7 +216,7 @@ public class LoanChargeReadPlatformServiceImpl implements LoanChargeReadPlatform
|
||||
sql = sql + "and lic.waived = false and lic.is_paid_derived=false";
|
||||
}
|
||||
sql = sql + " order by lsi.installment";
|
||||
return this.jdbcTemplate.query(sql, rm, new Object[] { loanChargeId }); // NOSONAR
|
||||
return this.jdbcTemplate.query(sql, rm, loanChargeId); // NOSONAR
|
||||
}
|
||||
|
||||
private static final class LoanInstallmentChargeMapper implements RowMapper<LoanInstallmentChargeData> {
|
||||
@@ -271,7 +264,7 @@ public class LoanChargeReadPlatformServiceImpl implements LoanChargeReadPlatform
|
||||
+ " order by lc.charge_time_enum ASC, lc.due_for_collection_as_of_date ASC, lc.is_penalty ASC";
|
||||
|
||||
Collection<LoanChargeData> charges = this.jdbcTemplate.query(sql, rm, // NOSONAR
|
||||
new Object[] { LoanTransactionType.ACCRUAL.getValue(), loanId, loanId });
|
||||
LoanTransactionType.ACCRUAL.getValue(), loanId, loanId);
|
||||
charges = updateLoanChargesWithUnrecognizedIncome(loanId, charges);
|
||||
|
||||
Collection<LoanChargeData> removeCharges = new ArrayList<>();
|
||||
@@ -348,7 +341,7 @@ public class LoanChargeReadPlatformServiceImpl implements LoanChargeReadPlatform
|
||||
final String sql = "select " + rm.schema() + " where lc.loan_id=? AND lc.is_active = true group by lc.id "
|
||||
+ " order by lc.charge_time_enum ASC, lc.due_for_collection_as_of_date ASC, lc.is_penalty ASC";
|
||||
|
||||
return this.jdbcTemplate.query(sql, rm, new Object[] { LoanTransactionType.WAIVE_CHARGES.getValue(), loanId, loanId }); // NOSONAR
|
||||
return this.jdbcTemplate.query(sql, rm, LoanTransactionType.WAIVE_CHARGES.getValue(), loanId, loanId); // NOSONAR
|
||||
}
|
||||
|
||||
private static final class LoanChargeUnRecognizedIncomeMapper implements RowMapper<LoanChargeData> {
|
||||
@@ -396,7 +389,7 @@ public class LoanChargeReadPlatformServiceImpl implements LoanChargeReadPlatform
|
||||
String sql = "select " + rm.schema()
|
||||
+ " where lic.loan_charge_id= ? group by lsi.installment, lsi.duedate, lic.amount_outstanding_derived, lic.amount, lic.is_paid_derived, lic.amount_waived_derived, lic.waived";
|
||||
Collection<LoanInstallmentChargeData> chargeDatas = this.jdbcTemplate.query(sql, rm, // NOSONAR
|
||||
new Object[] { LoanTransactionType.ACCRUAL.getValue(), loanChargeId });
|
||||
LoanTransactionType.ACCRUAL.getValue(), loanChargeId);
|
||||
final Map<Integer, LoanInstallmentChargeData> installmentChargeDatas = new HashMap<>();
|
||||
for (LoanInstallmentChargeData installmentChargeData : chargeDatas) {
|
||||
installmentChargeDatas.put(installmentChargeData.getInstallmentNumber(), installmentChargeData);
|
||||
@@ -457,7 +450,7 @@ public class LoanChargeReadPlatformServiceImpl implements LoanChargeReadPlatform
|
||||
final Map<Integer, LoanInstallmentChargeData> installmentChargeDatas) {
|
||||
final LoanInstallmentChargeUnRecognizedIncomeMapper rm = new LoanInstallmentChargeUnRecognizedIncomeMapper(installmentChargeDatas);
|
||||
String sql = "select " + rm.schema() + " where cpb.loan_charge_id = ? group by cpb.installment_number ";
|
||||
return this.jdbcTemplate.query(sql, rm, new Object[] { LoanTransactionType.WAIVE_CHARGES.getValue(), loanChargeId }); // NOSONAR
|
||||
return this.jdbcTemplate.query(sql, rm, LoanTransactionType.WAIVE_CHARGES.getValue(), loanChargeId); // NOSONAR
|
||||
}
|
||||
|
||||
private static final class LoanInstallmentChargeUnRecognizedIncomeMapper implements RowMapper<LoanInstallmentChargeData> {
|
||||
|
||||
+53
-68
@@ -215,8 +215,7 @@ public class LoanReadPlatformServiceImpl implements LoanReadPlatformService {
|
||||
sqlBuilder.append(" left join m_office transferToOffice on transferToOffice.id = c.transfer_to_office_id ");
|
||||
sqlBuilder.append(" where l.id=? and ( o.hierarchy like ? or transferToOffice.hierarchy like ?)");
|
||||
|
||||
return this.jdbcTemplate.queryForObject(sqlBuilder.toString(), rm,
|
||||
new Object[] { loanId, hierarchySearchString, hierarchySearchString });
|
||||
return this.jdbcTemplate.queryForObject(sqlBuilder.toString(), rm, loanId, hierarchySearchString, hierarchySearchString);
|
||||
} catch (final EmptyResultDataAccessException e) {
|
||||
throw new LoanNotFoundException(loanId, e);
|
||||
}
|
||||
@@ -231,7 +230,7 @@ public class LoanReadPlatformServiceImpl implements LoanReadPlatformService {
|
||||
|
||||
final String sql = "select " + rm.loanSchema() + " where l.account_no=?";
|
||||
|
||||
return this.jdbcTemplate.queryForObject(sql, rm, new Object[] { loanAccountNumber }); // NOSONAR
|
||||
return this.jdbcTemplate.queryForObject(sql, rm, loanAccountNumber); // NOSONAR
|
||||
|
||||
}
|
||||
|
||||
@@ -244,7 +243,7 @@ public class LoanReadPlatformServiceImpl implements LoanReadPlatformService {
|
||||
+ " left join glim_parent_child_mapping as glim on glim.glim_child_account_id=l.account_no "
|
||||
+ "where glim.glim_parent_account_id=?";
|
||||
|
||||
return this.jdbcTemplate.query(sql, rm, new Object[] { parentloanAccountNumber }); // NOSONAR
|
||||
return this.jdbcTemplate.query(sql, rm, parentloanAccountNumber); // NOSONAR
|
||||
|
||||
}
|
||||
|
||||
@@ -260,7 +259,7 @@ public class LoanReadPlatformServiceImpl implements LoanReadPlatformService {
|
||||
repaymentScheduleRelatedLoanData, disbursementData, isInterestRecalculationEnabled, totalPaidFeeCharges);
|
||||
final String sql = "select " + fullResultsetExtractor.schema() + " where ls.loan_id = ? order by ls.loan_id, ls.installment";
|
||||
|
||||
return this.jdbcTemplate.query(sql, fullResultsetExtractor, new Object[] { loanId }); // NOSONAR
|
||||
return this.jdbcTemplate.query(sql, fullResultsetExtractor, loanId); // NOSONAR
|
||||
} catch (final EmptyResultDataAccessException e) {
|
||||
throw new LoanNotFoundException(loanId, e);
|
||||
}
|
||||
@@ -282,7 +281,7 @@ public class LoanReadPlatformServiceImpl implements LoanReadPlatformService {
|
||||
***/
|
||||
final String sql = "select " + rm.loanPaymentsSchema()
|
||||
+ " where tr.loan_id = ? and tr.transaction_type_enum not in (0, 3) and (tr.is_reversed=false or tr.manually_adjusted_or_reversed = true) order by tr.transaction_date ASC,id ";
|
||||
return this.jdbcTemplate.query(sql, rm, new Object[] { loanId }); // NOSONAR
|
||||
return this.jdbcTemplate.query(sql, rm, loanId); // NOSONAR
|
||||
} catch (final EmptyResultDataAccessException e) {
|
||||
return null;
|
||||
}
|
||||
@@ -435,7 +434,7 @@ public class LoanReadPlatformServiceImpl implements LoanReadPlatformService {
|
||||
RepaymentTransactionTemplateMapper mapper = new RepaymentTransactionTemplateMapper(sqlGenerator);
|
||||
String sql = "select " + mapper.schema();
|
||||
LoanTransactionData loanTransactionData = this.jdbcTemplate.queryForObject(sql, mapper, // NOSONAR
|
||||
new Object[] { LoanTransactionType.REPAYMENT.getValue(), LoanTransactionType.REPAYMENT.getValue(), loanId, loanId });
|
||||
LoanTransactionType.REPAYMENT.getValue(), LoanTransactionType.REPAYMENT.getValue(), loanId, loanId);
|
||||
final Collection<PaymentTypeData> paymentOptions = this.paymentTypeReadPlatformService.retrieveAllPaymentTypes();
|
||||
return LoanTransactionData.templateOnTop(loanTransactionData, paymentOptions);
|
||||
}
|
||||
@@ -574,7 +573,7 @@ public class LoanReadPlatformServiceImpl implements LoanReadPlatformService {
|
||||
try {
|
||||
final LoanTransactionsMapper rm = new LoanTransactionsMapper(sqlGenerator);
|
||||
final String sql = "select " + rm.loanPaymentsSchema() + " where l.id = ? and tr.id = ? ";
|
||||
return this.jdbcTemplate.queryForObject(sql, rm, new Object[] { loanId, transactionId }); // NOSONAR
|
||||
return this.jdbcTemplate.queryForObject(sql, rm, loanId, transactionId); // NOSONAR
|
||||
} catch (final EmptyResultDataAccessException e) {
|
||||
throw new LoanTransactionNotFoundException(transactionId, e);
|
||||
}
|
||||
@@ -1050,10 +1049,9 @@ public class LoanReadPlatformServiceImpl implements LoanReadPlatformService {
|
||||
final BigDecimal interestOutstanding = interestActualDue.subtract(interestPaid);
|
||||
|
||||
final Integer installmentNumber = JdbcSupport.getIntegerDefaultToNullIfZero(rs, "period");
|
||||
final OverdueLoanScheduleData overdueLoanScheduleData = new OverdueLoanScheduleData(loanId, chargeId, dueDate, amount,
|
||||
dateFormat, locale, principalOutstanding, interestOutstanding, installmentNumber);
|
||||
|
||||
return overdueLoanScheduleData;
|
||||
return new OverdueLoanScheduleData(loanId, chargeId, dueDate, amount, dateFormat, locale, principalOutstanding,
|
||||
interestOutstanding, installmentNumber);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1106,7 +1104,7 @@ public class LoanReadPlatformServiceImpl implements LoanReadPlatformService {
|
||||
this.currency.currencyInMultiplesOf());
|
||||
BigDecimal totalPrincipalDisbursed = BigDecimal.ZERO;
|
||||
BigDecimal disbursementChargeAmount = this.totalFeeChargesDueAtDisbursement;
|
||||
if (disbursementData == null || disbursementData.isEmpty()) {
|
||||
if (disbursementData.isEmpty()) {
|
||||
periods.add(disbursementPeriod);
|
||||
totalPrincipalDisbursed = Money.of(monCurrency, this.disbursement.amount()).getAmount();
|
||||
} else {
|
||||
@@ -1140,7 +1138,7 @@ public class LoanReadPlatformServiceImpl implements LoanReadPlatformService {
|
||||
totalRepayment = totalRepayment.plus(disbursementPeriod.feeChargesPaid()).minus(waivedChargeAmount);
|
||||
totalOutstanding = totalOutstanding.plus(disbursementPeriod.feeChargesDue()).minus(disbursementPeriod.feeChargesPaid());
|
||||
|
||||
Integer loanTermInDays = Integer.valueOf(0);
|
||||
Integer loanTermInDays = 0;
|
||||
while (rs.next()) {
|
||||
|
||||
final Long loanId = rs.getLong("loanId");
|
||||
@@ -1149,50 +1147,43 @@ public class LoanReadPlatformServiceImpl implements LoanReadPlatformService {
|
||||
final LocalDate dueDate = JdbcSupport.getLocalDate(rs, "dueDate");
|
||||
final LocalDate obligationsMetOnDate = JdbcSupport.getLocalDate(rs, "obligationsMetOnDate");
|
||||
final boolean complete = rs.getBoolean("complete");
|
||||
if (disbursementData != null) {
|
||||
BigDecimal principal = BigDecimal.ZERO;
|
||||
for (final DisbursementData data : disbursementData) {
|
||||
if (fromDate.equals(this.disbursement.disbursementDate()) && data.disbursementDate().equals(fromDate)) {
|
||||
BigDecimal principal = BigDecimal.ZERO;
|
||||
for (final DisbursementData data : disbursementData) {
|
||||
if (fromDate.equals(this.disbursement.disbursementDate()) && data.disbursementDate().equals(fromDate)) {
|
||||
principal = principal.add(data.amount());
|
||||
LoanSchedulePeriodData periodData = null;
|
||||
if (data.getChargeAmount() == null) {
|
||||
periodData = LoanSchedulePeriodData.disbursementOnlyPeriod(data.disbursementDate(), data.amount(),
|
||||
disbursementChargeAmount, data.isDisbursed());
|
||||
} else {
|
||||
periodData = LoanSchedulePeriodData.disbursementOnlyPeriod(data.disbursementDate(), data.amount(),
|
||||
disbursementChargeAmount.add(data.getChargeAmount()).subtract(waivedChargeAmount), data.isDisbursed());
|
||||
}
|
||||
periods.add(periodData);
|
||||
this.outstandingLoanPrincipalBalance = this.outstandingLoanPrincipalBalance.add(data.amount());
|
||||
} else if (data.isDueForDisbursement(fromDate, dueDate)) {
|
||||
if (!excludePastUndisbursed || data.isDisbursed()
|
||||
|| !data.disbursementDate().isBefore(DateUtils.getBusinessLocalDate())) {
|
||||
principal = principal.add(data.amount());
|
||||
LoanSchedulePeriodData periodData = null;
|
||||
LoanSchedulePeriodData periodData;
|
||||
if (data.getChargeAmount() == null) {
|
||||
periodData = LoanSchedulePeriodData.disbursementOnlyPeriod(data.disbursementDate(), data.amount(),
|
||||
disbursementChargeAmount, data.isDisbursed());
|
||||
BigDecimal.ZERO, data.isDisbursed());
|
||||
} else {
|
||||
periodData = LoanSchedulePeriodData.disbursementOnlyPeriod(data.disbursementDate(), data.amount(),
|
||||
disbursementChargeAmount.add(data.getChargeAmount()).subtract(waivedChargeAmount),
|
||||
data.isDisbursed());
|
||||
}
|
||||
if (periodData != null) {
|
||||
periods.add(periodData);
|
||||
data.getChargeAmount(), data.isDisbursed());
|
||||
}
|
||||
periods.add(periodData);
|
||||
this.outstandingLoanPrincipalBalance = this.outstandingLoanPrincipalBalance.add(data.amount());
|
||||
} else if (data.isDueForDisbursement(fromDate, dueDate)) {
|
||||
if (!excludePastUndisbursed || (excludePastUndisbursed
|
||||
&& (data.isDisbursed() || !data.disbursementDate().isBefore(DateUtils.getBusinessLocalDate())))) {
|
||||
principal = principal.add(data.amount());
|
||||
LoanSchedulePeriodData periodData = null;
|
||||
if (data.getChargeAmount() == null) {
|
||||
periodData = LoanSchedulePeriodData.disbursementOnlyPeriod(data.disbursementDate(), data.amount(),
|
||||
BigDecimal.ZERO, data.isDisbursed());
|
||||
} else {
|
||||
periodData = LoanSchedulePeriodData.disbursementOnlyPeriod(data.disbursementDate(), data.amount(),
|
||||
data.getChargeAmount(), data.isDisbursed());
|
||||
}
|
||||
if (periodData != null) {
|
||||
periods.add(periodData);
|
||||
}
|
||||
this.outstandingLoanPrincipalBalance = this.outstandingLoanPrincipalBalance.add(data.amount());
|
||||
}
|
||||
}
|
||||
}
|
||||
totalPrincipalDisbursed = totalPrincipalDisbursed.add(principal);
|
||||
}
|
||||
totalPrincipalDisbursed = totalPrincipalDisbursed.add(principal);
|
||||
|
||||
Integer daysInPeriod = Integer.valueOf(0);
|
||||
Integer daysInPeriod = 0;
|
||||
if (fromDate != null) {
|
||||
daysInPeriod = Math.toIntExact(ChronoUnit.DAYS.between(fromDate, dueDate));
|
||||
loanTermInDays = Integer.valueOf(loanTermInDays.intValue() + daysInPeriod.intValue());
|
||||
loanTermInDays = loanTermInDays + daysInPeriod;
|
||||
}
|
||||
|
||||
final BigDecimal principalDue = JdbcSupport.getBigDecimalDefaultToZeroIfNull(rs, "principalDue");
|
||||
@@ -1575,7 +1566,7 @@ public class LoanReadPlatformServiceImpl implements LoanReadPlatformService {
|
||||
final LoanDisbursementDetailMapper rm = new LoanDisbursementDetailMapper(sqlGenerator);
|
||||
final String sql = "select " + rm.schema()
|
||||
+ " where dd.loan_id=? group by dd.id, lc.amount_waived_derived order by dd.expected_disburse_date";
|
||||
return this.jdbcTemplate.query(sql, rm, new Object[] { loanId }); // NOSONAR
|
||||
return this.jdbcTemplate.query(sql, rm, loanId); // NOSONAR
|
||||
}
|
||||
|
||||
private static final class LoanDisbursementDetailMapper implements RowMapper<DisbursementData> {
|
||||
@@ -1606,9 +1597,8 @@ public class LoanReadPlatformServiceImpl implements LoanReadPlatformService {
|
||||
if (chargeAmount != null && waivedAmount != null) {
|
||||
chargeAmount = chargeAmount.subtract(waivedAmount);
|
||||
}
|
||||
final DisbursementData disbursementData = new DisbursementData(id, expectedDisbursementdate, actualDisbursementdate, principal,
|
||||
netDisbursalAmount, loanChargeId, chargeAmount, waivedAmount);
|
||||
return disbursementData;
|
||||
return new DisbursementData(id, expectedDisbursementdate, actualDisbursementdate, principal, netDisbursalAmount, loanChargeId,
|
||||
chargeAmount, waivedAmount);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1617,14 +1607,14 @@ public class LoanReadPlatformServiceImpl implements LoanReadPlatformService {
|
||||
public DisbursementData retrieveLoanDisbursementDetail(Long loanId, Long disbursementId) {
|
||||
final LoanDisbursementDetailMapper rm = new LoanDisbursementDetailMapper(sqlGenerator);
|
||||
final String sql = "select " + rm.schema() + " where dd.loan_id=? and dd.id=? group by dd.id, lc.amount_waived_derived";
|
||||
return this.jdbcTemplate.queryForObject(sql, rm, new Object[] { loanId, disbursementId }); // NOSONAR
|
||||
return this.jdbcTemplate.queryForObject(sql, rm, loanId, disbursementId); // NOSONAR
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<LoanTermVariationsData> retrieveLoanTermVariations(Long loanId, Integer termType) {
|
||||
final LoanTermVariationsMapper rm = new LoanTermVariationsMapper();
|
||||
final String sql = "select " + rm.schema() + " where tv.loan_id=? and tv.term_type=?";
|
||||
return this.jdbcTemplate.query(sql, rm, new Object[] { loanId, termType }); // NOSONAR
|
||||
return this.jdbcTemplate.query(sql, rm, loanId, termType); // NOSONAR
|
||||
}
|
||||
|
||||
private static final class LoanTermVariationsMapper implements RowMapper<LoanTermVariationsData> {
|
||||
@@ -1642,10 +1632,8 @@ public class LoanReadPlatformServiceImpl implements LoanReadPlatformService {
|
||||
final LocalDate dateValue = JdbcSupport.getLocalDate(rs, "dateValue");
|
||||
final boolean isSpecificToInstallment = rs.getBoolean("isSpecificToInstallment");
|
||||
|
||||
final LoanTermVariationsData loanTermVariationsData = new LoanTermVariationsData(id,
|
||||
LoanEnumerations.loanvariationType(LoanTermVariationType.EMI_AMOUNT), variationApplicableFrom, decimalValue, dateValue,
|
||||
isSpecificToInstallment);
|
||||
return loanTermVariationsData;
|
||||
return new LoanTermVariationsData(id, LoanEnumerations.loanvariationType(LoanTermVariationType.EMI_AMOUNT),
|
||||
variationApplicableFrom, decimalValue, dateValue, isSpecificToInstallment);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1866,7 +1854,7 @@ public class LoanReadPlatformServiceImpl implements LoanReadPlatformService {
|
||||
sqlBuilder.append(" WHERE ml.loan_status_id = ? ");
|
||||
sqlBuilder.append(" and ml.is_npa = false ");
|
||||
sqlBuilder.append(" and ((");
|
||||
sqlBuilder.append("ml.interest_recalculation_enabled = 1 ");
|
||||
sqlBuilder.append("ml.interest_recalculation_enabled = true ");
|
||||
sqlBuilder.append(" and (ml.interest_recalcualated_on is null or ml.interest_recalcualated_on <> ?)");
|
||||
sqlBuilder.append(" and ((");
|
||||
sqlBuilder.append(" mr.completed_derived is false ");
|
||||
@@ -1884,8 +1872,8 @@ public class LoanReadPlatformServiceImpl implements LoanReadPlatformService {
|
||||
LocalDate currentdate = DateUtils.getBusinessLocalDate();
|
||||
// will look only for yesterday modified rates
|
||||
LocalDate yesterday = DateUtils.getBusinessLocalDate().minusDays(1);
|
||||
return this.jdbcTemplate.queryForList(sqlBuilder.toString(), Long.class,
|
||||
new Object[] { yesterday, LoanStatus.ACTIVE.getValue(), currentdate, currentdate, currentdate, yesterday });
|
||||
return this.jdbcTemplate.queryForList(sqlBuilder.toString(), Long.class, yesterday, LoanStatus.ACTIVE.getValue(), currentdate,
|
||||
currentdate, currentdate, yesterday);
|
||||
} catch (final EmptyResultDataAccessException e) {
|
||||
return null;
|
||||
}
|
||||
@@ -1931,9 +1919,9 @@ public class LoanReadPlatformServiceImpl implements LoanReadPlatformService {
|
||||
sqlBuilder.append(" group by ml.id ");
|
||||
sqlBuilder.append(" limit ? ");
|
||||
try {
|
||||
return Collections.synchronizedList(this.jdbcTemplate.queryForList(sqlBuilder.toString(), Long.class,
|
||||
new Object[] { yesterday, LoanStatus.ACTIVE.getValue(), currentdate, currentdate, currentdate, yesterday,
|
||||
maxLoanIdInList, officeHierarchy, pageSize }));
|
||||
return Collections.synchronizedList(
|
||||
this.jdbcTemplate.queryForList(sqlBuilder.toString(), Long.class, yesterday, LoanStatus.ACTIVE.getValue(), currentdate,
|
||||
currentdate, currentdate, yesterday, maxLoanIdInList, officeHierarchy, pageSize));
|
||||
} catch (final EmptyResultDataAccessException e) {
|
||||
return null;
|
||||
}
|
||||
@@ -1947,7 +1935,7 @@ public class LoanReadPlatformServiceImpl implements LoanReadPlatformService {
|
||||
|
||||
final String sql = "select " + rm.schema()
|
||||
+ " where tr.loan_id = ? and tr.transaction_type_enum = ? and tr.is_reversed=false order by tr.transaction_date ASC,id ";
|
||||
return this.jdbcTemplate.query(sql, rm, new Object[] { loanId, LoanTransactionType.WAIVE_INTEREST.getValue() }); // NOSONAR
|
||||
return this.jdbcTemplate.query(sql, rm, loanId, LoanTransactionType.WAIVE_INTEREST.getValue()); // NOSONAR
|
||||
} catch (final EmptyResultDataAccessException e) {
|
||||
return null;
|
||||
}
|
||||
@@ -2006,7 +1994,7 @@ public class LoanReadPlatformServiceImpl implements LoanReadPlatformService {
|
||||
|
||||
final String sql = "select " + rm.getSchema()
|
||||
+ " where lrs.loan_id = ? and lrs.interest_waived_derived is not null order by lrs.installment ASC ";
|
||||
return this.jdbcTemplate.query(sql, rm, new Object[] { loanId }); // NOSONAR
|
||||
return this.jdbcTemplate.query(sql, rm, loanId); // NOSONAR
|
||||
} catch (final EmptyResultDataAccessException e) {
|
||||
return null;
|
||||
}
|
||||
@@ -2081,12 +2069,9 @@ public class LoanReadPlatformServiceImpl implements LoanReadPlatformService {
|
||||
|
||||
@Override
|
||||
public LocalDate retrieveMinimumDateOfRepaymentTransaction(Long loanId) {
|
||||
// TODO Auto-generated method stub
|
||||
LocalDate date = this.jdbcTemplate.queryForObject(
|
||||
return this.jdbcTemplate.queryForObject(
|
||||
"select min(transaction_date) from m_loan_transaction where loan_id=? and transaction_type_enum=2", LocalDate.class,
|
||||
loanId);
|
||||
|
||||
return date;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -2253,7 +2238,7 @@ public class LoanReadPlatformServiceImpl implements LoanReadPlatformService {
|
||||
private static final class RepaymentTransactionTemplateMapper implements RowMapper<LoanTransactionData> {
|
||||
|
||||
private final DatabaseSpecificSQLGenerator sqlGenerator;
|
||||
private CurrencyMapper currencyMapper = new CurrencyMapper();
|
||||
private final CurrencyMapper currencyMapper = new CurrencyMapper();
|
||||
|
||||
RepaymentTransactionTemplateMapper(DatabaseSpecificSQLGenerator sqlGenerator) {
|
||||
this.sqlGenerator = sqlGenerator;
|
||||
@@ -2348,7 +2333,7 @@ public class LoanReadPlatformServiceImpl implements LoanReadPlatformService {
|
||||
public CollectionData retrieveLoanCollectionData(Long loanId) {
|
||||
final CollectionDataMapper mapper = new CollectionDataMapper(sqlGenerator);
|
||||
String sql = "select " + mapper.schema();
|
||||
CollectionData collectionData = this.jdbcTemplate.queryForObject(sql, mapper, new Object[] { loanId }); // NOSONAR
|
||||
CollectionData collectionData = this.jdbcTemplate.queryForObject(sql, mapper, loanId); // NOSONAR
|
||||
return collectionData;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user