From bd92d45847fb4ea6f58862223e8cb5d3c97f4b66 Mon Sep 17 00:00:00 2001 From: sparkyx Date: Fri, 20 Sep 2024 19:06:27 +0200 Subject: [PATCH] Fix : France saldo until end of exercice in Gestion --- include/class/fiche.class.php | 9 +++------ include/class/periode.class.php | 23 ++++++++++++----------- 2 files changed, 15 insertions(+), 17 deletions(-) diff --git a/include/class/fiche.class.php b/include/class/fiche.class.php index e8a314a84..401763c11 100644 --- a/include/class/fiche.class.php +++ b/include/class/fiche.class.php @@ -1339,11 +1339,6 @@ class Fiche // set a filter ? $search=$p_sql; - $exercice=$g_user->get_exercice(); - $tPeriode=new Periode($this->cn); - list($max,$min)=$tPeriode->get_limit($exercice); - - if ( noalyss_trim($p_search) != "" ) { $search.=" and f_id in @@ -1380,7 +1375,9 @@ class Fiche /* Filter on the default year */ if ( $g_parameter->MY_REPORT == 'N') { - $amount = $tiers->get_solde_detail(); + list($l_from,$l_to)=(new Periode($this->cn))->get_limit($g_user->get_exercice()); + $condition = sprintf (" j_date <= to_date('%s','DD.MM.YYYY') ", $l_to->last_day()); + $amount = $tiers->get_solde_detail($condition); } else { $amount=$tiers->get_solde_detail($filter_year); } diff --git a/include/class/periode.class.php b/include/class/periode.class.php index 63ac4de06..dee39238e 100644 --- a/include/class/periode.class.php +++ b/include/class/periode.class.php @@ -318,28 +318,29 @@ EOF; return 0; } - /*!\brief return the max and the min periode of the exercice given + /*! + * \brief return the max (to periode) and the min periode (from periode) of the exercice given * in parameter - * \param $p_exercice is the exercice + * \param $p_exercice is the exercice (parm_periode.p_exercice) * \return an array of Periode object */ function get_limit($p_exercice) { - $max=$this->cn->get_value("select p_id from parm_periode where p_exercice=$1 order by p_start asc limit 1", + $from_periode_id=$this->cn->get_value("select p_id from parm_periode where p_exercice=$1 order by p_start asc limit 1", array($p_exercice)); - $min=$this->cn->get_value("select p_id from parm_periode where p_exercice=$1 order by p_start desc limit 1", + $to_periode_id=$this->cn->get_value("select p_id from parm_periode where p_exercice=$1 order by p_start desc limit 1", array($p_exercice)); - $rMax=new Periode($this->cn); - $rMax->p_id=$max; - if ($rMax->load() == -1) + $periodeFrom=new Periode($this->cn); + $periodeFrom->p_id=$from_periode_id; + if ($periodeFrom->load() == -1) throw new Exception('Periode n\'existe pas'); - $rMin=new Periode($this->cn); - $rMin->p_id=$min; - if ($rMin->load() == -1) + $periodeTo=new Periode($this->cn); + $periodeTo->p_id=$to_periode_id; + if ($periodeTo->load() == -1) throw new Exception('Periode n\'existe pas'); - return array($rMax, $rMin); + return array($periodeFrom, $periodeTo); } /*!