private OperationLocation getOperationLocation(long operationLocationNumber) throws BusinessException { OperationLocation operationLocation = database.getOperationLocation(operationLocationNumber); if (operationLocation == null) { throw new BusinessException("exception.invalid.operation.location"); } return operationLocation; }
@Override public EnvelopeDeposit depositEnvelope( long operationLocation, long branch, long accountNumber, long envelope, double amount) throws BusinessException { CurrentAccount currentAccount = readCurrentAccount(branch, accountNumber); EnvelopeDeposit deposit = currentAccount.depositEnvelope(getOperationLocation(operationLocation), envelope, amount); database.save(deposit); return deposit; }
private CurrentAccount readCurrentAccount(long branch, long accountNumber) throws BusinessException { CurrentAccountId id = new CurrentAccountId(new Branch(branch), accountNumber); CurrentAccount currentAccount = database.getCurrentAccount(id); if (currentAccount == null) { throw new BusinessException("exception.inexistent.account"); } return currentAccount; }