[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Noalyss-commit] [noalyss] 120/238: Currency : send the saldo for financ
From: |
Dany De Bontridder |
Subject: |
[Noalyss-commit] [noalyss] 120/238: Currency : send the saldo for financial ledger |
Date: |
Sat, 26 Oct 2019 04:40:49 -0400 (EDT) |
sparkyx pushed a commit to annotated tag rel7110
in repository noalyss.
commit f16bc6f977f3486a58143251289109cc32274b58
Author: Dany De Bontridder <address@hidden>
Date: Sun Dec 9 17:04:07 2018 +0100
Currency : send the saldo for financial ledger
---
include/ajax/ajax_bank_saldo.php | 75 ++++++++++++++++++++++++++++------------
1 file changed, 52 insertions(+), 23 deletions(-)
diff --git a/include/ajax/ajax_bank_saldo.php b/include/ajax/ajax_bank_saldo.php
index 409d17b..8cb2548 100644
--- a/include/ajax/ajax_bank_saldo.php
+++ b/include/ajax/ajax_bank_saldo.php
@@ -1,4 +1,5 @@
<?php
+
/*
* This file is part of NOALYSS.
*
@@ -15,11 +16,11 @@
* You should have received a copy of the GNU General Public License
* along with NOALYSS; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-*/
+ */
// Copyright Author Dany De Bontridder address@hidden
-/*!\file
+/* !\file
* \brief respond ajax request, the get contains
* the value :
* - l for ledger
@@ -28,48 +29,76 @@
*/
-/*!\file
+/* !\file
* \brief get the saldo of a account
* the get variable are :
* - l the jrn id
* - ctl the ctl where to get the quick_code
*/
-if ( ! defined ('ALLOWED') ) die('Appel direct ne sont pas permis');
+if (!defined('ALLOWED'))
+ die('Appel direct ne sont pas permis');
require_once NOALYSS_INCLUDE.'/class/user.class.php';
require_once NOALYSS_INCLUDE.'/class/dossier.class.php';
require_once NOALYSS_INCLUDE.'/class/fiche.class.php';
-extract($_GET, EXTR_SKIP);
/* check the parameters */
-foreach ( array('j','ctl') as $a )
+foreach (array('j', 'ctl') as $a)
{
- if ( ! isset(${$a}) )
+ if (!isset(${$a}))
{
echo "missing $a";
return;
}
}
+$http=new HttpInput();
+try
+{
+ $ledger_id=$http->get('j', "number");
-if ( $g_user->check_jrn($_GET['j'])=='X' ) return '{"saldo":"0"}';
-/* make a filter on the exercice */
+ if ($g_user->check_jrn($ledger_id)=='X')
+ return '{"saldo":"0"}';
-$filter_year=" j_tech_per in (select p_id from parm_periode ".
- "where p_exercice='".$g_user->get_exercice()."')";
+ $id=$cn->get_value('select jrn_def_bank from jrn_def where jrn_def_id=$1',
array($ledger_id));
+ if ($id=='')
+ {
+ echo '{"saldo":"ERR"}';
+ return;
+ }
+ $acc=new Fiche($cn, $id);
-$id=$cn->get_value('select jrn_def_bank from jrn_def where
jrn_def_id=$1',array($_GET['j']));
-if ( $id == '' ) {
- echo '{"saldo":"ERR"}';
- return;
-}
-$acc=new Fiche($cn,$id);
+ $ledger=new Acc_Ledger_Fin($cn, $ledger_id);
+ $ledger->load();
+ // Is ledger in Default currency
+ if ($ledger->currency_id==0)
+ {
+ /* make a filter on the exercice */
-$res=$acc->get_bk_balance($filter_year." and ( trim(jr_pj_number) != '' and
jr_pj_number is not null)" );
+ $filter_year=" j_tech_per in (select p_id from parm_periode ".
+ "where p_exercice='".$g_user->get_exercice()."')";
-if ( empty($res) ) return '{"saldo":"0"}';
-$solde=$res['solde'];
-if ( $res['debit'] < $res['credit'] ) $solde=$solde*(-1);
-//header("Content-type: text/html; charset: utf8",true);
-echo '{"saldo":"'.$solde.'"}';
+
+ $res=$acc->get_bk_balance($filter_year." and ( trim(jr_pj_number) !=
'' and jr_pj_number is not null)");
+
+
+ if (empty($res))
+ return '{"saldo":"0"}';
+ $solde=$res['solde'];
+ if ($res['debit']<$res['credit'])
+ $solde=$solde*(-1);
+
+ echo '{"saldo":"'.$solde.'"}';
+ } else
+ {
+ $solde=$acc->get_bk_balance_currency();
+ echo '{"saldo":"'.$solde.'"}';
+ }
+}
+catch (Exception $e)
+{
+ record_log(__FILE__.":".__LINE__);
+ record_log($e->getMessage());
+ echo '{"saldo":"ERR"}';
+}
\ No newline at end of file
- [Noalyss-commit] [noalyss] 121/238: Currency : error when displaying, add 4 due to a mistype instruction, (continued)
- [Noalyss-commit] [noalyss] 121/238: Currency : error when displaying, add 4 due to a mistype instruction, Dany De Bontridder, 2019/10/26
- [Noalyss-commit] [noalyss] 128/238: Missing bracket, Dany De Bontridder, 2019/10/26
- [Noalyss-commit] [noalyss] 136/238: Translation, Dany De Bontridder, 2019/10/26
- [Noalyss-commit] [noalyss] 131/238: Translation + use of httpInput, Dany De Bontridder, 2019/10/26
- [Noalyss-commit] [noalyss] 148/238: remove commented code, Dany De Bontridder, 2019/10/26
- [Noalyss-commit] [noalyss] 125/238: Merge branch 'master' into r700-currency, Dany De Bontridder, 2019/10/26
- [Noalyss-commit] [noalyss] 170/238: Merge branch 'r700-currency' of gitlab.noalyss.eu:noalyss/noalyss into r700-currency, Dany De Bontridder, 2019/10/26
- [Noalyss-commit] [noalyss] 129/238: Esthetic with button "Add accounting", Dany De Bontridder, 2019/10/26
- [Noalyss-commit] [noalyss] 144/238: Currency : meaning 1 EUR is worth x currency for Sales, Dany De Bontridder, 2019/10/26
- [Noalyss-commit] [noalyss] 132/238: Translation, Dany De Bontridder, 2019/10/26
- [Noalyss-commit] [noalyss] 120/238: Currency : send the saldo for financial ledger,
Dany De Bontridder <=
- [Noalyss-commit] [noalyss] 145/238: Currency : the meaning is : 1 euro is worth xxx Currency , so we divide the amount with the currency rate to compute the EUR value, Dany De Bontridder, 2019/10/26
- [Noalyss-commit] [noalyss] 140/238: Misc. Operation : input : Missing tag TR, Dany De Bontridder, 2019/10/26
- [Noalyss-commit] [noalyss] 137/238: Translation, Dany De Bontridder, 2019/10/26
- [Noalyss-commit] [noalyss] 141/238: Currency : for misc. operation, Dany De Bontridder, 2019/10/26
- [Noalyss-commit] [noalyss] 164/238: Currency Show currency info for MISC, Dany De Bontridder, 2019/10/26
- [Noalyss-commit] [noalyss] 161/238: PHP 7.2 incomptability : sizeof of not array, Dany De Bontridder, 2019/10/26
- [Noalyss-commit] [noalyss] 166/238: Typo, Dany De Bontridder, 2019/10/26
- [Noalyss-commit] [noalyss] 154/238: by default jrn is an empty array, Dany De Bontridder, 2019/10/26
- [Noalyss-commit] [noalyss] 149/238: Currency : purchase, save all detail also in currency, fix problem with the advance payment, Dany De Bontridder, 2019/10/26
- [Noalyss-commit] [noalyss] 160/238: Protect parameters, Dany De Bontridder, 2019/10/26