[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Noalyss-commit] [noalyss] 100/238: Currency : financial use the rate de
From: |
Dany De Bontridder |
Subject: |
[Noalyss-commit] [noalyss] 100/238: Currency : financial use the rate depending of the operation date |
Date: |
Sat, 26 Oct 2019 04:40:43 -0400 (EDT) |
sparkyx pushed a commit to annotated tag rel7110
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] 192/238: Mantis #0001618: Journaux - choix du type en premier, (continued)
- [Noalyss-commit] [noalyss] 192/238: Mantis #0001618: Journaux - choix du type en premier, Dany De Bontridder, 2019/10/26
- [Noalyss-commit] [noalyss] 195/238: mantis #1690: Bug : impossible d'utiliser < dans Inplace_Edit Replace strip_tags , add a space before the "<", Dany De Bontridder, 2019/10/26
- [Noalyss-commit] [noalyss] 228/238: Bug with p_jrn, Dany De Bontridder, 2019/10/26
- [Noalyss-commit] [noalyss] 223/238: Task #0001703: Faciliter effacement montants dans les filtres, Dany De Bontridder, 2019/10/26
- [Noalyss-commit] [noalyss] 234/238: fixup! Printtva , under some circumstance tva_summary::check fails, Dany De Bontridder, 2019/10/26
- [Noalyss-commit] [noalyss] 201/238: Merge branch 'dev7109' into entreprise, Dany De Bontridder, 2019/10/26
- [Noalyss-commit] [noalyss] 93/238: translate, Dany De Bontridder, 2019/10/26
- [Noalyss-commit] [noalyss] 98/238: Fin currency : detail operation show currency , rate and amount, Dany De Bontridder, 2019/10/26
- [Noalyss-commit] [noalyss] 104/238: Reverse for Currency, Dany De Bontridder, 2019/10/26
- [Noalyss-commit] [noalyss] 101/238: Currency : SQL quant_fin is adapted, Dany De Bontridder, 2019/10/26
- [Noalyss-commit] [noalyss] 100/238: Currency : financial use the rate depending of the operation date,
Dany De Bontridder <=
- [Noalyss-commit] [noalyss] 108/238: acc_ledger_fin . translation, Dany De Bontridder, 2019/10/26
- [Noalyss-commit] [noalyss] 99/238: Modify quant_fin , we add a column j_id to have a fk to jrnx and operation_currency, Dany De Bontridder, 2019/10/26
- [Noalyss-commit] [noalyss] 109/238: Indentation, Dany De Bontridder, 2019/10/26
- [Noalyss-commit] [noalyss] 116/238: Database upgrade 131, Dany De Bontridder, 2019/10/26
- [Noalyss-commit] [noalyss] 111/238: Currency : sales in listing mode, Dany De Bontridder, 2019/10/26
- [Noalyss-commit] [noalyss] 115/238: Currency : ledger printing for FIN + detail operation, Dany De Bontridder, 2019/10/26
- [Noalyss-commit] [noalyss] 127/238: Merge commit '3f53de417dd89e9a90a386404f93f8648155e046' into r700-currency, Dany De Bontridder, 2019/10/26
- [Noalyss-commit] [noalyss] 118/238: Currency : export CSV history for card and accounting, fix bug with unneeded oc_vat_amount + add the currency rate, Dany De Bontridder, 2019/10/26
- [Noalyss-commit] [noalyss] 114/238: Currency : purchase oneline + extended html and csv, Dany De Bontridder, 2019/10/26
- [Noalyss-commit] [noalyss] 121/238: Currency : error when displaying, add 4 due to a mistype instruction, Dany De Bontridder, 2019/10/26