adamsaghy commented on code in PR #4837:
URL: https://github.com/apache/fineract/pull/4837#discussion_r2213159251
##########
fineract-savings/src/main/java/org/apache/fineract/portfolio/savings/domain/SavingsAccount.java:
##########
@@ -2375,6 +2411,50 @@ public void undoTransaction(final Long transactionId) {
}
}
+ protected Map<String, Object> undoActivate() {
+ final Map<String, Object> actualChanges = new LinkedHashMap<>();
+
+ final List<ApiParameterError> dataValidationErrors = new ArrayList<>();
+ final DataValidatorBuilder baseDataValidator = new
DataValidatorBuilder(dataValidationErrors)
+ .resource(depositAccountType().resourceName() +
SavingsApiConstants.undoActivateAction);
+
+ final SavingsAccountStatusType currentStatus =
SavingsAccountStatusType.fromInt(this.status);
+ if (!SavingsAccountStatusType.ACTIVE.hasStateOf(currentStatus)) {
+
baseDataValidator.reset().parameter(SavingsApiConstants.activatedOnDateParamName)
+
.failWithCodeNoParameterAddedToErrorCode("not.in.active.state");
+
+ if (!dataValidationErrors.isEmpty()) {
+ throw new
PlatformApiDataValidationException(dataValidationErrors);
+ }
+ }
+
+ final LocalDate businessDate = DateUtils.getBusinessLocalDate();
+
+ this.status = SavingsAccountStatusType.APPROVED.getValue();
+ actualChanges.put(SavingsApiConstants.statusParamName,
SavingsEnumerations.status(this.status));
+
+ this.rejectedOnDate = null;
+ this.rejectedBy = null;
+ this.withdrawnOnDate = null;
+ this.withdrawnBy = null;
+ this.closedOnDate = null;
+ this.closedBy = null;
+ this.activatedOnDate = null;
+ this.activatedBy = null;
+ this.lockedInUntilDate = null;
+
+
validateActivityNotBeforeClientOrGroupTransferDate(SavingsEvent.SAVINGS_UNOD_ACTIVATE,
businessDate);
+
+ // Undo Transactions
+ for (SavingsAccountTransaction transaction : getTransactions()) {
Review Comment:
Move this business logic out of the entity!
##########
fineract-savings/src/main/java/org/apache/fineract/portfolio/savings/domain/SavingsAccount.java:
##########
@@ -2680,6 +2760,98 @@ public Map<String, Object> activate(final AppUser
currentUser, final JsonCommand
return actualChanges;
}
+ protected Map<String, Object> undoActivate(final AppUser currentUser,
final JsonCommand command, final LocalDate operationDate) {
Review Comment:
Move out from the entity!
--
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]