public String performBill() { sender.setCheckingaccount(sender.getCheckingaccount() - amount); recipient.setCheckingaccount(recipient.getCheckingaccount() + amount); em.merge(sender); em.merge(recipient); return sender.getCheckingaccount().toString(); }
@Override public boolean setAmount(Long amount, String username) { sender = (UserEntity) em.createNamedQuery("UserEntity.findByUsername") .setParameter("username", username) .getSingleResult(); if (amount > sender.getCheckingaccount()) { System.out.println("You don't have enough money"); return false; } else { this.amount = amount; return true; } }
public void checkBillDetails() throws IncorrectBillDetailsException { Long sendAmount = sender.getCheckingaccount(); if ((sendAmount - amount) < 0) throw new IncorrectBillDetailsException( "Error: Bill details not correct. Check the amount of the transaction"); }