From 3a842ecb9a12842d2e90b9d0b8d4652b1ffacd8e Mon Sep 17 00:00:00 2001 From: Aleksandar Vidakovic Date: Wed, 18 Feb 2026 15:19:29 +0100 Subject: [PATCH] FINERACT-2243: New command processing - payment type (#5506) --- ...AccountMappingReadPlatformServiceImpl.java | 4 +- .../portfolio/charge/domain/Charge.java | 2 +- fineract-command/REFACTORING.md | 4 +- .../service/CommandWrapperBuilder.java | 25 --- .../api/PaymentTypeApiResource.java | 88 ++++----- .../api/PaymentTypeApiResourceConstants.java | 43 ----- .../api/PaymentTypeApiResourceSwagger.java | 96 ---------- .../command/PaymentTypeCreateCommand.java | 28 +++ .../command/PaymentTypeDeleteCommand.java | 28 +++ .../command/PaymentTypeUpdateCommand.java | 28 +++ .../data/PaymentTypeCreateRequest.java | 56 ++++++ .../data/PaymentTypeCreateResponse.java | 26 +-- .../paymenttype/data/PaymentTypeData.java | 36 ++-- .../data/PaymentTypeDataValidator.java | 176 ------------------ ...est.java => PaymentTypeDeleteRequest.java} | 14 +- .../data/PaymentTypeDeleteResponse.java | 38 ++++ .../data/PaymentTypeUpdateRequest.java | 60 ++++++ .../data/PaymentTypeUpdateResponse.java | 38 ++++ .../paymenttype/domain/PaymentType.java | 41 +--- .../domain/PaymentTypeRepositoryWrapper.java | 12 +- ...a => PaymentTypeCreateCommandHandler.java} | 34 ++-- ...a => PaymentTypeDeleteCommandHandler.java} | 34 ++-- ...a => PaymentTypeUpdateCommandHandler.java} | 34 ++-- .../PaymentTypeCreateRequestMapper.java | 32 ++++ ...rvice.java => PaymentTypeReadService.java} | 2 +- ...l.java => PaymentTypeReadServiceImpl.java} | 33 ++-- .../service/PaymentTypeWriteService.java | 14 +- .../service/PaymentTypeWriteServiceImpl.java | 103 +++++----- .../starter/PaymentTypeConfiguration.java | 20 +- .../data/DocumentCreateRequest.java | 16 +- .../data/DocumentUpdateRequest.java | 18 +- .../PaymentTypeGlobalInitializerStep.java | 12 +- .../mapper/LoanTransactionMapperTest.java | 4 +- .../api/JournalEntriesApiResourceSwagger.java | 4 +- .../JournalEntryReadPlatformServiceImpl.java | 2 +- ...ulkImportWorkbookPopulatorServiceImpl.java | 6 +- .../core/config/SecurityConfig.java | 7 + .../ChargeReadPlatformServiceImpl.java | 2 +- ...entTransactionReadPlatformServiceImpl.java | 2 +- ...ollectionSheetReadPlatformServiceImpl.java | 7 +- .../starter/CollectionSheetConfiguration.java | 4 +- .../api/LoanTransactionsApiResource.java | 4 +- .../service/LoanReadPlatformServiceImpl.java | 6 +- .../starter/LoanAccountConfiguration.java | 19 +- .../api/LoanProductsApiResource.java | 4 +- ...DepositAccountTransactionsApiResource.java | 4 +- .../api/FixedDepositProductsApiResource.java | 4 +- ...DepositAccountTransactionsApiResource.java | 4 +- .../RecurringDepositProductsApiResource.java | 4 +- ...SavingsAccountTransactionsApiResource.java | 4 +- .../api/SavingsProductsApiResource.java | 4 +- ...eMatureCalculationPlatformServiceImpl.java | 4 +- ...DepositAccountReadPlatformServiceImpl.java | 6 +- ...SavingsAccountReadPlatformServiceImpl.java | 2 +- .../savings/starter/SavingsConfiguration.java | 6 +- .../src/main/resources/application.properties | 24 ++- .../resources/ValidationMessages.properties | 21 +++ .../ClientSavingsIntegrationTest.java | 13 +- .../GroupSavingsIntegrationTest.java | 9 +- ...eOffWithAdvancedPaymentAllocationTest.java | 9 +- ...playWithAdvancedPaymentAllocationTest.java | 9 +- .../LoanPostChargeOffScenariosTest.java | 9 +- .../PaymentTypeIntegrationTest.java | 22 +-- .../RepaymentWithPostDatedChecksTest.java | 9 +- ...paymentWithDownPaymentIntegrationTest.java | 9 +- .../loan/LoanImportHandlerTest.java | 7 +- .../loan/LoanWorkbookPopulatorTest.java | 9 +- .../common/PaymentTypeHelper.java | 18 +- .../AccountTransferWithdrawalFeeTest.java | 9 +- 69 files changed, 727 insertions(+), 758 deletions(-) delete mode 100644 fineract-core/src/main/java/org/apache/fineract/portfolio/paymenttype/api/PaymentTypeApiResourceConstants.java delete mode 100644 fineract-core/src/main/java/org/apache/fineract/portfolio/paymenttype/api/PaymentTypeApiResourceSwagger.java create mode 100644 fineract-core/src/main/java/org/apache/fineract/portfolio/paymenttype/command/PaymentTypeCreateCommand.java create mode 100644 fineract-core/src/main/java/org/apache/fineract/portfolio/paymenttype/command/PaymentTypeDeleteCommand.java create mode 100644 fineract-core/src/main/java/org/apache/fineract/portfolio/paymenttype/command/PaymentTypeUpdateCommand.java create mode 100644 fineract-core/src/main/java/org/apache/fineract/portfolio/paymenttype/data/PaymentTypeCreateRequest.java rename fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/factory/PaymentTypesRequestFactory.java => fineract-core/src/main/java/org/apache/fineract/portfolio/paymenttype/data/PaymentTypeCreateResponse.java (60%) delete mode 100644 fineract-core/src/main/java/org/apache/fineract/portfolio/paymenttype/data/PaymentTypeDataValidator.java rename fineract-core/src/main/java/org/apache/fineract/portfolio/paymenttype/data/{request/PaymentTypeRequest.java => PaymentTypeDeleteRequest.java} (75%) create mode 100644 fineract-core/src/main/java/org/apache/fineract/portfolio/paymenttype/data/PaymentTypeDeleteResponse.java create mode 100644 fineract-core/src/main/java/org/apache/fineract/portfolio/paymenttype/data/PaymentTypeUpdateRequest.java create mode 100644 fineract-core/src/main/java/org/apache/fineract/portfolio/paymenttype/data/PaymentTypeUpdateResponse.java rename fineract-core/src/main/java/org/apache/fineract/portfolio/paymenttype/handler/{DeletePaymentTypeCommandHandler.java => PaymentTypeCreateCommandHandler.java} (52%) rename fineract-core/src/main/java/org/apache/fineract/portfolio/paymenttype/handler/{CreatePaymentTypeCommandHandler.java => PaymentTypeDeleteCommandHandler.java} (52%) rename fineract-core/src/main/java/org/apache/fineract/portfolio/paymenttype/handler/{UpdatePaymentTypeCommandHandler.java => PaymentTypeUpdateCommandHandler.java} (52%) create mode 100644 fineract-core/src/main/java/org/apache/fineract/portfolio/paymenttype/mapper/PaymentTypeCreateRequestMapper.java rename fineract-core/src/main/java/org/apache/fineract/portfolio/paymenttype/service/{PaymentTypeReadPlatformService.java => PaymentTypeReadService.java} (95%) rename fineract-core/src/main/java/org/apache/fineract/portfolio/paymenttype/service/{PaymentTypeReadPlatformServiceImpl.java => PaymentTypeReadServiceImpl.java} (63%) diff --git a/fineract-accounting/src/main/java/org/apache/fineract/accounting/producttoaccountmapping/service/ProductToGLAccountMappingReadPlatformServiceImpl.java b/fineract-accounting/src/main/java/org/apache/fineract/accounting/producttoaccountmapping/service/ProductToGLAccountMappingReadPlatformServiceImpl.java index 0e243f5f5..859a64399 100644 --- a/fineract-accounting/src/main/java/org/apache/fineract/accounting/producttoaccountmapping/service/ProductToGLAccountMappingReadPlatformServiceImpl.java +++ b/fineract-accounting/src/main/java/org/apache/fineract/accounting/producttoaccountmapping/service/ProductToGLAccountMappingReadPlatformServiceImpl.java @@ -223,8 +223,8 @@ public class ProductToGLAccountMappingReadPlatformServiceImpl implements Product List paymentTypeToGLAccountMappers = mappings.isEmpty() ? null : new ArrayList<>(); for (final ProductToGLAccountMapping mapping : mappings) { - final PaymentTypeData paymentTypeData = PaymentTypeData.instance(mapping.getPaymentType().getId(), - mapping.getPaymentType().getName()); + final PaymentTypeData paymentTypeData = PaymentTypeData.builder().id(mapping.getPaymentType().getId()) + .name(mapping.getPaymentType().getName()).build(); final GLAccountData gLAccountData = new GLAccountData().setId(mapping.getGlAccount().getId()) .setName(mapping.getGlAccount().getName()).setGlCode(mapping.getGlAccount().getGlCode()); diff --git a/fineract-charge/src/main/java/org/apache/fineract/portfolio/charge/domain/Charge.java b/fineract-charge/src/main/java/org/apache/fineract/portfolio/charge/domain/Charge.java index bdede8231..2f8e909a9 100644 --- a/fineract-charge/src/main/java/org/apache/fineract/portfolio/charge/domain/Charge.java +++ b/fineract-charge/src/main/java/org/apache/fineract/portfolio/charge/domain/Charge.java @@ -647,7 +647,7 @@ public class Charge extends AbstractPersistableCustom { PaymentTypeData paymentTypeData = null; if (this.paymentType != null) { - paymentTypeData = PaymentTypeData.instance(paymentType.getId(), paymentType.getName()); + paymentTypeData = PaymentTypeData.builder().id(paymentType.getId()).name(paymentType.getName()).build(); } final CurrencyData currency = new CurrencyData(this.currencyCode, null, 0, 0, null, null); diff --git a/fineract-command/REFACTORING.md b/fineract-command/REFACTORING.md index 2db31baa0..abdf90921 100644 --- a/fineract-command/REFACTORING.md +++ b/fineract-command/REFACTORING.md @@ -298,12 +298,12 @@ public class CreatePaymentTypeCommandHandler implements NewCommandSourceHandler @Slf4j @RequiredArgsConstructor @Component -public class CreatePaymentTypeCommandHandler implements CommandHandler { +public class PaymentTypeCreateCommandHandler implements CommandHandler { private final PaymentTypeWriteService paymentTypeWriteService; @Override - public CreatePaymentTypeResponse handle(Command command) { + public PaymentTypeCreateResponse handle(Command command) { // TODO: refactor business logic service to accept properly typed request objects as input return paymentTypeWriteService.createPaymentType(command.getPayload()); } diff --git a/fineract-core/src/main/java/org/apache/fineract/commands/service/CommandWrapperBuilder.java b/fineract-core/src/main/java/org/apache/fineract/commands/service/CommandWrapperBuilder.java index 9a7302c03..61b339618 100644 --- a/fineract-core/src/main/java/org/apache/fineract/commands/service/CommandWrapperBuilder.java +++ b/fineract-core/src/main/java/org/apache/fineract/commands/service/CommandWrapperBuilder.java @@ -29,7 +29,6 @@ import org.apache.fineract.commands.domain.CommandWrapper; import org.apache.fineract.infrastructure.accountnumberformat.service.AccountNumberFormatConstants; import org.apache.fineract.infrastructure.core.domain.ExternalId; import org.apache.fineract.portfolio.client.api.ClientApiConstants; -import org.apache.fineract.portfolio.paymenttype.api.PaymentTypeApiResourceConstants; import org.apache.fineract.portfolio.savings.DepositsApiConstants; import org.apache.fineract.portfolio.self.pockets.api.PocketApiConstants; import org.apache.fineract.useradministration.api.PasswordPreferencesApiConstants; @@ -2946,30 +2945,6 @@ public class CommandWrapperBuilder { return this; } - public CommandWrapperBuilder createPaymentType() { - this.actionName = "CREATE"; - this.entityName = PaymentTypeApiResourceConstants.ENTITY_NAME; - this.entityId = null; - this.href = "/" + PaymentTypeApiResourceConstants.RESOURCE_NAME; - return this; - } - - public CommandWrapperBuilder updatePaymentType(final Long paymentTypeId) { - this.actionName = "UPDATE"; - this.entityName = PaymentTypeApiResourceConstants.ENTITY_NAME; - this.entityId = paymentTypeId; - this.href = "/" + PaymentTypeApiResourceConstants.RESOURCE_NAME + paymentTypeId; - return this; - } - - public CommandWrapperBuilder deletePaymentType(final Long paymentTypeId) { - this.actionName = "DELETE"; - this.entityName = "PAYMENTTYPE"; - this.entityId = paymentTypeId; - this.href = "/" + PaymentTypeApiResourceConstants.RESOURCE_NAME + paymentTypeId; - return this; - } - public CommandWrapperBuilder updateExternalServiceProperties(final String externalServiceName) { this.actionName = "UPDATE"; this.entityName = "EXTERNALSERVICES"; diff --git a/fineract-core/src/main/java/org/apache/fineract/portfolio/paymenttype/api/PaymentTypeApiResource.java b/fineract-core/src/main/java/org/apache/fineract/portfolio/paymenttype/api/PaymentTypeApiResource.java index bf30fc051..4be438b08 100644 --- a/fineract-core/src/main/java/org/apache/fineract/portfolio/paymenttype/api/PaymentTypeApiResource.java +++ b/fineract-core/src/main/java/org/apache/fineract/portfolio/paymenttype/api/PaymentTypeApiResource.java @@ -19,11 +19,6 @@ package org.apache.fineract.portfolio.paymenttype.api; 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; import jakarta.ws.rs.DELETE; @@ -36,17 +31,21 @@ import jakarta.ws.rs.Produces; import jakarta.ws.rs.QueryParam; import jakarta.ws.rs.core.MediaType; 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.data.CommandProcessingResult; +import org.apache.fineract.command.core.CommandPipeline; import org.apache.fineract.infrastructure.core.serialization.DefaultToApiJsonSerializer; -import org.apache.fineract.infrastructure.security.service.PlatformSecurityContext; +import org.apache.fineract.portfolio.paymenttype.command.PaymentTypeCreateCommand; +import org.apache.fineract.portfolio.paymenttype.command.PaymentTypeDeleteCommand; +import org.apache.fineract.portfolio.paymenttype.command.PaymentTypeUpdateCommand; +import org.apache.fineract.portfolio.paymenttype.data.PaymentTypeCreateRequest; +import org.apache.fineract.portfolio.paymenttype.data.PaymentTypeCreateResponse; import org.apache.fineract.portfolio.paymenttype.data.PaymentTypeData; -import org.apache.fineract.portfolio.paymenttype.data.request.PaymentTypeRequest; -import org.apache.fineract.portfolio.paymenttype.domain.PaymentTypeRepositoryWrapper; -import org.apache.fineract.portfolio.paymenttype.service.PaymentTypeReadPlatformService; +import org.apache.fineract.portfolio.paymenttype.data.PaymentTypeDeleteRequest; +import org.apache.fineract.portfolio.paymenttype.data.PaymentTypeDeleteResponse; +import org.apache.fineract.portfolio.paymenttype.data.PaymentTypeUpdateRequest; +import org.apache.fineract.portfolio.paymenttype.data.PaymentTypeUpdateResponse; +import org.apache.fineract.portfolio.paymenttype.service.PaymentTypeReadService; import org.springframework.stereotype.Component; @Path("/v1/paymenttypes") @@ -55,19 +54,15 @@ import org.springframework.stereotype.Component; @RequiredArgsConstructor public class PaymentTypeApiResource { - private final PlatformSecurityContext securityContext; + private final PaymentTypeReadService readPlatformService; + private final CommandPipeline commandPipeline; private final DefaultToApiJsonSerializer jsonSerializer; - private final PaymentTypeReadPlatformService readPlatformService; - private final PortfolioCommandSourceWritePlatformService commandWritePlatformService; - private final PaymentTypeRepositoryWrapper paymentTypeRepositoryWrapper; @GET @Consumes({ MediaType.TEXT_HTML, MediaType.APPLICATION_JSON }) @Produces(MediaType.APPLICATION_JSON) @Operation(summary = "Retrieve all Payment Types", description = "Retrieve list of payment types") - public List getAllPaymentTypes( - @QueryParam("onlyWithCode") @Parameter(description = "onlyWithCode") final boolean onlyWithCode) { - securityContext.authenticatedUser().validateHasReadPermission(PaymentTypeApiResourceConstants.ENTITY_NAME); + public List getAllPaymentTypes(@QueryParam("onlyWithCode") final boolean onlyWithCode) { return onlyWithCode ? readPlatformService.retrieveAllPaymentTypesWithCode() : readPlatformService.retrieveAllPaymentTypes(); } @@ -76,27 +71,22 @@ public class PaymentTypeApiResource { @Consumes({ MediaType.TEXT_HTML, MediaType.APPLICATION_JSON }) @Produces(MediaType.APPLICATION_JSON) @Operation(summary = "Retrieve a Payment Type", description = "Retrieves a payment type") - public PaymentTypeData retrieveOnePaymentType( - @PathParam("paymentTypeId") @Parameter(description = "paymentTypeId") final Long paymentTypeId) { - securityContext.authenticatedUser().validateHasReadPermission(PaymentTypeApiResourceConstants.ENTITY_NAME); - paymentTypeRepositoryWrapper.findOneWithNotFoundDetection(paymentTypeId); + public PaymentTypeData retrieveOnePaymentType(@PathParam("paymentTypeId") final Long paymentTypeId) { return readPlatformService.retrieveOne(paymentTypeId); } @POST @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) - @Operation(summary = "Create a Payment Type", description = "Creates a new Payment type\n\n" + "Mandatory Fields: name\n\n" - + "Optional Fields: Description, isCashPayment,Position") - @RequestBody(required = true, content = @Content(schema = @Schema(implementation = PaymentTypeRequest.class))) - @ApiResponse(responseCode = "200", description = "OK", content = @Content(schema = @Schema(implementation = PaymentTypeApiResourceSwagger.PostPaymentTypesResponse.class))) - public CommandProcessingResult createPaymentType(@Parameter(hidden = true) PaymentTypeRequest paymentTypeRequest) { + @Operation(summary = "Create a Payment Type", description = "Creates a new Payment type") + public PaymentTypeCreateResponse createPaymentType(PaymentTypeCreateRequest request) { + final var command = new PaymentTypeCreateCommand(); - final CommandWrapper commandRequest = new CommandWrapperBuilder().createPaymentType() - .withJson(jsonSerializer.serialize(paymentTypeRequest)).build(); + command.setPayload(request); - CommandProcessingResult result = commandWritePlatformService.logCommandSource(commandRequest); - return result; + final Supplier response = commandPipeline.send(command); + + return response.get(); } @PUT @@ -104,17 +94,18 @@ public class PaymentTypeApiResource { @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) @Operation(summary = "Update a Payment Type", description = "Updates a Payment Type") - @RequestBody(required = true, content = @Content(schema = @Schema(implementation = PaymentTypeApiResourceSwagger.PutPaymentTypesPaymentTypeIdRequest.class))) - @ApiResponse(responseCode = "200", description = "OK", content = @Content(schema = @Schema(implementation = PaymentTypeApiResourceSwagger.PutPaymentTypesPaymentTypeIdResponse.class))) - public CommandProcessingResult updatePaymentType( - @PathParam("paymentTypeId") @Parameter(description = "paymentTypeId") final Long paymentTypeId, - @Parameter(hidden = true) final String apiRequestBodyAsJson) { + public PaymentTypeUpdateResponse updatePaymentType(@PathParam("paymentTypeId") final Long paymentTypeId, + final PaymentTypeUpdateRequest request) { - final CommandWrapper commandRequest = new CommandWrapperBuilder().updatePaymentType(paymentTypeId).withJson(apiRequestBodyAsJson) - .build(); + request.setId(paymentTypeId); - final CommandProcessingResult result = commandWritePlatformService.logCommandSource(commandRequest); - return result; + final var command = new PaymentTypeUpdateCommand(); + + command.setPayload(request); + + final Supplier response = commandPipeline.send(command); + + return response.get(); } @DELETE @@ -122,15 +113,14 @@ public class PaymentTypeApiResource { @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) @Operation(summary = "Delete a Payment Type", description = "Deletes payment type") - @ApiResponse(responseCode = "200", description = "OK", content = @Content(schema = @Schema(implementation = PaymentTypeApiResourceSwagger.DeletePaymentTypesPaymentTypeIdResponse.class))) - public CommandProcessingResult deleteCode( - @PathParam("paymentTypeId") @Parameter(description = "paymentTypeId") final Long paymentTypeId) { + public PaymentTypeDeleteResponse deleteCode(@PathParam("paymentTypeId") final Long paymentTypeId) { - final CommandWrapper commandRequest = new CommandWrapperBuilder().deletePaymentType(paymentTypeId).build(); + final var command = new PaymentTypeDeleteCommand(); - final CommandProcessingResult result = commandWritePlatformService.logCommandSource(commandRequest); + command.setPayload(PaymentTypeDeleteRequest.builder().id(paymentTypeId).build()); - return result; + final Supplier response = commandPipeline.send(command); + + return response.get(); } - } diff --git a/fineract-core/src/main/java/org/apache/fineract/portfolio/paymenttype/api/PaymentTypeApiResourceConstants.java b/fineract-core/src/main/java/org/apache/fineract/portfolio/paymenttype/api/PaymentTypeApiResourceConstants.java deleted file mode 100644 index 1e28e3a44..000000000 --- a/fineract-core/src/main/java/org/apache/fineract/portfolio/paymenttype/api/PaymentTypeApiResourceConstants.java +++ /dev/null @@ -1,43 +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.paymenttype.api; - -import java.util.Arrays; -import java.util.HashSet; -import java.util.Set; - -public final class PaymentTypeApiResourceConstants { - - private PaymentTypeApiResourceConstants() { - - } - - public static final String RESOURCE_NAME = "paymenttype"; - public static final String ENTITY_NAME = "PAYMENTTYPE"; - - public static final String ID = "id"; - public static final String NAME = "name"; - public static final String DESCRIPTION = "description"; - public static final String ISCASHPAYMENT = "isCashPayment"; - public static final String POSITION = "position"; - public static final String CODE_NAME = "code_name"; - public static final String IS_SYSTEM_DEFINED = "system_defined"; - - static final Set RESPONSE_DATA_PARAMETERS = new HashSet<>(Arrays.asList(ID, NAME, DESCRIPTION, ISCASHPAYMENT)); -} diff --git a/fineract-core/src/main/java/org/apache/fineract/portfolio/paymenttype/api/PaymentTypeApiResourceSwagger.java b/fineract-core/src/main/java/org/apache/fineract/portfolio/paymenttype/api/PaymentTypeApiResourceSwagger.java deleted file mode 100644 index 325c4836b..000000000 --- a/fineract-core/src/main/java/org/apache/fineract/portfolio/paymenttype/api/PaymentTypeApiResourceSwagger.java +++ /dev/null @@ -1,96 +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.paymenttype.api; - -import io.swagger.v3.oas.annotations.media.Schema; - -/** - * Created by Chirag Gupta on 01/01/18. - */ -public final class PaymentTypeApiResourceSwagger { - - private PaymentTypeApiResourceSwagger() {} - - @Schema(description = "GetPaymentTypesResponse") - public static final class GetPaymentTypesResponse { - - private GetPaymentTypesResponse() {} - - @Schema(example = "24") - public Long id; - @Schema(example = "PTC") - public String name; - @Schema(example = "Cash") - public String description; - @Schema(example = "true") - public Boolean isCashPayment; - @Schema(example = "0") - public Integer position; - @Schema(example = "REPAYMENT_REFUND") - public String codeName; - @Schema(example = "false") - public Boolean isSystemDefined; - } - - @Schema(description = "PostPaymentTypesResponse") - public static final class PostPaymentTypesResponse { - - private PostPaymentTypesResponse() {} - - @Schema(example = "1") - public Long resourceId; - } - - @Schema(description = "PutPaymentTypesPaymentTypeIdRequest") - public static final class PutPaymentTypesPaymentTypeIdRequest { - - private PutPaymentTypesPaymentTypeIdRequest() {} - - @Schema(example = "mPay") - public String name; - @Schema(example = "not a cash payment type") - public String description; - @Schema(example = "false") - public Boolean isCashPayment; - @Schema(example = "3") - public Integer position; - @Schema(example = "REPAYMENT_REFUND") - public String codeName; - @Schema(example = "false") - public Boolean isSystemDefined; - } - - @Schema(description = "PutPaymentTypesPaymentTypeIdResponse") - public static final class PutPaymentTypesPaymentTypeIdResponse { - - private PutPaymentTypesPaymentTypeIdResponse() {} - - @Schema(example = "13") - public Long resourceId; - } - - @Schema(description = "DeletePaymentTypesPaymentTypeIdResponse") - public static final class DeletePaymentTypesPaymentTypeIdResponse { - - private DeletePaymentTypesPaymentTypeIdResponse() {} - - @Schema(example = "13") - public Long resourceId; - } -} diff --git a/fineract-core/src/main/java/org/apache/fineract/portfolio/paymenttype/command/PaymentTypeCreateCommand.java b/fineract-core/src/main/java/org/apache/fineract/portfolio/paymenttype/command/PaymentTypeCreateCommand.java new file mode 100644 index 000000000..dc6d98a76 --- /dev/null +++ b/fineract-core/src/main/java/org/apache/fineract/portfolio/paymenttype/command/PaymentTypeCreateCommand.java @@ -0,0 +1,28 @@ +/** + * 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.paymenttype.command; + +import lombok.Data; +import lombok.EqualsAndHashCode; +import org.apache.fineract.command.core.Command; +import org.apache.fineract.portfolio.paymenttype.data.PaymentTypeCreateRequest; + +@Data +@EqualsAndHashCode(callSuper = true) +public class PaymentTypeCreateCommand extends Command {} diff --git a/fineract-core/src/main/java/org/apache/fineract/portfolio/paymenttype/command/PaymentTypeDeleteCommand.java b/fineract-core/src/main/java/org/apache/fineract/portfolio/paymenttype/command/PaymentTypeDeleteCommand.java new file mode 100644 index 000000000..dc251e713 --- /dev/null +++ b/fineract-core/src/main/java/org/apache/fineract/portfolio/paymenttype/command/PaymentTypeDeleteCommand.java @@ -0,0 +1,28 @@ +/** + * 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.paymenttype.command; + +import lombok.Data; +import lombok.EqualsAndHashCode; +import org.apache.fineract.command.core.Command; +import org.apache.fineract.portfolio.paymenttype.data.PaymentTypeDeleteRequest; + +@Data +@EqualsAndHashCode(callSuper = true) +public class PaymentTypeDeleteCommand extends Command {} diff --git a/fineract-core/src/main/java/org/apache/fineract/portfolio/paymenttype/command/PaymentTypeUpdateCommand.java b/fineract-core/src/main/java/org/apache/fineract/portfolio/paymenttype/command/PaymentTypeUpdateCommand.java new file mode 100644 index 000000000..48fdf2b61 --- /dev/null +++ b/fineract-core/src/main/java/org/apache/fineract/portfolio/paymenttype/command/PaymentTypeUpdateCommand.java @@ -0,0 +1,28 @@ +/** + * 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.paymenttype.command; + +import lombok.Data; +import lombok.EqualsAndHashCode; +import org.apache.fineract.command.core.Command; +import org.apache.fineract.portfolio.paymenttype.data.PaymentTypeUpdateRequest; + +@Data +@EqualsAndHashCode(callSuper = true) +public class PaymentTypeUpdateCommand extends Command {} diff --git a/fineract-core/src/main/java/org/apache/fineract/portfolio/paymenttype/data/PaymentTypeCreateRequest.java b/fineract-core/src/main/java/org/apache/fineract/portfolio/paymenttype/data/PaymentTypeCreateRequest.java new file mode 100644 index 000000000..c87363c42 --- /dev/null +++ b/fineract-core/src/main/java/org/apache/fineract/portfolio/paymenttype/data/PaymentTypeCreateRequest.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.paymenttype.data; + +import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotNull; +import jakarta.validation.constraints.PositiveOrZero; +import jakarta.validation.constraints.Size; +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 PaymentTypeCreateRequest implements Serializable { + + @Serial + private static final long serialVersionUID = 1L; + + @NotBlank(message = "{org.apache.fineract.portfolio.paymenttype.name.not-blank}") + private String name; + @Size(max = 500, message = "{org.apache.fineract.portfolio.paymenttype.description.size}") + private String description; + private Boolean isCashPayment; + @PositiveOrZero(message = "{org.apache.fineract.portfolio.paymenttype.position.positive-or-zero}") + private Long position; + // @JsonProperty("code_name") // TODO: fix this, for backwards compatibility only... leave this for Jackson config + @Size(max = 100, message = "{org.apache.fineract.portfolio.paymenttype.code-name.size}") + private String codeName; + // @JsonProperty("system_defined") // TODO: fix this, for backwards compatibility only... leave this for Jackson + // config + @Builder.Default + @NotNull(message = "{org.apache.fineract.portfolio.is-system-defined.not-null}") + private Boolean isSystemDefined = false; +} diff --git a/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/factory/PaymentTypesRequestFactory.java b/fineract-core/src/main/java/org/apache/fineract/portfolio/paymenttype/data/PaymentTypeCreateResponse.java similarity index 60% rename from fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/factory/PaymentTypesRequestFactory.java rename to fineract-core/src/main/java/org/apache/fineract/portfolio/paymenttype/data/PaymentTypeCreateResponse.java index d928cd420..28b2c9b83 100644 --- a/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/factory/PaymentTypesRequestFactory.java +++ b/fineract-core/src/main/java/org/apache/fineract/portfolio/paymenttype/data/PaymentTypeCreateResponse.java @@ -16,19 +16,23 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.fineract.test.factory; +package org.apache.fineract.portfolio.paymenttype.data; -import org.apache.fineract.client.models.PaymentTypeRequest; +import java.io.Serial; +import java.io.Serializable; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; -public final class PaymentTypesRequestFactory { +@Builder +@Data +@NoArgsConstructor +@AllArgsConstructor +public class PaymentTypeCreateResponse implements Serializable { - private PaymentTypesRequestFactory() {} + @Serial + private static final long serialVersionUID = 1L; - public static PaymentTypeRequest defaultPaymentTypeRequest(String name, String description, Boolean isCashPayment, Integer position) { - PaymentTypeRequest request = new PaymentTypeRequest(); - - request.name(name).description(description).isCashPayment(isCashPayment).position(position); - - return request; - } + private Long resourceId; } diff --git a/fineract-core/src/main/java/org/apache/fineract/portfolio/paymenttype/data/PaymentTypeData.java b/fineract-core/src/main/java/org/apache/fineract/portfolio/paymenttype/data/PaymentTypeData.java index be656fd51..2af1b04aa 100644 --- a/fineract-core/src/main/java/org/apache/fineract/portfolio/paymenttype/data/PaymentTypeData.java +++ b/fineract-core/src/main/java/org/apache/fineract/portfolio/paymenttype/data/PaymentTypeData.java @@ -18,41 +18,27 @@ */ package org.apache.fineract.portfolio.paymenttype.data; +import java.io.Serial; import java.io.Serializable; import lombok.AllArgsConstructor; -import lombok.EqualsAndHashCode; -import lombok.Getter; -import lombok.Setter; -import lombok.ToString; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; -@ToString -@Getter -@Setter -@EqualsAndHashCode +@Builder +@Data +@NoArgsConstructor @AllArgsConstructor public class PaymentTypeData implements Serializable { + @Serial + private static final long serialVersionUID = 1L; + private Long id; private String name; private String description; private Boolean isCashPayment; - private Integer position; + private Long position; private String codeName; private Boolean isSystemDefined; - - public static PaymentTypeData instance(final Long id, final String name, final String description, final Boolean isCashPayment, - final Integer position) { - String codeName = null; - Boolean isSystemDefined = false; - return new PaymentTypeData(id, name, description, isCashPayment, position, codeName, isSystemDefined); - } - - public static PaymentTypeData instance(final Long id, final String name) { - String description = null; - Boolean isCashPayment = null; - Integer position = null; - String codeName = null; - Boolean isSystemDefined = false; - return new PaymentTypeData(id, name, description, isCashPayment, position, codeName, isSystemDefined); - } } diff --git a/fineract-core/src/main/java/org/apache/fineract/portfolio/paymenttype/data/PaymentTypeDataValidator.java b/fineract-core/src/main/java/org/apache/fineract/portfolio/paymenttype/data/PaymentTypeDataValidator.java deleted file mode 100644 index f37c301a0..000000000 --- a/fineract-core/src/main/java/org/apache/fineract/portfolio/paymenttype/data/PaymentTypeDataValidator.java +++ /dev/null @@ -1,176 +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.paymenttype.data; - -import com.google.gson.JsonElement; -import com.google.gson.reflect.TypeToken; -import java.lang.reflect.Type; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; -import org.apache.commons.lang3.StringUtils; -import org.apache.fineract.infrastructure.core.data.ApiParameterError; -import org.apache.fineract.infrastructure.core.data.DataValidatorBuilder; -import org.apache.fineract.infrastructure.core.exception.InvalidJsonException; -import org.apache.fineract.infrastructure.core.exception.PlatformApiDataValidationException; -import org.apache.fineract.infrastructure.core.serialization.FromJsonHelper; -import org.apache.fineract.portfolio.paymenttype.api.PaymentTypeApiResourceConstants; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; - -@Component -public class PaymentTypeDataValidator { - - private final FromJsonHelper fromApiJsonHelper; - private static final Set CREATE_PAYMENT_TYPE_REQUEST_DATA_PARAMETERS = new HashSet<>( - Arrays.asList(PaymentTypeApiResourceConstants.NAME, PaymentTypeApiResourceConstants.DESCRIPTION, - PaymentTypeApiResourceConstants.ISCASHPAYMENT, PaymentTypeApiResourceConstants.POSITION, - PaymentTypeApiResourceConstants.CODE_NAME, PaymentTypeApiResourceConstants.IS_SYSTEM_DEFINED)); - - private static final Set UPDATE_PAYMENT_TYPE_REQUEST_DATA_PARAMETERS = new HashSet<>( - Arrays.asList(PaymentTypeApiResourceConstants.NAME, PaymentTypeApiResourceConstants.DESCRIPTION, - PaymentTypeApiResourceConstants.ISCASHPAYMENT, PaymentTypeApiResourceConstants.POSITION, - PaymentTypeApiResourceConstants.CODE_NAME, PaymentTypeApiResourceConstants.IS_SYSTEM_DEFINED)); - - @Autowired - public PaymentTypeDataValidator(final FromJsonHelper fromApiJsonHelper) { - this.fromApiJsonHelper = fromApiJsonHelper; - } - - public void validateForCreate(final String json) { - - if (StringUtils.isBlank(json)) { - throw new InvalidJsonException(); - } - - final Type typeOfMap = new TypeToken>() {}.getType(); - this.fromApiJsonHelper.checkForUnsupportedParameters(typeOfMap, json, CREATE_PAYMENT_TYPE_REQUEST_DATA_PARAMETERS); - final JsonElement element = this.fromApiJsonHelper.parse(json); - - final List dataValidationErrors = new ArrayList<>(); - - final DataValidatorBuilder baseDataValidator = new DataValidatorBuilder(dataValidationErrors) - .resource(PaymentTypeApiResourceConstants.ENTITY_NAME); - - if (this.fromApiJsonHelper.parameterExists(PaymentTypeApiResourceConstants.NAME, element)) { - final String name = this.fromApiJsonHelper.extractStringNamed(PaymentTypeApiResourceConstants.NAME, element); - baseDataValidator.reset().parameter(PaymentTypeApiResourceConstants.NAME).value(name).notBlank(); - } - - if (this.fromApiJsonHelper.parameterExists(PaymentTypeApiResourceConstants.DESCRIPTION, element)) { - final String description = this.fromApiJsonHelper.extractStringNamed(PaymentTypeApiResourceConstants.DESCRIPTION, element); - baseDataValidator.reset().parameter(PaymentTypeApiResourceConstants.DESCRIPTION).value(description).ignoreIfNull() - .notExceedingLengthOf(500); - } - - if (this.fromApiJsonHelper.parameterExists(PaymentTypeApiResourceConstants.ISCASHPAYMENT, element)) { - final Boolean isCashPayment = this.fromApiJsonHelper.extractBooleanNamed(PaymentTypeApiResourceConstants.ISCASHPAYMENT, - element); - baseDataValidator.reset().parameter(PaymentTypeApiResourceConstants.ISCASHPAYMENT).value(isCashPayment) - .validateForBooleanValue(); - } - - if (this.fromApiJsonHelper.parameterExists(PaymentTypeApiResourceConstants.POSITION, element)) { - final Long position = this.fromApiJsonHelper.extractLongNamed(PaymentTypeApiResourceConstants.POSITION, element); - baseDataValidator.reset().parameter(PaymentTypeApiResourceConstants.POSITION).value(position).ignoreIfNull() - .integerZeroOrGreater(); - } - - if (this.fromApiJsonHelper.parameterExists(PaymentTypeApiResourceConstants.CODE_NAME, element)) { - final String codeName = this.fromApiJsonHelper.extractStringNamed(PaymentTypeApiResourceConstants.CODE_NAME, element); - baseDataValidator.reset().parameter(PaymentTypeApiResourceConstants.CODE_NAME).value(codeName).ignoreIfNull() - .notExceedingLengthOf(100); - } - - if (this.fromApiJsonHelper.parameterExists(PaymentTypeApiResourceConstants.IS_SYSTEM_DEFINED, element)) { - final Boolean isSystemDefined = this.fromApiJsonHelper.extractBooleanNamed(PaymentTypeApiResourceConstants.IS_SYSTEM_DEFINED, - element); - baseDataValidator.reset().parameter(PaymentTypeApiResourceConstants.IS_SYSTEM_DEFINED).value(isSystemDefined) - .validateForBooleanValue(); - } - - throwExceptionIfValidationWarningsExist(dataValidationErrors); - } - - private void throwExceptionIfValidationWarningsExist(final List dataValidationErrors) { - if (!dataValidationErrors.isEmpty()) { - // - throw new PlatformApiDataValidationException(dataValidationErrors); - } - } - - public void validateForUpdate(final String json) { - if (StringUtils.isBlank(json)) { - throw new InvalidJsonException(); - } - - final Type typeOfMap = new TypeToken>() {}.getType(); - this.fromApiJsonHelper.checkForUnsupportedParameters(typeOfMap, json, UPDATE_PAYMENT_TYPE_REQUEST_DATA_PARAMETERS); - - final JsonElement element = this.fromApiJsonHelper.parse(json); - - final List dataValidationErrors = new ArrayList<>(); - - final DataValidatorBuilder baseDataValidator = new DataValidatorBuilder(dataValidationErrors) - .resource(PaymentTypeApiResourceConstants.ENTITY_NAME); - - if (this.fromApiJsonHelper.parameterExists(PaymentTypeApiResourceConstants.NAME, element)) { - final String name = this.fromApiJsonHelper.extractStringNamed(PaymentTypeApiResourceConstants.NAME, element); - baseDataValidator.reset().parameter(PaymentTypeApiResourceConstants.NAME).value(name); - } - - if (this.fromApiJsonHelper.parameterExists(PaymentTypeApiResourceConstants.DESCRIPTION, element)) { - final String description = this.fromApiJsonHelper.extractStringNamed(PaymentTypeApiResourceConstants.DESCRIPTION, element); - baseDataValidator.reset().parameter(PaymentTypeApiResourceConstants.DESCRIPTION).value(description).ignoreIfNull() - .notExceedingLengthOf(500); - } - - if (this.fromApiJsonHelper.parameterExists(PaymentTypeApiResourceConstants.ISCASHPAYMENT, element)) { - final Boolean isCashPayment = this.fromApiJsonHelper.extractBooleanNamed(PaymentTypeApiResourceConstants.ISCASHPAYMENT, - element); - baseDataValidator.reset().parameter(PaymentTypeApiResourceConstants.ISCASHPAYMENT).value(isCashPayment) - .validateForBooleanValue(); - } - - if (this.fromApiJsonHelper.parameterExists(PaymentTypeApiResourceConstants.POSITION, element)) { - final Long position = this.fromApiJsonHelper.extractLongNamed(PaymentTypeApiResourceConstants.POSITION, element); - baseDataValidator.reset().parameter(PaymentTypeApiResourceConstants.POSITION).value(position).ignoreIfNull() - .integerZeroOrGreater(); - } - - if (this.fromApiJsonHelper.parameterExists(PaymentTypeApiResourceConstants.CODE_NAME, element)) { - final String codeName = this.fromApiJsonHelper.extractStringNamed(PaymentTypeApiResourceConstants.CODE_NAME, element); - baseDataValidator.reset().parameter(PaymentTypeApiResourceConstants.CODE_NAME).value(codeName).ignoreIfNull() - .notExceedingLengthOf(100); - } - - if (this.fromApiJsonHelper.parameterExists(PaymentTypeApiResourceConstants.IS_SYSTEM_DEFINED, element)) { - final Boolean isSystemDefined = this.fromApiJsonHelper.extractBooleanNamed(PaymentTypeApiResourceConstants.IS_SYSTEM_DEFINED, - element); - baseDataValidator.reset().parameter(PaymentTypeApiResourceConstants.IS_SYSTEM_DEFINED).value(isSystemDefined) - .validateForBooleanValue(); - } - - throwExceptionIfValidationWarningsExist(dataValidationErrors); - } - -} diff --git a/fineract-core/src/main/java/org/apache/fineract/portfolio/paymenttype/data/request/PaymentTypeRequest.java b/fineract-core/src/main/java/org/apache/fineract/portfolio/paymenttype/data/PaymentTypeDeleteRequest.java similarity index 75% rename from fineract-core/src/main/java/org/apache/fineract/portfolio/paymenttype/data/request/PaymentTypeRequest.java rename to fineract-core/src/main/java/org/apache/fineract/portfolio/paymenttype/data/PaymentTypeDeleteRequest.java index f7cc8b00f..44d4a2eed 100644 --- a/fineract-core/src/main/java/org/apache/fineract/portfolio/paymenttype/data/request/PaymentTypeRequest.java +++ b/fineract-core/src/main/java/org/apache/fineract/portfolio/paymenttype/data/PaymentTypeDeleteRequest.java @@ -16,15 +16,23 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.fineract.portfolio.paymenttype.data.request; +package org.apache.fineract.portfolio.paymenttype.data; import java.io.Serial; import java.io.Serializable; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; -public record PaymentTypeRequest(String name, String description, Boolean isCashPayment, Integer position, String codeName, - Boolean isSystemDefined) implements Serializable { +@Builder +@Data +@NoArgsConstructor +@AllArgsConstructor +public class PaymentTypeDeleteRequest implements Serializable { @Serial private static final long serialVersionUID = 1L; + private Long id; } diff --git a/fineract-core/src/main/java/org/apache/fineract/portfolio/paymenttype/data/PaymentTypeDeleteResponse.java b/fineract-core/src/main/java/org/apache/fineract/portfolio/paymenttype/data/PaymentTypeDeleteResponse.java new file mode 100644 index 000000000..89c6072f0 --- /dev/null +++ b/fineract-core/src/main/java/org/apache/fineract/portfolio/paymenttype/data/PaymentTypeDeleteResponse.java @@ -0,0 +1,38 @@ +/** + * 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.paymenttype.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 PaymentTypeDeleteResponse implements Serializable { + + @Serial + private static final long serialVersionUID = 1L; + + private Long resourceId; +} diff --git a/fineract-core/src/main/java/org/apache/fineract/portfolio/paymenttype/data/PaymentTypeUpdateRequest.java b/fineract-core/src/main/java/org/apache/fineract/portfolio/paymenttype/data/PaymentTypeUpdateRequest.java new file mode 100644 index 000000000..9163a2203 --- /dev/null +++ b/fineract-core/src/main/java/org/apache/fineract/portfolio/paymenttype/data/PaymentTypeUpdateRequest.java @@ -0,0 +1,60 @@ +/** + * 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.paymenttype.data; + +import io.swagger.v3.oas.annotations.Hidden; +import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotNull; +import jakarta.validation.constraints.PositiveOrZero; +import jakarta.validation.constraints.Size; +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 PaymentTypeUpdateRequest implements Serializable { + + @Serial + private static final long serialVersionUID = 1L; + + @Hidden + @NotNull(message = "{org.apache.fineract.portfolio.paymenttype.id.not-null}") + private Long id; + @NotBlank(message = "{org.apache.fineract.portfolio.paymenttype.name.not-blank}") + private String name; + @Size(max = 500, message = "{org.apache.fineract.portfolio.paymenttype.description.size}") + private String description; + private Boolean isCashPayment; + @PositiveOrZero(message = "{org.apache.fineract.portfolio.paymenttype.position.positive-or-zero}") + private Long position; + // @JsonProperty("code_name") // TODO: fix this, for backwards compatibility only... leave this for Jackson config + @Size(max = 100, message = "{org.apache.fineract.portfolio.paymenttype.code-name.size}") + private String codeName; + // @JsonProperty("system_defined") // TODO: fix this, for backwards compatibility only... leave this for Jackson + // config + @Builder.Default + @NotNull(message = "{org.apache.fineract.portfolio.is-system-defined.not-null}") + private Boolean isSystemDefined = false; +} diff --git a/fineract-core/src/main/java/org/apache/fineract/portfolio/paymenttype/data/PaymentTypeUpdateResponse.java b/fineract-core/src/main/java/org/apache/fineract/portfolio/paymenttype/data/PaymentTypeUpdateResponse.java new file mode 100644 index 000000000..6a112043d --- /dev/null +++ b/fineract-core/src/main/java/org/apache/fineract/portfolio/paymenttype/data/PaymentTypeUpdateResponse.java @@ -0,0 +1,38 @@ +/** + * 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.paymenttype.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 PaymentTypeUpdateResponse implements Serializable { + + @Serial + private static final long serialVersionUID = 1L; + + private Long resourceId; +} diff --git a/fineract-core/src/main/java/org/apache/fineract/portfolio/paymenttype/domain/PaymentType.java b/fineract-core/src/main/java/org/apache/fineract/portfolio/paymenttype/domain/PaymentType.java index 321276f38..2305cdd81 100644 --- a/fineract-core/src/main/java/org/apache/fineract/portfolio/paymenttype/domain/PaymentType.java +++ b/fineract-core/src/main/java/org/apache/fineract/portfolio/paymenttype/domain/PaymentType.java @@ -21,20 +21,17 @@ package org.apache.fineract.portfolio.paymenttype.domain; import jakarta.persistence.Column; import jakarta.persistence.Entity; import jakarta.persistence.Table; -import java.util.LinkedHashMap; -import java.util.Map; import lombok.AllArgsConstructor; import lombok.Getter; +import lombok.NoArgsConstructor; import lombok.Setter; -import org.apache.commons.lang3.StringUtils; -import org.apache.fineract.infrastructure.core.api.JsonCommand; import org.apache.fineract.infrastructure.core.domain.AbstractPersistableCustom; -import org.apache.fineract.portfolio.paymenttype.api.PaymentTypeApiResourceConstants; @Getter @Setter @Entity @Table(name = "m_payment_type") +@NoArgsConstructor @AllArgsConstructor public class PaymentType extends AbstractPersistableCustom { @@ -55,38 +52,4 @@ public class PaymentType extends AbstractPersistableCustom { @Column(name = "is_system_defined") private Boolean isSystemDefined; - - protected PaymentType() {} - - public Map update(final JsonCommand command) { - - final Map actualChanges = new LinkedHashMap<>(3); - - if (command.isChangeInStringParameterNamed(PaymentTypeApiResourceConstants.NAME, this.name)) { - final String newValue = command.stringValueOfParameterNamed(PaymentTypeApiResourceConstants.NAME); - actualChanges.put(PaymentTypeApiResourceConstants.NAME, newValue); - this.name = StringUtils.defaultIfEmpty(newValue, null); - } - - if (command.isChangeInStringParameterNamed(PaymentTypeApiResourceConstants.DESCRIPTION, this.description)) { - final String newDescription = command.stringValueOfParameterNamed(PaymentTypeApiResourceConstants.DESCRIPTION); - actualChanges.put(PaymentTypeApiResourceConstants.DESCRIPTION, newDescription); - this.description = StringUtils.defaultIfEmpty(newDescription, null); - } - - if (command.isChangeInBooleanParameterNamed(PaymentTypeApiResourceConstants.ISCASHPAYMENT, this.isCashPayment)) { - final Boolean newCashPaymentType = command.booleanObjectValueOfParameterNamed(PaymentTypeApiResourceConstants.ISCASHPAYMENT); - actualChanges.put(PaymentTypeApiResourceConstants.ISCASHPAYMENT, newCashPaymentType); - this.isCashPayment = newCashPaymentType.booleanValue(); - } - - if (command.isChangeInLongParameterNamed(PaymentTypeApiResourceConstants.POSITION, this.position)) { - final Long newPosition = command.longValueOfParameterNamed(PaymentTypeApiResourceConstants.POSITION); - actualChanges.put(PaymentTypeApiResourceConstants.POSITION, newPosition); - this.position = newPosition; - } - - return actualChanges; - } - } diff --git a/fineract-core/src/main/java/org/apache/fineract/portfolio/paymenttype/domain/PaymentTypeRepositoryWrapper.java b/fineract-core/src/main/java/org/apache/fineract/portfolio/paymenttype/domain/PaymentTypeRepositoryWrapper.java index 8bcf81d02..e0d77bc55 100644 --- a/fineract-core/src/main/java/org/apache/fineract/portfolio/paymenttype/domain/PaymentTypeRepositoryWrapper.java +++ b/fineract-core/src/main/java/org/apache/fineract/portfolio/paymenttype/domain/PaymentTypeRepositoryWrapper.java @@ -18,27 +18,19 @@ */ package org.apache.fineract.portfolio.paymenttype.domain; -import java.util.List; import lombok.RequiredArgsConstructor; import org.apache.fineract.portfolio.paymenttype.exception.PaymentTypeNotFoundException; import org.springframework.stereotype.Service; @Service @RequiredArgsConstructor +// TODO: get rid of this, unnecessarily hides real repository; don't use this outside of payment domain! +@Deprecated(forRemoval = true) public class PaymentTypeRepositoryWrapper { private final PaymentTypeRepository repository; - public List findAll() { - return this.repository.findAllByOrderByPositionAsc(); - } - - public List findAllWithCodeName() { - return this.repository.findAllByCodeNameIsNotNullOrderByPositionAsc(); - } - public PaymentType findOneWithNotFoundDetection(final Long id) { return this.repository.findById(id).orElseThrow(() -> new PaymentTypeNotFoundException(id)); } - } diff --git a/fineract-core/src/main/java/org/apache/fineract/portfolio/paymenttype/handler/DeletePaymentTypeCommandHandler.java b/fineract-core/src/main/java/org/apache/fineract/portfolio/paymenttype/handler/PaymentTypeCreateCommandHandler.java similarity index 52% rename from fineract-core/src/main/java/org/apache/fineract/portfolio/paymenttype/handler/DeletePaymentTypeCommandHandler.java rename to fineract-core/src/main/java/org/apache/fineract/portfolio/paymenttype/handler/PaymentTypeCreateCommandHandler.java index 9be10b2fa..e7604f6e8 100644 --- a/fineract-core/src/main/java/org/apache/fineract/portfolio/paymenttype/handler/DeletePaymentTypeCommandHandler.java +++ b/fineract-core/src/main/java/org/apache/fineract/portfolio/paymenttype/handler/PaymentTypeCreateCommandHandler.java @@ -18,29 +18,33 @@ */ package org.apache.fineract.portfolio.paymenttype.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 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.paymenttype.data.PaymentTypeCreateRequest; +import org.apache.fineract.portfolio.paymenttype.data.PaymentTypeCreateResponse; import org.apache.fineract.portfolio.paymenttype.service.PaymentTypeWriteService; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; +import org.springframework.stereotype.Component; import org.springframework.transaction.annotation.Transactional; -@Service -@CommandType(entity = "PAYMENTTYPE", action = "DELETE") -public class DeletePaymentTypeCommandHandler implements NewCommandSourceHandler { +@Slf4j +@Component +@RequiredArgsConstructor +public class PaymentTypeCreateCommandHandler implements CommandHandler { private final PaymentTypeWriteService paymentTypeWriteService; - @Autowired - public DeletePaymentTypeCommandHandler(final PaymentTypeWriteService paymentTypeWriteService) { - this.paymentTypeWriteService = paymentTypeWriteService; + @Retry(name = "commandPaymentTypeCreate", fallbackMethod = "fallback") + @Override + @Transactional + public PaymentTypeCreateResponse handle(Command command) { + return paymentTypeWriteService.createPaymentType(command.getPayload()); } @Override - @Transactional - public CommandProcessingResult processCommand(JsonCommand command) { - return this.paymentTypeWriteService.deletePaymentType(command.entityId()); + public PaymentTypeCreateResponse fallback(Command command, Throwable t) { + return CommandHandler.super.fallback(command, t); } } diff --git a/fineract-core/src/main/java/org/apache/fineract/portfolio/paymenttype/handler/CreatePaymentTypeCommandHandler.java b/fineract-core/src/main/java/org/apache/fineract/portfolio/paymenttype/handler/PaymentTypeDeleteCommandHandler.java similarity index 52% rename from fineract-core/src/main/java/org/apache/fineract/portfolio/paymenttype/handler/CreatePaymentTypeCommandHandler.java rename to fineract-core/src/main/java/org/apache/fineract/portfolio/paymenttype/handler/PaymentTypeDeleteCommandHandler.java index 8c0b81ebe..9c1e9d050 100644 --- a/fineract-core/src/main/java/org/apache/fineract/portfolio/paymenttype/handler/CreatePaymentTypeCommandHandler.java +++ b/fineract-core/src/main/java/org/apache/fineract/portfolio/paymenttype/handler/PaymentTypeDeleteCommandHandler.java @@ -18,29 +18,33 @@ */ package org.apache.fineract.portfolio.paymenttype.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 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.paymenttype.data.PaymentTypeDeleteRequest; +import org.apache.fineract.portfolio.paymenttype.data.PaymentTypeDeleteResponse; import org.apache.fineract.portfolio.paymenttype.service.PaymentTypeWriteService; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; +import org.springframework.stereotype.Component; import org.springframework.transaction.annotation.Transactional; -@Service -@CommandType(entity = "PAYMENTTYPE", action = "CREATE") -public class CreatePaymentTypeCommandHandler implements NewCommandSourceHandler { +@Slf4j +@Component +@RequiredArgsConstructor +public class PaymentTypeDeleteCommandHandler implements CommandHandler { private final PaymentTypeWriteService paymentTypeWriteService; - @Autowired - public CreatePaymentTypeCommandHandler(final PaymentTypeWriteService paymentTypeWriteService) { - this.paymentTypeWriteService = paymentTypeWriteService; + @Retry(name = "commandPaymentTypeDelete", fallbackMethod = "fallback") + @Override + @Transactional + public PaymentTypeDeleteResponse handle(Command command) { + return paymentTypeWriteService.deletePaymentType(command.getPayload()); } @Override - @Transactional - public CommandProcessingResult processCommand(JsonCommand command) { - return this.paymentTypeWriteService.createPaymentType(command); + public PaymentTypeDeleteResponse fallback(Command command, Throwable t) { + return CommandHandler.super.fallback(command, t); } } diff --git a/fineract-core/src/main/java/org/apache/fineract/portfolio/paymenttype/handler/UpdatePaymentTypeCommandHandler.java b/fineract-core/src/main/java/org/apache/fineract/portfolio/paymenttype/handler/PaymentTypeUpdateCommandHandler.java similarity index 52% rename from fineract-core/src/main/java/org/apache/fineract/portfolio/paymenttype/handler/UpdatePaymentTypeCommandHandler.java rename to fineract-core/src/main/java/org/apache/fineract/portfolio/paymenttype/handler/PaymentTypeUpdateCommandHandler.java index 1240dd8bc..41914c9e5 100644 --- a/fineract-core/src/main/java/org/apache/fineract/portfolio/paymenttype/handler/UpdatePaymentTypeCommandHandler.java +++ b/fineract-core/src/main/java/org/apache/fineract/portfolio/paymenttype/handler/PaymentTypeUpdateCommandHandler.java @@ -18,29 +18,33 @@ */ package org.apache.fineract.portfolio.paymenttype.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 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.paymenttype.data.PaymentTypeUpdateRequest; +import org.apache.fineract.portfolio.paymenttype.data.PaymentTypeUpdateResponse; import org.apache.fineract.portfolio.paymenttype.service.PaymentTypeWriteService; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; +import org.springframework.stereotype.Component; import org.springframework.transaction.annotation.Transactional; -@Service -@CommandType(entity = "PAYMENTTYPE", action = "UPDATE") -public class UpdatePaymentTypeCommandHandler implements NewCommandSourceHandler { +@Slf4j +@Component +@RequiredArgsConstructor +public class PaymentTypeUpdateCommandHandler implements CommandHandler { private final PaymentTypeWriteService paymentTypeWriteService; - @Autowired - public UpdatePaymentTypeCommandHandler(final PaymentTypeWriteService paymentTypeWriteService) { - this.paymentTypeWriteService = paymentTypeWriteService; + @Retry(name = "commandPaymentTypeUpdate", fallbackMethod = "fallback") + @Override + @Transactional + public PaymentTypeUpdateResponse handle(Command command) { + return paymentTypeWriteService.updatePaymentType(command.getPayload()); } @Override - @Transactional - public CommandProcessingResult processCommand(JsonCommand command) { - return this.paymentTypeWriteService.updatePaymentType(command.entityId(), command); + public PaymentTypeUpdateResponse fallback(Command command, Throwable t) { + return CommandHandler.super.fallback(command, t); } } diff --git a/fineract-core/src/main/java/org/apache/fineract/portfolio/paymenttype/mapper/PaymentTypeCreateRequestMapper.java b/fineract-core/src/main/java/org/apache/fineract/portfolio/paymenttype/mapper/PaymentTypeCreateRequestMapper.java new file mode 100644 index 000000000..db83e4c05 --- /dev/null +++ b/fineract-core/src/main/java/org/apache/fineract/portfolio/paymenttype/mapper/PaymentTypeCreateRequestMapper.java @@ -0,0 +1,32 @@ +/** + * 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.paymenttype.mapper; + +import org.apache.fineract.infrastructure.core.config.MapstructMapperConfig; +import org.apache.fineract.portfolio.paymenttype.data.PaymentTypeCreateRequest; +import org.apache.fineract.portfolio.paymenttype.domain.PaymentType; +import org.mapstruct.Mapper; +import org.mapstruct.Mapping; + +@Mapper(config = MapstructMapperConfig.class) +public interface PaymentTypeCreateRequestMapper { + + @Mapping(ignore = true, target = "id") + PaymentType map(PaymentTypeCreateRequest source); +} diff --git a/fineract-core/src/main/java/org/apache/fineract/portfolio/paymenttype/service/PaymentTypeReadPlatformService.java b/fineract-core/src/main/java/org/apache/fineract/portfolio/paymenttype/service/PaymentTypeReadService.java similarity index 95% rename from fineract-core/src/main/java/org/apache/fineract/portfolio/paymenttype/service/PaymentTypeReadPlatformService.java rename to fineract-core/src/main/java/org/apache/fineract/portfolio/paymenttype/service/PaymentTypeReadService.java index c05051921..7a3e3edd7 100644 --- a/fineract-core/src/main/java/org/apache/fineract/portfolio/paymenttype/service/PaymentTypeReadPlatformService.java +++ b/fineract-core/src/main/java/org/apache/fineract/portfolio/paymenttype/service/PaymentTypeReadService.java @@ -21,7 +21,7 @@ package org.apache.fineract.portfolio.paymenttype.service; import java.util.List; import org.apache.fineract.portfolio.paymenttype.data.PaymentTypeData; -public interface PaymentTypeReadPlatformService { +public interface PaymentTypeReadService { List retrieveAllPaymentTypes(); diff --git a/fineract-core/src/main/java/org/apache/fineract/portfolio/paymenttype/service/PaymentTypeReadPlatformServiceImpl.java b/fineract-core/src/main/java/org/apache/fineract/portfolio/paymenttype/service/PaymentTypeReadServiceImpl.java similarity index 63% rename from fineract-core/src/main/java/org/apache/fineract/portfolio/paymenttype/service/PaymentTypeReadPlatformServiceImpl.java rename to fineract-core/src/main/java/org/apache/fineract/portfolio/paymenttype/service/PaymentTypeReadServiceImpl.java index a5825cd20..1100a59f0 100644 --- a/fineract-core/src/main/java/org/apache/fineract/portfolio/paymenttype/service/PaymentTypeReadPlatformServiceImpl.java +++ b/fineract-core/src/main/java/org/apache/fineract/portfolio/paymenttype/service/PaymentTypeReadServiceImpl.java @@ -20,47 +20,44 @@ package org.apache.fineract.portfolio.paymenttype.service; import java.util.List; import lombok.RequiredArgsConstructor; -import org.apache.fineract.infrastructure.security.service.PlatformSecurityContext; import org.apache.fineract.portfolio.paymenttype.data.PaymentTypeData; -import org.apache.fineract.portfolio.paymenttype.domain.PaymentType; -import org.apache.fineract.portfolio.paymenttype.domain.PaymentTypeRepositoryWrapper; +import org.apache.fineract.portfolio.paymenttype.domain.PaymentTypeRepository; +import org.apache.fineract.portfolio.paymenttype.exception.PaymentTypeNotFoundException; import org.apache.fineract.portfolio.paymenttype.mapper.PaymentTypeMapper; import org.springframework.cache.annotation.Cacheable; @RequiredArgsConstructor -public class PaymentTypeReadPlatformServiceImpl implements PaymentTypeReadPlatformService { +public class PaymentTypeReadServiceImpl implements PaymentTypeReadService { - private final PlatformSecurityContext context; + private final PaymentTypeRepository repository; private final PaymentTypeMapper paymentTypeMapper; - private final PaymentTypeRepositoryWrapper paymentTypeRepository; @Override @Cacheable(value = "payment_types", key = "T(org.apache.fineract.infrastructure.core.service.ThreadLocalContextUtil).getTenant().getTenantIdentifier().concat('payment_types')") public List retrieveAllPaymentTypes() { - // TODO Auto-generated method stub - this.context.authenticatedUser(); + var paymentType = repository.findAllByOrderByPositionAsc(); - List paymentType = this.paymentTypeRepository.findAll(); - return this.paymentTypeMapper.map(paymentType); + return paymentTypeMapper.map(paymentType); } @Override @Cacheable(value = "paymentTypesWithCode", key = "T(org.apache.fineract.infrastructure.core.service.ThreadLocalContextUtil).getTenant().getTenantIdentifier().concat('payment_types')") public List retrieveAllPaymentTypesWithCode() { - // TODO Auto-generated method stub - this.context.authenticatedUser(); + var paymentType = repository.findAllByCodeNameIsNotNullOrderByPositionAsc(); - List paymentType = this.paymentTypeRepository.findAllWithCodeName(); - return this.paymentTypeMapper.map(paymentType); + return paymentTypeMapper.map(paymentType); } @Override public PaymentTypeData retrieveOne(Long paymentTypeId) { - // TODO Auto-generated method stub - this.context.authenticatedUser(); + final var paymentType = repository.findById(paymentTypeId).orElseThrow(() -> new PaymentTypeNotFoundException(paymentTypeId)); - final PaymentType paymentType = this.paymentTypeRepository.findOneWithNotFoundDetection(paymentTypeId); - return this.paymentTypeMapper.map(paymentType); + return paymentTypeMapper.map(paymentType); } + /* + * // TODO: do proper jakarta validation to fineract api error mapping private void + * throwExceptionIfValidationWarningsExist(final List dataValidationErrors) { if + * (!dataValidationErrors.isEmpty()) { // throw new PlatformApiDataValidationException(dataValidationErrors); } } + */ } diff --git a/fineract-core/src/main/java/org/apache/fineract/portfolio/paymenttype/service/PaymentTypeWriteService.java b/fineract-core/src/main/java/org/apache/fineract/portfolio/paymenttype/service/PaymentTypeWriteService.java index 988602852..2d57959fd 100644 --- a/fineract-core/src/main/java/org/apache/fineract/portfolio/paymenttype/service/PaymentTypeWriteService.java +++ b/fineract-core/src/main/java/org/apache/fineract/portfolio/paymenttype/service/PaymentTypeWriteService.java @@ -18,14 +18,18 @@ */ package org.apache.fineract.portfolio.paymenttype.service; -import org.apache.fineract.infrastructure.core.api.JsonCommand; -import org.apache.fineract.infrastructure.core.data.CommandProcessingResult; +import org.apache.fineract.portfolio.paymenttype.data.PaymentTypeCreateRequest; +import org.apache.fineract.portfolio.paymenttype.data.PaymentTypeCreateResponse; +import org.apache.fineract.portfolio.paymenttype.data.PaymentTypeDeleteRequest; +import org.apache.fineract.portfolio.paymenttype.data.PaymentTypeDeleteResponse; +import org.apache.fineract.portfolio.paymenttype.data.PaymentTypeUpdateRequest; +import org.apache.fineract.portfolio.paymenttype.data.PaymentTypeUpdateResponse; public interface PaymentTypeWriteService { - CommandProcessingResult createPaymentType(JsonCommand command); + PaymentTypeCreateResponse createPaymentType(PaymentTypeCreateRequest request); - CommandProcessingResult updatePaymentType(Long id, JsonCommand command); + PaymentTypeUpdateResponse updatePaymentType(PaymentTypeUpdateRequest request); - CommandProcessingResult deletePaymentType(Long id); + PaymentTypeDeleteResponse deletePaymentType(PaymentTypeDeleteRequest request); } diff --git a/fineract-core/src/main/java/org/apache/fineract/portfolio/paymenttype/service/PaymentTypeWriteServiceImpl.java b/fineract-core/src/main/java/org/apache/fineract/portfolio/paymenttype/service/PaymentTypeWriteServiceImpl.java index 946adbbb1..b024be380 100644 --- a/fineract-core/src/main/java/org/apache/fineract/portfolio/paymenttype/service/PaymentTypeWriteServiceImpl.java +++ b/fineract-core/src/main/java/org/apache/fineract/portfolio/paymenttype/service/PaymentTypeWriteServiceImpl.java @@ -18,18 +18,21 @@ */ package org.apache.fineract.portfolio.paymenttype.service; -import java.util.Map; +import jakarta.validation.Valid; +import java.util.Objects; 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.commons.lang3.Strings; import org.apache.fineract.infrastructure.core.exception.ErrorHandler; import org.apache.fineract.infrastructure.core.exception.PlatformDataIntegrityException; -import org.apache.fineract.portfolio.paymenttype.api.PaymentTypeApiResourceConstants; -import org.apache.fineract.portfolio.paymenttype.data.PaymentTypeDataValidator; -import org.apache.fineract.portfolio.paymenttype.domain.PaymentType; +import org.apache.fineract.portfolio.paymenttype.data.PaymentTypeCreateRequest; +import org.apache.fineract.portfolio.paymenttype.data.PaymentTypeCreateResponse; +import org.apache.fineract.portfolio.paymenttype.data.PaymentTypeDeleteRequest; +import org.apache.fineract.portfolio.paymenttype.data.PaymentTypeDeleteResponse; +import org.apache.fineract.portfolio.paymenttype.data.PaymentTypeUpdateRequest; +import org.apache.fineract.portfolio.paymenttype.data.PaymentTypeUpdateResponse; import org.apache.fineract.portfolio.paymenttype.domain.PaymentTypeRepository; -import org.apache.fineract.portfolio.paymenttype.domain.PaymentTypeRepositoryWrapper; +import org.apache.fineract.portfolio.paymenttype.exception.PaymentTypeNotFoundException; +import org.apache.fineract.portfolio.paymenttype.mapper.PaymentTypeCreateRequestMapper; import org.springframework.cache.annotation.CacheEvict; import org.springframework.dao.DataIntegrityViolationException; import org.springframework.orm.jpa.JpaSystemException; @@ -38,55 +41,67 @@ import org.springframework.orm.jpa.JpaSystemException; public class PaymentTypeWriteServiceImpl implements PaymentTypeWriteService { private final PaymentTypeRepository repository; - private final PaymentTypeRepositoryWrapper repositoryWrapper; - private final PaymentTypeDataValidator fromApiJsonDeserializer; + private final PaymentTypeCreateRequestMapper createRequestMapper; @Override @CacheEvict(value = "payment_types", key = "T(org.apache.fineract.infrastructure.core.service.ThreadLocalContextUtil).getTenant().getTenantIdentifier().concat('payment_types')") - public CommandProcessingResult createPaymentType(JsonCommand command) { - this.fromApiJsonDeserializer.validateForCreate(command.json()); - String name = command.stringValueOfParameterNamed(PaymentTypeApiResourceConstants.NAME); - String description = command.stringValueOfParameterNamed(PaymentTypeApiResourceConstants.DESCRIPTION); - Boolean isCashPayment = command.booleanObjectValueOfParameterNamed(PaymentTypeApiResourceConstants.ISCASHPAYMENT); - Long position = command.longValueOfParameterNamed(PaymentTypeApiResourceConstants.POSITION); - String codeName = command.stringValueOfParameterNamed(PaymentTypeApiResourceConstants.CODE_NAME); - Boolean isSystemDefined = command.booleanObjectValueOfParameterNamed(PaymentTypeApiResourceConstants.IS_SYSTEM_DEFINED); - if (isSystemDefined == null) { - isSystemDefined = false; - } + public PaymentTypeCreateResponse createPaymentType(@Valid PaymentTypeCreateRequest request) { + final var paymentType = createRequestMapper.map(request); - PaymentType newPaymentType = new PaymentType(name, description, isCashPayment, position, codeName, isSystemDefined); - this.repository.saveAndFlush(newPaymentType); - return new CommandProcessingResultBuilder().withCommandId(command.commandId()).withEntityId(newPaymentType.getId()).build(); + repository.saveAndFlush(paymentType); + + return PaymentTypeCreateResponse.builder().resourceId(paymentType.getId()).build(); } @Override @CacheEvict(value = "payment_types", key = "T(org.apache.fineract.infrastructure.core.service.ThreadLocalContextUtil).getTenant().getTenantIdentifier().concat('payment_types')") - public CommandProcessingResult updatePaymentType(Long paymentTypeId, JsonCommand command) { - - this.fromApiJsonDeserializer.validateForUpdate(command.json()); - final PaymentType paymentType = this.repositoryWrapper.findOneWithNotFoundDetection(paymentTypeId); - final Map changes = paymentType.update(command); - - if (!changes.isEmpty()) { - this.repository.save(paymentType); - } - - return new CommandProcessingResultBuilder().withCommandId(command.commandId()).withEntityId(command.entityId()).build(); - } - - @Override - @CacheEvict(value = "payment_types", key = "T(org.apache.fineract.infrastructure.core.service.ThreadLocalContextUtil).getTenant().getTenantIdentifier().concat('payment_types')") - public CommandProcessingResult deletePaymentType(Long paymentTypeId) { - final PaymentType paymentType = this.repositoryWrapper.findOneWithNotFoundDetection(paymentTypeId); + @SuppressWarnings("AvoidHidingCauseException") + public PaymentTypeUpdateResponse updatePaymentType(@Valid PaymentTypeUpdateRequest request) { try { - this.repository.delete(paymentType); - this.repository.flush(); + final var paymentType = repository.findById(request.getId()) + .orElseThrow(() -> new PaymentTypeNotFoundException(request.getId())); + + if (!Strings.CS.equals(request.getName(), paymentType.getName())) { + paymentType.setName(request.getName()); + } + if (!Strings.CS.equals(request.getDescription(), paymentType.getDescription())) { + paymentType.setDescription(request.getDescription()); + } + if (!Strings.CS.equals(request.getCodeName(), paymentType.getCodeName())) { + paymentType.setCodeName(request.getCodeName()); + } + if (!Objects.equals(request.getPosition(), paymentType.getPosition())) { + paymentType.setPosition(request.getPosition()); + } + if (!Objects.equals(request.getIsCashPayment(), paymentType.getIsCashPayment())) { + paymentType.setIsCashPayment(request.getIsCashPayment()); + } + if (!Objects.equals(request.getIsSystemDefined(), paymentType.getIsSystemDefined())) { + paymentType.setIsSystemDefined(request.getIsSystemDefined()); + } + + repository.saveAndFlush(paymentType); + } catch (final JpaSystemException | DataIntegrityViolationException e) { + throw new PaymentTypeNotFoundException(request.getId()); + } + + return PaymentTypeUpdateResponse.builder().resourceId(request.getId()).build(); + } + + @Override + @CacheEvict(value = "payment_types", key = "T(org.apache.fineract.infrastructure.core.service.ThreadLocalContextUtil).getTenant().getTenantIdentifier().concat('payment_types')") + public PaymentTypeDeleteResponse deletePaymentType(@Valid PaymentTypeDeleteRequest request) { + final var paymentType = repository.findById(request.getId()).orElseThrow(() -> new PaymentTypeNotFoundException(request.getId())); + + try { + repository.delete(paymentType); + repository.flush(); } catch (final JpaSystemException | DataIntegrityViolationException e) { final Throwable throwable = e.getMostSpecificCause(); handleDataIntegrityIssues(throwable, e); } - return new CommandProcessingResultBuilder().withEntityId(paymentType.getId()).build(); + + return PaymentTypeDeleteResponse.builder().resourceId(paymentType.getId()).build(); } private void handleDataIntegrityIssues(final Throwable realCause, final Exception dve) { diff --git a/fineract-core/src/main/java/org/apache/fineract/portfolio/paymenttype/starter/PaymentTypeConfiguration.java b/fineract-core/src/main/java/org/apache/fineract/portfolio/paymenttype/starter/PaymentTypeConfiguration.java index c6c8ad523..2f71ed94f 100644 --- a/fineract-core/src/main/java/org/apache/fineract/portfolio/paymenttype/starter/PaymentTypeConfiguration.java +++ b/fineract-core/src/main/java/org/apache/fineract/portfolio/paymenttype/starter/PaymentTypeConfiguration.java @@ -18,13 +18,11 @@ */ package org.apache.fineract.portfolio.paymenttype.starter; -import org.apache.fineract.infrastructure.security.service.PlatformSecurityContext; -import org.apache.fineract.portfolio.paymenttype.data.PaymentTypeDataValidator; import org.apache.fineract.portfolio.paymenttype.domain.PaymentTypeRepository; -import org.apache.fineract.portfolio.paymenttype.domain.PaymentTypeRepositoryWrapper; +import org.apache.fineract.portfolio.paymenttype.mapper.PaymentTypeCreateRequestMapper; import org.apache.fineract.portfolio.paymenttype.mapper.PaymentTypeMapper; -import org.apache.fineract.portfolio.paymenttype.service.PaymentTypeReadPlatformService; -import org.apache.fineract.portfolio.paymenttype.service.PaymentTypeReadPlatformServiceImpl; +import org.apache.fineract.portfolio.paymenttype.service.PaymentTypeReadService; +import org.apache.fineract.portfolio.paymenttype.service.PaymentTypeReadServiceImpl; import org.apache.fineract.portfolio.paymenttype.service.PaymentTypeWriteService; import org.apache.fineract.portfolio.paymenttype.service.PaymentTypeWriteServiceImpl; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; @@ -35,16 +33,14 @@ import org.springframework.context.annotation.Configuration; public class PaymentTypeConfiguration { @Bean - @ConditionalOnMissingBean(PaymentTypeReadPlatformService.class) - PaymentTypeReadPlatformService paymentTypeReadPlatformService(PlatformSecurityContext context, PaymentTypeMapper paymentTypeMapper, - PaymentTypeRepositoryWrapper paymentTypeRepositoryWrapper) { - return new PaymentTypeReadPlatformServiceImpl(context, paymentTypeMapper, paymentTypeRepositoryWrapper); + @ConditionalOnMissingBean(PaymentTypeReadService.class) + PaymentTypeReadService paymentTypeReadPlatformService(PaymentTypeRepository repository, PaymentTypeMapper mapper) { + return new PaymentTypeReadServiceImpl(repository, mapper); } @Bean @ConditionalOnMissingBean(PaymentTypeWriteService.class) - PaymentTypeWriteService paymentTypeWriteService(PaymentTypeRepository repository, PaymentTypeRepositoryWrapper repositoryWrapper, - PaymentTypeDataValidator fromApiJsonDeserializer) { - return new PaymentTypeWriteServiceImpl(repository, repositoryWrapper, fromApiJsonDeserializer); + PaymentTypeWriteService paymentTypeWriteService(PaymentTypeRepository repository, PaymentTypeCreateRequestMapper createRequestMapper) { + return new PaymentTypeWriteServiceImpl(repository, createRequestMapper); } } diff --git a/fineract-document/src/main/java/org/apache/fineract/infrastructure/documentmanagement/data/DocumentCreateRequest.java b/fineract-document/src/main/java/org/apache/fineract/infrastructure/documentmanagement/data/DocumentCreateRequest.java index 9fe12c67a..8334c6eb3 100644 --- a/fineract-document/src/main/java/org/apache/fineract/infrastructure/documentmanagement/data/DocumentCreateRequest.java +++ b/fineract-document/src/main/java/org/apache/fineract/infrastructure/documentmanagement/data/DocumentCreateRequest.java @@ -40,19 +40,19 @@ public class DocumentCreateRequest implements Serializable { @Serial private static final long serialVersionUID = 1L; - @NotNull(message = "{org.apache.fineract.document.xxx.not-null}") - @Size(max = 50, message = "{org.apache.fineract.document.xxx.not-null}") + @NotNull(message = "{org.apache.fineract.document.entity-type.not-null}") + @Size(max = 50, message = "{org.apache.fineract.document.entity-type.size}") private String entityType; - @NotNull(message = "{org.apache.fineract.document.xxx.not-null}") + @NotNull(message = "{org.apache.fineract.document.entity-id.not-null}") private Long entityId; - @Size(max = 250, message = "{org.apache.fineract.document.xxx.not-null}") + @Size(max = 250, message = "{org.apache.fineract.document.name.size}") private String name; - @Size(max = 250, message = "{org.apache.fineract.document.xxx.not-null}") + @Size(max = 250, message = "{org.apache.fineract.document.description.size}") private String description; - @Size(max = 250, message = "{org.apache.fineract.document.xxx.not-null}") + @Size(max = 250, message = "{org.apache.fineract.document.file-name.size}") private String fileName; - @NotNull(message = "{org.apache.fineract.document.xxx.not-null}") - @Min(value = 1, message = "{org.apache.fineract.document.xxx.not-null}") + @NotNull(message = "{org.apache.fineract.document.size.not-null}") + @Min(value = 1, message = "{org.apache.fineract.document.size.min}") private Long size; private String type; @Hidden diff --git a/fineract-document/src/main/java/org/apache/fineract/infrastructure/documentmanagement/data/DocumentUpdateRequest.java b/fineract-document/src/main/java/org/apache/fineract/infrastructure/documentmanagement/data/DocumentUpdateRequest.java index 2d9a17f49..260480a1b 100644 --- a/fineract-document/src/main/java/org/apache/fineract/infrastructure/documentmanagement/data/DocumentUpdateRequest.java +++ b/fineract-document/src/main/java/org/apache/fineract/infrastructure/documentmanagement/data/DocumentUpdateRequest.java @@ -40,21 +40,21 @@ public class DocumentUpdateRequest implements Serializable { @Serial private static final long serialVersionUID = 1L; - @NotNull(message = "{org.apache.fineract.document.xxx.not-null}") + @NotNull(message = "{org.apache.fineract.document.id.not-null}") private Long id; - @NotNull(message = "{org.apache.fineract.document.xxx.not-null}") - @Size(max = 50, message = "{org.apache.fineract.document.xxx.not-null}") + @NotNull(message = "{org.apache.fineract.document.entity-type.not-null}") + @Size(max = 50, message = "{org.apache.fineract.document.entity-type.size}") private String entityType; - @NotNull(message = "{org.apache.fineract.document.xxx.not-null}") + @NotNull(message = "{org.apache.fineract.document.entity-id.not-null}") private Long entityId; - @Size(max = 250, message = "{org.apache.fineract.document.xxx.not-null}") + @Size(max = 250, message = "{org.apache.fineract.document.name.size}") private String name; - @Size(max = 250, message = "{org.apache.fineract.document.xxx.not-null}") + @Size(max = 250, message = "{org.apache.fineract.document.description.size}") private String description; - @Size(max = 250, message = "{org.apache.fineract.document.xxx.not-null}") + @Size(max = 250, message = "{org.apache.fineract.document.file-name.size}") private String fileName; - @NotNull(message = "{org.apache.fineract.document.xxx.not-null}") - @Min(value = 1, message = "{org.apache.fineract.document.xxx.not-null}") + @NotNull(message = "{org.apache.fineract.document.size.not-null}") + @Min(value = 1, message = "{org.apache.fineract.document.size.min}") private Long size; private String type; @Hidden diff --git a/fineract-e2e-tests-runner/src/test/java/org/apache/fineract/test/initializer/global/PaymentTypeGlobalInitializerStep.java b/fineract-e2e-tests-runner/src/test/java/org/apache/fineract/test/initializer/global/PaymentTypeGlobalInitializerStep.java index 7428f29d9..3946d3834 100644 --- a/fineract-e2e-tests-runner/src/test/java/org/apache/fineract/test/initializer/global/PaymentTypeGlobalInitializerStep.java +++ b/fineract-e2e-tests-runner/src/test/java/org/apache/fineract/test/initializer/global/PaymentTypeGlobalInitializerStep.java @@ -26,9 +26,8 @@ import java.util.Map; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.apache.fineract.client.feign.FineractFeignClient; +import org.apache.fineract.client.models.PaymentTypeCreateRequest; import org.apache.fineract.client.models.PaymentTypeData; -import org.apache.fineract.client.models.PaymentTypeRequest; -import org.apache.fineract.test.factory.PaymentTypesRequestFactory; import org.springframework.core.Ordered; import org.springframework.core.annotation.Order; import org.springframework.stereotype.Component; @@ -72,14 +71,15 @@ public class PaymentTypeGlobalInitializerStep implements FineractGlobalInitializ paymentTypeNames.add(PAYMENT_TYPE_REPAYMENT_ADJUSTMENT_REFUND); paymentTypeNames.forEach(paymentTypeName -> { - boolean paymentTypeExists = paymentTypes.stream().anyMatch(pt -> paymentTypeName.equals(pt.getName())); + var paymentTypeExists = paymentTypes.stream().anyMatch(pt -> paymentTypeName.equals(pt.getName())); + if (paymentTypeExists) { return; } - Integer position = paymentTypeNames.indexOf(paymentTypeName) + 2; - PaymentTypeRequest postPaymentTypesRequest = PaymentTypesRequestFactory.defaultPaymentTypeRequest(paymentTypeName, - paymentTypeName, false, position); + var position = Integer.valueOf(paymentTypeNames.indexOf(paymentTypeName) + 2).longValue(); + var postPaymentTypesRequest = new PaymentTypeCreateRequest().name(paymentTypeName).description(paymentTypeName) + .isCashPayment(false).position(position); executeVoid(() -> fineractClient.paymentType().createPaymentType(postPaymentTypesRequest, Map.of())); }); diff --git a/fineract-loan/src/test/java/org/apache/fineract/portfolio/loanaccount/mapper/LoanTransactionMapperTest.java b/fineract-loan/src/test/java/org/apache/fineract/portfolio/loanaccount/mapper/LoanTransactionMapperTest.java index 643fbb8ad..31e11e58a 100644 --- a/fineract-loan/src/test/java/org/apache/fineract/portfolio/loanaccount/mapper/LoanTransactionMapperTest.java +++ b/fineract-loan/src/test/java/org/apache/fineract/portfolio/loanaccount/mapper/LoanTransactionMapperTest.java @@ -96,8 +96,8 @@ public class LoanTransactionMapperTest { when(loanTransaction.getLoan().getNetDisbursalAmount()).thenReturn(BigDecimal.valueOf(2000)); // Setup payment detail mocks - when(paymentDetail.toData()).thenReturn(new PaymentDetailData(1L, PaymentTypeData.instance(1L, "Cash"), "accountNumber", - "checkNumber", "routingCode", "receiptNumber", "bankNumber")); + when(paymentDetail.toData()).thenReturn(new PaymentDetailData(1L, PaymentTypeData.builder().id(1L).name("Cash").build(), + "accountNumber", "checkNumber", "routingCode", "receiptNumber", "bankNumber")); // When LoanTransactionData result = mapper.mapLoanTransaction(loanTransaction); diff --git a/fineract-provider/src/main/java/org/apache/fineract/accounting/journalentry/api/JournalEntriesApiResourceSwagger.java b/fineract-provider/src/main/java/org/apache/fineract/accounting/journalentry/api/JournalEntriesApiResourceSwagger.java index 2e15e99b2..d31c1dafe 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/accounting/journalentry/api/JournalEntriesApiResourceSwagger.java +++ b/fineract-provider/src/main/java/org/apache/fineract/accounting/journalentry/api/JournalEntriesApiResourceSwagger.java @@ -23,7 +23,7 @@ import java.math.BigDecimal; import java.time.LocalDate; import java.util.List; import org.apache.fineract.portfolio.note.data.NoteData; -import org.apache.fineract.portfolio.paymenttype.api.PaymentTypeApiResourceSwagger.GetPaymentTypesResponse; +import org.apache.fineract.portfolio.paymenttype.data.PaymentTypeData; /** * Created by sanyam on 25/7/17. @@ -110,7 +110,7 @@ final class JournalEntriesApiResourceSwagger { @Schema(example = "62") public Long id; - public GetPaymentTypesResponse paymentType; + public PaymentTypeData paymentType; @Schema(example = "acc123") public String accountNumber; @Schema(example = "che123") diff --git a/fineract-provider/src/main/java/org/apache/fineract/accounting/journalentry/service/JournalEntryReadPlatformServiceImpl.java b/fineract-provider/src/main/java/org/apache/fineract/accounting/journalentry/service/JournalEntryReadPlatformServiceImpl.java index 0fde381cf..66e91b033 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/accounting/journalentry/service/JournalEntryReadPlatformServiceImpl.java +++ b/fineract-provider/src/main/java/org/apache/fineract/accounting/journalentry/service/JournalEntryReadPlatformServiceImpl.java @@ -187,7 +187,7 @@ public class JournalEntryReadPlatformServiceImpl implements JournalEntryReadPlat final Long paymentTypeId = JdbcSupport.getLong(rs, "paymentTypeId"); if (paymentTypeId != null) { final String typeName = rs.getString("paymentTypeName"); - final PaymentTypeData paymentType = PaymentTypeData.instance(paymentTypeId, typeName); + final PaymentTypeData paymentType = PaymentTypeData.builder().id(paymentTypeId).name(typeName).build(); final String accountNumber = rs.getString("accountNumber"); final String checkNumber = rs.getString("checkNumber"); final String routingCode = rs.getString("routingCode"); diff --git a/fineract-provider/src/main/java/org/apache/fineract/infrastructure/bulkimport/service/BulkImportWorkbookPopulatorServiceImpl.java b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/bulkimport/service/BulkImportWorkbookPopulatorServiceImpl.java index a821798ca..b4e935c39 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/infrastructure/bulkimport/service/BulkImportWorkbookPopulatorServiceImpl.java +++ b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/bulkimport/service/BulkImportWorkbookPopulatorServiceImpl.java @@ -91,7 +91,7 @@ import org.apache.fineract.portfolio.loanaccount.service.LoanReadPlatformService import org.apache.fineract.portfolio.loanproduct.data.LoanProductData; import org.apache.fineract.portfolio.loanproduct.service.LoanProductReadPlatformService; import org.apache.fineract.portfolio.paymenttype.data.PaymentTypeData; -import org.apache.fineract.portfolio.paymenttype.service.PaymentTypeReadPlatformService; +import org.apache.fineract.portfolio.paymenttype.service.PaymentTypeReadService; import org.apache.fineract.portfolio.products.data.ProductData; import org.apache.fineract.portfolio.products.service.ShareProductReadPlatformService; import org.apache.fineract.portfolio.savings.DepositAccountType; @@ -124,7 +124,7 @@ public class BulkImportWorkbookPopulatorServiceImpl implements BulkImportWorkboo private final CenterReadPlatformService centerReadPlatformService; private final GroupReadPlatformService groupReadPlatformService; private final FundReadPlatformService fundReadPlatformService; - private final PaymentTypeReadPlatformService paymentTypeReadPlatformService; + private final PaymentTypeReadService paymentTypeReadPlatformService; private final LoanProductReadPlatformService loanProductReadPlatformService; private final CurrencyReadPlatformService currencyReadPlatformService; private final LoanReadPlatformService loanReadPlatformService; @@ -142,7 +142,7 @@ public class BulkImportWorkbookPopulatorServiceImpl implements BulkImportWorkboo final OfficeReadPlatformService officeReadPlatformService, final StaffReadPlatformService staffReadPlatformService, final ClientReadPlatformService clientReadPlatformService, final CenterReadPlatformService centerReadPlatformService, final GroupReadPlatformService groupReadPlatformService, final FundReadPlatformService fundReadPlatformService, - final PaymentTypeReadPlatformService paymentTypeReadPlatformService, + final PaymentTypeReadService paymentTypeReadPlatformService, final LoanProductReadPlatformService loanProductReadPlatformService, final CurrencyReadPlatformService currencyReadPlatformService, final LoanReadPlatformService loanReadPlatformService, final GLAccountReadPlatformService glAccountReadPlatformService, 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 2577f396d..ca17edbd7 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 @@ -290,6 +290,13 @@ public class SecurityConfig { .hasAnyAuthority(ALL_FUNCTIONS, ALL_FUNCTIONS_READ, "READ_IMPORT") .requestMatchers(API_MATCHER.matcher(HttpMethod.GET, "/api/*/import/*")) .hasAnyAuthority(ALL_FUNCTIONS, ALL_FUNCTIONS_READ, "READ_IMPORT") + // payment type + .requestMatchers(API_MATCHER.matcher(HttpMethod.GET, "/api/*/paymenttypes/*")) + .hasAnyAuthority(ALL_FUNCTIONS, ALL_FUNCTIONS_READ, "READ_PAYMENTTYPE") + .requestMatchers(API_MATCHER.matcher(HttpMethod.POST, "/api/*/paymenttypes")) + .hasAnyAuthority(ALL_FUNCTIONS, ALL_FUNCTIONS_WRITE, "UPDATE_PAYMENTTYPE") + .requestMatchers(API_MATCHER.matcher(HttpMethod.POST, "/api/*/paymenttypes")) + .hasAnyAuthority(ALL_FUNCTIONS, ALL_FUNCTIONS_WRITE, "DELETE_PAYMENTTYPE") .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/charge/service/ChargeReadPlatformServiceImpl.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/charge/service/ChargeReadPlatformServiceImpl.java index 7e5f7b874..98562a56d 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/charge/service/ChargeReadPlatformServiceImpl.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/charge/service/ChargeReadPlatformServiceImpl.java @@ -371,7 +371,7 @@ public class ChargeReadPlatformServiceImpl implements ChargeReadPlatformService final String paymentTypeName = rs.getString("paymentTypeName"); PaymentTypeData paymentTypeData = null; if (paymentTypeId != null) { - paymentTypeData = PaymentTypeData.instance(paymentTypeId, paymentTypeName); + paymentTypeData = PaymentTypeData.builder().id(paymentTypeId).name(paymentTypeName).build(); } return ChargeData.builder().id(id).name(name).amount(amount).currency(currency).chargeTimeType(chargeTimeType) diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/client/service/ClientTransactionReadPlatformServiceImpl.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/client/service/ClientTransactionReadPlatformServiceImpl.java index ec42c7630..377ffdecc 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/client/service/ClientTransactionReadPlatformServiceImpl.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/client/service/ClientTransactionReadPlatformServiceImpl.java @@ -107,7 +107,7 @@ public class ClientTransactionReadPlatformServiceImpl implements ClientTransacti final Long paymentTypeId = JdbcSupport.getLong(rs, "paymentType"); if (paymentTypeId != null) { final String typeName = rs.getString("paymentTypeName"); - final PaymentTypeData paymentType = PaymentTypeData.instance(paymentTypeId, typeName); + final PaymentTypeData paymentType = PaymentTypeData.builder().id(paymentTypeId).name(typeName).build(); final String accountNumber = rs.getString("accountNumber"); final String checkNumber = rs.getString("checkNumber"); final String routingCode = rs.getString("routingCode"); diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/collectionsheet/service/CollectionSheetReadPlatformServiceImpl.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/collectionsheet/service/CollectionSheetReadPlatformServiceImpl.java index 7e6d16fb8..c1e020c5d 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/collectionsheet/service/CollectionSheetReadPlatformServiceImpl.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/collectionsheet/service/CollectionSheetReadPlatformServiceImpl.java @@ -65,7 +65,7 @@ import org.apache.fineract.portfolio.loanproduct.data.LoanProductData; import org.apache.fineract.portfolio.meeting.attendance.service.AttendanceDropdownReadPlatformService; import org.apache.fineract.portfolio.meeting.attendance.service.AttendanceEnumerations; import org.apache.fineract.portfolio.paymenttype.data.PaymentTypeData; -import org.apache.fineract.portfolio.paymenttype.service.PaymentTypeReadPlatformService; +import org.apache.fineract.portfolio.paymenttype.service.PaymentTypeReadService; import org.apache.fineract.portfolio.savings.data.SavingsProductData; import org.apache.fineract.useradministration.domain.AppUser; import org.springframework.dao.DataAccessException; @@ -86,7 +86,7 @@ public class CollectionSheetReadPlatformServiceImpl implements CollectionSheetRe private final AttendanceDropdownReadPlatformService attendanceDropdownReadPlatformService; private final MandatorySavingsCollectionsheetExtractor mandatorySavingsExtractor; private final CodeValueReadPlatformService codeValueReadPlatformService; - private final PaymentTypeReadPlatformService paymentTypeReadPlatformService; + private final PaymentTypeReadService paymentTypeReadPlatformService; private final CalendarReadPlatformService calendarReadPlatformService; private final ConfigurationDomainService configurationDomainService; private final CalendarInstanceRepository calendarInstanceRepository; @@ -98,8 +98,7 @@ public class CollectionSheetReadPlatformServiceImpl implements CollectionSheetRe final CollectionSheetGenerateCommandFromApiJsonDeserializer collectionSheetGenerateCommandFromApiJsonDeserializer, final CalendarRepositoryWrapper calendarRepositoryWrapper, final AttendanceDropdownReadPlatformService attendanceDropdownReadPlatformService, - final CodeValueReadPlatformService codeValueReadPlatformService, - final PaymentTypeReadPlatformService paymentTypeReadPlatformService, + final CodeValueReadPlatformService codeValueReadPlatformService, final PaymentTypeReadService paymentTypeReadPlatformService, final CalendarReadPlatformService calendarReadPlatformService, final ConfigurationDomainService configurationDomainService, final CalendarInstanceRepository calendarInstanceRepository, DatabaseSpecificSQLGenerator sqlGenerator) { this.context = context; diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/collectionsheet/starter/CollectionSheetConfiguration.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/collectionsheet/starter/CollectionSheetConfiguration.java index d684f330c..025f4ae6e 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/collectionsheet/starter/CollectionSheetConfiguration.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/collectionsheet/starter/CollectionSheetConfiguration.java @@ -40,7 +40,7 @@ import org.apache.fineract.portfolio.meeting.attendance.service.AttendanceDropdo import org.apache.fineract.portfolio.meeting.service.MeetingWritePlatformService; import org.apache.fineract.portfolio.paymentdetail.domain.PaymentDetailAssembler; import org.apache.fineract.portfolio.paymentdetail.service.PaymentDetailWritePlatformService; -import org.apache.fineract.portfolio.paymenttype.service.PaymentTypeReadPlatformService; +import org.apache.fineract.portfolio.paymenttype.service.PaymentTypeReadService; import org.apache.fineract.portfolio.savings.domain.DepositAccountAssembler; import org.apache.fineract.portfolio.savings.service.DepositAccountWritePlatformService; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; @@ -59,7 +59,7 @@ public class CollectionSheetConfiguration { CollectionSheetGenerateCommandFromApiJsonDeserializer collectionSheetGenerateCommandFromApiJsonDeserializer, CalendarRepositoryWrapper calendarRepositoryWrapper, AttendanceDropdownReadPlatformService attendanceDropdownReadPlatformService, - CodeValueReadPlatformService codeValueReadPlatformService, PaymentTypeReadPlatformService paymentTypeReadPlatformService, + CodeValueReadPlatformService codeValueReadPlatformService, PaymentTypeReadService paymentTypeReadPlatformService, CalendarReadPlatformService calendarReadPlatformService, ConfigurationDomainService configurationDomainService, CalendarInstanceRepository calendarInstanceRepository, DatabaseSpecificSQLGenerator sqlGenerator) { return new CollectionSheetReadPlatformServiceImpl(context, namedParameterJdbcTemplate, centerReadPlatformService, diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/api/LoanTransactionsApiResource.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/api/LoanTransactionsApiResource.java index 30e266efc..112c18b6b 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/api/LoanTransactionsApiResource.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/api/LoanTransactionsApiResource.java @@ -79,7 +79,7 @@ import org.apache.fineract.portfolio.loanaccount.service.LoanReadPlatformService import org.apache.fineract.portfolio.loanaccount.service.reaging.LoanReAgingService; import org.apache.fineract.portfolio.loanaccount.service.reamortization.LoanReAmortizationService; import org.apache.fineract.portfolio.paymenttype.data.PaymentTypeData; -import org.apache.fineract.portfolio.paymenttype.service.PaymentTypeReadPlatformService; +import org.apache.fineract.portfolio.paymenttype.service.PaymentTypeReadService; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.stereotype.Component; @@ -110,7 +110,7 @@ public class LoanTransactionsApiResource { private final ApiRequestParameterHelper apiRequestParameterHelper; private final DefaultToApiJsonSerializer toApiJsonSerializer; private final PortfolioCommandSourceWritePlatformService commandsSourceWritePlatformService; - private final PaymentTypeReadPlatformService paymentTypeReadPlatformService; + private final PaymentTypeReadService paymentTypeReadPlatformService; private final LoanChargePaidByReadService loanChargePaidByReadService; private final LoanReAgingService loanReAgingService; private final LoanReAmortizationService loanReAmortizationService; diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanReadPlatformServiceImpl.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanReadPlatformServiceImpl.java index 7da1e2df9..e0b1b7b12 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanReadPlatformServiceImpl.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanReadPlatformServiceImpl.java @@ -149,7 +149,7 @@ import org.apache.fineract.portfolio.loanproduct.service.LoanEnumerations; import org.apache.fineract.portfolio.loanproduct.service.LoanProductReadPlatformService; import org.apache.fineract.portfolio.paymentdetail.data.PaymentDetailData; import org.apache.fineract.portfolio.paymenttype.data.PaymentTypeData; -import org.apache.fineract.portfolio.paymenttype.service.PaymentTypeReadPlatformService; +import org.apache.fineract.portfolio.paymenttype.service.PaymentTypeReadService; import org.apache.fineract.useradministration.domain.AppUser; import org.springframework.dao.DataAccessException; import org.springframework.dao.EmptyResultDataAccessException; @@ -177,7 +177,7 @@ public class LoanReadPlatformServiceImpl implements LoanReadPlatformService, Loa private final CalendarReadPlatformService calendarReadPlatformService; private final StaffReadPlatformService staffReadPlatformService; private final PaginationHelper paginationHelper; - private final PaymentTypeReadPlatformService paymentTypeReadPlatformService; + private final PaymentTypeReadService paymentTypeReadPlatformService; private final FloatingRatesReadPlatformService floatingRatesReadPlatformService; private final LoanUtilService loanUtilService; private final ConfigurationDomainService configurationDomainService; @@ -1395,7 +1395,7 @@ public class LoanReadPlatformServiceImpl implements LoanReadPlatformService, Loa final Long paymentTypeId = JdbcSupport.getLong(rs, "paymentType"); if (paymentTypeId != null) { final String typeName = rs.getString("paymentTypeName"); - final PaymentTypeData paymentType = PaymentTypeData.instance(paymentTypeId, typeName); + final PaymentTypeData paymentType = PaymentTypeData.builder().id(paymentTypeId).name(typeName).build(); final String accountNumber = rs.getString("accountNumber"); final String checkNumber = rs.getString("checkNumber"); final String routingCode = rs.getString("routingCode"); diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/starter/LoanAccountConfiguration.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/starter/LoanAccountConfiguration.java index 3db392034..d2c1ff73e 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/starter/LoanAccountConfiguration.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/starter/LoanAccountConfiguration.java @@ -176,7 +176,7 @@ import org.apache.fineract.portfolio.loanproduct.service.LoanDropdownReadPlatfor import org.apache.fineract.portfolio.loanproduct.service.LoanProductReadPlatformService; import org.apache.fineract.portfolio.note.domain.NoteRepository; import org.apache.fineract.portfolio.paymentdetail.service.PaymentDetailWritePlatformService; -import org.apache.fineract.portfolio.paymenttype.service.PaymentTypeReadPlatformService; +import org.apache.fineract.portfolio.paymenttype.service.PaymentTypeReadService; import org.apache.fineract.portfolio.rate.service.RateAssembler; import org.apache.fineract.portfolio.repaymentwithpostdatedchecks.domain.PostDatedChecksRepository; import org.apache.fineract.portfolio.repaymentwithpostdatedchecks.service.RepaymentWithPostDatedChecksAssembler; @@ -342,15 +342,14 @@ public class LoanAccountConfiguration { FundReadPlatformService fundReadPlatformService, ChargeReadPlatformService chargeReadPlatformService, CodeValueReadPlatformService codeValueReadPlatformService, CalendarReadPlatformService calendarReadPlatformService, StaffReadPlatformService staffReadPlatformService, PaginationHelper paginationHelper, - PaymentTypeReadPlatformService paymentTypeReadPlatformService, - FloatingRatesReadPlatformService floatingRatesReadPlatformService, LoanUtilService loanUtilService, - ConfigurationDomainService configurationDomainService, AccountDetailsReadPlatformService accountDetailsReadPlatformService, - ColumnValidator columnValidator, DatabaseSpecificSQLGenerator sqlGenerator, - DelinquencyReadPlatformService delinquencyReadPlatformService, LoanTransactionRepository loanTransactionRepository, - LoanChargePaidByReadService loanChargePaidByReadService, LoanTransactionRelationReadService loanTransactionRelationReadService, - LoanForeclosureValidator loanForeclosureValidator, LoanTransactionMapper loanTransactionMapper, - LoanTransactionProcessingService loanTransactionProcessingService, LoanBalanceService loanBalanceService, - LoanCapitalizedIncomeBalanceRepository loanCapitalizedIncomeBalanceRepository, + PaymentTypeReadService paymentTypeReadPlatformService, FloatingRatesReadPlatformService floatingRatesReadPlatformService, + LoanUtilService loanUtilService, ConfigurationDomainService configurationDomainService, + AccountDetailsReadPlatformService accountDetailsReadPlatformService, ColumnValidator columnValidator, + DatabaseSpecificSQLGenerator sqlGenerator, DelinquencyReadPlatformService delinquencyReadPlatformService, + LoanTransactionRepository loanTransactionRepository, LoanChargePaidByReadService loanChargePaidByReadService, + LoanTransactionRelationReadService loanTransactionRelationReadService, LoanForeclosureValidator loanForeclosureValidator, + LoanTransactionMapper loanTransactionMapper, LoanTransactionProcessingService loanTransactionProcessingService, + LoanBalanceService loanBalanceService, LoanCapitalizedIncomeBalanceRepository loanCapitalizedIncomeBalanceRepository, LoanBuyDownFeeBalanceRepository loanBuyDownFeeBalanceRepository, @Lazy InterestRefundServiceDelegate interestRefundServiceDelegate, LoanMaximumAmountCalculator loanMaximumAmountCalculator, LoanRepaymentScheduleService loanRepaymentScheduleService) { diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanproduct/api/LoanProductsApiResource.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanproduct/api/LoanProductsApiResource.java index 15d8cfb4c..bd3f87c43 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanproduct/api/LoanProductsApiResource.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanproduct/api/LoanProductsApiResource.java @@ -109,7 +109,7 @@ import org.apache.fineract.portfolio.loanproduct.productmix.service.ProductMixRe import org.apache.fineract.portfolio.loanproduct.service.LoanDropdownReadPlatformService; import org.apache.fineract.portfolio.loanproduct.service.LoanProductReadPlatformService; import org.apache.fineract.portfolio.paymenttype.data.PaymentTypeData; -import org.apache.fineract.portfolio.paymenttype.service.PaymentTypeReadPlatformService; +import org.apache.fineract.portfolio.paymenttype.service.PaymentTypeReadService; import org.apache.fineract.portfolio.rate.data.RateData; import org.apache.fineract.portfolio.rate.service.RateReadService; import org.springframework.stereotype.Component; @@ -165,7 +165,7 @@ public class LoanProductsApiResource { private final DefaultToApiJsonSerializer productMixDataApiJsonSerializer; private final ProductMixReadPlatformService productMixReadPlatformService; private final DropdownReadPlatformService commonDropdownReadPlatformService; - private final PaymentTypeReadPlatformService paymentTypeReadPlatformService; + private final PaymentTypeReadService paymentTypeReadPlatformService; private final FloatingRatesReadPlatformService floatingRateReadPlatformService; private final RateReadService rateReadService; private final ConfigurationDomainService configurationDomainService; diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/api/FixedDepositAccountTransactionsApiResource.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/api/FixedDepositAccountTransactionsApiResource.java index 406cec9a1..ef1e43358 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/api/FixedDepositAccountTransactionsApiResource.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/api/FixedDepositAccountTransactionsApiResource.java @@ -45,7 +45,7 @@ import org.apache.fineract.infrastructure.core.serialization.ApiRequestJsonSeria import org.apache.fineract.infrastructure.core.serialization.DefaultToApiJsonSerializer; import org.apache.fineract.infrastructure.security.service.PlatformSecurityContext; import org.apache.fineract.portfolio.paymenttype.data.PaymentTypeData; -import org.apache.fineract.portfolio.paymenttype.service.PaymentTypeReadPlatformService; +import org.apache.fineract.portfolio.paymenttype.service.PaymentTypeReadService; import org.apache.fineract.portfolio.savings.DepositAccountType; import org.apache.fineract.portfolio.savings.DepositsApiConstants; import org.apache.fineract.portfolio.savings.data.SavingsAccountTransactionData; @@ -63,7 +63,7 @@ public class FixedDepositAccountTransactionsApiResource { private final PortfolioCommandSourceWritePlatformService commandsSourceWritePlatformService; private final ApiRequestParameterHelper apiRequestParameterHelper; private final SavingsAccountReadPlatformService savingsAccountReadPlatformService; - private final PaymentTypeReadPlatformService paymentTypeReadPlatformService; + private final PaymentTypeReadService paymentTypeReadPlatformService; private static final Set FIXED_DEPOSIT_TRANSACTION_RESPONSE_DATA_PARAMETERS = new HashSet<>( Arrays.asList(DepositsApiConstants.idParamName, DepositsApiConstants.accountIdParamName, DepositsApiConstants.accountNoParamName, DepositsApiConstants.currencyParamName, DepositsApiConstants.amountParamName, 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 4086254f5..4cc92f669 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 @@ -66,7 +66,7 @@ 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.paymenttype.data.PaymentTypeData; -import org.apache.fineract.portfolio.paymenttype.service.PaymentTypeReadPlatformService; +import org.apache.fineract.portfolio.paymenttype.service.PaymentTypeReadService; import org.apache.fineract.portfolio.savings.DepositAccountType; import org.apache.fineract.portfolio.savings.DepositsApiConstants; import org.apache.fineract.portfolio.savings.SavingsCompoundingInterestPeriodType; @@ -108,7 +108,7 @@ public class FixedDepositProductsApiResource { private final InterestRateChartReadPlatformService interestRateChartReadPlatformService; private final DepositsDropdownReadPlatformService depositsDropdownReadPlatformService; private final DropdownReadPlatformService dropdownReadPlatformService; - private final PaymentTypeReadPlatformService paymentTypeReadPlatformService; + private final PaymentTypeReadService paymentTypeReadPlatformService; private final TaxReadPlatformService taxReadPlatformService; @POST diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/api/RecurringDepositAccountTransactionsApiResource.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/api/RecurringDepositAccountTransactionsApiResource.java index 48c67f03b..fa071e90b 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/api/RecurringDepositAccountTransactionsApiResource.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/api/RecurringDepositAccountTransactionsApiResource.java @@ -52,7 +52,7 @@ import org.apache.fineract.infrastructure.core.serialization.ApiRequestJsonSeria import org.apache.fineract.infrastructure.core.serialization.DefaultToApiJsonSerializer; import org.apache.fineract.infrastructure.security.service.PlatformSecurityContext; import org.apache.fineract.portfolio.paymenttype.data.PaymentTypeData; -import org.apache.fineract.portfolio.paymenttype.service.PaymentTypeReadPlatformService; +import org.apache.fineract.portfolio.paymenttype.service.PaymentTypeReadService; import org.apache.fineract.portfolio.savings.DepositAccountType; import org.apache.fineract.portfolio.savings.DepositsApiConstants; import org.apache.fineract.portfolio.savings.data.SavingsAccountTransactionData; @@ -72,7 +72,7 @@ public class RecurringDepositAccountTransactionsApiResource { private final ApiRequestParameterHelper apiRequestParameterHelper; private final SavingsAccountReadPlatformService savingsAccountReadPlatformService; private final DepositAccountReadPlatformService depositAccountReadPlatformService; - private final PaymentTypeReadPlatformService paymentTypeReadPlatformService; + private final PaymentTypeReadService paymentTypeReadPlatformService; private static final Set FIXED_DEPOSIT_TRANSACTION_RESPONSE_DATA_PARAMETERS = new HashSet<>( Arrays.asList(DepositsApiConstants.idParamName, DepositsApiConstants.accountIdParamName, DepositsApiConstants.accountNoParamName, DepositsApiConstants.currencyParamName, DepositsApiConstants.amountParamName, 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 df941b6e5..9b9e23f7b 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 @@ -67,7 +67,7 @@ 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.paymenttype.data.PaymentTypeData; -import org.apache.fineract.portfolio.paymenttype.service.PaymentTypeReadPlatformService; +import org.apache.fineract.portfolio.paymenttype.service.PaymentTypeReadService; import org.apache.fineract.portfolio.savings.DepositAccountType; import org.apache.fineract.portfolio.savings.DepositsApiConstants; import org.apache.fineract.portfolio.savings.SavingsCompoundingInterestPeriodType; @@ -108,7 +108,7 @@ public class RecurringDepositProductsApiResource { private final InterestRateChartReadPlatformService interestRateChartReadPlatformService; private final DepositsDropdownReadPlatformService depositsDropdownReadPlatformService; private final DropdownReadPlatformService dropdownReadPlatformService; - private final PaymentTypeReadPlatformService paymentTypeReadPlatformService; + private final PaymentTypeReadService paymentTypeReadPlatformService; private final TaxReadPlatformService taxReadPlatformService; @POST diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/api/SavingsAccountTransactionsApiResource.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/api/SavingsAccountTransactionsApiResource.java index 98e7c094c..b2aff4081 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/api/SavingsAccountTransactionsApiResource.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/api/SavingsAccountTransactionsApiResource.java @@ -55,7 +55,7 @@ import org.apache.fineract.infrastructure.core.serialization.JsonParserHelper; import org.apache.fineract.infrastructure.core.service.PagedLocalRequest; import org.apache.fineract.infrastructure.security.service.PlatformSecurityContext; import org.apache.fineract.portfolio.paymenttype.data.PaymentTypeData; -import org.apache.fineract.portfolio.paymenttype.service.PaymentTypeReadPlatformService; +import org.apache.fineract.portfolio.paymenttype.service.PaymentTypeReadService; import org.apache.fineract.portfolio.savings.DepositAccountType; import org.apache.fineract.portfolio.savings.SavingsApiConstants; import org.apache.fineract.portfolio.savings.data.SavingsAccountTransactionData; @@ -78,7 +78,7 @@ public class SavingsAccountTransactionsApiResource { private final PortfolioCommandSourceWritePlatformService commandsSourceWritePlatformService; private final ApiRequestParameterHelper apiRequestParameterHelper; private final SavingsAccountReadPlatformService savingsAccountReadPlatformService; - private final PaymentTypeReadPlatformService paymentTypeReadPlatformService; + private final PaymentTypeReadService paymentTypeReadPlatformService; private final SavingsAccountTransactionSearchService transactionsSearchService; private boolean is(final String commandParam, final String commandValue) { diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/api/SavingsProductsApiResource.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/api/SavingsProductsApiResource.java index a800cf830..63800300f 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/api/SavingsProductsApiResource.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/api/SavingsProductsApiResource.java @@ -64,7 +64,7 @@ import org.apache.fineract.organisation.monetary.service.CurrencyReadPlatformSer import org.apache.fineract.portfolio.charge.data.ChargeData; import org.apache.fineract.portfolio.charge.service.ChargeReadPlatformService; import org.apache.fineract.portfolio.paymenttype.data.PaymentTypeData; -import org.apache.fineract.portfolio.paymenttype.service.PaymentTypeReadPlatformService; +import org.apache.fineract.portfolio.paymenttype.service.PaymentTypeReadService; import org.apache.fineract.portfolio.savings.SavingsApiConstants; import org.apache.fineract.portfolio.savings.SavingsCompoundingInterestPeriodType; import org.apache.fineract.portfolio.savings.SavingsInterestCalculationDaysInYearType; @@ -96,7 +96,7 @@ public class SavingsProductsApiResource { private final AccountingDropdownReadPlatformService accountingDropdownReadPlatformService; private final ProductToGLAccountMappingReadPlatformService accountMappingReadPlatformService; private final ChargeReadPlatformService chargeReadPlatformService; - private final PaymentTypeReadPlatformService paymentTypeReadPlatformService; + private final PaymentTypeReadService paymentTypeReadPlatformService; private final TaxReadPlatformService taxReadPlatformService; private final ConfigurationDomainService configurationDomainService; diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/service/DepositAccountPreMatureCalculationPlatformServiceImpl.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/service/DepositAccountPreMatureCalculationPlatformServiceImpl.java index e915c1b73..eacefbdec 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/service/DepositAccountPreMatureCalculationPlatformServiceImpl.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/service/DepositAccountPreMatureCalculationPlatformServiceImpl.java @@ -29,7 +29,7 @@ import org.apache.fineract.infrastructure.core.api.JsonQuery; import org.apache.fineract.infrastructure.core.data.EnumOptionData; import org.apache.fineract.infrastructure.core.serialization.FromJsonHelper; import org.apache.fineract.portfolio.paymenttype.data.PaymentTypeData; -import org.apache.fineract.portfolio.paymenttype.service.PaymentTypeReadPlatformService; +import org.apache.fineract.portfolio.paymenttype.service.PaymentTypeReadService; import org.apache.fineract.portfolio.savings.DepositAccountOnClosureType; import org.apache.fineract.portfolio.savings.DepositAccountType; import org.apache.fineract.portfolio.savings.data.DepositAccountData; @@ -51,7 +51,7 @@ public class DepositAccountPreMatureCalculationPlatformServiceImpl implements De private final DepositAccountAssembler depositAccountAssembler; private final SavingsAccountReadPlatformService savingsAccountReadPlatformService; private final ConfigurationDomainService configurationDomainService; - private final PaymentTypeReadPlatformService paymentTypeReadPlatformService; + private final PaymentTypeReadService paymentTypeReadPlatformService; @Transactional @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 618f77f25..4ea183134 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 @@ -68,7 +68,7 @@ import org.apache.fineract.portfolio.interestratechart.data.InterestRateChartDat import org.apache.fineract.portfolio.interestratechart.service.InterestRateChartReadPlatformService; import org.apache.fineract.portfolio.paymentdetail.data.PaymentDetailData; import org.apache.fineract.portfolio.paymenttype.data.PaymentTypeData; -import org.apache.fineract.portfolio.paymenttype.service.PaymentTypeReadPlatformService; +import org.apache.fineract.portfolio.paymenttype.service.PaymentTypeReadService; import org.apache.fineract.portfolio.savings.DepositAccountOnClosureType; import org.apache.fineract.portfolio.savings.DepositAccountType; import org.apache.fineract.portfolio.savings.SavingsAccountTransactionType; @@ -127,7 +127,7 @@ public class DepositAccountReadPlatformServiceImpl implements DepositAccountRead private final RecurringAccountDepositTransactionTemplateMapper rdTransactionTemplateMapper = new RecurringAccountDepositTransactionTemplateMapper(); private final DropdownReadPlatformService dropdownReadPlatformService; private final CalendarReadPlatformService calendarReadPlatformService; - private final PaymentTypeReadPlatformService paymentTypeReadPlatformService; + private final PaymentTypeReadService paymentTypeReadPlatformService; @Override public Collection retrieveAll(final DepositAccountType depositAccountType, @@ -1160,7 +1160,7 @@ public class DepositAccountReadPlatformServiceImpl implements DepositAccountRead final Long paymentTypeId = JdbcSupport.getLong(rs, PAYMENT_TYPE); if (paymentTypeId != null) { final String typeName = rs.getString(PAYMENT_TYPE_NAME); - final PaymentTypeData paymentType = PaymentTypeData.instance(paymentTypeId, typeName); + final PaymentTypeData paymentType = PaymentTypeData.builder().id(paymentTypeId).name(typeName).build(); final String accountNumber = rs.getString(ACCOUNT_NUMBER); final String checkNumber = rs.getString(CHECK_NUMBER); final String routingCode = rs.getString(ROUTING_CODE); diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/service/SavingsAccountReadPlatformServiceImpl.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/service/SavingsAccountReadPlatformServiceImpl.java index 922a0dcf1..fb1031e95 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/service/SavingsAccountReadPlatformServiceImpl.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/service/SavingsAccountReadPlatformServiceImpl.java @@ -1165,7 +1165,7 @@ public class SavingsAccountReadPlatformServiceImpl implements SavingsAccountRead final Long paymentTypeId = JdbcSupport.getLong(rs, "paymentType"); if (paymentTypeId != null) { final String typeName = rs.getString("paymentTypeName"); - final PaymentTypeData paymentType = PaymentTypeData.instance(paymentTypeId, typeName); + final PaymentTypeData paymentType = PaymentTypeData.builder().id(paymentTypeId).name(typeName).build(); final String accountNumber = rs.getString("accountNumber"); final String checkNumber = rs.getString("checkNumber"); final String routingCode = rs.getString("routingCode"); 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 e1bc759a7..e9e27ffb1 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 @@ -67,7 +67,7 @@ import org.apache.fineract.portfolio.interestratechart.service.InterestRateChart import org.apache.fineract.portfolio.loanaccount.domain.LoanRepository; import org.apache.fineract.portfolio.note.domain.NoteRepository; import org.apache.fineract.portfolio.paymentdetail.service.PaymentDetailWritePlatformService; -import org.apache.fineract.portfolio.paymenttype.service.PaymentTypeReadPlatformService; +import org.apache.fineract.portfolio.paymenttype.service.PaymentTypeReadService; import org.apache.fineract.portfolio.savings.data.DepositAccountDataValidator; import org.apache.fineract.portfolio.savings.data.DepositAccountTransactionDataValidator; import org.apache.fineract.portfolio.savings.data.DepositProductDataValidator; @@ -190,7 +190,7 @@ public class SavingsConfiguration { public DepositAccountPreMatureCalculationPlatformService depositAccountPreMatureCalculationPlatformService( FromJsonHelper fromJsonHelper, DepositAccountTransactionDataValidator depositAccountTransactionDataValidator, DepositAccountAssembler depositAccountAssembler, SavingsAccountReadPlatformService savingsAccountReadPlatformService, - ConfigurationDomainService configurationDomainService, PaymentTypeReadPlatformService paymentTypeReadPlatformService) { + ConfigurationDomainService configurationDomainService, PaymentTypeReadService paymentTypeReadPlatformService) { return new DepositAccountPreMatureCalculationPlatformServiceImpl(fromJsonHelper, depositAccountTransactionDataValidator, depositAccountAssembler, savingsAccountReadPlatformService, configurationDomainService, paymentTypeReadPlatformService); @@ -207,7 +207,7 @@ public class SavingsConfiguration { SavingsDropdownReadPlatformService savingsDropdownReadPlatformService, ChargeReadPlatformService chargeReadPlatformService, StaffReadPlatformService staffReadPlatformService, DepositsDropdownReadPlatformService depositsDropdownReadPlatformService, SavingsAccountReadPlatformService savingsAccountReadPlatformService, DropdownReadPlatformService dropdownReadPlatformService, - CalendarReadPlatformService calendarReadPlatformService, PaymentTypeReadPlatformService paymentTypeReadPlatformService) { + CalendarReadPlatformService calendarReadPlatformService, PaymentTypeReadService paymentTypeReadPlatformService) { return new DepositAccountReadPlatformServiceImpl(context, jdbcTemplate, chartReadPlatformService, productChartReadPlatformService, paginationParametersDataValidator, sqlGenerator, paginationHelper, clientReadPlatformService, groupReadPlatformService, depositProductReadPlatformService, savingsDropdownReadPlatformService, chargeReadPlatformService, staffReadPlatformService, diff --git a/fineract-provider/src/main/resources/application.properties b/fineract-provider/src/main/resources/application.properties index 2499cfe50..78a86a40b 100644 --- a/fineract-provider/src/main/resources/application.properties +++ b/fineract-provider/src/main/resources/application.properties @@ -577,6 +577,28 @@ resilience4j.retry.instances.commandImageDelete.enable-exponential-backoff=${FIN resilience4j.retry.instances.commandImageDelete.exponential-backoff-multiplier=${FINERACT_COMMAND_IMAGE_DELETE_RETRY_EXPONENTIAL_BACKOFF_MULTIPLIER:2} resilience4j.retry.instances.commandImageDelete.retryExceptions=${FINERACT_COMMAND_IMAGE_DELETE_RETRY_EXCEPTIONS:org.springframework.dao.ConcurrencyFailureException,org.eclipse.persistence.exceptions.OptimisticLockException,jakarta.persistence.OptimisticLockException,org.springframework.orm.jpa.JpaOptimisticLockingFailureException} +# payment type + +resilience4j.retry.instances.commandPaymentTypeCreate.max-attempts=${FINERACT_COMMAND_PAYMENT_TYPE_CREATE_RETRY_MAX_ATTEMPTS:3} +resilience4j.retry.instances.commandPaymentTypeCreate.wait-duration=${FINERACT_COMMAND_PAYMENT_TYPE_CREATE_RETRY_WAIT_DURATION:1s} +resilience4j.retry.instances.commandPaymentTypeCreate.enable-exponential-backoff=${FINERACT_COMMAND_PAYMENT_TYPE_CREATE_RETRY_ENABLE_EXPONENTIAL_BACKOFF:true} +resilience4j.retry.instances.commandPaymentTypeCreate.exponential-backoff-multiplier=${FINERACT_COMMAND_PAYMENT_TYPE_CREATE_RETRY_EXPONENTIAL_BACKOFF_MULTIPLIER:2} +resilience4j.retry.instances.commandPaymentTypeCreate.retryExceptions=${FINERACT_COMMAND_PAYMENT_TYPE_CREATE_RETRY_EXCEPTIONS:org.springframework.dao.ConcurrencyFailureException,org.eclipse.persistence.exceptions.OptimisticLockException,jakarta.persistence.OptimisticLockException,org.springframework.orm.jpa.JpaOptimisticLockingFailureException} + +resilience4j.retry.instances.commandPaymentTypeUpdate.max-attempts=${FINERACT_COMMAND_PAYMENT_TYPE_UPDATE_RETRY_MAX_ATTEMPTS:3} +resilience4j.retry.instances.commandPaymentTypeUpdate.wait-duration=${FINERACT_COMMAND_PAYMENT_TYPE_UPDATE_RETRY_WAIT_DURATION:1s} +resilience4j.retry.instances.commandPaymentTypeUpdate.enable-exponential-backoff=${FINERACT_COMMAND_PAYMENT_TYPE_UPDATE_RETRY_ENABLE_EXPONENTIAL_BACKOFF:true} +resilience4j.retry.instances.commandPaymentTypeUpdate.exponential-backoff-multiplier=${FINERACT_COMMAND_PAYMENT_TYPE_UPDATE_RETRY_EXPONENTIAL_BACKOFF_MULTIPLIER:2} +resilience4j.retry.instances.commandPaymentTypeUpdate.retryExceptions=${FINERACT_COMMAND_PAYMENT_TYPE_UPDATE_RETRY_EXCEPTIONS:org.springframework.dao.ConcurrencyFailureException,org.eclipse.persistence.exceptions.OptimisticLockException,jakarta.persistence.OptimisticLockException,org.springframework.orm.jpa.JpaOptimisticLockingFailureException} + +resilience4j.retry.instances.commandPaymentTypeDelete.max-attempts=${FINERACT_COMMAND_PAYMENT_TYPE_DELETE_RETRY_MAX_ATTEMPTS:3} +resilience4j.retry.instances.commandPaymentTypeDelete.wait-duration=${FINERACT_COMMAND_PAYMENT_TYPE_DELETE_RETRY_WAIT_DURATION:1s} +resilience4j.retry.instances.commandPaymentTypeDelete.enable-exponential-backoff=${FINERACT_COMMAND_PAYMENT_TYPE_DELETE_RETRY_ENABLE_EXPONENTIAL_BACKOFF:true} +resilience4j.retry.instances.commandPaymentTypeDelete.exponential-backoff-multiplier=${FINERACT_COMMAND_PAYMENT_TYPE_DELETE_RETRY_EXPONENTIAL_BACKOFF_MULTIPLIER:2} +resilience4j.retry.instances.commandPaymentTypeDelete.retryExceptions=${FINERACT_COMMAND_PAYMENT_TYPE_DELETE_RETRY_EXCEPTIONS:org.springframework.dao.ConcurrencyFailureException,org.eclipse.persistence.exceptions.OptimisticLockException,jakarta.persistence.OptimisticLockException,org.springframework.orm.jpa.JpaOptimisticLockingFailureException} + +# command + fineract.command.enabled=true fineract.command.executor=${FINERACT_COMMAND_EXECUTOR:sync} fineract.command.ring-buffer-size=${FINERACT_COMMAND_RING_BUFFER_SIZE:1024} @@ -587,8 +609,6 @@ fineract.command.idempotency-key-header-name=${FINERACT_IDEMPOTENCY_KEY_HEADER_N fineract.command.file-dead-letter-queue-enabled=${FINERACT_FILE_DEAD_LETTER_QUEUE_ENABLED:false} fineract.command.file-dead-letter-queue-path=${FINERACT_FILE_DEAD_LETTER_QUEUE_PATH:/tmp/fineract-command-audit} -# command - resilience4j.retry.instances.commandAuditProcessing.max-attempts=${FINERACT_COMMAND_AUDIT_PROCESSING_RETRY_MAX_ATTEMPTS:3} resilience4j.retry.instances.commandAuditProcessing.wait-duration=${FINERACT_COMMAND_AUDIT_PROCESSING_RETRY_WAIT_DURATION:1s} resilience4j.retry.instances.commandAuditProcessing.enable-exponential-backoff=${FINERACT_COMMAND_AUDIT_PROCESSING_RETRY_ENABLE_EXPONENTIAL_BACKOFF:true} diff --git a/fineract-validation/src/main/resources/ValidationMessages.properties b/fineract-validation/src/main/resources/ValidationMessages.properties index 132065662..03b61d377 100644 --- a/fineract-validation/src/main/resources/ValidationMessages.properties +++ b/fineract-validation/src/main/resources/ValidationMessages.properties @@ -58,3 +58,24 @@ org.apache.fineract.frequency-type.invalid=The parameter 'frequencyType' must be org.apache.fineract.portfolio.note.note.size=The parameter 'note' cannot exceed 1000 characters org.apache.fineract.portfolio.note.note.not-null=The parameter 'note' cannot be empty + +# Document Management + +org.apache.fineract.document.id.not-null=The parameter 'id' is mandatory +org.apache.fineract.document.entity-type.not-null=The parameter 'entityType' is mandatory +org.apache.fineract.document.entity-type.size=The parameter 'entityType' cannot exceed 50 characters +org.apache.fineract.document.entity-id.not-null=The parameter 'entityId' is mandatory +org.apache.fineract.document.name.size=The parameter 'name' cannot exceed 250 characters +org.apache.fineract.document.description.size=The parameter 'description' cannot exceed 250 characters +org.apache.fineract.document.file-name.size=The parameter 'fileName' cannot exceed 250 characters +org.apache.fineract.document.size.not-null=The parameter 'size' is mandatory +org.apache.fineract.document.size.min=The parameter 'size' must have a minimum value of 1 + +# Payment Type + +org.apache.fineract.portfolio.paymenttype.id.not-null=The parameter 'id' is mandatory +org.apache.fineract.portfolio.paymenttype.name.not-blank=The parameter 'name' cannot be blank +org.apache.fineract.portfolio.paymenttype.description.size=The parameter 'description' cannot exceed 500 characters +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 diff --git a/integration-tests/src/test/java/org/apache/fineract/integrationtests/ClientSavingsIntegrationTest.java b/integration-tests/src/test/java/org/apache/fineract/integrationtests/ClientSavingsIntegrationTest.java index 395e67674..633364af0 100644 --- a/integration-tests/src/test/java/org/apache/fineract/integrationtests/ClientSavingsIntegrationTest.java +++ b/integration-tests/src/test/java/org/apache/fineract/integrationtests/ClientSavingsIntegrationTest.java @@ -40,8 +40,7 @@ import java.util.Date; import java.util.HashMap; import java.util.List; import java.util.Locale; -import org.apache.fineract.client.models.PaymentTypeRequest; -import org.apache.fineract.client.models.PostPaymentTypesResponse; +import org.apache.fineract.client.models.PaymentTypeCreateRequest; import org.apache.fineract.client.models.PutGlobalConfigurationsRequest; import org.apache.fineract.infrastructure.businessdate.domain.BusinessDateType; import org.apache.fineract.infrastructure.configuration.api.GlobalConfigurationConstants; @@ -2664,10 +2663,10 @@ public class ClientSavingsIntegrationTest { String name = PaymentTypeHelper.randomNameGenerator("P_T", 5); String description = PaymentTypeHelper.randomNameGenerator("PT_Desc", 15); Boolean isCashPayment = false; - Integer position = 1; + Long position = 1L; - PostPaymentTypesResponse paymentTypesResponse = paymentTypeHelper.createPaymentType( - new PaymentTypeRequest().name(name).description(description).isCashPayment(isCashPayment).position(position)); + var paymentTypesResponse = paymentTypeHelper.createPaymentType( + new PaymentTypeCreateRequest().name(name).description(description).isCashPayment(isCashPayment).position(position)); Long paymentTypeIdOne = paymentTypesResponse.getResourceId(); Assertions.assertNotNull(paymentTypeIdOne); @@ -2688,8 +2687,8 @@ public class ClientSavingsIntegrationTest { String paymentTypeNameTwo = PaymentTypeHelper.randomNameGenerator("P_T", 5); - PostPaymentTypesResponse paymentTypesResponseTwo = paymentTypeHelper.createPaymentType( - new PaymentTypeRequest().name(paymentTypeNameTwo).description(description).isCashPayment(isCashPayment).position(position)); + var paymentTypesResponseTwo = paymentTypeHelper.createPaymentType(new PaymentTypeCreateRequest().name(paymentTypeNameTwo) + .description(description).isCashPayment(isCashPayment).position(position)); Long paymentTypeIdTwo = paymentTypesResponseTwo.getResourceId(); Assertions.assertNotNull(paymentTypeIdTwo); diff --git a/integration-tests/src/test/java/org/apache/fineract/integrationtests/GroupSavingsIntegrationTest.java b/integration-tests/src/test/java/org/apache/fineract/integrationtests/GroupSavingsIntegrationTest.java index f1f609a51..2c6424bf5 100644 --- a/integration-tests/src/test/java/org/apache/fineract/integrationtests/GroupSavingsIntegrationTest.java +++ b/integration-tests/src/test/java/org/apache/fineract/integrationtests/GroupSavingsIntegrationTest.java @@ -36,8 +36,7 @@ import java.util.HashMap; import java.util.List; import java.util.Locale; import java.util.Map; -import org.apache.fineract.client.models.PaymentTypeRequest; -import org.apache.fineract.client.models.PostPaymentTypesResponse; +import org.apache.fineract.client.models.PaymentTypeCreateRequest; import org.apache.fineract.integrationtests.common.ClientHelper; import org.apache.fineract.integrationtests.common.CommonConstants; import org.apache.fineract.integrationtests.common.GroupHelper; @@ -385,10 +384,10 @@ public class GroupSavingsIntegrationTest { String name = PaymentTypeHelper.randomNameGenerator("P_T", 5); String description = PaymentTypeHelper.randomNameGenerator("PT_Desc", 15); Boolean isCashPayment = true; - Integer position = 1; + Long position = 1L; - PostPaymentTypesResponse paymentTypesResponse = paymentTypeHelper.createPaymentType( - new PaymentTypeRequest().name(name).description(description).isCashPayment(isCashPayment).position(position)); + var paymentTypesResponse = paymentTypeHelper.createPaymentType( + new PaymentTypeCreateRequest().name(name).description(description).isCashPayment(isCashPayment).position(position)); Long paymentTypeId = paymentTypesResponse.getResourceId(); Assertions.assertNotNull(paymentTypeId); diff --git a/integration-tests/src/test/java/org/apache/fineract/integrationtests/LoanAccountChargeOffWithAdvancedPaymentAllocationTest.java b/integration-tests/src/test/java/org/apache/fineract/integrationtests/LoanAccountChargeOffWithAdvancedPaymentAllocationTest.java index fedb1983a..998da433d 100644 --- a/integration-tests/src/test/java/org/apache/fineract/integrationtests/LoanAccountChargeOffWithAdvancedPaymentAllocationTest.java +++ b/integration-tests/src/test/java/org/apache/fineract/integrationtests/LoanAccountChargeOffWithAdvancedPaymentAllocationTest.java @@ -47,13 +47,12 @@ import org.apache.fineract.client.models.GetLoansLoanIdTransactionsTransactionId import org.apache.fineract.client.models.JournalEntryTransactionItem; import org.apache.fineract.client.models.LoanProductChargeData; import org.apache.fineract.client.models.LoanProductChargeToGLAccountMapper; -import org.apache.fineract.client.models.PaymentTypeRequest; +import org.apache.fineract.client.models.PaymentTypeCreateRequest; import org.apache.fineract.client.models.PostClientsResponse; import org.apache.fineract.client.models.PostLoanProductsRequest; import org.apache.fineract.client.models.PostLoanProductsResponse; import org.apache.fineract.client.models.PostLoansLoanIdTransactionsRequest; import org.apache.fineract.client.models.PostLoansLoanIdTransactionsResponse; -import org.apache.fineract.client.models.PostPaymentTypesResponse; import org.apache.fineract.integrationtests.common.BusinessDateHelper; import org.apache.fineract.integrationtests.common.ClientHelper; import org.apache.fineract.integrationtests.common.PaymentTypeHelper; @@ -668,10 +667,10 @@ public class LoanAccountChargeOffWithAdvancedPaymentAllocationTest extends BaseL String paymentTypeName = PaymentTypeHelper.randomNameGenerator("P_T", 5); String description = PaymentTypeHelper.randomNameGenerator("PT_Desc", 15); Boolean isCashPayment = false; - Integer position = 1; + Long position = 1L; - PostPaymentTypesResponse paymentTypesResponse = paymentTypeHelper.createPaymentType( - new PaymentTypeRequest().name(paymentTypeName).description(description).isCashPayment(isCashPayment).position(position)); + var paymentTypesResponse = paymentTypeHelper.createPaymentType(new PaymentTypeCreateRequest().name(paymentTypeName) + .description(description).isCashPayment(isCashPayment).position(position)); Long paymentTypeIdOne = paymentTypesResponse.getResourceId(); Assertions.assertNotNull(paymentTypeIdOne); diff --git a/integration-tests/src/test/java/org/apache/fineract/integrationtests/LoanAccountChargeReveseReplayWithAdvancedPaymentAllocationTest.java b/integration-tests/src/test/java/org/apache/fineract/integrationtests/LoanAccountChargeReveseReplayWithAdvancedPaymentAllocationTest.java index acacd8c17..4d9bfc3b8 100644 --- a/integration-tests/src/test/java/org/apache/fineract/integrationtests/LoanAccountChargeReveseReplayWithAdvancedPaymentAllocationTest.java +++ b/integration-tests/src/test/java/org/apache/fineract/integrationtests/LoanAccountChargeReveseReplayWithAdvancedPaymentAllocationTest.java @@ -39,12 +39,11 @@ import org.apache.fineract.client.models.GetLoanPaymentChannelToFundSourceMappin import org.apache.fineract.client.models.GetLoansLoanIdResponse; import org.apache.fineract.client.models.LoanProductChargeData; import org.apache.fineract.client.models.LoanProductChargeToGLAccountMapper; -import org.apache.fineract.client.models.PaymentTypeRequest; +import org.apache.fineract.client.models.PaymentTypeCreateRequest; import org.apache.fineract.client.models.PostLoanProductsRequest; import org.apache.fineract.client.models.PostLoanProductsResponse; import org.apache.fineract.client.models.PostLoansLoanIdTransactionsRequest; import org.apache.fineract.client.models.PostLoansLoanIdTransactionsResponse; -import org.apache.fineract.client.models.PostPaymentTypesResponse; import org.apache.fineract.integrationtests.common.BusinessDateHelper; import org.apache.fineract.integrationtests.common.ClientHelper; import org.apache.fineract.integrationtests.common.PaymentTypeHelper; @@ -363,10 +362,10 @@ public class LoanAccountChargeReveseReplayWithAdvancedPaymentAllocationTest exte String paymentTypeName = PaymentTypeHelper.randomNameGenerator("P_T", 5); String description = PaymentTypeHelper.randomNameGenerator("PT_Desc", 15); Boolean isCashPayment = false; - Integer position = 1; + Long position = 1L; - PostPaymentTypesResponse paymentTypesResponse = paymentTypeHelper.createPaymentType( - new PaymentTypeRequest().name(paymentTypeName).description(description).isCashPayment(isCashPayment).position(position)); + var paymentTypesResponse = paymentTypeHelper.createPaymentType(new PaymentTypeCreateRequest().name(paymentTypeName) + .description(description).isCashPayment(isCashPayment).position(position)); Long paymentTypeIdOne = paymentTypesResponse.getResourceId(); Assertions.assertNotNull(paymentTypeIdOne); diff --git a/integration-tests/src/test/java/org/apache/fineract/integrationtests/LoanPostChargeOffScenariosTest.java b/integration-tests/src/test/java/org/apache/fineract/integrationtests/LoanPostChargeOffScenariosTest.java index f94f20ae7..a8daadc70 100644 --- a/integration-tests/src/test/java/org/apache/fineract/integrationtests/LoanPostChargeOffScenariosTest.java +++ b/integration-tests/src/test/java/org/apache/fineract/integrationtests/LoanPostChargeOffScenariosTest.java @@ -42,12 +42,11 @@ import org.apache.fineract.client.models.GetLoansLoanIdTransactionsTransactionId import org.apache.fineract.client.models.JournalEntryTransactionItem; import org.apache.fineract.client.models.LoanProductChargeData; import org.apache.fineract.client.models.LoanProductChargeToGLAccountMapper; -import org.apache.fineract.client.models.PaymentTypeRequest; +import org.apache.fineract.client.models.PaymentTypeCreateRequest; import org.apache.fineract.client.models.PostLoanProductsRequest; import org.apache.fineract.client.models.PostLoanProductsResponse; import org.apache.fineract.client.models.PostLoansLoanIdTransactionsRequest; import org.apache.fineract.client.models.PostLoansLoanIdTransactionsResponse; -import org.apache.fineract.client.models.PostPaymentTypesResponse; import org.apache.fineract.integrationtests.common.ClientHelper; import org.apache.fineract.integrationtests.common.PaymentTypeHelper; import org.apache.fineract.integrationtests.common.Utils; @@ -1134,10 +1133,10 @@ public class LoanPostChargeOffScenariosTest extends BaseLoanIntegrationTest { String paymentTypeName = PaymentTypeHelper.randomNameGenerator("P_T", 5); String description = PaymentTypeHelper.randomNameGenerator("PT_Desc", 15); Boolean isCashPayment = false; - Integer position = 1; + Long position = 1L; - PostPaymentTypesResponse paymentTypesResponse = paymentTypeHelper.createPaymentType( - new PaymentTypeRequest().name(paymentTypeName).description(description).isCashPayment(isCashPayment).position(position)); + var paymentTypesResponse = paymentTypeHelper.createPaymentType(new PaymentTypeCreateRequest().name(paymentTypeName) + .description(description).isCashPayment(isCashPayment).position(position)); Long paymentTypeIdOne = paymentTypesResponse.getResourceId(); Assertions.assertNotNull(paymentTypeIdOne); diff --git a/integration-tests/src/test/java/org/apache/fineract/integrationtests/PaymentTypeIntegrationTest.java b/integration-tests/src/test/java/org/apache/fineract/integrationtests/PaymentTypeIntegrationTest.java index a3f878acc..03a0f9bec 100644 --- a/integration-tests/src/test/java/org/apache/fineract/integrationtests/PaymentTypeIntegrationTest.java +++ b/integration-tests/src/test/java/org/apache/fineract/integrationtests/PaymentTypeIntegrationTest.java @@ -23,11 +23,9 @@ import io.restassured.builder.ResponseSpecBuilder; import io.restassured.http.ContentType; import io.restassured.specification.RequestSpecification; import io.restassured.specification.ResponseSpecification; -import org.apache.fineract.client.models.DeletePaymentTypesPaymentTypeIdResponse; +import org.apache.fineract.client.models.PaymentTypeCreateRequest; import org.apache.fineract.client.models.PaymentTypeData; -import org.apache.fineract.client.models.PaymentTypeRequest; -import org.apache.fineract.client.models.PostPaymentTypesResponse; -import org.apache.fineract.client.models.PutPaymentTypesPaymentTypeIdRequest; +import org.apache.fineract.client.models.PaymentTypeUpdateRequest; import org.apache.fineract.integrationtests.common.PaymentTypeHelper; import org.apache.fineract.integrationtests.common.Utils; import org.junit.jupiter.api.Assertions; @@ -55,10 +53,10 @@ public class PaymentTypeIntegrationTest { String name = PaymentTypeHelper.randomNameGenerator("P_T", 5); String description = PaymentTypeHelper.randomNameGenerator("PT_Desc", 15); Boolean isCashPayment = true; - Integer position = 1; + Long position = 1L; - PostPaymentTypesResponse paymentTypesResponse = paymentTypeHelper.createPaymentType( - new PaymentTypeRequest().name(name).description(description).isCashPayment(isCashPayment).position(position)); + var paymentTypesResponse = paymentTypeHelper.createPaymentType( + new PaymentTypeCreateRequest().name(name).description(description).isCashPayment(isCashPayment).position(position)); Long paymentTypeId = paymentTypesResponse.getResourceId(); Assertions.assertNotNull(paymentTypeId); paymentTypeHelper.verifyPaymentTypeCreatedOnServer(paymentTypeId); @@ -72,18 +70,18 @@ public class PaymentTypeIntegrationTest { String newName = PaymentTypeHelper.randomNameGenerator("P_TU", 5); String newDescription = PaymentTypeHelper.randomNameGenerator("PTU_Desc", 15); Boolean isCashPaymentUpdatedValue = false; - Integer newPosition = 2; + Long newPosition = 2L; - paymentTypeHelper.updatePaymentType(paymentTypeId, new PutPaymentTypesPaymentTypeIdRequest().name(newName) - .description(newDescription).isCashPayment(isCashPaymentUpdatedValue).position(newPosition)); - PaymentTypeData paymentTypeUpdatedResponse = paymentTypeHelper.retrieveById(paymentTypeId); + paymentTypeHelper.updatePaymentType(paymentTypeId, new PaymentTypeUpdateRequest().name(newName).description(newDescription) + .isCashPayment(isCashPaymentUpdatedValue).position(newPosition)); + var paymentTypeUpdatedResponse = paymentTypeHelper.retrieveById(paymentTypeId); Assertions.assertEquals(newName, paymentTypeUpdatedResponse.getName()); Assertions.assertEquals(newDescription, paymentTypeUpdatedResponse.getDescription()); Assertions.assertEquals(isCashPaymentUpdatedValue, paymentTypeUpdatedResponse.getIsCashPayment()); Assertions.assertEquals(newPosition, paymentTypeUpdatedResponse.getPosition()); // Delete - DeletePaymentTypesPaymentTypeIdResponse responseDelete = paymentTypeHelper.deletePaymentType(paymentTypeId); + var responseDelete = paymentTypeHelper.deletePaymentType(paymentTypeId); Long deletedPaymentTypeId = responseDelete.getResourceId(); Assertions.assertEquals(paymentTypeId, deletedPaymentTypeId); ResponseSpecification responseSpecification = new ResponseSpecBuilder().expectStatusCode(404).build(); diff --git a/integration-tests/src/test/java/org/apache/fineract/integrationtests/RepaymentWithPostDatedChecksTest.java b/integration-tests/src/test/java/org/apache/fineract/integrationtests/RepaymentWithPostDatedChecksTest.java index 8d7dd22a9..562e0932a 100644 --- a/integration-tests/src/test/java/org/apache/fineract/integrationtests/RepaymentWithPostDatedChecksTest.java +++ b/integration-tests/src/test/java/org/apache/fineract/integrationtests/RepaymentWithPostDatedChecksTest.java @@ -34,9 +34,8 @@ import java.util.Calendar; import java.util.HashMap; import java.util.List; import java.util.Locale; +import org.apache.fineract.client.models.PaymentTypeCreateRequest; import org.apache.fineract.client.models.PaymentTypeData; -import org.apache.fineract.client.models.PaymentTypeRequest; -import org.apache.fineract.client.models.PostPaymentTypesResponse; import org.apache.fineract.integrationtests.common.ClientHelper; import org.apache.fineract.integrationtests.common.CollateralManagementHelper; import org.apache.fineract.integrationtests.common.PaymentTypeHelper; @@ -138,10 +137,10 @@ public class RepaymentWithPostDatedChecksTest { String name = "PDC"; String description = PaymentTypeHelper.randomNameGenerator("PDC", 15); Boolean isCashPayment = false; - Integer position = 1; + Long position = 1L; - PostPaymentTypesResponse paymentTypesResponse = paymentTypeHelper.createPaymentType( - new PaymentTypeRequest().name(name).description(description).isCashPayment(isCashPayment).position(position)); + var paymentTypesResponse = paymentTypeHelper.createPaymentType( + new PaymentTypeCreateRequest().name(name).description(description).isCashPayment(isCashPayment).position(position)); Long paymentTypeId = paymentTypesResponse.getResourceId(); Assertions.assertNotNull(paymentTypeId); paymentTypeHelper.verifyPaymentTypeCreatedOnServer(paymentTypeId); diff --git a/integration-tests/src/test/java/org/apache/fineract/integrationtests/UndoRepaymentWithDownPaymentIntegrationTest.java b/integration-tests/src/test/java/org/apache/fineract/integrationtests/UndoRepaymentWithDownPaymentIntegrationTest.java index 4cf24b967..1c8107a05 100644 --- a/integration-tests/src/test/java/org/apache/fineract/integrationtests/UndoRepaymentWithDownPaymentIntegrationTest.java +++ b/integration-tests/src/test/java/org/apache/fineract/integrationtests/UndoRepaymentWithDownPaymentIntegrationTest.java @@ -41,12 +41,11 @@ import org.apache.fineract.client.models.GetLoanProductsProductIdResponse; import org.apache.fineract.client.models.GetLoansLoanIdResponse; import org.apache.fineract.client.models.LoanProductChargeData; import org.apache.fineract.client.models.LoanProductChargeToGLAccountMapper; -import org.apache.fineract.client.models.PaymentTypeRequest; +import org.apache.fineract.client.models.PaymentTypeCreateRequest; import org.apache.fineract.client.models.PostLoanProductsRequest; import org.apache.fineract.client.models.PostLoanProductsResponse; import org.apache.fineract.client.models.PostLoansLoanIdTransactionsResponse; import org.apache.fineract.client.models.PostLoansLoanIdTransactionsTransactionIdRequest; -import org.apache.fineract.client.models.PostPaymentTypesResponse; import org.apache.fineract.client.models.PutGlobalConfigurationsRequest; import org.apache.fineract.infrastructure.businessdate.domain.BusinessDateType; import org.apache.fineract.infrastructure.configuration.api.GlobalConfigurationConstants; @@ -211,10 +210,10 @@ public class UndoRepaymentWithDownPaymentIntegrationTest extends BaseLoanIntegra String paymentTypeName = PaymentTypeHelper.randomNameGenerator("P_T", 5); String description = PaymentTypeHelper.randomNameGenerator("PT_Desc", 15); Boolean isCashPayment = false; - Integer position = 1; + Long position = 1L; - PostPaymentTypesResponse paymentTypesResponse = paymentTypeHelper.createPaymentType( - new PaymentTypeRequest().name(paymentTypeName).description(description).isCashPayment(isCashPayment).position(position)); + var paymentTypesResponse = paymentTypeHelper.createPaymentType(new PaymentTypeCreateRequest().name(paymentTypeName) + .description(description).isCashPayment(isCashPayment).position(position)); Long paymentTypeIdOne = paymentTypesResponse.getResourceId(); Assertions.assertNotNull(paymentTypeIdOne); diff --git a/integration-tests/src/test/java/org/apache/fineract/integrationtests/bulkimport/importhandler/loan/LoanImportHandlerTest.java b/integration-tests/src/test/java/org/apache/fineract/integrationtests/bulkimport/importhandler/loan/LoanImportHandlerTest.java index fe51ff169..9d8906c4c 100644 --- a/integration-tests/src/test/java/org/apache/fineract/integrationtests/bulkimport/importhandler/loan/LoanImportHandlerTest.java +++ b/integration-tests/src/test/java/org/apache/fineract/integrationtests/bulkimport/importhandler/loan/LoanImportHandlerTest.java @@ -41,8 +41,7 @@ import java.util.List; import java.util.Locale; import java.util.Map; import java.util.UUID; -import org.apache.fineract.client.models.PaymentTypeRequest; -import org.apache.fineract.client.models.PostPaymentTypesResponse; +import org.apache.fineract.client.models.PaymentTypeCreateRequest; import org.apache.fineract.infrastructure.bulkimport.constants.LoanConstants; import org.apache.fineract.infrastructure.bulkimport.constants.TemplatePopulateImportConstants; import org.apache.fineract.integrationtests.bulkimport.importhandler.LocalContentStorageUtil; @@ -168,8 +167,8 @@ public class LoanImportHandlerTest { String paymentTypeName = PaymentTypeHelper.randomNameGenerator("P_T", 5); String paymentTypeDescription = PaymentTypeHelper.randomNameGenerator("PT_Desc", 15); - PostPaymentTypesResponse paymentTypesResponse = paymentTypeHelper.createPaymentType( - new PaymentTypeRequest().name(paymentTypeName).description(paymentTypeDescription).isCashPayment(true).position(1)); + var paymentTypesResponse = paymentTypeHelper.createPaymentType( + new PaymentTypeCreateRequest().name(paymentTypeName).description(paymentTypeDescription).isCashPayment(true).position(1L)); Long outcome_payment_creation = paymentTypesResponse.getResourceId(); Assertions.assertNotNull(outcome_payment_creation, "Could not create payment type"); diff --git a/integration-tests/src/test/java/org/apache/fineract/integrationtests/bulkimport/populator/loan/LoanWorkbookPopulatorTest.java b/integration-tests/src/test/java/org/apache/fineract/integrationtests/bulkimport/populator/loan/LoanWorkbookPopulatorTest.java index 9d8bf3014..a1baa2723 100644 --- a/integration-tests/src/test/java/org/apache/fineract/integrationtests/bulkimport/populator/loan/LoanWorkbookPopulatorTest.java +++ b/integration-tests/src/test/java/org/apache/fineract/integrationtests/bulkimport/populator/loan/LoanWorkbookPopulatorTest.java @@ -26,8 +26,7 @@ import io.restassured.specification.ResponseSpecification; import jakarta.ws.rs.core.HttpHeaders; import jakarta.ws.rs.core.MediaType; import java.io.IOException; -import org.apache.fineract.client.models.PaymentTypeRequest; -import org.apache.fineract.client.models.PostPaymentTypesResponse; +import org.apache.fineract.client.models.PaymentTypeCreateRequest; import org.apache.fineract.infrastructure.bulkimport.constants.TemplatePopulateImportConstants; import org.apache.fineract.integrationtests.common.ClientHelper; import org.apache.fineract.integrationtests.common.GroupHelper; @@ -93,9 +92,9 @@ public class LoanWorkbookPopulatorTest { String name = PaymentTypeHelper.randomNameGenerator("P_T", 5); String description = PaymentTypeHelper.randomNameGenerator("PT_Desc", 15); Boolean isCashPayment = true; - Integer position = 1; - PostPaymentTypesResponse paymentTypesResponse = paymentTypeHelper.createPaymentType( - new PaymentTypeRequest().name(name).description(description).isCashPayment(isCashPayment).position(position)); + Long position = 1L; + var paymentTypesResponse = paymentTypeHelper.createPaymentType( + new PaymentTypeCreateRequest().name(name).description(description).isCashPayment(isCashPayment).position(position)); Long outcome_payment_creation = paymentTypesResponse.getResourceId(); Assertions.assertNotNull(outcome_payment_creation, "Could not create payment type"); diff --git a/integration-tests/src/test/java/org/apache/fineract/integrationtests/common/PaymentTypeHelper.java b/integration-tests/src/test/java/org/apache/fineract/integrationtests/common/PaymentTypeHelper.java index 942f75ff3..8a9f3a3a9 100644 --- a/integration-tests/src/test/java/org/apache/fineract/integrationtests/common/PaymentTypeHelper.java +++ b/integration-tests/src/test/java/org/apache/fineract/integrationtests/common/PaymentTypeHelper.java @@ -26,12 +26,12 @@ import io.restassured.specification.RequestSpecification; import io.restassured.specification.ResponseSpecification; import java.util.List; import lombok.extern.slf4j.Slf4j; -import org.apache.fineract.client.models.DeletePaymentTypesPaymentTypeIdResponse; +import org.apache.fineract.client.models.PaymentTypeCreateRequest; +import org.apache.fineract.client.models.PaymentTypeCreateResponse; import org.apache.fineract.client.models.PaymentTypeData; -import org.apache.fineract.client.models.PaymentTypeRequest; -import org.apache.fineract.client.models.PostPaymentTypesResponse; -import org.apache.fineract.client.models.PutPaymentTypesPaymentTypeIdRequest; -import org.apache.fineract.client.models.PutPaymentTypesPaymentTypeIdResponse; +import org.apache.fineract.client.models.PaymentTypeDeleteResponse; +import org.apache.fineract.client.models.PaymentTypeUpdateRequest; +import org.apache.fineract.client.models.PaymentTypeUpdateResponse; import org.apache.fineract.client.util.Calls; @SuppressWarnings({ "rawtypes", "unchecked" }) @@ -50,7 +50,7 @@ public final class PaymentTypeHelper { return Calls.ok(FineractClientHelper.getFineractClient().paymentTypes.getAllPaymentTypes(onlyWithCode)); } - public PostPaymentTypesResponse createPaymentType(final PaymentTypeRequest paymentTypeRequest) { + public PaymentTypeCreateResponse createPaymentType(final PaymentTypeCreateRequest paymentTypeRequest) { log.info("---------------------------------CREATING A PAYMENT TYPE---------------------------------------------"); return Calls.ok(FineractClientHelper.getFineractClient().paymentTypes.createPaymentType(paymentTypeRequest)); } @@ -80,14 +80,14 @@ public final class PaymentTypeHelper { return new Gson().fromJson(jsonData, new TypeToken() {}.getType()); } - public PutPaymentTypesPaymentTypeIdResponse updatePaymentType(final Long paymentTypeId, - PutPaymentTypesPaymentTypeIdRequest putPaymentTypesPaymentTypeIdRequest) { + public PaymentTypeUpdateResponse updatePaymentType(final Long paymentTypeId, + PaymentTypeUpdateRequest putPaymentTypesPaymentTypeIdRequest) { log.info("-------------------------------UPDATING PAYMENT TYPE-------------------------------------------"); return Calls.ok(FineractClientHelper.getFineractClient().paymentTypes.updatePaymentType(paymentTypeId, putPaymentTypesPaymentTypeIdRequest)); } - public DeletePaymentTypesPaymentTypeIdResponse deletePaymentType(final Long paymentTypeId) { + public PaymentTypeDeleteResponse deletePaymentType(final Long paymentTypeId) { log.info("-------------------------------DELETING PAYMENT TYPE-------------------------------------------"); return Calls.ok(FineractClientHelper.getFineractClient().paymentTypes.deleteCode1(paymentTypeId)); } diff --git a/integration-tests/src/test/java/org/apache/fineract/integrationtests/savings/AccountTransferWithdrawalFeeTest.java b/integration-tests/src/test/java/org/apache/fineract/integrationtests/savings/AccountTransferWithdrawalFeeTest.java index 150fdd81c..4e496521b 100644 --- a/integration-tests/src/test/java/org/apache/fineract/integrationtests/savings/AccountTransferWithdrawalFeeTest.java +++ b/integration-tests/src/test/java/org/apache/fineract/integrationtests/savings/AccountTransferWithdrawalFeeTest.java @@ -23,9 +23,8 @@ import static io.restassured.RestAssured.given; import java.math.BigDecimal; import org.apache.fineract.client.models.AccountTransferRequest; import org.apache.fineract.client.models.ChargeRequest; -import org.apache.fineract.client.models.PaymentTypeRequest; +import org.apache.fineract.client.models.PaymentTypeCreateRequest; import org.apache.fineract.client.models.PostChargesResponse; -import org.apache.fineract.client.models.PostPaymentTypesResponse; import org.apache.fineract.client.models.PostSavingsAccountsResponse; import org.apache.fineract.client.models.PostSavingsAccountsSavingsAccountIdChargesRequest; import org.apache.fineract.client.models.PostSavingsAccountsSavingsAccountIdChargesResponse; @@ -109,9 +108,9 @@ public class AccountTransferWithdrawalFeeTest extends BaseSavingsIntegrationTest public void testFromSavingsToSavingsAccountTransferWithPaymentTypeWithdrawalFee() { // Create Payment Type final PaymentTypeHelper paymentTypeHelper = new PaymentTypeHelper(); - final PostPaymentTypesResponse paymentTypeResponse = paymentTypeHelper - .createPaymentType(new PaymentTypeRequest().name("Bank Transfer " + System.currentTimeMillis()) - .description("Payment via bank transfer").isCashPayment(false).position(1)); + final var paymentTypeResponse = paymentTypeHelper + .createPaymentType(new PaymentTypeCreateRequest().name("Bank Transfer " + System.currentTimeMillis()) + .description("Payment via bank transfer").isCashPayment(false).position(1L)); final Long paymentTypeId = paymentTypeResponse.getResourceId(); // Create withdrawal fee charge WITH payment type binding