balance amount in savings account showing negative balance(fixed)
withdrawl amount from savings account, showing negative balance(fixed)
This commit is contained in:
+4
-8
@@ -798,9 +798,10 @@ public class SavingsAccount extends AbstractPersistable<Long> {
|
||||
existingReversedTransactionIds.addAll(findExistingReversedTransactionIds());
|
||||
|
||||
final Money amount = Money.of(this.currency, transactionAmount);
|
||||
|
||||
final SavingsAccountTransaction transaction = SavingsAccountTransaction.deposit(this, paymentDetail, transactionDate, amount);
|
||||
this.transactions.add(transaction);
|
||||
|
||||
|
||||
this.summary.updateSummary(this.currency, this.savingsAccountTransactionSummaryWrapper, this.transactions);
|
||||
|
||||
final LocalDate today = DateUtils.getLocalDateOfTenant();
|
||||
@@ -875,9 +876,9 @@ public class SavingsAccount extends AbstractPersistable<Long> {
|
||||
|
||||
final Money transactionAmountMoney = Money.of(this.currency, transactionAmount);
|
||||
|
||||
if (isNotEnoughFundsToWithdraw(transactionAmountMoney)) {
|
||||
if (this.summary.getAccountBalance(this.currency).isLessThan(transactionAmountMoney.plus(this.withdrawalFeeAmount))) {
|
||||
//
|
||||
throw new InsufficientAccountBalanceException("transactionAmount", getAccountBalance(), transactionAmount);
|
||||
throw new InsufficientAccountBalanceException("transactionAmount", getAccountBalance(), this.withdrawalFeeAmount, transactionAmount);
|
||||
}
|
||||
|
||||
final SavingsAccountTransaction transaction = SavingsAccountTransaction.withdrawal(this, paymentDetail, transactionDate,
|
||||
@@ -906,11 +907,6 @@ public class SavingsAccount extends AbstractPersistable<Long> {
|
||||
}
|
||||
}
|
||||
|
||||
/***TODO Fixme: Annual fee seems to be added for all withdrawals?**/
|
||||
final Money annualFee = Money.of(this.currency, this.annualFeeAmount);
|
||||
SavingsAccountTransaction annualFeeTransaction = SavingsAccountTransaction.annualFee(this, transactionDate, annualFee);
|
||||
this.transactions.add(annualFeeTransaction);
|
||||
|
||||
this.summary.updateSummary(this.currency, this.savingsAccountTransactionSummaryWrapper, this.transactions);
|
||||
|
||||
final LocalDate today = DateUtils.getLocalDateOfTenant();
|
||||
|
||||
+3
-3
@@ -15,8 +15,8 @@ import org.mifosplatform.infrastructure.core.exception.AbstractPlatformDomainRul
|
||||
*/
|
||||
public class InsufficientAccountBalanceException extends AbstractPlatformDomainRuleException {
|
||||
|
||||
public InsufficientAccountBalanceException(final String paramName, final BigDecimal accountBalance, final BigDecimal withdrawalRequested) {
|
||||
super("error.msg.savingsaccount.transaction.insufficient.account.balance", "Insufficient account balance.", paramName,
|
||||
accountBalance, withdrawalRequested);
|
||||
public InsufficientAccountBalanceException(final String paramName, final BigDecimal accountBalance, final BigDecimal withdrawalFee, final BigDecimal transactionAmount) {
|
||||
super(withdrawalFee != null? "error.msg.savingsaccount.transaction.insufficient.account.balance.withdraw" : "error.msg.savingsaccount.transaction.insufficient.account.balance",
|
||||
"Insufficient account balance.", paramName, accountBalance, withdrawalFee, transactionAmount);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user