diff --git a/html/js/acc_ledger.js b/html/js/acc_ledger.js index e488708d4..e51e7cce6 100644 --- a/html/js/acc_ledger.js +++ b/html/js/acc_ledger.js @@ -490,8 +490,8 @@ function success_compute_ledger(request, json) g('htva_march' + ctl).value = rhtva; g('tvac_march' + ctl).value = rtvac; g('sum').show(); - CurrencyCompute('p_currency_rate','p_currency_euro'); refresh_ledger(); + CurrencyCompute('p_currency_rate','p_currency_euro'); return; } @@ -500,7 +500,6 @@ function success_compute_ledger(request, json) g('sum').show(); - CurrencyCompute('p_currency_rate','p_currency_euro'); if (g('e_march' + ctl + '_tva_amount').value == "" || g('e_march' + ctl + '_tva_amount').value == 0) { g('tva_march' + ctl).value = rtva; @@ -514,8 +513,9 @@ function success_compute_ledger(request, json) var tmp1 = Math.round(parseFloat(g('htva_march' + ctl).value) * 100) / 100; var tmp2 = Math.round(parseFloat(g('tva_march' + ctl).value) * 100) / 100; g('tvac_march' + ctl).value = Math.round((tmp1 + tmp2) * 100) / 100; - refresh_ledger(); + CurrencyCompute('p_currency_rate','p_currency_euro'); + } /** diff --git a/include/class/acc_compute.class.php b/include/class/acc_compute.class.php index a6a33d384..d9c8e0df6 100644 --- a/include/class/acc_compute.class.php +++ b/include/class/acc_compute.class.php @@ -89,13 +89,13 @@ class Acc_Compute function convert_euro() { $local_amount=$this->amount; - $this->amount=bcmul($this->amount,$this->currency_rate,6); + $this->amount=bcdiv($this->amount,$this->currency_rate,6); $this->amount_currency=$local_amount; } function convert_euro_vat() { $local_amount=$this->amount_vat; - $this->amount_vat=bcmul($this->amount_vat,$this->currency_rate,6); + $this->amount_vat=bcdiv($this->amount_vat,$this->currency_rate,6); $this->amount_vat_currency=$local_amount; } public function get_parameter($p_string) diff --git a/include/class/acc_ledger.class.php b/include/class/acc_ledger.class.php index f128d9968..13f69dd18 100644 --- a/include/class/acc_ledger.class.php +++ b/include/class/acc_ledger.class.php @@ -920,7 +920,6 @@ class Acc_Ledger extends jrn_def_sql $ret.=_("Devise")." ".$currency_select->input(); $ret.=$currency_input->change('CurrencyComputeMisc(\'p_currency_rate\',\'p_currency_euro\');'); $currency=new Acc_Currency($this->db,0); - $ret.=$currency->get_code(); $nb_row=(isset($nb_item) )?$nb_item:$this->nb; @@ -1389,6 +1388,7 @@ class Acc_Ledger extends jrn_def_sql // for each item, insert into operation_analytique */ $op=new Anc_Operation($this->db); + $op->set_currency_rate($currency_rate); $op->oa_group=$group; $op->j_id=$j_id; $op->oa_date=$e_date; diff --git a/include/class/acc_ledger_fin.class.php b/include/class/acc_ledger_fin.class.php index 9d7b682ab..a27e22204 100644 --- a/include/class/acc_ledger_fin.class.php +++ b/include/class/acc_ledger_fin.class.php @@ -647,7 +647,7 @@ class Acc_Ledger_Fin extends Acc_Ledger $r.='
'.sprintf(_("Taux = %s"),$cur_rate); - $r.='
'.sprintf(_("Nouveau solde = %f %s"),bcmul($new_solde,$cur_rate),$default_currency->get_code()); + $r.='
'.sprintf(_("Nouveau solde = %f %s"),bcdiv($new_solde,$cur_rate),$default_currency->get_code()); } else { $cur=$acc_currency->get_code(); @@ -803,7 +803,7 @@ class Acc_Ledger_Fin extends Acc_Ledger // convert to EUR if needed and round it $amount_input=${"e_other$i" . "_amount"} = round(${"e_other$i" . "_amount"}, 2); - $amount_eur=bcmul($amount_input,$currency_rate); + $amount_eur=bcdiv($amount_input,$currency_rate); diff --git a/include/class/acc_ledger_purchase.class.php b/include/class/acc_ledger_purchase.class.php index 504cd24bd..90911debd 100644 --- a/include/class/acc_ledger_purchase.class.php +++ b/include/class/acc_ledger_purchase.class.php @@ -706,7 +706,7 @@ class Acc_Ledger_Purchase extends Acc_Ledger } // insert into quant_purchase //----- - $price_euro=bcmul(${'e_march'.$i.'_price'}, $p_currency_rate); + $price_euro=bcdiv(${'e_march'.$i.'_price'}, $p_currency_rate); if ( $g_parameter->MY_TVA_USE=='Y') { @@ -933,7 +933,7 @@ class Acc_Ledger_Purchase extends Acc_Ledger $cust_amount=bcsub($cust_amount, $tot_tva_reversed); // Convert paid amount in EUR - $acompte=bcmul($acompte, $p_currency_rate); + $acompte=bcdiv($acompte, $p_currency_rate); $famount=bcsub($cust_amount,$acompte); @@ -1686,10 +1686,11 @@ class Acc_Ledger_Purchase extends Acc_Ledger $decalage=($g_parameter->MY_TVA_USE == 'Y')?'':''; $tot = round(bcadd($tot_amount, $tot_tva), 2); $str_tot=_('Totaux'); - $tot_eur=round(bcmul($tot, $p_currency_rate),2); + $tot_eur=round(bcdiv($tot, $p_currency_rate),2); - // Get currency code - $str_code='EUR'; + // Get currency code + $default_currency=new Acc_Currency($this->db,0); + $str_code=$default_currency->get_code(); if ( $p_currency_code != 0 ) { $acc_currency=new Acc_Currency($this->db); $acc_currency->set_id($p_currency_code); diff --git a/include/class/acc_ledger_sold.class.php b/include/class/acc_ledger_sold.class.php index 0714584f4..ba65074ec 100644 --- a/include/class/acc_ledger_sold.class.php +++ b/include/class/acc_ledger_sold.class.php @@ -619,7 +619,7 @@ class Acc_Ledger_Sold extends Acc_Ledger { $poste_val = $sposte; } // Convert paid amount in EUR - $acompte_eur=bcmul($acompte, $p_currency_rate); + $acompte_eur=bcdiv($acompte, $p_currency_rate); $famount=bcsub($cust_amount,$acompte_eur); $acc_pay->poste = $poste_val; @@ -1449,7 +1449,7 @@ EOF; $Price = new INum(); $Price->setReadOnly(false); $Price->size = 9; - $Price->javascript = "onBlur='format_number(this,4);clean_tva($i);compute_ledger($i)'"; + $Price->javascript = "onBlur=\"format_number(this,4);clean_tva($i);compute_ledger($i);\""; $array[$i]['pu'] = $Price->input("e_march" . $i . "_price", $march_price); $array[$i]['tva'] = ''; $array[$i]['amount_tva'] = ''; @@ -1462,7 +1462,7 @@ EOF; $Tva->set_attribute('compute', $i); $Tva->set_filter("sale"); - $Tva->js = 'onblur="format_number(this);clean_tva(' . $i . ');compute_ledger(' . $i . ')"'; + $Tva->js = 'onblur="format_number(this);clean_tva(' . $i . ');compute_ledger(' . $i . ');"'; $Tva->value = $march_tva_id; $array[$i]['tva'] = $Tva->input("e_march$i" . "_tva_id"); // vat amount @@ -1480,7 +1480,7 @@ EOF; $Quantity = new INum(); $Quantity->setReadOnly(false); $Quantity->size = 8; - $Quantity->javascript = "onChange='format_number(this);clean_tva($i);compute_ledger($i)'"; + $Quantity->javascript = "onChange=\"format_number(this);clean_tva($i);compute_ledger($i);\""; $array[$i]['quantity'] = $Quantity->input("e_quant" . $i, $quant); }// foreach article $f_type = _('Client'); diff --git a/include/template/form_ledger_detail.php b/include/template/form_ledger_detail.php index 9f2bd1ff3..c2df339c2 100644 --- a/include/template/form_ledger_detail.php +++ b/include/template/form_ledger_detail.php @@ -68,7 +68,6 @@ input()?> change('CurrencyCompute(\'p_currency_rate\',\'p_currency_euro\');')?> - get_code();?>