/**
  * Create new transaction
  *
  * @param Request $request
  * @return Response
  */
 public function transactionCreateAction(Request $request)
 {
     $transaction = new Transaction();
     $form = $this->createForm(new TransactionFormType(), $transaction);
     $form->bind($request);
     if ($form->isValid()) {
         $now = new \DateTime();
         $date = $this->dateFormat($request->get('date'));
         $txDate = $this->dateFormat($transaction->getTxDate(), true);
         $settleDate = $this->dateFormat($transaction->getSettleDate(), true);
         $transaction->setStatus(Transaction::STATUS_NOT_POSTED);
         $transaction->setImportDate($date->format('Y-m-d'));
         $transaction->setCreated($now->format('Y-m-d'));
         $transaction->setTxDate($txDate->format('Y-m-d'));
         $transaction->setSettleDate($settleDate->format('Y-m-d'));
         $user = $this->getUser();
         $user instanceof UserInterface && $transaction->setUsername($user->getUsername());
         $dm = $this->get('doctrine_mongodb')->getManager();
         $dm->persist($transaction);
         $dm->flush();
         return new JsonResponse($this->get('wealthbot_admin.pas_interface.transactions')->toArray($transaction));
     } else {
         $errors = new FormErrorBag($form);
         return new Response($errors->toJson(), 400);
     }
 }
 /**
  * @SecureParam(name="billingSpec", permissions="EDIT")
  * @param BillingSpec $billingSpec
  * @return Response
  */
 public function updateAction(BillingSpec $billingSpec)
 {
     $form = $this->createForm(new BillingSpecFormType(), $billingSpec);
     $form->bind($this->getRequest());
     if ($form->isValid()) {
         $em = $this->getDoctrine()->getManager();
         $em->persist($billingSpec);
         $em->flush();
         return new Response();
     } else {
         $errors = new FormErrorBag($form);
         return new Response($errors->toJson(), 400);
     }
 }