From a9d6970055bf057ef3b4f1ff9269943bce4a780f Mon Sep 17 00:00:00 2001 From: sparkyx Date: Mon, 4 Jan 2021 13:04:47 +0100 Subject: [PATCH 1/3] Bug : if all the quantity are NULL, then we have only one row in jrn --- include/class/acc_ledger_purchase.class.php | 2 +- include/class/acc_ledger_sold.class.php | 4 +++- include/class/acc_operation.class.php | 4 ++++ 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/include/class/acc_ledger_purchase.class.php b/include/class/acc_ledger_purchase.class.php index 241744697..667e03251 100644 --- a/include/class/acc_ledger_purchase.class.php +++ b/include/class/acc_ledger_purchase.class.php @@ -260,7 +260,7 @@ class Acc_Ledger_Purchase extends Acc_Ledger } } } - $nb++; + if ( ${"e_quant".$i} != 0 && trim(${"e_quant".$i}) !="" ) {$nb++;} } if ( $nb == 0 ) diff --git a/include/class/acc_ledger_sold.class.php b/include/class/acc_ledger_sold.class.php index 9cb0668cc..27ec56adf 100644 --- a/include/class/acc_ledger_sold.class.php +++ b/include/class/acc_ledger_sold.class.php @@ -208,7 +208,9 @@ class Acc_Ledger_Sold extends Acc_Ledger { $fiche->get_by_qcode(${'e_march' . $i}); if ($fiche->belong_ledger($p_jrn, 'cred') != 1) throw new Exception(_('La fiche ') . ${'e_march' . $i} . _('n\'est pas accessible à ce journal'), 10); - $nb++; + + if ( ${"e_quant".$i} != 0 && trim(${"e_quant".$i}) !="" ) {$nb++;} + } if ($nb == 0) throw new Exception(_('Il n\'y a aucune marchandise'), 12); diff --git a/include/class/acc_operation.class.php b/include/class/acc_operation.class.php index 06946c760..f5ff15d9d 100644 --- a/include/class/acc_operation.class.php +++ b/include/class/acc_operation.class.php @@ -60,6 +60,7 @@ class Acc_Operation $this->periode=$g_user->get_periode(); $this->jr_id=0; $this->jr_optype="NOR"; + $this->amount=0; } /** *@brief retrieve the grpt_id from jrn for a jr_id @@ -183,6 +184,7 @@ class Acc_Operation $this->amount=abs($this->amount); $debit=($this->type=='c')?'false':'true'; $this->desc=(isset($this->desc))?$this->desc:''; + $this->amount=(trim($this->amount)==''||$this->amount==NULL)?0:$this->amount; $Res=$this->db->exec_sql("select insert_jrnx ($1::text,abs($2)::numeric,$3::account_type,$4::integer,$5::integer,$6::bool,$7::text,$8::integer,upper($9),$10::text)", array( @@ -287,8 +289,10 @@ class Acc_Operation { $this->mt=microtime(true); } + // if amount == -1then the triggers will throw an error // + $this->amount=(trim($this->amount)==''||$this->amount==NULL)?0:$this->amount; $Res=$this->db->exec_sql("insert into jrn (jr_def_id,jr_montant,jr_comment,". "jr_date,jr_ech,jr_grpt_id,jr_tech_per,jr_mt,jr_optype) values (". "$1,$2,$3,". From a4ed48354b752c5a42482b879e800799ed7e1966 Mon Sep 17 00:00:00 2001 From: sparkyx Date: Mon, 4 Jan 2021 17:41:34 +0100 Subject: [PATCH 2/3] Generate document : DESCRIPTION for invoice (e_comm) --- include/class/document.class.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/class/document.class.php b/include/class/document.class.php index d7b7f8789..c74a0b60b 100644 --- a/include/class/document.class.php +++ b/include/class/document.class.php @@ -1206,6 +1206,8 @@ class Document ,[$p_array['ag_id']]); return $description; } + if ( isset($p_array['e_comm'])) {return $p_array['e_comm'] ; } + return ""; break; From 0150e4e88d8b24e06155a0f3145a2ff011bc2f2c Mon Sep 17 00:00:00 2001 From: sparkyx Date: Wed, 24 Feb 2021 13:37:19 +0100 Subject: [PATCH 3/3] Bug : Bank , no warning if balance incorrect when the first amount is 0 Protect $_REQUEST , do no replace the first amount when it is corrected --- include/class/acc_ledger_fin.class.php | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/include/class/acc_ledger_fin.class.php b/include/class/acc_ledger_fin.class.php index de48fcb16..1aea14b4b 100644 --- a/include/class/acc_ledger_fin.class.php +++ b/include/class/acc_ledger_fin.class.php @@ -218,16 +218,23 @@ class Acc_Ledger_Fin extends Acc_Ledger throw new Exception('Il n\'y a aucune opération', 12); /* Check if the last_saldo and first_saldo are correct */ - if (strlen(trim($last_sold)) != 0 && isNumber($last_sold) && - strlen(trim($first_sold)) != 0 && isNumber($first_sold)) + if (strlen(trim($last_sold)) != 0 + && isNumber($last_sold) + && strlen(trim($first_sold)) != 0 + && isNumber($first_sold) + ) { $diff = $last_sold - $first_sold; $diff = round($diff, 2) - round($tot_amount, 2); - if ($first_sold != 0 && $last_sold != 0) + $calc=bcadd($first_sold,$tot_amount,4); + if ($first_sold != 0 || $last_sold != 0) { - if ($diff != 0) - throw new Exception('Le montant de l\'extrait est incorrect' . - $tot_amount . ' extrait ' . $diff, 13); + if ($diff != 0) { + throw new Exception(sprintf( _('Le montant de l\'extrait [%s] est incorrect,'. + " solde calculé [%s] , différence de [%s]") , + $last_sold,$calc,$diff),13); + + } } } }