@Override public Collection<LoanProductData> retrieveAllowedProductsForMix(final Long productId) { this.context.authenticatedUser(); final LoanProductLookupMapper rm = new LoanProductLookupMapper(); String sql = "Select " + rm.schema() + " where "; // 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 += " lp.id in ( " + inClause + " ) and "; } sql += "lp.id not in (" + "Select pm.restricted_product_id from m_product_mix pm where pm.product_id=? " + "UNION " + "Select pm.product_id from m_product_mix pm where pm.restricted_product_id=?)"; return this.jdbcTemplate.query(sql, rm, new Object[] {productId, productId}); }
@Override public Collection<LoanProductData> retrieveAllLoanProductsForLookup() { this.context.authenticatedUser(); final LoanProductLookupMapper rm = new LoanProductLookupMapper(); String sql = "select " + rm.schema(); // 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 id in ( " + inClause + " ) "; } return this.jdbcTemplate.query(sql, rm, new Object[] {}); }