From c2179cab1416d6cb1925af5839d64fafa47ca05c Mon Sep 17 00:00:00 2001 From: sparkyx Date: Sat, 3 Apr 2004 00:21:24 +0000 Subject: [PATCH] Fix bug in annulation, add check to validate number and card --- Changelog | 26 +++++++++ doc/manuel-fr.sgml | 54 +++++++++++++++++-- html/annulation.php | 27 +++++----- include/constant.php | 4 +- include/form_input.php | 47 +++++++++++----- include/jrn.php | 2 +- include/stock_inc.php | 104 ++++++++++++++++++++++++++---------- include/user_action_ach.php | 2 + include/user_action_fin.php | 4 ++ include/user_common.php | 49 +++++++++++++---- 10 files changed, 249 insertions(+), 70 deletions(-) diff --git a/Changelog b/Changelog index 1423b45ce..ce2c7bc3c 100644 --- a/Changelog +++ b/Changelog @@ -1,5 +1,31 @@ +2004-04-02 sparkyx + + * html/annulation.php, include/central_inc.php: + Change cancel an op : j_internal=='ANNULE' and jr_internal of the cancel operation = 'ANNULE' + + * html/annulation.php, include/central_inc.php, include/jrn.php: + Change centralize and jr_internal rule + + * html/modify_op.php, include/jrn.php: Payment + + * include/stock_inc.php: Stock include file + + * html/annulation.php, html/fiche_new.php, html/fiche_search.php, html/jrn_search.php, html/login.php, html/print_balance.php, html/stock.php, html/user_login.php, include/constant.php, include/form_input.php, include/jrn.php, include/postgres.php, include/user_common.php, include/user_menu.php, sql/account_repository.sql, sql/demo.sql, sql/mod-be.sql, FAQ-fr.txt, doc/FAQ-fr.txt, doc/manuel-fr.sgml, html/admin_repo.php, style-light.css: + Many little Bugs fixed + 2004-04-01 sparkyx + * include/form_input.php, include/user_action_fin.php, include/user_action_ods.php: + Improve appearance in user interface for ach, ven, fin and ods + + * include/compta_menu.php, include/fiche_inc.php, include/form_input.php, include/jrn.php, include/user_common.php: + code cleaning + + * include/form_inc.php, html/enc_jrn.php, html/jrn_add.php, html/jrn_detail.php, html/jrn_search.php, html/poste_search.php, html/win_detail_jrn.js, html/win_search_jrn.js, html/win_search_poste.js: + remove javascript file, the javascript are now in include/constant.php (define JS_) + + * Changelog: Update + * sql/dump-db.sql: script for creating db files * include/jrn.php: Adapt for new features (ODS, UpdateJrn...) diff --git a/doc/manuel-fr.sgml b/doc/manuel-fr.sgml index 5239cb2f1..3f0d76049 100644 --- a/doc/manuel-fr.sgml +++ b/doc/manuel-fr.sgml @@ -176,15 +176,51 @@ passe pas par des comptes d + Fiscalité, TVA +

tous les requalifications des montants doivent +se faire par le journal des opérations diverses + Belgique + TVA & impôt +

Pour faire votre déclaration tva, vous pouvez utilisez les +balances des comptes ou les formulaires. + +

+Attention NE PAS REPRENDRE LES +MONTANTS AINSI !!!. Avant de faire votre déclaration, vous devez d'abord +rectifier les montants. Par exemple, 50% de la tva sur la voiture ne +sont pas récupérable par la tva mais par l'impôt des société. +Il faut "déplacer" 50% de cette tva dans un poste comptable tva non +admises, +cela devrait être un compte de la classe 6 (donc 6xxxx à 411xxx), les charges +augmentent mais la tva à récupérer diminue, ce qui est logique puisque +cette tva est à récupérer par l'impôt des sociétés. + +

Idem pour les frais de restaurant, ne pas oublier pendant les +travaux de fin d'exercice,d'imputer 50% du total de vos frais de +restaurant à un compte de dépense non admise. Il n'est pas dans le +PCMN donc créer le poste vous-même (classe 67). + +

De plus si vous utilisez la voiture pour votre usage personnel, 2/7 +doivent être mis sur le compte exploitant dans le cas d'une +sprl. C'est-à-dire qu'il +faut diminuer les charges 6xxxx frais de voiture à 41xxx Compte de +l'exploitant. Et de la même manière, diminuer la tva de vos frais de +voiture de 2/7. + + + France +

Pas reçu de doc ni d'aide sur ce sujet désolé + + - Les profils + Les modes

Dans le menu préférence, il existe deux sortes d'interface que vous pouvez utiliser,

-Le profil comptable +Le mode comptable

Dans ce cas, vous verrez votre comptabilité comme un comptable s'attend à la voir avec des postes comptables, des écritures comptables impliquant des @@ -196,7 +232,7 @@ r mal encodé, vous devez introduire l'écriture comptable inverse pour corriger, pensez à mettre la mention "correction d'erreur" -Le profil utilisateur +Le mode utilisateur

Dans ce cas, vous verrez votre comptabilité comme un utilisateur, facture à payer, facture à encoder... @@ -246,6 +282,12 @@ exemple : Ceux qui terminent par une étoile reprennent les comptes qui commence par l'expression ainsi 411* reprendra 411, 4111, 4112,4113 et 4114. Vous séparez les différents comptes par un espace. + +Il vaut mieux ne pas créer plus de 4 journaux par types, c'est-à-dire +16 au total, il y a à cela deux raisons : la première est que cela +devient ingérable, la seconde est que l'affichage en mode utilisateur +serait euh... atroce. Quatre journaux en tout est largement suffisant +pour les besoins d'une entreprise. Journal des Achats Journal des Ventes @@ -288,7 +330,10 @@ vous devrez mettre manuellement le poste comptable Création d'une fiche

-Quelques attributs à expliquer : Gestion Poste, Prix Achat, Prix de vente, Poste Comptable +Quelques attributs à expliquer : Gestion Poste, Prix Achat, Prix de +vente, Poste Comptable. Vous n'êtes pas obligé de créer une fiche pour +tout, par exemple pour les restaurants, vous pouvez encodez une seule +et unique fiche appelée restaurant.

@@ -507,6 +552,5 @@ encoder dans le journal financier, ne pas oublier le rapprochement Banque : le client nous a payé pour la facture du 21 encoder dans le journal financier, ne pas oublier le rapprochement
- diff --git a/html/annulation.php b/html/annulation.php index bc6cc75f8..f3ec773ef 100644 --- a/html/annulation.php +++ b/html/annulation.php @@ -55,9 +55,10 @@ if ( isset ($annul) ) { if ( isset ($_POST['p_id'])) { // Get the current periode $period=GetUserPeriode($cn,$g_user); - + $p_id=$_POST['p_id']; // Check if it a centralize operation - if ( isCentralize($cn,$p_id) == 0 ) { + if ( isCentralize($cn,$p_id) == 0 and + isValid($cn,$p_id) == 1 ) { // get the next op id $seq=GetNextId($cn,'j_grpt')+1; @@ -69,33 +70,35 @@ if ( isset ($annul) ) { ) select j_montant, j_poste, $seq, j_jrn_def, case when j_debit=false then true else false end, - j_text,'ANNULE,'$g_user',$period + j_text,'ANNULE','$g_user',$period from jrnx where j_grpt=".$_POST['p_id']; $Res=ExecSql($cn,$sql); // build the sql stmt for jrn $sql= "insert into jrn ( - jr_def_id,jr_montant,jr_comment, jr_date,jr_grpt_id,jr_internal ,jr_tech_per + jr_def_id,jr_montant,jr_comment, jr_date,jr_grpt_id,jr_internal ,jr_tech_per, + jr_valid ) select - jr_def_id,jr_montant,'Annulation '||jr_comment,jr_date,$seq ,'ANNULE', $period + jr_def_id,jr_montant,'Annulation '||jr_comment,jr_date,$seq ,'ANNULE', $period, + false from jrn where jr_grpt_id=".$_POST['p_id']; $Res=ExecSql($cn,$sql); // also in the stock table - $sql="insert into stock_goods ( - j_id,f_id,sg_quantity,sg_type - ) select - j_id,f_id,sg_quantity, case when sg_type='c' then 'd' else 'c' end - from stock_goods natural join jrnx where j_grpt=".$_POST['p_id']; + $sql="delete from stock_goods where sg_id = any ( select sg_id + from stock_goods natural join jrnx where j_grpt=".$_POST['p_id'].")"; $Res=ExecSql($cn,$sql); + // Update jr_valid + $Res=ExecSql($cn,"update jrn set jr_valid=false where jr_grpt_id=$p_id"); + echo '

Opération annulée

'; } - echo '

Opération annulée

'; + ?> diff --git a/include/form_input.php b/include/form_input.php index 987c73947..5eb274902 100644 --- a/include/form_input.php +++ b/include/form_input.php @@ -737,7 +737,6 @@ function FormAch($p_cn,$p_jrn,$p_user,$p_submit,$p_array=null,$view_only=true,$p // Save old value and set a new one $e_client=( isset ($e_client) )?$e_client:""; - // $r.=''.InputType("Fournisseur","SELECT","e_client",$customer,$view_only,$fiche).''; $e_client_label=""; @@ -790,6 +789,7 @@ function FormAch($p_cn,$p_jrn,$p_user,$p_submit,$p_array=null,$view_only=true,$p echo_error($msg); echo_error($msg); echo ""; $march_buy=0; + if ( $view_only ) return null; } $march_tva_label=""; $march_label=""; @@ -801,6 +801,7 @@ function FormAch($p_cn,$p_jrn,$p_user,$p_submit,$p_array=null,$view_only=true,$p echo_error($msg); echo_error($msg); echo ""; $march=""; + if ( $view_only ) return null; } else { // retrieve the tva label and name $a_fiche=GetFicheAttribut($p_cn, $march); @@ -809,6 +810,13 @@ function FormAch($p_cn,$p_jrn,$p_user,$p_submit,$p_array=null,$view_only=true,$p $march_label=$a_fiche['vw_name']; } } + } else { + if ( $view_only ) { + $msg="Fiche inexistante !!! "; + echo_error($msg); echo_error($msg); + echo ""; + return null; + } } $r.=''.InputType("","js_search","e_march".$i,$march,$view_only,'deb'); $r.=InputType("","span", "e_march".$i."_label", $march_label,$view_only); @@ -923,7 +931,7 @@ function RecordAchat($p_cn,$p_array,$p_user,$p_jrn) $j_id=InsertJrnx($p_cn,'d',$p_user,$p_jrn,$poste,$e_date,$a_price[$i]*$a_quant[$i],$seq,$periode); // if ( withStock($p_cn,$a_good[$i]) == true ) // always save quantity but in withStock we can find what card need a stock management - InsertStockGoods($p_cn,$j_id,$a_good[$i],$a_quant[$i],'c'); + InsertStockGoods($p_cn,$j_id,$a_good[$i],$a_quant[$i],'d'); } // Insert Vat if (sizeof($a_vat) != 0 ) // no vat @@ -934,14 +942,16 @@ function RecordAchat($p_cn,$p_array,$p_user,$p_jrn) } } echo_debug("echeance = $e_ech"); - InsertJrn($p_cn,$e_date,$e_ech,$p_jrn,"",$amount+$sum_vat,$seq,$periode); - // Set Internal code and Comment - $comment=SetInternalCode($p_cn,$seq,$p_jrn)." client : ".GetFicheName($p_cn,$e_client); - if ( $e_comment=="" ) { - // Update comment if comment is blank - $Res=ExecSql($p_cn,"update jrn set jr_comment='".$comment."' where jr_grpt_id=".$seq); + if ( ($amount+$sum_vat) != 0 ){ + InsertJrn($p_cn,$e_date,$e_ech,$p_jrn,"",$amount+$sum_vat,$seq,$periode); + // Set Internal code and Comment + $comment=SetInternalCode($p_cn,$seq,$p_jrn)." client : ".GetFicheName($p_cn,$e_client); + if ( $e_comment=="" ) { + // Update comment if comment is blank + $Res=ExecSql($p_cn,"update jrn set jr_comment='".$comment."' where jr_grpt_id=".$seq); + } + return $comment; } - return $comment; } /* function FormFin($p_cn,$p_jrn,$p_user,$p_array=null,$view_only=true,$p_item=1) @@ -1007,16 +1017,25 @@ function FormFin($p_cn,$p_jrn,$p_user,$p_submit,$p_array=null,$view_only=true,$p // retrieve e_bank_account_label if ( isNumber($e_bank_account) == 1 ) { - if ( isFicheOfJrn($p_cn,$p_jrn,$e_bank_account,'cred') == 0 ) { + if ( isFicheOfJrn($p_cn,$p_jrn,$e_bank_account,'deb') == 0 ) { $msg="Fiche inexistante !!! "; echo_error($msg); echo_error($msg); echo ""; $e_bank_account=""; + echo_debug("FormFin returns NULL the bank account is not valid"); + return null; } else { $a_client=GetFicheAttribut($p_cn,$e_bank_account); if ( $a_client != null) $e_bank_account_label=$a_client['vw_name']." adresse ".$a_client['vw_addr']." ".$a_client['vw_cp']; } + }else { + + if ( $view_only ==true) { + return null; + echo_debug("FormFin returns NULL the bank account is not valid"); + } + } $r.=''.InputType("Banque","js_search","e_bank_account",$e_bank_account,$view_only,FICHE_TYPE_FIN).''; @@ -1062,7 +1081,7 @@ function FormFin($p_cn,$p_jrn,$p_user,$p_submit,$p_array=null,$view_only=true,$p $tiers_comment=(isset (${"e_other$i"."_comment"}))?${"e_other$i"."_comment"}:""; // If $tiers has a value if ( isNumber($tiers) == 1 ) { - if ( isFicheOfJrn($p_cn,$p_jrn,$tiers,'deb') == 0 ) { + if ( isFicheOfJrn($p_cn,$p_jrn,$tiers,'cred') == 0 ) { $msg="Fiche inexistante !!! "; echo_error($msg); echo_error($msg); echo ""; @@ -1078,7 +1097,7 @@ function FormFin($p_cn,$p_jrn,$p_user,$p_submit,$p_array=null,$view_only=true,$p ${"e_other$i"."_amount"}=(isset (${"e_other$i"."_amount"}))?${"e_other$i"."_amount"}:0; // Compute the string to pass to InputType $f=FICHE_TYPE_CLIENT.",".FICHE_TYPE_FOURNISSEUR.",".FICHE_TYPE_ADM_TAX.",".FICHE_TYPE_FIN; - $r.=''.InputType("","js_search","e_other".$i,$tiers,$view_only,$f); + $r.=''.InputType("","js_search","e_other".$i,$tiers,$view_only,'cred'); $r.=InputType("","span", "e_other$i"."_label", $tiers_label,$view_only); // Comment $r.=InputType("","Text","e_other$i"."_comment",$tiers_comment,$view_only); @@ -1123,7 +1142,7 @@ return $r; * true on success */ function RecordFin($p_cn,$p_array,$p_user,$p_jrn) { - + echo_debug("RecordFin"); foreach ( $p_array as $v => $e) { ${"$v"}=$e; @@ -1186,7 +1205,7 @@ function RecordFin($p_cn,$p_array,$p_user,$p_jrn) { $Res=ExecSql($p_cn,"update jrn set jr_comment='".$comment."' where jr_grpt_id=".$seq); } } - return $comment; + } /* function FormODS($p_cn,$p_jrn,$p_user,$p_array=null,$view_only=true,$p_article=1) * Purpose : Display the miscellaneous operation diff --git a/include/jrn.php b/include/jrn.php index 10ffffe06..601c528f7 100644 --- a/include/jrn.php +++ b/include/jrn.php @@ -968,7 +968,7 @@ function NextJrn($p_cn,$p_type) */ function SetInternalCode($p_cn,$p_grpt,$p_jrn) { - $num=CountSql($p_cn,"select * from jrn where jr_def_id=$p_jrn where jr_internal != 'ANNULE'"); + $num=CountSql($p_cn,"select * from jrn where jr_def_id=$p_jrn and jr_internal != 'ANNULE'"); $atype=GetJrnProperty($p_cn,$p_jrn); $type=$atype['jrn_def_code']; $internal_code=sprintf("%s-%05d",$type,$num); diff --git a/include/stock_inc.php b/include/stock_inc.php index 2d41dad46..4e5562052 100644 --- a/include/stock_inc.php +++ b/include/stock_inc.php @@ -31,29 +31,23 @@ * return: string containing the table */ function ViewStock($p_cn,$p_year) { - - // build sql - $sql= 'select C.sg_code,sum(deb) as deb_sum,sum(cred) as cred_sum - from jrnx + // build sql +$sql=" select C.sg_code,sum(deb) as deb_sum,sum(cred) as cred_sum + from jrnx join stock_goods using (j_id) join - ( select sg_code, - case when sg_type=\'d\' then sg_quantity else 0 end as deb, - case when sg_type=\'c\' then sg_quantity else 0 end as cred - from stock_goods + ( select sg_code,j_id, + case when sg_type='d' then sg_quantity else 0 end as deb, + case when sg_type='c' then sg_quantity else 0 end as cred + from stock_goods where sg_code is not null - ) as C on (stock_goods.sg_code=C.sg_code) - left outer join (select f_id,av_text as name - from jnt_fic_att_value join attr_value using (jft_id) where ad_id='.ATTR_DEF_NAME.' - ) as B on stock_goods.f_id=B.f_id + and sg_code != 'null' + ) as C on (jrnx.j_id=C.j_id) + where + to_char(j_date,'YYYY') = '$p_year' +group by c.sg_code"; - where - - to_char(j_date,\'YYYY\') = \''.$p_year.'\' -group by c.sg_code -'; - // send the sql $Res=ExecSql($p_cn,$sql); @@ -61,7 +55,8 @@ group by c.sg_code // store it in a HTLM table $result=""; $result.=""; - $result.=''; + $result.=''; + $result.=''; $result.=''; $result.=''; $result.=''; @@ -71,23 +66,41 @@ group by c.sg_code for ($i = 0; $i < $M ; $i++ ) { $r=pg_fetch_array($Res,$i); $result.=""; - // name and link to details -/* $result.=""; -*/ + + // sg_code and link to details + $result.=""; + + // name + $a_name=getFicheNameCode($p_cn,$r['sg_code']); + $name=""; + if ( $a_name != null ) { + foreach ($a_name as $key=>$element) { + $name.=$element['av_text'].","; + } + }// if ( $a_name + $result.=""; + + // Debit (in) $result.=""; + + // Credit (out) $result.=""; - $result.=""; + + + // diff + $diff=$r['deb_sum']-$r['cred_sum']; + $result.=""; $result.=""; } - $result.="
NomCodeNomsEntréeSortieSolde
".''. - $r['name']."".''. + $r['sg_code']." $name ".$r['deb_sum']."".$r['cred_sum']."".$r['deb_sum']-$r['cred_sum']."".$diff."
"; + $result.=""; return $result; } /* function ViewDetailStock ($p_cn,$p_f_id,$p_year) - ************************************************** + ************************************************************ * Purpose : return all the stock movement * * parm : @@ -102,4 +115,41 @@ function ViewDetailStock($p_cn,$p_f_id,$p_year) { } +/* function getFicheNameCode ($p_cn,$p_sg_code) + ************************************************************ + * Purpose : return an array of f_id and f_name + * + * parm : + * - p_cn database connection + * - stock_goods.sg_code + * gen : + * - none + * return: + * - array (f_id, f_label) or null if nothing is found + */ +function getFicheNameCode ($p_cn,$p_sg_code) { + // Sql stmt +$sql="select f_id,av_text + from stock_goods + join jnt_fic_att_value using (f_id ) + join attr_value using (jft_id) + where + ad_id=".ATTR_DEF_NAME." + and sg_code='$p_sg_code' + and sg_code != null "; +// Execute + $Res=ExecSql($p_cn,$sql); + if ( ( $M=pg_NumRows($Res)) == 0 ) return null; + + // Store in an array + for ( $i=0; $i<$M;$i++) { + $r=pg_fetch_array($Res,$i); + $a['f_id']=$r['f_id']; + $a['av_text']=$r['av_text']; + $result[$i]=$a; + } + + return $result; + +} \ No newline at end of file diff --git a/include/user_action_ach.php b/include/user_action_ach.php index 9c8fc791c..d906a06fd 100644 --- a/include/user_action_ach.php +++ b/include/user_action_ach.php @@ -93,6 +93,8 @@ if ( $action == 'new' ) { // if something goes wrong, correct it if ( $r == null ) { + $submit=' + '; $r=FormAch($cn,$g_jrn,$g_user,$submit,$HTTP_POST_VARS,false, $nb_number); } echo '
'; diff --git a/include/user_action_fin.php b/include/user_action_fin.php index 224f153e0..aa7003b6b 100644 --- a/include/user_action_fin.php +++ b/include/user_action_fin.php @@ -90,6 +90,10 @@ if ( $action == 'new' ) { // if something goes wrong correct it if ( $r == null ) { + // submit button in the form + $submit=' + '; + $r=FormFin($cn,$g_jrn,$g_user,$submit,$HTTP_POST_VARS,false, $nb_number); } diff --git a/include/user_common.php b/include/user_common.php index c4b2e8cfe..e5ea75a19 100644 --- a/include/user_common.php +++ b/include/user_common.php @@ -219,7 +219,8 @@ function ListJrn($p_cn,$p_jrn,$p_where="",$p_array=null) jrn_def_id, jrn_def_name, jrn_def_ech, - jrn_def_type + jrn_def_type, + jr_valid from jrn join jrn_def on jrn_def_id=jr_def_id $p_where @@ -242,7 +243,8 @@ function ListJrn($p_cn,$p_jrn,$p_where="",$p_array=null) jrn_def_id, jrn_def_name, jrn_def_ech, - jrn_def_type + jrn_def_type, + jr_valid from jrn join jrn_def on jrn_def_id=jr_def_id where jrn_def_id=$p_jrn"; $l_and=" and "; @@ -331,13 +333,14 @@ function ListJrn($p_cn,$p_jrn,$p_where="",$p_array=null) }// if ( $a != null ) { $r.=""; //$l=user_jrn.php?action=update&line=91 -// TODO Add print - $r.=""; -// cancel operation - $r.=sprintf('', - "Annulation",$row['jr_grpt_id'],$l_sessid); - $r.=""; - + if ( $row['jr_valid'] == 't' ) { + // TODO Add print + $r.=""; + // cancel operation + $r.=sprintf('', + "Annulation",$row['jr_grpt_id'],$l_sessid); + $r.=""; + } // end row $r.=""; @@ -595,3 +598,31 @@ function UpdateComment ($p_cn,$p_jr_id,$p_comment) { } +/* function isValid ($p_cn, $p_grpt_id + ************************************************** + * Purpose : test if a jrn op is valid + * + * parm : + * - db connection + * - p_grpt_id + * gen : + * - none + * return: + * 1 is valid + * 0 is not valid + */ +function isValid ($p_cn,$p_grpt_id) { + $Res=ExecSql($p_cn,"select jr_valid from jrn where jr_grpt_id=$p_grpt_id"); + + if ( ( $M = pg_NumRows($Res)) == 0 ) return 0; + + $a=pg_fetch_array($Res,0); + + if ( $a['jr_valid'] == 't') return 1; + if ( $a['jr_valid'] == 'f') return 0; + + echo_error ("Invalid result = ".$a['result']); + + +} +