noalyss-commit
[Top][All Lists]
Advanced

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

[Noalyss-commit] [noalyss] 145/238: Currency : the meaning is : 1 euro i


From: Dany De Bontridder
Subject: [Noalyss-commit] [noalyss] 145/238: Currency : the meaning is : 1 euro is worth xxx Currency , so we divide the amount with the currency rate to compute the EUR value
Date: Sat, 26 Oct 2019 04:40:53 -0400 (EDT)

sparkyx pushed a commit to annotated tag rel7110
in repository noalyss.

commit c953d43fd2b5a082e28b334c7697ea4c7c108e1d
Author: Dany De Bontridder <address@hidden>
Date:   Sat Jan 5 11:37:03 2019 +0100

    Currency : the meaning is : 1 euro is worth xxx Currency ,
    so we divide the amount with the currency rate to compute the EUR value
---
 html/js/acc_ledger.js                       |  6 +++---
 include/class/acc_compute.class.php         |  4 ++--
 include/class/acc_ledger.class.php          |  2 +-
 include/class/acc_ledger_fin.class.php      |  4 ++--
 include/class/acc_ledger_purchase.class.php | 11 ++++++-----
 include/class/acc_ledger_sold.class.php     |  8 ++++----
 include/template/form_ledger_detail.php     |  1 -
 7 files changed, 18 insertions(+), 18 deletions(-)

diff --git a/html/js/acc_ledger.js b/html/js/acc_ledger.js
index e488708..e51e7cc 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 a6a33d3..d9c8e0d 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 f128d99..13f69dd 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 9d7b682..a27e222 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.='<br>'.sprintf(_("Taux = %s"),$cur_rate);
-                    $r.='<br>'.sprintf(_("Nouveau solde  = %f 
%s"),bcmul($new_solde,$cur_rate),$default_currency->get_code());
+                    $r.='<br>'.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 504cd24..90911de 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')?'<td></td><td></td><td></td><td></td>':'<td></td>';
          $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 0714584..ba65074 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 9f2bd1f..c2df339 100644
--- a/include/template/form_ledger_detail.php
+++ b/include/template/form_ledger_detail.php
@@ -68,7 +68,6 @@
         <td>
             <?=$currency_select->input()?>
            
<?=$currency_input->change('CurrencyCompute(\'p_currency_rate\',\'p_currency_euro\');')?>
-           <?=$currency->get_code();?>
 
         </td>
     </tr>



reply via email to

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