diff --git a/include/class_customer.php b/include/class_customer.php index 3f5bb3691..d6a8674c6 100644 --- a/include/class_customer.php +++ b/include/class_customer.php @@ -20,6 +20,7 @@ // Copyright Author Dany De Bontridder ddebontridder@yahoo.fr require_once("constant.php"); require_once("postgres.php"); +require_once("class_parm_code.php"); // Use the view vw_customer // class Customer { @@ -71,12 +72,17 @@ class Customer { // BASE ACCOUNT // for belgium - // TODO : those values should be in a table because - // they are _national_ parameters - //----- - $SOLD="70"; - $CUSTOMER="400"; - $TVA="451"; + $s=new parm_code($this->db,'VENTE'); + $s->Get() + $SOLD=$s->p_value; + + $c=new parm_code($this->db,'CUSTOMER'); + $c->Get(); + $CUSTOMER=$c->p_value; + + $t=new parm_code($this->db,'COMPTE_TVA'); + $t->Get(); + $TVA=$t->p_value; // Get all the sell operation //---- $sql="select j_grpt @@ -150,11 +156,12 @@ where //if not submitted to VAT, remove from list: //STAN: currently commented out because I don't know if it is really what we need. - //if (!isset($a_Res[$customer]['vat_number']) || strcmp($a_Res[$customer]['vat_number'], "") == 0) - //{ - // unset($a_Res[$customer]); - //} - + //Dany : yes we need it because the decla. concerns only the registered customer at the VAT + if (!isset($a_Res[$customer]['vat_number']) || strcmp($a_Res[$customer]['vat_number'], "") == 0) + { + unset($a_Res[$customer]); + } + }// foreach $a } diff --git a/include/class_fiche_def.php b/include/class_fiche_def.php index d45a49dde..c896f942f 100644 --- a/include/class_fiche_def.php +++ b/include/class_fiche_def.php @@ -123,6 +123,27 @@ class fiche_def_ref " where frd_id=".$this->frd_id; $Res=ExecSql($this->db,$sql); } +/* function Get + ************************************************** + * Purpose : Get the data with the p_code and complete + * the current object + * + * parm : + * - none + * gen : + * - + * return: none + */ + function Get() + { + $sql="select * from fiche_def_ref ". + " where frd_id=".$this->frd_id; + $Res=ExecSql($this->db,$sql); + if ( pg_NumRows($Res) == 0 ) return null; + $r=pg_fetch_array($Res,0); + $this->frd_text=$r['frd_text']; + $this->frd_class_base=$r['frd_class_base']; + } } ?> \ No newline at end of file diff --git a/include/fiche_def.inc.php b/include/fiche_def.inc.php index 96c0fcb64..05aa51610 100644 --- a/include/fiche_def.inc.php +++ b/include/fiche_def.inc.php @@ -53,8 +53,9 @@ echo ""; if ( isset ($_POST['mod']) ) { extract ($_POST); - echo '
'; - echo "Voulez-vous modifier ?"; + echo '
'; + echo "Voulez-vous modifier ?
Attention, ne changer pas la signification de "; + echo " ce poste, par exemple ne pas changer Client par fournisseur,
sinon le programme fonctionnera mal, utiliser uniquement des chiffres pour la classe de base ou rien
"; $idx=$_POST['idx']; $mod=new fiche_def_ref($cn); $mod->frd_id=$all[$idx]->frd_id; diff --git a/include/user_action_fin.php b/include/user_action_fin.php index 7647ac021..ff0d5db0e 100644 --- a/include/user_action_fin.php +++ b/include/user_action_fin.php @@ -22,6 +22,7 @@ echo_debug('user_action_fin.php',__LINE__,"include user_action_fin.php"); // include_once("form_input.php"); require_once("user_form_fin.php"); include_once("class_widget.php"); +require_once("class_parm_code.php"); $cn=DbConnect($_SESSION['g_dossier']); @@ -202,9 +203,13 @@ if ( $action == 'solde' ) { // find the bank account // TODO : those values should be in a table because // they are _national_ parameters + $banque=new parm_code($cn,'BANQUE'); + $caisse=new parm_code($cn,'CAISSE'); + $vir_interne=new parm_code($cn,'VIREMENT_INTERNE'); $accountSql="select distinct pcm_val::text,pcm_lib from tmp_pcmn - where pcm_val like '550%' or pcm_val like '58%' or pcm_val like '57%' + where pcm_val like '".$banque->p_value."%' or pcm_val like '".$vir_interne->p_value."%' + or pcm_val like '".$caisse->p_value."%' order by pcm_val::text"; $ResAccount=ExecSql($cn,$accountSql); echo '
'; diff --git a/include/user_form_ach.php b/include/user_form_ach.php index bc5bb68b9..79c229fa5 100644 --- a/include/user_form_ach.php +++ b/include/user_form_ach.php @@ -23,6 +23,7 @@ require_once("class_widget.php"); require_once("preference.php"); require_once("fiche_inc.php"); require_once("user_common.php"); +require_once("class_parm_code.php"); /* function FormAchInput * Purpose : Display the form for a sell * Used to show detail, encode a new invoice @@ -709,7 +710,8 @@ function RecordSell($p_cn,$p_array,$p_user,$p_jrn) // they are _national_ parameters // save it echo_debug('user_form_ach.php',__LINE__,"InsertJrnx($p_cn,'d',$p_user->id,$p_jrn,'6740',$e_date,round($nd_amount,2),$seq,$periode);"); - $j_id=InsertJrnx($p_cn,'d',$p_user->id,$p_jrn,'6740',$e_date,round($nd_amount,2),$seq,$periode); + $dna=new parm_code($p_cn,'DNA'); + $j_id=InsertJrnx($p_cn,'d',$p_user->id,$p_jrn,$dna->p_value,$e_date,round($nd_amount,2),$seq,$periode); if ( $j_id == false) { Rollback($p_cn);exit("error 'user_form_ach.php' __LINE__");} $amount=$amount-$nd_amount; } @@ -725,9 +727,11 @@ function RecordSell($p_cn,$p_array,$p_user,$p_jrn) // TODO : those values should be in a table because // they are _national_ parameters + $tva_dna=new parm_code($p_cn,'TVA_DNA'); echo_debug('user_form_ach.php',__LINE__, - "InsertJrnx($p_cn,'d',$p_user->id,$p_jrn,'6190',$e_date,round($ded_vat,2),$seq,$periode);"); - $j_id=InsertJrnx($p_cn,'d',$p_user->id,$p_jrn,'6740',$e_date,round($ded_vat,2),$seq,$periode); + "InsertJrnx($p_cn,'d',$p_user->id,$p_jrn,".$tva_dna->p_value.",$e_date,round($ded_vat,2),$seq,$periode);"); + + $j_id=InsertJrnx($p_cn,'d',$p_user->id,$p_jrn,$tva_dna->p_value,$e_date,round($ded_vat,2),$seq,$periode); if ( $j_id == false) { Rollback($p_cn);exit("error 'user_form_ach.php' __LINE__");} } @@ -743,12 +747,13 @@ function RecordSell($p_cn,$p_array,$p_user,$p_jrn) $sum_tva_nd+=$ded_vat; // Save it + $tva_ded_impot=new parm_code($p_cn,'TVA_DED_IMPOT'); echo_debug('user_form_ach.php',__LINE__, - "InsertJrnx($p_cn,'d',$p_user->id,$p_jrn,'6190',$e_date,round($ded_vat,2),$seq,$periode);"); + "InsertJrnx($p_cn,'d',$p_user->id,$p_jrn,".$tva_ded_impot->p_value.",$e_date,round($ded_vat,2),$seq,$periode);"); // TODO : those values should be in a table because // they are _national_ parameters - $j_id=InsertJrnx($p_cn,'d',$p_user->id,$p_jrn,'6190',$e_date,round($ded_vat,2),$seq,$periode); + $j_id=InsertJrnx($p_cn,'d',$p_user->id,$p_jrn,$tva_ded_impot->p_value,$e_date,round($ded_vat,2),$seq,$periode); if ( $j_id == false) { Rollback($p_cn);exit("error 'user_form_ach.php' __LINE__");} } diff --git a/sql/5306/parm_code.sql b/sql/5306/parm_code.sql index 6e20cf977..a8b6b79c1 100644 --- a/sql/5306/parm_code.sql +++ b/sql/5306/parm_code.sql @@ -12,5 +12,5 @@ INSERT INTO parm_code VALUES ('COMPTE_COURANT', '56', 'Poste comptable pour le c INSERT INTO parm_code VALUES ('CAISSE', '57', 'Poste comptable pour la caisse'); INSERT INTO parm_code VALUES ('TVA_DNA', '6740', 'Tva non déductible s'); INSERT INTO parm_code VALUES ('TVA_DED_IMPOT', '619000', 'Tva déductible par l''impôt'); - +INSERT INTO parm_code VALUES ('VENTE ', '70', 'Poste comptable de base pour les ventes');