From 8bc37a2bd31144c297707caadb718b4bc4479d48 Mon Sep 17 00:00:00 2001 From: Dany De Bontridder Date: Thu, 20 Jan 2011 19:38:17 +0000 Subject: [PATCH] #202 contrepartie DNA --- html/admin/sql/patch/upgrade92.sql | 9 ++++ html/js/infobulle.js | 1 + include/card_attr.inc.php | 6 ++- include/class_acc_ledger_purchase.php | 64 ++++++++++++++++----------- include/class_fiche.php | 10 ++--- include/class_fiche_attr.php | 4 +- include/constant.php | 2 +- sql/upgrade.sql | 8 ++-- 8 files changed, 65 insertions(+), 39 deletions(-) create mode 100644 html/admin/sql/patch/upgrade92.sql diff --git a/html/admin/sql/patch/upgrade92.sql b/html/admin/sql/patch/upgrade92.sql new file mode 100644 index 000000000..4b70fdc63 --- /dev/null +++ b/html/admin/sql/patch/upgrade92.sql @@ -0,0 +1,9 @@ +begin; + +insert into attr_def(ad_id,ad_text,ad_type,ad_size) values (50,'Contrepartie pour TVA récup par impot','poste',22); +insert into attr_def(ad_id,ad_text,ad_type,ad_size) values (51,'Contrepartie pour TVA non Ded.','poste',22); +insert into attr_def(ad_id,ad_text,ad_type,ad_size) values (52,'Contrepartie pour dépense à charge du gérant','poste',22); +insert into attr_def(ad_id,ad_text,ad_type,ad_size) values (53,'Contrepartie pour dépense fiscal. non déd.','poste',22); + +update version set val=93; +commit; diff --git a/html/js/infobulle.js b/html/js/infobulle.js index f77e422d4..fb1842862 100644 --- a/html/js/infobulle.js +++ b/html/js/infobulle.js @@ -41,6 +41,7 @@ content[10]="ATTENTION changer le poste comptable d'une fiche ne modifiera pa content[11]="ATTENTION si le poste comptable est vide, il sera créé automatiquement"; content[12]="Document généré uniquement si le mode de paiement est utilisé"; content[13]="Vous pouvez utiliser le % pour indiquer le poste parent"; +content[14]="Attention, le poste comptable doit exister, il ne sera pas vérifié"; function showBulle(p_ctl) { diff --git a/include/card_attr.inc.php b/include/card_attr.inc.php index f9540e36a..dad4b46b0 100644 --- a/include/card_attr.inc.php +++ b/include/card_attr.inc.php @@ -74,7 +74,11 @@ $select_type->value=array( array('value'=>'text','label'=>'Texte'), array('value'=>'numeric','label'=>'Nombre'), array('value'=>'date','label'=>'Date'), - array('value'=>'zone','label'=>'Zone de texte') + array('value'=>'zone','label'=>'Zone de texte'), + array('value'=>'poste','label'=>'Poste Comptable'), + array('value'=>'card','label'=>'Fiche'), + + ); $remove=new IButton('rmfa'); $remove->label='Effacer'; diff --git a/include/class_acc_ledger_purchase.php b/include/class_acc_ledger_purchase.php index 7056ade20..f9dd86069 100644 --- a/include/class_acc_ledger_purchase.php +++ b/include/class_acc_ledger_purchase.php @@ -251,7 +251,7 @@ class Acc_Ledger_Purchase extends Acc_Ledger if ( $poste_nd->load() == false) { $nd_msg=sprintf(_("Pour la fiche %s, le compte %s n'existe pas"), - $fiche->getName,$poste_nd->id); + $fiche->getName(),$poste_nd->id); $nd_msg=h($nd_msg); throw new Exception ($nd_msg); } @@ -552,6 +552,8 @@ class Acc_Ledger_Purchase extends Acc_Ledger */ if ( $tot_nd != 0) { + $dna_default=new Acc_Parm_Code($this->db,'DNA'); + /* save op. */ if ( ! $fiche->empty_attribute(ATTR_DEF_ACCOUNT_ND)) { @@ -559,11 +561,13 @@ class Acc_Ledger_Purchase extends Acc_Ledger } else { - $dna=new Acc_Parm_Code($this->db,'DNA'); + $dna=$dna_default->p_value; } + $dna=($dna=='')?$dna_default->p_value:$dna; + $acc_operation->type='d'; $acc_operation->amount=$tot_nd; - $acc_operation->poste=$dna->p_value; + $acc_operation->poste=$dna; $acc_operation->qcode=''; if ( $tot_nd > 0 ) $tot_debit=bcadd($tot_debit,$tot_nd); $j_id=$acc_operation->insert_jrnx(); @@ -574,6 +578,8 @@ class Acc_Ledger_Purchase extends Acc_Ledger */ if ( $tot_perso != 0) { + $dna_default=new Acc_Parm_Code($this->db,'DEP_PRIV'); + /* save op. */ $acc_operation->type='d'; if ( ! $fiche->empty_attribute(ATTR_DEF_ACCOUNT_ND_PERSO)) @@ -582,11 +588,12 @@ class Acc_Ledger_Purchase extends Acc_Ledger } else { - $dna=new Acc_Parm_Code($this->db,'DEV_PRIV'); + $dna=$dna_default->p_value; } - + $dna=($dna=='')?$dna_default->p_value:$dna; + $acc_operation->amount=$tot_perso; - $acc_operation->poste=$dna->p_value; + $acc_operation->poste=$dna; $acc_operation->qcode=''; if ( $tot_perso > 0 ) $tot_debit=bcadd($tot_debit,$tot_perso); $j_id=$acc_operation->insert_jrnx(); @@ -594,42 +601,47 @@ class Acc_Ledger_Purchase extends Acc_Ledger } if ( $tot_tva_nd != 0) { + $dna_default=new Acc_Parm_Code($this->db,'TVA_DNA'); + /* save op. */ $acc_operation->type='d'; $acc_operation->qcode=''; - if ( ! $fiche->empty_attribute(ATTR_DEF_ACCOUNT_ND_TVA)) - { - $dna=$fiche->strAttribut(ATTR_DEF_ACCOUNT_ND_TVA); - } - else - { - $dna=new Acc_Parm_Code($this->db,'TVA_DNA'); - } - - $acc_operation->amount=$tot_tva_nd; - $acc_operation->poste=$dna->p_value; - if ( $tot_tva_nd > 0 ) $tot_debit=bcadd($tot_debit,$tot_tva_nd); - $j_id=$acc_operation->insert_jrnx(); - - } - if ( $tot_tva_ndded != 0) - { - /* save op. */ if ( ! $fiche->empty_attribute(ATTR_DEF_ACCOUNT_ND_TVA_ND)) { $dna=$fiche->strAttribut(ATTR_DEF_ACCOUNT_ND_TVA_ND); } else { - $dna=new Acc_Parm_Code($this->db,'TVA_DED_IMPOT'); + $dna=$dna_default->p_value; } + $dna=($dna=='')?$dna_default->p_value:$dna; + + $acc_operation->amount=$tot_tva_nd; + $acc_operation->poste=$dna; + if ( $tot_tva_nd > 0 ) $tot_debit=bcadd($tot_debit,$tot_tva_nd); + $j_id=$acc_operation->insert_jrnx(); + + } + if ( $tot_tva_ndded != 0) + { + $dna_default=new Acc_Parm_Code($this->db,'TVA_DED_IMPOT'); + /* save op. */ + if ( ! $fiche->empty_attribute(ATTR_DEF_ACCOUNT_ND_TVA)) + { + $dna=$fiche->strAttribut(ATTR_DEF_ACCOUNT_ND_TVA); + } + else + { + $dna=$dna_default->p_value; + } + $dna=($dna=='')?$dna_default->value:$dna; $acc_operation->type='d'; $acc_operation->qcode=''; $acc_operation->amount=$tot_tva_ndded; - $acc_operation->poste=$dna->p_value; + $acc_operation->poste=$dna; if ( $tot_tva_ndded > 0 ) $tot_debit=bcadd($tot_debit,$tot_tva_ndded); $j_id=$acc_operation->insert_jrnx(); diff --git a/include/class_fiche.php b/include/class_fiche.php index e40bd8fc4..8d3e76da1 100644 --- a/include/class_fiche.php +++ b/include/class_fiche.php @@ -499,14 +499,14 @@ class Fiche $w->heigh=2; break; case 'poste': - $w=new IPoste("av_text".$r->ad_id); + $w=new IPoste("av_text".$attr->ad_id); $w->set_attribute('ipopup','ipop_account'); - $w->set_attribute('account',"av_text".$r->ad_id); + $w->set_attribute('account',"av_text".$attr->ad_id); $w->table=1; - $bulle=HtmlInput::infobulle(10); + $bulle=HtmlInput::infobulle(14); break; case 'card': - $w=new ICard("av_text".$r->ad_id); + $w=new ICard("av_text".$attr->ad_id); // filter on frd_id $sql=' select fd_id from fiche_def '; $filter=$this->cn->make_list($sql); @@ -640,7 +640,7 @@ class Fiche $w->set_attribute('ipopup','ipop_account'); $w->set_attribute('account',"av_text".$r->ad_id); $w->table=1; - $bulle=HtmlInput::infobulle(10); + $bulle=HtmlInput::infobulle(14); break; case 'card': $w=new ICard("av_text".$r->ad_id); diff --git a/include/class_fiche_attr.php b/include/class_fiche_attr.php index 53f6fd57d..2b80e49d3 100644 --- a/include/class_fiche_attr.php +++ b/include/class_fiche_attr.php @@ -64,8 +64,8 @@ class Fiche_Attr if ( strlen(trim($this->ad_type))==0) throw new Exception('Le type ne peut pas être vide',1); $this->ad_type=strtolower($this->ad_type); - if ( in_array($this->ad_type,array('date','text','numeric','zone'))==false) - throw new Exception('Le type doit être text, numeric ou date',1); + if ( in_array($this->ad_type,array('date','text','numeric','zone','poste','card'))==false) + throw new Exception('Le type doit être text, numeric,poste, card ou date',1); if ( trim($this->ad_size)=='' || isNumber($this->ad_size)==0||$this->ad_size>22) { switch ($this->ad_type) diff --git a/include/constant.php b/include/constant.php index 95783b307..3253876e7 100644 --- a/include/constant.php +++ b/include/constant.php @@ -39,7 +39,7 @@ $g_captcha=false; $version_phpcompta=3872; -define ("DBVERSION",92); +define ("DBVERSION",93); define ("DBVERSIONREPO",13); define ('NOTFOUND','--not found--'); diff --git a/sql/upgrade.sql b/sql/upgrade.sql index 5f55d6111..45aa6d0fb 100644 --- a/sql/upgrade.sql +++ b/sql/upgrade.sql @@ -1,5 +1,5 @@ -insert into attr_def(ad_id,ad_text,ad_type,ad_size) values (50,'Contrepartie pour TVA récup par impot',poste,22); -insert into attr_def(ad_id,ad_text,ad_type,ad_size) values (51,'Contrepartie pour TVA non Ded.',poste,22); -insert into attr_def(ad_id,ad_text,ad_type,ad_size) values (52,'Contrepartie pour Dépense personnel',poste,22); -insert into attr_def(ad_id,ad_text,ad_type,ad_size) values (53,'Contrepartie pour DNA',poste,22); +insert into attr_def(ad_id,ad_text,ad_type,ad_size) values (50,'Contrepartie pour TVA récup par impot','poste',22); +insert into attr_def(ad_id,ad_text,ad_type,ad_size) values (51,'Contrepartie pour TVA non Ded.','poste',22); +insert into attr_def(ad_id,ad_text,ad_type,ad_size) values (52,'Contrepartie pour dépense à charge du gérant','poste',22); +insert into attr_def(ad_id,ad_text,ad_type,ad_size) values (53,'Contrepartie pour dépense fiscal. non déd.','poste',22);