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 d3f1dd9bc..904bfbc87 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 @@ -82,11 +82,11 @@ public class GLAccountsApiResource { @Path("template") @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) - public String retrieveNewAccountDetails(@Context final UriInfo uriInfo) { + public String retrieveNewAccountDetails(@Context final UriInfo uriInfo, @QueryParam("type") final Integer type) { this.context.authenticatedUser().validateHasReadPermission(this.resourceNameForPermission); - GLAccountData glAccountData = this.glAccountReadPlatformService.retrieveNewGLAccountDetails(); + GLAccountData glAccountData = this.glAccountReadPlatformService.retrieveNewGLAccountDetails(type); glAccountData = handleTemplate(glAccountData); final ApiRequestJsonSerializationSettings settings = this.apiRequestParameterHelper.process(uriInfo.getQueryParameters()); 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 e427fc263..3b0a8aaf9 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 @@ -108,14 +108,18 @@ public class GLAccountData { this.allowedExpensesTagOptions = allowedExpensesTagOptions; } - public static GLAccountData sensibleDefaultsForNewGLAccountCreation() { + public static GLAccountData sensibleDefaultsForNewGLAccountCreation(final Integer GLAccType) { final Long id = null; final String name = null; final Long parentId = null; final String glCode = null; final boolean disabled = false; final boolean manualEntriesAllowed = true; - final EnumOptionData type = AccountingEnumerations.gLAccountType(GLAccountType.ASSET); + final EnumOptionData type; + if(GLAccType!=0) + type = AccountingEnumerations.gLAccountType(GLAccType); + else + type = AccountingEnumerations.gLAccountType(GLAccountType.ASSET); final EnumOptionData usage = AccountingEnumerations.gLAccountUsage(GLAccountUsage.DETAIL); final String description = null; final String nameDecorated = null; diff --git a/mifosng-provider/src/main/java/org/mifosplatform/accounting/glaccount/service/GLAccountReadPlatformService.java b/mifosng-provider/src/main/java/org/mifosplatform/accounting/glaccount/service/GLAccountReadPlatformService.java index 3e118df5e..d982c3153 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/accounting/glaccount/service/GLAccountReadPlatformService.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/accounting/glaccount/service/GLAccountReadPlatformService.java @@ -21,7 +21,7 @@ public interface GLAccountReadPlatformService { List retrieveAllEnabledDetailGLAccounts(GLAccountType accountType); - GLAccountData retrieveNewGLAccountDetails(); - List retrieveAllEnabledHeaderGLAccounts(GLAccountType accountType); -} + + GLAccountData retrieveNewGLAccountDetails(final Integer type); +} \ No newline at end of file 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 9f3d9ab85..8419094c4 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 @@ -42,7 +42,9 @@ public class GLAccountReadPlatformServiceImpl implements GLAccountReadPlatformSe public String schema() { return " gl.id as id, name as name, parent_id as parentId, gl_code as glCode, disabled as disabled, manual_journal_entries_allowed as manualEntriesAllowed, " - + "classification_enum as classification, account_usage as accountUsage, description as description, "+nameDecoratedBaseOnHierarchy +"as nameDecorated, " + + "classification_enum as classification, account_usage as accountUsage, description as description, " + + nameDecoratedBaseOnHierarchy + + "as nameDecorated, " + "cv.id as codeId, cv.code_value as codeValue from acc_gl_account gl left join m_code_value cv on tag_id=cv.id"; } @@ -64,7 +66,8 @@ public class GLAccountReadPlatformServiceImpl implements GLAccountReadPlatformSe final Long codeId = rs.getLong("codeId"); final String codeValue = rs.getString("codeValue"); CodeValueData tagId = CodeValueData.instance(codeId, codeValue); - return new GLAccountData(id, name, parentId, glCode, disabled, manualEntriesAllowed, accountType, usage, description, nameDecorated, tagId); + return new GLAccountData(id, name, parentId, glCode, disabled, manualEntriesAllowed, accountType, usage, description, + nameDecorated, tagId); } } @@ -191,13 +194,12 @@ public class GLAccountReadPlatformServiceImpl implements GLAccountReadPlatformSe } @Override - public GLAccountData retrieveNewGLAccountDetails() { - return GLAccountData.sensibleDefaultsForNewGLAccountCreation(); + public GLAccountData retrieveNewGLAccountDetails(final Integer type) { + return GLAccountData.sensibleDefaultsForNewGLAccountCreation(type); } - @Override - public List retrieveAllEnabledHeaderGLAccounts(GLAccountType accountType) { - return retrieveAllGLAccounts(accountType.getValue(), null, GLAccountUsage.HEADER.getValue(), null, false); - } - -} + @Override + public List retrieveAllEnabledHeaderGLAccounts(final GLAccountType accountType) { + return retrieveAllGLAccounts(accountType.getValue(), null, GLAccountUsage.HEADER.getValue(), null, false); + } +} \ No newline at end of file