From 6963b544f5fa3efc3fa724a2bdbaebfc0e7ceecc Mon Sep 17 00:00:00 2001 From: kapil-panchal Date: Tue, 16 Sep 2025 12:33:40 +0530 Subject: [PATCH] FINERACT-2250 - Feature --- .../ApproveRejectMakerCheckerCommand.java | 32 +++---- .../command/DeleteMakerCheckerCommand.java | 33 ++++++++ .../ApproveRejectMakerCheckerRequest.java | 52 ++++++++++++ .../ApproveRejectMakerCheckerResponse.java | 34 ++++++++ .../data/DeleteMakerCheckerRequest.java | 46 ++++++++++ .../data/DeleteMakerCheckerResponse.java | 34 ++++++++ .../data/MakerCheckerResponseDTO.java | 43 ++++++++++ .../api/MakercheckersApiResource.java | 83 ++++++++++--------- ...proveRejectMakerCheckerCommandHandler.java | 54 ++++++++++++ .../DeleteMakerCheckerCommandHandler.java | 42 ++++++++++ .../resources/ValidationMessages.properties | 12 +++ 11 files changed, 404 insertions(+), 61 deletions(-) rename fineract-provider/src/main/java/org/apache/fineract/commands/api/MakercheckersApiResourceSwagger.java => fineract-core/src/main/java/org/apache/fineract/commands/command/ApproveRejectMakerCheckerCommand.java (60%) create mode 100644 fineract-core/src/main/java/org/apache/fineract/commands/command/DeleteMakerCheckerCommand.java create mode 100644 fineract-core/src/main/java/org/apache/fineract/commands/data/ApproveRejectMakerCheckerRequest.java create mode 100644 fineract-core/src/main/java/org/apache/fineract/commands/data/ApproveRejectMakerCheckerResponse.java create mode 100644 fineract-core/src/main/java/org/apache/fineract/commands/data/DeleteMakerCheckerRequest.java create mode 100644 fineract-core/src/main/java/org/apache/fineract/commands/data/DeleteMakerCheckerResponse.java create mode 100644 fineract-core/src/main/java/org/apache/fineract/commands/data/MakerCheckerResponseDTO.java create mode 100644 fineract-provider/src/main/java/org/apache/fineract/commands/handler/ApproveRejectMakerCheckerCommandHandler.java create mode 100644 fineract-provider/src/main/java/org/apache/fineract/commands/handler/DeleteMakerCheckerCommandHandler.java diff --git a/fineract-provider/src/main/java/org/apache/fineract/commands/api/MakercheckersApiResourceSwagger.java b/fineract-core/src/main/java/org/apache/fineract/commands/command/ApproveRejectMakerCheckerCommand.java similarity index 60% rename from fineract-provider/src/main/java/org/apache/fineract/commands/api/MakercheckersApiResourceSwagger.java rename to fineract-core/src/main/java/org/apache/fineract/commands/command/ApproveRejectMakerCheckerCommand.java index 07f523e016c..d632eaedaa1 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/commands/api/MakercheckersApiResourceSwagger.java +++ b/fineract-core/src/main/java/org/apache/fineract/commands/command/ApproveRejectMakerCheckerCommand.java @@ -16,28 +16,18 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.fineract.commands.api; +package org.apache.fineract.commands.command; -import io.swagger.v3.oas.annotations.media.Schema; +import java.io.Serial; +import lombok.Getter; +import lombok.Setter; +import org.apache.fineract.command.core.Command; +import org.apache.fineract.commands.data.ApproveRejectMakerCheckerRequest; -/** - * Created by sanyam on 27/7/17. - */ -final class MakercheckersApiResourceSwagger { - - private MakercheckersApiResourceSwagger() { - // only to initialize swagger documentation - } - - @Schema(description = "PostMakerCheckersResponse") - public static final class PostMakerCheckersResponse { - - private PostMakerCheckersResponse() { - - } - - @Schema(example = "1") - public Long auditId; +@Getter +@Setter +public class ApproveRejectMakerCheckerCommand extends Command { - } + @Serial + private static final long serialVersionUID = 1L; } diff --git a/fineract-core/src/main/java/org/apache/fineract/commands/command/DeleteMakerCheckerCommand.java b/fineract-core/src/main/java/org/apache/fineract/commands/command/DeleteMakerCheckerCommand.java new file mode 100644 index 00000000000..7d3f64116a4 --- /dev/null +++ b/fineract-core/src/main/java/org/apache/fineract/commands/command/DeleteMakerCheckerCommand.java @@ -0,0 +1,33 @@ +/** + * 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.commands.command; + +import java.io.Serial; +import lombok.Getter; +import lombok.Setter; +import org.apache.fineract.command.core.Command; +import org.apache.fineract.commands.data.DeleteMakerCheckerRequest; + +@Getter +@Setter +public class DeleteMakerCheckerCommand extends Command { + + @Serial + private static final long serialVersionUID = 1L; +} diff --git a/fineract-core/src/main/java/org/apache/fineract/commands/data/ApproveRejectMakerCheckerRequest.java b/fineract-core/src/main/java/org/apache/fineract/commands/data/ApproveRejectMakerCheckerRequest.java new file mode 100644 index 00000000000..f4155f4dc8a --- /dev/null +++ b/fineract-core/src/main/java/org/apache/fineract/commands/data/ApproveRejectMakerCheckerRequest.java @@ -0,0 +1,52 @@ +/** + * 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.commands.data; + +import jakarta.validation.constraints.Digits; +import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotNull; +import jakarta.validation.constraints.Pattern; +import jakarta.validation.constraints.PositiveOrZero; +import java.io.Serial; +import java.io.Serializable; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; + +@Getter +@Setter +@NoArgsConstructor +@AllArgsConstructor +@Builder +public class ApproveRejectMakerCheckerRequest implements Serializable { + + @Serial + private static final long serialVersionUID = 1L; + + @NotNull(message = "{org.apache.fineract.commands.makerchecker.auditId.notnull}") + @PositiveOrZero(message = "{org.apache.fineract.commands.makerchecker.auditId.positiveOrZero}") + @Digits(integer = 10, fraction = 0, message = "{org.apache.fineract.commands.makerchecker.auditId.digits}") + private Long auditId; + + @NotBlank(message = "{org.apache.fineract.commands.makerchecker.command.param.notblank}") + @Pattern(regexp = "^(approve|reject)$", message = "{org.apache.fineract.commands.makerchecker.command.param.pattern}") + private String commandParam; +} diff --git a/fineract-core/src/main/java/org/apache/fineract/commands/data/ApproveRejectMakerCheckerResponse.java b/fineract-core/src/main/java/org/apache/fineract/commands/data/ApproveRejectMakerCheckerResponse.java new file mode 100644 index 00000000000..7afeddb2250 --- /dev/null +++ b/fineract-core/src/main/java/org/apache/fineract/commands/data/ApproveRejectMakerCheckerResponse.java @@ -0,0 +1,34 @@ +/** + * 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.commands.data; + +import java.io.Serial; +import java.io.Serializable; +import lombok.Getter; +import lombok.Setter; +import lombok.experimental.SuperBuilder; + +@Getter +@Setter +@SuperBuilder +public class ApproveRejectMakerCheckerResponse extends MakerCheckerResponseDTO implements Serializable { + + @Serial + private static final long serialVersionUID = 1L; +} diff --git a/fineract-core/src/main/java/org/apache/fineract/commands/data/DeleteMakerCheckerRequest.java b/fineract-core/src/main/java/org/apache/fineract/commands/data/DeleteMakerCheckerRequest.java new file mode 100644 index 00000000000..fcbdb0b58a4 --- /dev/null +++ b/fineract-core/src/main/java/org/apache/fineract/commands/data/DeleteMakerCheckerRequest.java @@ -0,0 +1,46 @@ +/** + * 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.commands.data; + +import jakarta.validation.constraints.Digits; +import jakarta.validation.constraints.NotNull; +import jakarta.validation.constraints.PositiveOrZero; +import java.io.Serial; +import java.io.Serializable; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; + +@Getter +@Setter +@NoArgsConstructor +@AllArgsConstructor +@Builder +public class DeleteMakerCheckerRequest implements Serializable { + + @Serial + private static final long serialVersionUID = 1L; + + @NotNull(message = "{org.apache.fineract.commands.makerchecker.auditId.notnull}") + @PositiveOrZero(message = "{org.apache.fineract.commands.makerchecker.auditId.positiveOrZero}") + @Digits(integer = 10, fraction = 0, message = "{org.apache.fineract.commands.makerchecker.auditId.digits}") + private Long auditId; +} diff --git a/fineract-core/src/main/java/org/apache/fineract/commands/data/DeleteMakerCheckerResponse.java b/fineract-core/src/main/java/org/apache/fineract/commands/data/DeleteMakerCheckerResponse.java new file mode 100644 index 00000000000..55d3fa2cd77 --- /dev/null +++ b/fineract-core/src/main/java/org/apache/fineract/commands/data/DeleteMakerCheckerResponse.java @@ -0,0 +1,34 @@ +/** + * 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.commands.data; + +import java.io.Serial; +import java.io.Serializable; +import lombok.Getter; +import lombok.Setter; +import lombok.experimental.SuperBuilder; + +@Getter +@Setter +@SuperBuilder +public class DeleteMakerCheckerResponse extends MakerCheckerResponseDTO implements Serializable { + + @Serial + private static final long serialVersionUID = 1L; +} diff --git a/fineract-core/src/main/java/org/apache/fineract/commands/data/MakerCheckerResponseDTO.java b/fineract-core/src/main/java/org/apache/fineract/commands/data/MakerCheckerResponseDTO.java new file mode 100644 index 00000000000..830f29cda17 --- /dev/null +++ b/fineract-core/src/main/java/org/apache/fineract/commands/data/MakerCheckerResponseDTO.java @@ -0,0 +1,43 @@ +/** + * 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.commands.data; + +import java.io.Serial; +import java.io.Serializable; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.experimental.SuperBuilder; + +@Getter +@Setter +@NoArgsConstructor +@AllArgsConstructor +@SuperBuilder +public abstract class MakerCheckerResponseDTO implements Serializable { + + @Serial + private static final long serialVersionUID = 1L; + + private Long commandId; + private Long officeId; + private Long clientId; + private Long resourceId; +} diff --git a/fineract-provider/src/main/java/org/apache/fineract/commands/api/MakercheckersApiResource.java b/fineract-provider/src/main/java/org/apache/fineract/commands/api/MakercheckersApiResource.java index 5acafefbc2e..f7e65b6358b 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/commands/api/MakercheckersApiResource.java +++ b/fineract-provider/src/main/java/org/apache/fineract/commands/api/MakercheckersApiResource.java @@ -20,11 +20,11 @@ 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.responses.ApiResponse; -import io.swagger.v3.oas.annotations.responses.ApiResponses; import io.swagger.v3.oas.annotations.tags.Tag; +import jakarta.validation.constraints.Digits; +import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.Pattern; +import jakarta.validation.constraints.PositiveOrZero; import jakarta.ws.rs.BeanParam; import jakarta.ws.rs.Consumes; import jakarta.ws.rs.DELETE; @@ -38,36 +38,40 @@ import jakarta.ws.rs.core.MediaType; import jakarta.ws.rs.core.UriInfo; import java.util.List; +import java.util.UUID; +import java.util.function.Supplier; import lombok.RequiredArgsConstructor; import org.apache.commons.lang3.StringUtils; +import org.apache.fineract.command.core.CommandPipeline; +import org.apache.fineract.commands.command.ApproveRejectMakerCheckerCommand; +import org.apache.fineract.commands.command.DeleteMakerCheckerCommand; +import org.apache.fineract.commands.data.ApproveRejectMakerCheckerRequest; +import org.apache.fineract.commands.data.ApproveRejectMakerCheckerResponse; import org.apache.fineract.commands.data.AuditData; import org.apache.fineract.commands.data.AuditSearchData; +import org.apache.fineract.commands.data.DeleteMakerCheckerRequest; +import org.apache.fineract.commands.data.DeleteMakerCheckerResponse; import org.apache.fineract.commands.data.request.MakerCheckerRequest; import org.apache.fineract.commands.service.AuditReadPlatformService; -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.exception.UnrecognizedQueryParamException; import org.apache.fineract.infrastructure.core.serialization.ApiRequestJsonSerializationSettings; +import org.apache.fineract.infrastructure.core.service.DateUtils; import org.apache.fineract.infrastructure.security.utils.SQLBuilder; import org.springframework.stereotype.Component; @Path("/v1/makercheckers") @Component @Tag(name = "Maker Checker (or 4-eye) functionality") +@Consumes({ MediaType.APPLICATION_JSON }) +@Produces({ MediaType.APPLICATION_JSON }) @RequiredArgsConstructor public class MakercheckersApiResource { - private static final String COMMAND_APPROVE = "approve"; - private static final String COMMAND_REJECT = "reject"; - private final AuditReadPlatformService readPlatformService; private final ApiRequestParameterHelper apiRequestParameterHelper; - private final PortfolioCommandSourceWritePlatformService writePlatformService; + private final CommandPipeline commandPipeline; @GET - @Consumes({ MediaType.APPLICATION_JSON }) - @Produces({ MediaType.APPLICATION_JSON }) @Operation(summary = "List Maker Checker Entries", description = "Get a list of entries that can be checked by the requestor that match the criteria supplied.\n" + "\n" + "Example Requests:\n" + "\n" + "makercheckers\n" + "\n" + "makercheckers?fields=madeOnDate,maker,processingResult\n" + "\n" + "makercheckers?makerDateTimeFrom=2013-03-25 08:00:00&makerDateTimeTo=2013-04-04 18:00:00\n" + "\n" @@ -77,13 +81,10 @@ public List retrieveCommands(@Context final UriInfo uriInfo, @BeanPar final ApiRequestJsonSerializationSettings settings = apiRequestParameterHelper.process(uriInfo.getQueryParameters()); return readPlatformService.retrieveAllEntriesToBeChecked(extraCriteria, settings.isIncludeJson()); - } @GET @Path("/searchtemplate") - @Consumes({ MediaType.APPLICATION_JSON }) - @Produces({ MediaType.APPLICATION_JSON }) @Operation(summary = "Maker Checker Search Template", description = "This is a convenience resource. It can be useful when building a Checker Inbox UI. \"appUsers\" are data scoped to the office/branch the requestor is associated with. \"actionNames\" and \"entityNames\" returned are those that the requestor has Checker approval permissions for.\n" + "\n" + "Example Requests:\n" + "\n" + "makercheckers/searchtemplate\n" + "makercheckers/searchtemplate?fields=entityNames") public AuditSearchData retrieveAuditSearchTemplate() { @@ -92,24 +93,21 @@ public AuditSearchData retrieveAuditSearchTemplate() { @POST @Path("{auditId}") - @Consumes({ MediaType.APPLICATION_JSON }) - @Produces({ MediaType.APPLICATION_JSON }) @Operation(summary = "Approve Maker Checker Entry | Reject Maker Checker Entry") - @ApiResponses({ - @ApiResponse(responseCode = "200", description = "OK", content = @Content(schema = @Schema(implementation = MakercheckersApiResourceSwagger.PostMakerCheckersResponse.class))) }) - public CommandProcessingResult approveMakerCheckerEntry(@PathParam("auditId") @Parameter(description = "auditId") final Long auditId, - @QueryParam("command") @Parameter(description = "command") final String commandParam) { - - CommandProcessingResult result = null; - if (is(commandParam, COMMAND_APPROVE)) { - result = writePlatformService.approveEntry(auditId); - } else if (is(commandParam, COMMAND_REJECT)) { - final Long id = writePlatformService.rejectEntry(auditId); - result = CommandProcessingResult.commandOnlyResult(id); - } else { - throw new UnrecognizedQueryParamException("command", commandParam); - } - return result; + public ApproveRejectMakerCheckerResponse approveMakerCheckerEntry( + @PathParam("auditId") @Parameter(description = "auditId") @PositiveOrZero(message = "{org.apache.fineract.commands.makerchecker.auditId.positiveOrZero}") @Digits(integer = 10, fraction = 0, message = "{org.apache.fineract.commands.makerchecker.auditId.digits}") final Long auditId, + @QueryParam("command") @Parameter(description = "command") @NotBlank(message = "{org.apache.fineract.commands.makerchecker.command.param.notblank}") @Pattern(regexp = "^(approve|reject)$", message = "{org.apache.fineract.commands.makerchecker.command.param.pattern}") final String commandParam) { + + final ApproveRejectMakerCheckerRequest request = ApproveRejectMakerCheckerRequest.builder().auditId(auditId) + .commandParam(commandParam).build(); + + final ApproveRejectMakerCheckerCommand command = new ApproveRejectMakerCheckerCommand(); + command.setPayload(request); + command.setCreatedAt(DateUtils.getAuditOffsetDateTime()); + command.setId(UUID.randomUUID()); + + final Supplier response = commandPipeline.send(command); + return response.get(); } private boolean is(final String commandParam, final String commandValue) { @@ -118,14 +116,19 @@ private boolean is(final String commandParam, final String commandValue) { @DELETE @Path("{auditId}") - @Consumes({ MediaType.APPLICATION_JSON }) - @Produces({ MediaType.APPLICATION_JSON }) @Operation(summary = "Delete Maker Checker Entry") - @ApiResponses({ - @ApiResponse(responseCode = "200", description = "OK", content = @Content(schema = @Schema(implementation = MakercheckersApiResourceSwagger.PostMakerCheckersResponse.class))) }) - public CommandProcessingResult deleteMakerCheckerEntry(@PathParam("auditId") @Parameter(description = "auditId") final Long auditId) { - final Long id = writePlatformService.deleteEntry(auditId); - return CommandProcessingResult.commandOnlyResult(id); + public DeleteMakerCheckerResponse deleteMakerCheckerEntry( + @PathParam("auditId") @Parameter(description = "auditId") @PositiveOrZero(message = "{org.apache.fineract.commands.makerchecker.auditId.positiveOrZero}") @Digits(integer = 10, fraction = 0, message = "{org.apache.fineract.commands.makerchecker.auditId.digits}") final Long auditId) { + + final DeleteMakerCheckerRequest request = DeleteMakerCheckerRequest.builder().auditId(auditId).build(); + final DeleteMakerCheckerCommand command = new DeleteMakerCheckerCommand(); + + command.setPayload(request); + command.setCreatedAt(DateUtils.getAuditOffsetDateTime()); + command.setId(UUID.randomUUID()); + + final Supplier response = commandPipeline.send(command); + return response.get(); } private SQLBuilder getExtraCriteria(MakerCheckerRequest makerCheckerRequest) { diff --git a/fineract-provider/src/main/java/org/apache/fineract/commands/handler/ApproveRejectMakerCheckerCommandHandler.java b/fineract-provider/src/main/java/org/apache/fineract/commands/handler/ApproveRejectMakerCheckerCommandHandler.java new file mode 100644 index 00000000000..6928dd9e948 --- /dev/null +++ b/fineract-provider/src/main/java/org/apache/fineract/commands/handler/ApproveRejectMakerCheckerCommandHandler.java @@ -0,0 +1,54 @@ +/** + * 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.commands.handler; + +import lombok.RequiredArgsConstructor; +import org.apache.fineract.command.core.Command; +import org.apache.fineract.command.core.CommandHandler; +import org.apache.fineract.commands.data.ApproveRejectMakerCheckerRequest; +import org.apache.fineract.commands.data.ApproveRejectMakerCheckerResponse; +import org.apache.fineract.commands.service.PortfolioCommandSourceWritePlatformService; +import org.apache.fineract.infrastructure.core.data.CommandProcessingResult; +import org.apache.fineract.infrastructure.core.exception.UnrecognizedQueryParamException; +import org.springframework.stereotype.Component; +import org.springframework.transaction.annotation.Transactional; + +@Component +@RequiredArgsConstructor +public class ApproveRejectMakerCheckerCommandHandler + implements CommandHandler { + + private final PortfolioCommandSourceWritePlatformService writePlatformService; + + @Transactional + @Override + public ApproveRejectMakerCheckerResponse handle(Command command) { + + if (command.getPayload().getCommandParam().equalsIgnoreCase("approve")) { + CommandProcessingResult response = writePlatformService.approveEntry(command.getPayload().getAuditId()); + return ApproveRejectMakerCheckerResponse.builder().commandId(response.getCommandId()).officeId(response.getOfficeId()) + .clientId(response.getClientId()).resourceId(response.getResourceId()).build(); + } else if (command.getPayload().getCommandParam().equalsIgnoreCase("reject")) { + final Long id = writePlatformService.rejectEntry(command.getPayload().getAuditId()); + return ApproveRejectMakerCheckerResponse.builder().commandId(id).build(); + } else { + throw new UnrecognizedQueryParamException("command", command.getPayload().getCommandParam()); + } + } +} diff --git a/fineract-provider/src/main/java/org/apache/fineract/commands/handler/DeleteMakerCheckerCommandHandler.java b/fineract-provider/src/main/java/org/apache/fineract/commands/handler/DeleteMakerCheckerCommandHandler.java new file mode 100644 index 00000000000..d17a4e3fc41 --- /dev/null +++ b/fineract-provider/src/main/java/org/apache/fineract/commands/handler/DeleteMakerCheckerCommandHandler.java @@ -0,0 +1,42 @@ +/** + * 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.commands.handler; + +import lombok.RequiredArgsConstructor; +import org.apache.fineract.command.core.Command; +import org.apache.fineract.command.core.CommandHandler; +import org.apache.fineract.commands.data.DeleteMakerCheckerRequest; +import org.apache.fineract.commands.data.DeleteMakerCheckerResponse; +import org.apache.fineract.commands.service.PortfolioCommandSourceWritePlatformService; +import org.springframework.stereotype.Component; +import org.springframework.transaction.annotation.Transactional; + +@Component +@RequiredArgsConstructor +public class DeleteMakerCheckerCommandHandler implements CommandHandler { + + private final PortfolioCommandSourceWritePlatformService writePlatformService; + + @Transactional + @Override + public DeleteMakerCheckerResponse handle(Command command) { + final Long id = writePlatformService.deleteEntry(command.getPayload().getAuditId()); + return DeleteMakerCheckerResponse.builder().commandId(id).build(); + } +} diff --git a/fineract-validation/src/main/resources/ValidationMessages.properties b/fineract-validation/src/main/resources/ValidationMessages.properties index d8d01b20a7f..4dc18e77ff8 100644 --- a/fineract-validation/src/main/resources/ValidationMessages.properties +++ b/fineract-validation/src/main/resources/ValidationMessages.properties @@ -43,3 +43,15 @@ org.apache.fineract.cache.cache-type.not-null=The parameter 'cacheType' is manda org.apache.fineract.organisation.monetary.currencies.not-null=The parameter 'currencies' is mandatory. org.apache.fineract.organisation.monetary.currencies.not-empty=The parameter 'currencies' cannot be empty. + +# MakerChecker + +org.apache.fineract.commands.makerchecker.auditId.notnull=The Audit ID must not be null. +org.apache.fineract.commands.makerchecker.auditId.positiveOrZero=The Audit ID must be a \ + positive number. +org.apache.fineract.commands.makerchecker.auditId.digits=Audit ID must be a valid number \ + with up to {integer} digits. +org.apache.fineract.commands.makerchecker.command.param.notblank=Command Param cannot be blank, \ + and it should either be 'approve' or 'reject'. +org.apache.fineract.commands.makerchecker.command.param.pattern=Command Param must either be \ + 'approve' or 'reject'.