You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@fineract.apache.org by jyothsnag <gi...@git.apache.org> on 2016/08/16 08:42:42 UTC

[GitHub] incubator-fineract pull request #209: feature implementation of undoreject a...

GitHub user jyothsnag opened a pull request:

    https://github.com/apache/incubator-fineract/pull/209

    feature implementation of undoreject and undowithdrawal for client

    

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/jyothsnag/incubator-fineract 1218

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/incubator-fineract/pull/209.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #209
    
----
commit 58bbaa2e2b25a0aad984f1d276a21c4dd8fdd54b
Author: jyothsnag <jy...@confluxtechnologies.com>
Date:   2016-08-12T10:14:07Z

    feature implementation of undoreject and undowithdrawal for client

----


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-fineract pull request #209: feature implementation of undoreject a...

Posted by asfgit <gi...@git.apache.org>.
Github user asfgit closed the pull request at:

    https://github.com/apache/incubator-fineract/pull/209


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-fineract pull request #209: feature implementation of undoreject a...

Posted by rajuan <gi...@git.apache.org>.
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-fineract pull request #209: feature implementation of undoreject a...

Posted by nazeer1100126 <gi...@git.apache.org>.
Github user nazeer1100126 commented on a diff in the pull request:

    https://github.com/apache/incubator-fineract/pull/209#discussion_r74900872
  
    --- 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 --
    
    This validation logic can be moved to validator


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-fineract pull request #209: feature implementation of undoreject a...

Posted by nazeer1100126 <gi...@git.apache.org>.
Github user nazeer1100126 commented on a diff in the pull request:

    https://github.com/apache/incubator-fineract/pull/209#discussion_r74900829
  
    --- 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()) {
    --- End diff --
    
    This validation logic can be moved to validator


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-fineract pull request #209: feature implementation of undoreject a...

Posted by rajuan <gi...@git.apache.org>.
Github user rajuan commented on a diff in the pull request:

    https://github.com/apache/incubator-fineract/pull/209#discussion_r74913738
  
    --- 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()) {
    --- 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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---