FINERACT-1920:Create Interoperation Loan Repayment API (#3119)
This commit is contained in:
+10
@@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+3
@@ -81,4 +81,7 @@ public interface InteropService {
|
||||
|
||||
@NotNull
|
||||
String disburseLoan(@NotNull String accountId, String apiRequestBodyAsJson);
|
||||
|
||||
@NotNull
|
||||
String loanRepayment(@NotNull String accountId, String apiRequestBodyAsJson);
|
||||
}
|
||||
|
||||
+13
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user