[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Noalyss-commit] [noalyss] 33/73: CURRENCY : conversion problem
From: |
Dany De Bontridder |
Subject: |
[Noalyss-commit] [noalyss] 33/73: CURRENCY : conversion problem |
Date: |
Fri, 28 May 2021 05:26:30 -0400 (EDT) |
sparkyx pushed a commit to branch master
in repository noalyss.
commit 58cc7c7c04bbf071bee733fbb730b077cd086806
Author: sparkyx <danydb@noalyss.eu>
AuthorDate: Mon Apr 19 11:34:48 2021 +0200
CURRENCY : conversion problem
---
include/class/acc_currency.class.php | 9 +++++++--
include/class/acc_ledger.class.php | 3 +++
include/class/acc_ledger_fin.class.php | 14 ++++++++++++--
include/compta_fin.inc.php | 2 ++
4 files changed, 24 insertions(+), 4 deletions(-)
diff --git a/include/class/acc_currency.class.php
b/include/class/acc_currency.class.php
index 7c17092..21e4eb3 100644
--- a/include/class/acc_currency.class.php
+++ b/include/class/acc_currency.class.php
@@ -140,15 +140,20 @@ class Acc_Currency
*/
function get_rate_date($p_date)
{
+ if ( $this->get_id() == 0 ) { return 1;}
- if (isDate($p_date) == null ) return -1;
+ if (isDate($p_date) == null ) {
+ throw new Exception(_("Date invalide"));
+ }
$sql="select ch_value from currency_history
where
ch_from=(select max(ch_from) from currency_history where ch_from
<= to_date($1,'DD.MM.YYYY') and currency_id=$2)
and currency_id=$2";
$value=$this->cn->get_value($sql,[$p_date,$this->get_id()]);
- if ($value == "") return -2;
+ if ($value == "") {
+ throw new Exception(_("Aucun taux à cette date , aller sur
CFGCURRENCY"));
+ }
return $value;
}
diff --git a/include/class/acc_ledger.class.php
b/include/class/acc_ledger.class.php
index 4869437..d22da1e 100644
--- a/include/class/acc_ledger.class.php
+++ b/include/class/acc_ledger.class.php
@@ -3210,6 +3210,9 @@ class Acc_Ledger extends jrn_def_sql
function get_currency()
{
$cr=new Acc_Currency($this->db,$this->currency_id);
+ if ( $cr->get_id() < 0 ) {
+ throw new Exception("ACL.3214"._("Taux invalide"));
+ }
return $cr;
}
/**
diff --git a/include/class/acc_ledger_fin.class.php
b/include/class/acc_ledger_fin.class.php
index 50a1bc1..e6495ef 100644
--- a/include/class/acc_ledger_fin.class.php
+++ b/include/class/acc_ledger_fin.class.php
@@ -806,8 +806,14 @@ class Acc_Ledger_Fin extends Acc_Ledger
$get_solde=true;
$acc_currency=new
Acc_Currency($this->db,$this->currency_id);
- $currency_rate=$acc_currency->get_rate_date($e_date);
+ // get the currency_rate when we have one date for all
the operations
+ if ( $chdate != 2 ) {
+
$currency_rate=$acc_currency->get_rate_date($e_date);
+ }
+ if (DEBUGNOALYSS > 1) {
+ printf("<p> rate %s </p>",$currency_rate);
+ }
// for each item
for ($i = 0; $i < $nb_item; $i++)
{
@@ -816,7 +822,11 @@ class Acc_Ledger_Fin extends Acc_Ledger
if (strlen(trim(${"e_other$i"})) == 0)
continue;
- if ( $chdate == 2 ) $e_date=${'dateop'.$i};
+ // get the currency_rate when each operation
has its own date
+ if ( $chdate == 2 ) {
+ $e_date=${'dateop'.$i};
+
$currency_rate=$acc_currency->get_rate_date($e_date);
+ }
// if date is date of operation
if ($chdate == 2 && $get_solde )
{
diff --git a/include/compta_fin.inc.php b/include/compta_fin.inc.php
index 9501143..01f2e47 100644
--- a/include/compta_fin.inc.php
+++ b/include/compta_fin.inc.php
@@ -60,6 +60,8 @@ if ( $jrn_priv == 'X')
NoAccess();
exit -1;
}
+$Ledger->set_currency_id();
+
$p_msg="";
//----------------------------------------
// Confirm the operations
- [Noalyss-commit] [noalyss] 23/73: remove debug info, (continued)
- [Noalyss-commit] [noalyss] 23/73: remove debug info, Dany De Bontridder, 2021/05/28
- [Noalyss-commit] [noalyss] 21/73: Fix : warning when Acc_Param not set properly for BANK, CASH,, Dany De Bontridder, 2021/05/28
- [Noalyss-commit] [noalyss] 19/73: Merge branch 'dev-8104', Dany De Bontridder, 2021/05/28
- [Noalyss-commit] [noalyss] 35/73: improve cosmetic, Dany De Bontridder, 2021/05/28
- [Noalyss-commit] [noalyss] 01/73: Nouveau logo, Dany De Bontridder, 2021/05/28
- [Noalyss-commit] [noalyss] 09/73: CSS : position dashboard and ledger name, Dany De Bontridder, 2021/05/28
- [Noalyss-commit] [noalyss] 12/73: Cosmetic, Dany De Bontridder, 2021/05/28
- [Noalyss-commit] [noalyss] 22/73: Fix bug : not TVA asked, Dany De Bontridder, 2021/05/28
- [Noalyss-commit] [noalyss] 20/73: Cosmetic : place of login, Dany De Bontridder, 2021/05/28
- [Noalyss-commit] [noalyss] 31/73: Task #0001961: Devise, cosmetic align number, Dany De Bontridder, 2021/05/28
- [Noalyss-commit] [noalyss] 33/73: CURRENCY : conversion problem,
Dany De Bontridder <=
- [Noalyss-commit] [noalyss] 32/73: Fix bug Forecast, Dany De Bontridder, 2021/05/28
- [Noalyss-commit] [noalyss] 15/73: Cosmetic and small bugs, Dany De Bontridder, 2021/05/28
- [Noalyss-commit] [noalyss] 17/73: Cosmetic :, Dany De Bontridder, 2021/05/28
- [Noalyss-commit] [noalyss] 14/73: Cosmetic bg color tabs, Dany De Bontridder, 2021/05/28
- [Noalyss-commit] [noalyss] 42/73: Cosmetic : position of "invoice, template , ..." after saving an operation, Dany De Bontridder, 2021/05/28
- [Noalyss-commit] [noalyss] 43/73: Improve Manage_Table : align column numeric to the right by default, Dany De Bontridder, 2021/05/28
- [Noalyss-commit] [noalyss] 18/73: Direct Access with a Single AC (without the full path), Dany De Bontridder, 2021/05/28
- [Noalyss-commit] [noalyss] 30/73: Historic : search on currency, Dany De Bontridder, 2021/05/28
- [Noalyss-commit] [noalyss] 26/73: Cosmetic : select_box for javascript , display the selected option, Dany De Bontridder, 2021/05/28
- [Noalyss-commit] [noalyss] 25/73: Cosmetic : icon in dialog box, lightblue when hover, Dany De Bontridder, 2021/05/28