示例#1
0
 protected function createTransactionFromRow($row, Administration $administration)
 {
     $transaction = new Transaction();
     $transaction->setAdministration($administration);
     $bankAccount = $this->bankAccountManager->findBankAccount($row[1], $administration);
     if (!$bankAccount || $row[1] != $bankAccount->getIban()) {
         throw new InvalidBankAccountException();
     }
     $transaction->setBankAccount($bankAccount);
     if ($row[9] != 'EUR') {
         throw new InvalidCurrencyException();
     }
     $transaction->setDate(new \DateTime($row[0]));
     //boekdatum
     $amount = (double) $row[10];
     $transaction->setAmount($amount);
     $transaction->setIban($row[2]);
     $transaction->setName($row[3]);
     $description = $row[16] . "\r\n" . $row[17];
     $description = trim($description);
     $transaction->setDescription($description);
     if (empty($transaction->getName())) {
         $transaction->setName(strtok($description, "\r\n"));
     }
     $transaction->setSourceData(json_encode($row));
     $transaction->setSourceId(md5($row[11] . $row[15]));
     return $transaction;
 }
 /**
  * @Route("/transactions/new", name="transaction_new")
  * @param Request $request
  * @return string
  */
 public function newAction(Request $request)
 {
     $administration = $this->checkCurrentAdministration(Permission::EDIT);
     $transaction = new Transaction();
     $transaction->setAdministration($administration);
     $transaction->setDate(new \DateTime());
     return $this->edit($transaction, $request);
 }