/**
  * Удаляет операцию перевода на финцель
  * @param int $id
  * @return bool
  */
 function deleteTargetOperation($id = 0)
 {
     $tr_id = $this->db->select("SELECT target_id FROM target_bill WHERE id=?", $id);
     $this->db->query("DELETE FROM target_bill WHERE id=? AND user_id=?", $id, $this->_user->getId());
     $targ = new Targets_Model();
     $targ->staticTargetUpdate($tr_id[0]['target_id']);
     $this->_user->initUserTargets();
     $this->_user->save();
     return true;
 }
 /**
  * Тест перевода на долговой счёт
  */
 public function testDebtTransfer()
 {
     $this->_prepareOperation();
     // Долговой счёт
     $options = array('user_id' => $this->userId, 'account_name' => 'Debt account', 'account_currency_id' => myMoney::RUR, 'account_type_id' => Account_Collection::ACCOUNT_TYPE_CREDIT);
     $account = CreateObjectHelper::makeAccount($options);
     $toAccountId = $account['account_id'];
     $options = array('user_id' => $this->userId, 'system_category_id' => Category_Model::DEBT_SYSTEM_CATEGORY_ID);
     $debtCategoryId = CreateObjectHelper::createCategory($options);
     $this->user->init();
     $this->user->save();
     $operation = new Operation_Model($this->user);
     // Перевели 100 рублей с рублёвого на долларовый
     $opId = $operation->addTransfer(100, 0, 0, '2010-01-01', $this->accountId, $toAccountId, 'Комментарий', array('тег 1'));
     $dateFrom = '2009-12-29';
     $dateTo = '2010-01-02';
     $list = $operation->getOperationList($dateFrom, $dateTo);
     $this->assertEquals($debtCategoryId, $list[0]['cat_id'], 'Expected only 1 transfer operation');
 }