Clearing out TODO's and fetching available loan officers for modify loan template
This commit is contained in:
@@ -118,15 +118,13 @@ public class LoansApiResource {
|
|||||||
"closedOnDate", "expectedMaturityDate",
|
"closedOnDate", "expectedMaturityDate",
|
||||||
"status",
|
"status",
|
||||||
"lifeCycleStatusDate", "summary", "repaymentSchedule",
|
"lifeCycleStatusDate", "summary", "repaymentSchedule",
|
||||||
"loanRepayments", "permissions", "convenienceData", "charges")
|
"loanRepayments", "permissions", "convenienceData", "charges",
|
||||||
|
"loanOfficerOptions")
|
||||||
);
|
);
|
||||||
|
|
||||||
Set<String> responseParameters = ApiParameterHelper.extractFieldsForResponseIfProvided(uriInfo.getQueryParameters());
|
Set<String> responseParameters = ApiParameterHelper.extractFieldsForResponseIfProvided(uriInfo.getQueryParameters());
|
||||||
if (responseParameters.isEmpty()) {
|
if (responseParameters.isEmpty()) {
|
||||||
responseParameters.addAll(typicalResponseParameters);
|
responseParameters.addAll(typicalResponseParameters);
|
||||||
}else if (responseParameters.contains("loanOfficerOptions") && (responseParameters.size() == 1)) {
|
|
||||||
// TODO Vishwas: check if response parameters should be additive
|
|
||||||
responseParameters.addAll(typicalResponseParameters);
|
|
||||||
}
|
}
|
||||||
boolean prettyPrint = ApiParameterHelper.prettyPrint(uriInfo.getQueryParameters());
|
boolean prettyPrint = ApiParameterHelper.prettyPrint(uriInfo.getQueryParameters());
|
||||||
|
|
||||||
@@ -159,13 +157,8 @@ public class LoansApiResource {
|
|||||||
Collection<ChargeData> charges = loanBasicDetails.getCharges();
|
Collection<ChargeData> charges = loanBasicDetails.getCharges();
|
||||||
|
|
||||||
// populate loan officers if query param is passed in
|
// populate loan officers if query param is passed in
|
||||||
Collection<StaffData> allowedLoanOfficers = null;
|
Collection<StaffData> allowedLoanOfficers = this.staffReadPlatformService.retrieveAllLoanOfficersByOffice(loanBasicDetails.getClientOfficeId());
|
||||||
if (responseParameters.contains("loanOfficerOptions")) {
|
|
||||||
// get applicable loan officers
|
|
||||||
allowedLoanOfficers = this.staffReadPlatformService
|
|
||||||
.retrieveAllStaff(" office_id = "
|
|
||||||
+ loanBasicDetails.getClientOfficeId() + " and is_loan_officer = 1");
|
|
||||||
}
|
|
||||||
final LoanAccountData newLoanAccount = new LoanAccountData(loanBasicDetails, convenienceDataRequired, null, null, null, null, charges,
|
final LoanAccountData newLoanAccount = new LoanAccountData(loanBasicDetails, convenienceDataRequired, null, null, null, null, charges,
|
||||||
productOptions, loanTermFrequencyTypeOptions, repaymentFrequencyTypeOptions,
|
productOptions, loanTermFrequencyTypeOptions, repaymentFrequencyTypeOptions,
|
||||||
transactionProcessingStrategyOptions, interestRateFrequencyTypeOptions,
|
transactionProcessingStrategyOptions, interestRateFrequencyTypeOptions,
|
||||||
@@ -190,16 +183,12 @@ public class LoansApiResource {
|
|||||||
"repaymentFrequencyType", "interestRateFrequencyType", "amortizationType", "interestType", "interestCalculationPeriodType",
|
"repaymentFrequencyType", "interestRateFrequencyType", "amortizationType", "interestType", "interestCalculationPeriodType",
|
||||||
"submittedOnDate", "approvedOnDate", "expectedDisbursementDate", "actualDisbursementDate",
|
"submittedOnDate", "approvedOnDate", "expectedDisbursementDate", "actualDisbursementDate",
|
||||||
"expectedFirstRepaymentOnDate", "interestChargedFromDate", "closedOnDate", "expectedMaturityDate",
|
"expectedFirstRepaymentOnDate", "interestChargedFromDate", "closedOnDate", "expectedMaturityDate",
|
||||||
"status", "lifeCycleStatusDate")
|
"status", "lifeCycleStatusDate", "loanOfficerName", "loanOfficerId")
|
||||||
);
|
);
|
||||||
|
|
||||||
Set<String> responseParameters = ApiParameterHelper.extractFieldsForResponseIfProvided(uriInfo.getQueryParameters());
|
Set<String> responseParameters = ApiParameterHelper.extractFieldsForResponseIfProvided(uriInfo.getQueryParameters());
|
||||||
if (responseParameters.isEmpty()) {
|
if (responseParameters.isEmpty()) {
|
||||||
responseParameters.addAll(typicalResponseParameters);
|
responseParameters.addAll(typicalResponseParameters);
|
||||||
} else if ((responseParameters.contains("loanOfficerName") || responseParameters
|
|
||||||
.contains("loanOfficerId")) && (responseParameters.size() <= 2)) {
|
|
||||||
// TODO Vishwas: check if response parameters should be additive
|
|
||||||
responseParameters.addAll(typicalResponseParameters);
|
|
||||||
}
|
}
|
||||||
boolean prettyPrint = ApiParameterHelper.prettyPrint(uriInfo.getQueryParameters());
|
boolean prettyPrint = ApiParameterHelper.prettyPrint(uriInfo.getQueryParameters());
|
||||||
|
|
||||||
@@ -249,11 +238,13 @@ public class LoansApiResource {
|
|||||||
Collection<FundData> fundOptions = new ArrayList<FundData>();
|
Collection<FundData> fundOptions = new ArrayList<FundData>();
|
||||||
Collection<ChargeData> chargeOptions = null;
|
Collection<ChargeData> chargeOptions = null;
|
||||||
ChargeData chargeTemplate = null;
|
ChargeData chargeTemplate = null;
|
||||||
|
Collection<StaffData> allowedLoanOfficers = null;
|
||||||
|
|
||||||
final boolean template = ApiParameterHelper.template(uriInfo.getQueryParameters());
|
final boolean template = ApiParameterHelper.template(uriInfo.getQueryParameters());
|
||||||
if(template) {
|
if(template) {
|
||||||
responseParameters.addAll(Arrays.asList("productOptions", "amortizationTypeOptions", "interestTypeOptions", "interestCalculationPeriodTypeOptions",
|
responseParameters.addAll(Arrays.asList("productOptions", "amortizationTypeOptions", "interestTypeOptions", "interestCalculationPeriodTypeOptions",
|
||||||
"repaymentFrequencyTypeOptions", "interestRateFrequencyTypeOptions", "fundOptions", "transactionProcessingStrategyOptions", "chargeOptions"));
|
"repaymentFrequencyTypeOptions", "interestRateFrequencyTypeOptions", "fundOptions", "transactionProcessingStrategyOptions", "chargeOptions",
|
||||||
|
"loanOfficerOptions"));
|
||||||
|
|
||||||
productOptions = this.loanProductReadPlatformService.retrieveAllLoanProductsForLookup();
|
productOptions = this.loanProductReadPlatformService.retrieveAllLoanProductsForLookup();
|
||||||
loanTermFrequencyTypeOptions = dropdownReadPlatformService.retrieveLoanTermFrequencyTypeOptions();
|
loanTermFrequencyTypeOptions = dropdownReadPlatformService.retrieveLoanTermFrequencyTypeOptions();
|
||||||
@@ -270,14 +261,8 @@ public class LoansApiResource {
|
|||||||
if (charges != null) {
|
if (charges != null) {
|
||||||
chargeOptions.removeAll(charges);
|
chargeOptions.removeAll(charges);
|
||||||
}
|
}
|
||||||
}
|
allowedLoanOfficers = this.staffReadPlatformService.retrieveAllLoanOfficersByOffice(loanBasicDetails.getClientOfficeId());
|
||||||
|
|
||||||
Collection<StaffData> allowedLoanOfficers = null;
|
|
||||||
if (responseParameters.contains("loanOfficerOptions")) {
|
|
||||||
// get applicable loan officers
|
|
||||||
allowedLoanOfficers = this.staffReadPlatformService
|
|
||||||
.retrieveAllStaff(" office_id = "
|
|
||||||
+ loanBasicDetails.getClientOfficeId() + " and is_loan_officer = 1");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
final LoanAccountData loanAccount = new LoanAccountData(loanBasicDetails, convenienceDataRequired, summary, repaymentSchedule, loanRepayments, permissions, charges,
|
final LoanAccountData loanAccount = new LoanAccountData(loanBasicDetails, convenienceDataRequired, summary, repaymentSchedule, loanRepayments, permissions, charges,
|
||||||
|
|||||||
@@ -209,7 +209,8 @@ public class Loan extends AbstractAuditableCustom<AppUser, Long> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void modifyLoanApplication(final LoanApplicationCommand command, final Client client, final LoanProduct loanProduct,
|
public void modifyLoanApplication(final LoanApplicationCommand command, final Client client, final LoanProduct loanProduct,
|
||||||
final Fund fund, final LoanTransactionProcessingStrategy strategy, final LoanSchedule modifiedLoanSchedule) {
|
final Fund fund, final LoanTransactionProcessingStrategy strategy, final LoanSchedule modifiedLoanSchedule,
|
||||||
|
final Staff loanOfficer) {
|
||||||
|
|
||||||
if (command.isClientChanged()) {
|
if (command.isClientChanged()) {
|
||||||
this.client = client;
|
this.client = client;
|
||||||
@@ -220,6 +221,9 @@ public class Loan extends AbstractAuditableCustom<AppUser, Long> {
|
|||||||
if (command.isFundChanged()) {
|
if (command.isFundChanged()) {
|
||||||
this.fund = fund;
|
this.fund = fund;
|
||||||
}
|
}
|
||||||
|
if(command.isLoanOfficerChanged()){
|
||||||
|
this.loanofficer = loanOfficer;
|
||||||
|
}
|
||||||
if (command.isTransactionStrategyChanged()) {
|
if (command.isTransactionStrategyChanged()) {
|
||||||
this.transactionProcessingStrategy = strategy;
|
this.transactionProcessingStrategy = strategy;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -169,7 +169,7 @@ public class LoanAssembler {
|
|||||||
return fund;
|
return fund;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Staff findLoanOfficerByIdIfProvided(final Long loanOfficerId) {
|
public Staff findLoanOfficerByIdIfProvided(final Long loanOfficerId) {
|
||||||
Staff staff = null;
|
Staff staff = null;
|
||||||
if (loanOfficerId != null) {
|
if (loanOfficerId != null) {
|
||||||
staff = this.staffRepository.findOne(loanOfficerId);
|
staff = this.staffRepository.findOne(loanOfficerId);
|
||||||
|
|||||||
+3
-1
@@ -42,6 +42,7 @@ import org.mifosng.platform.loan.domain.LoanTransactionProcessingStrategy;
|
|||||||
import org.mifosng.platform.loan.domain.LoanTransactionRepository;
|
import org.mifosng.platform.loan.domain.LoanTransactionRepository;
|
||||||
import org.mifosng.platform.loan.domain.PeriodFrequencyType;
|
import org.mifosng.platform.loan.domain.PeriodFrequencyType;
|
||||||
import org.mifosng.platform.security.PlatformSecurityContext;
|
import org.mifosng.platform.security.PlatformSecurityContext;
|
||||||
|
import org.mifosng.platform.staff.domain.Staff;
|
||||||
import org.mifosng.platform.user.domain.AppUser;
|
import org.mifosng.platform.user.domain.AppUser;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.security.core.context.SecurityContextHolder;
|
import org.springframework.security.core.context.SecurityContextHolder;
|
||||||
@@ -140,10 +141,11 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
|
|||||||
}
|
}
|
||||||
|
|
||||||
Fund fund = this.loanAssembler.findFundByIdIfProvided(command.getFundId());
|
Fund fund = this.loanAssembler.findFundByIdIfProvided(command.getFundId());
|
||||||
|
Staff loanOfficer = this.loanAssembler.findLoanOfficerByIdIfProvided(command.getLoanOfficerId());
|
||||||
LoanTransactionProcessingStrategy strategy = this.loanAssembler.findStrategyByIdIfProvided(command.getTransactionProcessingStrategyId());
|
LoanTransactionProcessingStrategy strategy = this.loanAssembler.findStrategyByIdIfProvided(command.getTransactionProcessingStrategyId());
|
||||||
|
|
||||||
LoanSchedule loanSchedule = this.calculationPlatformService.calculateLoanSchedule(command.toCalculateLoanScheduleCommand());
|
LoanSchedule loanSchedule = this.calculationPlatformService.calculateLoanSchedule(command.toCalculateLoanScheduleCommand());
|
||||||
loan.modifyLoanApplication(command, client, loanProduct, fund, strategy, loanSchedule);
|
loan.modifyLoanApplication(command, client, loanProduct, fund, strategy, loanSchedule, loanOfficer);
|
||||||
|
|
||||||
this.loanRepository.save(loan);
|
this.loanRepository.save(loan);
|
||||||
|
|
||||||
|
|||||||
+5
-5
@@ -22,10 +22,8 @@ public class StaffCommandValidator {
|
|||||||
|
|
||||||
DataValidatorBuilder baseDataValidator = new DataValidatorBuilder(dataValidationErrors).resource("staff");
|
DataValidatorBuilder baseDataValidator = new DataValidatorBuilder(dataValidationErrors).resource("staff");
|
||||||
|
|
||||||
baseDataValidator.reset().parameter("officeId").value(command.getOfficeId()).notNull().integerGreaterThanZero();
|
|
||||||
|
|
||||||
baseDataValidator.reset().parameter("firstname")
|
baseDataValidator.reset().parameter("firstname")
|
||||||
.value(command.getFirstName()).ignoreIfNull()
|
.value(command.getFirstName()).notBlank()
|
||||||
.notExceedingLengthOf(50);
|
.notExceedingLengthOf(50);
|
||||||
baseDataValidator.reset().parameter("lastname")
|
baseDataValidator.reset().parameter("lastname")
|
||||||
.value(command.getLastName()).notBlank()
|
.value(command.getLastName()).notBlank()
|
||||||
@@ -50,7 +48,7 @@ public class StaffCommandValidator {
|
|||||||
baseDataValidator.reset().parameter("id").value(command.getId()).notNull();
|
baseDataValidator.reset().parameter("id").value(command.getId()).notNull();
|
||||||
baseDataValidator.reset().parameter("officeId").value(command.getOfficeId()).ignoreIfNull().integerGreaterThanZero();
|
baseDataValidator.reset().parameter("officeId").value(command.getOfficeId()).ignoreIfNull().integerGreaterThanZero();
|
||||||
baseDataValidator.reset().parameter("firstname")
|
baseDataValidator.reset().parameter("firstname")
|
||||||
.value(command.getFirstName()).ignoreIfNull()
|
.value(command.getFirstName()).ignoreIfNull().notBlank()
|
||||||
.notExceedingLengthOf(50);
|
.notExceedingLengthOf(50);
|
||||||
baseDataValidator.reset().parameter("lastname")
|
baseDataValidator.reset().parameter("lastname")
|
||||||
.value(command.getLastName()).ignoreIfNull().notBlank()
|
.value(command.getLastName()).ignoreIfNull().notBlank()
|
||||||
@@ -58,7 +56,9 @@ public class StaffCommandValidator {
|
|||||||
|
|
||||||
baseDataValidator.reset().parameter("loanOfficerFlag").value(command.getLoanOfficerFlag()).ignoreIfNull();
|
baseDataValidator.reset().parameter("loanOfficerFlag").value(command.getLoanOfficerFlag()).ignoreIfNull();
|
||||||
|
|
||||||
baseDataValidator.reset().anyOfNotNull(command.getFirstName(), command.getLastName(), command.getOfficeId(), command.getLoanOfficerFlag());
|
baseDataValidator.reset().anyOfNotNull(command.getFirstName(),
|
||||||
|
command.getLastName(), command.getOfficeId(),
|
||||||
|
command.getLoanOfficerFlag());
|
||||||
|
|
||||||
if (!dataValidationErrors.isEmpty()) {
|
if (!dataValidationErrors.isEmpty()) {
|
||||||
throw new PlatformApiDataValidationException(
|
throw new PlatformApiDataValidationException(
|
||||||
|
|||||||
+2
@@ -9,4 +9,6 @@ public interface StaffReadPlatformService {
|
|||||||
StaffData retrieveStaff(Long staffId);
|
StaffData retrieveStaff(Long staffId);
|
||||||
|
|
||||||
Collection<StaffData> retrieveAllStaff(final String extraCriteria);
|
Collection<StaffData> retrieveAllStaff(final String extraCriteria);
|
||||||
|
|
||||||
|
Collection<StaffData> retrieveAllLoanOfficersByOffice(final long officeId);
|
||||||
}
|
}
|
||||||
+7
@@ -68,6 +68,13 @@ public class StaffReadPlatformServiceImpl implements StaffReadPlatformService {
|
|||||||
return this.jdbcTemplate.query(sql, rm, new Object[] {});
|
return this.jdbcTemplate.query(sql, rm, new Object[] {});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Collection<StaffData> retrieveAllLoanOfficersByOffice(long officeId) {
|
||||||
|
return retrieveAllStaff(" office_id = " + officeId
|
||||||
|
+ " and is_loan_officer = 1");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public StaffData retrieveStaff(final Long staffId) {
|
public StaffData retrieveStaff(final Long staffId) {
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user