Currency : improve decimals

This commit is contained in:
sparkyx 2023-07-05 17:48:47 +02:00
parent 678e36fa79
commit 64ecf1ade7
6 changed files with 37 additions and 6 deletions

View file

@ -961,7 +961,7 @@ class Acc_Ledger extends jrn_def_sql
$currency_select->selected=$http->request('p_currency_code','string',0);
$currency_input=new INum("p_currency_rate");
$currency_input->prec=6;
$currency_input->prec=8;
$currency_input->id="p_currency_rate";
$currency_input->value=$http->request('p_currency_rate','string',1);
$ret.=tr(td(_("Devise")).td($currency_select->input().

View file

@ -1470,7 +1470,7 @@ 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->prec=8;
$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\');"';

View file

@ -1566,7 +1566,7 @@ EOF;
$currency_input=new INum("p_currency_rate");
$currency_input->id="p_currency_rate";
$currency_input->prec=6;
$currency_input->prec=8;
$currency_input->value=$http->extract('p_currency_rate','string',1);
$currency_input->javascript='onchange="format_number(this,4);CurrencyCompute(\'p_currency_rate\',\'p_currency_euro\');"';

View file

@ -116,7 +116,7 @@ if (!defined("NOALYSS_PACKAGE_REPOSITORY")) {
if (!defined("SYSINFO_DISPLAY")) {
define("SYSINFO_DISPLAY", TRUE);
}
define("DBVERSION", 186);
define("DBVERSION", 187);
define("MONO_DATABASE", 25);
define("DBVERSIONREPO", 20);
define('NOTFOUND', '--not found--');

View file

@ -0,0 +1,28 @@
begin;
-- more precision for currency conversion
DROP VIEW public.v_currency_last_value;
ALTER TABLE public.currency_history ALTER COLUMN ch_value TYPE numeric(20, 8) USING ch_value::numeric;
CREATE OR REPLACE VIEW public.v_currency_last_value
AS WITH recent_rate AS (
SELECT currency_history.currency_id,
max(currency_history.ch_from) AS rc_from
FROM currency_history
GROUP BY currency_history.currency_id
)
SELECT cr1.id AS currency_id,
cr1.cr_name,
cr1.cr_code_iso,
ch1.id AS currency_history_id,
ch1.ch_value,
to_char(recent_rate.rc_from::timestamp with time zone, 'DD.MM.YYYY'::text) AS str_from
FROM currency cr1
JOIN recent_rate ON recent_rate.currency_id = cr1.id
JOIN currency_history ch1 ON recent_rate.currency_id = ch1.currency_id AND recent_rate.rc_from = ch1.ch_from;
insert into version (val,v_description) values (187,'Currency : more decimals');
commit;

View file

@ -5,6 +5,9 @@
* @file
* @brief Display a form to enter an operation Sale or Purchase
*/
$default_currency=new Acc_Currency(Dossier::connect(),0);
?>
<div id="jrn_name_div">
<h1 id="jrn_name"> <?php echo $this->get_name()?></h1>
@ -159,8 +162,8 @@ echo '</tr>';
</tr>
<tr id="row_currency" class="highlight" style="display:none">
<td> <?php echo _("Total")?>
EUR
<td> <?php printf( _("Total %s"),$default_currency->get_code() );?>
</td>
<td class="num visible_gt800"></td>
<?php if ($flag_tva=='Y') {?>