Clearing out TODO's and fetching available loan officers for modify loan template

This commit is contained in:
Vishwas Babu AJ
2012-09-13 01:07:03 +05:30
parent bd80d01821
commit c90b98c12e
7 changed files with 33 additions and 33 deletions
@@ -118,15 +118,13 @@ public class LoansApiResource {
"closedOnDate", "expectedMaturityDate",
"status",
"lifeCycleStatusDate", "summary", "repaymentSchedule",
"loanRepayments", "permissions", "convenienceData", "charges")
"loanRepayments", "permissions", "convenienceData", "charges",
"loanOfficerOptions")
);
Set<String> responseParameters = ApiParameterHelper.extractFieldsForResponseIfProvided(uriInfo.getQueryParameters());
if (responseParameters.isEmpty()) {
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());
@@ -159,13 +157,8 @@ public class LoansApiResource {
Collection<ChargeData> charges = loanBasicDetails.getCharges();
// populate loan officers if query param is passed in
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");
}
Collection<StaffData> allowedLoanOfficers = this.staffReadPlatformService.retrieveAllLoanOfficersByOffice(loanBasicDetails.getClientOfficeId());
final LoanAccountData newLoanAccount = new LoanAccountData(loanBasicDetails, convenienceDataRequired, null, null, null, null, charges,
productOptions, loanTermFrequencyTypeOptions, repaymentFrequencyTypeOptions,
transactionProcessingStrategyOptions, interestRateFrequencyTypeOptions,
@@ -190,16 +183,12 @@ public class LoansApiResource {
"repaymentFrequencyType", "interestRateFrequencyType", "amortizationType", "interestType", "interestCalculationPeriodType",
"submittedOnDate", "approvedOnDate", "expectedDisbursementDate", "actualDisbursementDate",
"expectedFirstRepaymentOnDate", "interestChargedFromDate", "closedOnDate", "expectedMaturityDate",
"status", "lifeCycleStatusDate")
"status", "lifeCycleStatusDate", "loanOfficerName", "loanOfficerId")
);
Set<String> responseParameters = ApiParameterHelper.extractFieldsForResponseIfProvided(uriInfo.getQueryParameters());
if (responseParameters.isEmpty()) {
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());
@@ -249,11 +238,13 @@ public class LoansApiResource {
Collection<FundData> fundOptions = new ArrayList<FundData>();
Collection<ChargeData> chargeOptions = null;
ChargeData chargeTemplate = null;
Collection<StaffData> allowedLoanOfficers = null;
final boolean template = ApiParameterHelper.template(uriInfo.getQueryParameters());
if(template) {
responseParameters.addAll(Arrays.asList("productOptions", "amortizationTypeOptions", "interestTypeOptions", "interestCalculationPeriodTypeOptions",
"repaymentFrequencyTypeOptions", "interestRateFrequencyTypeOptions", "fundOptions", "transactionProcessingStrategyOptions", "chargeOptions"));
"repaymentFrequencyTypeOptions", "interestRateFrequencyTypeOptions", "fundOptions", "transactionProcessingStrategyOptions", "chargeOptions",
"loanOfficerOptions"));
productOptions = this.loanProductReadPlatformService.retrieveAllLoanProductsForLookup();
loanTermFrequencyTypeOptions = dropdownReadPlatformService.retrieveLoanTermFrequencyTypeOptions();
@@ -270,16 +261,10 @@ public class LoansApiResource {
if (charges != null) {
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,
productOptions, loanTermFrequencyTypeOptions, repaymentFrequencyTypeOptions,
transactionProcessingStrategyOptions, interestRateFrequencyTypeOptions,
@@ -209,7 +209,8 @@ public class Loan extends AbstractAuditableCustom<AppUser, Long> {
}
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()) {
this.client = client;
@@ -220,6 +221,9 @@ public class Loan extends AbstractAuditableCustom<AppUser, Long> {
if (command.isFundChanged()) {
this.fund = fund;
}
if(command.isLoanOfficerChanged()){
this.loanofficer = loanOfficer;
}
if (command.isTransactionStrategyChanged()) {
this.transactionProcessingStrategy = strategy;
}
@@ -169,7 +169,7 @@ public class LoanAssembler {
return fund;
}
private Staff findLoanOfficerByIdIfProvided(final Long loanOfficerId) {
public Staff findLoanOfficerByIdIfProvided(final Long loanOfficerId) {
Staff staff = null;
if (loanOfficerId != null) {
staff = this.staffRepository.findOne(loanOfficerId);
@@ -42,6 +42,7 @@ import org.mifosng.platform.loan.domain.LoanTransactionProcessingStrategy;
import org.mifosng.platform.loan.domain.LoanTransactionRepository;
import org.mifosng.platform.loan.domain.PeriodFrequencyType;
import org.mifosng.platform.security.PlatformSecurityContext;
import org.mifosng.platform.staff.domain.Staff;
import org.mifosng.platform.user.domain.AppUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.context.SecurityContextHolder;
@@ -140,10 +141,11 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
}
Fund fund = this.loanAssembler.findFundByIdIfProvided(command.getFundId());
Staff loanOfficer = this.loanAssembler.findLoanOfficerByIdIfProvided(command.getLoanOfficerId());
LoanTransactionProcessingStrategy strategy = this.loanAssembler.findStrategyByIdIfProvided(command.getTransactionProcessingStrategyId());
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);
@@ -22,10 +22,8 @@ public class StaffCommandValidator {
DataValidatorBuilder baseDataValidator = new DataValidatorBuilder(dataValidationErrors).resource("staff");
baseDataValidator.reset().parameter("officeId").value(command.getOfficeId()).notNull().integerGreaterThanZero();
baseDataValidator.reset().parameter("firstname")
.value(command.getFirstName()).ignoreIfNull()
.value(command.getFirstName()).notBlank()
.notExceedingLengthOf(50);
baseDataValidator.reset().parameter("lastname")
.value(command.getLastName()).notBlank()
@@ -50,7 +48,7 @@ public class StaffCommandValidator {
baseDataValidator.reset().parameter("id").value(command.getId()).notNull();
baseDataValidator.reset().parameter("officeId").value(command.getOfficeId()).ignoreIfNull().integerGreaterThanZero();
baseDataValidator.reset().parameter("firstname")
.value(command.getFirstName()).ignoreIfNull()
.value(command.getFirstName()).ignoreIfNull().notBlank()
.notExceedingLengthOf(50);
baseDataValidator.reset().parameter("lastname")
.value(command.getLastName()).ignoreIfNull().notBlank()
@@ -58,7 +56,9 @@ public class StaffCommandValidator {
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()) {
throw new PlatformApiDataValidationException(
@@ -9,4 +9,6 @@ public interface StaffReadPlatformService {
StaffData retrieveStaff(Long staffId);
Collection<StaffData> retrieveAllStaff(final String extraCriteria);
Collection<StaffData> retrieveAllLoanOfficersByOffice(final long officeId);
}
@@ -68,6 +68,13 @@ public class StaffReadPlatformServiceImpl implements StaffReadPlatformService {
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
public StaffData retrieveStaff(final Long staffId) {