noalyss-commit
[Top][All Lists]
Advanced

[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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]