From 40126a0ae2e20e8531ed6d36bc66f19fa6c1bf65 Mon Sep 17 00:00:00 2001 From: avarice010 Date: Wed, 8 May 2013 18:56:42 +0530 Subject: [PATCH] MIFOSX-314 Make adding new accounts of a particular type easier --- .../accounting/glaccount/api/GLAccountsApiResource.java | 4 ++-- .../accounting/glaccount/data/GLAccountData.java | 8 ++++++-- .../glaccount/service/GLAccountReadPlatformService.java | 2 +- .../service/GLAccountReadPlatformServiceImpl.java | 4 ++-- 4 files changed, 11 insertions(+), 7 deletions(-) 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 ce6d5a91a..c150ce3cf 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 @@ -73,11 +73,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 e3368f80b..9cecfcb21 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 @@ -64,14 +64,18 @@ public class GLAccountData { this.usageOptions = usageOptions; } - 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; return new GLAccountData(id, name, parentId, glCode, disabled, manualEntriesAllowed, type, usage, description); 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 5f51428f6..1974afe90 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,5 +21,5 @@ public interface GLAccountReadPlatformService { List retrieveAllEnabledDetailGLAccounts(GLAccountType accountType); - GLAccountData retrieveNewGLAccountDetails(); + GLAccountData retrieveNewGLAccountDetails(final Integer type); } 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 52ea07020..f7fa4697b 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 @@ -186,8 +186,8 @@ public class GLAccountReadPlatformServiceImpl implements GLAccountReadPlatformSe } @Override - public GLAccountData retrieveNewGLAccountDetails() { - return GLAccountData.sensibleDefaultsForNewGLAccountCreation(); + public GLAccountData retrieveNewGLAccountDetails(final Integer type) { + return GLAccountData.sensibleDefaultsForNewGLAccountCreation(type); } }