[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Noalyss-commit] [noalyss] 120/218: Currency : send the saldo for financ
From: |
Dany De Bontridder |
Subject: |
[Noalyss-commit] [noalyss] 120/218: Currency : send the saldo for financial ledger |
Date: |
Thu, 12 Sep 2019 15:58:52 -0400 (EDT) |
sparkyx pushed a commit to branch entreprise
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] 72/218: Merge branch 'master' into r700-currency, (continued)
- [Noalyss-commit] [noalyss] 72/218: Merge branch 'master' into r700-currency, Dany De Bontridder, 2019/09/12
- [Noalyss-commit] [noalyss] 83/218: adapt to 7.2 ,init, Dany De Bontridder, 2019/09/12
- [Noalyss-commit] [noalyss] 86/218: Currency : show the currency of the ledger when entering info, Dany De Bontridder, 2019/09/12
- [Noalyss-commit] [noalyss] 89/218: adapt to 7.2 ,array, Dany De Bontridder, 2019/09/12
- [Noalyss-commit] [noalyss] 90/218: Code cleaning : remove SQL with hardcoded value, Dany De Bontridder, 2019/09/12
- [Noalyss-commit] [noalyss] 109/218: Indentation, Dany De Bontridder, 2019/09/12
- [Noalyss-commit] [noalyss] 121/218: Currency : error when displaying, add 4 due to a mistype instruction, Dany De Bontridder, 2019/09/12
- [Noalyss-commit] [noalyss] 126/218: Merge branch 'master' into r700-currency, Dany De Bontridder, 2019/09/12
- [Noalyss-commit] [noalyss] 117/218: Currency : cosmetic display history : show only the value of the card/accounting, Dany De Bontridder, 2019/09/12
- [Noalyss-commit] [noalyss] 116/218: Database upgrade 131, Dany De Bontridder, 2019/09/12
- [Noalyss-commit] [noalyss] 120/218: Currency : send the saldo for financial ledger,
Dany De Bontridder <=
- [Noalyss-commit] [noalyss] 135/218: Translation, Dany De Bontridder, 2019/09/12
- [Noalyss-commit] [noalyss] 123/218: Currency = payment automatic for Sales and Purchases, Dany De Bontridder, 2019/09/12
- [Noalyss-commit] [noalyss] 131/218: Translation + use of httpInput, Dany De Bontridder, 2019/09/12
- [Noalyss-commit] [noalyss] 124/218: 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, 2019/09/12
- [Noalyss-commit] [noalyss] 138/218: Translation, Dany De Bontridder, 2019/09/12
- [Noalyss-commit] [noalyss] 139/218: Translation, Dany De Bontridder, 2019/09/12
- [Noalyss-commit] [noalyss] 137/218: Translation, Dany De Bontridder, 2019/09/12
- [Noalyss-commit] [noalyss] 140/218: Misc. Operation : input : Missing tag TR, Dany De Bontridder, 2019/09/12
- [Noalyss-commit] [noalyss] 144/218: Currency : meaning 1 EUR is worth x currency for Sales, Dany De Bontridder, 2019/09/12
- [Noalyss-commit] [noalyss] 141/218: Currency : for misc. operation, Dany De Bontridder, 2019/09/12