[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Noalyss-commit] [noalyss] 03/03: Currency : improve decimals
From: |
dwm |
Subject: |
[Noalyss-commit] [noalyss] 03/03: Currency : improve decimals |
Date: |
Sat, 8 Jul 2023 12:36:36 -0400 (EDT) |
sparkyx pushed a commit to branch master
in repository noalyss.
commit 64ecf1ade7a07bb1b2ca084732739174417aca6f
Author: sparkyx <danydb@noalyss.eu>
AuthorDate: Wed Jul 5 17:48:47 2023 +0200
Currency : improve decimals
---
include/class/acc_ledger.class.php | 2 +-
include/class/acc_ledger_purchase.class.php | 2 +-
include/class/acc_ledger_sale.class.php | 2 +-
include/constant.php | 2 +-
include/sql/patch/upgrade186.sql | 28 ++++++++++++++++++++++++++++
include/template/form_ledger_detail.php | 7 +++++--
6 files changed, 37 insertions(+), 6 deletions(-)
diff --git a/include/class/acc_ledger.class.php
b/include/class/acc_ledger.class.php
index 183d61ac9..5f9cce127 100644
--- a/include/class/acc_ledger.class.php
+++ b/include/class/acc_ledger.class.php
@@ -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().
diff --git a/include/class/acc_ledger_purchase.class.php
b/include/class/acc_ledger_purchase.class.php
index 1ffaf5cbd..f9a6ca35d 100644
--- a/include/class/acc_ledger_purchase.class.php
+++ b/include/class/acc_ledger_purchase.class.php
@@ -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\');"';
diff --git a/include/class/acc_ledger_sale.class.php
b/include/class/acc_ledger_sale.class.php
index b8264458f..f742ce1b6 100644
--- a/include/class/acc_ledger_sale.class.php
+++ b/include/class/acc_ledger_sale.class.php
@@ -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\');"';
diff --git a/include/constant.php b/include/constant.php
index f1de5a037..31f8c5172 100644
--- a/include/constant.php
+++ b/include/constant.php
@@ -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--');
diff --git a/include/sql/patch/upgrade186.sql b/include/sql/patch/upgrade186.sql
new file mode 100644
index 000000000..4396cdda7
--- /dev/null
+++ b/include/sql/patch/upgrade186.sql
@@ -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;
\ No newline at end of file
diff --git a/include/template/form_ledger_detail.php
b/include/template/form_ledger_detail.php
index eaf1fe868..e72cd2bc5 100644
--- a/include/template/form_ledger_detail.php
+++ b/include/template/form_ledger_detail.php
@@ -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') {?>