diff --git a/include/class_acc_ledger_sold.php b/include/class_acc_ledger_sold.php index 7f1861c20..1b1e75389 100644 --- a/include/class_acc_ledger_sold.php +++ b/include/class_acc_ledger_sold.php @@ -288,7 +288,7 @@ class Acc_Ledger_Sold extends Acc_Ledger $fiche=new Fiche($this->db); $fiche->get_by_qcode(${"e_march".$i}); $amount=bcmul(${'e_march'.$i.'_price'},${'e_quant'.$i}); - $tot_amount+=$amount; + $tot_amount=bcadd($tot_amount,$amount); $acc_operation=new Acc_Operation($this->db); $acc_operation->date=$e_date; $sposte=$fiche->strAttribut(ATTR_DEF_ACCOUNT); @@ -321,6 +321,8 @@ class Acc_Ledger_Sold extends Acc_Ledger $oTva=new Acc_Tva($this->db); $idx_tva=${'e_march'.$i.'_tva_id'}; $tva_item=${'e_march'.$i.'_tva_amount'}; + $oTva->set_parameter("id",$idx_tva); + $oTva->load(); /* if empty then we need to compute it */ if (trim($tva_item)=='') { @@ -333,6 +335,7 @@ class Acc_Ledger_Sold extends Acc_Ledger $tva[$idx_tva]+=$tva_item; else $tva[$idx_tva]=$tva_item; + var_dump($oTva->get_parameter("both_side")); if ($oTva->get_parameter("both_side")==0) $tot_tva=round(bcadd($tva_item,$tot_tva),2); } @@ -433,6 +436,7 @@ class Acc_Ledger_Sold extends Acc_Ledger // if TVA is on both side, we deduce it immediately if ( $oTva->get_parameter("both_side")==1) { + echo "remove_tva"; $poste_vat=$oTva->get_side('d'); $cust_amount=bcadd($tot_amount,$tot_tva); $acc_operation=new Acc_Operation($this->db); @@ -443,6 +447,8 @@ class Acc_Ledger_Sold extends Acc_Ledger $acc_operation->jrn=$p_jrn; $acc_operation->type='d'; $acc_operation->periode=$tperiode; + $acc_operation->insert_jrnx(); + $tot_debit=bcadd($tot_debit,$value); } diff --git a/include/class_acc_tva.php b/include/class_acc_tva.php index 2d3a9501f..80487bbdf 100644 --- a/include/class_acc_tva.php +++ b/include/class_acc_tva.php @@ -132,7 +132,7 @@ class Acc_Tva */ public function load() { - $sql="select tva_label,tva_rate, tva_comment,tva_poste,tva_both_side from tva_rate where tva_id=$1"; + $sql="select tva_id,tva_label,tva_rate, tva_comment,tva_poste,tva_both_side from tva_rate where tva_id=$1"; $res=$this->cn->exec_sql( $sql, array($this->tva_id) diff --git a/include/tva.inc.php b/include/tva.inc.php index e887eb145..1195c3d50 100644 --- a/include/tva.inc.php +++ b/include/tva.inc.php @@ -35,7 +35,7 @@ if (isset($_POST['confirm_rm'])) echo '
Vous ne pouvez pas effacer tous taux' . ' Si votre société n\'utilise pas la TVA, changer dans le menu société
'; } -$both=(isset($_REQUEST['both']))?1:0; +$both_side=(isset($_REQUEST['both']))?1:0; //----------------------------------------------------- // Record Change if (isset($_POST['confirm_mod']) @@ -50,7 +50,7 @@ if (isset($_POST['confirm_mod']) { $err = 2; } - + var_dump($_POST); if ($err == 0) { if (isset($_POST['confirm_add'])) @@ -62,14 +62,14 @@ if (isset($_POST['confirm_mod']) $tva_rate, $tva_comment, $tva_poste, - $both) + $both_side) ); $err = Database::fetch_result($res); } if (isset($_POST['confirm_mod'])) { $Res = $cn->exec_sql( - "select tva_modify($1,$2,$3,$4,$5,$6)", array($tva_id, $tva_label, $tva_rate, $tva_comment, $tva_poste,$both) + "select tva_modify($1,$2,$3,$4,$5,$6)", array($tva_id, $tva_label, $tva_rate, $tva_comment, $tva_poste,$both_side) ); $err = Database::fetch_result($Res); } diff --git a/sql/tva.sql b/sql/tva.sql index 0520663bc..2bf18e3df 100644 --- a/sql/tva.sql +++ b/sql/tva.sql @@ -9,7 +9,6 @@ drop FUNCTION comptaproc.tva_modify(integer, text, numeric, text, text); CREATE OR REPLACE FUNCTION comptaproc.tva_modify(integer, text, numeric, text, text,integer) RETURNS integer - LANGUAGE plpgsql AS $function$ declare p_tva_id alias for $1; @@ -41,6 +40,7 @@ update tva_rate set tva_label=p_tva_label,tva_rate=p_tva_rate,tva_comment=p_tva_ return 0; end; $function$ + LANGUAGE plpgsql; ---------------------------------------------------------------------- -- TVA INSERT @@ -50,7 +50,6 @@ drop FUNCTION comptaproc.tva_insert(text, numeric, text, text); CREATE OR REPLACE FUNCTION comptaproc.tva_insert(text, numeric, text, text,integer) RETURNS integer - LANGUAGE plpgsql AS $function$ declare l_tva_id integer; @@ -83,3 +82,4 @@ insert into tva_rate(tva_id,tva_label,tva_rate,tva_comment,tva_poste,tva_both_si return 0; end; $function$ + LANGUAGE plpgsql;