From 07bb3f7c6d40120bb622ef3a453a08d30c2c6e9f Mon Sep 17 00:00:00 2001 From: sparkyx Date: Sat, 3 Apr 2004 01:38:39 +0000 Subject: [PATCH] Fix central - stock - improve doc --- include/central_inc.php | 2 -- include/form_input.php | 26 +++++++++++++++----------- include/jrn.php | 2 +- include/user_common.php | 10 ++++++---- install.sh | 3 +-- sql/account_repository.sql | 2 -- 6 files changed, 23 insertions(+), 22 deletions(-) diff --git a/include/central_inc.php b/include/central_inc.php index 013c7087e..6db3fb058 100644 --- a/include/central_inc.php +++ b/include/central_inc.php @@ -63,8 +63,6 @@ $sql="insert into centralized( c_j_id, from jrnx left join jrn on jr_grpt_id=j_grpt where j_tech_per =".$p_periode." - and jr_internal != 'ANNULE' - and j_internal != 'ANNULE' order by j_date,j_grpt,j_debit desc "; $Res=StartSql($p_cn); $Res=ExecSql($p_cn,$sql); diff --git a/include/form_input.php b/include/form_input.php index 5eb274902..73f1e1521 100644 --- a/include/form_input.php +++ b/include/form_input.php @@ -628,10 +628,12 @@ function RecordInvoice($p_cn,$p_array,$p_user,$p_jrn) $a_vat=ComputeVat($p_cn, $a_good,$a_quant,$a_price); $sum_vat=0.0; - foreach ( $a_vat as $element => $t) { - echo_debug(" a_vat element $element t $t"); - $sum_vat+=$t; - echo_debug("sum_vat = $sum_vat"); + if ( $a_vat != null ){ + foreach ( $a_vat as $element => $t) { + echo_debug(" a_vat element $element t $t"); + $sum_vat+=$t; + echo_debug("sum_vat = $sum_vat"); + } } // First we add in jrnx @@ -659,7 +661,7 @@ function RecordInvoice($p_cn,$p_array,$p_user,$p_jrn) InsertStockGoods($p_cn,$j_id,$a_good[$i],$a_quant[$i],'c'); } // Insert Vat - if (sizeof($a_vat) != 0 ) // no vat + if ( $a_vat!= null ) // no vat { foreach ($a_vat as $tva_id => $tva_amount ) { $poste=GetTvaPoste($p_cn,$tva_id,'c'); @@ -907,12 +909,14 @@ function RecordAchat($p_cn,$p_array,$p_user,$p_jrn) $a_vat=ComputeVat($p_cn, $a_good,$a_quant,$a_price); $sum_vat=0.0; - foreach ( $a_vat as $element => $t) { - echo_debug(" a_vat element $element t $t"); - $sum_vat+=$t; - echo_debug("sum_vat = $sum_vat"); + if ( $a_vat != null ) { + foreach ( $a_vat as $element => $t) { + echo_debug(" a_vat element $element t $t"); + $sum_vat+=$t; + echo_debug("sum_vat = $sum_vat"); + } } - // First we add in jrnx + // First we add in jrnx // Compute the j_grpt $seq=GetNextId($p_cn,'j_grpt')+1; @@ -934,7 +938,7 @@ function RecordAchat($p_cn,$p_array,$p_user,$p_jrn) InsertStockGoods($p_cn,$j_id,$a_good[$i],$a_quant[$i],'d'); } // Insert Vat - if (sizeof($a_vat) != 0 ) // no vat + if ( $a_vat != null ) // no vat { foreach ($a_vat as $tva_id => $tva_amount ) { $poste=GetTvaPoste($p_cn,$tva_id,'d'); diff --git a/include/jrn.php b/include/jrn.php index 601c528f7..68ca0c0ff 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 and jr_internal != 'ANNULE'"); + $num=CountSql($p_cn,"select * from jrn where jr_def_id=$p_jrn and jr_internal != 'ANNULE'")+1; $atype=GetJrnProperty($p_cn,$p_jrn); $type=$atype['jrn_def_code']; $internal_code=sprintf("%s-%05d",$type,$num); diff --git a/include/user_common.php b/include/user_common.php index e5ea75a19..5ff3562c4 100644 --- a/include/user_common.php +++ b/include/user_common.php @@ -36,6 +36,7 @@ include_once("postgres.php"); */ function GetTvaRate($p_cn,$p_tva_id) { + if (strlen(trim($p_tva_id))==0) return 0; $Res=pg_exec($p_cn,"select tva_id,tva_rate,tva_label from tva_rate where tva_id=".$p_tva_id); if (pg_NumRows($Res) == 0 ) return null; @@ -65,10 +66,11 @@ echo_debug("ComputeVat $a_fiche $a_quant $a_price"); // foreach goods for ( $i=0 ; $i < sizeof($a_fiche);$i++) { // if the card id is null or empty - if ( isNumber($a_fiche[$i])==0) continue; + if ( isNumber($a_fiche[$i])==0 + or strlen(trim($a_fiche[$i]))==0) continue; // Get the tva_id $tva_id=GetFicheAttribut($p_cn,$a_fiche[$i],ATTR_DEF_TVA); - + if ( $tva_id == 'Unknown' ) continue; // for each fiche find the tva_rate and tva_id $a_vat=GetTvaRate($p_cn,$tva_id); @@ -150,7 +152,7 @@ function InsertJrnx($p_cn,$p_type,$p_user,$p_jrn,$p_poste,$p_date,$p_amount,$p_g $sql=sprintf("insert into jrnx (j_date,j_montant, j_poste,j_grpt, j_jrn_def,j_debit,j_tech_user,j_tech_per) values (to_date('%s','DD.MM.YYYY'),abs(%.2f),%d,%d,%d,%s,'%s',%d)", - $p_date,$p_amount,$p_poste,$p_grpt,$p_jrn,$debit,$p_user,$p_periode); + $p_date,round($p_amount,2),$p_poste,$p_grpt,$p_jrn,$debit,$p_user,$p_periode); echo_debug("InsertJrnx $sql"); $Res=ExecSql($p_cn,$sql); return GetSequence($p_cn,'s_jrn_op'); @@ -184,7 +186,7 @@ function InsertJrn($p_cn,$p_date,$p_echeance,$p_jrn,$p_comment,$p_amount,$p_grpt } $sql=sprintf("insert into jrn (jr_def_id,jr_montant,jr_comment,jr_date,jr_ech,jr_grpt_id,jr_tech_per) values ( %d,abs(%.2f),'%s',to_date('%s','DD.MM.YYYY'),%s,%d,%d)", - $p_jrn, $p_amount,$p_comment,$p_date,$p_echeance,$p_grpt,$p_periode); + $p_jrn, round($p_amount,2),$p_comment,$p_date,$p_echeance,$p_grpt,$p_periode); echo_debug("InsertJrn $sql"); $Res=ExecSql($p_cn,$sql); return GetSequence($p_cn,'s_jrn'); diff --git a/install.sh b/install.sh index 8983bcb3e..2cd95af90 100755 --- a/install.sh +++ b/install.sh @@ -22,10 +22,9 @@ echo "The file install.log will be created with the log of the installation, just check if it finished with the message installation ok" - # Output the log to install log exec 3>install.log 2>&3 1>&3 -set -xv +#set -xv version=3 VerifOutil() { diff --git a/sql/account_repository.sql b/sql/account_repository.sql index c79e77494..27650033c 100644 --- a/sql/account_repository.sql +++ b/sql/account_repository.sql @@ -176,8 +176,6 @@ INSERT INTO ac_users VALUES (1, NULL, NULL, 'phpcompta', 1, 'b1cc88e1907cde80cb2 -- INSERT INTO ac_dossier VALUES (1, 'Demo', 'Base de données pour développement & démo', 0); -INSERT INTO ac_dossier VALUES (8, 'Test', 'Test du modèle', 0); -INSERT INTO ac_dossier VALUES (9, 'Test 2', 'Test 2', 0); --