more api doc updates and make available LoanProductLookup to loan template

This commit is contained in:
John Woodlock
2012-05-31 13:27:59 +10:00
parent 803db98668
commit b491d53f10
9 changed files with 642 additions and 677 deletions
+381 -555
View File
File diff suppressed because it is too large Load Diff
+5 -12
View File
@@ -8,24 +8,16 @@ recreate()
Lost permissions again... restore fixed it up... must be some prob with permissions/roles maintenance
also, maybe I should be using a user that has everything but role admin.
users - delete still falls over if user doesn't exist. DOING
Loan Products
List/Retrieve - should show textual values of enums? DOING
Create - principal is later called principalMoney , also consistency between other loan fields and loan product fields with Type on them DOING
clients - parentid = id or id 1 has parentId not null DOING
list clients notes - noteType needs a 'text'
createdOn & updatedOn values... do they need reformatting?
are they ord
updating client note - ignores clientId anyhow! so is it really a notes resource?
list clients notes - noteType needs a 'text'TODO
createdOn & updatedOn values... do they need reformatting?TODO
updating client note - ignores clientId anyhow! so is it really a notes resource? TODO
loan template
Formatted field still there
Type fields rename and with associated text?
allowedProduct should maybe just be id & name
which fields have defaults as not all on NewLoanWorkflowStepOneData dto seem to be default.
loan retrieve
break up data into categories.. e.g.
@@ -43,6 +35,7 @@ loanRepayments
Additional Fields
put right message for parameter not recognized etc.(plus tht 9 other jpwwrongmsg items)
should be able to get clients by branch as well (but not for now)
@@ -32,7 +32,7 @@ import org.springframework.stereotype.Component;
@Scope("singleton")
public class LoanProductApiResource {
private String defaultFieldList = "principal,inArrearsTolerance,numberOfRepayments,repaymentEvery,interestRatePerPeriod,annualInterestRate,repaymentFrequencyType,interestRateFrequencyType,amortizationType,interestType,interestCalculationPeriodType";
private String defaultFieldList = "principal,inArrearsTolerance,interestRatePerPeriod,annualInterestRate,repaymentFrequencyType,interestRateFrequencyType,amortizationType,interestType,interestCalculationPeriodType";
private String allowedFieldList = "currencyOptions,amortizationTypeOptions,interestTypeOptions,interestCalculationPeriodTypeOptions,repaymentFrequencyTypeOptions,interestRateFrequencyTypeOptions";
private String filterName = "myFilter";
@@ -67,7 +67,7 @@ public class ApiGlobalErrorResponse {
public static ApiGlobalErrorResponse domainRuleViolation(String globalisationMessageCode, String defaultUserMessage, Object... defaultUserMessageArgs) {
ApiGlobalErrorResponse globalErrorResponse = new ApiGlobalErrorResponse();
globalErrorResponse.setHttpStatusCode("403");
globalErrorResponse.setDeveloperMessage("Request was understoon but caused a domain rule violation.");
globalErrorResponse.setDeveloperMessage("Request was understood but caused a domain rule violation.");
globalErrorResponse.setDeveloperDocLink("https://github.com/keithwoodlock/mifosx/wiki/HTTP-API-Error-codes");
globalErrorResponse.setUserMessageGlobalisationCode("validation.msg.domain.rule.violation");
globalErrorResponse.setDefaultUserMessage("Errors contain reason for domain rule violation.");
@@ -0,0 +1,34 @@
package org.mifosng.platform.api.data;
import java.io.Serializable;
public class LoanProductLookup implements Serializable {
private Long id;
private String name;
public LoanProductLookup() {
//
}
public LoanProductLookup(Long id, String name) {
this.id = id;
this.name = name;
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
@@ -19,28 +19,28 @@ public class NewLoanData implements Serializable {
private String clientName;
private Long productId;
private String productName;
private List<LoanProductData> allowedProducts = new ArrayList<LoanProductData>();
private List<LoanProductLookup> allowedProducts = new ArrayList<LoanProductLookup>();
// extra
private String dateFormat;
private String submittedOnDateFormatted;
private LocalDate submittedOnDate;
private String submittedOnNote = "";
private String expectedDisbursementDateFormatted;
private LocalDate expectedDisbursementDate = new LocalDate();
private String repaymentsStartingFromDateFormatted;
private LocalDate repaymentsStartingFromDate;
private String interestCalculatedFromDateFormatted;
private LocalDate interestCalculatedFromDate;
private LoanSchedule repaymentSchedule;
private LoanProductData selectedProduct;
public NewLoanData() {
//
}
@@ -93,11 +93,11 @@ public class NewLoanData implements Serializable {
this.productName = productName;
}
public List<LoanProductData> getAllowedProducts() {
public List<LoanProductLookup> getAllowedProducts() {
return allowedProducts;
}
public void setAllowedProducts(List<LoanProductData> allowedProducts) {
public void setAllowedProducts(List<LoanProductLookup> allowedProducts) {
this.allowedProducts = allowedProducts;
}
@@ -137,7 +137,8 @@ public class NewLoanData implements Serializable {
return repaymentsStartingFromDate;
}
public void setRepaymentsStartingFromDate(LocalDate repaymentsStartingFromDate) {
public void setRepaymentsStartingFromDate(
LocalDate repaymentsStartingFromDate) {
this.repaymentsStartingFromDate = repaymentsStartingFromDate;
}
@@ -145,7 +146,8 @@ public class NewLoanData implements Serializable {
return interestCalculatedFromDate;
}
public void setInterestCalculatedFromDate(LocalDate interestCalculatedFromDate) {
public void setInterestCalculatedFromDate(
LocalDate interestCalculatedFromDate) {
this.interestCalculatedFromDate = interestCalculatedFromDate;
}
@@ -14,6 +14,7 @@ import org.mifosng.data.LoanRepaymentData;
import org.mifosng.data.MoneyData;
import org.mifosng.platform.api.data.ClientData;
import org.mifosng.platform.api.data.LoanProductData;
import org.mifosng.platform.api.data.LoanProductLookup;
import org.mifosng.platform.api.data.NewLoanData;
import org.mifosng.platform.client.service.ClientReadPlatformService;
import org.mifosng.platform.currency.domain.ApplicationCurrency;
@@ -44,9 +45,13 @@ public class LoanReadPlatformServiceImpl implements LoanReadPlatformService {
private final LoanTransactionRepository loanTransactionRepository;
@Autowired
public LoanReadPlatformServiceImpl(final PlatformSecurityContext context,
final LoanRepository loanRepository, final LoanTransactionRepository loanTransactionRepository, final ApplicationCurrencyRepository applicationCurrencyRepository,
final LoanProductReadPlatformService loanProductReadPlatformService, final ClientReadPlatformService clientReadPlatformService) {
public LoanReadPlatformServiceImpl(
final PlatformSecurityContext context,
final LoanRepository loanRepository,
final LoanTransactionRepository loanTransactionRepository,
final ApplicationCurrencyRepository applicationCurrencyRepository,
final LoanProductReadPlatformService loanProductReadPlatformService,
final ClientReadPlatformService clientReadPlatformService) {
this.context = context;
this.loanRepository = loanRepository;
this.loanTransactionRepository = loanTransactionRepository;
@@ -54,7 +59,7 @@ public class LoanReadPlatformServiceImpl implements LoanReadPlatformService {
this.loanProductReadPlatformService = loanProductReadPlatformService;
this.clientReadPlatformService = clientReadPlatformService;
}
@Override
public LoanAccountData retrieveLoanAccountDetails(Long loanId) {
@@ -62,13 +67,16 @@ public class LoanReadPlatformServiceImpl implements LoanReadPlatformService {
// need of loan information.
AppUser currentUser = context.authenticatedUser();
Loan loan = this.loanRepository.findOne(loansThatMatch(currentUser.getOrganisation(), loanId));
Loan loan = this.loanRepository.findOne(loansThatMatch(
currentUser.getOrganisation(), loanId));
if (loan == null) {
throw new LoanNotFoundException(loanId);
}
final String currencyCode = loan.getLoanRepaymentScheduleDetail().getPrincipal().getCurrencyCode();
ApplicationCurrency currency = this.applicationCurrencyRepository.findOneByCode(currencyCode);
final String currencyCode = loan.getLoanRepaymentScheduleDetail()
.getPrincipal().getCurrencyCode();
ApplicationCurrency currency = this.applicationCurrencyRepository
.findOneByCode(currencyCode);
if (currency == null) {
throw new CurrencyNotFoundException(currencyCode);
}
@@ -81,7 +89,7 @@ public class LoanReadPlatformServiceImpl implements LoanReadPlatformService {
return loanData;
}
private LoanAccountData convertToData(final Loan realLoan,
CurrencyData currencyData) {
@@ -166,22 +174,28 @@ public class LoanReadPlatformServiceImpl implements LoanReadPlatformService {
.getRepaymentPeriodFrequencyType().toString(),
tolerance, loanData, waiveAllowed, interestRebateOwed);
}
@Override
public NewLoanData retrieveClientAndProductDetails(final Long clientId, final Long productId) {
public NewLoanData retrieveClientAndProductDetails(final Long clientId,
final Long productId) {
AppUser currentUser = context.authenticatedUser();
NewLoanData workflowData = new NewLoanData();
workflowData.setOrganisationId(currentUser.getOrganisation().getId());
workflowData.setOrganisationName(currentUser.getOrganisation().getName());
workflowData.setOrganisationName(currentUser.getOrganisation()
.getName());
Collection<LoanProductData> loanProducts = this.loanProductReadPlatformService.retrieveAllLoanProducts();
workflowData.setAllowedProducts(new ArrayList<LoanProductData>(loanProducts));
Collection<LoanProductLookup> loanProducts = this.loanProductReadPlatformService
.retrieveAllLoanProductsForLookup();
workflowData.setAllowedProducts(new ArrayList<LoanProductLookup>(
loanProducts));
if (loanProducts.size() == 1) {
Long allowedProductId = workflowData.getAllowedProducts().get(0).getId();
LoanProductData selectedProduct = this.loanProductReadPlatformService.retrieveLoanProduct(allowedProductId);
Long allowedProductId = workflowData.getAllowedProducts().get(0)
.getId();
LoanProductData selectedProduct = this.loanProductReadPlatformService
.retrieveLoanProduct(allowedProductId);
if (selectedProduct == null) {
throw new LoanProductNotFoundException(allowedProductId);
}
@@ -190,7 +204,8 @@ public class LoanReadPlatformServiceImpl implements LoanReadPlatformService {
workflowData.setProductName(selectedProduct.getName());
workflowData.setSelectedProduct(selectedProduct);
} else {
LoanProductData selectedProduct = findLoanProductById(loanProducts, productId);
LoanProductData selectedProduct = findLoanProductById(loanProducts,
productId);
if (selectedProduct == null) {
throw new LoanProductNotFoundException(productId);
}
@@ -199,7 +214,8 @@ public class LoanReadPlatformServiceImpl implements LoanReadPlatformService {
workflowData.setSelectedProduct(selectedProduct);
}
ClientData clientAccount = this.clientReadPlatformService.retrieveIndividualClient(clientId);
ClientData clientAccount = this.clientReadPlatformService
.retrieveIndividualClient(clientId);
workflowData.setClientId(clientAccount.getId());
workflowData.setClientName(clientAccount.getDisplayName());
@@ -207,20 +223,19 @@ public class LoanReadPlatformServiceImpl implements LoanReadPlatformService {
}
private LoanProductData findLoanProductById(
Collection<LoanProductData> loanProducts, Long productId) {
Collection<LoanProductLookup> loanProducts, Long productId) {
LoanProductData match = this.loanProductReadPlatformService
.retrieveNewLoanProductDetails();
for (LoanProductData loanProductData : loanProducts) {
if (loanProductData.getId().equals(productId)) {
for (LoanProductLookup loanProductLookup : loanProducts) {
if (loanProductLookup.getId().equals(productId)) {
match = this.loanProductReadPlatformService
.retrieveLoanProduct(loanProductData.getId());
.retrieveLoanProduct(loanProductLookup.getId());
break;
}
}
return match;
}
@Override
public LoanRepaymentData retrieveNewLoanRepaymentDetails(Long loanId) {
@@ -228,13 +243,16 @@ public class LoanReadPlatformServiceImpl implements LoanReadPlatformService {
// TODO - OPTIMIZE - write simple sql query to fetch back date of
// possible next transaction date.
Loan loan = this.loanRepository.findOne(loansThatMatch(currentUser.getOrganisation(), loanId));
Loan loan = this.loanRepository.findOne(loansThatMatch(
currentUser.getOrganisation(), loanId));
if (loan == null) {
throw new LoanNotFoundException(loanId);
}
final String currencyCode = loan.getLoanRepaymentScheduleDetail().getPrincipal().getCurrencyCode();
ApplicationCurrency currency = this.applicationCurrencyRepository.findOneByCode(currencyCode);
final String currencyCode = loan.getLoanRepaymentScheduleDetail()
.getPrincipal().getCurrencyCode();
ApplicationCurrency currency = this.applicationCurrencyRepository
.findOneByCode(currencyCode);
if (currency == null) {
throw new CurrencyNotFoundException(currencyCode);
}
@@ -243,9 +261,11 @@ public class LoanReadPlatformServiceImpl implements LoanReadPlatformService {
currency.getName(), currency.getDecimalPlaces(),
currency.getDisplaySymbol(), currency.getNameCode());
LocalDate earliestUnpaidInstallmentDate = loan.possibleNextRepaymentDate();
LocalDate earliestUnpaidInstallmentDate = loan
.possibleNextRepaymentDate();
Money possibleNextRepaymentAmount = loan.possibleNextRepaymentAmount();
MoneyData possibleNextRepayment = MoneyData.of(currencyData, possibleNextRepaymentAmount.getAmount());
MoneyData possibleNextRepayment = MoneyData.of(currencyData,
possibleNextRepaymentAmount.getAmount());
LoanRepaymentData newRepaymentDetails = new LoanRepaymentData();
newRepaymentDetails.setDate(earliestUnpaidInstallmentDate);
@@ -261,13 +281,16 @@ public class LoanReadPlatformServiceImpl implements LoanReadPlatformService {
// TODO - OPTIMIZE - write simple sql query to fetch back date of
// possible next transaction date.
Loan loan = this.loanRepository.findOne(loansThatMatch(currentUser.getOrganisation(), loanId));
Loan loan = this.loanRepository.findOne(loansThatMatch(
currentUser.getOrganisation(), loanId));
if (loan == null) {
throw new LoanNotFoundException(loanId);
}
final String currencyCode = loan.getLoanRepaymentScheduleDetail().getPrincipal().getCurrencyCode();
ApplicationCurrency currency = this.applicationCurrencyRepository.findOneByCode(currencyCode);
final String currencyCode = loan.getLoanRepaymentScheduleDetail()
.getPrincipal().getCurrencyCode();
ApplicationCurrency currency = this.applicationCurrencyRepository
.findOneByCode(currencyCode);
if (currency == null) {
throw new CurrencyNotFoundException(currencyCode);
}
@@ -288,22 +311,28 @@ public class LoanReadPlatformServiceImpl implements LoanReadPlatformService {
}
@Override
public LoanRepaymentData retrieveLoanRepaymentDetails(Long loanId, Long transactionId) {
public LoanRepaymentData retrieveLoanRepaymentDetails(Long loanId,
Long transactionId) {
AppUser currentUser = context.authenticatedUser();
Loan loan = this.loanRepository.findOne(loansThatMatch(currentUser.getOrganisation(), loanId));
Loan loan = this.loanRepository.findOne(loansThatMatch(
currentUser.getOrganisation(), loanId));
if (loan == null) {
throw new LoanNotFoundException(loanId);
}
final String currencyCode = loan.getLoanRepaymentScheduleDetail().getPrincipal().getCurrencyCode();
ApplicationCurrency currency = this.applicationCurrencyRepository.findOneByCode(currencyCode);
final String currencyCode = loan.getLoanRepaymentScheduleDetail()
.getPrincipal().getCurrencyCode();
ApplicationCurrency currency = this.applicationCurrencyRepository
.findOneByCode(currencyCode);
if (currency == null) {
throw new CurrencyNotFoundException(currencyCode);
}
LoanTransaction transaction = this.loanTransactionRepository.findOne(loanTransactionsThatMatch(currentUser.getOrganisation(), transactionId));
LoanTransaction transaction = this.loanTransactionRepository
.findOne(loanTransactionsThatMatch(
currentUser.getOrganisation(), transactionId));
if (transaction == null) {
throw new LoanTransactionNotFoundException(transactionId);
}
@@ -3,11 +3,14 @@ package org.mifosng.platform.loanproduct.service;
import java.util.Collection;
import org.mifosng.platform.api.data.LoanProductData;
import org.mifosng.platform.api.data.LoanProductLookup;
public interface LoanProductReadPlatformService {
Collection<LoanProductData> retrieveAllLoanProducts();
Collection<LoanProductLookup> retrieveAllLoanProductsForLookup();
LoanProductData retrieveLoanProduct(Long productId);
LoanProductData retrieveNewLoanProductDetails();
@@ -13,6 +13,7 @@ import org.mifosng.data.CurrencyData;
import org.mifosng.data.MoneyData;
import org.mifosng.platform.api.data.EnumOptionData;
import org.mifosng.platform.api.data.LoanProductData;
import org.mifosng.platform.api.data.LoanProductLookup;
import org.mifosng.platform.currency.service.CurrencyReadPlatformService;
import org.mifosng.platform.exceptions.LoanProductNotFoundException;
import org.mifosng.platform.infrastructure.JdbcSupport;
@@ -29,15 +30,18 @@ import org.springframework.jdbc.core.simple.SimpleJdbcTemplate;
import org.springframework.stereotype.Service;
@Service
public class LoanProductReadPlatformServiceImpl implements LoanProductReadPlatformService {
public class LoanProductReadPlatformServiceImpl implements
LoanProductReadPlatformService {
private final PlatformSecurityContext context;
private final CurrencyReadPlatformService currencyReadPlatformService;
private final SimpleJdbcTemplate jdbcTemplate;
private final LoanDropdownReadPlatformService dropdownReadPlatformService;
@Autowired
public LoanProductReadPlatformServiceImpl(final PlatformSecurityContext context, final CurrencyReadPlatformService currencyReadPlatformService,
public LoanProductReadPlatformServiceImpl(
final PlatformSecurityContext context,
final CurrencyReadPlatformService currencyReadPlatformService,
final LoanDropdownReadPlatformService dropdownReadPlatformService,
final DataSource dataSource) {
this.context = context;
@@ -50,33 +54,53 @@ public class LoanProductReadPlatformServiceImpl implements LoanProductReadPlatfo
public LoanProductData retrieveLoanProduct(final Long loanProductId) {
try {
List<CurrencyData> allowedCurrencies = currencyReadPlatformService.retrieveAllPlatformCurrencies();
List<CurrencyData> allowedCurrencies = currencyReadPlatformService
.retrieveAllPlatformCurrencies();
LoanProductMapper rm = new LoanProductMapper(allowedCurrencies);
String sql = "select " + rm.loanProductSchema() + " where lp.id = ?";
LoanProductData productData = this.jdbcTemplate.queryForObject(sql, rm, new Object[] { loanProductId });
String sql = "select " + rm.loanProductSchema()
+ " where lp.id = ?";
LoanProductData productData = this.jdbcTemplate.queryForObject(sql,
rm, new Object[] { loanProductId });
populateProductDataWithDropdownOptions(productData);
return productData;
} catch (EmptyResultDataAccessException e) {
throw new LoanProductNotFoundException(loanProductId);
}
}
@Override
public Collection<LoanProductData> retrieveAllLoanProducts() {
AppUser currentUser = this.context.authenticatedUser();
// TODO - include currency read in the sql
List<CurrencyData> allowedCurrencies = currencyReadPlatformService
.retrieveAllPlatformCurrencies();
List<CurrencyData> allowedCurrencies = currencyReadPlatformService.retrieveAllPlatformCurrencies();
LoanProductMapper rm = new LoanProductMapper(allowedCurrencies);
String sql = "select " + rm.loanProductSchema() + " where lp.org_id = ?";
String sql = "select " + rm.loanProductSchema()
+ " where lp.org_id = ?";
return this.jdbcTemplate.query(sql, rm, new Object[] { currentUser.getOrganisation().getId() });
return this.jdbcTemplate.query(sql, rm, new Object[] { currentUser
.getOrganisation().getId() });
}
@Override
public Collection<LoanProductLookup> retrieveAllLoanProductsForLookup() {
AppUser currentUser = this.context.authenticatedUser();
LoanProductLookupMapper rm = new LoanProductLookupMapper();
String sql = "select " + rm.loanProductLookupSchema()
+ " where lp.org_id = ?";
return this.jdbcTemplate.query(sql, rm, new Object[] { currentUser
.getOrganisation().getId() });
}
@Override
@@ -84,11 +108,17 @@ public class LoanProductReadPlatformServiceImpl implements LoanProductReadPlatfo
LoanProductData productData = new LoanProductData();
productData.setAmortizationType(LoanEnumerations.amortizationType(AmortizationMethod.EQUAL_INSTALLMENTS));
productData.setInterestType(LoanEnumerations.interestType(InterestMethod.DECLINING_BALANCE));
productData.setRepaymentFrequencyType(LoanEnumerations.repaymentFrequencyType(PeriodFrequencyType.MONTHS));
productData.setInterestRateFrequencyType(LoanEnumerations.interestRateFrequencyType(PeriodFrequencyType.MONTHS));
productData.setInterestCalculationPeriodType(LoanEnumerations.interestCalculationPeriodType(InterestCalculationPeriodMethod.SAME_AS_REPAYMENT_PERIOD));
productData.setAmortizationType(LoanEnumerations
.amortizationType(AmortizationMethod.EQUAL_INSTALLMENTS));
productData.setInterestType(LoanEnumerations
.interestType(InterestMethod.DECLINING_BALANCE));
productData.setRepaymentFrequencyType(LoanEnumerations
.repaymentFrequencyType(PeriodFrequencyType.MONTHS));
productData.setInterestRateFrequencyType(LoanEnumerations
.interestRateFrequencyType(PeriodFrequencyType.MONTHS));
productData
.setInterestCalculationPeriodType(LoanEnumerations
.interestCalculationPeriodType(InterestCalculationPeriodMethod.SAME_AS_REPAYMENT_PERIOD));
populateProductDataWithDropdownOptions(productData);
@@ -98,11 +128,12 @@ public class LoanProductReadPlatformServiceImpl implements LoanProductReadPlatfo
productData.setPrincipal(zero);
productData.setInArrearsTolerance(zero);
}
return productData;
}
private static final class LoanProductMapper implements RowMapper<LoanProductData> {
private static final class LoanProductMapper implements
RowMapper<LoanProductData> {
private final List<CurrencyData> allowedCurrencies;
@@ -130,74 +161,121 @@ public class LoanProductReadPlatformServiceImpl implements LoanProductReadPlatfo
String description = rs.getString("description");
String currencyCode = rs.getString("currencyCode");
Integer currencyDigits = JdbcSupport.getInteger(rs, "currencyDigits");
CurrencyData currencyData = findCurrencyByCode(currencyCode, allowedCurrencies);
Integer currencyDigits = JdbcSupport.getInteger(rs,
"currencyDigits");
CurrencyData currencyData = findCurrencyByCode(currencyCode,
allowedCurrencies);
if (currencyData != null) {
currencyData.setDecimalPlaces(currencyDigits);
}
BigDecimal principal = rs.getBigDecimal("principal");
BigDecimal tolerance = rs.getBigDecimal("tolerance");
MoneyData principalMoney = MoneyData.of(currencyData, principal);
MoneyData toleranceMoney = MoneyData.of(currencyData, tolerance);
Integer numberOfRepayments = JdbcSupport.getInteger(rs, "numberOfRepayments");
Integer numberOfRepayments = JdbcSupport.getInteger(rs,
"numberOfRepayments");
Integer repaymentEvery = JdbcSupport.getInteger(rs, "repaidEvery");
BigDecimal interestRatePerPeriod = rs.getBigDecimal("interestRatePerPeriod");
BigDecimal annualInterestRate = rs.getBigDecimal("annualInterestRate");
BigDecimal interestRatePerPeriod = rs
.getBigDecimal("interestRatePerPeriod");
BigDecimal annualInterestRate = rs
.getBigDecimal("annualInterestRate");
int repaymentFrequencyTypeId = JdbcSupport.getInteger(rs,
"repaymentPeriodFrequency");
EnumOptionData repaymentFrequencyType = LoanEnumerations
.repaymentFrequencyType(repaymentFrequencyTypeId);
int amortizationTypeId = JdbcSupport.getInteger(rs,
"amortizationMethod");
EnumOptionData amortizationType = LoanEnumerations
.amortizationType(amortizationTypeId);
int interestRateFrequencyTypeId = JdbcSupport.getInteger(rs,
"interestRatePerPeriodFreq");
EnumOptionData interestRateFrequencyType = LoanEnumerations
.interestRateFrequencyType(interestRateFrequencyTypeId);
int repaymentFrequencyTypeId = JdbcSupport.getInteger(rs, "repaymentPeriodFrequency");
EnumOptionData repaymentFrequencyType = LoanEnumerations.repaymentFrequencyType(repaymentFrequencyTypeId);
int amortizationTypeId = JdbcSupport.getInteger(rs, "amortizationMethod");
EnumOptionData amortizationType = LoanEnumerations.amortizationType(amortizationTypeId);
int interestRateFrequencyTypeId = JdbcSupport.getInteger(rs, "interestRatePerPeriodFreq");
EnumOptionData interestRateFrequencyType = LoanEnumerations.interestRateFrequencyType(interestRateFrequencyTypeId);
int interestTypeId = JdbcSupport.getInteger(rs, "interestMethod");
EnumOptionData interestType = LoanEnumerations.interestType(interestTypeId);
int interestCalculationPeriodTypeId = JdbcSupport.getInteger(rs, "interestCalculationInPeriodMethod");
EnumOptionData interestCalculationPeriodType = LoanEnumerations.interestCalculationPeriodType(interestCalculationPeriodTypeId);
EnumOptionData interestType = LoanEnumerations
.interestType(interestTypeId);
int interestCalculationPeriodTypeId = JdbcSupport.getInteger(rs,
"interestCalculationInPeriodMethod");
EnumOptionData interestCalculationPeriodType = LoanEnumerations
.interestCalculationPeriodType(interestCalculationPeriodTypeId);
DateTime createdOn = JdbcSupport.getDateTime(rs, "createdon");
DateTime lastModifedOn = JdbcSupport.getDateTime(rs, "modifiedon");
return new LoanProductData(createdOn, lastModifedOn, id, name, description, principalMoney, toleranceMoney,
numberOfRepayments, repaymentEvery, interestRatePerPeriod, annualInterestRate,
repaymentFrequencyType, interestRateFrequencyType, amortizationType, interestType, interestCalculationPeriodType);
return new LoanProductData(createdOn, lastModifedOn, id, name,
description, principalMoney, toleranceMoney,
numberOfRepayments, repaymentEvery, interestRatePerPeriod,
annualInterestRate, repaymentFrequencyType,
interestRateFrequencyType, amortizationType, interestType,
interestCalculationPeriodType);
}
private CurrencyData findCurrencyByCode(String currencyCode, List<CurrencyData> allowedCurrencies) {
private CurrencyData findCurrencyByCode(String currencyCode,
List<CurrencyData> allowedCurrencies) {
CurrencyData match = null;
for (CurrencyData currencyData : allowedCurrencies) {
if (currencyData.getCode().equalsIgnoreCase(currencyCode)) {
match = currencyData;
break;
}
}
}
return match;
}
}
private void populateProductDataWithDropdownOptions(LoanProductData productData) {
private static final class LoanProductLookupMapper implements
RowMapper<LoanProductLookup> {
List<CurrencyData> currencyOptions = currencyReadPlatformService.retrieveAllowedCurrencies();
List<EnumOptionData> amortizationTypeOptions = dropdownReadPlatformService.retrieveLoanAmortizationTypeOptions();
List<EnumOptionData> interestTypeOptions = dropdownReadPlatformService.retrieveLoanInterestTypeOptions();
List<EnumOptionData> interestCalculationPeriodTypeOptions = dropdownReadPlatformService.retrieveLoanInterestRateCalculatedInPeriodOptions();
List<EnumOptionData> repaymentFrequencyTypeOptions = dropdownReadPlatformService.retrieveRepaymentFrequencyTypeOptions();
List<EnumOptionData> interestRateFrequencyTypeOptions = dropdownReadPlatformService.retrieveInterestRateFrequencyTypeOptions();
public String loanProductLookupSchema() {
return "lp.id as id, lp.name as name from portfolio_product_loan lp";
}
@Override
public LoanProductLookup mapRow(final ResultSet rs, final int rowNum)
throws SQLException {
Long id = rs.getLong("id");
String name = rs.getString("name");
return new LoanProductLookup(id, name);
}
}
private void populateProductDataWithDropdownOptions(
LoanProductData productData) {
List<CurrencyData> currencyOptions = currencyReadPlatformService
.retrieveAllowedCurrencies();
List<EnumOptionData> amortizationTypeOptions = dropdownReadPlatformService
.retrieveLoanAmortizationTypeOptions();
List<EnumOptionData> interestTypeOptions = dropdownReadPlatformService
.retrieveLoanInterestTypeOptions();
List<EnumOptionData> interestCalculationPeriodTypeOptions = dropdownReadPlatformService
.retrieveLoanInterestRateCalculatedInPeriodOptions();
List<EnumOptionData> repaymentFrequencyTypeOptions = dropdownReadPlatformService
.retrieveRepaymentFrequencyTypeOptions();
List<EnumOptionData> interestRateFrequencyTypeOptions = dropdownReadPlatformService
.retrieveInterestRateFrequencyTypeOptions();
productData.setCurrencyOptions(currencyOptions);
productData.setAmortizationTypeOptions(amortizationTypeOptions);
productData.setInterestTypeOptions(interestTypeOptions);
productData.setInterestCalculationPeriodTypeOptions(interestCalculationPeriodTypeOptions);
productData.setRepaymentFrequencyTypeOptions(repaymentFrequencyTypeOptions);
productData.setInterestRateFrequencyTypeOptions(interestRateFrequencyTypeOptions);
productData
.setInterestCalculationPeriodTypeOptions(interestCalculationPeriodTypeOptions);
productData
.setRepaymentFrequencyTypeOptions(repaymentFrequencyTypeOptions);
productData
.setInterestRateFrequencyTypeOptions(interestRateFrequencyTypeOptions);
}
}