public function GetCaveById(Gyuser_Model_OtherCaves $obj)
 {
     $table = $this->getDbTable();
     $select = $table->select();
     $select->setIntegrityCheck(false);
     $select->from(array('ocs' => 'other_caves'), array('id', 'name', 'email', 'balance', 'tasa_anual', 'impuesto_al_cheque', 'gastos_general', 'gastos_interior', 'gastos_denuncia', 'gastos_rechazo', 'acreditacion_capital', 'acreditacion_interior', 'gastos_menor_a_monto_1', 'gastos_menor_a_1', 'gastos_menor_a_monto_2', 'gastos_menor_a_2'));
     $select->joinLeft(array('ops' => 'operations'), 'ops.cave_id = ocs.id', array('cave_id', 'liquidacion_id'));
     $select->joinLeft(array('cqu' => 'cheques'), 'cqu.operation_id = ops.id ', array('sum(cqu.amount) as rej_amount', 'sum(cqu.rejected_cost) as rej_cost'));
     $select->where('cqu.status = ?', 3);
     $select->where('cqu.rejected_liquidacion_id is null');
     $select->where('ocs.status = ?', true);
     $select->where('ocs.id = ?', $obj->getId());
     $select->order('name ASC');
     $row = $table->fetchRow($select);
     if ($row) {
         $entry = new Gyuser_Model_OtherCaves();
         $entry->setId($row->id);
         $entry->setName($row->name);
         $entry->setEmail($row->email);
         $entry->setBalance($row->balance);
         $entry->setRej_check_amount(floatval($row->rej_amount) + floatval($row->rej_cost));
         $entry->setTasa_anual($row->tasa_anual);
         $entry->setImpuesto_al_cheque($row->impuesto_al_cheque);
         $entry->setGastos_general($row->gastos_general);
         $entry->setGastos_interior($row->gastos_interior);
         $entry->setGastos_denuncia($row->gastos_denuncia);
         $entry->setGastos_rechazo($row->gastos_rechazo);
         $entry->setAcreditacion_capital($row->acreditacion_capital);
         $entry->setAcreditacion_interior($row->acreditacion_interior);
         $entry->setGastos_cheque_menor_a_1($row->gastos_menor_a_monto_1);
         $entry->setGastos_cheque_a_1($row->gastos_menor_a_1);
         $entry->setGastos_cheque_menor_a_2($row->gastos_menor_a_monto_2);
         $entry->setGastos_cheque_a_2($row->gastos_menor_a_2);
         $cMapper = new Gyuser_Model_ChequesDataMapper();
         $cObj = new Gyuser_Model_Cheques();
         $cObj->setStatus(4);
         $cObj->setCave_id($row->cave_id);
         if (@$row->cave_id) {
             $cAmount = $cMapper->GetTotalAmountByCave($cObj);
             $entry->setPassed_amount($cAmount);
         }
         return $entry;
     } else {
         return null;
     }
 }