[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Noalyss-commit] [noalyss] 96/162: Currency : financial use the rate dep
From: |
Dany De Bontridder |
Subject: |
[Noalyss-commit] [noalyss] 96/162: Currency : financial use the rate depending of the operation date |
Date: |
Sat, 11 Jul 2020 13:23:49 -0400 (EDT) |
sparkyx pushed a commit to annotated tag E-4
in repository noalyss.
commit 23b60f92ea2580e382d32dc144a0c6c3cd9c2375
Author: Dany De Bontridder <danydb@noalyss.eu>
AuthorDate: Wed Nov 28 10:00:09 2018 +0100
Currency : financial use the rate depending of the operation date
---
include/class/acc_currency.class.php | 17 +++++++++++++++++
include/class/acc_ledger_fin.class.php | 5 +++--
2 files changed, 20 insertions(+), 2 deletions(-)
diff --git a/include/class/acc_currency.class.php
b/include/class/acc_currency.class.php
index 3012916..7470957 100644
--- a/include/class/acc_currency.class.php
+++ b/include/class/acc_currency.class.php
@@ -133,6 +133,23 @@ class Acc_Currency
return $sum;
}
+ /**
+ * Return the rate used at a certain date or -1 if date if not in the
format DD.MM.YYYY or -2 if no value is found
+ * @param date $p_date
+ */
+ function get_rate_date($p_date)
+ {
+ global $cn;
+ if (isDate($p_date) == null ) return -1;
+
+ $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=$cn->get_value($sql,[$p_date,$this->get_id()]);
+ if ($value == "") return -2;
+ return $value;
+ }
}
diff --git a/include/class/acc_ledger_fin.class.php
b/include/class/acc_ledger_fin.class.php
index 8ae133f..30206fa 100644
--- a/include/class/acc_ledger_fin.class.php
+++ b/include/class/acc_ledger_fin.class.php
@@ -630,7 +630,7 @@ class Acc_Ledger_Fin extends Acc_Ledger
$r.="</TABLE>";
$acc_currency=$this->get_currency();
$cur=$acc_currency->get_code();
- $cur_rate=$acc_currency->get_rate();
+ $cur_rate=$acc_currency->get_rate_date($e_date);
$default_currency=new Acc_Currency($this->db , 0);
// saldo
$r.='<br>'.sprintf(_("Ancien solde = %d %s"),$solde, $cur);
@@ -639,6 +639,7 @@ class Acc_Ledger_Fin extends Acc_Ledger
if ( $acc_currency->get_id() != 0)
{
+ $r.='<br>'.sprintf(_("Taux = %s"),$cur_rate);
$r.='<br>'.sprintf(_("Nouveau solde = %d
%s"),bcmul($new_solde,$cur_rate),$default_currency->get_code());
}
$r.='<br>'.sprintf(_("Difference = %d %s"), $tot_amount, $cur);
@@ -756,7 +757,7 @@ 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();
+ $currency_rate=$acc_currency->get_rate_date($e_date);
// for each item
for ($i = 0; $i < $nb_item; $i++)
- [Noalyss-commit] [noalyss] 81/162: Currency : financial ledger can be set to a specific currency, (continued)
- [Noalyss-commit] [noalyss] 81/162: Currency : financial ledger can be set to a specific currency, Dany De Bontridder, 2020/07/11
- [Noalyss-commit] [noalyss] 84/162: FIN : cosmetic : bug due the currency feature in the input there are 2 supplementary rows for total in EUR and CURRENCY. Those rows don't exist for FIN, Dany De Bontridder, 2020/07/11
- [Noalyss-commit] [noalyss] 85/162: adapt to 7.2 ,array, Dany De Bontridder, 2020/07/11
- [Noalyss-commit] [noalyss] 86/162: Code cleaning : remove SQL with hardcoded value, Dany De Bontridder, 2020/07/11
- [Noalyss-commit] [noalyss] 88/162: Merge branch 'master' into r700-currency, Dany De Bontridder, 2020/07/11
- [Noalyss-commit] [noalyss] 87/162: PHP 7.2 : fix incomptability, Dany De Bontridder, 2020/07/11
- [Noalyss-commit] [noalyss] 89/162: translate, Dany De Bontridder, 2020/07/11
- [Noalyss-commit] [noalyss] 92/162: Merge branch 'master' into r700-currency, Dany De Bontridder, 2020/07/11
- [Noalyss-commit] [noalyss] 93/162: Fin : currency , add missing info into Operation_Currency, Dany De Bontridder, 2020/07/11
- [Noalyss-commit] [noalyss] 91/162: currency : adapt for FIN, Dany De Bontridder, 2020/07/11
- [Noalyss-commit] [noalyss] 96/162: Currency : financial use the rate depending of the operation date,
Dany De Bontridder <=
- [Noalyss-commit] [noalyss] 90/162: acc_ledger_fin : cosmetic : input, Dany De Bontridder, 2020/07/11
- [Noalyss-commit] [noalyss] 94/162: Fin currency : detail operation show currency , rate and amount, Dany De Bontridder, 2020/07/11
- [Noalyss-commit] [noalyss] 95/162: Modify quant_fin , we add a column j_id to have a fk to jrnx and operation_currency, Dany De Bontridder, 2020/07/11
- [Noalyss-commit] [noalyss] 97/162: Currency : SQL quant_fin is adapted, Dany De Bontridder, 2020/07/11
- [Noalyss-commit] [noalyss] 98/162: Version DB 131, Dany De Bontridder, 2020/07/11
- [Noalyss-commit] [noalyss] 99/162: reverse for quant_fin, Dany De Bontridder, 2020/07/11
- [Noalyss-commit] [noalyss] 100/162: Reverse for Currency, Dany De Bontridder, 2020/07/11
- [Noalyss-commit] [noalyss] 102/162: Currency : adapt for bank saldo, Dany De Bontridder, 2020/07/11
- [Noalyss-commit] [noalyss] 103/162: Currency : export PDF and CSV with currency for printing financial ledger listing(oneline), Dany De Bontridder, 2020/07/11
- [Noalyss-commit] [noalyss] 101/162: Background color, Dany De Bontridder, 2020/07/11