public function getSaldo(BankAccount $bankAccount) { $repo = $this->entityManager->getRepository('HomefinanceBundle:Transaction'); $transactions = $repo->findBy(array('administration' => $bankAccount->getAdministration(), 'bank_account' => $bankAccount)); $total = (double) $bankAccount->getStartingBalance(); foreach ($transactions as $t) { $total = $total + $t->getAmount(); } return $total; }