From 84029b02816c8c76b1a0c69bae2fc20670e7ee64 Mon Sep 17 00:00:00 2001 From: eric-martin Date: Sat, 10 Nov 2018 21:05:53 -0600 Subject: [PATCH] Fixed Balance < 0 for Insufficient funds --- .../java/com/baeldung/jtademo/services/TellerService.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/jta/src/main/java/com/baeldung/jtademo/services/TellerService.java b/jta/src/main/java/com/baeldung/jtademo/services/TellerService.java index d3bd80a2ee..f79238e66a 100644 --- a/jta/src/main/java/com/baeldung/jtademo/services/TellerService.java +++ b/jta/src/main/java/com/baeldung/jtademo/services/TellerService.java @@ -25,7 +25,7 @@ public class TellerService { bankAccountService.transfer(fromAccontId, toAccountId, amount); auditService.log(fromAccontId, toAccountId, amount); BigDecimal balance = bankAccountService.balanceOf(fromAccontId); - if (balance.compareTo(BigDecimal.ZERO) <= 0) { + if (balance.compareTo(BigDecimal.ZERO) < 0) { throw new RuntimeException("Insufficient fund."); } } @@ -35,7 +35,7 @@ public class TellerService { bankAccountService.transfer(fromAccontId, toAccountId, amount); auditService.log(fromAccontId, toAccountId, amount); BigDecimal balance = bankAccountService.balanceOf(fromAccontId); - if (balance.compareTo(BigDecimal.ZERO) <= 0) { + if (balance.compareTo(BigDecimal.ZERO) < 0) { userTransaction.rollback(); throw new RuntimeException("Insufficient fund."); } else {