From 3d45f187a63a2c3b6b40f3b0a809b527f032c6f3 Mon Sep 17 00:00:00 2001 From: Dany De Bontridder Date: Fri, 4 Jan 2019 17:33:09 +0100 Subject: [PATCH] Currency : meaning 1 EUR is worth x currency for Sales --- html/js/acc_currency.js | 6 +++--- include/class/acc_ledger_sold.class.php | 11 ++++++----- include/class/anc_operation.class.php | 2 +- include/template/form_ledger_detail.php | 2 +- 4 files changed, 11 insertions(+), 10 deletions(-) diff --git a/html/js/acc_currency.js b/html/js/acc_currency.js index 0fb6fdf71..fdf49ab2a 100644 --- a/html/js/acc_currency.js +++ b/html/js/acc_currency.js @@ -115,7 +115,7 @@ function CurrencyCompute(p_rate,p_update) console.log("rate is nan" + rate); rate=1; } - var tot=tvac*rate; + var tot=tvac/rate; tot=Math.round(tot*100)/100; $(p_update).innerHTML=tot; @@ -148,11 +148,11 @@ function CurrencyComputeMisc(p_rate,p_update) console.log("rate is nan" + rate); rate=1; } - var totDeb=debAmount*rate; + var totDeb=debAmount/rate; totDeb=Math.round(totDeb*100)/100; $('default_currency_deb').innerHTML=totDeb; - var totCred=credAmount*rate; + var totCred=credAmount/rate; totCred=Math.round(totCred*100)/100; $('default_currency_cred').innerHTML=totCred; diff --git a/include/class/acc_ledger_sold.class.php b/include/class/acc_ledger_sold.class.php index ba973c007..0714584f4 100644 --- a/include/class/acc_ledger_sold.class.php +++ b/include/class/acc_ledger_sold.class.php @@ -309,7 +309,7 @@ class Acc_Ledger_Sold extends Acc_Ledger { $amount_currency = bcmul(${'e_march' . $i . '_price'}, ${'e_quant' . $i}); // convert amount to currency - $amount=bcmul($amount_currency,$p_currency_rate); + $amount=bcdiv($amount_currency,$p_currency_rate); $tot_amount = bcadd($tot_amount, $amount); $tot_amount = round($tot_amount, 2); @@ -363,7 +363,7 @@ class Acc_Ledger_Sold extends Acc_Ledger { $l->load(); $tva_item_currency = bcmul($amount, $l->get_parameter('rate')); } - $tva_item=bcmul($tva_item_currency,$p_currency_rate); + $tva_item=bcdiv($tva_item_currency,$p_currency_rate); $tva_item=round($tva_item,2); if (isset($tva[$idx_tva])) { @@ -413,7 +413,7 @@ class Acc_Ledger_Sold extends Acc_Ledger { $op->save_form_plan($_POST, $i, $j_id); } - $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') { /* save into quant_sold */ $r = $this->db->exec_sql("select insert_quant_sold ($1,$2,$3,$4,$5,$6,$7,$8,$9,$10)", array(null, /* 1 */ @@ -942,12 +942,13 @@ class Acc_Ledger_Sold extends Acc_Ledger { // Add the sum $decalage=($g_parameter->MY_TVA_USE == 'Y')?'':''; $tot = bcadd($tot_amount, $tot_tva, 2); - $tot_eur=round(bcmul($tot, $p_currency_rate),2); + $tot_eur=round(bcdiv($tot, $p_currency_rate),2); $tot=nbm($tot); $str_tot=_('Totaux'); // Get currency code - $str_code='EUR'; + $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/anc_operation.class.php b/include/class/anc_operation.class.php index 13445271f..aa3b19d3b 100644 --- a/include/class/anc_operation.class.php +++ b/include/class/anc_operation.class.php @@ -799,7 +799,7 @@ class Anc_Operation $op->oa_group=$this->oa_group; $op->j_id=$p_j_id; // convert oa_amount to EUR - $op->oa_amount=bcmul($val[$p_item][$row],$this->currency_rate); + $op->oa_amount=bcdiv($val[$p_item][$row],$this->currency_rate); $op->oa_debit=$this->oa_debit; $op->oa_date=$this->oa_date; diff --git a/include/template/form_ledger_detail.php b/include/template/form_ledger_detail.php index ab315cf77..9f2bd1ff3 100644 --- a/include/template/form_ledger_detail.php +++ b/include/template/form_ledger_detail.php @@ -68,7 +68,7 @@ input()?> change('CurrencyCompute(\'p_currency_rate\',\'p_currency_euro\');')?> - get_code();?> + get_code();?>