@Override public Collection<LoanProductData> retrieveAllLoanProducts() { AppUser currentUser = this.context.authenticatedUser(); // TODO - include currency read in the sql List<CurrencyData> allowedCurrencies = currencyReadPlatformService.retrieveAllPlatformCurrencies(); LoanProductMapper rm = new LoanProductMapper(allowedCurrencies); String sql = "select " + rm.loanProductSchema() + " where lp.org_id = ?"; return this.jdbcTemplate.query(sql, rm, new Object[] {currentUser.getOrganisation().getId()}); }
@Override public LoanProductData retrieveLoanProduct(final Long loanProductId) { try { final Collection<ChargeData> charges = this.chargeReadPlatformService.retrieveLoanProductCharges(loanProductId); final Collection<LoanProductBorrowerCycleVariationData> borrowerCycleVariationDatas = retrieveLoanProductBorrowerCycleVariations(loanProductId); final LoanProductMapper rm = new LoanProductMapper(charges, borrowerCycleVariationDatas); final String sql = "select " + rm.loanProductSchema() + " where lp.id = ?"; return this.jdbcTemplate.queryForObject(sql, rm, new Object[] {loanProductId}); } catch (final EmptyResultDataAccessException e) { throw new LoanProductNotFoundException(loanProductId); } }
@Override public LoanProductData retrieveLoanProduct(final Long loanProductId) { try { 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}); populateProductDataWithDropdownOptions(productData); return productData; } catch (EmptyResultDataAccessException e) { throw new LoanProductNotFoundException(loanProductId); } }
@Override public Collection<LoanProductData> retrieveAllLoanProducts() { this.context.authenticatedUser(); final LoanProductMapper rm = new LoanProductMapper(null, null); String sql = "select " + rm.loanProductSchema(); // Check if branch specific products are enabled. If yes, fetch only products mapped to current // user's office String inClause = mifosEntityAccessUtil.getSQLWhereClauseForProductIDsForUserOffice_ifGlobalConfigEnabled( MifosEntityType.LOAN_PRODUCT); if ((inClause != null) && (!(inClause.trim().isEmpty()))) { sql += " where lp.id in ( " + inClause + " ) "; } return this.jdbcTemplate.query(sql, rm, new Object[] {}); }