From 6152bb9564243aed9b035196894e3dd8ade3cda9 Mon Sep 17 00:00:00 2001 From: avinashvijayvargiya Date: Wed, 18 Mar 2026 10:32:53 +0530 Subject: [PATCH] FINERACT-2287: New command processing for interest rate charts --- .../core/config/SecurityConfig.java | 22 ++ .../InterestRateChartSlabsApiResource.java | 121 ++++------ ...erestRateChartSlabsApiResourceSwagger.java | 108 --------- .../api/InterestRateChartsApiResource.java | 161 +++++--------- .../InterestRateChartsApiResourceSwagger.java | 60 ----- .../InterestRateChartCreateCommand.java | 29 +++ .../InterestRateChartDeleteCommand.java | 29 +++ .../InterestRateChartSlabsCreateCommand.java | 29 +++ .../InterestRateChartSlabsDeleteCommand.java | 29 +++ .../InterestRateChartSlabsUpdateCommand.java | 29 +++ .../InterestRateChartUpdateCommand.java | 29 +++ ...va => InterestRateChartCreateRequest.java} | 30 +-- .../data/InterestRateChartCreateResponse.java | 39 ++++ .../data/InterestRateChartDeleteRequest.java | 41 ++++ .../data/InterestRateChartDeleteResponse.java | 39 ++++ .../InterestRateChartSlabsCreateRequest.java | 91 ++++++++ .../InterestRateChartSlabsCreateResponse.java | 39 ++++ .../InterestRateChartSlabsDeleteRequest.java | 44 ++++ .../InterestRateChartSlabsDeleteResponse.java | 39 ++++ .../InterestRateChartSlabsUpdateRequest.java | 92 ++++++++ .../InterestRateChartSlabsUpdateResponse.java | 56 +++++ ...va => InterestRateChartUpdateRequest.java} | 24 +- .../InterestRateChartUpdateResponse.java} | 23 +- ...CreateInterestRateChartCommandHandler.java | 44 ---- ...teInterestRateChartSlabCommandHandler.java | 44 ---- ...DeleteInterestRateChartCommandHandler.java | 44 ---- ...teInterestRateChartSlabCommandHandler.java | 45 ---- ...InterestRateChartCreateCommandHandler.java | 53 +++++ ...InterestRateChartDeleteCommandHandler.java | 53 +++++ ...estRateChartSlabsCreateCommandHandler.java | 53 +++++ ...estRateChartSlabsDeleteCommandHandler.java | 53 +++++ ...estRateChartSlabsUpdateCommandHandler.java | 53 +++++ ...InterestRateChartUpdateCommandHandler.java | 53 +++++ ...UpdateInterestRateChartCommandHandler.java | 44 ---- ...teInterestRateChartSlabCommandHandler.java | 45 ---- ...InterestIncentiveDropdownReadService.java} | 3 +- ...estIncentivesDropdownReadServiceImpl.java} | 3 +- .../InterestIncentivesEnumerations.java | 1 + ...InterestRateChartDropdownReadService.java} | 3 +- ...restRateChartDropdownReadServiceImpl.java} | 3 +- ...java => InterestRateChartReadService.java} | 9 +- ... => InterestRateChartReadServiceImpl.java} | 206 ++++++++---------- ...restRateChartSlabWritePlatformService.java | 31 --- ...WritePlatformServiceJpaRepositoryImpl.java | 95 -------- ...=> InterestRateChartSlabsReadService.java} | 3 +- ...nterestRateChartSlabsReadServiceImpl.java} | 110 +++++----- .../InterestRateChartSlabsWriteService.java | 36 +++ ...nterestRateChartSlabsWriteServiceImpl.java | 120 ++++++++++ ...WritePlatformServiceJpaRepositoryImpl.java | 88 -------- .../InterestRateChartWriteService.java | 36 +++ .../InterestRateChartWriteServiceImpl.java | 87 ++++++++ .../InterestRateChartConfiguration.java | 127 +++++------ .../api/FixedDepositProductsApiResource.java | 6 +- .../RecurringDepositProductsApiResource.java | 6 +- ...erestRateChartReadPlatformServiceImpl.java | 8 +- ...DepositAccountReadPlatformServiceImpl.java | 4 +- ...DepositProductReadPlatformServiceImpl.java | 4 +- ...WritePlatformServiceJpaRepositoryImpl.java | 2 - ...WritePlatformServiceJpaRepositoryImpl.java | 2 - .../savings/starter/SavingsConfiguration.java | 18 +- .../src/main/resources/application.properties | 37 ++++ .../data/InterestRateChartData.java | 15 +- .../domain/InterestRateChartFields.java | 9 +- .../domain/InterestRateChartSlabFields.java | 12 +- .../resources/ValidationMessages.properties | 25 +++ 65 files changed, 1748 insertions(+), 1148 deletions(-) delete mode 100644 fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/api/InterestRateChartSlabsApiResourceSwagger.java create mode 100644 fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/command/InterestRateChartCreateCommand.java create mode 100644 fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/command/InterestRateChartDeleteCommand.java create mode 100644 fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/command/InterestRateChartSlabsCreateCommand.java create mode 100644 fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/command/InterestRateChartSlabsDeleteCommand.java create mode 100644 fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/command/InterestRateChartSlabsUpdateCommand.java create mode 100644 fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/command/InterestRateChartUpdateCommand.java rename fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/data/{InterestRateChartStabRequest.java => InterestRateChartCreateRequest.java} (68%) create mode 100644 fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/data/InterestRateChartCreateResponse.java create mode 100644 fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/data/InterestRateChartDeleteRequest.java create mode 100644 fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/data/InterestRateChartDeleteResponse.java create mode 100644 fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/data/InterestRateChartSlabsCreateRequest.java create mode 100644 fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/data/InterestRateChartSlabsCreateResponse.java create mode 100644 fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/data/InterestRateChartSlabsDeleteRequest.java create mode 100644 fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/data/InterestRateChartSlabsDeleteResponse.java create mode 100644 fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/data/InterestRateChartSlabsUpdateRequest.java create mode 100644 fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/data/InterestRateChartSlabsUpdateResponse.java rename fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/data/{InterestIncentiveRequest.java => InterestRateChartUpdateRequest.java} (75%) rename fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/{service/InterestRateChartWritePlatformService.java => data/InterestRateChartUpdateResponse.java} (63%) delete mode 100644 fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/handler/CreateInterestRateChartCommandHandler.java delete mode 100644 fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/handler/CreateInterestRateChartSlabCommandHandler.java delete mode 100644 fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/handler/DeleteInterestRateChartCommandHandler.java delete mode 100644 fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/handler/DeleteInterestRateChartSlabCommandHandler.java create mode 100644 fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/handler/InterestRateChartCreateCommandHandler.java create mode 100644 fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/handler/InterestRateChartDeleteCommandHandler.java create mode 100644 fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/handler/InterestRateChartSlabsCreateCommandHandler.java create mode 100644 fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/handler/InterestRateChartSlabsDeleteCommandHandler.java create mode 100644 fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/handler/InterestRateChartSlabsUpdateCommandHandler.java create mode 100644 fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/handler/InterestRateChartUpdateCommandHandler.java delete mode 100644 fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/handler/UpdateInterestRateChartCommandHandler.java delete mode 100644 fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/handler/UpdateInterestRateChartSlabCommandHandler.java rename fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/service/{InterestIncentiveDropdownReadPlatformService.java => InterestIncentiveDropdownReadService.java} (95%) rename fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/service/{InterestIncentivesDropdownReadPlatformServiceImpl.java => InterestIncentivesDropdownReadServiceImpl.java} (94%) rename fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/service/{InterestRateChartDropdownReadPlatformService.java => InterestRateChartDropdownReadService.java} (94%) rename fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/service/{InterestRateChartDropdownReadPlatformServiceImpl.java => InterestRateChartDropdownReadServiceImpl.java} (91%) rename fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/service/{InterestRateChartReadPlatformService.java => InterestRateChartReadService.java} (84%) rename fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/service/{InterestRateChartReadPlatformServiceImpl.java => InterestRateChartReadServiceImpl.java} (58%) delete mode 100644 fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/service/InterestRateChartSlabWritePlatformService.java delete mode 100644 fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/service/InterestRateChartSlabWritePlatformServiceJpaRepositoryImpl.java rename fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/service/{InterestRateChartSlabReadPlatformService.java => InterestRateChartSlabsReadService.java} (95%) rename fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/service/{InterestRateChartSlabReadPlatformServiceImpl.java => InterestRateChartSlabsReadServiceImpl.java} (69%) create mode 100644 fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/service/InterestRateChartSlabsWriteService.java create mode 100644 fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/service/InterestRateChartSlabsWriteServiceImpl.java delete mode 100644 fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/service/InterestRateChartWritePlatformServiceJpaRepositoryImpl.java create mode 100644 fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/service/InterestRateChartWriteService.java create mode 100644 fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/service/InterestRateChartWriteServiceImpl.java diff --git a/fineract-provider/src/main/java/org/apache/fineract/infrastructure/core/config/SecurityConfig.java b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/core/config/SecurityConfig.java index 2aa14cb57e7..2696fbe4fa8 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/infrastructure/core/config/SecurityConfig.java +++ b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/core/config/SecurityConfig.java @@ -335,6 +335,28 @@ public SecurityFilterChain filterChain(HttpSecurity http) throws Exception { .hasAnyAuthority(ALL_FUNCTIONS, ALL_FUNCTIONS_READ, "READ_WORKING_DAYS") .requestMatchers(API_MATCHER.matcher(HttpMethod.PUT, "/api/*/workingdays")) .hasAnyAuthority(ALL_FUNCTIONS, ALL_FUNCTIONS_WRITE, "UPDATE_WORKING_DAYS") + // interest rate chart slabs (before charts for specificity) + .requestMatchers(API_MATCHER.matcher(HttpMethod.GET, "/api/*/interestratecharts/*/chartslabs")) + .hasAnyAuthority(ALL_FUNCTIONS, ALL_FUNCTIONS_READ, "READ_CHARTSLAB") + .requestMatchers(API_MATCHER.matcher(HttpMethod.GET, "/api/*/interestratecharts/*/chartslabs/*")) + .hasAnyAuthority(ALL_FUNCTIONS, ALL_FUNCTIONS_READ, "READ_CHARTSLAB") + .requestMatchers(API_MATCHER.matcher(HttpMethod.POST, "/api/*/interestratecharts/*/chartslabs")) + .hasAnyAuthority(ALL_FUNCTIONS, ALL_FUNCTIONS_WRITE, "CREATE_CHARTSLAB") + .requestMatchers(API_MATCHER.matcher(HttpMethod.PUT, "/api/*/interestratecharts/*/chartslabs/*")) + .hasAnyAuthority(ALL_FUNCTIONS, ALL_FUNCTIONS_WRITE, "UPDATE_CHARTSLAB") + .requestMatchers(API_MATCHER.matcher(HttpMethod.DELETE, "/api/*/interestratecharts/*/chartslabs/*")) + .hasAnyAuthority(ALL_FUNCTIONS, ALL_FUNCTIONS_WRITE, "DELETE_CHARTSLAB") + // interest rate chart + .requestMatchers(API_MATCHER.matcher(HttpMethod.GET, "/api/*/interestratecharts")) + .hasAnyAuthority(ALL_FUNCTIONS, ALL_FUNCTIONS_READ, "READ_INTERESTRATECHART") + .requestMatchers(API_MATCHER.matcher(HttpMethod.GET, "/api/*/interestratecharts/*")) + .hasAnyAuthority(ALL_FUNCTIONS, ALL_FUNCTIONS_READ, "READ_INTERESTRATECHART") + .requestMatchers(API_MATCHER.matcher(HttpMethod.POST, "/api/*/interestratecharts")) + .hasAnyAuthority(ALL_FUNCTIONS, ALL_FUNCTIONS_WRITE, "CREATE_INTERESTRATECHART") + .requestMatchers(API_MATCHER.matcher(HttpMethod.PUT, "/api/*/interestratecharts/*")) + .hasAnyAuthority(ALL_FUNCTIONS, ALL_FUNCTIONS_WRITE, "UPDATE_INTERESTRATECHART") + .requestMatchers(API_MATCHER.matcher(HttpMethod.DELETE, "/api/*/interestratecharts/*")) + .hasAnyAuthority(ALL_FUNCTIONS, ALL_FUNCTIONS_WRITE, "DELETE_INTERESTRATECHART") .requestMatchers(API_MATCHER.matcher(HttpMethod.POST, "/api/*/twofactor/validate")).fullyAuthenticated() .requestMatchers(API_MATCHER.matcher("/api/*/twofactor")).fullyAuthenticated() diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/api/InterestRateChartSlabsApiResource.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/api/InterestRateChartSlabsApiResource.java index 91d8388e069..b5786244b17 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/api/InterestRateChartSlabsApiResource.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/api/InterestRateChartSlabsApiResource.java @@ -18,13 +18,9 @@ */ package org.apache.fineract.portfolio.interestratechart.api; -import static org.apache.fineract.portfolio.interestratechart.InterestRateChartSlabApiConstants.INTERESTRATE_CHART_SLAB_RESOURCE_NAME; - import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; 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.tags.Tag; import jakarta.ws.rs.Consumes; @@ -35,118 +31,97 @@ import jakarta.ws.rs.Path; import jakarta.ws.rs.PathParam; import jakarta.ws.rs.Produces; -import jakarta.ws.rs.core.Context; import jakarta.ws.rs.core.MediaType; -import jakarta.ws.rs.core.UriInfo; import java.util.List; +import java.util.function.Supplier; import lombok.RequiredArgsConstructor; -import org.apache.fineract.commands.domain.CommandWrapper; -import org.apache.fineract.commands.service.CommandWrapperBuilder; -import org.apache.fineract.commands.service.PortfolioCommandSourceWritePlatformService; -import org.apache.fineract.infrastructure.core.api.ApiRequestParameterHelper; -import org.apache.fineract.infrastructure.core.data.CommandProcessingResult; -import org.apache.fineract.infrastructure.core.serialization.ApiRequestJsonSerializationSettings; -import org.apache.fineract.infrastructure.core.serialization.DefaultToApiJsonSerializer; -import org.apache.fineract.infrastructure.security.service.PlatformSecurityContext; +import org.apache.fineract.command.core.CommandPipeline; +import org.apache.fineract.portfolio.interestratechart.command.InterestRateChartSlabsCreateCommand; +import org.apache.fineract.portfolio.interestratechart.command.InterestRateChartSlabsDeleteCommand; +import org.apache.fineract.portfolio.interestratechart.command.InterestRateChartSlabsUpdateCommand; import org.apache.fineract.portfolio.interestratechart.data.InterestRateChartSlabData; -import org.apache.fineract.portfolio.interestratechart.data.InterestRateChartStabRequest; -import org.apache.fineract.portfolio.interestratechart.service.InterestRateChartSlabReadPlatformService; +import org.apache.fineract.portfolio.interestratechart.data.InterestRateChartSlabsCreateRequest; +import org.apache.fineract.portfolio.interestratechart.data.InterestRateChartSlabsCreateResponse; +import org.apache.fineract.portfolio.interestratechart.data.InterestRateChartSlabsDeleteRequest; +import org.apache.fineract.portfolio.interestratechart.data.InterestRateChartSlabsDeleteResponse; +import org.apache.fineract.portfolio.interestratechart.data.InterestRateChartSlabsUpdateRequest; +import org.apache.fineract.portfolio.interestratechart.data.InterestRateChartSlabsUpdateResponse; +import org.apache.fineract.portfolio.interestratechart.service.InterestRateChartSlabsReadService; import org.springframework.stereotype.Component; @Path("/v1/interestratecharts/{chartId}/chartslabs") @Component +@Consumes({ MediaType.APPLICATION_JSON }) +@Produces({ MediaType.APPLICATION_JSON }) @Tag(name = "Interest Rate Slab (A.K.A interest bands)", description = "The slabs a.k.a interest bands are associated with Interest Rate Chart. These bands allow to define different interest rates for different deposit term periods.") @RequiredArgsConstructor public class InterestRateChartSlabsApiResource { - private final InterestRateChartSlabReadPlatformService interestRateChartSlabReadPlatformService; - private final PlatformSecurityContext context; - private final DefaultToApiJsonSerializer toApiJsonSerializer; - private final PortfolioCommandSourceWritePlatformService commandsSourceWritePlatformService; - private final ApiRequestParameterHelper apiRequestParameterHelper; + private final InterestRateChartSlabsReadService interestRateChartSlabsReadService; + private final CommandPipeline commandPipeline; @GET @Path("template") - @Consumes({ MediaType.APPLICATION_JSON }) - @Produces({ MediaType.APPLICATION_JSON }) - public InterestRateChartSlabData template(@PathParam("chartId") @Parameter(description = "chartId") final Long chartId) { - return this.interestRateChartSlabReadPlatformService.retrieveTemplate(); + public InterestRateChartSlabData template(@PathParam("chartId") final Long chartId) { + return interestRateChartSlabsReadService.retrieveTemplate(); } @GET - @Consumes({ MediaType.APPLICATION_JSON }) - @Produces({ MediaType.APPLICATION_JSON }) @Operation(summary = "Retrieve all Slabs", description = "Retrieve list of slabs associated with a chart\n" + "\n" + "Example Requests:\n" + "\n" + "interestratecharts/1/chartslabs") - public List retrieveAll(@PathParam("chartId") @Parameter(description = "chartId") final Long chartId) { - - this.context.authenticatedUser().validateHasReadPermission(INTERESTRATE_CHART_SLAB_RESOURCE_NAME); - return this.interestRateChartSlabReadPlatformService.retrieveAll(chartId); + public List retrieveAll(@PathParam("chartId") final Long chartId) { + return interestRateChartSlabsReadService.retrieveAll(chartId); } @GET @Path("{chartSlabId}") - @Consumes({ MediaType.APPLICATION_JSON }) - @Produces({ MediaType.APPLICATION_JSON }) @Operation(summary = "Retrieve a Slab", description = "Retrieve a slab associated with an Interest rate chart\n" + "\n" + "Example Requests:\n" + "\n" + "interestratecharts/1/chartslabs/1\n") - public InterestRateChartSlabData retrieveOne(@PathParam("chartId") @Parameter(description = "chartId") final Long chartId, - @PathParam("chartSlabId") @Parameter(description = "chartSlabId") final Long chartSlabId, @Context final UriInfo uriInfo) { - - this.context.authenticatedUser().validateHasReadPermission(INTERESTRATE_CHART_SLAB_RESOURCE_NAME); - - InterestRateChartSlabData chartSlab = this.interestRateChartSlabReadPlatformService.retrieveOne(chartId, chartSlabId); - final ApiRequestJsonSerializationSettings settings = this.apiRequestParameterHelper.process(uriInfo.getQueryParameters()); - if (settings.isTemplate()) { - chartSlab = this.interestRateChartSlabReadPlatformService.retrieveWithTemplate(chartSlab); - } - - return chartSlab; + public InterestRateChartSlabData retrieveOne(@PathParam("chartId") final Long chartId, + @PathParam("chartSlabId") final Long chartSlabId) { + return interestRateChartSlabsReadService.retrieveOne(chartId, chartSlabId); } @POST - @Consumes({ MediaType.APPLICATION_JSON }) - @Produces({ MediaType.APPLICATION_JSON }) @Operation(summary = "Create a Slab", description = "Creates a new interest rate slab for an interest rate chart.\n" + "Mandatory Fields\n" + "periodType, fromPeriod, annualInterestRate\n" + "Optional Fields\n" + "toPeriod and description\n" + "Example Requests:\n" + "\n" + "interestratecharts/1/chartslabs") - @RequestBody(required = true, content = @Content(schema = @Schema(implementation = InterestRateChartStabRequest.class))) - @ApiResponse(responseCode = "200", description = "OK", content = @Content(schema = @Schema(implementation = InterestRateChartSlabsApiResourceSwagger.PostInterestRateChartsChartIdChartSlabsResponse.class))) - public CommandProcessingResult create(@PathParam("chartId") @Parameter(description = "chartId") final Long chartId, - @Parameter(hidden = true) InterestRateChartStabRequest interestRateChartStabRequest) { - - final CommandWrapper commandRequest = new CommandWrapperBuilder().createInterestRateChartSlab(chartId) - .withJson(toApiJsonSerializer.serialize(interestRateChartStabRequest)).build(); - - return this.commandsSourceWritePlatformService.logCommandSource(commandRequest); + @ApiResponse(responseCode = "200", description = "OK", content = @Content(schema = @Schema(implementation = InterestRateChartSlabsCreateResponse.class))) + public InterestRateChartSlabsCreateResponse create(@PathParam("chartId") final Long chartId, + final InterestRateChartSlabsCreateRequest request) { + request.setChartId(chartId); + final var command = new InterestRateChartSlabsCreateCommand(); + command.setPayload(request); + final Supplier responseSupplier = commandPipeline.send(command); + return responseSupplier.get(); } @PUT @Path("{chartSlabId}") - @Consumes({ MediaType.APPLICATION_JSON }) - @Produces({ MediaType.APPLICATION_JSON }) @Operation(summary = "Update a Slab", description = "It updates the Slab from chart") - @RequestBody(required = true, content = @Content(schema = @Schema(implementation = InterestRateChartStabRequest.class))) - @ApiResponse(responseCode = "200", description = "OK", content = @Content(schema = @Schema(implementation = InterestRateChartSlabsApiResourceSwagger.PutInterestRateChartsChartIdChartSlabsChartSlabIdResponse.class))) - public CommandProcessingResult update(@PathParam("chartId") @Parameter(description = "chartId") final Long chartId, - @PathParam("chartSlabId") @Parameter(description = "chartSlabId") final Long chartSlabId, - @Parameter(hidden = true) InterestRateChartStabRequest request) { + @ApiResponse(responseCode = "200", description = "OK", content = @Content(schema = @Schema(implementation = InterestRateChartSlabsUpdateResponse.class))) + public InterestRateChartSlabsUpdateResponse update(@PathParam("chartId") final Long chartId, + @PathParam("chartSlabId") final Long chartSlabId, final InterestRateChartSlabsUpdateRequest request) { + request.setChartId(chartId); + request.setChartSlabId(chartSlabId); + + final var command = new InterestRateChartSlabsUpdateCommand(); + command.setPayload(request); - final CommandWrapper commandRequest = new CommandWrapperBuilder().updateInterestRateChartSlab(chartId, chartSlabId) - .withJson(toApiJsonSerializer.serialize(request)).build(); + final Supplier responseSupplier = commandPipeline.send(command); - return this.commandsSourceWritePlatformService.logCommandSource(commandRequest); + return responseSupplier.get(); } @DELETE @Path("{chartSlabId}") - @Consumes({ MediaType.APPLICATION_JSON }) - @Produces({ MediaType.APPLICATION_JSON }) @Operation(summary = "Delete a Slab", description = "Delete a Slab from a chart") - @ApiResponse(responseCode = "200", description = "OK", content = @Content(schema = @Schema(implementation = InterestRateChartSlabsApiResourceSwagger.DeleteInterestRateChartsChartIdChartSlabsResponse.class))) - public CommandProcessingResult delete(@PathParam("chartId") @Parameter(description = "chartId") final Long chartId, - @PathParam("chartSlabId") @Parameter(description = "chartSlabId") final Long chartSlabId) { - final CommandWrapper commandRequest = new CommandWrapperBuilder().deleteInterestRateChartSlab(chartId, chartSlabId).build(); - return this.commandsSourceWritePlatformService.logCommandSource(commandRequest); + @ApiResponse(responseCode = "200", description = "OK", content = @Content(schema = @Schema(implementation = InterestRateChartSlabsDeleteResponse.class))) + public InterestRateChartSlabsDeleteResponse delete(@PathParam("chartId") final Long chartId, + @PathParam("chartSlabId") final Long chartSlabId) { + final var command = new InterestRateChartSlabsDeleteCommand(); + command.setPayload(InterestRateChartSlabsDeleteRequest.builder().chartId(chartId).chartSlabId(chartSlabId).build()); + final Supplier responseSupplier = commandPipeline.send(command); + return responseSupplier.get(); } } diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/api/InterestRateChartSlabsApiResourceSwagger.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/api/InterestRateChartSlabsApiResourceSwagger.java deleted file mode 100644 index a28212fa402..00000000000 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/api/InterestRateChartSlabsApiResourceSwagger.java +++ /dev/null @@ -1,108 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.fineract.portfolio.interestratechart.api; - -import io.swagger.v3.oas.annotations.media.Schema; -import java.math.BigDecimal; -import java.util.Set; - -/** - * Created by Chirag Gupta on 08/12/17. - */ -final class InterestRateChartSlabsApiResourceSwagger { - - private InterestRateChartSlabsApiResourceSwagger() {} - - @Schema(description = "PostInterestRateChartsChartIdChartSlabsRequest") - public static final class PostInterestRateChartsChartIdChartSlabsRequest { - - private PostInterestRateChartsChartIdChartSlabsRequest() {} - - static final class PostInterestRateChartsChartIdChartSlabsIncentives { - - private PostInterestRateChartsChartIdChartSlabsIncentives() {} - - @Schema(example = "2") - public Integer entityType; - @Schema(example = "2") - public Integer attributeName; - @Schema(example = "2") - public Integer conditionType; - @Schema(example = "11") - public String attributeValue; - @Schema(example = "2") - public Integer incentiveType; - @Schema(example = "-1") - public BigDecimal amount; - } - - @Schema(example = "0") - public Integer periodType; - @Schema(example = "1") - public Integer fromPeriod; - @Schema(example = "180") - public Integer toPeriod; - @Schema(example = "5") - public Double annualInterestRate; - @Schema(example = "5% interest from 1 day till 180 days of deposit") - public String description; - @Schema(example = "en") - public String locale; - public Set incentives; - } - - @Schema(description = "PostInterestRateChartsChartIdChartSlabsResponse") - public static final class PostInterestRateChartsChartIdChartSlabsResponse { - - private PostInterestRateChartsChartIdChartSlabsResponse() {} - - @Schema(example = "1") - public Long resourceId; - } - - @Schema(description = "PutInterestRateChartsChartIdChartSlabsChartSlabIdRequest") - public static final class PutInterestRateChartsChartIdChartSlabsChartSlabIdRequest { - - private PutInterestRateChartsChartIdChartSlabsChartSlabIdRequest() {} - - @Schema(example = "6") - public Double annualInterestRate; - @Schema(example = "Interest rate changed to 6%") - public String description; - } - - @Schema(description = "PutInterestRateChartsChartIdChartSlabsChartSlabIdResponse") - public static final class PutInterestRateChartsChartIdChartSlabsChartSlabIdResponse { - - private PutInterestRateChartsChartIdChartSlabsChartSlabIdResponse() {} - - @Schema(example = "1") - public Long resourceId; - public PutInterestRateChartsChartIdChartSlabsChartSlabIdRequest changes; - } - - @Schema(description = "DeleteInterestRateChartsChartIdChartSlabsResponse") - public static final class DeleteInterestRateChartsChartIdChartSlabsResponse { - - private DeleteInterestRateChartsChartIdChartSlabsResponse() {} - - @Schema(example = "1") - public Long resourceId; - } -} diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/api/InterestRateChartsApiResource.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/api/InterestRateChartsApiResource.java index 8c8280c4537..4cbdf65cf06 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/api/InterestRateChartsApiResource.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/api/InterestRateChartsApiResource.java @@ -16,22 +16,13 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.fineract.portfolio.interestratechart.api; -import static org.apache.fineract.portfolio.interestratechart.InterestRateChartApiConstants.chartSlabs; -import static org.apache.fineract.portfolio.interestratechart.InterestRateChartApiConstants.descriptionParamName; -import static org.apache.fineract.portfolio.interestratechart.InterestRateChartApiConstants.endDateParamName; -import static org.apache.fineract.portfolio.interestratechart.InterestRateChartApiConstants.fromDateParamName; -import static org.apache.fineract.portfolio.interestratechart.InterestRateChartApiConstants.idParamName; -import static org.apache.fineract.portfolio.interestratechart.InterestRateChartApiConstants.isPrimaryGroupingByAmountParamName; -import static org.apache.fineract.portfolio.interestratechart.InterestRateChartApiConstants.nameParamName; +package org.apache.fineract.portfolio.interestratechart.api; import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.media.ArraySchema; 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.tags.Tag; import jakarta.ws.rs.Consumes; @@ -43,146 +34,106 @@ import jakarta.ws.rs.PathParam; import jakarta.ws.rs.Produces; import jakarta.ws.rs.QueryParam; -import jakarta.ws.rs.core.Context; import jakarta.ws.rs.core.MediaType; -import jakarta.ws.rs.core.UriInfo; -import java.util.Arrays; import java.util.Collection; -import java.util.HashSet; -import java.util.Set; +import java.util.function.Supplier; import lombok.RequiredArgsConstructor; -import org.apache.fineract.commands.domain.CommandWrapper; -import org.apache.fineract.commands.service.CommandWrapperBuilder; -import org.apache.fineract.commands.service.PortfolioCommandSourceWritePlatformService; -import org.apache.fineract.infrastructure.core.api.ApiParameterHelper; -import org.apache.fineract.infrastructure.core.api.ApiRequestParameterHelper; -import org.apache.fineract.infrastructure.core.data.CommandProcessingResult; -import org.apache.fineract.infrastructure.core.serialization.ApiRequestJsonSerializationSettings; -import org.apache.fineract.infrastructure.core.serialization.DefaultToApiJsonSerializer; -import org.apache.fineract.infrastructure.security.service.PlatformSecurityContext; +import org.apache.fineract.command.core.CommandPipeline; import org.apache.fineract.portfolio.interestratechart.InterestRateChartApiConstants; +import org.apache.fineract.portfolio.interestratechart.command.InterestRateChartCreateCommand; +import org.apache.fineract.portfolio.interestratechart.command.InterestRateChartDeleteCommand; +import org.apache.fineract.portfolio.interestratechart.command.InterestRateChartUpdateCommand; +import org.apache.fineract.portfolio.interestratechart.data.InterestRateChartCreateRequest; +import org.apache.fineract.portfolio.interestratechart.data.InterestRateChartCreateResponse; import org.apache.fineract.portfolio.interestratechart.data.InterestRateChartData; -import org.apache.fineract.portfolio.interestratechart.service.InterestRateChartReadPlatformService; +import org.apache.fineract.portfolio.interestratechart.data.InterestRateChartDeleteRequest; +import org.apache.fineract.portfolio.interestratechart.data.InterestRateChartDeleteResponse; +import org.apache.fineract.portfolio.interestratechart.data.InterestRateChartUpdateRequest; +import org.apache.fineract.portfolio.interestratechart.data.InterestRateChartUpdateResponse; +import org.apache.fineract.portfolio.interestratechart.service.InterestRateChartReadService; import org.springframework.stereotype.Component; @Path("/v1/interestratecharts") @Component +@Consumes({ MediaType.APPLICATION_JSON }) +@Produces({ MediaType.APPLICATION_JSON }) @Tag(name = "Interest Rate Chart", description = "This defines an interest rate scheme that can be associated to a term deposit product. This will have a slab (band or range) of deposit periods and the associated interest rates applicable along with incentives for each band.") @RequiredArgsConstructor public class InterestRateChartsApiResource { - private final InterestRateChartReadPlatformService chartReadPlatformService; - private final PlatformSecurityContext context; - private final DefaultToApiJsonSerializer toApiJsonSerializer; - private final PortfolioCommandSourceWritePlatformService commandsSourceWritePlatformService; - private final ApiRequestParameterHelper apiRequestParameterHelper; - private static final Set INTERESTRATE_CHART_RESPONSE_DATA_PARAMETERS = new HashSet<>(Arrays.asList( - InterestRateChartApiConstants.localeParamName, InterestRateChartApiConstants.dateFormatParamName, idParamName, nameParamName, - descriptionParamName, fromDateParamName, endDateParamName, chartSlabs, isPrimaryGroupingByAmountParamName)); + private final InterestRateChartReadService chartReadPlatformService; + + private final CommandPipeline commandPipeline; @GET @Path("template") - @Consumes({ MediaType.APPLICATION_JSON }) - @Produces({ MediaType.APPLICATION_JSON }) - @Operation(summary = "Retrieve Chart Details Template", description = "This is a convenience resource. It can be useful when building maintenance user interface screens for creating a chart. The template data returned consists of any or all of:\n" - + "\n" + "Field Defaults\n" + "Allowed Value Lists\n" + "Example Request:\n" + "\n" + "interestratecharts/template") + @Operation(summary = "Retrieve Chart Details Template", description = """ + This is a convenience resource. It can be useful when building maintenance user interface screens for creating a chart. The template data returned consists of any or all of: Field Defaults Allowed Value Lists + Example Request: interestratecharts/template + """) @ApiResponse(responseCode = "200", description = "OK", content = @Content(schema = @Schema(implementation = InterestRateChartsApiResourceSwagger.GetInterestRateChartsTemplateResponse.class))) - public String template(@Context final UriInfo uriInfo) { - this.context.authenticatedUser().validateHasReadPermission(InterestRateChartApiConstants.INTERESTRATE_CHART_RESOURCE_NAME); - - InterestRateChartData chartData = this.chartReadPlatformService.template(); - - final ApiRequestJsonSerializationSettings settings = this.apiRequestParameterHelper.process(uriInfo.getQueryParameters()); - return this.toApiJsonSerializer.serialize(settings, chartData, INTERESTRATE_CHART_RESPONSE_DATA_PARAMETERS); + public InterestRateChartData template() { + return chartReadPlatformService.template(); } @GET - @Consumes({ MediaType.APPLICATION_JSON }) - @Produces({ MediaType.APPLICATION_JSON }) - @Operation(summary = "Retrieve all Charts", description = "Retrieve list of charts associated with a term deposit product(FD or RD).\n" - + "Example Requests:\n" + "\n" + "interestratecharts?productId=1") + @Operation(summary = "Retrieve all Charts", description = """ + Retrieve list of charts associated with a term deposit product(FD or RD). + Example Requests: interestratecharts?productId=1 + """) @ApiResponse(responseCode = "200", description = "OK", content = @Content(array = @ArraySchema(schema = @Schema(implementation = InterestRateChartsApiResourceSwagger.GetInterestRateChartsResponse.class)))) - public String retrieveAll(@Context final UriInfo uriInfo, - @QueryParam("productId") @Parameter(description = "productId") final Long productId) { + public Collection retrieveAll(@QueryParam("productId") final Long productId) { - this.context.authenticatedUser().validateHasReadPermission(InterestRateChartApiConstants.INTERESTRATE_CHART_RESOURCE_NAME); - - Collection chartDatas = this.chartReadPlatformService.retrieveAllWithSlabs(productId); - - final ApiRequestJsonSerializationSettings settings = this.apiRequestParameterHelper.process(uriInfo.getQueryParameters()); - return this.toApiJsonSerializer.serialize(settings, chartDatas, INTERESTRATE_CHART_RESPONSE_DATA_PARAMETERS); + return chartReadPlatformService.retrieveAllWithSlabs(productId); } @GET @Path("{chartId}") - @Consumes({ MediaType.APPLICATION_JSON }) - @Produces({ MediaType.APPLICATION_JSON }) @Operation(summary = "Retrieve a Chart", description = "It retrieves the Interest Rate Chart\n" + "Example Requests:\n" + "\n" + "interestratecharts/1") @ApiResponse(responseCode = "200", description = "OK", content = @Content(schema = @Schema(implementation = InterestRateChartsApiResourceSwagger.GetInterestRateChartsResponse.class))) - public String retrieveOne(@PathParam("chartId") @Parameter(description = "chartId") final Long chartId, - @Context final UriInfo uriInfo) { - - this.context.authenticatedUser().validateHasReadPermission(InterestRateChartApiConstants.INTERESTRATE_CHART_RESOURCE_NAME); - - InterestRateChartData chartData = null; - final Set associationParameters = ApiParameterHelper.extractAssociationsForResponseIfProvided(uriInfo.getQueryParameters()); - if (!associationParameters.isEmpty() && associationParameters.contains(InterestRateChartApiConstants.chartSlabs)) { - chartData = this.chartReadPlatformService.retrieveOneWithSlabs(chartId); + public InterestRateChartData retrieveOne(@PathParam("chartId") final Long chartId, + @QueryParam("associations") final String associations) { + InterestRateChartData chartData; + if (associations != null && associations.contains(InterestRateChartApiConstants.chartSlabs)) { + chartData = chartReadPlatformService.retrieveOneWithSlabs(chartId); } else { - chartData = this.chartReadPlatformService.retrieveOne(chartId); + chartData = chartReadPlatformService.retrieveOne(chartId); } - - final ApiRequestJsonSerializationSettings settings = this.apiRequestParameterHelper.process(uriInfo.getQueryParameters()); - if (settings.isTemplate()) { - chartData = this.chartReadPlatformService.retrieveWithTemplate(chartData); - } - - return this.toApiJsonSerializer.serialize(settings, chartData, INTERESTRATE_CHART_RESPONSE_DATA_PARAMETERS); + return chartData; } @POST - @Consumes({ MediaType.APPLICATION_JSON }) - @Produces({ MediaType.APPLICATION_JSON }) @Operation(summary = "Create a Chart", description = "Creates a new chart which can be attached to a term deposit products (FD or RD).") - @RequestBody(required = true, content = @Content(schema = @Schema(implementation = InterestRateChartsApiResourceSwagger.PostInterestRateChartsRequest.class))) - @ApiResponse(responseCode = "200", description = "OK", content = @Content(schema = @Schema(implementation = InterestRateChartsApiResourceSwagger.PostInterestRateChartsResponse.class))) - public String create(@Parameter(hidden = true) final String apiRequestBodyAsJson) { - - final CommandWrapper commandRequest = new CommandWrapperBuilder().createInterestRateChart().withJson(apiRequestBodyAsJson).build(); + @ApiResponse(responseCode = "200", description = "OK", content = @Content(schema = @Schema(implementation = InterestRateChartCreateResponse.class))) + public InterestRateChartCreateResponse create(final InterestRateChartCreateRequest request) { - final CommandProcessingResult result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest); - - return this.toApiJsonSerializer.serialize(result); + final var command = new InterestRateChartCreateCommand(); + command.setPayload(request); + final Supplier responseSupplier = commandPipeline.send(command); + return responseSupplier.get(); } @PUT @Path("{chartId}") - @Consumes({ MediaType.APPLICATION_JSON }) - @Produces({ MediaType.APPLICATION_JSON }) @Operation(summary = "Update a Chart", description = "It updates the chart") - @RequestBody(required = true, content = @Content(schema = @Schema(implementation = InterestRateChartsApiResourceSwagger.PutInterestRateChartsChartIdRequest.class))) - @ApiResponse(responseCode = "200", description = "OK", content = @Content(schema = @Schema(implementation = InterestRateChartsApiResourceSwagger.PutInterestRateChartsChartIdResponse.class))) - public String update(@PathParam("chartId") @Parameter(description = "chartId") final Long chartId, - @Parameter(hidden = true) final String apiRequestBodyAsJson) { - - final CommandWrapper commandRequest = new CommandWrapperBuilder().updateInterestRateChart(chartId).withJson(apiRequestBodyAsJson) - .build(); - - final CommandProcessingResult result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest); - - return this.toApiJsonSerializer.serialize(result); + @ApiResponse(responseCode = "200", description = "OK", content = @Content(schema = @Schema(implementation = InterestRateChartUpdateResponse.class))) + public InterestRateChartUpdateResponse update(@PathParam("chartId") final Long chartId, final InterestRateChartUpdateRequest request) { + request.setId(chartId); + final var command = new InterestRateChartUpdateCommand(); + command.setPayload(request); + final Supplier responseSupplier = commandPipeline.send(command); + return responseSupplier.get(); } @DELETE @Path("{chartId}") - @Consumes({ MediaType.APPLICATION_JSON }) - @Produces({ MediaType.APPLICATION_JSON }) @Operation(summary = "Delete a Chart", description = "It deletes the chart") - @ApiResponse(responseCode = "200", description = "OK", content = @Content(schema = @Schema(implementation = InterestRateChartsApiResourceSwagger.DeleteInterestRateChartsChartIdResponse.class))) - public String delete(@PathParam("chartId") @Parameter(description = "chartId") final Long chartId) { - final CommandWrapper commandRequest = new CommandWrapperBuilder().deleteInterestRateChart(chartId).build(); - final CommandProcessingResult result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest); - return this.toApiJsonSerializer.serialize(result); + @ApiResponse(responseCode = "200", description = "OK", content = @Content(schema = @Schema(implementation = InterestRateChartDeleteResponse.class))) + public InterestRateChartDeleteResponse delete(@PathParam("chartId") final Long chartId) { + final var command = new InterestRateChartDeleteCommand(); + command.setPayload(InterestRateChartDeleteRequest.builder().chartId(chartId).build()); + final Supplier responseSupplier = commandPipeline.send(command); + return responseSupplier.get(); } } diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/api/InterestRateChartsApiResourceSwagger.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/api/InterestRateChartsApiResourceSwagger.java index b0feeca8e67..49ff6740ce7 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/api/InterestRateChartsApiResourceSwagger.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/api/InterestRateChartsApiResourceSwagger.java @@ -22,9 +22,6 @@ import java.time.LocalDate; import java.util.Set; -/** - * Created by Chirag Gupta on 12/04/17. - */ final class InterestRateChartsApiResourceSwagger { private InterestRateChartsApiResourceSwagger() {} @@ -96,61 +93,4 @@ private GetInterestRateChartsCurrency() {} public String savingsProductName; public Set chartSlabs; } - - @Schema(description = "PostInterestRateChartsRequest") - public static final class PostInterestRateChartsRequest { - - private PostInterestRateChartsRequest() {} - - @Schema(example = "Chart - 2014") - public String name; - @Schema(example = "This chart is applicable for year 2014") - public String description; - @Schema(example = "Document") - public String type; - @Schema(example = "en") - public String locale; - @Schema(example = "dd MMMM yyyy") - public String dateFormat; - @Schema(example = "01 Jan 2014") - public String fromDate; - } - - @Schema(description = "PostInterestRateChartsResponse") - public static final class PostInterestRateChartsResponse { - - private PostInterestRateChartsResponse() {} - - @Schema(example = "1") - public Long resourceId; - } - - @Schema(description = "PutInterestRateChartsChartIdRequest") - public static final class PutInterestRateChartsChartIdRequest { - - private PutInterestRateChartsChartIdRequest() {} - - @Schema(example = "Interest rate chart for 2014") - public String name; - @Schema(example = "Interest rate chart for 2014") - public String description; - } - - @Schema(description = "PutInterestRateChartsChartIdResponse") - public static final class PutInterestRateChartsChartIdResponse { - - private PutInterestRateChartsChartIdResponse() {} - - @Schema(example = "1") - public Long resourceId; - } - - @Schema(description = "DeleteInterestRateChartsChartIdResponse") - public static final class DeleteInterestRateChartsChartIdResponse { - - private DeleteInterestRateChartsChartIdResponse() {} - - @Schema(example = "1") - public Long resourceId; - } } diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/command/InterestRateChartCreateCommand.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/command/InterestRateChartCreateCommand.java new file mode 100644 index 00000000000..a0a72c6168d --- /dev/null +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/command/InterestRateChartCreateCommand.java @@ -0,0 +1,29 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.fineract.portfolio.interestratechart.command; + +import lombok.Data; +import lombok.EqualsAndHashCode; +import org.apache.fineract.command.core.Command; +import org.apache.fineract.portfolio.interestratechart.data.InterestRateChartCreateRequest; + +@Data +@EqualsAndHashCode(callSuper = true) +public class InterestRateChartCreateCommand extends Command {} diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/command/InterestRateChartDeleteCommand.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/command/InterestRateChartDeleteCommand.java new file mode 100644 index 00000000000..1486c0a6f84 --- /dev/null +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/command/InterestRateChartDeleteCommand.java @@ -0,0 +1,29 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.fineract.portfolio.interestratechart.command; + +import lombok.Data; +import lombok.EqualsAndHashCode; +import org.apache.fineract.command.core.Command; +import org.apache.fineract.portfolio.interestratechart.data.InterestRateChartDeleteRequest; + +@Data +@EqualsAndHashCode(callSuper = true) +public class InterestRateChartDeleteCommand extends Command {} diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/command/InterestRateChartSlabsCreateCommand.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/command/InterestRateChartSlabsCreateCommand.java new file mode 100644 index 00000000000..5b3cdde0057 --- /dev/null +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/command/InterestRateChartSlabsCreateCommand.java @@ -0,0 +1,29 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.fineract.portfolio.interestratechart.command; + +import lombok.Data; +import lombok.EqualsAndHashCode; +import org.apache.fineract.command.core.Command; +import org.apache.fineract.portfolio.interestratechart.data.InterestRateChartSlabsCreateRequest; + +@Data +@EqualsAndHashCode(callSuper = true) +public class InterestRateChartSlabsCreateCommand extends Command {} diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/command/InterestRateChartSlabsDeleteCommand.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/command/InterestRateChartSlabsDeleteCommand.java new file mode 100644 index 00000000000..fb62d9f9c50 --- /dev/null +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/command/InterestRateChartSlabsDeleteCommand.java @@ -0,0 +1,29 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.fineract.portfolio.interestratechart.command; + +import lombok.Data; +import lombok.EqualsAndHashCode; +import org.apache.fineract.command.core.Command; +import org.apache.fineract.portfolio.interestratechart.data.InterestRateChartSlabsDeleteRequest; + +@Data +@EqualsAndHashCode(callSuper = true) +public class InterestRateChartSlabsDeleteCommand extends Command {} diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/command/InterestRateChartSlabsUpdateCommand.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/command/InterestRateChartSlabsUpdateCommand.java new file mode 100644 index 00000000000..5d4905b8684 --- /dev/null +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/command/InterestRateChartSlabsUpdateCommand.java @@ -0,0 +1,29 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.fineract.portfolio.interestratechart.command; + +import lombok.Data; +import lombok.EqualsAndHashCode; +import org.apache.fineract.command.core.Command; +import org.apache.fineract.portfolio.interestratechart.data.InterestRateChartSlabsUpdateRequest; + +@Data +@EqualsAndHashCode(callSuper = true) +public class InterestRateChartSlabsUpdateCommand extends Command {} diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/command/InterestRateChartUpdateCommand.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/command/InterestRateChartUpdateCommand.java new file mode 100644 index 00000000000..ceab67450b8 --- /dev/null +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/command/InterestRateChartUpdateCommand.java @@ -0,0 +1,29 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.fineract.portfolio.interestratechart.command; + +import lombok.Data; +import lombok.EqualsAndHashCode; +import org.apache.fineract.command.core.Command; +import org.apache.fineract.portfolio.interestratechart.data.InterestRateChartUpdateRequest; + +@Data +@EqualsAndHashCode(callSuper = true) +public class InterestRateChartUpdateCommand extends Command {} diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/data/InterestRateChartStabRequest.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/data/InterestRateChartCreateRequest.java similarity index 68% rename from fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/data/InterestRateChartStabRequest.java rename to fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/data/InterestRateChartCreateRequest.java index fd95c692564..a28d768d581 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/data/InterestRateChartStabRequest.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/data/InterestRateChartCreateRequest.java @@ -16,30 +16,34 @@ * specific language governing permissions and limitations * under the License. */ + package org.apache.fineract.portfolio.interestratechart.data; import java.io.Serial; import java.io.Serializable; -import java.math.BigDecimal; -import java.util.List; +import lombok.AllArgsConstructor; +import lombok.Builder; import lombok.Data; import lombok.NoArgsConstructor; +@Builder @Data @NoArgsConstructor -public class InterestRateChartStabRequest implements Serializable { +@AllArgsConstructor +public class InterestRateChartCreateRequest implements Serializable { @Serial private static final long serialVersionUID = 1L; - private String locale; - private String currencyCode; - private String description; - private Integer periodType; - private Integer fromPeriod; - private Integer toPeriod; - private BigDecimal amountRangeFrom; - private BigDecimal amountRangeTo; - private BigDecimal annualInterestRate; - private List incentives; + public String name; + + public String description; + + public String type; + + public String locale; + + public String dateFormat; + + public String fromDate; } diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/data/InterestRateChartCreateResponse.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/data/InterestRateChartCreateResponse.java new file mode 100644 index 00000000000..05f353039ab --- /dev/null +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/data/InterestRateChartCreateResponse.java @@ -0,0 +1,39 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.fineract.portfolio.interestratechart.data; + +import java.io.Serial; +import java.io.Serializable; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Builder +@Data +@NoArgsConstructor +@AllArgsConstructor +public class InterestRateChartCreateResponse implements Serializable { + + @Serial + private static final long serialVersionUID = 1L; + + private Long resourceId; +} diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/data/InterestRateChartDeleteRequest.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/data/InterestRateChartDeleteRequest.java new file mode 100644 index 00000000000..71d24d235e1 --- /dev/null +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/data/InterestRateChartDeleteRequest.java @@ -0,0 +1,41 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.fineract.portfolio.interestratechart.data; + +import jakarta.validation.constraints.NotNull; +import java.io.Serial; +import java.io.Serializable; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Builder +@Data +@NoArgsConstructor +@AllArgsConstructor +public class InterestRateChartDeleteRequest implements Serializable { + + @Serial + private static final long serialVersionUID = 1L; + + @NotNull(message = "{org.apache.fineract.portfolio.interestratechart.id.not-null}") + private Long chartId; +} diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/data/InterestRateChartDeleteResponse.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/data/InterestRateChartDeleteResponse.java new file mode 100644 index 00000000000..38f85f188df --- /dev/null +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/data/InterestRateChartDeleteResponse.java @@ -0,0 +1,39 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.fineract.portfolio.interestratechart.data; + +import java.io.Serial; +import java.io.Serializable; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Builder +@Data +@NoArgsConstructor +@AllArgsConstructor +public class InterestRateChartDeleteResponse implements Serializable { + + @Serial + private static final long serialVersionUID = 1L; + + private Long resourceId; +} diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/data/InterestRateChartSlabsCreateRequest.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/data/InterestRateChartSlabsCreateRequest.java new file mode 100644 index 00000000000..127959faa5a --- /dev/null +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/data/InterestRateChartSlabsCreateRequest.java @@ -0,0 +1,91 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.fineract.portfolio.interestratechart.data; + +import io.swagger.v3.oas.annotations.Hidden; +import java.io.Serial; +import java.io.Serializable; +import java.math.BigDecimal; +import java.util.List; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +@AllArgsConstructor +@NoArgsConstructor +@Data +@Builder +public class InterestRateChartSlabsCreateRequest implements Serializable { + + @Serial + private static final long serialVersionUID = 1L; + + @Hidden + private Long chartId; + + private Long chartSlabId; + + private Integer periodType; + + private Integer fromPeriod; + + private Integer toPeriod; + + private BigDecimal amountRangeFrom; + + private BigDecimal amountRangeTo; + + private Double annualInterestRate; + + private String currencyCode; + + private String description; + + private String locale; + + private List incentives; + + @AllArgsConstructor + @NoArgsConstructor + @Data + @Builder + public static class Incentive implements Serializable { + + @Serial + private static final long serialVersionUID = 1L; + + private Long id; + + private String description; + + private Integer entityType; + + private Integer attributeName; + + private Integer conditionType; + + private String attributeValue; + + private Integer incentiveType; + + private BigDecimal amount; + } +} diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/data/InterestRateChartSlabsCreateResponse.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/data/InterestRateChartSlabsCreateResponse.java new file mode 100644 index 00000000000..62c59bd3182 --- /dev/null +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/data/InterestRateChartSlabsCreateResponse.java @@ -0,0 +1,39 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.fineract.portfolio.interestratechart.data; + +import java.io.Serial; +import java.io.Serializable; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Builder +@Data +@NoArgsConstructor +@AllArgsConstructor +public class InterestRateChartSlabsCreateResponse implements Serializable { + + @Serial + private static final long serialVersionUID = 1L; + + private Long resourceId; +} diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/data/InterestRateChartSlabsDeleteRequest.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/data/InterestRateChartSlabsDeleteRequest.java new file mode 100644 index 00000000000..e8f9e091efc --- /dev/null +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/data/InterestRateChartSlabsDeleteRequest.java @@ -0,0 +1,44 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.fineract.portfolio.interestratechart.data; + +import jakarta.validation.constraints.NotNull; +import java.io.Serial; +import java.io.Serializable; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +@AllArgsConstructor +@NoArgsConstructor +@Data +@Builder +public class InterestRateChartSlabsDeleteRequest implements Serializable { + + @Serial + private static final long serialVersionUID = 1L; + + @NotNull(message = "{org.apache.fineract.portfolio.interestratechartslabs.chart-id.not-null}") + private Long chartId; + + @NotNull(message = "{org.apache.fineract.portfolio.interestratechartslabs.chart-slab-id.not-null}") + private Long chartSlabId; +} diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/data/InterestRateChartSlabsDeleteResponse.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/data/InterestRateChartSlabsDeleteResponse.java new file mode 100644 index 00000000000..b8f9da85ee7 --- /dev/null +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/data/InterestRateChartSlabsDeleteResponse.java @@ -0,0 +1,39 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.fineract.portfolio.interestratechart.data; + +import java.io.Serial; +import java.io.Serializable; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Builder +@Data +@NoArgsConstructor +@AllArgsConstructor +public class InterestRateChartSlabsDeleteResponse implements Serializable { + + @Serial + private static final long serialVersionUID = 1L; + + private Long resourceId; +} diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/data/InterestRateChartSlabsUpdateRequest.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/data/InterestRateChartSlabsUpdateRequest.java new file mode 100644 index 00000000000..c211c7e872d --- /dev/null +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/data/InterestRateChartSlabsUpdateRequest.java @@ -0,0 +1,92 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.fineract.portfolio.interestratechart.data; + +import io.swagger.v3.oas.annotations.Hidden; +import java.io.Serial; +import java.io.Serializable; +import java.math.BigDecimal; +import java.util.List; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +@AllArgsConstructor +@NoArgsConstructor +@Data +@Builder +public class InterestRateChartSlabsUpdateRequest implements Serializable { + + @Serial + private static final long serialVersionUID = 1L; + + @Hidden + private Long chartId; + + @Hidden + private Long chartSlabId; + + private Integer periodType; + + private Integer fromPeriod; + + private Integer toPeriod; + + private BigDecimal amountRangeFrom; + + private BigDecimal amountRangeTo; + + private Double annualInterestRate; + + private String currencyCode; + + private String description; + + private String locale; + + private List incentives; + + @AllArgsConstructor + @NoArgsConstructor + @Data + @Builder + public static class Incentive implements Serializable { + + @Serial + private static final long serialVersionUID = 1L; + + private Long id; + + private String description; + + private Integer entityType; + + private Integer attributeName; + + private Integer conditionType; + + private String attributeValue; + + private Integer incentiveType; + + private BigDecimal amount; + } +} diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/data/InterestRateChartSlabsUpdateResponse.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/data/InterestRateChartSlabsUpdateResponse.java new file mode 100644 index 00000000000..10ecaa4faa9 --- /dev/null +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/data/InterestRateChartSlabsUpdateResponse.java @@ -0,0 +1,56 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.fineract.portfolio.interestratechart.data; + +import java.io.Serial; +import java.io.Serializable; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Builder +@AllArgsConstructor +@NoArgsConstructor +@Data +public class InterestRateChartSlabsUpdateResponse implements Serializable { + + @Serial + private static final long serialVersionUID = 1L; + + private Long resourceId; + + private InterestRateChartSlabsUpdateChanges changes; + + @Builder + @AllArgsConstructor + @NoArgsConstructor + @Data + public static class InterestRateChartSlabsUpdateChanges implements Serializable { + + @Serial + private static final long serialVersionUID = 1L; + + private Double annualInterestRate; + + private String description; + } + +} diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/data/InterestIncentiveRequest.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/data/InterestRateChartUpdateRequest.java similarity index 75% rename from fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/data/InterestIncentiveRequest.java rename to fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/data/InterestRateChartUpdateRequest.java index f3c84204757..53b37587dca 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/data/InterestIncentiveRequest.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/data/InterestRateChartUpdateRequest.java @@ -16,24 +16,30 @@ * specific language governing permissions and limitations * under the License. */ + package org.apache.fineract.portfolio.interestratechart.data; +import io.swagger.v3.oas.annotations.Hidden; +import java.io.Serial; import java.io.Serializable; -import java.math.BigDecimal; +import lombok.AllArgsConstructor; +import lombok.Builder; import lombok.Data; import lombok.NoArgsConstructor; +@Builder @Data @NoArgsConstructor -public class InterestIncentiveRequest implements Serializable { +@AllArgsConstructor +public class InterestRateChartUpdateRequest implements Serializable { + + @Serial + private static final long serialVersionUID = 1L; + @Hidden private Long id; - private String description; - private Integer entityType; - private Integer attributeName; - private Integer conditionType; - private String attributeValue; - private Integer incentiveType; - private BigDecimal amount; + private String name; + + private String description; } diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/service/InterestRateChartWritePlatformService.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/data/InterestRateChartUpdateResponse.java similarity index 63% rename from fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/service/InterestRateChartWritePlatformService.java rename to fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/data/InterestRateChartUpdateResponse.java index 401731666cd..7ac93d63be1 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/service/InterestRateChartWritePlatformService.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/data/InterestRateChartUpdateResponse.java @@ -16,16 +16,25 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.fineract.portfolio.interestratechart.service; -import org.apache.fineract.infrastructure.core.api.JsonCommand; -import org.apache.fineract.infrastructure.core.data.CommandProcessingResult; +package org.apache.fineract.portfolio.interestratechart.data; -public interface InterestRateChartWritePlatformService { +import java.io.Serial; +import java.io.Serializable; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; - CommandProcessingResult create(JsonCommand command); +@Builder +@AllArgsConstructor +@NoArgsConstructor +@Data +public class InterestRateChartUpdateResponse implements Serializable { - CommandProcessingResult update(Long interestChartId, JsonCommand command); + @Serial + private static final long serialVersionUID = 1L; + + private Long resourceId; - CommandProcessingResult deleteChart(Long interestChartId); } diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/handler/CreateInterestRateChartCommandHandler.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/handler/CreateInterestRateChartCommandHandler.java deleted file mode 100644 index 8d9472fda76..00000000000 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/handler/CreateInterestRateChartCommandHandler.java +++ /dev/null @@ -1,44 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.fineract.portfolio.interestratechart.handler; - -import org.apache.fineract.commands.annotation.CommandType; -import org.apache.fineract.commands.handler.NewCommandSourceHandler; -import org.apache.fineract.infrastructure.core.api.JsonCommand; -import org.apache.fineract.infrastructure.core.data.CommandProcessingResult; -import org.apache.fineract.portfolio.interestratechart.service.InterestRateChartWritePlatformService; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -@Service -@CommandType(entity = "INTERESTRATECHART", action = "CREATE") -public class CreateInterestRateChartCommandHandler implements NewCommandSourceHandler { - - private final InterestRateChartWritePlatformService writePlatformService; - - @Autowired - public CreateInterestRateChartCommandHandler(final InterestRateChartWritePlatformService writePlatformService) { - this.writePlatformService = writePlatformService; - } - - @Override - public CommandProcessingResult processCommand(final JsonCommand command) { - return this.writePlatformService.create(command); - } -} diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/handler/CreateInterestRateChartSlabCommandHandler.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/handler/CreateInterestRateChartSlabCommandHandler.java deleted file mode 100644 index f3d77239037..00000000000 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/handler/CreateInterestRateChartSlabCommandHandler.java +++ /dev/null @@ -1,44 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.fineract.portfolio.interestratechart.handler; - -import org.apache.fineract.commands.annotation.CommandType; -import org.apache.fineract.commands.handler.NewCommandSourceHandler; -import org.apache.fineract.infrastructure.core.api.JsonCommand; -import org.apache.fineract.infrastructure.core.data.CommandProcessingResult; -import org.apache.fineract.portfolio.interestratechart.service.InterestRateChartSlabWritePlatformService; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -@Service -@CommandType(entity = "CHARTSLAB", action = "CREATE") -public class CreateInterestRateChartSlabCommandHandler implements NewCommandSourceHandler { - - private final InterestRateChartSlabWritePlatformService writePlatformService; - - @Autowired - public CreateInterestRateChartSlabCommandHandler(final InterestRateChartSlabWritePlatformService writePlatformService) { - this.writePlatformService = writePlatformService; - } - - @Override - public CommandProcessingResult processCommand(final JsonCommand command) { - return this.writePlatformService.create(command); - } -} diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/handler/DeleteInterestRateChartCommandHandler.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/handler/DeleteInterestRateChartCommandHandler.java deleted file mode 100644 index bb556602041..00000000000 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/handler/DeleteInterestRateChartCommandHandler.java +++ /dev/null @@ -1,44 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.fineract.portfolio.interestratechart.handler; - -import org.apache.fineract.commands.annotation.CommandType; -import org.apache.fineract.commands.handler.NewCommandSourceHandler; -import org.apache.fineract.infrastructure.core.api.JsonCommand; -import org.apache.fineract.infrastructure.core.data.CommandProcessingResult; -import org.apache.fineract.portfolio.interestratechart.service.InterestRateChartWritePlatformService; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -@Service -@CommandType(entity = "INTERESTRATECHART", action = "DELETE") -public class DeleteInterestRateChartCommandHandler implements NewCommandSourceHandler { - - private final InterestRateChartWritePlatformService writePlatformService; - - @Autowired - public DeleteInterestRateChartCommandHandler(final InterestRateChartWritePlatformService writePlatformService) { - this.writePlatformService = writePlatformService; - } - - @Override - public CommandProcessingResult processCommand(final JsonCommand command) { - return this.writePlatformService.deleteChart(command.entityId()); - } -} diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/handler/DeleteInterestRateChartSlabCommandHandler.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/handler/DeleteInterestRateChartSlabCommandHandler.java deleted file mode 100644 index d58610982a7..00000000000 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/handler/DeleteInterestRateChartSlabCommandHandler.java +++ /dev/null @@ -1,45 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.fineract.portfolio.interestratechart.handler; - -import org.apache.fineract.commands.annotation.CommandType; -import org.apache.fineract.commands.handler.NewCommandSourceHandler; -import org.apache.fineract.infrastructure.core.api.JsonCommand; -import org.apache.fineract.infrastructure.core.data.CommandProcessingResult; -import org.apache.fineract.portfolio.interestratechart.service.InterestRateChartSlabWritePlatformService; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -@Service -@CommandType(entity = "CHARTSLAB", action = "DELETE") -public class DeleteInterestRateChartSlabCommandHandler implements NewCommandSourceHandler { - - private final InterestRateChartSlabWritePlatformService writePlatformService; - - @Autowired - public DeleteInterestRateChartSlabCommandHandler(final InterestRateChartSlabWritePlatformService writePlatformService) { - this.writePlatformService = writePlatformService; - } - - @Override - public CommandProcessingResult processCommand(final JsonCommand command) { - // command.subentityId(); //returns chart id - return this.writePlatformService.deleteChartSlab(command.entityId(), command.subentityId()); - } -} diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/handler/InterestRateChartCreateCommandHandler.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/handler/InterestRateChartCreateCommandHandler.java new file mode 100644 index 00000000000..8555f12db51 --- /dev/null +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/handler/InterestRateChartCreateCommandHandler.java @@ -0,0 +1,53 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.fineract.portfolio.interestratechart.handler; + +import io.github.resilience4j.retry.annotation.Retry; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.apache.fineract.command.core.Command; +import org.apache.fineract.command.core.CommandHandler; +import org.apache.fineract.portfolio.interestratechart.data.InterestRateChartCreateRequest; +import org.apache.fineract.portfolio.interestratechart.data.InterestRateChartCreateResponse; +import org.apache.fineract.portfolio.interestratechart.service.InterestRateChartWriteService; +import org.springframework.stereotype.Component; +import org.springframework.transaction.annotation.Transactional; + +@Slf4j +@Component +@RequiredArgsConstructor +public class InterestRateChartCreateCommandHandler + implements CommandHandler { + + private final InterestRateChartWriteService writePlatformService; + + @Retry(name = "commandInterestRateChartCreate", fallbackMethod = "fallback") + @Override + @Transactional + public InterestRateChartCreateResponse handle(Command command) { + return writePlatformService.createInterestRateChart(command.getPayload()); + } + + @Override + public InterestRateChartCreateResponse fallback(Command command, Throwable t) { + // NOTE: fallback method needs to be in the same class + return CommandHandler.super.fallback(command, t); + } +} diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/handler/InterestRateChartDeleteCommandHandler.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/handler/InterestRateChartDeleteCommandHandler.java new file mode 100644 index 00000000000..530dc25064c --- /dev/null +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/handler/InterestRateChartDeleteCommandHandler.java @@ -0,0 +1,53 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.fineract.portfolio.interestratechart.handler; + +import io.github.resilience4j.retry.annotation.Retry; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.apache.fineract.command.core.Command; +import org.apache.fineract.command.core.CommandHandler; +import org.apache.fineract.portfolio.interestratechart.data.InterestRateChartDeleteRequest; +import org.apache.fineract.portfolio.interestratechart.data.InterestRateChartDeleteResponse; +import org.apache.fineract.portfolio.interestratechart.service.InterestRateChartWriteService; +import org.springframework.stereotype.Component; +import org.springframework.transaction.annotation.Transactional; + +@Slf4j +@Component +@RequiredArgsConstructor +public class InterestRateChartDeleteCommandHandler + implements CommandHandler { + + private final InterestRateChartWriteService writePlatformService; + + @Retry(name = "commandInterestRateChartDelete", fallbackMethod = "fallback") + @Override + @Transactional + public InterestRateChartDeleteResponse handle(Command command) { + return writePlatformService.deleteInterestRateChart(command.getPayload()); + } + + @Override + public InterestRateChartDeleteResponse fallback(Command command, Throwable t) { + // NOTE: fallback method needs to be in the same class + return CommandHandler.super.fallback(command, t); + } +} diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/handler/InterestRateChartSlabsCreateCommandHandler.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/handler/InterestRateChartSlabsCreateCommandHandler.java new file mode 100644 index 00000000000..435ae43ecc8 --- /dev/null +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/handler/InterestRateChartSlabsCreateCommandHandler.java @@ -0,0 +1,53 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.fineract.portfolio.interestratechart.handler; + +import io.github.resilience4j.retry.annotation.Retry; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.apache.fineract.command.core.Command; +import org.apache.fineract.command.core.CommandHandler; +import org.apache.fineract.portfolio.interestratechart.data.InterestRateChartSlabsCreateRequest; +import org.apache.fineract.portfolio.interestratechart.data.InterestRateChartSlabsCreateResponse; +import org.apache.fineract.portfolio.interestratechart.service.InterestRateChartSlabsWriteService; +import org.springframework.stereotype.Component; +import org.springframework.transaction.annotation.Transactional; + +@Slf4j +@Component +@RequiredArgsConstructor +public class InterestRateChartSlabsCreateCommandHandler + implements CommandHandler { + + private final InterestRateChartSlabsWriteService writePlatformService; + + @Retry(name = "commandInterestRateChartSlabsCreate", fallbackMethod = "fallback") + @Override + @Transactional + public InterestRateChartSlabsCreateResponse handle(Command command) { + return writePlatformService.createInterestRateChartSlab(command.getPayload()); + } + + @Override + public InterestRateChartSlabsCreateResponse fallback(Command command, Throwable t) { + // NOTE: fallback method needs to be in the same class + return CommandHandler.super.fallback(command, t); + } +} diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/handler/InterestRateChartSlabsDeleteCommandHandler.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/handler/InterestRateChartSlabsDeleteCommandHandler.java new file mode 100644 index 00000000000..9d1e29769b5 --- /dev/null +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/handler/InterestRateChartSlabsDeleteCommandHandler.java @@ -0,0 +1,53 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.fineract.portfolio.interestratechart.handler; + +import io.github.resilience4j.retry.annotation.Retry; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.apache.fineract.command.core.Command; +import org.apache.fineract.command.core.CommandHandler; +import org.apache.fineract.portfolio.interestratechart.data.InterestRateChartSlabsDeleteRequest; +import org.apache.fineract.portfolio.interestratechart.data.InterestRateChartSlabsDeleteResponse; +import org.apache.fineract.portfolio.interestratechart.service.InterestRateChartSlabsWriteService; +import org.springframework.stereotype.Component; +import org.springframework.transaction.annotation.Transactional; + +@Slf4j +@Component +@RequiredArgsConstructor +public class InterestRateChartSlabsDeleteCommandHandler + implements CommandHandler { + + private final InterestRateChartSlabsWriteService writePlatformService; + + @Retry(name = "commandInterestRateChartSlabsDelete", fallbackMethod = "fallback") + @Override + @Transactional + public InterestRateChartSlabsDeleteResponse handle(Command command) { + return writePlatformService.deleteInterestRateChartSlab(command.getPayload()); + } + + @Override + public InterestRateChartSlabsDeleteResponse fallback(Command command, Throwable t) { + // NOTE: fallback method needs to be in the same class + return CommandHandler.super.fallback(command, t); + } +} diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/handler/InterestRateChartSlabsUpdateCommandHandler.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/handler/InterestRateChartSlabsUpdateCommandHandler.java new file mode 100644 index 00000000000..3fb86de012d --- /dev/null +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/handler/InterestRateChartSlabsUpdateCommandHandler.java @@ -0,0 +1,53 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.fineract.portfolio.interestratechart.handler; + +import io.github.resilience4j.retry.annotation.Retry; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.apache.fineract.command.core.Command; +import org.apache.fineract.command.core.CommandHandler; +import org.apache.fineract.portfolio.interestratechart.data.InterestRateChartSlabsUpdateRequest; +import org.apache.fineract.portfolio.interestratechart.data.InterestRateChartSlabsUpdateResponse; +import org.apache.fineract.portfolio.interestratechart.service.InterestRateChartSlabsWriteService; +import org.springframework.stereotype.Component; +import org.springframework.transaction.annotation.Transactional; + +@Slf4j +@Component +@RequiredArgsConstructor +public class InterestRateChartSlabsUpdateCommandHandler + implements CommandHandler { + + private final InterestRateChartSlabsWriteService writePlatformService; + + @Retry(name = "commandInterestRateChartSlabsUpdate", fallbackMethod = "fallback") + @Override + @Transactional + public InterestRateChartSlabsUpdateResponse handle(Command command) { + return writePlatformService.updateInterestRateChartSlab(command.getPayload()); + } + + @Override + public InterestRateChartSlabsUpdateResponse fallback(Command command, Throwable t) { + // NOTE: fallback method needs to be in the same class + return CommandHandler.super.fallback(command, t); + } +} diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/handler/InterestRateChartUpdateCommandHandler.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/handler/InterestRateChartUpdateCommandHandler.java new file mode 100644 index 00000000000..b9716a6aea0 --- /dev/null +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/handler/InterestRateChartUpdateCommandHandler.java @@ -0,0 +1,53 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.fineract.portfolio.interestratechart.handler; + +import io.github.resilience4j.retry.annotation.Retry; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.apache.fineract.command.core.Command; +import org.apache.fineract.command.core.CommandHandler; +import org.apache.fineract.portfolio.interestratechart.data.InterestRateChartUpdateRequest; +import org.apache.fineract.portfolio.interestratechart.data.InterestRateChartUpdateResponse; +import org.apache.fineract.portfolio.interestratechart.service.InterestRateChartWriteService; +import org.springframework.stereotype.Component; +import org.springframework.transaction.annotation.Transactional; + +@Slf4j +@Component +@RequiredArgsConstructor +public class InterestRateChartUpdateCommandHandler + implements CommandHandler { + + private final InterestRateChartWriteService writePlatformService; + + @Retry(name = "commandInterestRateChartUpdate", fallbackMethod = "fallback") + @Override + @Transactional + public InterestRateChartUpdateResponse handle(Command command) { + return writePlatformService.updateInterestRateChart(command.getPayload()); + } + + @Override + public InterestRateChartUpdateResponse fallback(Command command, Throwable t) { + // NOTE: fallback method needs to be in the same class + return CommandHandler.super.fallback(command, t); + } +} diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/handler/UpdateInterestRateChartCommandHandler.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/handler/UpdateInterestRateChartCommandHandler.java deleted file mode 100644 index c1bba0abfca..00000000000 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/handler/UpdateInterestRateChartCommandHandler.java +++ /dev/null @@ -1,44 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.fineract.portfolio.interestratechart.handler; - -import org.apache.fineract.commands.annotation.CommandType; -import org.apache.fineract.commands.handler.NewCommandSourceHandler; -import org.apache.fineract.infrastructure.core.api.JsonCommand; -import org.apache.fineract.infrastructure.core.data.CommandProcessingResult; -import org.apache.fineract.portfolio.interestratechart.service.InterestRateChartWritePlatformService; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -@Service -@CommandType(entity = "INTERESTRATECHART", action = "UPDATE") -public class UpdateInterestRateChartCommandHandler implements NewCommandSourceHandler { - - private final InterestRateChartWritePlatformService writePlatformService; - - @Autowired - public UpdateInterestRateChartCommandHandler(final InterestRateChartWritePlatformService writePlatformService) { - this.writePlatformService = writePlatformService; - } - - @Override - public CommandProcessingResult processCommand(final JsonCommand command) { - return this.writePlatformService.update(command.entityId(), command); - } -} diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/handler/UpdateInterestRateChartSlabCommandHandler.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/handler/UpdateInterestRateChartSlabCommandHandler.java deleted file mode 100644 index b24427a1c23..00000000000 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/handler/UpdateInterestRateChartSlabCommandHandler.java +++ /dev/null @@ -1,45 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.fineract.portfolio.interestratechart.handler; - -import org.apache.fineract.commands.annotation.CommandType; -import org.apache.fineract.commands.handler.NewCommandSourceHandler; -import org.apache.fineract.infrastructure.core.api.JsonCommand; -import org.apache.fineract.infrastructure.core.data.CommandProcessingResult; -import org.apache.fineract.portfolio.interestratechart.service.InterestRateChartSlabWritePlatformService; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -@Service -@CommandType(entity = "CHARTSLAB", action = "UPDATE") -public class UpdateInterestRateChartSlabCommandHandler implements NewCommandSourceHandler { - - private final InterestRateChartSlabWritePlatformService writePlatformService; - - @Autowired - public UpdateInterestRateChartSlabCommandHandler(final InterestRateChartSlabWritePlatformService writePlatformService) { - this.writePlatformService = writePlatformService; - } - - @Override - public CommandProcessingResult processCommand(final JsonCommand command) { - // command.subentityId();//returns chart id - return this.writePlatformService.update(command.entityId(), command.subentityId(), command); - } -} diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/service/InterestIncentiveDropdownReadPlatformService.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/service/InterestIncentiveDropdownReadService.java similarity index 95% rename from fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/service/InterestIncentiveDropdownReadPlatformService.java rename to fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/service/InterestIncentiveDropdownReadService.java index 5315b4d3709..69e67593020 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/service/InterestIncentiveDropdownReadPlatformService.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/service/InterestIncentiveDropdownReadService.java @@ -16,12 +16,13 @@ * specific language governing permissions and limitations * under the License. */ + package org.apache.fineract.portfolio.interestratechart.service; import java.util.Collection; import org.apache.fineract.infrastructure.core.data.EnumOptionData; -public interface InterestIncentiveDropdownReadPlatformService { +public interface InterestIncentiveDropdownReadService { Collection retrieveEntityTypeOptions(); diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/service/InterestIncentivesDropdownReadPlatformServiceImpl.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/service/InterestIncentivesDropdownReadServiceImpl.java similarity index 94% rename from fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/service/InterestIncentivesDropdownReadPlatformServiceImpl.java rename to fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/service/InterestIncentivesDropdownReadServiceImpl.java index 28879b5ca28..234f5de3fee 100755 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/service/InterestIncentivesDropdownReadPlatformServiceImpl.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/service/InterestIncentivesDropdownReadServiceImpl.java @@ -16,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ + package org.apache.fineract.portfolio.interestratechart.service; import java.util.Collection; @@ -28,7 +29,7 @@ import org.apache.fineract.portfolio.interestratechart.incentive.InterestIncentiveType; @NoArgsConstructor -public class InterestIncentivesDropdownReadPlatformServiceImpl implements InterestIncentiveDropdownReadPlatformService { +public class InterestIncentivesDropdownReadServiceImpl implements InterestIncentiveDropdownReadService { @Override public Collection retrieveEntityTypeOptions() { diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/service/InterestIncentivesEnumerations.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/service/InterestIncentivesEnumerations.java index 33058e03aeb..abf0a7e5c00 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/service/InterestIncentivesEnumerations.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/service/InterestIncentivesEnumerations.java @@ -16,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ + package org.apache.fineract.portfolio.interestratechart.service; import java.util.ArrayList; diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/service/InterestRateChartDropdownReadPlatformService.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/service/InterestRateChartDropdownReadService.java similarity index 94% rename from fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/service/InterestRateChartDropdownReadPlatformService.java rename to fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/service/InterestRateChartDropdownReadService.java index dfaea1fe48d..54d2416d4bb 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/service/InterestRateChartDropdownReadPlatformService.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/service/InterestRateChartDropdownReadService.java @@ -16,12 +16,13 @@ * specific language governing permissions and limitations * under the License. */ + package org.apache.fineract.portfolio.interestratechart.service; import java.util.Collection; import org.apache.fineract.infrastructure.core.data.EnumOptionData; -public interface InterestRateChartDropdownReadPlatformService { +public interface InterestRateChartDropdownReadService { Collection retrievePeriodTypeOptions(); } diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/service/InterestRateChartDropdownReadPlatformServiceImpl.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/service/InterestRateChartDropdownReadServiceImpl.java similarity index 91% rename from fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/service/InterestRateChartDropdownReadPlatformServiceImpl.java rename to fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/service/InterestRateChartDropdownReadServiceImpl.java index 384845a596c..8d582b0557f 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/service/InterestRateChartDropdownReadPlatformServiceImpl.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/service/InterestRateChartDropdownReadServiceImpl.java @@ -16,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ + package org.apache.fineract.portfolio.interestratechart.service; import java.util.Collection; @@ -24,7 +25,7 @@ import org.apache.fineract.portfolio.common.domain.PeriodFrequencyType; @NoArgsConstructor -public class InterestRateChartDropdownReadPlatformServiceImpl implements InterestRateChartDropdownReadPlatformService { +public class InterestRateChartDropdownReadServiceImpl implements InterestRateChartDropdownReadService { @Override public Collection retrievePeriodTypeOptions() { diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/service/InterestRateChartReadPlatformService.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/service/InterestRateChartReadService.java similarity index 84% rename from fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/service/InterestRateChartReadPlatformService.java rename to fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/service/InterestRateChartReadService.java index 764be19f21b..0b61eee3eed 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/service/InterestRateChartReadPlatformService.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/service/InterestRateChartReadService.java @@ -16,19 +16,16 @@ * specific language governing permissions and limitations * under the License. */ + package org.apache.fineract.portfolio.interestratechart.service; import java.util.Collection; import org.apache.fineract.portfolio.interestratechart.data.InterestRateChartData; -public interface InterestRateChartReadPlatformService { - - // Collection retrieveAll(Long savingsProductId); +public interface InterestRateChartReadService { InterestRateChartData retrieveOne(Long interestChartId); - // Collection retrieveAllWithSlabs(); - Collection retrieveAllWithSlabs(Long savingsProductId); Collection retrieveAllWithSlabsWithTemplate(Long savingsProductId); @@ -37,8 +34,6 @@ public interface InterestRateChartReadPlatformService { InterestRateChartData retrieveWithTemplate(InterestRateChartData interestRateChartData); - InterestRateChartData retrieveOneWithSlabsOnProductId(Long productId); - InterestRateChartData template(); InterestRateChartData retrieveActiveChartWithTemplate(Long productId); diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/service/InterestRateChartReadPlatformServiceImpl.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/service/InterestRateChartReadServiceImpl.java similarity index 58% rename from fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/service/InterestRateChartReadPlatformServiceImpl.java rename to fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/service/InterestRateChartReadServiceImpl.java index 56f9a01a801..faff7d80f95 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/service/InterestRateChartReadPlatformServiceImpl.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/service/InterestRateChartReadServiceImpl.java @@ -25,12 +25,12 @@ import java.util.ArrayList; import java.util.Collection; import java.util.List; +import lombok.RequiredArgsConstructor; import org.apache.fineract.infrastructure.codes.data.CodeValueData; import org.apache.fineract.infrastructure.codes.service.CodeValueReadPlatformService; import org.apache.fineract.infrastructure.core.data.EnumOptionData; import org.apache.fineract.infrastructure.core.domain.JdbcSupport; import org.apache.fineract.infrastructure.core.service.database.DatabaseSpecificSQLGenerator; -import org.apache.fineract.infrastructure.security.service.PlatformSecurityContext; import org.apache.fineract.organisation.monetary.data.CurrencyData; import org.apache.fineract.portfolio.client.api.ClientApiConstants; import org.apache.fineract.portfolio.common.service.CommonEnumerations; @@ -46,34 +46,21 @@ import org.springframework.jdbc.core.ResultSetExtractor; import org.springframework.jdbc.core.RowMapper; -public class InterestRateChartReadPlatformServiceImpl implements InterestRateChartReadPlatformService { +@RequiredArgsConstructor +public class InterestRateChartReadServiceImpl implements InterestRateChartReadService { - private final PlatformSecurityContext context; private final JdbcTemplate jdbcTemplate; private static final InterestRateChartMapper CHART_ROW_MAPPER = new InterestRateChartMapper(); private final InterestRateChartExtractor chartExtractor; - private final InterestRateChartDropdownReadPlatformService chartDropdownReadPlatformService; - private final InterestIncentiveDropdownReadPlatformService interestIncentiveDropdownReadPlatformService; + private final InterestRateChartDropdownReadService chartDropdownReadPlatformService; + private final InterestIncentiveDropdownReadService interestIncentiveDropdownReadService; private final CodeValueReadPlatformService codeValueReadPlatformService; - public InterestRateChartReadPlatformServiceImpl(PlatformSecurityContext context, final JdbcTemplate jdbcTemplate, - InterestRateChartDropdownReadPlatformService chartDropdownReadPlatformService, - final InterestIncentiveDropdownReadPlatformService interestIncentiveDropdownReadPlatformService, - final CodeValueReadPlatformService codeValueReadPlatformService, DatabaseSpecificSQLGenerator sqlGenerator) { - this.context = context; - this.jdbcTemplate = jdbcTemplate; - this.chartDropdownReadPlatformService = chartDropdownReadPlatformService; - this.interestIncentiveDropdownReadPlatformService = interestIncentiveDropdownReadPlatformService; - this.codeValueReadPlatformService = codeValueReadPlatformService; - chartExtractor = new InterestRateChartExtractor(sqlGenerator); - } - @Override public InterestRateChartData retrieveOne(Long chartId) { try { - this.context.authenticatedUser(); final String sql = "select " + CHART_ROW_MAPPER.schema() + " where irc.id = ?"; - return this.jdbcTemplate.queryForObject(sql, CHART_ROW_MAPPER, chartId); // NOSONAR + return jdbcTemplate.queryForObject(sql, CHART_ROW_MAPPER, chartId); // NOSONAR } catch (final EmptyResultDataAccessException e) { throw new InterestRateChartNotFoundException(chartId, e); } @@ -81,24 +68,20 @@ public InterestRateChartData retrieveOne(Long chartId) { @Override public Collection retrieveAllWithSlabs(Long productId) { - this.context.authenticatedUser(); - StringBuilder sql = new StringBuilder(); - sql.append("select "); - sql.append(this.chartExtractor.schema()); - sql.append(" where sp.id = ? order by irc.id, "); - sql.append("CASE "); - sql.append("WHEN irc.is_primary_grouping_by_amount then ircd.amount_range_from "); - sql.append("WHEN irc.is_primary_grouping_by_amount then ircd.amount_range_to "); - sql.append("END,"); - sql.append("ircd.from_period, ircd.to_period,"); - sql.append("CASE "); - sql.append("WHEN NOT irc.is_primary_grouping_by_amount then ircd.amount_range_from "); - sql.append("WHEN NOT irc.is_primary_grouping_by_amount then ircd.amount_range_to "); - sql.append("END"); - - return this.jdbcTemplate.query( - con -> con.prepareStatement(sql.toString(), ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE), - ps -> ps.setLong(1, productId), this.chartExtractor); + String sql = "select " + chartExtractor.schema() + """ + where sp.id = ? order by irc.id, \ + CASE \ + WHEN irc.is_primary_grouping_by_amount then ircd.amount_range_from \ + WHEN irc.is_primary_grouping_by_amount then ircd.amount_range_to \ + END,\ + ircd.from_period, ircd.to_period,\ + CASE \ + WHEN NOT irc.is_primary_grouping_by_amount then ircd.amount_range_from \ + WHEN NOT irc.is_primary_grouping_by_amount then ircd.amount_range_to \ + END"""; + + return jdbcTemplate.query(con -> con.prepareStatement(sql, ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE), + ps -> ps.setLong(1, productId), chartExtractor); } @@ -115,15 +98,14 @@ public Collection retrieveAllWithSlabsWithTemplate(Long p @Override public InterestRateChartData retrieveActiveChartWithTemplate(Long productId) { - Collection chartDatas = this.retrieveAllWithSlabsWithTemplate(productId); + Collection chartDatas = retrieveAllWithSlabsWithTemplate(productId); return DepositProductData.activeChart(chartDatas); } @Override public InterestRateChartData retrieveOneWithSlabs(Long chartId) { - this.context.authenticatedUser(); - final String sql = "select " + this.chartExtractor.schema() + " where irc.id = ? order by ircd.id asc"; - Collection chartDatas = this.jdbcTemplate.query(sql, this.chartExtractor, new Object[] { chartId }); // NOSONAR + final String sql = "select " + chartExtractor.schema() + " where irc.id = ? order by ircd.id asc"; + Collection chartDatas = jdbcTemplate.query(sql, chartExtractor, new Object[] { chartId }); // NOSONAR if (chartDatas == null || chartDatas.isEmpty()) { throw new InterestRateChartNotFoundException(chartId); } @@ -135,46 +117,40 @@ public InterestRateChartData retrieveOneWithSlabs(Long chartId) { public InterestRateChartData retrieveWithTemplate(InterestRateChartData chartData) { final List genderOptions = new ArrayList<>( - this.codeValueReadPlatformService.retrieveCodeValuesByCode(ClientApiConstants.GENDER)); + codeValueReadPlatformService.retrieveCodeValuesByCode(ClientApiConstants.GENDER)); final List clientTypeOptions = new ArrayList<>( - this.codeValueReadPlatformService.retrieveCodeValuesByCode(ClientApiConstants.CLIENT_TYPE)); + codeValueReadPlatformService.retrieveCodeValuesByCode(ClientApiConstants.CLIENT_TYPE)); final List clientClassificationOptions = new ArrayList<>( - this.codeValueReadPlatformService.retrieveCodeValuesByCode(ClientApiConstants.CLIENT_CLASSIFICATION)); - return InterestRateChartData.withTemplate(chartData, this.chartDropdownReadPlatformService.retrievePeriodTypeOptions(), - this.interestIncentiveDropdownReadPlatformService.retrieveEntityTypeOptions(), - this.interestIncentiveDropdownReadPlatformService.retrieveAttributeNameOptions(), - this.interestIncentiveDropdownReadPlatformService.retrieveConditionTypeOptions(), - this.interestIncentiveDropdownReadPlatformService.retrieveIncentiveTypeOptions(), genderOptions, clientTypeOptions, + codeValueReadPlatformService.retrieveCodeValuesByCode(ClientApiConstants.CLIENT_CLASSIFICATION)); + return InterestRateChartData.withTemplate(chartData, chartDropdownReadPlatformService.retrievePeriodTypeOptions(), + interestIncentiveDropdownReadService.retrieveEntityTypeOptions(), + interestIncentiveDropdownReadService.retrieveAttributeNameOptions(), + interestIncentiveDropdownReadService.retrieveConditionTypeOptions(), + interestIncentiveDropdownReadService.retrieveIncentiveTypeOptions(), genderOptions, clientTypeOptions, clientClassificationOptions); } - @Override - public InterestRateChartData retrieveOneWithSlabsOnProductId(@SuppressWarnings("unused") Long productId) { - // TODO Auto-generated method stub - return null; - } - @Override public InterestRateChartData template() { final List genderOptions = new ArrayList<>( - this.codeValueReadPlatformService.retrieveCodeValuesByCode(ClientApiConstants.GENDER)); + codeValueReadPlatformService.retrieveCodeValuesByCode(ClientApiConstants.GENDER)); final List clientTypeOptions = new ArrayList<>( - this.codeValueReadPlatformService.retrieveCodeValuesByCode(ClientApiConstants.CLIENT_TYPE)); + codeValueReadPlatformService.retrieveCodeValuesByCode(ClientApiConstants.CLIENT_TYPE)); final List clientClassificationOptions = new ArrayList<>( - this.codeValueReadPlatformService.retrieveCodeValuesByCode(ClientApiConstants.CLIENT_CLASSIFICATION)); - return InterestRateChartData.template(this.chartDropdownReadPlatformService.retrievePeriodTypeOptions(), - this.interestIncentiveDropdownReadPlatformService.retrieveEntityTypeOptions(), - this.interestIncentiveDropdownReadPlatformService.retrieveAttributeNameOptions(), - this.interestIncentiveDropdownReadPlatformService.retrieveConditionTypeOptions(), - this.interestIncentiveDropdownReadPlatformService.retrieveIncentiveTypeOptions(), genderOptions, clientTypeOptions, + codeValueReadPlatformService.retrieveCodeValuesByCode(ClientApiConstants.CLIENT_CLASSIFICATION)); + return InterestRateChartData.template(chartDropdownReadPlatformService.retrievePeriodTypeOptions(), + interestIncentiveDropdownReadService.retrieveEntityTypeOptions(), + interestIncentiveDropdownReadService.retrieveAttributeNameOptions(), + interestIncentiveDropdownReadService.retrieveConditionTypeOptions(), + interestIncentiveDropdownReadService.retrieveIncentiveTypeOptions(), genderOptions, clientTypeOptions, clientClassificationOptions); } - private static final class InterestRateChartExtractor implements ResultSetExtractor> { + public static final class InterestRateChartExtractor implements ResultSetExtractor> { InterestRateChartMapper chartMapper = new InterestRateChartMapper(); InterestRateChartSlabExtractor chartSlabsMapper; @@ -185,31 +161,32 @@ public String schema() { return this.schemaSql; } - private InterestRateChartExtractor(DatabaseSpecificSQLGenerator sqlGenerator) { + public InterestRateChartExtractor(DatabaseSpecificSQLGenerator sqlGenerator) { chartSlabsMapper = new InterestRateChartSlabExtractor(sqlGenerator); - final StringBuilder sqlBuilder = new StringBuilder(400); - - sqlBuilder.append("irc.id as ircId, irc.name as ircName, irc.description as ircDescription,") - .append("irc.from_date as ircFromDate, irc.end_date as ircEndDate, ") - .append("irc.is_primary_grouping_by_amount as isPrimaryGroupingByAmount, ") - .append("ircd.id as ircdId, ircd.description as ircdDescription, ircd.period_type_enum ircdPeriodTypeId, ") - .append("ircd.from_period as ircdFromPeriod, ircd.to_period as ircdToPeriod, ircd.amount_range_from as ircdAmountRangeFrom, ") - .append("ircd.amount_range_to as ircdAmountRangeTo, ircd.annual_interest_rate as ircdAnnualInterestRate, ") - .append("curr.code as currencyCode, curr.name as currencyName, curr.internationalized_name_code as currencyNameCode, ") - .append("curr.display_symbol as currencyDisplaySymbol, curr.decimal_places as currencyDigits, curr.currency_multiplesof as inMultiplesOf, ") - .append("sp.id as savingsProductId, sp.name as savingsProductName, ").append("iri.id as iriId, ") - .append(" iri.entiry_type as entityType, iri.attribute_name as attributeName ,") - .append(" iri.condition_type as conditionType, iri.attribute_value as attributeValue, ") - .append(" iri.incentive_type as incentiveType, iri.amount as amount, ").append("code.code_value as attributeValueDesc ") - .append("from ") - .append("m_interest_rate_chart irc left join m_interest_rate_slab ircd on irc.id=ircd.interest_rate_chart_id ") - .append(" left join m_interest_incentives iri on iri.interest_rate_slab_id = ircd.id ") - .append(" left join m_code_value code on " + sqlGenerator.castChar("code.id") + " = iri.attribute_value ") - .append("left join m_currency curr on ircd.currency_code= curr.code ") - .append("left join m_deposit_product_interest_rate_chart dpirc on irc.id=dpirc.interest_rate_chart_id ") - .append("left join m_savings_product sp on sp.id=dpirc.deposit_product_id "); - - this.schemaSql = sqlBuilder.toString(); + this.schemaSql = """ + irc.id as ircId, irc.name as ircName, irc.description as ircDescription,\ + irc.from_date as ircFromDate, irc.end_date as ircEndDate, \ + irc.is_primary_grouping_by_amount as isPrimaryGroupingByAmount, \ + ircd.id as ircdId, ircd.description as ircdDescription, ircd.period_type_enum ircdPeriodTypeId, \ + ircd.from_period as ircdFromPeriod, ircd.to_period as ircdToPeriod, ircd.amount_range_from as ircdAmountRangeFrom, \ + ircd.amount_range_to as ircdAmountRangeTo, ircd.annual_interest_rate as ircdAnnualInterestRate, \ + curr.code as currencyCode, curr.name as currencyName, curr.internationalized_name_code as currencyNameCode, \ + curr.display_symbol as currencyDisplaySymbol, curr.decimal_places as currencyDigits, curr.currency_multiplesof as inMultiplesOf, \ + sp.id as savingsProductId, sp.name as savingsProductName, iri.id as iriId, \ + iri.entiry_type as entityType, iri.attribute_name as attributeName ,\ + iri.condition_type as conditionType, iri.attribute_value as attributeValue, \ + iri.incentive_type as incentiveType, iri.amount as amount, code.code_value as attributeValueDesc \ + from \ + m_interest_rate_chart irc left join m_interest_rate_slab ircd on irc.id=ircd.interest_rate_chart_id \ + left join m_interest_incentives iri on iri.interest_rate_slab_id = ircd.id \ + left join m_code_value code on \ + """ + + sqlGenerator.castChar("code.id") + """ + = iri.attribute_value \ + left join m_currency curr on ircd.currency_code= curr.code \ + left join m_deposit_product_interest_rate_chart dpirc on irc.id=dpirc.interest_rate_chart_id \ + left join m_savings_product sp on sp.id=dpirc.deposit_product_id \ + """; } @Override @@ -250,16 +227,16 @@ public String schema() { } private InterestRateChartMapper() { - final StringBuilder sqlBuilder = new StringBuilder(400); - - sqlBuilder.append("irc.id as ircId, irc.name as ircName, irc.description as ircDescription, ") - .append("irc.from_date as ircFromDate, irc.end_date as ircEndDate, ") - .append("irc.is_primary_grouping_by_amount as isPrimaryGroupingByAmount, ") - .append("sp.id as savingsProductId, sp.name as savingsProductName ").append("from ") - .append("m_interest_rate_chart irc ") - .append("left join m_deposit_product_interest_rate_chart dpirc on irc.id=dpirc.interest_rate_chart_id ") - .append("left join m_savings_product sp on sp.id=dpirc.deposit_product_id "); - this.schemaSql = sqlBuilder.toString(); + this.schemaSql = """ + irc.id as ircId, irc.name as ircName, irc.description as ircDescription, \ + irc.from_date as ircFromDate, irc.end_date as ircEndDate, \ + irc.is_primary_grouping_by_amount as isPrimaryGroupingByAmount, \ + sp.id as savingsProductId, sp.name as savingsProductName \ + from \ + m_interest_rate_chart irc \ + left join m_deposit_product_interest_rate_chart dpirc on irc.id=dpirc.interest_rate_chart_id \ + left join m_savings_product sp on sp.id=dpirc.deposit_product_id \ + """; } @Override @@ -288,21 +265,24 @@ public String schema() { } private InterestRateChartSlabsMapper(DatabaseSpecificSQLGenerator sqlGenerator) { - final StringBuilder sqlBuilder = new StringBuilder(400); - - sqlBuilder.append("ircd.id as ircdId, ircd.description as ircdDescription, ircd.period_type_enum ircdPeriodTypeId, ").append( - "ircd.from_period as ircdFromPeriod, ircd.to_period as ircdToPeriod, ircd.amount_range_from as ircdAmountRangeFrom, ") - .append("ircd.amount_range_to as ircdAmountRangeTo, ircd.annual_interest_rate as ircdAnnualInterestRate, ") - .append("curr.code as currencyCode, curr.name as currencyName, curr.internationalized_name_code as currencyNameCode, ") - .append("curr.display_symbol as currencyDisplaySymbol, curr.decimal_places as currencyDigits, curr.currency_multiplesof as inMultiplesOf, ") - .append("iri.id as iriId, ").append(" iri.entiry_type as entityType, iri.attribute_name as attributeName ,") - .append(" iri.condition_type as conditionType, iri.attribute_value as attributeValue, ") - .append(" iri.incentive_type as incentiveType, iri.amount as amount, ").append("code.code_value as attributeValueDesc ") - .append("from ").append("m_interest_rate_slab ircd ") - .append(" left join m_interest_incentives iri on iri.interest_rate_slab_id = ircd.id ") - .append(" left join m_code_value code on " + sqlGenerator.castChar("code.id") + " = iri.attribute_value ") - .append("left join m_currency curr on ircd.currency_code= curr.code "); - this.schemaSql = sqlBuilder.toString(); + this.schemaSql = """ + ircd.id as ircdId, ircd.description as ircdDescription, ircd.period_type_enum ircdPeriodTypeId, \ + ircd.from_period as ircdFromPeriod, ircd.to_period as ircdToPeriod, ircd.amount_range_from as ircdAmountRangeFrom, \ + ircd.amount_range_to as ircdAmountRangeTo, ircd.annual_interest_rate as ircdAnnualInterestRate, \ + curr.code as currencyCode, curr.name as currencyName, curr.internationalized_name_code as currencyNameCode, \ + curr.display_symbol as currencyDisplaySymbol, curr.decimal_places as currencyDigits, curr.currency_multiplesof as inMultiplesOf, \ + iri.id as iriId, iri.entiry_type as entityType, iri.attribute_name as attributeName ,\ + iri.condition_type as conditionType, iri.attribute_value as attributeValue, \ + iri.incentive_type as incentiveType, iri.amount as amount, code.code_value as attributeValueDesc \ + from \ + m_interest_rate_slab ircd \ + left join m_interest_incentives iri on iri.interest_rate_slab_id = ircd.id \ + left join m_code_value code on \ + """ + + sqlGenerator.castChar("code.id") + """ + = iri.attribute_value \ + left join m_currency curr on ircd.currency_code= curr.code \ + """; } @Override diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/service/InterestRateChartSlabWritePlatformService.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/service/InterestRateChartSlabWritePlatformService.java deleted file mode 100644 index caeb69bba10..00000000000 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/service/InterestRateChartSlabWritePlatformService.java +++ /dev/null @@ -1,31 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.fineract.portfolio.interestratechart.service; - -import org.apache.fineract.infrastructure.core.api.JsonCommand; -import org.apache.fineract.infrastructure.core.data.CommandProcessingResult; - -public interface InterestRateChartSlabWritePlatformService { - - CommandProcessingResult create(JsonCommand command); - - CommandProcessingResult update(Long chartSlabId, Long interestChartId, JsonCommand command); - - CommandProcessingResult deleteChartSlab(Long chartSlabId, Long interestRateChartId); -} diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/service/InterestRateChartSlabWritePlatformServiceJpaRepositoryImpl.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/service/InterestRateChartSlabWritePlatformServiceJpaRepositoryImpl.java deleted file mode 100644 index c1e0547dc27..00000000000 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/service/InterestRateChartSlabWritePlatformServiceJpaRepositoryImpl.java +++ /dev/null @@ -1,95 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.fineract.portfolio.interestratechart.service; - -import java.util.LinkedHashMap; -import java.util.Locale; -import java.util.Map; -import lombok.RequiredArgsConstructor; -import org.apache.fineract.infrastructure.core.api.JsonCommand; -import org.apache.fineract.infrastructure.core.data.CommandProcessingResult; -import org.apache.fineract.infrastructure.core.data.CommandProcessingResultBuilder; -import org.apache.fineract.infrastructure.security.service.PlatformSecurityContext; -import org.apache.fineract.portfolio.interestratechart.data.InterestRateChartSlabDataValidator; -import org.apache.fineract.portfolio.interestratechart.domain.InterestRateChartRepositoryWrapper; -import org.apache.fineract.portfolio.interestratechart.domain.InterestRateChartSlab; -import org.apache.fineract.portfolio.interestratechart.domain.InterestRateChartSlabRepository; -import org.apache.fineract.portfolio.savings.domain.SavingsProductRepository; -import org.springframework.transaction.annotation.Transactional; - -@RequiredArgsConstructor -public class InterestRateChartSlabWritePlatformServiceJpaRepositoryImpl implements InterestRateChartSlabWritePlatformService { - - @SuppressWarnings("unused") - private final PlatformSecurityContext context; - private final InterestRateChartSlabDataValidator interestRateChartSlabDataValidator; - @SuppressWarnings("unused") - private final InterestRateChartAssembler interestRateChartAssembler; - private final InterestRateChartSlabAssembler interestRateChartSlabAssembler; - @SuppressWarnings("unused") - private final InterestRateChartRepositoryWrapper interestRateChartRepository; - private final InterestRateChartSlabRepository chartSlabRepository; - @SuppressWarnings("unused") - private final SavingsProductRepository savingsProductRepository; - - @Override - @Transactional - public CommandProcessingResult create(JsonCommand command) { - this.interestRateChartSlabDataValidator.validateCreate(command.json()); - - final InterestRateChartSlab interestRateChartSlab = this.interestRateChartSlabAssembler.assembleFrom(command); - - this.chartSlabRepository.saveAndFlush(interestRateChartSlab); - - final Long interestRateChartId = interestRateChartSlab.getId(); - - return new CommandProcessingResultBuilder() // - .withCommandId(command.commandId()) // - .withEntityId(interestRateChartId) // - .build(); - } - - @Override - @Transactional - public CommandProcessingResult update(Long chartSlabId, Long interestRateChartId, JsonCommand command) { - this.interestRateChartSlabDataValidator.validateUpdate(command.json()); - final Map changes = new LinkedHashMap<>(20); - final InterestRateChartSlab updateChartSlabs = this.interestRateChartSlabAssembler.assembleFrom(chartSlabId, interestRateChartId); - final Locale locale = command.extractLocale(); - updateChartSlabs.update(command, changes, locale); - - this.chartSlabRepository.saveAndFlush(updateChartSlabs); - - return new CommandProcessingResultBuilder() // - .withCommandId(command.commandId()) // - .withEntityId(interestRateChartId) // - .with(changes).build(); - } - - @Override - @Transactional - public CommandProcessingResult deleteChartSlab(Long chartSlabId, Long interestRateChartId) { - final InterestRateChartSlab deleteChartSlabs = this.interestRateChartSlabAssembler.assembleFrom(chartSlabId, interestRateChartId); - this.chartSlabRepository.delete(deleteChartSlabs); - return new CommandProcessingResultBuilder() // - .withEntityId(chartSlabId) // - .build(); - } - -} diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/service/InterestRateChartSlabReadPlatformService.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/service/InterestRateChartSlabsReadService.java similarity index 95% rename from fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/service/InterestRateChartSlabReadPlatformService.java rename to fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/service/InterestRateChartSlabsReadService.java index b7a483c8d4e..c21b5acfc8e 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/service/InterestRateChartSlabReadPlatformService.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/service/InterestRateChartSlabsReadService.java @@ -16,12 +16,13 @@ * specific language governing permissions and limitations * under the License. */ + package org.apache.fineract.portfolio.interestratechart.service; import java.util.List; import org.apache.fineract.portfolio.interestratechart.data.InterestRateChartSlabData; -public interface InterestRateChartSlabReadPlatformService { +public interface InterestRateChartSlabsReadService { List retrieveAll(Long chartId); diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/service/InterestRateChartSlabReadPlatformServiceImpl.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/service/InterestRateChartSlabsReadServiceImpl.java similarity index 69% rename from fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/service/InterestRateChartSlabReadPlatformServiceImpl.java rename to fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/service/InterestRateChartSlabsReadServiceImpl.java index 6c7bb0a8401..24c39ec975d 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/service/InterestRateChartSlabReadPlatformServiceImpl.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/service/InterestRateChartSlabsReadServiceImpl.java @@ -16,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ + package org.apache.fineract.portfolio.interestratechart.service; import java.math.BigDecimal; @@ -30,7 +31,6 @@ import org.apache.fineract.infrastructure.core.data.EnumOptionData; import org.apache.fineract.infrastructure.core.domain.JdbcSupport; import org.apache.fineract.infrastructure.core.service.database.DatabaseSpecificSQLGenerator; -import org.apache.fineract.infrastructure.security.service.PlatformSecurityContext; import org.apache.fineract.organisation.monetary.data.CurrencyData; import org.apache.fineract.portfolio.client.api.ClientApiConstants; import org.apache.fineract.portfolio.common.service.CommonEnumerations; @@ -44,29 +44,29 @@ import org.springframework.jdbc.core.RowMapper; @RequiredArgsConstructor +public class InterestRateChartSlabsReadServiceImpl implements InterestRateChartSlabsReadService { -public class InterestRateChartSlabReadPlatformServiceImpl implements InterestRateChartSlabReadPlatformService { - - private final PlatformSecurityContext context; private final JdbcTemplate jdbcTemplate; + private final InterestRateChartSlabExtractor chartSlabExtractor; - private final InterestRateChartDropdownReadPlatformService chartDropdownReadPlatformService; - private final InterestIncentiveDropdownReadPlatformService interestIncentiveDropdownReadPlatformService; + + private final InterestRateChartDropdownReadService chartDropdownReadPlatformService; + + private final InterestIncentiveDropdownReadService interestIncentiveDropdownReadService; + private final CodeValueReadPlatformService codeValueReadPlatformService; @Override public List retrieveAll(Long chartId) { - this.context.authenticatedUser(); - final String sql = "select " + this.chartSlabExtractor.schema() + " where ircd.interest_rate_chart_id = ? order by ircd.id"; - return this.jdbcTemplate.query(sql, this.chartSlabExtractor, new Object[] { chartId }); // NOSONAR + final String sql = "select " + chartSlabExtractor.schema() + " where ircd.interest_rate_chart_id = ? order by ircd.id"; + return jdbcTemplate.query(sql, chartSlabExtractor, chartId); // NOSONAR } @Override public InterestRateChartSlabData retrieveOne(Long chartId, Long chartSlabId) { - this.context.authenticatedUser(); - final String sql = "select " + this.chartSlabExtractor.schema() + " where irc.id = ? order by ircd.id asc"; - Collection chartDatas = this.jdbcTemplate.query(sql, this.chartSlabExtractor, // NOSONAR - new Object[] { chartSlabId, chartId }); + final String sql = "select " + chartSlabExtractor.schema() + " where irc.id = ? order by ircd.id asc"; + Collection chartDatas = jdbcTemplate.query(sql, chartSlabExtractor, // NOSONAR + chartSlabId, chartId); if (chartDatas == null || chartDatas.isEmpty()) { throw new InterestRateChartSlabNotFoundException(chartSlabId, chartId); } @@ -77,37 +77,37 @@ public InterestRateChartSlabData retrieveOne(Long chartId, Long chartSlabId) { @Override public InterestRateChartSlabData retrieveWithTemplate(InterestRateChartSlabData chartSlab) { final List genderOptions = new ArrayList<>( - this.codeValueReadPlatformService.retrieveCodeValuesByCode(ClientApiConstants.GENDER)); + codeValueReadPlatformService.retrieveCodeValuesByCode(ClientApiConstants.GENDER)); final List clientTypeOptions = new ArrayList<>( - this.codeValueReadPlatformService.retrieveCodeValuesByCode(ClientApiConstants.CLIENT_TYPE)); + codeValueReadPlatformService.retrieveCodeValuesByCode(ClientApiConstants.CLIENT_TYPE)); final List clientClassificationOptions = new ArrayList<>( - this.codeValueReadPlatformService.retrieveCodeValuesByCode(ClientApiConstants.CLIENT_CLASSIFICATION)); + codeValueReadPlatformService.retrieveCodeValuesByCode(ClientApiConstants.CLIENT_CLASSIFICATION)); - return InterestRateChartSlabData.withTemplate(chartSlab, this.chartDropdownReadPlatformService.retrievePeriodTypeOptions(), - this.interestIncentiveDropdownReadPlatformService.retrieveEntityTypeOptions(), - this.interestIncentiveDropdownReadPlatformService.retrieveAttributeNameOptions(), - this.interestIncentiveDropdownReadPlatformService.retrieveConditionTypeOptions(), - this.interestIncentiveDropdownReadPlatformService.retrieveIncentiveTypeOptions(), genderOptions, clientTypeOptions, + return InterestRateChartSlabData.withTemplate(chartSlab, chartDropdownReadPlatformService.retrievePeriodTypeOptions(), + interestIncentiveDropdownReadService.retrieveEntityTypeOptions(), + interestIncentiveDropdownReadService.retrieveAttributeNameOptions(), + interestIncentiveDropdownReadService.retrieveConditionTypeOptions(), + interestIncentiveDropdownReadService.retrieveIncentiveTypeOptions(), genderOptions, clientTypeOptions, clientClassificationOptions); } @Override public InterestRateChartSlabData retrieveTemplate() { final List genderOptions = new ArrayList<>( - this.codeValueReadPlatformService.retrieveCodeValuesByCode(ClientApiConstants.GENDER)); + codeValueReadPlatformService.retrieveCodeValuesByCode(ClientApiConstants.GENDER)); final List clientTypeOptions = new ArrayList<>( - this.codeValueReadPlatformService.retrieveCodeValuesByCode(ClientApiConstants.CLIENT_TYPE)); + codeValueReadPlatformService.retrieveCodeValuesByCode(ClientApiConstants.CLIENT_TYPE)); final List clientClassificationOptions = new ArrayList<>( - this.codeValueReadPlatformService.retrieveCodeValuesByCode(ClientApiConstants.CLIENT_CLASSIFICATION)); - return InterestRateChartSlabData.template(this.chartDropdownReadPlatformService.retrievePeriodTypeOptions(), - this.interestIncentiveDropdownReadPlatformService.retrieveEntityTypeOptions(), - this.interestIncentiveDropdownReadPlatformService.retrieveAttributeNameOptions(), - this.interestIncentiveDropdownReadPlatformService.retrieveConditionTypeOptions(), - this.interestIncentiveDropdownReadPlatformService.retrieveIncentiveTypeOptions(), genderOptions, clientTypeOptions, + codeValueReadPlatformService.retrieveCodeValuesByCode(ClientApiConstants.CLIENT_CLASSIFICATION)); + return InterestRateChartSlabData.template(chartDropdownReadPlatformService.retrievePeriodTypeOptions(), + interestIncentiveDropdownReadService.retrieveEntityTypeOptions(), + interestIncentiveDropdownReadService.retrieveAttributeNameOptions(), + interestIncentiveDropdownReadService.retrieveConditionTypeOptions(), + interestIncentiveDropdownReadService.retrieveIncentiveTypeOptions(), genderOptions, clientTypeOptions, clientClassificationOptions); } @@ -115,26 +115,29 @@ private static final class InterestRateChartSlabsMapper implements RowMapper> { - InterestRateChartSlabsMapper chartSlabsMapper; - InterestIncentiveMapper incentiveMapper = new InterestIncentiveMapper(); - private final String schemaSql; - public String schema() { - return this.schemaSql; - } + InterestRateChartSlabsMapper chartSlabsMapper; + + InterestIncentiveMapper incentiveMapper = new InterestIncentiveMapper(); public InterestRateChartSlabExtractor(DatabaseSpecificSQLGenerator sqlGenerator) { chartSlabsMapper = new InterestRateChartSlabsMapper(sqlGenerator); this.schemaSql = chartSlabsMapper.schema(); } + public String schema() { + return this.schemaSql; + } + @Override public List extractData(ResultSet rs) throws SQLException, DataAccessException { diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/service/InterestRateChartSlabsWriteService.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/service/InterestRateChartSlabsWriteService.java new file mode 100644 index 00000000000..9e5f3ed18f2 --- /dev/null +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/service/InterestRateChartSlabsWriteService.java @@ -0,0 +1,36 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.fineract.portfolio.interestratechart.service; + +import org.apache.fineract.portfolio.interestratechart.data.InterestRateChartSlabsCreateRequest; +import org.apache.fineract.portfolio.interestratechart.data.InterestRateChartSlabsCreateResponse; +import org.apache.fineract.portfolio.interestratechart.data.InterestRateChartSlabsDeleteRequest; +import org.apache.fineract.portfolio.interestratechart.data.InterestRateChartSlabsDeleteResponse; +import org.apache.fineract.portfolio.interestratechart.data.InterestRateChartSlabsUpdateRequest; +import org.apache.fineract.portfolio.interestratechart.data.InterestRateChartSlabsUpdateResponse; + +public interface InterestRateChartSlabsWriteService { + + InterestRateChartSlabsCreateResponse createInterestRateChartSlab(InterestRateChartSlabsCreateRequest request); + + InterestRateChartSlabsUpdateResponse updateInterestRateChartSlab(InterestRateChartSlabsUpdateRequest request); + + InterestRateChartSlabsDeleteResponse deleteInterestRateChartSlab(InterestRateChartSlabsDeleteRequest request); +} diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/service/InterestRateChartSlabsWriteServiceImpl.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/service/InterestRateChartSlabsWriteServiceImpl.java new file mode 100644 index 00000000000..94c7b12d3bd --- /dev/null +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/service/InterestRateChartSlabsWriteServiceImpl.java @@ -0,0 +1,120 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.fineract.portfolio.interestratechart.service; + +import java.math.BigDecimal; +import java.util.List; +import lombok.RequiredArgsConstructor; +import org.apache.fineract.portfolio.interestratechart.data.InterestRateChartSlabsCreateRequest; +import org.apache.fineract.portfolio.interestratechart.data.InterestRateChartSlabsCreateResponse; +import org.apache.fineract.portfolio.interestratechart.data.InterestRateChartSlabsDeleteRequest; +import org.apache.fineract.portfolio.interestratechart.data.InterestRateChartSlabsDeleteResponse; +import org.apache.fineract.portfolio.interestratechart.data.InterestRateChartSlabsUpdateRequest; +import org.apache.fineract.portfolio.interestratechart.data.InterestRateChartSlabsUpdateResponse; +import org.apache.fineract.portfolio.interestratechart.domain.InterestIncentives; +import org.apache.fineract.portfolio.interestratechart.domain.InterestIncentivesFields; +import org.apache.fineract.portfolio.interestratechart.domain.InterestRateChart; +import org.apache.fineract.portfolio.interestratechart.domain.InterestRateChartRepositoryWrapper; +import org.apache.fineract.portfolio.interestratechart.domain.InterestRateChartSlab; +import org.apache.fineract.portfolio.interestratechart.domain.InterestRateChartSlabFields; +import org.apache.fineract.portfolio.interestratechart.domain.InterestRateChartSlabRepository; +import org.apache.fineract.portfolio.interestratechart.exception.InterestRateChartSlabNotFoundException; +import org.apache.fineract.portfolio.savings.SavingsPeriodFrequencyType; +import org.springframework.transaction.annotation.Transactional; + +@RequiredArgsConstructor +public class InterestRateChartSlabsWriteServiceImpl implements InterestRateChartSlabsWriteService { + + private final InterestRateChartRepositoryWrapper interestRateChartRepository; + + private final InterestRateChartSlabRepository chartSlabRepository; + + @Override + @Transactional + public InterestRateChartSlabsCreateResponse createInterestRateChartSlab(InterestRateChartSlabsCreateRequest request) { + final InterestRateChart chart = interestRateChartRepository.findOneWithNotFoundDetection(request.getChartId()); + + final SavingsPeriodFrequencyType periodType = SavingsPeriodFrequencyType.fromInt(request.getPeriodType()); + final BigDecimal annualInterestRate = request.getAnnualInterestRate() != null ? BigDecimal.valueOf(request.getAnnualInterestRate()) + : null; + + final InterestRateChartSlabFields slabFields = InterestRateChartSlabFields.createNew(request.getDescription(), periodType, + request.getFromPeriod(), request.getToPeriod(), null, null, annualInterestRate, null); + + final InterestRateChartSlab interestRateChartSlab = InterestRateChartSlab.createNew(slabFields, chart); + + if (request.getIncentives() != null) { + assembleIncentives(request.getIncentives(), interestRateChartSlab); + } + + chartSlabRepository.saveAndFlush(interestRateChartSlab); + + return InterestRateChartSlabsCreateResponse.builder().resourceId(interestRateChartSlab.getId()).build(); + } + + @Override + @Transactional + public InterestRateChartSlabsUpdateResponse updateInterestRateChartSlab(InterestRateChartSlabsUpdateRequest request) { + final InterestRateChart chart = interestRateChartRepository.findOneWithNotFoundDetection(request.getChartId()); + final InterestRateChartSlab chartSlab = chart.findChartSlab(request.getChartSlabId()); + + if (chartSlab == null) { + throw new InterestRateChartSlabNotFoundException(request.getChartSlabId(), request.getChartId()); + } + + if (request.getAnnualInterestRate() != null) { + chartSlab.slabFields().setAnnualInterestRate(BigDecimal.valueOf(request.getAnnualInterestRate())); + } + + if (request.getDescription() != null) { + chartSlab.slabFields().setDescription(request.getDescription()); + } + + chartSlabRepository.saveAndFlush(chartSlab); + + return InterestRateChartSlabsUpdateResponse.builder().resourceId(request.getChartId()).build(); + } + + @Override + @Transactional + public InterestRateChartSlabsDeleteResponse deleteInterestRateChartSlab(InterestRateChartSlabsDeleteRequest request) { + final InterestRateChart chart = interestRateChartRepository.findOneWithNotFoundDetection(request.getChartId()); + final InterestRateChartSlab chartSlab = chart.findChartSlab(request.getChartSlabId()); + + if (chartSlab == null) { + throw new InterestRateChartSlabNotFoundException(request.getChartSlabId(), request.getChartId()); + } + + chartSlabRepository.delete(chartSlab); + + return InterestRateChartSlabsDeleteResponse.builder().resourceId(request.getChartSlabId()).build(); + } + + private void assembleIncentives(List incentives, + InterestRateChartSlab interestRateChartSlab) { + for (InterestRateChartSlabsCreateRequest.Incentive incentive : incentives) { + final InterestIncentivesFields fields = InterestIncentivesFields.createNew(incentive.getEntityType(), + incentive.getAttributeName(), incentive.getConditionType(), incentive.getAttributeValue(), incentive.getIncentiveType(), + incentive.getAmount(), null); + // InterestIncentives constructor already calls addInterestIncentive on the slab + new InterestIncentives(interestRateChartSlab, fields); + } + } +} diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/service/InterestRateChartWritePlatformServiceJpaRepositoryImpl.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/service/InterestRateChartWritePlatformServiceJpaRepositoryImpl.java deleted file mode 100644 index 92023a28e3d..00000000000 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/service/InterestRateChartWritePlatformServiceJpaRepositoryImpl.java +++ /dev/null @@ -1,88 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.fineract.portfolio.interestratechart.service; - -import java.util.LinkedHashMap; -import java.util.Map; -import lombok.RequiredArgsConstructor; -import org.apache.fineract.infrastructure.core.api.JsonCommand; -import org.apache.fineract.infrastructure.core.data.CommandProcessingResult; -import org.apache.fineract.infrastructure.core.data.CommandProcessingResultBuilder; -import org.apache.fineract.infrastructure.security.service.PlatformSecurityContext; -import org.apache.fineract.portfolio.interestratechart.data.InterestRateChartDataValidator; -import org.apache.fineract.portfolio.interestratechart.domain.InterestRateChart; -import org.apache.fineract.portfolio.interestratechart.domain.InterestRateChartRepositoryWrapper; -import org.springframework.transaction.annotation.Transactional; - -@RequiredArgsConstructor -public class InterestRateChartWritePlatformServiceJpaRepositoryImpl implements InterestRateChartWritePlatformService { - - @SuppressWarnings("unused") - private final PlatformSecurityContext context; - private final InterestRateChartDataValidator interestRateChartDataValidator; - private final InterestRateChartAssembler interestRateChartAssembler; - private final InterestRateChartRepositoryWrapper interestRateChartRepository; - - @Override - @Transactional - public CommandProcessingResult create(JsonCommand command) { - this.interestRateChartDataValidator.validateForCreate(command.json()); - - final InterestRateChart interestRateChart = this.interestRateChartAssembler.assembleFrom(command); - - this.interestRateChartRepository.saveAndFlush(interestRateChart); - - final Long interestRateChartId = interestRateChart.getId(); - - return new CommandProcessingResultBuilder() // - .withCommandId(command.commandId()) // - .withEntityId(interestRateChartId) // - .build(); - } - - @Override - @Transactional - public CommandProcessingResult update(Long interestRateChartId, JsonCommand command) { - this.interestRateChartDataValidator.validateUpdate(command.json()); - final Map changes = new LinkedHashMap<>(20); - final InterestRateChart interestRateChart = this.interestRateChartAssembler.assembleFrom(interestRateChartId); - - interestRateChart.update(command, changes); - - this.interestRateChartRepository.saveAndFlush(interestRateChart); - - return new CommandProcessingResultBuilder() // - .withCommandId(command.commandId()) // - .withEntityId(interestRateChartId) // - .with(changes).build(); - } - - @Override - @Transactional - public CommandProcessingResult deleteChart(Long chartId) { - final InterestRateChart chart = this.interestRateChartRepository.findOneWithNotFoundDetection(chartId); - // validate if chart is associated with any accounts - - this.interestRateChartRepository.delete(chart); - return new CommandProcessingResultBuilder() // - .withEntityId(chartId) // - .build(); - } - -} diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/service/InterestRateChartWriteService.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/service/InterestRateChartWriteService.java new file mode 100644 index 00000000000..3ed739eb7d2 --- /dev/null +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/service/InterestRateChartWriteService.java @@ -0,0 +1,36 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.fineract.portfolio.interestratechart.service; + +import org.apache.fineract.portfolio.interestratechart.data.InterestRateChartCreateRequest; +import org.apache.fineract.portfolio.interestratechart.data.InterestRateChartCreateResponse; +import org.apache.fineract.portfolio.interestratechart.data.InterestRateChartDeleteRequest; +import org.apache.fineract.portfolio.interestratechart.data.InterestRateChartDeleteResponse; +import org.apache.fineract.portfolio.interestratechart.data.InterestRateChartUpdateRequest; +import org.apache.fineract.portfolio.interestratechart.data.InterestRateChartUpdateResponse; + +public interface InterestRateChartWriteService { + + InterestRateChartCreateResponse createInterestRateChart(InterestRateChartCreateRequest request); + + InterestRateChartUpdateResponse updateInterestRateChart(InterestRateChartUpdateRequest request); + + InterestRateChartDeleteResponse deleteInterestRateChart(InterestRateChartDeleteRequest request); +} diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/service/InterestRateChartWriteServiceImpl.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/service/InterestRateChartWriteServiceImpl.java new file mode 100644 index 00000000000..c9dbaf36d8c --- /dev/null +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/service/InterestRateChartWriteServiceImpl.java @@ -0,0 +1,87 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.fineract.portfolio.interestratechart.service; + +import java.time.LocalDate; +import java.time.format.DateTimeFormatter; +import java.util.ArrayList; +import java.util.Locale; +import lombok.RequiredArgsConstructor; +import org.apache.fineract.portfolio.interestratechart.data.InterestRateChartCreateRequest; +import org.apache.fineract.portfolio.interestratechart.data.InterestRateChartCreateResponse; +import org.apache.fineract.portfolio.interestratechart.data.InterestRateChartDeleteRequest; +import org.apache.fineract.portfolio.interestratechart.data.InterestRateChartDeleteResponse; +import org.apache.fineract.portfolio.interestratechart.data.InterestRateChartUpdateRequest; +import org.apache.fineract.portfolio.interestratechart.data.InterestRateChartUpdateResponse; +import org.apache.fineract.portfolio.interestratechart.domain.InterestRateChart; +import org.apache.fineract.portfolio.interestratechart.domain.InterestRateChartFields; +import org.apache.fineract.portfolio.interestratechart.domain.InterestRateChartRepositoryWrapper; +import org.springframework.transaction.annotation.Transactional; + +@RequiredArgsConstructor +public class InterestRateChartWriteServiceImpl implements InterestRateChartWriteService { + + private final InterestRateChartRepositoryWrapper interestRateChartRepository; + + @Override + @Transactional + public InterestRateChartCreateResponse createInterestRateChart(InterestRateChartCreateRequest request) { + final String dateFormat = request.getDateFormat() != null ? request.getDateFormat() : "dd MMMM yyyy"; + final Locale locale = request.getLocale() != null ? Locale.forLanguageTag(request.getLocale()) : Locale.getDefault(); + final DateTimeFormatter formatter = DateTimeFormatter.ofPattern(dateFormat, locale); + final LocalDate fromDate = request.getFromDate() != null ? LocalDate.parse(request.getFromDate(), formatter) : null; + + final InterestRateChartFields fields = InterestRateChartFields.createNew(request.getName(), request.getDescription(), fromDate, + null, false); + final InterestRateChart interestRateChart = InterestRateChart.createNew(fields, new ArrayList<>()); + + interestRateChartRepository.saveAndFlush(interestRateChart); + + return InterestRateChartCreateResponse.builder().resourceId(interestRateChart.getId()).build(); + } + + @Override + @Transactional + public InterestRateChartUpdateResponse updateInterestRateChart(InterestRateChartUpdateRequest request) { + final InterestRateChart interestRateChart = interestRateChartRepository.findOneWithNotFoundDetection(request.getId()); + + if (request.getName() != null && !request.getName().equals(interestRateChart.chartFields().getName())) { + interestRateChart.chartFields().setName(request.getName()); + } + + if (request.getDescription() != null && !request.getDescription().equals(interestRateChart.chartFields().getDescription())) { + interestRateChart.chartFields().setDescription(request.getDescription()); + } + + interestRateChartRepository.saveAndFlush(interestRateChart); + + return InterestRateChartUpdateResponse.builder().resourceId(interestRateChart.getId()).build(); + } + + @Override + @Transactional + public InterestRateChartDeleteResponse deleteInterestRateChart(InterestRateChartDeleteRequest request) { + final InterestRateChart chart = interestRateChartRepository.findOneWithNotFoundDetection(request.getChartId()); + + interestRateChartRepository.delete(chart); + + return InterestRateChartDeleteResponse.builder().resourceId(chart.getId()).build(); + } +} diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/starter/InterestRateChartConfiguration.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/starter/InterestRateChartConfiguration.java index 3c18b2327f6..0f7516fcc3f 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/starter/InterestRateChartConfiguration.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/starter/InterestRateChartConfiguration.java @@ -16,32 +16,29 @@ * specific language governing permissions and limitations * under the License. */ + package org.apache.fineract.portfolio.interestratechart.starter; import org.apache.fineract.infrastructure.codes.service.CodeValueReadPlatformService; import org.apache.fineract.infrastructure.core.serialization.FromJsonHelper; import org.apache.fineract.infrastructure.core.service.database.DatabaseSpecificSQLGenerator; -import org.apache.fineract.infrastructure.security.service.PlatformSecurityContext; -import org.apache.fineract.portfolio.interestratechart.data.InterestRateChartDataValidator; -import org.apache.fineract.portfolio.interestratechart.data.InterestRateChartSlabDataValidator; import org.apache.fineract.portfolio.interestratechart.domain.InterestRateChartRepositoryWrapper; import org.apache.fineract.portfolio.interestratechart.domain.InterestRateChartSlabRepository; import org.apache.fineract.portfolio.interestratechart.service.InterestIncentiveAssembler; -import org.apache.fineract.portfolio.interestratechart.service.InterestIncentiveDropdownReadPlatformService; -import org.apache.fineract.portfolio.interestratechart.service.InterestIncentivesDropdownReadPlatformServiceImpl; +import org.apache.fineract.portfolio.interestratechart.service.InterestIncentiveDropdownReadService; +import org.apache.fineract.portfolio.interestratechart.service.InterestIncentivesDropdownReadServiceImpl; import org.apache.fineract.portfolio.interestratechart.service.InterestRateChartAssembler; -import org.apache.fineract.portfolio.interestratechart.service.InterestRateChartDropdownReadPlatformService; -import org.apache.fineract.portfolio.interestratechart.service.InterestRateChartDropdownReadPlatformServiceImpl; -import org.apache.fineract.portfolio.interestratechart.service.InterestRateChartReadPlatformService; -import org.apache.fineract.portfolio.interestratechart.service.InterestRateChartReadPlatformServiceImpl; +import org.apache.fineract.portfolio.interestratechart.service.InterestRateChartDropdownReadService; +import org.apache.fineract.portfolio.interestratechart.service.InterestRateChartDropdownReadServiceImpl; +import org.apache.fineract.portfolio.interestratechart.service.InterestRateChartReadService; +import org.apache.fineract.portfolio.interestratechart.service.InterestRateChartReadServiceImpl; import org.apache.fineract.portfolio.interestratechart.service.InterestRateChartSlabAssembler; -import org.apache.fineract.portfolio.interestratechart.service.InterestRateChartSlabReadPlatformService; -import org.apache.fineract.portfolio.interestratechart.service.InterestRateChartSlabReadPlatformServiceImpl; -import org.apache.fineract.portfolio.interestratechart.service.InterestRateChartSlabWritePlatformService; -import org.apache.fineract.portfolio.interestratechart.service.InterestRateChartSlabWritePlatformServiceJpaRepositoryImpl; -import org.apache.fineract.portfolio.interestratechart.service.InterestRateChartWritePlatformService; -import org.apache.fineract.portfolio.interestratechart.service.InterestRateChartWritePlatformServiceJpaRepositoryImpl; -import org.apache.fineract.portfolio.savings.domain.SavingsProductRepository; +import org.apache.fineract.portfolio.interestratechart.service.InterestRateChartSlabsReadService; +import org.apache.fineract.portfolio.interestratechart.service.InterestRateChartSlabsReadServiceImpl; +import org.apache.fineract.portfolio.interestratechart.service.InterestRateChartSlabsWriteService; +import org.apache.fineract.portfolio.interestratechart.service.InterestRateChartSlabsWriteServiceImpl; +import org.apache.fineract.portfolio.interestratechart.service.InterestRateChartWriteService; +import org.apache.fineract.portfolio.interestratechart.service.InterestRateChartWriteServiceImpl; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @@ -56,16 +53,6 @@ public InterestIncentiveAssembler interestIncentiveAssembler(FromJsonHelper from return new InterestIncentiveAssembler(fromApiJsonHelper); } - @Bean - @ConditionalOnMissingBean(InterestIncentiveDropdownReadPlatformService.class) - public InterestIncentiveDropdownReadPlatformService interestIncentiveDropdownReadPlatformService( - - ) { - return new InterestIncentivesDropdownReadPlatformServiceImpl( - - ); - } - @Bean @ConditionalOnMissingBean(InterestRateChartAssembler.class) public InterestRateChartAssembler interestRateChartAssembler(FromJsonHelper fromApiJsonHelper, @@ -74,71 +61,77 @@ public InterestRateChartAssembler interestRateChartAssembler(FromJsonHelper from } @Bean - @ConditionalOnMissingBean(InterestRateChartDropdownReadPlatformService.class) - public InterestRateChartDropdownReadPlatformService interestRateChartDropdownReadPlatformService( + @ConditionalOnMissingBean(InterestRateChartSlabAssembler.class) + public InterestRateChartSlabAssembler interestRateChartSlabAssembler(FromJsonHelper fromApiJsonHelper, + InterestRateChartRepositoryWrapper interestRateChartRepositoryWrapper, InterestIncentiveAssembler incentiveAssembler) { + return new InterestRateChartSlabAssembler(fromApiJsonHelper, interestRateChartRepositoryWrapper, incentiveAssembler); + } + + @Bean + @ConditionalOnMissingBean(InterestIncentiveDropdownReadService.class) + public InterestIncentiveDropdownReadService interestIncentiveDropdownReadService( ) { - return new InterestRateChartDropdownReadPlatformServiceImpl( + return new InterestIncentivesDropdownReadServiceImpl( ); } @Bean - @ConditionalOnMissingBean(InterestRateChartReadPlatformService.class) - public InterestRateChartReadPlatformService interestRateChartReadPlatformService(PlatformSecurityContext context, - JdbcTemplate jdbcTemplate, InterestRateChartDropdownReadPlatformService chartDropdownReadPlatformService, - InterestIncentiveDropdownReadPlatformService interestIncentiveDropdownReadPlatformService, - CodeValueReadPlatformService codeValueReadPlatformService, DatabaseSpecificSQLGenerator sqlGenerator) { - return new InterestRateChartReadPlatformServiceImpl(context, jdbcTemplate, chartDropdownReadPlatformService, - interestIncentiveDropdownReadPlatformService, codeValueReadPlatformService, sqlGenerator); + @ConditionalOnMissingBean(InterestRateChartDropdownReadService.class) + public InterestRateChartDropdownReadService interestRateChartDropdownReadService( + + ) { + return new InterestRateChartDropdownReadServiceImpl( + + ); } @Bean - @ConditionalOnMissingBean(InterestRateChartSlabAssembler.class) - public InterestRateChartSlabAssembler interestRateChartSlabAssembler(FromJsonHelper fromApiJsonHelper, - InterestRateChartRepositoryWrapper interestRateChartRepositoryWrapper, InterestIncentiveAssembler incentiveAssembler) { - return new InterestRateChartSlabAssembler(fromApiJsonHelper, interestRateChartRepositoryWrapper, incentiveAssembler); + public InterestRateChartReadServiceImpl.InterestRateChartExtractor interestRateChartExtractor( + DatabaseSpecificSQLGenerator sqlGenerator) { + return new InterestRateChartReadServiceImpl.InterestRateChartExtractor(sqlGenerator); } @Bean - public InterestRateChartSlabReadPlatformServiceImpl.InterestRateChartSlabExtractor interestRateChartSlabExtractor( - DatabaseSpecificSQLGenerator sqlGenerator) { - return new InterestRateChartSlabReadPlatformServiceImpl.InterestRateChartSlabExtractor(sqlGenerator); + @ConditionalOnMissingBean(InterestRateChartReadService.class) + public InterestRateChartReadService interestRateChartReadService(JdbcTemplate jdbcTemplate, + InterestRateChartReadServiceImpl.InterestRateChartExtractor chartExtractor, + InterestRateChartDropdownReadService chartDropdownReadPlatformService, + InterestIncentiveDropdownReadService interestIncentiveDropdownReadService, + CodeValueReadPlatformService codeValueReadPlatformService) { + return new InterestRateChartReadServiceImpl(jdbcTemplate, chartExtractor, chartDropdownReadPlatformService, + interestIncentiveDropdownReadService, codeValueReadPlatformService); } @Bean - @ConditionalOnMissingBean(InterestRateChartSlabReadPlatformService.class) - public InterestRateChartSlabReadPlatformService interestRateChartSlabReadPlatformService( + public InterestRateChartSlabsReadServiceImpl.InterestRateChartSlabExtractor interestRateChartSlabExtractor( + DatabaseSpecificSQLGenerator sqlGenerator) { + return new InterestRateChartSlabsReadServiceImpl.InterestRateChartSlabExtractor(sqlGenerator); + } - PlatformSecurityContext context, JdbcTemplate jdbcTemplate, - InterestRateChartSlabReadPlatformServiceImpl.InterestRateChartSlabExtractor chartSlabExtractor, - InterestRateChartDropdownReadPlatformService chartDropdownReadPlatformService, - InterestIncentiveDropdownReadPlatformService interestIncentiveDropdownReadPlatformService, + @Bean + @ConditionalOnMissingBean(InterestRateChartSlabsReadService.class) + public InterestRateChartSlabsReadService interestRateChartSlabReadService(JdbcTemplate jdbcTemplate, + InterestRateChartSlabsReadServiceImpl.InterestRateChartSlabExtractor chartSlabExtractor, + InterestRateChartDropdownReadService chartDropdownReadPlatformService, + InterestIncentiveDropdownReadService interestIncentiveDropdownReadService, CodeValueReadPlatformService codeValueReadPlatformService) { - return new InterestRateChartSlabReadPlatformServiceImpl(context, jdbcTemplate, chartSlabExtractor, chartDropdownReadPlatformService, - interestIncentiveDropdownReadPlatformService, codeValueReadPlatformService); + return new InterestRateChartSlabsReadServiceImpl(jdbcTemplate, chartSlabExtractor, chartDropdownReadPlatformService, + interestIncentiveDropdownReadService, codeValueReadPlatformService); } @Bean - @ConditionalOnMissingBean(InterestRateChartSlabWritePlatformService.class) - public InterestRateChartSlabWritePlatformService interestRateChartSlabWritePlatformService( - - PlatformSecurityContext context, InterestRateChartSlabDataValidator interestRateChartSlabDataValidator, - InterestRateChartAssembler interestRateChartAssembler, InterestRateChartSlabAssembler interestRateChartSlabAssembler, - InterestRateChartRepositoryWrapper interestRateChartRepository, InterestRateChartSlabRepository chartSlabRepository, - SavingsProductRepository savingsProductRepository) { - return new InterestRateChartSlabWritePlatformServiceJpaRepositoryImpl(context, interestRateChartSlabDataValidator, - interestRateChartAssembler, interestRateChartSlabAssembler, interestRateChartRepository, chartSlabRepository, - savingsProductRepository); + @ConditionalOnMissingBean(InterestRateChartSlabsWriteService.class) + public InterestRateChartSlabsWriteService interestRateChartSlabWriteService( + InterestRateChartRepositoryWrapper interestRateChartRepository, InterestRateChartSlabRepository chartSlabRepository) { + return new InterestRateChartSlabsWriteServiceImpl(interestRateChartRepository, chartSlabRepository); } @Bean - @ConditionalOnMissingBean(InterestRateChartWritePlatformService.class) - public InterestRateChartWritePlatformService interestRateChartWritePlatformService(PlatformSecurityContext context, - InterestRateChartDataValidator interestRateChartDataValidator, InterestRateChartAssembler interestRateChartAssembler, - InterestRateChartRepositoryWrapper interestRateChartRepository) { - return new InterestRateChartWritePlatformServiceJpaRepositoryImpl(context, interestRateChartDataValidator, - interestRateChartAssembler, interestRateChartRepository); + @ConditionalOnMissingBean(InterestRateChartWriteService.class) + public InterestRateChartWriteService interestRateChartWriteService(InterestRateChartRepositoryWrapper interestRateChartRepository) { + return new InterestRateChartWriteServiceImpl(interestRateChartRepository); } } diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/api/FixedDepositProductsApiResource.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/api/FixedDepositProductsApiResource.java index 4cc92f66918..1d5b916990e 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/api/FixedDepositProductsApiResource.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/api/FixedDepositProductsApiResource.java @@ -64,7 +64,7 @@ import org.apache.fineract.portfolio.charge.service.ChargeReadPlatformService; import org.apache.fineract.portfolio.common.service.DropdownReadPlatformService; import org.apache.fineract.portfolio.interestratechart.data.InterestRateChartData; -import org.apache.fineract.portfolio.interestratechart.service.InterestRateChartReadPlatformService; +import org.apache.fineract.portfolio.interestratechart.service.InterestRateChartReadService; import org.apache.fineract.portfolio.paymenttype.data.PaymentTypeData; import org.apache.fineract.portfolio.paymenttype.service.PaymentTypeReadService; import org.apache.fineract.portfolio.savings.DepositAccountType; @@ -104,8 +104,8 @@ public class FixedDepositProductsApiResource { private final AccountingDropdownReadPlatformService accountingDropdownReadPlatformService; private final ProductToGLAccountMappingReadPlatformService accountMappingReadPlatformService; private final ChargeReadPlatformService chargeReadPlatformService; - private final InterestRateChartReadPlatformService chartReadPlatformService; - private final InterestRateChartReadPlatformService interestRateChartReadPlatformService; + private final InterestRateChartReadService chartReadPlatformService; + private final InterestRateChartReadService interestRateChartReadPlatformService; private final DepositsDropdownReadPlatformService depositsDropdownReadPlatformService; private final DropdownReadPlatformService dropdownReadPlatformService; private final PaymentTypeReadService paymentTypeReadPlatformService; diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/api/RecurringDepositProductsApiResource.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/api/RecurringDepositProductsApiResource.java index 06ca18b6a25..84c74b00fa7 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/api/RecurringDepositProductsApiResource.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/api/RecurringDepositProductsApiResource.java @@ -65,7 +65,7 @@ import org.apache.fineract.portfolio.charge.service.ChargeReadPlatformService; import org.apache.fineract.portfolio.common.service.DropdownReadPlatformService; import org.apache.fineract.portfolio.interestratechart.data.InterestRateChartData; -import org.apache.fineract.portfolio.interestratechart.service.InterestRateChartReadPlatformService; +import org.apache.fineract.portfolio.interestratechart.service.InterestRateChartReadService; import org.apache.fineract.portfolio.paymenttype.data.PaymentTypeData; import org.apache.fineract.portfolio.paymenttype.service.PaymentTypeReadService; import org.apache.fineract.portfolio.savings.DepositAccountType; @@ -104,8 +104,8 @@ public class RecurringDepositProductsApiResource { private final AccountingDropdownReadPlatformService accountingDropdownReadPlatformService; private final ProductToGLAccountMappingReadPlatformService accountMappingReadPlatformService; private final ChargeReadPlatformService chargeReadPlatformService; - private final InterestRateChartReadPlatformService chartReadPlatformService; - private final InterestRateChartReadPlatformService interestRateChartReadPlatformService; + private final InterestRateChartReadService chartReadPlatformService; + private final InterestRateChartReadService interestRateChartReadPlatformService; private final DepositsDropdownReadPlatformService depositsDropdownReadPlatformService; private final DropdownReadPlatformService dropdownReadPlatformService; private final PaymentTypeReadService paymentTypeReadPlatformService; diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/service/DepositAccountInterestRateChartReadPlatformServiceImpl.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/service/DepositAccountInterestRateChartReadPlatformServiceImpl.java index 58fbb50eba4..82821e47983 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/service/DepositAccountInterestRateChartReadPlatformServiceImpl.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/service/DepositAccountInterestRateChartReadPlatformServiceImpl.java @@ -38,9 +38,9 @@ import org.apache.fineract.portfolio.common.domain.PeriodFrequencyType; import org.apache.fineract.portfolio.common.service.CommonEnumerations; import org.apache.fineract.portfolio.interestratechart.incentive.InterestIncentiveAttributeName; -import org.apache.fineract.portfolio.interestratechart.service.InterestIncentiveDropdownReadPlatformService; +import org.apache.fineract.portfolio.interestratechart.service.InterestIncentiveDropdownReadService; import org.apache.fineract.portfolio.interestratechart.service.InterestIncentivesEnumerations; -import org.apache.fineract.portfolio.interestratechart.service.InterestRateChartDropdownReadPlatformService; +import org.apache.fineract.portfolio.interestratechart.service.InterestRateChartDropdownReadService; import org.apache.fineract.portfolio.interestratechart.service.InterestRateChartEnumerations; import org.apache.fineract.portfolio.savings.data.DepositAccountInterestIncentiveData; import org.apache.fineract.portfolio.savings.data.DepositAccountInterestRateChartData; @@ -59,8 +59,8 @@ public class DepositAccountInterestRateChartReadPlatformServiceImpl implements D private final JdbcTemplate jdbcTemplate; private static final DepositAccountInterestRateChartMapper CHART_ROW_MAPPER = new DepositAccountInterestRateChartMapper(); private final DepositAccountInterestRateChartExtractor chartExtractor; - private final InterestRateChartDropdownReadPlatformService chartDropdownReadPlatformService; - private final InterestIncentiveDropdownReadPlatformService interestIncentiveDropdownReadPlatformService; + private final InterestRateChartDropdownReadService chartDropdownReadPlatformService; + private final InterestIncentiveDropdownReadService interestIncentiveDropdownReadPlatformService; private final CodeValueReadPlatformService codeValueReadPlatformService; @Override diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/service/DepositAccountReadPlatformServiceImpl.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/service/DepositAccountReadPlatformServiceImpl.java index 4ea1831349d..76b45d37c01 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/service/DepositAccountReadPlatformServiceImpl.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/service/DepositAccountReadPlatformServiceImpl.java @@ -65,7 +65,7 @@ import org.apache.fineract.portfolio.group.data.GroupGeneralData; import org.apache.fineract.portfolio.group.service.GroupReadPlatformService; import org.apache.fineract.portfolio.interestratechart.data.InterestRateChartData; -import org.apache.fineract.portfolio.interestratechart.service.InterestRateChartReadPlatformService; +import org.apache.fineract.portfolio.interestratechart.service.InterestRateChartReadService; import org.apache.fineract.portfolio.paymentdetail.data.PaymentDetailData; import org.apache.fineract.portfolio.paymenttype.data.PaymentTypeData; import org.apache.fineract.portfolio.paymenttype.service.PaymentTypeReadService; @@ -111,7 +111,7 @@ public class DepositAccountReadPlatformServiceImpl implements DepositAccountRead private final PlatformSecurityContext context; private final JdbcTemplate jdbcTemplate; private final DepositAccountInterestRateChartReadPlatformService accountChartReadPlatformService; - private final InterestRateChartReadPlatformService productChartReadPlatformService; + private final InterestRateChartReadService productChartReadPlatformService; private final PaginationParametersDataValidator paginationParametersDataValidator; private final DatabaseSpecificSQLGenerator sqlGenerator; private final PaginationHelper paginationHelper; diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/service/DepositProductReadPlatformServiceImpl.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/service/DepositProductReadPlatformServiceImpl.java index e51c5fdd9dd..1cca6cfe32e 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/service/DepositProductReadPlatformServiceImpl.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/service/DepositProductReadPlatformServiceImpl.java @@ -29,7 +29,7 @@ import org.apache.fineract.infrastructure.security.service.PlatformSecurityContext; import org.apache.fineract.organisation.monetary.data.CurrencyData; import org.apache.fineract.portfolio.interestratechart.data.InterestRateChartData; -import org.apache.fineract.portfolio.interestratechart.service.InterestRateChartReadPlatformService; +import org.apache.fineract.portfolio.interestratechart.service.InterestRateChartReadService; import org.apache.fineract.portfolio.savings.DepositAccountType; import org.apache.fineract.portfolio.savings.data.DepositProductData; import org.apache.fineract.portfolio.savings.data.FixedDepositProductData; @@ -48,7 +48,7 @@ public class DepositProductReadPlatformServiceImpl implements DepositProductRead private static final DepositProductLookupMapper DEPOSIT_PRODUCT_LOOKUP_MAPPER = new DepositProductLookupMapper(); private final PlatformSecurityContext context; private final JdbcTemplate jdbcTemplate; - private final InterestRateChartReadPlatformService chartReadPlatformService; + private final InterestRateChartReadService chartReadPlatformService; @Override public Collection retrieveAll(final DepositAccountType depositAccountType) { diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/service/FixedDepositProductWritePlatformServiceJpaRepositoryImpl.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/service/FixedDepositProductWritePlatformServiceJpaRepositoryImpl.java index a05c538ab10..b53f058324d 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/service/FixedDepositProductWritePlatformServiceJpaRepositoryImpl.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/service/FixedDepositProductWritePlatformServiceJpaRepositoryImpl.java @@ -101,8 +101,6 @@ public CommandProcessingResult update(final Long productId, final JsonCommand co final FixedDepositProduct product = this.fixedDepositProductRepository.findById(productId) .orElseThrow(() -> new FixedDepositProductNotFoundException(productId)); - product.setHelpers(this.chartAssembler); - final Map changes = product.update(command); if (changes.containsKey(chargesParamName)) { diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/service/RecurringDepositProductWritePlatformServiceJpaRepositoryImpl.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/service/RecurringDepositProductWritePlatformServiceJpaRepositoryImpl.java index 354c92cdf05..c1b189cc055 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/service/RecurringDepositProductWritePlatformServiceJpaRepositoryImpl.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/service/RecurringDepositProductWritePlatformServiceJpaRepositoryImpl.java @@ -101,8 +101,6 @@ public CommandProcessingResult update(final Long productId, final JsonCommand co final RecurringDepositProduct product = this.recurringDepositProductRepository.findById(productId) .orElseThrow(() -> new RecurringDepositProductNotFoundException(productId)); - product.setHelpers(this.chartAssembler); - final Map changes = product.update(command); if (changes.containsKey(chargesParamName)) { diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/starter/SavingsConfiguration.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/starter/SavingsConfiguration.java index e9e27ffb16c..8077de70824 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/starter/SavingsConfiguration.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/starter/SavingsConfiguration.java @@ -60,10 +60,10 @@ import org.apache.fineract.portfolio.group.domain.GroupRepository; import org.apache.fineract.portfolio.group.domain.GroupRepositoryWrapper; import org.apache.fineract.portfolio.group.service.GroupReadPlatformService; -import org.apache.fineract.portfolio.interestratechart.service.InterestIncentiveDropdownReadPlatformService; +import org.apache.fineract.portfolio.interestratechart.service.InterestIncentiveDropdownReadService; import org.apache.fineract.portfolio.interestratechart.service.InterestRateChartAssembler; -import org.apache.fineract.portfolio.interestratechart.service.InterestRateChartDropdownReadPlatformService; -import org.apache.fineract.portfolio.interestratechart.service.InterestRateChartReadPlatformService; +import org.apache.fineract.portfolio.interestratechart.service.InterestRateChartDropdownReadService; +import org.apache.fineract.portfolio.interestratechart.service.InterestRateChartReadService; import org.apache.fineract.portfolio.loanaccount.domain.LoanRepository; import org.apache.fineract.portfolio.note.domain.NoteRepository; import org.apache.fineract.portfolio.paymentdetail.service.PaymentDetailWritePlatformService; @@ -168,11 +168,11 @@ public DepositAccountInterestRateChartReadPlatformServiceImpl.DepositAccountInte @Bean @ConditionalOnMissingBean(DepositAccountInterestRateChartReadPlatformService.class) - public DepositAccountInterestRateChartReadPlatformService depositAccountInterestRateChartReadPlatformService( - PlatformSecurityContext context, JdbcTemplate jdbcTemplate, + public DepositAccountInterestRateChartReadPlatformService depositAccountInterestRateChartReadService(PlatformSecurityContext context, + JdbcTemplate jdbcTemplate, DepositAccountInterestRateChartReadPlatformServiceImpl.DepositAccountInterestRateChartExtractor chartExtractor, - InterestRateChartDropdownReadPlatformService chartDropdownReadPlatformService, - InterestIncentiveDropdownReadPlatformService interestIncentiveDropdownReadPlatformService, + InterestRateChartDropdownReadService chartDropdownReadPlatformService, + InterestIncentiveDropdownReadService interestIncentiveDropdownReadPlatformService, CodeValueReadPlatformService codeValueReadPlatformService) { return new DepositAccountInterestRateChartReadPlatformServiceImpl(context, jdbcTemplate, chartExtractor, chartDropdownReadPlatformService, interestIncentiveDropdownReadPlatformService, codeValueReadPlatformService); @@ -200,7 +200,7 @@ public DepositAccountPreMatureCalculationPlatformService depositAccountPreMature @ConditionalOnMissingBean(DepositAccountReadPlatformService.class) public DepositAccountReadPlatformService depositAccountReadPlatformService(PlatformSecurityContext context, JdbcTemplate jdbcTemplate, DepositAccountInterestRateChartReadPlatformService chartReadPlatformService, - InterestRateChartReadPlatformService productChartReadPlatformService, + InterestRateChartReadService productChartReadPlatformService, PaginationParametersDataValidator paginationParametersDataValidator, DatabaseSpecificSQLGenerator sqlGenerator, PaginationHelper paginationHelper, ClientReadPlatformService clientReadPlatformService, GroupReadPlatformService groupReadPlatformService, DepositProductReadPlatformService depositProductReadPlatformService, @@ -268,7 +268,7 @@ public DepositApplicationProcessWritePlatformService depositApplicationProcessWr @Bean @ConditionalOnMissingBean(DepositProductReadPlatformService.class) public DepositProductReadPlatformService depositProductReadPlatformService(PlatformSecurityContext context, JdbcTemplate jdbcTemplate, - InterestRateChartReadPlatformService interestRateChartReadPlatformService) { + InterestRateChartReadService interestRateChartReadPlatformService) { return new DepositProductReadPlatformServiceImpl(context, jdbcTemplate, interestRateChartReadPlatformService); } diff --git a/fineract-provider/src/main/resources/application.properties b/fineract-provider/src/main/resources/application.properties index 02d0325ba38..a67d89b228c 100644 --- a/fineract-provider/src/main/resources/application.properties +++ b/fineract-provider/src/main/resources/application.properties @@ -640,3 +640,40 @@ resilience4j.retry.instances.commandAuditFallback.wait-duration=${FINERACT_COMMA resilience4j.retry.instances.commandAuditFallback.enable-exponential-backoff=${FINERACT_COMMAND_AUDIT_FALLBACK_RETRY_ENABLE_EXPONENTIAL_BACKOFF:true} resilience4j.retry.instances.commandAuditFallback.exponential-backoff-multiplier=${FINERACT_COMMAND_AUDIT_FALLBACK_RETRY_EXPONENTIAL_BACKOFF_MULTIPLIER:2} resilience4j.retry.instances.commandAuditFallback.retryExceptions=${FINERACT_COMMAND_AUDIT_FALLBACK_RETRY_EXCEPTIONS:org.springframework.dao.ConcurrencyFailureException,org.eclipse.persistence.exceptions.OptimisticLockException,jakarta.persistence.OptimisticLockException,org.springframework.orm.jpa.JpaOptimisticLockingFailureException} + + +resilience4j.retry.instances.commandInterestRateChartCreate.max-attempts=${FINERACT_COMMAND_INTEREST_RATE_CHART_CREATE_RETRY_MAX_ATTEMPTS:3} +resilience4j.retry.instances.commandInterestRateChartCreate.wait-duration=${FINERACT_COMMAND_INTEREST_RATE_CHART_CREATE_RETRY_WAIT_DURATION:1s} +resilience4j.retry.instances.commandInterestRateChartCreate.enable-exponential-backoff=${FINERACT_COMMAND_INTEREST_RATE_CHART_CREATE_RETRY_ENABLE_EXPONENTIAL_BACKOFF:true} +resilience4j.retry.instances.commandInterestRateChartCreate.exponential-backoff-multiplier=${FINERACT_COMMAND_INTEREST_RATE_CHART_CREATE_RETRY_EXPONENTIAL_BACKOFF_MULTIPLIER:2} +resilience4j.retry.instances.commandInterestRateChartCreate.retryExceptions=${FINERACT_COMMAND_INTEREST_RATE_CHART_CREATE_RETRY_EXCEPTIONS:org.springframework.dao.ConcurrencyFailureException,org.eclipse.persistence.exceptions.OptimisticLockException,jakarta.persistence.OptimisticLockException,org.springframework.orm.jpa.JpaOptimisticLockingFailureException} + +resilience4j.retry.instances.commandInterestRateChartUpdate.max-attempts=${FINERACT_COMMAND_INTEREST_RATE_CHART_UPDATE_RETRY_MAX_ATTEMPTS:3} +resilience4j.retry.instances.commandInterestRateChartUpdate.wait-duration=${FINERACT_COMMAND_INTEREST_RATE_CHART_UPDATE_RETRY_WAIT_DURATION:1s} +resilience4j.retry.instances.commandInterestRateChartUpdate.enable-exponential-backoff=${FINERACT_COMMAND_INTEREST_RATE_CHART_UPDATE_RETRY_ENABLE_EXPONENTIAL_BACKOFF:true} +resilience4j.retry.instances.commandInterestRateChartUpdate.exponential-backoff-multiplier=${FINERACT_COMMAND_INTEREST_RATE_CHART_UPDATE_RETRY_EXPONENTIAL_BACKOFF_MULTIPLIER:2} +resilience4j.retry.instances.commandInterestRateChartUpdate.retryExceptions=${FINERACT_COMMAND_INTEREST_RATE_CHART_UPDATE_RETRY_EXCEPTIONS:org.springframework.dao.ConcurrencyFailureException,org.eclipse.persistence.exceptions.OptimisticLockException,jakarta.persistence.OptimisticLockException,org.springframework.orm.jpa.JpaOptimisticLockingFailureException} + +resilience4j.retry.instances.commandInterestRateChartDelete.max-attempts=${FINERACT_COMMAND_INTEREST_RATE_CHART_DELETE_RETRY_MAX_ATTEMPTS:3} +resilience4j.retry.instances.commandInterestRateChartDelete.wait-duration=${FINERACT_COMMAND_INTEREST_RATE_CHART_DELETE_RETRY_WAIT_DURATION:1s} +resilience4j.retry.instances.commandInterestRateChartDelete.enable-exponential-backoff=${FINERACT_COMMAND_INTEREST_RATE_CHART_DELETE_RETRY_ENABLE_EXPONENTIAL_BACKOFF:true} +resilience4j.retry.instances.commandInterestRateChartDelete.exponential-backoff-multiplier=${FINERACT_COMMAND_INTEREST_RATE_CHART_DELETE_RETRY_EXPONENTIAL_BACKOFF_MULTIPLIER:2} +resilience4j.retry.instances.commandInterestRateChartDelete.retryExceptions=${FINERACT_COMMAND_INTEREST_RATE_CHART_DELETE_RETRY_EXCEPTIONS:org.springframework.dao.ConcurrencyFailureException,org.eclipse.persistence.exceptions.OptimisticLockException,jakarta.persistence.OptimisticLockException,org.springframework.orm.jpa.JpaOptimisticLockingFailureException} + +resilience4j.retry.instances.commandInterestRateChartSlabsCreate.max-attempts=${FINERACT_COMMAND_INTEREST_RATE_CHART_SLABS_CREATE_RETRY_MAX_ATTEMPTS:3} +resilience4j.retry.instances.commandInterestRateChartSlabsCreate.wait-duration=${FINERACT_COMMAND_INTEREST_RATE_CHART_SLABS_CREATE_RETRY_WAIT_DURATION:1s} +resilience4j.retry.instances.commandInterestRateChartSlabsCreate.enable-exponential-backoff=${FINERACT_COMMAND_INTEREST_RATE_CHART_SLABS_CREATE_RETRY_ENABLE_EXPONENTIAL_BACKOFF:true} +resilience4j.retry.instances.commandInterestRateChartSlabsCreate.exponential-backoff-multiplier=${FINERACT_COMMAND_INTEREST_RATE_CHART_SLABS_CREATE_RETRY_EXPONENTIAL_BACKOFF_MULTIPLIER:2} +resilience4j.retry.instances.commandInterestRateChartSlabsCreate.retryExceptions=${FINERACT_COMMAND_INTEREST_RATE_CHART_SLABS_CREATE_RETRY_EXCEPTIONS:org.springframework.dao.ConcurrencyFailureException,org.eclipse.persistence.exceptions.OptimisticLockException,jakarta.persistence.OptimisticLockException,org.springframework.orm.jpa.JpaOptimisticLockingFailureException} + +resilience4j.retry.instances.commandInterestRateChartSlabsUpdate.max-attempts=${FINERACT_COMMAND_INTEREST_RATE_CHART_SLABS_UPDATE_RETRY_MAX_ATTEMPTS:3} +resilience4j.retry.instances.commandInterestRateChartSlabsUpdate.wait-duration=${FINERACT_COMMAND_INTEREST_RATE_CHART_SLABS_UPDATE_RETRY_WAIT_DURATION:1s} +resilience4j.retry.instances.commandInterestRateChartSlabsUpdate.enable-exponential-backoff=${FINERACT_COMMAND_INTEREST_RATE_CHART_SLABS_UPDATE_RETRY_ENABLE_EXPONENTIAL_BACKOFF:true} +resilience4j.retry.instances.commandInterestRateChartSlabsUpdate.exponential-backoff-multiplier=${FINERACT_COMMAND_INTEREST_RATE_CHART_SLABS_UPDATE_RETRY_EXPONENTIAL_BACKOFF_MULTIPLIER:2} +resilience4j.retry.instances.commandInterestRateChartSlabsUpdate.retryExceptions=${FINERACT_COMMAND_INTEREST_RATE_CHART_SLABS_UPDATE_RETRY_EXCEPTIONS:org.springframework.dao.ConcurrencyFailureException,org.eclipse.persistence.exceptions.OptimisticLockException,jakarta.persistence.OptimisticLockException,org.springframework.orm.jpa.JpaOptimisticLockingFailureException} + +resilience4j.retry.instances.commandInterestRateChartSlabsDelete.max-attempts=${FINERACT_COMMAND_INTEREST_RATE_CHART_SLABS_DELETE_RETRY_MAX_ATTEMPTS:3} +resilience4j.retry.instances.commandInterestRateChartSlabsDelete.wait-duration=${FINERACT_COMMAND_INTEREST_RATE_CHART_SLABS_DELETE_RETRY_WAIT_DURATION:1s} +resilience4j.retry.instances.commandInterestRateChartSlabsDelete.enable-exponential-backoff=${FINERACT_COMMAND_INTEREST_RATE_CHART_SLABS_DELETE_RETRY_ENABLE_EXPONENTIAL_BACKOFF:true} +resilience4j.retry.instances.commandInterestRateChartSlabsDelete.exponential-backoff-multiplier=${FINERACT_COMMAND_INTEREST_RATE_CHART_SLABS_DELETE_RETRY_EXPONENTIAL_BACKOFF_MULTIPLIER:2} +resilience4j.retry.instances.commandInterestRateChartSlabsDelete.retryExceptions=${FINERACT_COMMAND_INTEREST_RATE_CHART_SLABS_DELETE_RETRY_EXCEPTIONS:org.springframework.dao.ConcurrencyFailureException,org.eclipse.persistence.exceptions.OptimisticLockException,jakarta.persistence.OptimisticLockException,org.springframework.orm.jpa.JpaOptimisticLockingFailureException} diff --git a/fineract-savings/src/main/java/org/apache/fineract/portfolio/interestratechart/data/InterestRateChartData.java b/fineract-savings/src/main/java/org/apache/fineract/portfolio/interestratechart/data/InterestRateChartData.java index 6dd4d9ce84c..a66a38dcd05 100644 --- a/fineract-savings/src/main/java/org/apache/fineract/portfolio/interestratechart/data/InterestRateChartData.java +++ b/fineract-savings/src/main/java/org/apache/fineract/portfolio/interestratechart/data/InterestRateChartData.java @@ -18,9 +18,11 @@ */ package org.apache.fineract.portfolio.interestratechart.data; +import com.fasterxml.jackson.annotation.JsonProperty; import java.time.LocalDate; import java.util.ArrayList; import java.util.Collection; +import lombok.Getter; import org.apache.fineract.infrastructure.codes.data.CodeValueData; import org.apache.fineract.infrastructure.core.data.EnumOptionData; import org.apache.fineract.infrastructure.core.service.DateUtils; @@ -28,6 +30,7 @@ /** * Immutable data object representing a InterestRateChart. */ +@Getter public final class InterestRateChartData { private final Long id; @@ -35,12 +38,14 @@ public final class InterestRateChartData { private final String description; private final LocalDate fromDate; private final LocalDate endDate; + @JsonProperty("savingsProductId") private final Long productId; + @JsonProperty("savingsProductName") private final String productName; private final boolean isPrimaryGroupingByAmount; // associations - private Collection chartSlabs; + private Collection chartSlabs = new ArrayList<>(); // template private final Collection periodTypes; @@ -55,7 +60,7 @@ public final class InterestRateChartData { public static InterestRateChartData instance(Long id, String name, String description, LocalDate fromDate, LocalDate endDate, boolean isPrimaryGroupingByAmount, Long savingsProductId, String savingsProductName) { Collection periodTypes = null; - Collection chartSlabs = null; + Collection chartSlabs = new ArrayList<>(); final Collection entityTypeOptions = null; final Collection attributeNameOptions = null; final Collection conditionTypeOptions = null; @@ -102,7 +107,7 @@ public static InterestRateChartData template(Collection periodTy final boolean isPrimaryGroupingByAmount = false; final Long savingsProductId = null; final String savingsProductName = null; - final Collection chartSlabs = null; + final Collection chartSlabs = new ArrayList<>(); return new InterestRateChartData(id, name, description, fromDate, endDate, isPrimaryGroupingByAmount, savingsProductId, savingsProductName, chartSlabs, periodTypes, entityTypeOptions, attributeNameOptions, conditionTypeOptions, @@ -136,10 +141,6 @@ private InterestRateChartData(Long id, String name, String description, LocalDat } public void addChartSlab(final InterestRateChartSlabData chartSlab) { - if (this.chartSlabs == null) { - this.chartSlabs = new ArrayList<>(); - } - this.chartSlabs.add(chartSlab); } diff --git a/fineract-savings/src/main/java/org/apache/fineract/portfolio/interestratechart/domain/InterestRateChartFields.java b/fineract-savings/src/main/java/org/apache/fineract/portfolio/interestratechart/domain/InterestRateChartFields.java index c9f76033ae2..bdf9158b569 100644 --- a/fineract-savings/src/main/java/org/apache/fineract/portfolio/interestratechart/domain/InterestRateChartFields.java +++ b/fineract-savings/src/main/java/org/apache/fineract/portfolio/interestratechart/domain/InterestRateChartFields.java @@ -31,12 +31,15 @@ import java.time.LocalDate; import java.util.Map; import lombok.Getter; +import lombok.Setter; import org.apache.fineract.infrastructure.core.api.JsonCommand; import org.apache.fineract.infrastructure.core.data.DataValidatorBuilder; import org.apache.fineract.infrastructure.core.domain.LocalDateInterval; import org.apache.fineract.infrastructure.core.service.DateUtils; @Embeddable +@Getter +@Setter public class InterestRateChartFields { @Column(name = "name", length = 100, unique = false, nullable = false) @@ -45,11 +48,9 @@ public class InterestRateChartFields { @Column(name = "description", nullable = true) private String description; - @Getter @Column(name = "from_date", nullable = false) private LocalDate fromDate; - @Getter @Column(name = "end_date", nullable = true) private LocalDate endDate; @@ -147,8 +148,4 @@ public boolean isApplicableChartFor(final LocalDate target) { return interval.contains(target); } - public boolean isPrimaryGroupingByAmount() { - return this.isPrimaryGroupingByAmount; - } - } diff --git a/fineract-savings/src/main/java/org/apache/fineract/portfolio/interestratechart/domain/InterestRateChartSlabFields.java b/fineract-savings/src/main/java/org/apache/fineract/portfolio/interestratechart/domain/InterestRateChartSlabFields.java index 5e6cefd3632..0092dc19104 100644 --- a/fineract-savings/src/main/java/org/apache/fineract/portfolio/interestratechart/domain/InterestRateChartSlabFields.java +++ b/fineract-savings/src/main/java/org/apache/fineract/portfolio/interestratechart/domain/InterestRateChartSlabFields.java @@ -35,12 +35,16 @@ import java.util.Locale; import java.util.Map; import java.util.Objects; +import lombok.Getter; +import lombok.Setter; import org.apache.fineract.infrastructure.core.api.JsonCommand; import org.apache.fineract.infrastructure.core.data.DataValidatorBuilder; import org.apache.fineract.infrastructure.core.service.DateUtils; import org.apache.fineract.portfolio.savings.SavingsPeriodFrequencyType; @Embeddable +@Getter +@Setter public class InterestRateChartSlabFields { @Column(name = "description", nullable = true) @@ -58,14 +62,6 @@ public class InterestRateChartSlabFields { @Column(name = "amount_range_from", scale = 6, precision = 19) private BigDecimal amountRangeFrom; - public BigDecimal getAmountRangeFrom() { - return this.amountRangeFrom; - } - - public BigDecimal getAmountRangeTo() { - return this.amountRangeTo; - } - @Column(name = "amount_range_to", scale = 6, precision = 19) private BigDecimal amountRangeTo; diff --git a/fineract-validation/src/main/resources/ValidationMessages.properties b/fineract-validation/src/main/resources/ValidationMessages.properties index 03b61d377bf..f706b607bc9 100644 --- a/fineract-validation/src/main/resources/ValidationMessages.properties +++ b/fineract-validation/src/main/resources/ValidationMessages.properties @@ -79,3 +79,28 @@ org.apache.fineract.portfolio.paymenttype.description.size=The parameter 'descri org.apache.fineract.portfolio.paymenttype.position.positive-or-zero=The parameter 'position' must be zero or positive org.apache.fineract.portfolio.paymenttype.code-name.size=The parameter 'codeName' cannot exceed 100 characters org.apache.fineract.portfolio.is-system-defined.not-null=The parameter 'isSystemDefined' is mandatory + +# Interest Rate Chart +org.apache.fineract.portfolio.interestratechart.id.not-null=The parameter 'id' is mandatory +org.apache.fineract.portfolio.interestratechart.name.not-blank=The parameter 'name' cannot be blank +org.apache.fineract.portfolio.interestratechart.description.size=The parameter 'description' cannot exceed 1000 characters +org.apache.fineract.portfolio.interestratechart.fromDate.not-null=The parameter 'fromDate' is mandatory +org.apache.fineract.portfolio.interestratechart.toDate.not-null=The parameter 'toDate' is mandatory + +# Interest Rate Chart Slabs +org.apache.fineract.portfolio.interestratechartslabs.chart-id.not-null=The parameter 'chartId' is mandatory +org.apache.fineract.portfolio.interestratechartslabs.chart-slab-id.not-null=The parameter 'chartSlabId' is mandatory +org.apache.fineract.portfolio.interestratechartslabs.period-type.not-null=The parameter 'periodType' is mandatory +org.apache.fineract.portfolio.interestratechartslabs.from-period.not-null=The parameter 'fromPeriod' is mandatory +org.apache.fineract.portfolio.interestratechartslabs.to-period.not-null=The parameter 'toPeriod' is mandatory +org.apache.fineract.portfolio.interestratechartslabs.annual-interest-rate.not-null=The parameter 'annualInterestRate' is mandatory +org.apache.fineract.portfolio.interestratechartslabs.annual-interest-rate.decimal-min=The parameter 'annualInterestRate' must be greater than or equal to 0.0 +org.apache.fineract.portfolio.interestratechartslabs.description.size=The parameter 'description' cannot exceed 500 characters + +# Interest Rate Chart Slab Incentives +org.apache.fineract.portfolio.interestratechartslabs.incentive.entity-type.not-null=The parameter 'entityType' is mandatory +org.apache.fineract.portfolio.interestratechartslabs.incentive.attribute-name.not-null=The parameter 'attributeName' is mandatory +org.apache.fineract.portfolio.interestratechartslabs.incentive.condition-type.not-null=The parameter 'conditionType' is mandatory +org.apache.fineract.portfolio.interestratechartslabs.incentive.attribute-value.not-null=The parameter 'attributeValue' is mandatory +org.apache.fineract.portfolio.interestratechartslabs.incentive.incentive-type.not-null=The parameter 'incentiveType' is mandatory +org.apache.fineract.portfolio.interestratechartslabs.incentive.amount.not-null=The parameter 'amount' is mandatory