From d810da721ef31ccf59ed673c86013bca8e44a54c Mon Sep 17 00:00:00 2001 From: sparkyx Date: Fri, 12 Jul 2024 18:39:12 +0200 Subject: [PATCH] allow many-to-many lettering + cosmetic --- include/class/acc_ledger.class.php | 8 +++----- include/class/acc_ledger_purchase.class.php | 4 +++- include/class/acc_ledger_sale.class.php | 4 ++-- include/class/acc_reconciliation.class.php | 5 +++-- include/class/lettering.class.php | 15 +++++++++------ 5 files changed, 20 insertions(+), 16 deletions(-) diff --git a/include/class/acc_ledger.class.php b/include/class/acc_ledger.class.php index e3e5b9f99..17f6dd420 100644 --- a/include/class/acc_ledger.class.php +++ b/include/class/acc_ledger.class.php @@ -439,7 +439,7 @@ class Acc_Ledger extends jrn_def_sql // Add a "concerned operation to bound these op.together // - $rec=new Acc_Reconciliation($this->db); + $rec=new Acc_Reconciliation($this->db); $rec->set_jr_id($seq); $rec->insert($this->jr_id); @@ -449,13 +449,11 @@ class Acc_Ledger extends jrn_def_sql throw (new Exception(__FILE__.__LINE__."SQL ERROR [ $sql ]")); } - - // the table stock must updated // also in the stock table $sql="delete from stock_goods where sg_id = any ( select sg_id - from stock_goods natural join jrnx where j_grpt=".$this->jr_grpt_id.")"; - $Res=$this->db->exec_sql($sql); + from stock_goods natural join jrnx where j_grpt=$1)"; + $Res=$this->db->exec_sql($sql,array($this->jr_grpt_id)); if ($Res==false) { throw (new Exception(__FILE__.__LINE__."SQL ERROR [ $sql ]")); diff --git a/include/class/acc_ledger_purchase.class.php b/include/class/acc_ledger_purchase.class.php index c28e7eb9b..2eebca15e 100644 --- a/include/class/acc_ledger_purchase.class.php +++ b/include/class/acc_ledger_purchase.class.php @@ -1804,6 +1804,8 @@ class Acc_Ledger_Purchase extends Acc_Ledger EOF; if ($p_currency_code !=0) { + $sql_currency=new Currency_SQL($this->cn,0); + $iso_code=$sql_currency->getp("cr_code_iso"); $rate=_("Taux "); $r.=<< @@ -1818,7 +1820,7 @@ $r.=<< - {$tot_eur} EUR + {$tot_eur} {$iso_code} EOF; diff --git a/include/class/acc_ledger_sale.class.php b/include/class/acc_ledger_sale.class.php index 75f27c89c..bfa9eb539 100644 --- a/include/class/acc_ledger_sale.class.php +++ b/include/class/acc_ledger_sale.class.php @@ -1064,9 +1064,9 @@ if ( $g_parameter->MY_TVA_USE=="Y") { EOF; - $sql_currency=new Currency_SQL($this->cn,$p_currency_code); - $iso_code=$sql_currency->getp("cr_code_iso"); if ($p_currency_code !=0) { + $sql_currency=new Currency_SQL($this->cn,0); + $iso_code=$sql_currency->getp("cr_code_iso"); $r.=<< diff --git a/include/class/acc_reconciliation.class.php b/include/class/acc_reconciliation.class.php index 52d0f7abc..6b4cf8439 100644 --- a/include/class/acc_reconciliation.class.php +++ b/include/class/acc_reconciliation.class.php @@ -121,8 +121,9 @@ class Acc_Reconciliation ==0) { // Ok we can insert - $Res=$this->db->exec_sql("insert into jrn_rapt(jr_id,jra_concerned) values ". - "(".$this->jr_id.",$jr_id2)"); + $Res=$this->db->exec_sql("insert into jrn_rapt(jr_id,jra_concerned) values ($1,$2)", + array($this->jr_id,$jr_id2) + ); // try to letter automatically same account from both operation $this->auto_letter($jr_id2); diff --git a/include/class/lettering.class.php b/include/class/lettering.class.php index 63e9a9a5c..579f1fac1 100644 --- a/include/class/lettering.class.php +++ b/include/class/lettering.class.php @@ -161,20 +161,23 @@ class Lettering return; // already linked - if ($let1!=0&&$let2!=0&&$let1!=$let2) + /* if ($let1!=0&&$let2!=0&&$let1!=$let2) return; - +*/ // none is linked if ($let1==0&&$let2==0) { $jl_id=$this->db->get_next_seq("jnt_letter_jl_id_seq"); $this->db->exec_sql('insert into jnt_letter(jl_id) values($1)', array($jl_id)); - } - // one is linked but not the other - if ($let1==0&&$let2!=0) + } elseif ($let1==0&&$let2!=0) + { + // one is linked but not the other $jl_id=$let2; - if ($let1!=0&&$let2==0) + }elseif ($let1!=0&&$let2==0) { $jl_id=$let1; + } else { + throw new \Exception ("LET179 invalid"); + } /* insert */ if ($first=='t')