noalyss-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Noalyss-commit] [noalyss] 140/162: Currency : meaning 1 EUR is worth x


From: Dany De Bontridder
Subject: [Noalyss-commit] [noalyss] 140/162: Currency : meaning 1 EUR is worth x currency for Sales
Date: Sat, 11 Jul 2020 13:24:05 -0400 (EDT)

sparkyx pushed a commit to annotated tag E-4
in repository noalyss.

commit 3d45f187a63a2c3b6b40f3b0a809b527f032c6f3
Author: Dany De Bontridder <danydb@noalyss.eu>
AuthorDate: Fri Jan 4 17:33:09 2019 +0100

    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 0fb6fdf..fdf49ab 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 ba973c0..0714584 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')?'<td></td><td></td><td></td><td></td>':'<td></td>';
          $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 1344527..aa3b19d 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 ab315cf..9f2bd1f 100644
--- a/include/template/form_ledger_detail.php
+++ b/include/template/form_ledger_detail.php
@@ -68,7 +68,7 @@
         <td>
             <?=$currency_select->input()?>
            
<?=$currency_input->change('CurrencyCompute(\'p_currency_rate\',\'p_currency_euro\');')?>
-            <?=$currency->get_code();?>
+           <?=$currency->get_code();?>
 
         </td>
     </tr>



reply via email to

[Prev in Thread] Current Thread [Next in Thread]