From 8fc9b7a0999bc4eccfc81645eb71069587f926fa Mon Sep 17 00:00:00 2001 From: sparkyx Date: Sun, 10 Apr 2022 17:11:31 +0200 Subject: [PATCH] Fix : cannot letter a record because remains old data --- include/class/lettering.class.php | 17 +++++++++++++++-- include/lettering.account.inc.php | 2 +- include/lettering.card.inc.php | 2 +- 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/include/class/lettering.class.php b/include/class/lettering.class.php index 91228c874..de3d8666f 100644 --- a/include/class/lettering.class.php +++ b/include/class/lettering.class.php @@ -224,6 +224,7 @@ class Lettering */ public function save($p_array) { + if (!isset($p_array['letter_j_id'])) { // if nothing selected then remove @@ -287,6 +288,7 @@ class Lettering echo $exc->getMessage(); error_log($exc->getTraceAsString()); $this->db->rollback(); + return; } @@ -384,7 +386,15 @@ class Lettering ob_end_clean(); return $r; } - + /** + * @brief for some reason , sometimes, a record in letter_X doesn't have his counterpart + * in letter_Y + */ + function remove_incoherent() + { + $this->db->exec_sql("delete from letter_cred lc where jl_id not in (select jl_id from letter_deb)"); + $this->db->exec_sql("delete from letter_deb lc where jl_id not in (select jl_id from letter_cred)"); + } /** * wrapper : it call show_all, show_lettered or show_not_lettered depending * of the parameter @@ -392,6 +402,7 @@ class Lettering */ public function show_list($p_type) { + switch ($p_type) { case 'all': @@ -505,7 +516,9 @@ class Lettering_Account extends Lettering isNumber($this->fil_amount_max)==1&& isNumber($this->fil_amount_min)==1&& ($this->fil_amount_max!=0||$this->fil_amount_min!=0)) - $filter_amount=" and (j_montant >= $this->fil_amount_min and j_montant<=$this->fil_amount_max or (coalesce(comptaproc.get_letter_jnt($p_jid),-1)= coalesce(comptaproc.get_letter_jnt(j_id),-1) and coalesce(comptaproc.get_letter_jnt($p_jid),-1) <> -1 )) "; + $filter_amount=" and (j_montant >= $this->fil_amount_min and j_montant<=$this->fil_amount_max " + . " or (coalesce(comptaproc.get_letter_jnt($p_jid),-1)= coalesce(comptaproc.get_letter_jnt(j_id),-1) " + . " and coalesce(comptaproc.get_letter_jnt($p_jid),-1) <> -1 )) "; $sql=" select j_id,j_date,to_char(j_date,'DD.MM.YYYY') as j_date_fmt, j_montant,j_debit,jr_comment,jr_internal,jr_id,jr_def_id, diff --git a/include/lettering.account.inc.php b/include/lettering.account.inc.php index 178d63586..184ff6fe5 100644 --- a/include/lettering.account.inc.php +++ b/include/lettering.account.inc.php @@ -124,7 +124,7 @@ $letter=new Lettering_Account($cn); $letter->set_parameter('account',$http->get('acc')); $letter->set_parameter('start',$start->value); $letter->set_parameter('end',$end->value); - +$letter->remove_incoherent(); if ( $sel->selected == 0 ) echo $letter->show_list('all'); if ( $sel->selected == 1 ) diff --git a/include/lettering.card.inc.php b/include/lettering.card.inc.php index c28db7859..d5aa2d69e 100644 --- a/include/lettering.card.inc.php +++ b/include/lettering.card.inc.php @@ -123,7 +123,7 @@ $quick_code=strtoupper(trim($http->get('acc'))); $letter->set_parameter('quick_code',$quick_code); $letter->set_parameter('start',$start->value); $letter->set_parameter('end',$end->value); - +$letter->remove_incoherent(); if ( $sel->selected == 0 ) echo $letter->show_list('all'); if ( $sel->selected == 1 )