diff --git a/mifosng-provider/src/main/java/org/mifosplatform/accounting/glaccount/api/GLAccountsApiResource.java b/mifosng-provider/src/main/java/org/mifosplatform/accounting/glaccount/api/GLAccountsApiResource.java index 904bfbc87..02a150463 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/accounting/glaccount/api/GLAccountsApiResource.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/accounting/glaccount/api/GLAccountsApiResource.java @@ -50,9 +50,10 @@ import org.springframework.stereotype.Component; public class GLAccountsApiResource { private static final Set RESPONSE_DATA_PARAMETERS = new HashSet(Arrays.asList("id", "name", "parentId", "glCode", - "disabled", "manualEntriesAllowed", "type", "usage", "description", "assetHeaderAccountOptions", "liabilityHeaderAccountOptions", - "equityHeaderAccountOptions", "incomeHeaderAccountOptions", "expenseHeaderAccountOptions", "nameDecorated", "tagId", - "allowedAssetsTagOptions", "allowedLiabilitiesTagOptions", "allowedEquityTagOptions", "allowedIncomeTagOptions", "allowedExpensesTagOptions")); + "disabled", "manualEntriesAllowed", "type", "usage", "description", "assetHeaderAccountOptions", + "liabilityHeaderAccountOptions", "equityHeaderAccountOptions", "incomeHeaderAccountOptions", "expenseHeaderAccountOptions", + "nameDecorated", "tagId", "allowedAssetsTagOptions", "allowedLiabilitiesTagOptions", "allowedEquityTagOptions", + "allowedIncomeTagOptions", "allowedExpensesTagOptions", "creditAccounts", "debitAccounts")); private final String resourceNameForPermission = "GLACCOUNT"; @@ -63,12 +64,13 @@ public class GLAccountsApiResource { private final PlatformSecurityContext context; private final PortfolioCommandSourceWritePlatformService commandsSourceWritePlatformService; private final CodeValueReadPlatformService codeValueReadPlatformService; - + @Autowired public GLAccountsApiResource(final PlatformSecurityContext context, final GLAccountReadPlatformService glAccountReadPlatformService, final DefaultToApiJsonSerializer toApiJsonSerializer, final ApiRequestParameterHelper apiRequestParameterHelper, final PortfolioCommandSourceWritePlatformService commandsSourceWritePlatformService, - final AccountingDropdownReadPlatformService dropdownReadPlatformService, final CodeValueReadPlatformService codeValueReadPlatformService) { + final AccountingDropdownReadPlatformService dropdownReadPlatformService, + final CodeValueReadPlatformService codeValueReadPlatformService) { this.context = context; this.apiRequestParameterHelper = apiRequestParameterHelper; this.commandsSourceWritePlatformService = commandsSourceWritePlatformService; @@ -82,7 +84,7 @@ public class GLAccountsApiResource { @Path("template") @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) - public String retrieveNewAccountDetails(@Context final UriInfo uriInfo, @QueryParam("type") final Integer type) { + public String retrieveNewAccountDetails(@Context final UriInfo uriInfo, @QueryParam("type") final Integer type) { this.context.authenticatedUser().validateHasReadPermission(this.resourceNameForPermission); @@ -167,22 +169,32 @@ public class GLAccountsApiResource { private GLAccountData handleTemplate(final GLAccountData glAccountData) { final List accountTypeOptions = this.dropdownReadPlatformService.retrieveGLAccountTypeOptions(); final List usageOptions = this.dropdownReadPlatformService.retrieveGLAccountUsageOptions(); - final List assetHeaderAccountOptions = defaultIfEmpty(this.glAccountReadPlatformService.retrieveAllEnabledHeaderGLAccounts(GLAccountType.ASSET)); - final List liabilityHeaderAccountOptions = defaultIfEmpty(this.glAccountReadPlatformService.retrieveAllEnabledHeaderGLAccounts(GLAccountType.LIABILITY)); - final List equityHeaderAccountOptions = defaultIfEmpty(this.glAccountReadPlatformService.retrieveAllEnabledHeaderGLAccounts(GLAccountType.EQUITY)); - final List incomeHeaderAccountOptions = defaultIfEmpty(this.glAccountReadPlatformService.retrieveAllEnabledHeaderGLAccounts(GLAccountType.INCOME)); - final List expenseHeaderAccountOptions = defaultIfEmpty(this.glAccountReadPlatformService.retrieveAllEnabledHeaderGLAccounts(GLAccountType.EXPENSE)); - final Collection allowedAssetsTagOptions = this.codeValueReadPlatformService.retrieveCodeValuesByCode(AccountingConstants.ASSESTS_TAG_OPTION_CODE_NAME); - final Collection allowedLiabilitiesTagOptions = this.codeValueReadPlatformService.retrieveCodeValuesByCode(AccountingConstants.LIABILITIES_TAG_OPTION_CODE_NAME); - final Collection allowedEquityTagOptions = this.codeValueReadPlatformService.retrieveCodeValuesByCode(AccountingConstants.EQUITY_TAG_OPTION_CODE_NAME); - final Collection allowedIncomeTagOptions = this.codeValueReadPlatformService.retrieveCodeValuesByCode(AccountingConstants.INCOME_TAG_OPTION_CODE_NAME); - final Collection allowedExpensesTagOptions = this.codeValueReadPlatformService.retrieveCodeValuesByCode(AccountingConstants.EXPENSES_TAG_OPTION_CODE_NAME); - + final List assetHeaderAccountOptions = defaultIfEmpty(this.glAccountReadPlatformService + .retrieveAllEnabledHeaderGLAccounts(GLAccountType.ASSET)); + final List liabilityHeaderAccountOptions = defaultIfEmpty(this.glAccountReadPlatformService + .retrieveAllEnabledHeaderGLAccounts(GLAccountType.LIABILITY)); + final List equityHeaderAccountOptions = defaultIfEmpty(this.glAccountReadPlatformService + .retrieveAllEnabledHeaderGLAccounts(GLAccountType.EQUITY)); + final List incomeHeaderAccountOptions = defaultIfEmpty(this.glAccountReadPlatformService + .retrieveAllEnabledHeaderGLAccounts(GLAccountType.INCOME)); + final List expenseHeaderAccountOptions = defaultIfEmpty(this.glAccountReadPlatformService + .retrieveAllEnabledHeaderGLAccounts(GLAccountType.EXPENSE)); + final Collection allowedAssetsTagOptions = this.codeValueReadPlatformService + .retrieveCodeValuesByCode(AccountingConstants.ASSESTS_TAG_OPTION_CODE_NAME); + final Collection allowedLiabilitiesTagOptions = this.codeValueReadPlatformService + .retrieveCodeValuesByCode(AccountingConstants.LIABILITIES_TAG_OPTION_CODE_NAME); + final Collection allowedEquityTagOptions = this.codeValueReadPlatformService + .retrieveCodeValuesByCode(AccountingConstants.EQUITY_TAG_OPTION_CODE_NAME); + final Collection allowedIncomeTagOptions = this.codeValueReadPlatformService + .retrieveCodeValuesByCode(AccountingConstants.INCOME_TAG_OPTION_CODE_NAME); + final Collection allowedExpensesTagOptions = this.codeValueReadPlatformService + .retrieveCodeValuesByCode(AccountingConstants.EXPENSES_TAG_OPTION_CODE_NAME); + return new GLAccountData(glAccountData, accountTypeOptions, usageOptions, assetHeaderAccountOptions, liabilityHeaderAccountOptions, - equityHeaderAccountOptions, incomeHeaderAccountOptions, expenseHeaderAccountOptions, allowedAssetsTagOptions, + equityHeaderAccountOptions, incomeHeaderAccountOptions, expenseHeaderAccountOptions, allowedAssetsTagOptions, allowedLiabilitiesTagOptions, allowedEquityTagOptions, allowedIncomeTagOptions, allowedExpensesTagOptions); } - + private List defaultIfEmpty(final List list) { List returnList = null; if (list != null && !list.isEmpty()) { @@ -190,4 +202,4 @@ public class GLAccountsApiResource { } return returnList; } -} \ No newline at end of file +} diff --git a/mifosng-provider/src/main/java/org/mifosplatform/accounting/glaccount/data/GLAccountData.java b/mifosng-provider/src/main/java/org/mifosplatform/accounting/glaccount/data/GLAccountData.java index 4d3e9d3d3..004431078 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/accounting/glaccount/data/GLAccountData.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/accounting/glaccount/data/GLAccountData.java @@ -48,6 +48,10 @@ public class GLAccountData { final Collection allowedIncomeTagOptions; final Collection allowedExpensesTagOptions; + // for predefined journal entry template + private final List creditAccounts; + private final List debitAccounts; + public GLAccountData(final Long id, final String name, final Long parentId, final String glCode, final boolean disabled, final boolean manualEntriesAllowed, final EnumOptionData type, final EnumOptionData usage, final String description, final String nameDecorated, final CodeValueData tagId) { @@ -71,17 +75,19 @@ public class GLAccountData { this.expenseHeaderAccountOptions = null; this.allowedAssetsTagOptions = null; this.allowedLiabilitiesTagOptions = null; - this.allowedEquityTagOptions=null; - this.allowedIncomeTagOptions=null; - this.allowedExpensesTagOptions=null; + this.allowedEquityTagOptions = null; + this.allowedIncomeTagOptions = null; + this.allowedExpensesTagOptions = null; + this.creditAccounts = null; + this.debitAccounts = null; } public GLAccountData(final GLAccountData accountData, final List accountTypeOptions, final List usageOptions, final List assetHeaderAccountOptions, final List liabilityHeaderAccountOptions, final List equityHeaderAccountOptions, - final List incomeHeaderAccountOptions, final List expenseHeaderAccountOptions, - final Collection allowedAssetsTagOptions, final Collection allowedLiabilitiesTagOptions, - final Collection allowedEquityTagOptions, final Collection allowedIncomeTagOptions, + final List incomeHeaderAccountOptions, final List expenseHeaderAccountOptions, + final Collection allowedAssetsTagOptions, final Collection allowedLiabilitiesTagOptions, + final Collection allowedEquityTagOptions, final Collection allowedIncomeTagOptions, final Collection allowedExpensesTagOptions) { this.id = accountData.id; this.name = accountData.name; @@ -106,6 +112,8 @@ public class GLAccountData { this.allowedEquityTagOptions = allowedEquityTagOptions; this.allowedIncomeTagOptions = allowedIncomeTagOptions; this.allowedExpensesTagOptions = allowedExpensesTagOptions; + this.creditAccounts = accountData.creditAccounts; + this.debitAccounts = accountData.debitAccounts; } public static GLAccountData sensibleDefaultsForNewGLAccountCreation(final Integer glAccType) { @@ -116,19 +124,20 @@ public class GLAccountData { final boolean disabled = false; final boolean manualEntriesAllowed = true; final EnumOptionData type; - if(glAccType != null && glAccType >= GLAccountType.getMinValue() && glAccType <= GLAccountType.getMaxValue()) + if (glAccType != null && glAccType >= GLAccountType.getMinValue() && glAccType <= GLAccountType.getMaxValue()) { type = AccountingEnumerations.gLAccountType(glAccType); - else + } else { type = AccountingEnumerations.gLAccountType(GLAccountType.ASSET); + } final EnumOptionData usage = AccountingEnumerations.gLAccountUsage(GLAccountUsage.DETAIL); final String description = null; final String nameDecorated = null; final CodeValueData tagId = null; return new GLAccountData(id, name, parentId, glCode, disabled, manualEntriesAllowed, type, usage, description, nameDecorated, tagId); } - + public GLAccountData(final Long id, final String name, final String glCode) { - this.id = id; + this.id = id; this.name = name; this.parentId = null; this.glCode = glCode; @@ -148,23 +157,23 @@ public class GLAccountData { this.expenseHeaderAccountOptions = null; this.allowedAssetsTagOptions = null; this.allowedLiabilitiesTagOptions = null; - this.allowedEquityTagOptions=null; - this.allowedIncomeTagOptions=null; - this.allowedExpensesTagOptions=null; - } + this.allowedEquityTagOptions = null; + this.allowedIncomeTagOptions = null; + this.allowedExpensesTagOptions = null; + this.creditAccounts = null; + this.debitAccounts = null; + } - public Long getId() { - return this.id; - } + public Long getId() { + return this.id; + } - public String getName() { - return this.name; - } + public String getName() { + return this.name; + } - public String getGlCode() { - return this.glCode; - } - - + public String getGlCode() { + return this.glCode; + } } \ No newline at end of file diff --git a/mifosng-provider/src/main/java/org/mifosplatform/accounting/glaccount/data/GLAccountDataForLookup.java b/mifosng-provider/src/main/java/org/mifosplatform/accounting/glaccount/data/GLAccountDataForLookup.java index 94e0a537d..751a803f0 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/accounting/glaccount/data/GLAccountDataForLookup.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/accounting/glaccount/data/GLAccountDataForLookup.java @@ -1,15 +1,21 @@ package org.mifosplatform.accounting.glaccount.data; public class GLAccountDataForLookup { - - private final Long id; - - public GLAccountDataForLookup(final Long id) { - this.id = id; - } - public Long getId() { - return this.id; - } + private final Long id; + @SuppressWarnings("unused") + private final String name; + @SuppressWarnings("unused") + private final String glCode; + + public GLAccountDataForLookup(final Long id, final String name, final String glCode) { + this.id = id; + this.name = name; + this.glCode = glCode; + } + + public Long getId() { + return this.id; + } } diff --git a/mifosng-provider/src/main/java/org/mifosplatform/accounting/glaccount/service/GLAccountReadPlatformServiceImpl.java b/mifosng-provider/src/main/java/org/mifosplatform/accounting/glaccount/service/GLAccountReadPlatformServiceImpl.java index 5f85a5c77..87b9078cd 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/accounting/glaccount/service/GLAccountReadPlatformServiceImpl.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/accounting/glaccount/service/GLAccountReadPlatformServiceImpl.java @@ -214,13 +214,15 @@ public class GLAccountReadPlatformServiceImpl implements GLAccountReadPlatformSe private static final class GLAccountDataLookUpMapper implements RowMapper { public String schema() { - return " gl.id as id from acc_accounting_rule rule join acc_rule_tags tags on tags.acc_rule_id = rule.id join acc_gl_account gl on gl.tag_id=tags.tag_id"; + return " gl.id as id, gl.name as name, gl.gl_code as glCode from acc_accounting_rule rule join acc_rule_tags tags on tags.acc_rule_id = rule.id join acc_gl_account gl on gl.tag_id=tags.tag_id"; } @Override public GLAccountDataForLookup mapRow(final ResultSet rs, @SuppressWarnings("unused") final int rowNum) throws SQLException { final Long id = JdbcSupport.getLong(rs, "id"); - return new GLAccountDataForLookup(id); + final String name = rs.getString("name"); + final String glCode = rs.getString("glCode"); + return new GLAccountDataForLookup(id, name, glCode); } } diff --git a/mifosng-provider/src/main/java/org/mifosplatform/accounting/rule/api/AccountingRuleApiResource.java b/mifosng-provider/src/main/java/org/mifosplatform/accounting/rule/api/AccountingRuleApiResource.java index 961847d75..57c8746b5 100755 --- a/mifosng-provider/src/main/java/org/mifosplatform/accounting/rule/api/AccountingRuleApiResource.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/accounting/rule/api/AccountingRuleApiResource.java @@ -53,7 +53,7 @@ public class AccountingRuleApiResource { private static final Set RESPONSE_DATA_PARAMETERS = new HashSet(Arrays.asList("id", "officeId", "officeName", "accountToDebitId", "accountToCreditId", "name", "description", "systemDefined", "allowedAssetsTagOptions", "allowedLiabilitiesTagOptions", "allowedEquityTagOptions", "allowedIncomeTagOptions", "allowedExpensesTagOptions", "debitTags", - "creditTags")); + "creditTags", "creditAccounts", "debitAccounts")); private final String resourceNameForPermission = "ACCOUNTINGRULE"; diff --git a/mifosng-provider/src/main/java/org/mifosplatform/accounting/rule/data/AccountingRuleData.java b/mifosng-provider/src/main/java/org/mifosplatform/accounting/rule/data/AccountingRuleData.java index 9b8d1acdb..42aca2773 100755 --- a/mifosng-provider/src/main/java/org/mifosplatform/accounting/rule/data/AccountingRuleData.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/accounting/rule/data/AccountingRuleData.java @@ -10,6 +10,7 @@ import java.util.Collection; import java.util.List; import org.mifosplatform.accounting.glaccount.data.GLAccountData; +import org.mifosplatform.accounting.glaccount.data.GLAccountDataForLookup; import org.mifosplatform.infrastructure.codes.data.CodeValueData; import org.mifosplatform.organisation.office.data.OfficeData; @@ -40,6 +41,8 @@ public class AccountingRuleData { private final Collection allowedEquityTagOptions; private final Collection allowedIncomeTagOptions; private final Collection allowedExpensesTagOptions; + private final List creditAccounts; + private final List debitAccounts; public AccountingRuleData(final AccountingRuleData accountingRuleData, final List allowedAccounts, final List allowedOffices, final Collection allowedAssetsTagOptions, @@ -62,6 +65,8 @@ public class AccountingRuleData { this.allowedExpensesTagOptions = allowedExpensesTagOptions; this.creditTags = accountingRuleData.creditTags; this.debitTags = accountingRuleData.debitTags; + this.creditAccounts = accountingRuleData.creditAccounts; + this.debitAccounts = accountingRuleData.debitAccounts; } public AccountingRuleData(final List allowedAccounts, final List allowedOffices, @@ -85,6 +90,8 @@ public class AccountingRuleData { this.allowedExpensesTagOptions = allowedExpensesTagOptions; this.creditTags = null; this.debitTags = null; + this.creditAccounts = null; + this.debitAccounts = null; } public AccountingRuleData(final Long id, final Long officeId, final String officeName, final String name, final String description, @@ -106,10 +113,13 @@ public class AccountingRuleData { this.allowedExpensesTagOptions = null; this.creditTags = null; this.debitTags = null; + this.creditAccounts = new ArrayList(); + this.debitAccounts = new ArrayList(); } public AccountingRuleData(final AccountingRuleData accountingRuleData, final List creditTags, - final List debitTags) { + final List creditAccounts, final List debitTags, + final List debitAccounts) { this.id = accountingRuleData.id; this.officeId = accountingRuleData.officeId; this.officeName = accountingRuleData.officeName; @@ -126,7 +136,9 @@ public class AccountingRuleData { this.allowedIncomeTagOptions = accountingRuleData.allowedIncomeTagOptions; this.allowedExpensesTagOptions = accountingRuleData.allowedExpensesTagOptions; this.creditTags = creditTags; + this.creditAccounts = creditAccounts; this.debitTags = debitTags; + this.debitAccounts = debitAccounts; } public GLAccountData getDebitAccountHead() { @@ -144,4 +156,12 @@ public class AccountingRuleData { public List getDebitTags() { return this.debitTags; } + + public List getCreditAccounts() { + return this.creditAccounts; + } + + public List getDebitAccounts() { + return this.debitAccounts; + } } \ No newline at end of file diff --git a/mifosng-provider/src/main/java/org/mifosplatform/accounting/rule/service/AccountingRuleReadPlatformServiceImpl.java b/mifosng-provider/src/main/java/org/mifosplatform/accounting/rule/service/AccountingRuleReadPlatformServiceImpl.java index de1a9d6d3..e87499023 100755 --- a/mifosng-provider/src/main/java/org/mifosplatform/accounting/rule/service/AccountingRuleReadPlatformServiceImpl.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/accounting/rule/service/AccountingRuleReadPlatformServiceImpl.java @@ -14,6 +14,8 @@ import java.util.Map; import org.mifosplatform.accounting.common.AccountingEnumerations; import org.mifosplatform.accounting.glaccount.data.GLAccountData; +import org.mifosplatform.accounting.glaccount.data.GLAccountDataForLookup; +import org.mifosplatform.accounting.glaccount.service.GLAccountReadPlatformService; import org.mifosplatform.accounting.journalentry.domain.JournalEntryType; import org.mifosplatform.accounting.rule.data.AccountingRuleData; import org.mifosplatform.accounting.rule.data.AccountingTagRuleData; @@ -33,10 +35,13 @@ import org.springframework.stereotype.Service; public class AccountingRuleReadPlatformServiceImpl implements AccountingRuleReadPlatformService { private final JdbcTemplate jdbcTemplate; + private final GLAccountReadPlatformService glAccountReadPlatformService; @Autowired - public AccountingRuleReadPlatformServiceImpl(final TenantAwareRoutingDataSource dataSource) { + public AccountingRuleReadPlatformServiceImpl(final TenantAwareRoutingDataSource dataSource, + final GLAccountReadPlatformService glAccountReadPlatformService) { this.jdbcTemplate = new JdbcTemplate(dataSource); + this.glAccountReadPlatformService = glAccountReadPlatformService; } // Will remove the old one if everything goes well. @@ -88,13 +93,15 @@ public class AccountingRuleReadPlatformServiceImpl implements AccountingRuleRead } }*/ - private static final class AccountingRuleDataExtractor implements ResultSetExtractor { + private static final class AccountingRuleDataExtractor implements ResultSetExtractor> { private final String schemaSql; private final JdbcTemplate jdbcTemplate; + private final GLAccountReadPlatformService glAccountReadPlatformService; - public AccountingRuleDataExtractor(final JdbcTemplate jdbcTemplate) { + public AccountingRuleDataExtractor(final JdbcTemplate jdbcTemplate, final GLAccountReadPlatformService glAccountReadPlatformService) { this.jdbcTemplate = jdbcTemplate; + this.glAccountReadPlatformService = glAccountReadPlatformService; final StringBuilder sqlBuilder = new StringBuilder(400); sqlBuilder .append(" rule.id as id,rule.name as name, rule.office_id as officeId,office.name as officeName,") @@ -141,11 +148,17 @@ public class AccountingRuleReadPlatformServiceImpl implements AccountingRuleRead } if (accountingRuleData.getCreditAccountHead() == null) { final List creditTags = getCreditOrDebitTags(id, JournalEntryType.CREDIT.getValue()); - accountingRuleData = new AccountingRuleData(accountingRuleData, creditTags, accountingRuleData.getDebitTags()); + final List creditAccounts = this.glAccountReadPlatformService.retrieveAccountsByTagId(id, + JournalEntryType.CREDIT.getValue()); + accountingRuleData = new AccountingRuleData(accountingRuleData, creditTags, creditAccounts, + accountingRuleData.getDebitTags(), accountingRuleData.getDebitAccounts()); } if (accountingRuleData.getDebitAccountHead() == null) { final List debitTags = getCreditOrDebitTags(id, JournalEntryType.DEBIT.getValue()); - accountingRuleData = new AccountingRuleData(accountingRuleData, accountingRuleData.getCreditTags(), debitTags); + final List debitAccounts = this.glAccountReadPlatformService.retrieveAccountsByTagId(id, + JournalEntryType.DEBIT.getValue()); + accountingRuleData = new AccountingRuleData(accountingRuleData, accountingRuleData.getCreditTags(), + accountingRuleData.getCreditAccounts(), debitTags, debitAccounts); } extractedData.put(id, accountingRuleData); } @@ -162,7 +175,8 @@ public class AccountingRuleReadPlatformServiceImpl implements AccountingRuleRead @Override public List retrieveAllAccountingRules(final Long officeId) { - final AccountingRuleDataExtractor resultSetExtractor = new AccountingRuleDataExtractor(this.jdbcTemplate); + final AccountingRuleDataExtractor resultSetExtractor = new AccountingRuleDataExtractor(this.jdbcTemplate, + this.glAccountReadPlatformService); Object[] arguments = new Object[] {}; String sql = "select " + resultSetExtractor.schema() + " and system_defined=0 "; if (officeId != null) { @@ -170,21 +184,19 @@ public class AccountingRuleReadPlatformServiceImpl implements AccountingRuleRead arguments = new Object[] { officeId }; } sql = sql + " order by rule.id asc"; - @SuppressWarnings("unchecked") - final Map extractedData = (Map) this.jdbcTemplate.query(sql, - resultSetExtractor, arguments); + final Map extractedData = this.jdbcTemplate.query(sql, resultSetExtractor, arguments); return new ArrayList(extractedData.values()); } @Override public AccountingRuleData retrieveAccountingRuleById(final Long accountingRuleId) { try { - final AccountingRuleDataExtractor resultSetExtractor = new AccountingRuleDataExtractor(this.jdbcTemplate); + final AccountingRuleDataExtractor resultSetExtractor = new AccountingRuleDataExtractor(this.jdbcTemplate, + this.glAccountReadPlatformService); final String sql = "select " + resultSetExtractor.schema() + " and rule.id = ?"; - @SuppressWarnings("unchecked") - final Map extractedData = (Map) this.jdbcTemplate.query(sql, - resultSetExtractor, new Object[] { accountingRuleId }); + final Map extractedData = this.jdbcTemplate.query(sql, resultSetExtractor, + new Object[] { accountingRuleId }); final AccountingRuleData accountingRuleData = extractedData.get(accountingRuleId); if (accountingRuleData == null) { throw new AccountingRuleNotFoundException(accountingRuleId); } return accountingRuleData;