Currency : the meaning is : 1 euro is worth xxx Currency ,

so we divide the amount with the currency rate to compute the EUR value
This commit is contained in:
Dany De Bontridder 2019-01-05 11:37:03 +01:00
parent 3d45f187a6
commit c953d43fd2
7 changed files with 18 additions and 18 deletions

View file

@ -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');
}
/**

View file

@ -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)

View file

@ -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;

View file

@ -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);

View file

@ -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);

View file

@ -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');

View file

@ -68,7 +68,6 @@
<td>
<?=$currency_select->input()?>
<?=$currency_input->change('CurrencyCompute(\'p_currency_rate\',\'p_currency_euro\');')?>
<?=$currency->get_code();?>
</td>
</tr>