@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<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 public Collection<LoanProductData> retrieveAvailableLoanProductsForMix() { this.context.authenticatedUser(); final LoanProductLookupMapper rm = new LoanProductLookupMapper(); String sql = "Select " + rm.productMixSchema(); // 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 += " and lp.id in ( " + inClause + " ) "; } return this.jdbcTemplate.query(sql, rm, new Object[] {}); }