Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions fineract-client-feign/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ tasks.register('buildJavaSdk', org.openapitools.generator.gradle.plugin.tasks.Ge
verbose = false
validateSpec = false
skipValidateSpec = true
skipOperationExample = true
inputSpec = "file:///$swaggerFile"
outputDir = "$buildDir/generated/temp-java".toString()
templateDir = "$projectDir/src/main/resources/templates/java"
Expand Down
3 changes: 3 additions & 0 deletions fineract-client/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ task buildJavaSdk(type: org.openapitools.generator.gradle.plugin.tasks.GenerateT
verbose = false
validateSpec = false
skipValidateSpec = true
skipOperationExample = true
inputSpec = "file:///$swaggerFile"
outputDir = "$buildDir/generated/temp-java".toString()
templateDir = "$projectDir/src/main/resources/templates/java"
Expand All @@ -88,6 +89,7 @@ task buildTypescriptAngularSdk(type: org.openapitools.generator.gradle.plugin.ta
verbose = false
validateSpec = false
skipValidateSpec = true
skipOperationExample = true
inputSpec = "file:///$swaggerFile"
outputDir = "$buildDir/generated/typescript".toString()
apiPackage = 'apache-fineract-client/services'
Expand Down Expand Up @@ -125,6 +127,7 @@ task buildAsciidoc(type: org.openapitools.generator.gradle.plugin.tasks.Generate
verbose = false
validateSpec = false
skipValidateSpec = true
skipOperationExample = true
inputSpec = "file:///$swaggerFile"
outputDir = "$buildDir/generated/asciidoc".toString()
apiPackage = 'org.apache.fineract.client.services'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5231,10 +5231,7 @@ public void adminAddsCapitalizedIncomeAdjustmentToTheLoan(final String transacti
final String amount) {
final PostLoansResponse loanResponse = testContext().get(TestContextKey.LOAN_CREATE_RESPONSE);
final long loanId = loanResponse.getLoanId();

// Get current business date to ensure we're not creating backdated transactions
String currentBusinessDate = businessDateHelper.getBusinessDate();
log.debug("Current business date: {}, Transaction date: {}", currentBusinessDate, transactionDate);
eventStore.reset();

final GetLoansLoanIdResponse loanDetailsResponse = ok(() -> fineractClient.loans().retrieveLoan(loanId,
Map.of("staffInSelectedOfficeOnly", "false", "associations", "transactions")));
Expand All @@ -5248,17 +5245,15 @@ public void adminAddsCapitalizedIncomeAdjustmentToTheLoan(final String transacti

testContext().set(TestContextKey.LOAN_CAPITALIZED_INCOME_ADJUSTMENT_RESPONSE, adjustmentResponse);
log.debug("Capitalized Income Adjustment created: Transaction ID {}", adjustmentResponse.getResourceId());
eventCheckHelper.loanBalanceChangedEventCheck(loanId);
}

@And("Admin adds capitalized income adjustment of capitalized income transaction made on {string} with {string} payment type to the loan on {string} with {string} EUR transaction amount")
public void adminAddsCapitalizedIncomeAdjustmentToTheLoan(final String originalTransactionDate, final String transactionPaymentType,
final String transactionDate, final String amount) {
final PostLoansResponse loanResponse = testContext().get(TestContextKey.LOAN_CREATE_RESPONSE);
final long loanId = loanResponse.getLoanId();

// Get current business date to ensure we're not creating backdated transactions
String currentBusinessDate = businessDateHelper.getBusinessDate();
log.debug("Current business date: {}, Transaction date: {}", currentBusinessDate, transactionDate);
eventStore.reset();

final GetLoansLoanIdResponse loanDetailsResponse = ok(() -> fineractClient.loans().retrieveLoan(loanId,
Map.of("staffInSelectedOfficeOnly", "false", "associations", "transactions")));
Expand All @@ -5280,6 +5275,7 @@ public void adminAddsCapitalizedIncomeAdjustmentToTheLoan(final String originalT
testContext().set(TestContextKey.LOAN_CAPITALIZED_INCOME_ADJUSTMENT_RESPONSE, adjustmentResponse);
assert adjustmentResponse != null;
log.debug("Capitalized Income Adjustment created: Transaction ID {}", adjustmentResponse.getResourceId());
eventCheckHelper.loanBalanceChangedEventCheck(loanId);
}

@Then("Loan's available disbursement amount is {string}")
Expand All @@ -5302,6 +5298,7 @@ public void adminAddsCapitalizedIncomeAdjustmentToTheLoanWithCapitalizedIncomeDa
final String transactionDate, final String amount, final String capitalizedIncomeTrnsDate) {
final PostLoansResponse loanResponse = testContext().get(TestContextKey.LOAN_CREATE_RESPONSE);
final long loanId = loanResponse.getLoanId();
eventStore.reset();

final GetLoansLoanIdResponse loanDetailsResponse = ok(() -> fineractClient.loans().retrieveLoan(loanId,
Map.of("staffInSelectedOfficeOnly", "false", "associations", "transactions")));
Expand All @@ -5316,6 +5313,7 @@ public void adminAddsCapitalizedIncomeAdjustmentToTheLoanWithCapitalizedIncomeDa

testContext().set(TestContextKey.LOAN_CAPITALIZED_INCOME_ADJUSTMENT_RESPONSE, adjustmentResponse);
log.debug("Capitalized Income Adjustment created: Transaction ID {}", adjustmentResponse.getResourceId());
eventCheckHelper.loanBalanceChangedEventCheck(loanId);
}

@And("Admin adds invalid capitalized income adjustment with {string} payment type to the loan on {string} with {string} EUR transaction amount")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
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.validation.Valid;
import jakarta.ws.rs.BeanParam;
import jakarta.ws.rs.Consumes;
import jakarta.ws.rs.GET;
Expand All @@ -35,14 +36,18 @@
import jakarta.ws.rs.QueryParam;
import jakarta.ws.rs.core.MediaType;
import lombok.RequiredArgsConstructor;
import org.apache.fineract.command.core.CommandDispatcher;
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.infrastructure.core.serialization.DefaultToApiJsonSerializer;
import org.apache.fineract.infrastructure.core.service.Page;
import org.apache.fineract.infrastructure.core.service.SearchParameters;
import org.apache.fineract.infrastructure.security.service.PlatformSecurityContext;
import org.apache.fineract.portfolio.account.command.AccountTransferCreateCommand;
import org.apache.fineract.portfolio.account.command.AccountTransferRefundByTransferCommand;
import org.apache.fineract.portfolio.account.data.AccountTransferCreateRequest;
import org.apache.fineract.portfolio.account.data.AccountTransferCreateResponse;
import org.apache.fineract.portfolio.account.data.AccountTransferData;
import org.apache.fineract.portfolio.account.data.request.AccountTransSearchParam;
import org.apache.fineract.portfolio.account.data.request.AccountTransferRequest;
Expand All @@ -56,9 +61,9 @@
public class AccountTransfersApiResource {

private final PlatformSecurityContext context;
private final DefaultToApiJsonSerializer<AccountTransferData> toApiJsonSerializer;
private final PortfolioCommandSourceWritePlatformService commandsSourceWritePlatformService;
private final AccountTransfersReadPlatformService accountTransfersReadPlatformService;
private final PortfolioCommandSourceWritePlatformService commandsSourceWritePlatformService;
private final CommandDispatcher dispatcher;

@GET
@Path("template")
Expand All @@ -70,7 +75,6 @@ public class AccountTransfersApiResource {
+ "accounttransfers/template?fromClientId=1&fromAccountType=2&fromAccountId=1")
@ApiResponse(responseCode = "200", description = "OK", content = @Content(schema = @Schema(implementation = AccountTransfersApiResourceSwagger.GetAccountTransfersTemplateResponse.class)))
public AccountTransferData template(@BeanParam AccountTransSearchParam accountTransSearchParam) {

context.authenticatedUser().validateHasReadPermission(AccountTransfersApiConstants.ACCOUNT_TRANSFER_RESOURCE_NAME);

return accountTransfersReadPlatformService.retrieveTemplate(accountTransSearchParam.getFromAccountId(),
Expand All @@ -86,11 +90,10 @@ public AccountTransferData template(@BeanParam AccountTransSearchParam accountTr
@Operation(summary = "Create new Transfer", operationId = "createAccountTransfer", description = "Ability to create new transfer of monetary funds from one account to another.")
@RequestBody(required = true, content = @Content(schema = @Schema(implementation = AccountTransferRequest.class)))
@ApiResponse(responseCode = "200", description = "OK", content = @Content(schema = @Schema(implementation = AccountTransfersApiResourceSwagger.PostAccountTransfersResponse.class)))
public CommandProcessingResult create(@Parameter(hidden = true) AccountTransferRequest accountTransferRequest) {
final CommandWrapper commandRequest = new CommandWrapperBuilder().createAccountTransfer()
.withJson(toApiJsonSerializer.serialize(accountTransferRequest)).build();

return commandsSourceWritePlatformService.logCommandSource(commandRequest);
public AccountTransferCreateResponse create(@Parameter(hidden = true) @Valid AccountTransferCreateRequest request) {
final var command = new AccountTransferCreateCommand();
command.setPayload(request);
return (AccountTransferCreateResponse) dispatcher.dispatch(command).get();
}

@GET
Expand All @@ -104,9 +107,7 @@ public Page<AccountTransferData> retrieveAll(@QueryParam("externalId") @Paramete
@QueryParam("orderBy") @Parameter(description = "orderBy") final String orderBy,
@QueryParam("sortOrder") @Parameter(description = "sortOrder") final String sortOrder,
@QueryParam("accountDetailId") @Parameter(description = "accountDetailId") final Long accountDetailId) {

context.authenticatedUser().validateHasReadPermission(AccountTransfersApiConstants.ACCOUNT_TRANSFER_RESOURCE_NAME);

final SearchParameters searchParameters = SearchParameters.builder().limit(limit).externalId(externalId).offset(offset)
.orderBy(orderBy).sortOrder(sortOrder).build();

Expand All @@ -121,6 +122,7 @@ public Page<AccountTransferData> retrieveAll(@QueryParam("externalId") @Paramete
@ApiResponse(responseCode = "200", description = "OK", content = @Content(schema = @Schema(implementation = AccountTransfersApiResourceSwagger.GetAccountTransfersResponse.GetAccountTransfersPageItems.class)))
public AccountTransferData retrieveOne(@PathParam("transferId") @Parameter(description = "transferId") final Long transferId) {
context.authenticatedUser().validateHasReadPermission(AccountTransfersApiConstants.ACCOUNT_TRANSFER_RESOURCE_NAME);

return accountTransfersReadPlatformService.retrieveOne(transferId);
}

Expand All @@ -133,6 +135,7 @@ public AccountTransferData retrieveOne(@PathParam("transferId") @Parameter(descr
@ApiResponse(responseCode = "200", description = "OK", content = @Content(schema = @Schema(implementation = AccountTransfersApiResourceSwagger.GetAccountTransfersTemplateRefundByTransferResponse.class)))
public AccountTransferData templateRefundByTransfer(@BeanParam AccountTransSearchParam accountTransSearchParam) {
context.authenticatedUser().validateHasReadPermission(AccountTransfersApiConstants.ACCOUNT_TRANSFER_RESOURCE_NAME);

return accountTransfersReadPlatformService.retrieveRefundByTransferTemplate(accountTransSearchParam.getFromAccountId(),
accountTransSearchParam.getFromClientId(), accountTransSearchParam.getFromAccountId(),
accountTransSearchParam.getFromAccountType(), accountTransSearchParam.getToOfficeId(),
Expand All @@ -147,10 +150,11 @@ public AccountTransferData templateRefundByTransfer(@BeanParam AccountTransSearc
@Operation(summary = "Refund of an Active Loan by Transfer", operationId = "refundByTransfer", description = "Ability to refund an active loan by transferring to a savings account.")
@RequestBody(required = true, content = @Content(schema = @Schema(implementation = AccountTransferRequest.class)))
@ApiResponse(responseCode = "200", description = "OK", content = @Content(schema = @Schema(implementation = AccountTransfersApiResourceSwagger.PostAccountTransfersRefundByTransferResponse.class)))
public CommandProcessingResult templateRefundByTransferPost(@Parameter(hidden = true) AccountTransferRequest accountTransferRequest) {
final CommandWrapper commandRequest = new CommandWrapperBuilder().refundByTransfer()
.withJson(toApiJsonSerializer.serialize(accountTransferRequest)).build();
return commandsSourceWritePlatformService.logCommandSource(commandRequest);
public AccountTransferCreateResponse templateRefundByTransferPost(@Parameter(hidden = true) AccountTransferCreateRequest request) {
final var command = new AccountTransferRefundByTransferCommand();
command.setPayload(request);

return (AccountTransferCreateResponse) dispatcher.dispatch(command).get();
}

@POST
Expand Down
Loading
Loading