galovics commented on code in PR #2687:
URL: https://github.com/apache/fineract/pull/2687#discussion_r1001777473


##########
fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/api/LoansApiResource.java:
##########
@@ -786,13 +786,22 @@ public String 
calculateLoanScheduleOrSubmitLoanApplication(
     @ApiResponses({
             @ApiResponse(responseCode = "200", description = "OK", content = 
@Content(schema = @Schema(implementation = 
LoansApiResourceSwagger.PutLoansLoanIdResponse.class))) })
     public String modifyLoanApplication(@PathParam("loanId") 
@Parameter(description = "loanId") final Long loanId,
+            @QueryParam("command") @Parameter(description = "command") final 
String commandParam,
             @Parameter(hidden = true) final String apiRequestBodyAsJson) {
 
-        final CommandWrapper commandRequest = new 
CommandWrapperBuilder().updateLoanApplication(loanId).withJson(apiRequestBodyAsJson)
-                .build();
+        final CommandWrapperBuilder builder = new 
CommandWrapperBuilder().withJson(apiRequestBodyAsJson);
+        CommandWrapper commandRequest = null;
+        if (CommandParameterUtil.is(commandParam, 
LoanApiConstants.MARK_AS_FRAUD_COMMAND)) {
+            commandRequest = builder.markAsFraud(loanId).build();
+        } else {
+            commandRequest = builder.updateLoanApplication(loanId).build();
+        }
 
-        final CommandProcessingResult result = 
this.commandsSourceWritePlatformService.logCommandSource(commandRequest);
+        if (commandRequest == null) {

Review Comment:
   Is this possible? In the else case above, you always have a commandRequest.



##########
fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanWritePlatformServiceJpaRepositoryImpl.java:
##########
@@ -3303,6 +3303,36 @@ public CommandProcessingResult creditBalanceRefund(Long 
loanId, JsonCommand comm
 
     }
 
+    @Override
+    @Transactional
+    public CommandProcessingResult markLoanAsFraud(Long loanId, JsonCommand 
command) {
+        Loan loan = this.loanAssembler.assembleFrom(loanId);
+        final Map<String, Object> changes = new LinkedHashMap<>();
+
+        this.loanEventApiJsonValidator.validateMarkAsFraudLoan(command.json());

Review Comment:
   Let's do the validation at the beginning, before assemling the Loan entity. 
In that case we can save some DB load if there's a validation error.



##########
fineract-provider/src/main/resources/db/changelog/tenant/changelog-tenant.xml:
##########
@@ -81,4 +81,5 @@
     <include file="parts/0059_add_spring_batch_loan_id_list_table.xml" 
relativeToChangelogFile="true"/>
     <include file="parts/0060_add_job_name_to_command_source.xml" 
relativeToChangelogFile="true"/>
     <include file="parts/0061_add_idempotency_key_to_command_source.xml" 
relativeToChangelogFile="true"/>
+    <include file="parts/0062_add_flag_attribute_to_loan.xml" 
relativeToChangelogFile="true"/>

Review Comment:
   let's call it add_fraud_attribute_to_loan.xml



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to