Search in sources :

Example 21 with CommandWrapperBuilder

use of org.apache.fineract.commands.service.CommandWrapperBuilder in project fineract by apache.

the class SmsApiResource method update.

@PUT
@Path("{resourceId}")
public String update(@PathParam("resourceId") final Long resourceId, final String apiRequestBodyAsJson) {
    final CommandWrapper commandRequest = new CommandWrapperBuilder().updateSms(resourceId).withJson(apiRequestBodyAsJson).build();
    final CommandProcessingResult result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest);
    return this.toApiJsonSerializer.serialize(result);
}
Also used : CommandWrapperBuilder(org.apache.fineract.commands.service.CommandWrapperBuilder) CommandWrapper(org.apache.fineract.commands.domain.CommandWrapper) CommandProcessingResult(org.apache.fineract.infrastructure.core.data.CommandProcessingResult) Path(javax.ws.rs.Path) PUT(javax.ws.rs.PUT)

Example 22 with CommandWrapperBuilder

use of org.apache.fineract.commands.service.CommandWrapperBuilder in project fineract by apache.

the class LoanTransactionsApiResource method executeLoanTransaction.

@POST
@Consumes({ MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_JSON })
@Operation(summary = "Make a Repayment | Make a Refund of an Active Loan by Cash | Foreclosure of an Active Loan | Waive Interest | Write-off Loan | Make Recovery Payment | Undo Loan Write-off Transaction", description = "Make Recovery Payment:\n\n" + "This API allows collecting recovery payments for written-off loans")
@RequestBody(required = true, content = @Content(schema = @Schema(implementation = LoanTransactionsApiResourceSwagger.PostLoansLoanIdTransactionsRequest.class)))
@ApiResponses({ @ApiResponse(responseCode = "200", description = "OK", content = @Content(schema = @Schema(implementation = LoanTransactionsApiResourceSwagger.PostLoansLoanIdTransactionsResponse.class))) })
public String executeLoanTransaction(@PathParam("loanId") @Parameter(description = "loanId") final Long loanId, @QueryParam("command") @Parameter(description = "command") final String commandParam, @Parameter(hidden = true) final String apiRequestBodyAsJson) {
    final CommandWrapperBuilder builder = new CommandWrapperBuilder().withJson(apiRequestBodyAsJson);
    CommandProcessingResult result = null;
    if (is(commandParam, "repayment")) {
        final CommandWrapper commandRequest = builder.loanRepaymentTransaction(loanId).build();
        result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest);
    } else if (is(commandParam, "waiveinterest")) {
        final CommandWrapper commandRequest = builder.waiveInterestPortionTransaction(loanId).build();
        result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest);
    } else if (is(commandParam, "writeoff")) {
        final CommandWrapper commandRequest = builder.writeOffLoanTransaction(loanId).build();
        result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest);
    } else if (is(commandParam, "close-rescheduled")) {
        final CommandWrapper commandRequest = builder.closeLoanAsRescheduledTransaction(loanId).build();
        result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest);
    } else if (is(commandParam, "close")) {
        final CommandWrapper commandRequest = builder.closeLoanTransaction(loanId).build();
        result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest);
    } else if (is(commandParam, "undowriteoff")) {
        final CommandWrapper commandRequest = builder.undoWriteOffLoanTransaction(loanId).build();
        result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest);
    } else if (is(commandParam, "recoverypayment")) {
        final CommandWrapper commandRequest = builder.loanRecoveryPaymentTransaction(loanId).build();
        result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest);
    } else if (is(commandParam, "refundByCash")) {
        final CommandWrapper commandRequest = builder.refundLoanTransactionByCash(loanId).build();
        result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest);
    } else if (is(commandParam, "foreclosure")) {
        final CommandWrapper commandRequest = builder.loanForeclosure(loanId).build();
        result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest);
    }
    if (result == null) {
        throw new UnrecognizedQueryParamException("command", commandParam);
    }
    return this.toApiJsonSerializer.serialize(result);
}
Also used : CommandWrapperBuilder(org.apache.fineract.commands.service.CommandWrapperBuilder) UnrecognizedQueryParamException(org.apache.fineract.infrastructure.core.exception.UnrecognizedQueryParamException) CommandProcessingResult(org.apache.fineract.infrastructure.core.data.CommandProcessingResult) CommandWrapper(org.apache.fineract.commands.domain.CommandWrapper) POST(javax.ws.rs.POST) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces) Operation(io.swagger.v3.oas.annotations.Operation) ApiResponses(io.swagger.v3.oas.annotations.responses.ApiResponses) RequestBody(io.swagger.v3.oas.annotations.parameters.RequestBody)

Example 23 with CommandWrapperBuilder

use of org.apache.fineract.commands.service.CommandWrapperBuilder in project fineract by apache.

the class LoansApiResource method stateTransitions.

@POST
@Path("{loanId}")
@Consumes({ MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_JSON })
@Operation(summary = "Approve Loan Application | Recover Loan Guarantee | Undo Loan Application Approval | Assign a Loan Officer | Unassign a Loan Officer | Reject Loan Application | Applicant Withdraws from Loan Application | Disburse Loan Disburse Loan To Savings Account | Undo Loan Disbursal", description = "Approve Loan Application:\n" + "Mandatory Fields: approvedOnDate\n" + "Optional Fields: approvedLoanAmount and expectedDisbursementDate\n" + "Approves the loan application\n\n" + "Recover Loan Guarantee:\n" + "Recovers the loan guarantee\n\n" + "Undo Loan Application Approval:\n" + "Undoes the Loan Application Approval\n\n" + "Assign a Loan Officer:\n" + "Allows you to assign Loan Officer for existing Loan.\n\n" + "Unassign a Loan Officer:\n" + "Allows you to unassign the Loan Officer.\n\n" + "Reject Loan Application:\n" + "Mandatory Fields: rejectedOnDate\n" + "Allows you to reject the loan application\n\n" + "Applicant Withdraws from Loan Application:\n" + "Mandatory Fields: withdrawnOnDate\n" + "Allows the applicant to withdraw the loan application\n\n" + "Disburse Loan:\n" + "Mandatory Fields: actualDisbursementDate\n" + "Optional Fields: transactionAmount and fixedEmiAmount\n" + "Disburses the Loan\n\n" + "Disburse Loan To Savings Account:\n" + "Mandatory Fields: actualDisbursementDate\n" + "Optional Fields: transactionAmount and fixedEmiAmount\n" + "Disburses the loan to Saving Account\n\n" + "Undo Loan Disbursal:\n" + "Undoes the Loan Disbursal\n" + "Showing request and response for Assign a Loan Officer")
@RequestBody(required = true, content = @Content(schema = @Schema(implementation = LoansApiResourceSwagger.PostLoansLoanIdRequest.class)))
@ApiResponses({ @ApiResponse(responseCode = "200", description = "OK", content = @Content(schema = @Schema(implementation = LoansApiResourceSwagger.PostLoansLoanIdResponse.class))) })
public String stateTransitions(@PathParam("loanId") @Parameter(description = "loanId") final Long loanId, @QueryParam("command") @Parameter(description = "command") final String commandParam, @Parameter(hidden = true) final String apiRequestBodyAsJson) {
    final CommandWrapperBuilder builder = new CommandWrapperBuilder().withJson(apiRequestBodyAsJson);
    CommandProcessingResult result = null;
    if (is(commandParam, "reject")) {
        final CommandWrapper commandRequest = builder.rejectLoanApplication(loanId).build();
        result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest);
    } else if (is(commandParam, "withdrawnByApplicant")) {
        final CommandWrapper commandRequest = builder.withdrawLoanApplication(loanId).build();
        result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest);
    } else if (is(commandParam, "approve")) {
        final CommandWrapper commandRequest = builder.approveLoanApplication(loanId).build();
        result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest);
    } else if (is(commandParam, "disburse")) {
        final CommandWrapper commandRequest = builder.disburseLoanApplication(loanId).build();
        result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest);
    } else if (is(commandParam, "disburseToSavings")) {
        final CommandWrapper commandRequest = builder.disburseLoanToSavingsApplication(loanId).build();
        result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest);
    }
    if (is(commandParam, "undoapproval")) {
        final CommandWrapper commandRequest = builder.undoLoanApplicationApproval(loanId).build();
        result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest);
    } else if (is(commandParam, "undodisbursal")) {
        final CommandWrapper commandRequest = builder.undoLoanApplicationDisbursal(loanId).build();
        result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest);
    } else if (is(commandParam, "undolastdisbursal")) {
        final CommandWrapper commandRequest = builder.undoLastDisbursalLoanApplication(loanId).build();
        result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest);
    }
    if (is(commandParam, "assignloanofficer")) {
        final CommandWrapper commandRequest = builder.assignLoanOfficer(loanId).build();
        result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest);
    } else if (is(commandParam, "unassignloanofficer")) {
        final CommandWrapper commandRequest = builder.unassignLoanOfficer(loanId).build();
        result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest);
    } else if (is(commandParam, "recoverGuarantees")) {
        final CommandWrapper commandRequest = new CommandWrapperBuilder().recoverFromGuarantor(loanId).build();
        result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest);
    }
    if (result == null) {
        throw new UnrecognizedQueryParamException("command", commandParam);
    }
    return this.toApiJsonSerializer.serialize(result);
}
Also used : CommandWrapperBuilder(org.apache.fineract.commands.service.CommandWrapperBuilder) UnrecognizedQueryParamException(org.apache.fineract.infrastructure.core.exception.UnrecognizedQueryParamException) CommandProcessingResult(org.apache.fineract.infrastructure.core.data.CommandProcessingResult) CommandWrapper(org.apache.fineract.commands.domain.CommandWrapper) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces) Operation(io.swagger.v3.oas.annotations.Operation) ApiResponses(io.swagger.v3.oas.annotations.responses.ApiResponses) RequestBody(io.swagger.v3.oas.annotations.parameters.RequestBody)

Example 24 with CommandWrapperBuilder

use of org.apache.fineract.commands.service.CommandWrapperBuilder in project fineract by apache.

the class LoansApiResource method deleteLoanApplication.

@DELETE
@Path("{loanId}")
@Consumes({ MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_JSON })
@Operation(summary = "Delete a Loan Application", description = "Note: Only loans in \"Submitted and awaiting approval\" status can be deleted.")
@ApiResponses({ @ApiResponse(responseCode = "200", description = "OK", content = @Content(schema = @Schema(implementation = LoansApiResourceSwagger.DeleteLoansLoanIdResponse.class))) })
public String deleteLoanApplication(@PathParam("loanId") @Parameter(description = "loanId") final Long loanId) {
    final CommandWrapper commandRequest = new CommandWrapperBuilder().deleteLoanApplication(loanId).build();
    final CommandProcessingResult result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest);
    return this.toApiJsonSerializer.serialize(result);
}
Also used : CommandWrapperBuilder(org.apache.fineract.commands.service.CommandWrapperBuilder) CommandWrapper(org.apache.fineract.commands.domain.CommandWrapper) CommandProcessingResult(org.apache.fineract.infrastructure.core.data.CommandProcessingResult) Path(javax.ws.rs.Path) DELETE(javax.ws.rs.DELETE) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces) Operation(io.swagger.v3.oas.annotations.Operation) ApiResponses(io.swagger.v3.oas.annotations.responses.ApiResponses)

Example 25 with CommandWrapperBuilder

use of org.apache.fineract.commands.service.CommandWrapperBuilder in project fineract by apache.

the class SelfBeneficiariesTPTApiResource method update.

@PUT
@Path("{beneficiaryId}")
@Consumes({ MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_JSON })
@Operation(summary = "Update TPT Beneficiary", description = "Api to update third party beneficiary linked to current user.\n" + "\n" + "Example Requests:\n" + "\n" + "/self/beneficiaries/tpt/{beneficiaryId}\n\n" + "Optional Fields: name, transferLimit")
@RequestBody(required = true, content = @Content(schema = @Schema(implementation = SelfBeneficiariesTPTApiResourceSwagger.PutSelfBeneficiariesTPTBeneficiaryIdRequest.class)))
@ApiResponses({ @ApiResponse(responseCode = "200", description = "OK", content = @Content(schema = @Schema(implementation = SelfBeneficiariesTPTApiResourceSwagger.PutSelfBeneficiariesTPTBeneficiaryIdResponse.class))) })
public String update(@PathParam("beneficiaryId") @Parameter(description = "beneficiaryId") final Long beneficiaryId, @Parameter(hidden = true) final String apiRequestBodyAsJson) {
    final CommandWrapper commandRequest = new CommandWrapperBuilder().updateSelfServiceBeneficiaryTPT(beneficiaryId).withJson(apiRequestBodyAsJson).build();
    final CommandProcessingResult result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest);
    return this.toApiJsonSerializer.serialize(result);
}
Also used : CommandWrapperBuilder(org.apache.fineract.commands.service.CommandWrapperBuilder) CommandWrapper(org.apache.fineract.commands.domain.CommandWrapper) CommandProcessingResult(org.apache.fineract.infrastructure.core.data.CommandProcessingResult) Path(javax.ws.rs.Path) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces) Operation(io.swagger.v3.oas.annotations.Operation) PUT(javax.ws.rs.PUT) ApiResponses(io.swagger.v3.oas.annotations.responses.ApiResponses) RequestBody(io.swagger.v3.oas.annotations.parameters.RequestBody)

Aggregations

CommandWrapperBuilder (org.apache.fineract.commands.service.CommandWrapperBuilder)309 CommandWrapper (org.apache.fineract.commands.domain.CommandWrapper)307 CommandProcessingResult (org.apache.fineract.infrastructure.core.data.CommandProcessingResult)299 Produces (javax.ws.rs.Produces)253 Consumes (javax.ws.rs.Consumes)251 Operation (io.swagger.v3.oas.annotations.Operation)199 ApiResponses (io.swagger.v3.oas.annotations.responses.ApiResponses)193 Path (javax.ws.rs.Path)184 RequestBody (io.swagger.v3.oas.annotations.parameters.RequestBody)152 POST (javax.ws.rs.POST)121 PUT (javax.ws.rs.PUT)89 DELETE (javax.ws.rs.DELETE)61 GsonBuilder (com.google.gson.GsonBuilder)31 DateSerializer (org.apache.fineract.infrastructure.bulkimport.importhandler.helper.DateSerializer)30 UnrecognizedQueryParamException (org.apache.fineract.infrastructure.core.exception.UnrecognizedQueryParamException)28 Cell (org.apache.poi.ss.usermodel.Cell)13 Sheet (org.apache.poi.ss.usermodel.Sheet)13 JsonObject (com.google.gson.JsonObject)11 JsonElement (com.google.gson.JsonElement)10 ApiRequestJsonSerializationSettings (org.apache.fineract.infrastructure.core.serialization.ApiRequestJsonSerializationSettings)7