@Override public void removeBranchBankAccount(final BranchBankAccount branchBankAccount) throws BusinessException, SystemException { final Collection<BranchBankAccountTransaction> branchBankAccountTransactions = this.branchBankAccountTransactionService .findBranchBankAccountTransactionsByBranchBankAccountId(branchBankAccount.getId()); if (branchBankAccountTransactions != null && branchBankAccountTransactions.size() > 0) { throw new ApplicationException( "Bank account cannot be deleted as transactions have be found."); } this.branchBankAccountDao.remove(branchBankAccount); }
@Override public BranchBankAccount processBranchBankAccountTransaction( final Long branchBankAccountId, final BankAccountTransactionTypeConstant accountTransactionTypeConstant, final Double amount, final String description, final String externalTransactionNumber, final Date transactionDate) { if (amount == null) { throw new ApplicationException(" Transaction amount cannot be null."); } final BranchBankAccount branchBankAccount = this.branchBankAccountDao.findById(branchBankAccountId); if (transactionDate != null) { if (transactionDate.before(branchBankAccount.getAccountOpeningDate())) { throw new ApplicationException( "Transaction date " + transactionDate + " is before account opening date " + branchBankAccount.getAccountOpeningDate()); } } final String transactionNr = this.sequenceGeneratorService.getNextTransactionNumberForBankAccountTransaction(); final BranchBankAccountTransaction branchBankAccountTransaction = new BranchBankAccountTransaction(); branchBankAccountTransaction.setAmount(amount); branchBankAccountTransaction.setBranchBankAccount(branchBankAccount); branchBankAccountTransaction.setDescription( accountTransactionTypeConstant.getLabel() + (description != null ? ("/" + description) : "")); branchBankAccountTransaction.setTransactionDate( transactionDate != null ? transactionDate : DateUtil.getSystemDate()); branchBankAccountTransaction.setTransactionType(accountTransactionTypeConstant); branchBankAccountTransaction.setTransactionNr(transactionNr); branchBankAccountTransaction.setExternalTransactionNr(externalTransactionNumber); this.branchBankAccountTransactionService.saveBranchBankAccountTransaction( branchBankAccountTransaction); return branchBankAccount; }