[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Noalyss-commit] [noalyss] 100/218: Currency : financial use the rate de
From: |
Dany De Bontridder |
Subject: |
[Noalyss-commit] [noalyss] 100/218: Currency : financial use the rate depending of the operation date |
Date: |
Thu, 12 Sep 2019 15:58:48 -0400 (EDT) |
sparkyx pushed a commit to branch entreprise
in repository noalyss.
commit 23b60f92ea2580e382d32dc144a0c6c3cd9c2375
Author: Dany De Bontridder <address@hidden>
Date: 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] 74/218: Merge branch 'r700-currency' of gitlab.noalyss.eu:noalyss/noalyss into r700-currency, (continued)
- [Noalyss-commit] [noalyss] 74/218: Merge branch 'r700-currency' of gitlab.noalyss.eu:noalyss/noalyss into r700-currency, Dany De Bontridder, 2019/09/12
- [Noalyss-commit] [noalyss] 76/218: Bug : cannot set group, Dany De Bontridder, 2019/09/12
- [Noalyss-commit] [noalyss] 69/218: Create lib for Tabs, Dany De Bontridder, 2019/09/12
- [Noalyss-commit] [noalyss] 77/218: Manage_Table : issue with the type select, Dany De Bontridder, 2019/09/12
- [Noalyss-commit] [noalyss] 80/218: Improve debug info, Dany De Bontridder, 2019/09/12
- [Noalyss-commit] [noalyss] 88/218: 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, 2019/09/12
- [Noalyss-commit] [noalyss] 85/218: Currency : financial ledger can be set to a specific currency, Dany De Bontridder, 2019/09/12
- [Noalyss-commit] [noalyss] 102/218: Version DB 131, Dany De Bontridder, 2019/09/12
- [Noalyss-commit] [noalyss] 101/218: Currency : SQL quant_fin is adapted, Dany De Bontridder, 2019/09/12
- [Noalyss-commit] [noalyss] 103/218: reverse for quant_fin, Dany De Bontridder, 2019/09/12
- [Noalyss-commit] [noalyss] 100/218: Currency : financial use the rate depending of the operation date,
Dany De Bontridder <=
- [Noalyss-commit] [noalyss] 94/218: acc_ledger_fin : cosmetic : input, Dany De Bontridder, 2019/09/12
- [Noalyss-commit] [noalyss] 99/218: Modify quant_fin , we add a column j_id to have a fk to jrnx and operation_currency, Dany De Bontridder, 2019/09/12
- [Noalyss-commit] [noalyss] 108/218: acc_ledger_fin . translation, Dany De Bontridder, 2019/09/12
- [Noalyss-commit] [noalyss] 111/218: Currency : sales in listing mode, Dany De Bontridder, 2019/09/12
- [Noalyss-commit] [noalyss] 106/218: Currency : adapt for bank saldo, Dany De Bontridder, 2019/09/12
- [Noalyss-commit] [noalyss] 112/218: currency : sale extended html , csv, Dany De Bontridder, 2019/09/12
- [Noalyss-commit] [noalyss] 110/218: Currency : All ledger's listing mode , html , csv and pdf, Dany De Bontridder, 2019/09/12
- [Noalyss-commit] [noalyss] 119/218: currency : adapt middle of payment, Dany De Bontridder, 2019/09/12
- [Noalyss-commit] [noalyss] 107/218: Currency : export PDF and CSV with currency for printing financial ledger listing(oneline), Dany De Bontridder, 2019/09/12
- [Noalyss-commit] [noalyss] 130/218: typo doc, Dany De Bontridder, 2019/09/12