public  function enDeuda($conditions = array()){

             $dbo = $this->getDataSource();  
             
             $subQuery = $dbo->buildStatement(
                array(
                    'fields' => array('SUM(  `Aeg`.`importe` )'),
                    'table' => 'account_egresos_gastos',
                    'alias' => 'Aeg',
                    'limit' => null,
                    'offset' => null,
                    'joins' => array(),
                    'conditions' => array(
                        'Aeg.gasto_id = `Gasto`.`id`',
                        ),
                    'order' => null,
                    'group' => array('Aeg.gasto_id')
                ), $this
            );      
             
            $conditions[] = "IFNULL(($subQuery), 0) <> `Gasto`.`importe_total`";
            $fieldContain['recursive'] = -1;
            $fieldContain['fields'] = array('Gasto.id','Gasto.id');
            $fieldContain['conditions'] = $conditions;

            $ret = parent::find('list', $fieldContain);

            $gastos = $this->find('all', array('conditions'=>array('Gasto.id'=>$ret)));
            return $gastos;
        }
public  function enDeuda($conditions = array()){

             $dbo = $this->getDataSource();  
             
             $subQuery = $dbo->buildStatement(
                array(
                    'fields' => array('SUM(  `Aeg`.`importe` )'),
                    'table' => 'account_egresos_gastos',
                    'alias' => 'Aeg',
                    'limit' => null,
                    'offset' => null,
                    'joins' => array(),
                    'conditions' => array(
                        'Aeg.gasto_id = `Gasto`.`id`',
                        ),
                    'order' => null,
                    'group' => array('Aeg.gasto_id')
                ), $this
            );      
             
            $conditions[] = "IFNULL(($subQuery), 0) <> `Gasto`.`importe_total`";
            $fieldContain['recursive'] = -1;
            $fieldContain['fields'] = array('Gasto.id','Gasto.id');
            $fieldContain['conditions'] = $conditions;

            $ret = parent::find('list', $fieldContain);

            $gastos = $this->find('all', array('conditions'=>array('Gasto.id'=>$ret)));
            return $gastos;
        }
public function enDeuda ( $ conditions = array ( ) ) { $ dbo = $ this -> getDataSource ( ) ; $ subQuery = $ dbo -> buildStatement ( array ( 'fields' => array ( 'SUM(  `Aeg`.`importe` )' ) , 'table' => 'account_egresos_gastos' , 'alias' => 'Aeg' , 'limit' => null , 'offset' => null , 'joins' => array ( ) , 'conditions' => array ( 'Aeg.gasto_id = `Gasto`.`id`' , ) , 'order' => null , 'group' => array ( 'Aeg.gasto_id' ) ) , $ this ) ; $ conditions [ ] = "IFNULL(($subQuery), 0) <> `Gasto`.`importe_total`" ; $ fieldContain [ 'recursive' ] = - 1 ; $ fieldContain [ 'fields' ] = array ( 'Gasto.id' , 'Gasto.id' ) ; $ fieldContain [ 'conditions' ] = $ conditions ; $ ret = parent :: find ( 'list' , $ fieldContain ) ; $ gastos = $ this -> find ( 'all' , array ( 'conditions' => array ( 'Gasto.id' => $ ret ) ) ) ; return $ gastos ; }
Devuelve todos los gastos que adeudan pagos
o sea, cuyo importe_total no llega a ser cubierto con los pagos realizados
@return array de Gastos
Devuelve todos los gastos que adeudan pagos o sea cuyo importe_total no llega a ser cubierto con los pagos realizados