From cd644787af832e458e33b7d63a1f9ff3356657fb Mon Sep 17 00:00:00 2001 From: sparkyx Date: Fri, 12 Jul 2024 19:03:04 +0200 Subject: [PATCH] Block new operation with deactivated card --- include/class/acc_ledger.class.php | 4 ++++ include/class/acc_ledger_fin.class.php | 9 ++++++--- include/class/acc_ledger_purchase.class.php | 15 ++++++++++++--- include/class/acc_ledger_sale.class.php | 17 ++++++++++++++--- 4 files changed, 36 insertions(+), 9 deletions(-) diff --git a/include/class/acc_ledger.class.php b/include/class/acc_ledger.class.php index 17f6dd420..2ae52a103 100644 --- a/include/class/acc_ledger.class.php +++ b/include/class/acc_ledger.class.php @@ -1295,7 +1295,11 @@ class Acc_Ledger extends jrn_def_sql if (isset(${'qc_'.$i})&&trim(${'qc_'.$i})!="") { $f=new Fiche($this->db); + $f->get_by_qcode(${'qc_'.$i}); $f->quick_code=${'qc_'.$i}; + + if ($f->get_f_enable() == '0') + throw new Exception(sprintf(_("La fiche %s n'est plus utilisée"),${'qc_'.$i}), 50); if ($f->belong_ledger($p_jrn) < 1 ) throw new Exception("La fiche quick_code = ". $f->quick_code." n'est pas dans ce journal", 4); diff --git a/include/class/acc_ledger_fin.class.php b/include/class/acc_ledger_fin.class.php index de3a2ea72..808d625ed 100644 --- a/include/class/acc_ledger_fin.class.php +++ b/include/class/acc_ledger_fin.class.php @@ -133,6 +133,11 @@ class Acc_Ledger_Fin extends Acc_Ledger { if (noalyss_strlentrim(${'e_other'.$i})==0) continue; + /* check if all card has a ATTR_DEF_ACCOUNT */ + $fiche=new Fiche($this->db); + $fiche->get_by_qcode(${'e_other'.$i}); + if ($fiche->get_f_enable() == '0') + throw new Exception(sprintf(_("La fiche %s n'est plus utilisée"),${'e_other'.$i}), 50); /* check if amount are numeric and */ if (isNumber(${'e_other'.$i.'_amount'})==0) throw new Exception('La fiche '.${'e_other'.$i}.'a un montant invalide ['.${'e_other'.$i.'_amount'}.']', @@ -140,9 +145,7 @@ class Acc_Ledger_Fin extends Acc_Ledger /* compute the total */ $tot_amount+=round(${'e_other'.$i.'_amount'}, 2); - /* check if all card has a ATTR_DEF_ACCOUNT */ - $fiche=new Fiche($this->db); - $fiche->get_by_qcode(${'e_other'.$i}); + if ($fiche->empty_attribute(ATTR_DEF_ACCOUNT)==true) throw new Exception('La fiche '.${'e_other'.$i}.'n\'a pas de poste comptable', 8); diff --git a/include/class/acc_ledger_purchase.class.php b/include/class/acc_ledger_purchase.class.php index 2eebca15e..e95e057e2 100644 --- a/include/class/acc_ledger_purchase.class.php +++ b/include/class/acc_ledger_purchase.class.php @@ -111,10 +111,14 @@ class Acc_Ledger_Purchase extends Acc_Ledger /* check the account */ $fiche=new Fiche($this->db); $fiche->get_by_qcode($e_client); + if ($fiche->get_f_enable() == '0') + throw new Exception(sprintf(_("La fiche %s n'est plus utilisée"),$e_client), 50); if ( $fiche->empty_attribute(ATTR_DEF_ACCOUNT) == true) throw new Exception(_('La fiche ').$e_client._('n\'a pas de poste comptable'),8); + + /* get the account and explode if necessary */ $sposte=$fiche->strAttribut(ATTR_DEF_ACCOUNT); // if 2 accounts, take only the credit one for supplier @@ -158,6 +162,13 @@ class Acc_Ledger_Purchase extends Acc_Ledger for ($i=0;$i< $nb_item;$i++) { if ( noalyss_strlentrim(${'e_march'.$i})== 0) continue; + + /* check if all card has a ATTR_DEF_ACCOUNT*/ + $fiche=new Fiche($this->db); + $fiche->get_by_qcode(${'e_march'.$i}); + if ($fiche->get_f_enable() == '0') + throw new Exception(sprintf(_("La fiche %s n'est plus utilisée"), ${'e_march' . $i}), 50); + /* check if amount are numeric and */ if ( isNumber(${'e_march'.$i.'_price'}) == 0 ) throw new Exception(_('La fiche ').${'e_march'.$i}._('a un montant invalide').' ['.${'e_march'.$i}.']',6); @@ -181,9 +192,7 @@ class Acc_Ledger_Purchase extends Acc_Ledger throw new Exception(_(" La TVA ".$tva_rate->tva_label." utilise des postes comptables inexistants")); } - /* check if all card has a ATTR_DEF_ACCOUNT*/ - $fiche=new Fiche($this->db); - $fiche->get_by_qcode(${'e_march'.$i}); + if ( $fiche->empty_attribute(ATTR_DEF_ACCOUNT) == true) throw new Exception(_('La fiche ').${'e_march'.$i}._('n\'a pas de poste comptable'),8); diff --git a/include/class/acc_ledger_sale.class.php b/include/class/acc_ledger_sale.class.php index bfa9eb539..28e39581d 100644 --- a/include/class/acc_ledger_sale.class.php +++ b/include/class/acc_ledger_sale.class.php @@ -108,9 +108,15 @@ class Acc_Ledger_Sale extends Acc_Ledger { $fiche = new Fiche($this->db); $fiche->get_by_qcode($e_client); + + if ($fiche->get_f_enable() == '0') + throw new Exception(sprintf(_("La fiche %s n'est plus utilisée"),$e_client), 50); + if ($fiche->empty_attribute(ATTR_DEF_ACCOUNT) == true) throw new Exception(_('La fiche ') . $e_client . _('n\'a pas de poste comptable'), 8); + + /* get the account and explode if necessary */ $sposte = $fiche->strAttribut(ATTR_DEF_ACCOUNT); // if 2 accounts, take only the debit one for customer @@ -142,14 +148,19 @@ class Acc_Ledger_Sale extends Acc_Ledger { for ($i = 0; $i < $nb_item; $i++) { if (! isset (${'e_march' . $i}) || noalyss_strlentrim(${'e_march' . $i}) == 0) continue; + /* check if all card has a ATTR_DEF_ACCOUNT */ + $fiche = new Fiche($this->db); + $fiche->get_by_qcode(${'e_march' . $i}); + if ($fiche->get_f_enable() == '0') + throw new Exception(sprintf(_("La fiche %s n'est plus utilisée"), ${'e_march' . $i}), 50); + + /* check if amount are numeric and */ if (isNumber(${'e_march' . $i . '_price'}) == 0) throw new Exception(_('La fiche ') . ${'e_march' . $i} . _('a un montant invalide [') . ${'e_march' . $i} . ']', 6); if (isNumber(${'e_quant' . $i}) == 0) throw new Exception(_('La fiche ') . ${'e_march' . $i} . _('a une quantité invalide [') . ${'e_quant' . $i} . ']', 7); - /* check if all card has a ATTR_DEF_ACCOUNT */ - $fiche = new Fiche($this->db); - $fiche->get_by_qcode(${'e_march' . $i}); + if ($fiche->empty_attribute(ATTR_DEF_ACCOUNT) == true) throw new Exception(_('La fiche ') . ${'e_march' . $i} . _('n\'a pas de poste comptable'), 8);