From cc5c5abd6e99977530ced6f8bf5105294b3877eb Mon Sep 17 00:00:00 2001 From: Dany De Bontridder Date: Fri, 4 Jan 2019 16:44:14 +0100 Subject: [PATCH] Currency : Precision 6 --- include/class/acc_compute.class.php | 4 ++-- include/class/acc_ledger.class.php | 6 +++--- include/class/acc_ledger_purchase.class.php | 3 ++- include/class/acc_ledger_sold.class.php | 1 + include/lib/manage_table_sql.class.php | 20 +++++++++++++++++++- include/template/form_ledger_detail.php | 2 +- 6 files changed, 28 insertions(+), 8 deletions(-) diff --git a/include/class/acc_compute.class.php b/include/class/acc_compute.class.php index 49ba34d5c..a6a33d384 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); + $this->amount=bcmul($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); + $this->amount_vat=bcmul($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 7dfcd0e5d..f128d9968 100644 --- a/include/class/acc_ledger.class.php +++ b/include/class/acc_ledger.class.php @@ -913,12 +913,12 @@ class Acc_Ledger extends jrn_def_sql $currency_select = $this->CurrencyInput("currency_code", "p_currency_rate" , "p_currency_euro"); $currency_select->selected=$http->request('p_currency_code','string',0); - $currency_input=new INum("p_currency_rate",6); + $currency_input=new INum("p_currency_rate"); + $currency_input->prec=6; $currency_input->id="p_currency_rate"; $currency_input->value=$http->request('p_currency_rate','string',1); - $currency_input->javascript='onchange="format_number(this,6);CurrencyCompute(\'p_currency_rate\',\'p_currency_euro\');"'; $ret.=_("Devise")." ".$currency_select->input(); - $ret.=$currency_input->change(); + $ret.=$currency_input->change('CurrencyComputeMisc(\'p_currency_rate\',\'p_currency_euro\');'); $currency=new Acc_Currency($this->db,0); $ret.=$currency->get_code(); diff --git a/include/class/acc_ledger_purchase.class.php b/include/class/acc_ledger_purchase.class.php index fefced5d6..504cd24bd 100644 --- a/include/class/acc_ledger_purchase.class.php +++ b/include/class/acc_ledger_purchase.class.php @@ -1397,9 +1397,10 @@ class Acc_Ledger_Purchase extends Acc_Ledger $currency_select->selected=$http->request('p_currency_code','string',0); $currency_input=new INum("p_currency_rate"); + $currency_input->prec=6; $currency_input->id="p_currency_rate"; $currency_input->value=$http->request('p_currency_rate','string',1); - $currency_input->javascript='onchange="format_number(this,4);CurrencyCompute(\'p_currency_rate\',\'p_currency_euro\');"'; + $currency_input->javascript='onchange="format_number(this,6);CurrencyCompute(\'p_currency_rate\',\'p_currency_euro\');"'; $currency=new Acc_Currency($this->db,0); diff --git a/include/class/acc_ledger_sold.class.php b/include/class/acc_ledger_sold.class.php index e55ae9bfc..ba973c007 100644 --- a/include/class/acc_ledger_sold.class.php +++ b/include/class/acc_ledger_sold.class.php @@ -1490,6 +1490,7 @@ EOF; $currency_input=new INum("p_currency_rate"); $currency_input->id="p_currency_rate"; + $currency_input->prec=6; $currency_input->value=$http->request('p_currency_rate','string',1); $currency_input->javascript='onchange="format_number(this,4);CurrencyCompute(\'p_currency_rate\',\'p_currency_euro\');"'; diff --git a/include/lib/manage_table_sql.class.php b/include/lib/manage_table_sql.class.php index 2982c4d94..b642c5dae 100644 --- a/include/lib/manage_table_sql.class.php +++ b/include/lib/manage_table_sql.class.php @@ -893,7 +893,7 @@ function check() $text->size=$min_size; echo $text->input(); } - elseif ($this->a_type[$key]=="numeric") + elseif ($this->a_type[$key]=="numeric") // number 2 decimale { $text=new INum($key); $text->value=$value; @@ -901,6 +901,24 @@ function check() $text->size=$min_size; echo $text->input(); } + elseif ($this->a_type[$key]=="numeric4") // number 4 decimale + { + $text=new INum($key); + $text->prec=4; + $text->value=$value; + $min_size=(strlen($value)<10)?10:strlen($value)+1; + $text->size=$min_size; + echo $text->input(); + } + elseif ($this->a_type[$key]=="numeric6") // number 6 decimale + { + $text=new INum($key); + $text->prec=6; + $text->value=$value; + $min_size=(strlen($value)<10)?10:strlen($value)+1; + $text->size=$min_size; + echo $text->input(); + } elseif ($this->a_type[$key]=="date") { $text=new IDate($key); diff --git a/include/template/form_ledger_detail.php b/include/template/form_ledger_detail.php index b337c9d57..ab315cf77 100644 --- a/include/template/form_ledger_detail.php +++ b/include/template/form_ledger_detail.php @@ -67,7 +67,7 @@ input()?> - change()?> + change('CurrencyCompute(\'p_currency_rate\',\'p_currency_euro\');')?> get_code();?>