Merge pull request #5657 from eugenp/WP-ZeroBalance

Fixed Balance < 0 for Insufficient funds
This commit is contained in:
Eric Martin 2018-11-10 21:11:15 -06:00 committed by GitHub
commit 861df15d2e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -25,7 +25,7 @@ public class TellerService {
bankAccountService.transfer(fromAccontId, toAccountId, amount); bankAccountService.transfer(fromAccontId, toAccountId, amount);
auditService.log(fromAccontId, toAccountId, amount); auditService.log(fromAccontId, toAccountId, amount);
BigDecimal balance = bankAccountService.balanceOf(fromAccontId); BigDecimal balance = bankAccountService.balanceOf(fromAccontId);
if (balance.compareTo(BigDecimal.ZERO) <= 0) { if (balance.compareTo(BigDecimal.ZERO) < 0) {
throw new RuntimeException("Insufficient fund."); throw new RuntimeException("Insufficient fund.");
} }
} }
@ -35,7 +35,7 @@ public class TellerService {
bankAccountService.transfer(fromAccontId, toAccountId, amount); bankAccountService.transfer(fromAccontId, toAccountId, amount);
auditService.log(fromAccontId, toAccountId, amount); auditService.log(fromAccontId, toAccountId, amount);
BigDecimal balance = bankAccountService.balanceOf(fromAccontId); BigDecimal balance = bankAccountService.balanceOf(fromAccontId);
if (balance.compareTo(BigDecimal.ZERO) <= 0) { if (balance.compareTo(BigDecimal.ZERO) < 0) {
userTransaction.rollback(); userTransaction.rollback();
throw new RuntimeException("Insufficient fund."); throw new RuntimeException("Insufficient fund.");
} else { } else {