Merge pull request #437 from goutham-M/mifosx-537
mifosx-537 differentiate b/w client/loan related notes
This commit is contained in:
+18
-4
@@ -74,6 +74,9 @@ import org.mifosplatform.portfolio.loanproduct.data.LoanProductData;
|
||||
import org.mifosplatform.portfolio.loanproduct.data.TransactionProcessingStrategyData;
|
||||
import org.mifosplatform.portfolio.loanproduct.service.LoanDropdownReadPlatformService;
|
||||
import org.mifosplatform.portfolio.loanproduct.service.LoanProductReadPlatformService;
|
||||
import org.mifosplatform.portfolio.note.data.NoteData;
|
||||
import org.mifosplatform.portfolio.note.domain.NoteType;
|
||||
import org.mifosplatform.portfolio.note.service.NoteReadPlatformServiceImpl;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
import org.springframework.stereotype.Component;
|
||||
@@ -97,7 +100,7 @@ public class LoansApiResource {
|
||||
"amortizationTypeOptions", "interestTypeOptions", "interestCalculationPeriodTypeOptions", "repaymentFrequencyTypeOptions",
|
||||
"termFrequencyTypeOptions", "interestRateFrequencyTypeOptions", "fundOptions", "repaymentStrategyOptions", "chargeOptions",
|
||||
"loanOfficerOptions", "loanPurposeOptions", "loanCollateralOptions", "chargeTemplate", "calendarOptions", "syncDisbursementWithMeeting",
|
||||
"loanCounter", "loanProductCounter"));
|
||||
"loanCounter", "loanProductCounter", "notes"));
|
||||
|
||||
private final String resourceNameForPermissions = "LOAN";
|
||||
|
||||
@@ -121,6 +124,7 @@ public class LoansApiResource {
|
||||
private final FromJsonHelper fromJsonHelper;
|
||||
private final PortfolioCommandSourceWritePlatformService commandsSourceWritePlatformService;
|
||||
private final CalendarReadPlatformService calendarReadPlatformService;
|
||||
private final NoteReadPlatformServiceImpl noteReadPlatformService;
|
||||
|
||||
@Autowired
|
||||
public LoansApiResource(final PlatformSecurityContext context, final LoanReadPlatformService loanReadPlatformService,
|
||||
@@ -136,7 +140,7 @@ public class LoansApiResource {
|
||||
final DefaultToApiJsonSerializer<BulkTransferLoanOfficerData> loanOfficeTransferToApiJsonSerializer,
|
||||
final ApiRequestParameterHelper apiRequestParameterHelper, final FromJsonHelper fromJsonHelper,
|
||||
final PortfolioCommandSourceWritePlatformService commandsSourceWritePlatformService,
|
||||
final CalendarReadPlatformService calendarReadPlatformService) {
|
||||
final CalendarReadPlatformService calendarReadPlatformService, final NoteReadPlatformServiceImpl noteReadPlatformService) {
|
||||
this.context = context;
|
||||
this.loanReadPlatformService = loanReadPlatformService;
|
||||
this.loanProductReadPlatformService = loanProductReadPlatformService;
|
||||
@@ -157,6 +161,7 @@ public class LoansApiResource {
|
||||
this.fromJsonHelper = fromJsonHelper;
|
||||
this.commandsSourceWritePlatformService = commandsSourceWritePlatformService;
|
||||
this.calendarReadPlatformService = calendarReadPlatformService;
|
||||
this.noteReadPlatformService = noteReadPlatformService;
|
||||
}
|
||||
|
||||
@GET
|
||||
@@ -275,13 +280,14 @@ public class LoansApiResource {
|
||||
Collection<GuarantorData> guarantors = null;
|
||||
Collection<CollateralData> collateral = null;
|
||||
CalendarData meeting = null;
|
||||
Collection<NoteData> notes = null;
|
||||
|
||||
final Set<String> mandatoryResponseParameters = new HashSet<String>();
|
||||
final Set<String> associationParameters = ApiParameterHelper.extractAssociationsForResponseIfProvided(uriInfo.getQueryParameters());
|
||||
if (!associationParameters.isEmpty()) {
|
||||
|
||||
if (associationParameters.contains("all")) {
|
||||
associationParameters.addAll(Arrays.asList("repaymentSchedule", "transactions", "charges", "guarantors", "collateral"));
|
||||
associationParameters.addAll(Arrays.asList("repaymentSchedule", "transactions", "charges", "guarantors", "collateral","notes"));
|
||||
}
|
||||
|
||||
if (associationParameters.contains("guarantors")) {
|
||||
@@ -327,6 +333,14 @@ public class LoansApiResource {
|
||||
mandatoryResponseParameters.add("meeting");
|
||||
meeting = this.calendarReadPlatformService.retrieveLoanCalendar(loanId);
|
||||
}
|
||||
|
||||
if (associationParameters.contains("notes")) {
|
||||
mandatoryResponseParameters.add("notes");
|
||||
notes = this.noteReadPlatformService.retrieveNotesByResource(loanId, NoteType.LOAN.getValue());
|
||||
if (CollectionUtils.isEmpty(notes)) {
|
||||
notes = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Collection<LoanProductData> productOptions = null;
|
||||
@@ -381,7 +395,7 @@ public class LoansApiResource {
|
||||
charges, collateral, guarantors, meeting, productOptions, loanTermFrequencyTypeOptions, repaymentFrequencyTypeOptions,
|
||||
repaymentStrategyOptions, interestRateFrequencyTypeOptions, amortizationTypeOptions, interestTypeOptions,
|
||||
interestCalculationPeriodTypeOptions, fundOptions, chargeOptions, chargeTemplate, allowedLoanOfficers, loanPurposeOptions,
|
||||
loanCollateralOptions, calendarOptions);
|
||||
loanCollateralOptions, calendarOptions, notes);
|
||||
|
||||
final ApiRequestJsonSerializationSettings settings = apiRequestParameterHelper.process(uriInfo.getQueryParameters(),
|
||||
mandatoryResponseParameters);
|
||||
|
||||
+23
-14
@@ -30,14 +30,15 @@ import org.mifosplatform.portfolio.loanaccount.guarantor.data.GuarantorData;
|
||||
import org.mifosplatform.portfolio.loanaccount.loanschedule.data.LoanScheduleData;
|
||||
import org.mifosplatform.portfolio.loanproduct.data.LoanProductData;
|
||||
import org.mifosplatform.portfolio.loanproduct.data.TransactionProcessingStrategyData;
|
||||
import org.mifosplatform.portfolio.note.data.NoteData;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
/**
|
||||
* Immutable data object representing loan account data.
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
public class LoanAccountData {
|
||||
|
||||
public class LoanAccountData {
|
||||
// basic loan details
|
||||
|
||||
// identity
|
||||
@@ -102,6 +103,7 @@ public class LoanAccountData {
|
||||
private final Collection<CollateralData> collateral;
|
||||
private final Collection<GuarantorData> guarantors;
|
||||
private final CalendarData meeting;
|
||||
private Collection<NoteData> notes;
|
||||
|
||||
// template
|
||||
private final Collection<LoanProductData> productOptions;
|
||||
@@ -180,6 +182,7 @@ public class LoanAccountData {
|
||||
final Collection<LoanChargeData> charges = null;
|
||||
final Collection<CollateralData> collateral = null;
|
||||
final Collection<GuarantorData> guarantors = null;
|
||||
final Collection<NoteData> notes = null;
|
||||
final CalendarData calendarData = null;
|
||||
final Collection<LoanProductData> productOptions = null;
|
||||
final Collection<EnumOptionData> termFrequencyTypeOptions = null;
|
||||
@@ -209,7 +212,7 @@ public class LoanAccountData {
|
||||
productOptions, termFrequencyTypeOptions, repaymentFrequencyTypeOptions, transactionProcessingStrategyOptions,
|
||||
interestRateFrequencyTypeOptions, amortizationTypeOptions, interestTypeOptions, interestCalculationPeriodTypeOptions,
|
||||
fundOptions, chargeOptions, chargeTemplate, loanOfficerOptions, loanPurposeOptions, loanCollateralOptions, calendarOptions,
|
||||
syncDisbursementWithMeeting, loancounter, loanProductCounter);
|
||||
syncDisbursementWithMeeting, loancounter, loanProductCounter, notes);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -264,6 +267,7 @@ public class LoanAccountData {
|
||||
final Collection<LoanChargeData> charges = null;
|
||||
final Collection<CollateralData> collateral = null;
|
||||
final Collection<GuarantorData> guarantors = null;
|
||||
final Collection<NoteData> notes = null;
|
||||
final CalendarData calendarData = null;
|
||||
final Collection<LoanProductData> productOptions = null;
|
||||
final Collection<EnumOptionData> termFrequencyTypeOptions = null;
|
||||
@@ -294,7 +298,7 @@ public class LoanAccountData {
|
||||
productOptions, termFrequencyTypeOptions, repaymentFrequencyTypeOptions, repaymentStrategyOptions,
|
||||
interestRateFrequencyTypeOptions, amortizationTypeOptions, interestTypeOptions, interestCalculationPeriodTypeOptions,
|
||||
fundOptions, chargeOptions, chargeTemplate, loanOfficerOptions, loanPurposeOptions, loanCollateralOptions, calendarOptions,
|
||||
syncDisbursementWithMeeting, loancounter, loanProductCounter);
|
||||
syncDisbursementWithMeeting, loancounter, loanProductCounter, notes);
|
||||
}
|
||||
|
||||
public static LoanAccountData populateClientDefaults(final LoanAccountData acc, final LoanAccountData clientAcc) {
|
||||
@@ -312,7 +316,7 @@ public class LoanAccountData {
|
||||
acc.transactionProcessingStrategyOptions, acc.interestRateFrequencyTypeOptions, acc.amortizationTypeOptions,
|
||||
acc.interestTypeOptions, acc.interestCalculationPeriodTypeOptions, acc.fundOptions, acc.chargeOptions, null,
|
||||
acc.loanOfficerOptions, acc.loanPurposeOptions, acc.loanCollateralOptions, acc.calendarOptions, acc.syncDisbursementWithMeeting,
|
||||
acc.loanCounter, acc.loanProductCounter);
|
||||
acc.loanCounter, acc.loanProductCounter, acc.notes);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -368,6 +372,7 @@ public class LoanAccountData {
|
||||
final Collection<LoanChargeData> charges = null;
|
||||
final Collection<CollateralData> collateral = null;
|
||||
final Collection<GuarantorData> guarantors = null;
|
||||
final Collection<NoteData> notes = null;
|
||||
final CalendarData calendarData = null;
|
||||
final Collection<LoanProductData> productOptions = null;
|
||||
final Collection<EnumOptionData> termFrequencyTypeOptions = null;
|
||||
@@ -398,7 +403,7 @@ public class LoanAccountData {
|
||||
productOptions, termFrequencyTypeOptions, repaymentFrequencyTypeOptions, repaymentStrategyOptions,
|
||||
interestRateFrequencyTypeOptions, amortizationTypeOptions, interestTypeOptions, interestCalculationPeriodTypeOptions,
|
||||
fundOptions, chargeOptions, chargeTemplate, loanOfficerOptions, loanPurposeOptions, loanCollateralOptions, calendarOptions,
|
||||
syncDisbursementWithMeeting, loancounter, loanProductCounter);
|
||||
syncDisbursementWithMeeting, loancounter, loanProductCounter, notes);
|
||||
}
|
||||
|
||||
public static LoanAccountData populateGroupDefaults(final LoanAccountData acc, final LoanAccountData groupAcc) {
|
||||
@@ -416,7 +421,7 @@ public class LoanAccountData {
|
||||
acc.transactionProcessingStrategyOptions, acc.interestRateFrequencyTypeOptions, acc.amortizationTypeOptions,
|
||||
acc.interestTypeOptions, acc.interestCalculationPeriodTypeOptions, acc.fundOptions, acc.chargeOptions, null,
|
||||
acc.loanOfficerOptions, acc.loanPurposeOptions, acc.loanCollateralOptions, acc.calendarOptions,
|
||||
acc.syncDisbursementWithMeeting, acc.loanCounter, acc.loanProductCounter);
|
||||
acc.syncDisbursementWithMeeting, acc.loanCounter, acc.loanProductCounter, acc.notes);
|
||||
}
|
||||
|
||||
public static LoanAccountData loanProductWithTemplateDefaults(final LoanProductData product,
|
||||
@@ -469,6 +474,7 @@ public class LoanAccountData {
|
||||
final Collection<LoanTransactionData> transactions = null;
|
||||
final Collection<CollateralData> collateral = null;
|
||||
final Collection<GuarantorData> guarantors = null;
|
||||
final Collection<NoteData> notes = null;
|
||||
final CalendarData calendarData = null;
|
||||
final Collection<LoanProductData> productOptions = null;
|
||||
final Collection<CalendarData> calendarOptions = null;
|
||||
@@ -497,7 +503,7 @@ public class LoanAccountData {
|
||||
repaymentSchedule, transactions, charges, collateral, guarantors, calendarData, productOptions, termFrequencyTypeOptions,
|
||||
repaymentFrequencyTypeOptions, repaymentStrategyOptions, interestRateFrequencyTypeOptions, amortizationTypeOptions,
|
||||
interestTypeOptions, interestCalculationPeriodTypeOptions, fundOptions, chargeOptions, chargeTemplate, loanOfficerOptions,
|
||||
loanPurposeOptions, loanCollateralOptions, calendarOptions, syncDisbursementWithMeeting, loancounter, loanProductCounter);
|
||||
loanPurposeOptions, loanCollateralOptions, calendarOptions, syncDisbursementWithMeeting, loancounter, loanProductCounter, notes);
|
||||
}
|
||||
|
||||
public static LoanAccountData populateLoanProductDefaults(final LoanAccountData acc, final LoanProductData product) {
|
||||
@@ -506,6 +512,7 @@ public class LoanAccountData {
|
||||
final Collection<LoanTransactionData> transactions = null;
|
||||
final Collection<CollateralData> collateral = null;
|
||||
final Collection<GuarantorData> guarantors = null;
|
||||
final Collection<NoteData> notes = null;
|
||||
final CalendarData calendarData = null;
|
||||
final Collection<LoanProductData> productOptions = null;
|
||||
final Collection<EnumOptionData> termFrequencyTypeOptions = null;
|
||||
@@ -544,7 +551,7 @@ public class LoanAccountData {
|
||||
calendarData, productOptions, termFrequencyTypeOptions, repaymentFrequencyTypeOptions, repaymentStrategyOptions,
|
||||
interestRateFrequencyTypeOptions, amortizationTypeOptions, interestTypeOptions, interestCalculationPeriodTypeOptions,
|
||||
fundOptions, chargeOptions, chargeTemplate, loanOfficerOptions, loanPurposeOptions, loanCollateralOptions, calendarOptions,
|
||||
acc.syncDisbursementWithMeeting, acc.loanCounter, acc.loanProductCounter);
|
||||
acc.syncDisbursementWithMeeting, acc.loanCounter, acc.loanProductCounter, notes);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -571,6 +578,7 @@ public class LoanAccountData {
|
||||
final Collection<LoanChargeData> charges = null;
|
||||
final Collection<CollateralData> collateral = null;
|
||||
final Collection<GuarantorData> guarantors = null;
|
||||
final Collection<NoteData> notes = null;
|
||||
final CalendarData calendarData = null;
|
||||
final Collection<LoanProductData> productOptions = null;
|
||||
final Collection<EnumOptionData> termFrequencyTypeOptions = null;
|
||||
@@ -598,7 +606,7 @@ public class LoanAccountData {
|
||||
productOptions, termFrequencyTypeOptions, repaymentFrequencyTypeOptions, repaymentStrategyOptions,
|
||||
interestRateFrequencyTypeOptions, amortizationTypeOptions, interestTypeOptions, interestCalculationPeriodTypeOptions,
|
||||
fundOptions, chargeOptions, chargeTemplate, loanOfficerOptions, loanPurposeOptions, loanCollateralOptions, calendarOptions,
|
||||
syncDisbursementWithMeeting, loancounter, loanProductCounter);
|
||||
syncDisbursementWithMeeting, loancounter, loanProductCounter, notes);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -615,7 +623,7 @@ public class LoanAccountData {
|
||||
final Collection<EnumOptionData> interestTypeOptions, final Collection<EnumOptionData> interestCalculationPeriodTypeOptions,
|
||||
final Collection<FundData> fundOptions, final Collection<ChargeData> chargeOptions, final ChargeData chargeTemplate,
|
||||
final Collection<StaffData> loanOfficerOptions, final Collection<CodeValueData> loanPurposeOptions,
|
||||
final Collection<CodeValueData> loanCollateralOptions, final Collection<CalendarData> calendarOptions) {
|
||||
final Collection<CodeValueData> loanCollateralOptions, final Collection<CalendarData> calendarOptions, final Collection<NoteData> notes) {
|
||||
return new LoanAccountData(acc.id, acc.accountNo, acc.status, acc.externalId, acc.clientId, acc.clientName, acc.clientOfficeId,
|
||||
acc.group, acc.loanType, acc.loanProductId, acc.loanProductName, acc.loanProductDescription, acc.fundId, acc.fundName,
|
||||
acc.loanPurposeId, acc.loanPurposeName, acc.loanOfficerId, acc.loanOfficerName, acc.currency, acc.principal,
|
||||
@@ -628,7 +636,7 @@ public class LoanAccountData {
|
||||
productOptions, termFrequencyTypeOptions, repaymentFrequencyTypeOptions, transactionProcessingStrategyOptions,
|
||||
interestRateFrequencyTypeOptions, amortizationTypeOptions, interestTypeOptions, interestCalculationPeriodTypeOptions,
|
||||
fundOptions, chargeOptions, chargeTemplate, loanOfficerOptions, loanPurposeOptions, loanCollateralOptions, calendarOptions,
|
||||
acc.syncDisbursementWithMeeting, acc.loanCounter, acc.loanProductCounter);
|
||||
acc.syncDisbursementWithMeeting, acc.loanCounter, acc.loanProductCounter, notes);
|
||||
}
|
||||
|
||||
public static LoanAccountData associationsAndTemplate(final LoanAccountData acc, final Collection<LoanProductData> productOptions,
|
||||
@@ -637,7 +645,7 @@ public class LoanAccountData {
|
||||
acc.meeting, productOptions, acc.termFrequencyTypeOptions, acc.repaymentFrequencyTypeOptions,
|
||||
acc.transactionProcessingStrategyOptions, acc.interestRateFrequencyTypeOptions, acc.amortizationTypeOptions,
|
||||
acc.interestTypeOptions, acc.interestCalculationPeriodTypeOptions, acc.fundOptions, acc.chargeOptions, null,
|
||||
allowedLoanOfficers, acc.loanPurposeOptions, acc.loanCollateralOptions, calendarOptions);
|
||||
allowedLoanOfficers, acc.loanPurposeOptions, acc.loanCollateralOptions, calendarOptions, acc.notes);
|
||||
}
|
||||
|
||||
public static LoanAccountData associateGroup(final LoanAccountData acc, final GroupGeneralData group) {
|
||||
@@ -654,7 +662,7 @@ public class LoanAccountData {
|
||||
acc.transactionProcessingStrategyOptions, acc.interestRateFrequencyTypeOptions, acc.amortizationTypeOptions,
|
||||
acc.interestTypeOptions, acc.interestCalculationPeriodTypeOptions, acc.fundOptions, acc.chargeOptions, null,
|
||||
acc.loanOfficerOptions, acc.loanPurposeOptions, acc.loanCollateralOptions, acc.calendarOptions,
|
||||
acc.syncDisbursementWithMeeting, acc.loanCounter, acc.loanProductCounter);
|
||||
acc.syncDisbursementWithMeeting, acc.loanCounter, acc.loanProductCounter, acc.notes);
|
||||
}
|
||||
|
||||
private LoanAccountData(
|
||||
@@ -701,7 +709,7 @@ public class LoanAccountData {
|
||||
final Collection<FundData> fundOptions, final Collection<ChargeData> chargeOptions, final ChargeData chargeTemplate,
|
||||
final Collection<StaffData> loanOfficerOptions, final Collection<CodeValueData> loanPurposeOptions,
|
||||
final Collection<CodeValueData> loanCollateralOptions, final Collection<CalendarData> calendarOptions,
|
||||
final Boolean syncDisbursementWithMeeting, final Integer loanCounter, final Integer loanProductCounter) {
|
||||
final Boolean syncDisbursementWithMeeting, final Integer loanCounter, final Integer loanProductCounter, final Collection<NoteData> notes) {
|
||||
this.id = id;
|
||||
this.accountNo = accountNo;
|
||||
this.status = status;
|
||||
@@ -755,6 +763,7 @@ public class LoanAccountData {
|
||||
this.collateral = collateral;
|
||||
this.guarantors = guarantors;
|
||||
this.meeting = meeting;
|
||||
this.notes = notes;
|
||||
|
||||
// template
|
||||
this.productOptions = productOptions;
|
||||
|
||||
+3
-3
@@ -94,17 +94,17 @@ public class NoteReadPlatformServiceImpl implements NoteReadPlatformService {
|
||||
|
||||
final String sql = rm.schema() + " where " + conditionSql + " order by n.created_date DESC";
|
||||
|
||||
return this.jdbcTemplate.query(sql, rm, new Object[] { resourceId });
|
||||
return this.jdbcTemplate.query(sql, rm, new Object[] { resourceId});
|
||||
}
|
||||
|
||||
public static String getResourceCondition(final NoteType noteType) {
|
||||
String conditionSql = "";
|
||||
switch (noteType) {
|
||||
case CLIENT:
|
||||
conditionSql = " n.client_id = ? ";
|
||||
conditionSql = " n.client_id = ? and note_type_enum = " + NoteType.CLIENT.getValue();
|
||||
break;
|
||||
case LOAN:
|
||||
conditionSql = " n.loan_id = ? ";
|
||||
conditionSql = " n.loan_id = ? and ( n.note_type_enum = " + NoteType.LOAN.getValue()+ " or n.note_type_enum = " + NoteType.LOAN_TRANSACTION.getValue() + " )";
|
||||
break;
|
||||
case LOAN_TRANSACTION:
|
||||
conditionSql = " n.loan_transaction_id = ? ";
|
||||
|
||||
Reference in New Issue
Block a user