diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/domain/SavingsAccount.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/domain/SavingsAccount.java index ee4c6d4e1..447127344 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/domain/SavingsAccount.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/domain/SavingsAccount.java @@ -803,7 +803,9 @@ public class SavingsAccount extends AbstractPersistable { final Money annualFee = Money.of(this.currency, this.annualFeeAmount); final SavingsAccountTransaction annualFeeTransaction = SavingsAccountTransaction.annualFee(this, annualFeeTransactionDate, annualFee); this.transactions.add(annualFeeTransaction); - + + validateAccountBalanceDoesNotBecomeNegative(SavingsApiConstants.applyAnnualFeeTransactionAction); + this.summary.updateSummary(this.currency, this.savingsAccountTransactionSummaryWrapper, this.transactions); calculateInterestUsing(mc, today); diff --git a/mifosng-provider/src/main/java/org/mifosplatform/scheduledjobs/service/ScheduledJobRunnerServiceImpl.java b/mifosng-provider/src/main/java/org/mifosplatform/scheduledjobs/service/ScheduledJobRunnerServiceImpl.java index 00a37e310..88e1449b1 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/scheduledjobs/service/ScheduledJobRunnerServiceImpl.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/scheduledjobs/service/ScheduledJobRunnerServiceImpl.java @@ -6,7 +6,10 @@ package org.mifosplatform.scheduledjobs.service; import java.util.Collection; +import java.util.List; +import org.mifosplatform.infrastructure.core.data.ApiParameterError; +import org.mifosplatform.infrastructure.core.exception.PlatformApiDataValidationException; import org.mifosplatform.infrastructure.core.service.RoutingDataSourceServiceFactory; import org.mifosplatform.infrastructure.core.service.ThreadLocalContextUtil; import org.mifosplatform.infrastructure.jobs.annotation.CronTarget; @@ -204,8 +207,15 @@ public class ScheduledJobRunnerServiceImpl implements ScheduledJobRunnerService .retrieveAccountsWithAnnualFeeDue(); for (SavingsAccountAnnualFeeData savingsAccountReference : annualFeeData) { - this.savingsAccountWritePlatformService.applyAnnualFee(savingsAccountReference.getId(), - savingsAccountReference.getNextAnnualFeeDueDate()); + try{ + this.savingsAccountWritePlatformService.applyAnnualFee(savingsAccountReference.getId(), + savingsAccountReference.getNextAnnualFeeDueDate()); + } catch (PlatformApiDataValidationException e) { + List errors = e.getErrors(); + for(ApiParameterError error : errors){ + logger.error("Apply annual fee failed for account:"+savingsAccountReference.getAccountNo()+" with message "+error.getDeveloperMessage()); + } + } } logger.info(ThreadLocalContextUtil.getTenant().getName() + ": Savings accounts affected by update: " + annualFeeData.size());