[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Noalyss-commit] [noalyss] 124/238: Currency : when we pay at the same t
From: |
Dany De Bontridder |
Subject: |
[Noalyss-commit] [noalyss] 124/238: Currency : when we pay at the same time as we record the sale / purchase , either the bank is in euro (default currency) or the sale/purchase has the same currency than the financial ledger |
Date: |
Sat, 26 Oct 2019 04:40:49 -0400 (EDT) |
sparkyx pushed a commit to annotated tag rel7110
in repository noalyss.
commit 2134aeffe7083a653f83e33b1c6e82bbb910e529
Author: Dany De Bontridder <address@hidden>
Date: Sun Dec 9 23:57:17 2018 +0100
Currency : when we pay at the same time as we record the sale / purchase ,
either
the bank is in euro (default currency) or the sale/purchase has the same
currency than the financial ledger
---
include/class/acc_ledger.class.php | 28 +++++++++++++++++++++++++++-
include/class/acc_ledger_purchase.class.php | 7 ++++++-
include/class/acc_ledger_sold.class.php | 7 +++++++
3 files changed, 40 insertions(+), 2 deletions(-)
diff --git a/include/class/acc_ledger.class.php
b/include/class/acc_ledger.class.php
index 40addb8..0d6b9a9 100644
--- a/include/class/acc_ledger.class.php
+++ b/include/class/acc_ledger.class.php
@@ -1607,7 +1607,33 @@ class Acc_Ledger extends jrn_def_sql
return false;
throw new Exception("Valeur invalid ".__FILE__.':'.__LINE__);
}
-
+
+ /**
+ * When we write a record for the payment at the same time as a sale or a
purchase, to have a
+ * bank saldo reliable , all the bank operation must be in the same
currency
+ * Operation = Currency 1 and Bank = Currency 2 then it must failed ,
except if currency 2 (of the bank is the
+ * default currency
+ * @param string $p_qcode_payment Qcode of the payment card
+ * @param int $p_currency_id currency id of the sale/purchase operation
+ * @throws Exception
+ */
+ function check_currency($p_qcode_payment, $p_currency_id)
+ {
+ $card=new Fiche($this->db);
+ $card->get_by_qcode($p_qcode_payment);
+ if ( $card->id == 0) throw new Exception (_("Fiche invalide"));
+
+ $ledger = $card->get_bank_ledger();
+ if ( $ledger != NULL )
+ {
+ $ledger_currency_id=$ledger->get_currency()->get_id();
+ // if sale and payment are not the same currency and the
+ if ($ledger_currency_id != 0 && $p_currency_id !=
$ledger_currency_id )
+ {
+ throw new Exception (_("Devise de la banque doit être
identique à l'opération"));
+ }
+ }
+ }
/**
* @brief get the date of the last operation
*/
diff --git a/include/class/acc_ledger_purchase.class.php
b/include/class/acc_ledger_purchase.class.php
index 2fc3cd5..af6f33e 100644
--- a/include/class/acc_ledger_purchase.class.php
+++ b/include/class/acc_ledger_purchase.class.php
@@ -159,7 +159,12 @@ class Acc_Ledger_Purchase extends Acc_Ledger
//------------------------------------------------------
// The "Paid By" check
//------------------------------------------------------
- if ($e_mp != 0 ) $this->check_payment($e_mp,${"e_mp_qcode_".$e_mp});
+ if ($e_mp != 0 ) {
+ $this->check_payment($e_mp,${"e_mp_qcode_".$e_mp});
+ // check for the currency , if we use a financial ledger and a
card which is a bank account (with his own
+ // ledger , then the currency of the operation must be the same
+ $this->check_currency(${"e_mp_qcode_" . $e_mp},$p_currency_code);
+ }
//----------------------------------------
diff --git a/include/class/acc_ledger_sold.class.php
b/include/class/acc_ledger_sold.class.php
index 472de16..0640e10 100644
--- a/include/class/acc_ledger_sold.class.php
+++ b/include/class/acc_ledger_sold.class.php
@@ -218,8 +218,15 @@ class Acc_Ledger_Sold extends Acc_Ledger {
if ($e_mp != 0) {
$this->check_payment($e_mp, ${"e_mp_qcode_" . $e_mp});
+ // check for the currency , if we use a financial ledger and a
card which is a bank account (with his own
+ // ledger , then the currency of the operation must be the same
+ $this->check_currency(${"e_mp_qcode_" . $e_mp},$p_currency_code);
}
+
+
+
+ //
// Check payment date
if ( isset ($mp_date) && trim ($mp_date) != "" && isDate($mp_date) ==
null) {
throw new Exception(_('Date de paiement invalide'),13);
- [Noalyss-commit] [noalyss] 97/238: Fin : currency , add missing info into Operation_Currency, (continued)
- [Noalyss-commit] [noalyss] 97/238: Fin : currency , add missing info into Operation_Currency, Dany De Bontridder, 2019/10/26
- [Noalyss-commit] [noalyss] 95/238: currency : adapt for FIN, Dany De Bontridder, 2019/10/26
- [Noalyss-commit] [noalyss] 103/238: reverse for quant_fin, Dany De Bontridder, 2019/10/26
- [Noalyss-commit] [noalyss] 96/238: Merge branch 'master' into r700-currency, Dany De Bontridder, 2019/10/26
- [Noalyss-commit] [noalyss] 106/238: Currency : adapt for bank saldo, Dany De Bontridder, 2019/10/26
- [Noalyss-commit] [noalyss] 102/238: Version DB 131, Dany De Bontridder, 2019/10/26
- [Noalyss-commit] [noalyss] 113/238: change background, Dany De Bontridder, 2019/10/26
- [Noalyss-commit] [noalyss] 112/238: currency : sale extended html , csv, Dany De Bontridder, 2019/10/26
- [Noalyss-commit] [noalyss] 110/238: Currency : All ledger's listing mode , html , csv and pdf, Dany De Bontridder, 2019/10/26
- [Noalyss-commit] [noalyss] 119/238: currency : adapt middle of payment, Dany De Bontridder, 2019/10/26
- [Noalyss-commit] [noalyss] 124/238: Currency : when we pay at the same time as we record the sale / purchase , either the bank is in euro (default currency) or the sale/purchase has the same currency than the financial ledger,
Dany De Bontridder <=
- [Noalyss-commit] [noalyss] 126/238: Merge branch 'master' into r700-currency, Dany De Bontridder, 2019/10/26
- [Noalyss-commit] [noalyss] 146/238: Currency : history for accounting , correct amount in currency, Dany De Bontridder, 2019/10/26
- [Noalyss-commit] [noalyss] 139/238: Translation, Dany De Bontridder, 2019/10/26
- [Noalyss-commit] [noalyss] 133/238: Translation, Dany De Bontridder, 2019/10/26
- [Noalyss-commit] [noalyss] 142/238: Currency : Precision 6, Dany De Bontridder, 2019/10/26
- [Noalyss-commit] [noalyss] 156/238: Merge branch 'r700-currency' of gitlab.noalyss.eu:noalyss/noalyss into r700-currency, Dany De Bontridder, 2019/10/26
- [Noalyss-commit] [noalyss] 143/238: Currency : precision 6, display default currency , protect used currency against delete, Dany De Bontridder, 2019/10/26
- [Noalyss-commit] [noalyss] 134/238: use of httpInput, Dany De Bontridder, 2019/10/26
- [Noalyss-commit] [noalyss] 135/238: Translation, Dany De Bontridder, 2019/10/26
- [Noalyss-commit] [noalyss] 151/238: Task #1660 : place the button for the inventory on the top, Dany De Bontridder, 2019/10/26