Ejemplo n.º 1
0
 /**
  * Возвращает операцию начального остатка
  * @return Operation
  */
 private function getBalanceOperation()
 {
     if (is_null($this->balanceOperation)) {
         $params = array($this->getId(), Operation::TYPE_BALANCE);
         $this->balanceOperation = Doctrine_Query::create()->from('Operation o')->andWhere("account_id = ? AND type = ?", $params)->fetchOne();
         if (!$this->balanceOperation) {
             $params = array('user_id' => $this->getUserId(), 'amount' => 0, 'date' => '0000-00-00', 'category_id' => NULL, 'type' => Operation::TYPE_BALANCE, 'comment' => 'Начальный остаток', 'accepted' => 1);
             $this->balanceOperation = new Operation();
             $this->balanceOperation->fromArray($params);
         }
         $this->balanceOperation->setAccount($this);
     }
     return $this->balanceOperation;
 }