FINERACT-1920:Create Interoperation Loan Repayment API (#3119)

This commit is contained in:
logoutdhaval
2023-04-27 15:14:32 +05:30
committed by GitHub
parent 57a1cb2f8c
commit eaad5fdf0c
5 changed files with 90 additions and 0 deletions
@@ -416,4 +416,14 @@ public class InteropApiResource {
return interopService.disburseLoan(accountId, apiRequestBodyAsJson);
}
@POST
@Consumes({ MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_JSON })
@Path("transactions/{accountId}/loanrepayment")
@Operation(summary = "Disburse Loan by Account Id", description = "")
public String loanRepayment(@PathParam("accountId") @Parameter(description = "accountId") String accountId,
@Parameter(hidden = true) final String apiRequestBodyAsJson, @Context UriInfo uriInfo) {
return interopService.loanRepayment(accountId, apiRequestBodyAsJson);
}
}
@@ -81,4 +81,7 @@ public interface InteropService {
@NotNull
String disburseLoan(@NotNull String accountId, String apiRequestBodyAsJson);
@NotNull
String loanRepayment(@NotNull String accountId, String apiRequestBodyAsJson);
}
@@ -544,6 +544,19 @@ public class InteropServiceImpl implements InteropService {
return this.toApiJsonSerializer.serialize(result);
}
@Override
public @NotNull String loanRepayment(@NotNull String accountId, String apiRequestBodyAsJson) {
Loan loan = validateAndGetLoan(accountId);
Long loanId = loan.getId();
final CommandWrapperBuilder builder = new CommandWrapperBuilder().withJson(apiRequestBodyAsJson);
final CommandWrapper commandRequest = builder.loanRepaymentTransaction(loanId).build();
CommandProcessingResult result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest);
return this.toApiJsonSerializer.serialize(result);
}
private SavingsAccount validateAndGetSavingAccount(String accountId) {
SavingsAccount savingsAccount = savingsAccountRepository.findByExternalId(accountId);
if (savingsAccount == null) {