Block new operation with deactivated card

This commit is contained in:
sparkyx 2024-07-12 19:03:04 +02:00
parent d810da721e
commit cd644787af
4 changed files with 36 additions and 9 deletions

View file

@ -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);

View file

@ -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);

View file

@ -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);

View file

@ -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);