Skip to content

Commit 861df15

Browse files
authored
Merge pull request eugenp#5657 from eugenp/WP-ZeroBalance
Fixed Balance < 0 for Insufficient funds
2 parents a3ff526 + 84029b0 commit 861df15

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

‎jta/src/main/java/com/baeldung/jtademo/services/TellerService.java‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public void executeTransfer(String fromAccontId, String toAccountId, BigDecimal
2525
bankAccountService.transfer(fromAccontId, toAccountId, amount);
2626
auditService.log(fromAccontId, toAccountId, amount);
2727
BigDecimal balance = bankAccountService.balanceOf(fromAccontId);
28-
if (balance.compareTo(BigDecimal.ZERO) <= 0) {
28+
if (balance.compareTo(BigDecimal.ZERO) < 0) {
2929
throw new RuntimeException("Insufficient fund.");
3030
}
3131
}
@@ -35,7 +35,7 @@ public void executeTransferProgrammaticTx(String fromAccontId, String toAccountI
3535
bankAccountService.transfer(fromAccontId, toAccountId, amount);
3636
auditService.log(fromAccontId, toAccountId, amount);
3737
BigDecimal balance = bankAccountService.balanceOf(fromAccontId);
38-
if (balance.compareTo(BigDecimal.ZERO) <= 0) {
38+
if (balance.compareTo(BigDecimal.ZERO) < 0) {
3939
userTransaction.rollback();
4040
throw new RuntimeException("Insufficient fund.");
4141
} else {

0 commit comments

Comments
 (0)