public function createSimpleExpenseTransaction(Account $expenseAccount, Account $assetAccount, $amount, $date)
 {
     $transaction = new Transaction();
     $description = $this->translator->trans("transaction.description.simple_expense", array("%account_to%" => $expenseAccount->getName()), 'Finance');
     $transaction->setDescription($description);
     $transaction->setCircuit(Transaction::CIRCUIT_TWO);
     $transaction->setDate($date);
     $expenseEntry = new JournalEntry();
     $expenseEntry->setAccount($expenseAccount);
     $expenseEntry->setTransaction($transaction);
     $expenseEntry->setDebit($amount);
     $expenseEntry->setDate($date);
     $transaction->addJournalEntry($expenseEntry);
     $assetEntry = new JournalEntry();
     $assetEntry->setAccount($assetAccount);
     $assetEntry->setCredit($amount);
     $assetEntry->setDate($date);
     $assetEntry->setTransaction($transaction);
     $transaction->addJournalEntry($assetEntry);
     /* persist */
     $this->transactionRepository->save($transaction);
     return $transaction;
 }
 /**
  * Deletes a Account entity.
  *
  * @Route("/{id}/delete", name="finance_account_delete", requirements={"id"="\d+"})
  * @Method("DELETE")
  */
 public function deleteAction(Account $account, Request $request)
 {
     $form = $this->createDeleteForm($account->getId(), 'finance_account_delete');
     if ($form->handleRequest($request)->isValid()) {
         $em = $this->getDoctrine()->getManager();
         $em->remove($account);
         $em->flush();
     }
     return $this->redirect($this->generateUrl('finance_account'));
 }