diff --git a/html/admin/setup.php b/html/admin/setup.php index 898ff02e9..f7de9ac5f 100644 --- a/html/admin/setup.php +++ b/html/admin/setup.php @@ -487,6 +487,9 @@ if ( DEBUG=='false' ) ob_start(); if ( GetVersion($db) == 21 ) { ExecuteScript($db,'sql/patch/upgrade21.sql'); } // version + if ( GetVersion($db) == 22 ) { + ExecuteScript($db,'sql/patch/upgrade22.sql'); + } // version if ( DEBUG == 'false') ob_end_clean(); }//for @@ -587,6 +590,9 @@ if (DEBUG == 'false' ) ob_start(); if ( GetVersion($db) == 21 ) { ExecuteScript($db,'sql/patch/upgrade21.sql'); } // version + if ( GetVersion($db) == 22 ) { + ExecuteScript($db,'sql/patch/upgrade22.sql'); + } // version if ( DEBUG == 'false') ob_end_clean(); } diff --git a/html/admin/sql/patch/upgrade22.sql b/html/admin/sql/patch/upgrade22.sql new file mode 100644 index 000000000..75c8ab5a5 --- /dev/null +++ b/html/admin/sql/patch/upgrade22.sql @@ -0,0 +1,86 @@ +begin; +create or replace function account_insert (p_f_id integer, p_account poste_comptable) +RETURNS int4 AS +$body$ +declare +nParent tmp_pcmn.pcm_val_parent%type; +sName varchar; +nNew tmp_pcmn.pcm_val%type; +bAuto bool; +nFd_id integer; +nCount integer; +begin + + if length(trim(p_account)) != 0 then + raise notice 'p_account is not empty'; + select * into nCount from tmp_pcmn where pcm_val=p_account; + if nCount !=0 then + raise notice 'this account exists in tmp_pcmn '; + perform attribut_insert(p_f_id,5,to_char(p_account,'999999999999')); + else + -- account doesn't exist, create it + select av_text into sName from + attr_value join jnt_fic_att_value using (jft_id) + where + ad_id=1 and f_id=p_f_id; + + nParent:=account_parent(p_account); + insert into tmp_pcmn(pcm_val,pcm_lib,pcm_val_parent) + values (p_account,sName,nParent); + perform attribut_insert(p_f_id,5,to_char(nNew,'999999999999')); + + end if; + else + raise notice 'p_account is empty'; + select fd_id into nFd_id from fiche where f_id=p_f_id; + bAuto:= account_auto(nFd_id); + if bAuto = true then + raise notice 'account generated automatically'; + nNew:=account_compute(p_f_id); + raise notice 'nNew %', nNew; + select av_text into sName from + attr_value join jnt_fic_att_value using (jft_id) + where + ad_id=1 and f_id=p_f_id; + nParent:=account_parent(nNew); + perform account_add (nNew,sName); + perform attribut_insert(p_f_id,5,to_char(nNew,'999999999999')); + + else + perform attribut_insert(p_f_id,5,null); + end if; + end if; + +return 0; +end; +$body$ +LANGUAGE 'plpgsql' VOLATILE; + +-- Function: attribut_insert(p_f_id int4, p_ad_id int4, p_value "varchar") + +-- DROP FUNCTION attribut_insert(p_f_id int4, p_ad_id int4, p_value "varchar"); + +CREATE OR REPLACE FUNCTION attribut_insert(p_f_id int4, p_ad_id int4, p_value "varchar") + RETURNS void AS +$BODY$ +declare + n_jft_id integer; +begin + select nextval('s_jnt_fic_att_value') into n_jft_id; + insert into jnt_fic_att_value (jft_id,f_id,ad_id) values (n_jft_id,p_f_id,p_ad_id); + insert into attr_value (jft_id,av_text) values (n_jft_id,trim(p_value)); +return; +end; +$BODY$ LANGUAGE 'plpgsql' VOLATILE; + +update attr_value set av_text=trim(av_text); + +update jrnx set j_qcode = B.av_text from + (select f_id,av_text from attr_value join jnt_fic_att_value using (jft_id) + where ad_id=5) as A + join ( select f_id,av_text from attr_value join jnt_fic_att_value using (jft_id) + where ad_id=23) as B using(f_id) where j_poste=a.av_text; + + +update version set val=23; +commit; diff --git a/html/index.php b/html/index.php index f17231ed1..0b48de808 100644 --- a/html/index.php +++ b/html/index.php @@ -76,7 +76,7 @@ BODY { -Version 2.1.0 +Version 2.1.1

Il est conseillé de ne PAS utiliser Internet Explorer.

diff --git a/include/class_fiche.php b/include/class_fiche.php index 186ab273b..d6e9c011a 100644 --- a/include/class_fiche.php +++ b/include/class_fiche.php @@ -350,7 +350,7 @@ class fiche { } elseif ( $r->ad_id == ATTR_DEF_TVA) { - $ret.=JS_TVA; + $ret.=JS_SHOW_TVA; $w=new widget("js_tva"); } elseif ( $r->ad_id == ATTR_DEF_COMPANY ) diff --git a/include/user_form_ach.php b/include/user_form_ach.php index 62ee62323..9e7bafc66 100644 --- a/include/user_form_ach.php +++ b/include/user_form_ach.php @@ -536,8 +536,11 @@ function FormAchView ($p_cn,$p_jrn,$p_periode,$p_array,$p_submit,$p_number,$p_pi } else { $fiche_price=${"e_march$i"."_sell"}; } + // round it + $fiche_price=round($fiche_price,2); + // get TVA Amount - $tva_amount=${"e_march".$i."_tva_amount"}; + $tva_amount=round(${"e_march".$i."_tva_amount"},2); // VAT $vat=(isNumber(${"e_march$i"."_tva_id"})==0 || ${"e_march$i"."_tva_id"}==-1 )?getFicheAttribut($p_cn,${"e_march$i"},ATTR_DEF_TVA):${"e_march$i"."_tva_id"}; @@ -689,7 +692,7 @@ function RecordSell($p_cn,$p_array,$p_user,$p_jrn) $a_quant[$i]=${"e_quant$i"}; $a_price[$i]=0; $a_vat_good[$i]=${"e_march$i"."_tva_id"}; - $a_vat_amount[$i]=${"e_march".$i."_tva_amount"}; + $a_vat_amount[$i]=round(${"e_march".$i."_tva_amount"},2); // check wether the price is set or no if ( isNumber(${"e_march$i"."_sell"}) == 0 ) { @@ -701,6 +704,8 @@ function RecordSell($p_cn,$p_array,$p_user,$p_jrn) // The price is valid $a_price[$i]=${"e_march$i"."_sell"}; } + $a_price[$i]=round($a_price[$i],2); + $cost=$a_price[$i]*$a_quant[$i]; $amount+=$cost; $amount_jrn+=$cost;