From 89ba32b982b28a1fa5dffd7cec3e586633377a55 Mon Sep 17 00:00:00 2001 From: Hossam Hatem <7ossam7atem1@gmail.com> Date: Fri, 21 Feb 2025 00:09:48 +0200 Subject: [PATCH] FINERACT-2081: fixed GLAccountsApiResource by replace string concatenation and remove 'ApiResponses' wrapper --- .../glaccount/api/GLAccountsApiResource.java | 90 +++++++++++++------ 1 file changed, 61 insertions(+), 29 deletions(-) diff --git a/fineract-accounting/src/main/java/org/apache/fineract/accounting/glaccount/api/GLAccountsApiResource.java b/fineract-accounting/src/main/java/org/apache/fineract/accounting/glaccount/api/GLAccountsApiResource.java index 2bbd839dd..20d0b9d8d 100644 --- a/fineract-accounting/src/main/java/org/apache/fineract/accounting/glaccount/api/GLAccountsApiResource.java +++ b/fineract-accounting/src/main/java/org/apache/fineract/accounting/glaccount/api/GLAccountsApiResource.java @@ -25,7 +25,6 @@ import io.swagger.v3.oas.annotations.media.Content; import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.parameters.RequestBody; import io.swagger.v3.oas.annotations.responses.ApiResponse; -import io.swagger.v3.oas.annotations.responses.ApiResponses; import io.swagger.v3.oas.annotations.tags.Tag; import jakarta.ws.rs.Consumes; import jakarta.ws.rs.DELETE; @@ -74,8 +73,10 @@ import org.springframework.stereotype.Component; @Path("/v1/glaccounts") @Component -@Tag(name = "General Ledger Account", description = "Ledger accounts represent an Individual account within an Organizations Chart Of Accounts(COA) and are assigned a name and unique number by which they can be identified. \n" - + "All transactions relating to a company's assets, liabilities, owners' equity, revenue and expenses are recorded against these accounts") +@Tag(name = "General Ledger Account", description = """ + Ledger accounts represent an Individual account within an Organizations Chart Of Accounts(COA) and are assigned a name and unique number by which they can be identified. + All transactions relating to a company's assets, liabilities, owners' equity, revenue and expenses are recorded against these accounts + """) @RequiredArgsConstructor public class GLAccountsApiResource { @@ -102,12 +103,26 @@ public class GLAccountsApiResource { @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) @Operation(tags = { - "General Ledger Account" }, summary = "Retrieve GL Accounts Template", description = "This is a convenience resource. It can be useful when building maintenance user interface screens for client applications. The template data returned consists of any or all of:\n" - + "\n" + "Field Defaults\n" + "Allowed Value Lists\n" + "Example Request:\n" + "\n" + "glaccounts/template\n" - + "glaccounts/template?type=1\n" + "\n" + "type is optional and integer value from 1 to 5.\n" + "\n" + "1.Assets \n" - + "2.Liabilities \n" + "3.Equity \n" + "4.Income \n" + "5.Expenses") - @ApiResponses({ - @ApiResponse(responseCode = "200", description = "OK", content = @Content(schema = @Schema(implementation = GLAccountsApiResourceSwagger.GetGLAccountsTemplateResponse.class))) }) + "General Ledger Account" }, summary = "Retrieve GL Accounts Template", description = """ + This is a convenience resource. It can be useful when building maintenance user interface screens for client applications. The template data returned consists of any or all of: + + Field Defaults + Allowed Value Lists + Example Request: + + glaccounts/template + glaccounts/template?type=1 + + type is optional and integer value from 1 to 5. + + 1.Assets + 2.Liabilities + 3.Equity + 4.Income + 5.Expenses + """) + + @ApiResponse(responseCode = "200", description = "OK", content = @Content(schema = @Schema(implementation = GLAccountsApiResourceSwagger.GetGLAccountsTemplateResponse.class))) public String retrieveNewAccountDetails(@Context final UriInfo uriInfo, @QueryParam("type") @Parameter(description = "type") final Integer type) { @@ -123,12 +138,20 @@ public class GLAccountsApiResource { @GET @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) - @Operation(tags = { "General Ledger Account" }, summary = "List General Ledger Accounts", description = "ARGUMENTS\n" - + "type Integer optional manualEntriesAllowed boolean optional usage Integer optional disabled boolean optional parentId Long optional tagId Long optional\n" - + "Example Requests:\n" + "\n" + "glaccounts\n" + "\n" + "\n" - + "glaccounts?type=1&manualEntriesAllowed=true&usage=1&disabled=false\n" + "\n" + "glaccounts?fetchRunningBalance=true") - @ApiResponses({ - @ApiResponse(responseCode = "200", description = "OK", content = @Content(array = @ArraySchema(schema = @Schema(implementation = GLAccountsApiResourceSwagger.GetGLAccountsResponse.class)))) }) + @Operation(tags = { + "General Ledger Account" }, summary = "List General Ledger Account", description = """ + ARGUMENTS + type Integer optional manualEntriesAllowed boolean optional usage Integer optional disabled boolean optional parentId Long optional tagId Long optional + Example Requests: + + glaccounts + + glaccounts?type=1&manualEntriesAllowed=true&usage=1&disabled=false + + glaccounts?fetchRunningBalance=true + """) + + @ApiResponse(responseCode = "200", description = "OK", content = @Content(array = @ArraySchema(schema = @Schema(implementation = GLAccountsApiResourceSwagger.GetGLAccountsResponse.class)))) public String retrieveAllAccounts(@Context final UriInfo uriInfo, @QueryParam("type") @Parameter(description = "type") final Integer type, @QueryParam("searchParam") @Parameter(description = "searchParam") final String searchParam, @@ -150,11 +173,18 @@ public class GLAccountsApiResource { @Path("{glAccountId}") @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) - @Operation(tags = { "General Ledger Account" }, summary = "Retrieve a General Ledger Account", description = "Example Requests:\n" - + "\n" + "glaccounts/1\n" + "\n" + "\n" + "glaccounts/1?template=true\n" + "\n" + "\n" + "glaccounts/1?fields=name,glCode\n" - + "\n" + "\n" + "glaccounts/1?fetchRunningBalance=true") - @ApiResponses({ - @ApiResponse(responseCode = "200", description = "OK", content = @Content(schema = @Schema(implementation = GLAccountsApiResourceSwagger.GetGLAccountsResponse.class))) }) + @Operation(tags = { "General Ledger Account" }, summary = "Retrieve a General Ledger Account", description = """ + Example Requests: + + glaccounts/1 + + glaccounts/1?template=true + + glaccounts/1?fields=name,glCode + + glaccounts/1?fetchRunningBalance=true + """) + @ApiResponse(responseCode = "200", description = "OK", content = @Content(schema = @Schema(implementation = GLAccountsApiResourceSwagger.GetGLAccountsResponse.class))) public String retreiveAccount(@PathParam("glAccountId") @Parameter(description = "glAccountId") final Long glAccountId, @Context final UriInfo uriInfo, @QueryParam("fetchRunningBalance") @Parameter(description = "fetchRunningBalance") final boolean runningBalance) { @@ -174,12 +204,14 @@ public class GLAccountsApiResource { @POST @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) - @Operation(tags = { - "General Ledger Account" }, summary = "Create a General Ledger Account", description = "Note: You may optionally create Hierarchical Chart of Accounts by using the \"parentId\" property of an Account\n" - + "Mandatory Fields: \n" + "name, glCode, type, usage and manualEntriesAllowed") + @Operation(tags = { "General Ledger Account" }, summary = "Create a General Ledger Account", description = """ + Note: You may optionally create Hierarchical Chart of Accounts by using the "parentId" property of an Account + Mandatory Fields: + name, glCode, type, usage and manualEntriesAllowed + """) @RequestBody(content = @Content(schema = @Schema(implementation = GLAccountsApiResourceSwagger.PostGLAccountsRequest.class))) - @ApiResponses({ - @ApiResponse(responseCode = "200", description = "OK", content = @Content(schema = @Schema(implementation = GLAccountsApiResourceSwagger.PostGLAccountsResponse.class))) }) + + @ApiResponse(responseCode = "200", description = "OK", content = @Content(schema = @Schema(implementation = GLAccountsApiResourceSwagger.PostGLAccountsResponse.class))) public String createGLAccount(@Parameter(hidden = true) final String jsonRequestBody) { final CommandWrapper commandRequest = new CommandWrapperBuilder().createGLAccount().withJson(jsonRequestBody).build(); @@ -195,8 +227,8 @@ public class GLAccountsApiResource { @Produces({ MediaType.APPLICATION_JSON }) @Operation(tags = { "General Ledger Account" }, summary = "Update a GL Account", description = "Updates a GL Account") @RequestBody(content = @Content(schema = @Schema(implementation = GLAccountsApiResourceSwagger.PutGLAccountsRequest.class))) - @ApiResponses({ - @ApiResponse(responseCode = "200", description = "OK", content = @Content(schema = @Schema(implementation = GLAccountsApiResourceSwagger.PutGLAccountsResponse.class))) }) + + @ApiResponse(responseCode = "200", description = "OK", content = @Content(schema = @Schema(implementation = GLAccountsApiResourceSwagger.PutGLAccountsResponse.class))) public String updateGLAccount(@PathParam("glAccountId") @Parameter(description = "glAccountId") final Long glAccountId, @Parameter(hidden = true) final String jsonRequestBody) { @@ -212,8 +244,8 @@ public class GLAccountsApiResource { @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) @Operation(tags = { "General Ledger Account" }, summary = "Delete a GL Account", description = "Deletes a GL Account") - @ApiResponses({ - @ApiResponse(responseCode = "200", description = "OK", content = @Content(schema = @Schema(implementation = GLAccountsApiResourceSwagger.DeleteGLAccountsRequest.class))) }) + + @ApiResponse(responseCode = "200", description = "OK", content = @Content(schema = @Schema(implementation = GLAccountsApiResourceSwagger.DeleteGLAccountsRequest.class))) public String deleteGLAccount(@PathParam("glAccountId") @Parameter(description = "glAccountId") final Long glAccountId) { final CommandWrapper commandRequest = new CommandWrapperBuilder().deleteGLAccount(glAccountId).build();