did loanproduct read TODO about joining to currency rather than matching after
This commit is contained in:
+23
-36
@@ -59,12 +59,7 @@ public class LoanProductReadPlatformServiceImpl implements
|
|||||||
public LoanProductData retrieveLoanProduct(final Long loanProductId) {
|
public LoanProductData retrieveLoanProduct(final Long loanProductId) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
List<CurrencyData> allowedCurrencies = currencyReadPlatformService
|
LoanProductMapper rm = new LoanProductMapper();
|
||||||
.retrieveAllPlatformCurrencies();
|
|
||||||
|
|
||||||
Collection<FundData> allFunds = this.fundReadPlatformService.retrieveAllFunds();
|
|
||||||
|
|
||||||
LoanProductMapper rm = new LoanProductMapper(allowedCurrencies, allFunds);
|
|
||||||
String sql = "select " + rm.loanProductSchema()
|
String sql = "select " + rm.loanProductSchema()
|
||||||
+ " where lp.id = ?";
|
+ " where lp.id = ?";
|
||||||
|
|
||||||
@@ -84,11 +79,7 @@ public class LoanProductReadPlatformServiceImpl implements
|
|||||||
|
|
||||||
AppUser currentUser = this.context.authenticatedUser();
|
AppUser currentUser = this.context.authenticatedUser();
|
||||||
|
|
||||||
// TODO - include currency read in the sql
|
LoanProductMapper rm = new LoanProductMapper();
|
||||||
List<CurrencyData> allowedCurrencies = currencyReadPlatformService.retrieveAllPlatformCurrencies();
|
|
||||||
Collection<FundData> allFunds = this.fundReadPlatformService.retrieveAllFunds();
|
|
||||||
|
|
||||||
LoanProductMapper rm = new LoanProductMapper(allowedCurrencies, allFunds);
|
|
||||||
|
|
||||||
String sql = "select " + rm.loanProductSchema()
|
String sql = "select " + rm.loanProductSchema()
|
||||||
+ " where lp.org_id = ?";
|
+ " where lp.org_id = ?";
|
||||||
@@ -140,14 +131,13 @@ public class LoanProductReadPlatformServiceImpl implements
|
|||||||
return productData;
|
return productData;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final class LoanProductMapper implements RowMapper<LoanProductData> {
|
private static final class LoanProductMapper implements
|
||||||
|
RowMapper<LoanProductData> {
|
||||||
|
|
||||||
private final List<CurrencyData> allowedCurrencies;
|
// private final List<CurrencyData> allowedCurrencies;
|
||||||
private final Collection<FundData> allFunds;
|
// private final Collection<FundData> allFunds;
|
||||||
|
|
||||||
public LoanProductMapper(List<CurrencyData> allowedCurrencies, Collection<FundData> allFunds) {
|
public LoanProductMapper() {
|
||||||
this.allowedCurrencies = allowedCurrencies;
|
|
||||||
this.allFunds = allFunds;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String loanProductSchema() {
|
public String loanProductSchema() {
|
||||||
@@ -157,8 +147,11 @@ public class LoanProductReadPlatformServiceImpl implements
|
|||||||
+ "lp.annual_nominal_interest_rate as annualInterestRate, lp.interest_method_enum as interestMethod, lp.interest_calculated_in_period_enum as interestCalculationInPeriodMethod,"
|
+ "lp.annual_nominal_interest_rate as annualInterestRate, lp.interest_method_enum as interestMethod, lp.interest_calculated_in_period_enum as interestCalculationInPeriodMethod,"
|
||||||
+ "lp.repay_every as repaidEvery, lp.repayment_period_frequency_enum as repaymentPeriodFrequency, lp.number_of_repayments as numberOfRepayments, "
|
+ "lp.repay_every as repaidEvery, lp.repayment_period_frequency_enum as repaymentPeriodFrequency, lp.number_of_repayments as numberOfRepayments, "
|
||||||
+ "lp.amortization_method_enum as amortizationMethod, lp.arrearstolerance_amount as tolerance, "
|
+ "lp.amortization_method_enum as amortizationMethod, lp.arrearstolerance_amount as tolerance, "
|
||||||
+ "lp.created_date as createdon, lp.lastmodified_date as modifiedon "
|
+ "lp.created_date as createdon, lp.lastmodified_date as modifiedon, "
|
||||||
+ " from portfolio_product_loan lp left join org_fund f on f.id = lp.fund_id";
|
+ "curr.name as currencyName, curr.internationalized_name_code as currencyNameCode, curr.display_symbol as currencyDisplaySymbol "
|
||||||
|
+ " from portfolio_product_loan lp "
|
||||||
|
+ " left join org_fund f on f.id = lp.fund_id"
|
||||||
|
+ " join ref_currency curr on curr.code = lp.currency_code";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -173,14 +166,16 @@ public class LoanProductReadPlatformServiceImpl implements
|
|||||||
String fundName = rs.getString("fundName");
|
String fundName = rs.getString("fundName");
|
||||||
|
|
||||||
String currencyCode = rs.getString("currencyCode");
|
String currencyCode = rs.getString("currencyCode");
|
||||||
|
String currencyName = rs.getString("currencyName");
|
||||||
|
String currencyNameCode = rs.getString("currencyNameCode");
|
||||||
|
String currencyDisplaySymbol = rs
|
||||||
|
.getString("currencyDisplaySymbol");
|
||||||
Integer currencyDigits = JdbcSupport.getInteger(rs,
|
Integer currencyDigits = JdbcSupport.getInteger(rs,
|
||||||
"currencyDigits");
|
"currencyDigits");
|
||||||
|
|
||||||
CurrencyData currencyData = findCurrencyByCode(currencyCode,
|
CurrencyData currencyData = new CurrencyData(currencyCode,
|
||||||
allowedCurrencies);
|
currencyName, currencyDigits, currencyDisplaySymbol,
|
||||||
if (currencyData != null) {
|
currencyNameCode);
|
||||||
currencyData.setDecimalPlaces(currencyDigits);
|
|
||||||
}
|
|
||||||
|
|
||||||
BigDecimal principal = rs.getBigDecimal("principal");
|
BigDecimal principal = rs.getBigDecimal("principal");
|
||||||
BigDecimal tolerance = rs.getBigDecimal("tolerance");
|
BigDecimal tolerance = rs.getBigDecimal("tolerance");
|
||||||
@@ -231,16 +226,6 @@ public class LoanProductReadPlatformServiceImpl implements
|
|||||||
interestCalculationPeriodType, fundId, fundName);
|
interestCalculationPeriodType, fundId, fundName);
|
||||||
}
|
}
|
||||||
|
|
||||||
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 static final class LoanProductLookupMapper implements
|
private static final class LoanProductLookupMapper implements
|
||||||
@@ -262,7 +247,8 @@ public class LoanProductReadPlatformServiceImpl implements
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void populateProductDataWithDropdownOptions(LoanProductData productData) {
|
private void populateProductDataWithDropdownOptions(
|
||||||
|
LoanProductData productData) {
|
||||||
|
|
||||||
List<CurrencyData> currencyOptions = currencyReadPlatformService
|
List<CurrencyData> currencyOptions = currencyReadPlatformService
|
||||||
.retrieveAllowedCurrencies();
|
.retrieveAllowedCurrencies();
|
||||||
@@ -277,7 +263,8 @@ public class LoanProductReadPlatformServiceImpl implements
|
|||||||
List<EnumOptionData> interestRateFrequencyTypeOptions = dropdownReadPlatformService
|
List<EnumOptionData> interestRateFrequencyTypeOptions = dropdownReadPlatformService
|
||||||
.retrieveInterestRateFrequencyTypeOptions();
|
.retrieveInterestRateFrequencyTypeOptions();
|
||||||
|
|
||||||
Collection<FundData> fundOptions = this.fundReadPlatformService.retrieveAllFunds();
|
Collection<FundData> fundOptions = this.fundReadPlatformService
|
||||||
|
.retrieveAllFunds();
|
||||||
|
|
||||||
productData.setCurrencyOptions(currencyOptions);
|
productData.setCurrencyOptions(currencyOptions);
|
||||||
productData.setAmortizationTypeOptions(amortizationTypeOptions);
|
productData.setAmortizationTypeOptions(amortizationTypeOptions);
|
||||||
|
|||||||
Reference in New Issue
Block a user