Ejemplo n.º 1
0
 /**
  * dopasowyje dluznika do transakcji wyciagu
  * 
  * @param Statement $statement
  * @param bool $replace TRUE jezeli zastopic przypisanych kontrahentow
  */
 public function mergeContractors(Statement $statement, $replace = false)
 {
     $paginator = $statement->getTransactions()->getPaginator();
     if ($paginator->getCurrentPageNumber() == $paginator->getPages()->first) {
         /* resetuje sesje dla pakietu żądań -> paginacji */
         $this->getWarningManager()->cleanWarnings();
     }
     foreach ($statement->getTransactions() as $transaction) {
         /* @var $transaction \Vindication\BankStatement\Entity\Transaction */
         if (null !== $transaction->get('kontrahent_id') && !$replace) {
             $this->getWarningManager()->addWarning()->setType(Warning::TYPE_NO_CONTRACTOR);
             continue;
         }
         $accountNumber = $transaction->getSubAccountNo() ?: $transaction->getAccountNo();
         if (empty($accountNumber)) {
             $this->getWarningManager()->addWarning()->setType(Warning::TYPE_NO_ACCOUNT);
             continue;
         }
         $contractor = $this->getService('ContractorMapper')->findByBankAccountNumber($accountNumber, $statement);
         if (null !== $contractor) {
             /* @var $contractor \Vindication\Contractor\Entity\Contractor */
             $transaction->setContractor($contractor)->getEntityManager()->save();
         } else {
             $this->getWarningManager()->addWarning()->setType(Warning::TYPE_NO_CONTRACTOR);
         }
     }
 }
Ejemplo n.º 2
0
 /**
  * 
  * @param \Vindication\BankStatement\Entity\Statement $statement
  * @param closure $closure
  * @return \Vindication\BankStatement\Iterator\Transactions
  */
 public function getTransactions(Entity\Statement $statement, $closure = null)
 {
     $select = $this->getAdapter()->select()->from(array('o' => 'wyciag_bankowy_operacja', 's.*'))->joinLeft(array('d' => 'dluznicy'), 'd.PK_dluznicy = o.kontrahent_id', array('d.*'))->where('s.id =?', $statement->getID());
     $this->addFilters($select);
     if (null === $this->getRequestData()->getSort()) {
         $select->order(array('o.id ASC'));
     }
     if (is_callable($closure)) {
         $closure($select);
     }
     $iterator = new Iterator\Transactions();
     $iterator->setPaginator($paginator = $this->getPaginator($select));
     foreach ($paginator as $result) {
         $iterator->append($transaction = new Entity\Transaction($result));
         if ($transaction->get('kontrahent_id')) {
             $transaction->setContractor(new Contractor($result));
         }
     }
     return $iterator;
 }