Github user rajuan commented on a diff in the pull request:

    https://github.com/apache/incubator-fineract/pull/209#discussion_r74913746
  
    --- Diff: 
fineract-provider/src/main/java/org/apache/fineract/portfolio/client/service/ClientWritePlatformServiceJpaRepositoryImpl.java
 ---
    @@ -844,4 +844,59 @@ public CommandProcessingResult reActivateClient(Long 
entityId, JsonCommand comma
                     .withEntityId(entityId) //
                     .build();
         }
    -}
    \ No newline at end of file
    +
    +   @Override
    +   public CommandProcessingResult undoRejection(Long entityId, JsonCommand 
command) {
    +           final AppUser currentUser = this.context.authenticatedUser();
    +           this.fromApiJsonDeserializer.validateUndoRejection(command);
    +
    +           final Client client = 
this.clientRepository.findOneWithNotFoundDetection(entityId);
    +           final LocalDate undoRejectDate = command
    +                           
.localDateValueOfParameterNamed(ClientApiConstants.reopenedDateParamName);
    +
    +           if (!client.isRejected()) {
    +                   final String errorMessage = "only rejected clients may 
be reactivated.";
    +                   throw new 
InvalidClientStateTransitionException("undorejection", 
"on.nonrejected.account", errorMessage);
    +           } else if (client.getRejectedDate().isAfter(undoRejectDate)) {
    +                   final String errorMessage = "The client reactivation 
date cannot be before the client rejected date.";
    +                   throw new 
InvalidClientStateTransitionException("reopened", 
"date.cannot.before.client.rejected.date",
    +                                   errorMessage, undoRejectDate, 
client.getRejectedDate());
    +           }
    +
    +           client.reOpened(currentUser, undoRejectDate.toDate());
    +           this.clientRepository.saveAndFlush(client);
    +
    +           return new CommandProcessingResultBuilder() //
    +                           .withCommandId(command.commandId()) //
    +                           .withClientId(entityId) //
    +                           .withEntityId(entityId) //
    +                           .build();
    +   }
    +
    +   @Override
    +   public CommandProcessingResult undoWithdrawal(Long entityId, 
JsonCommand command) {
    +           final AppUser currentUser = this.context.authenticatedUser();
    +           this.fromApiJsonDeserializer.validateUndoWithDrawn(command);
    +
    +           final Client client = 
this.clientRepository.findOneWithNotFoundDetection(entityId);
    +           final LocalDate undoWithdrawalDate = command
    +                           
.localDateValueOfParameterNamed(ClientApiConstants.reopenedDateParamName);
    +
    +           if (!client.isWithdrawn()) {
    --- End diff --
    
    I do not think moving the validation to validator is absolutely required 
here. We are still avoiding entity creation, which is a good benefit.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

Reply via email to