noalyss-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Noalyss-commit] [noalyss] 82/173: Merge branch 'dev7109' into entrepris


From: Dany De Bontridder
Subject: [Noalyss-commit] [noalyss] 82/173: Merge branch 'dev7109' into entreprise
Date: Mon, 22 Mar 2021 12:58:51 -0400 (EDT)

sparkyx pushed a commit to branch master
in repository noalyss.

commit 6872a81d8bdcdfdc3c0630a6c971deddc9ee9cde
Merge: f33ff14 dfc79b6
Author: Dany De Bontridder <danydb@noalyss.eu>
AuthorDate: Mon Aug 26 15:50:46 2019 +0200

    Merge branch 'dev7109' into entreprise

 dev/get_database_item.sh                           |    9 +-
 html/ajax_misc.php                                 |   86 +-
 html/js/managetable.js                             |    2 +-
 html/js/scripts.js                                 |   35 +
 html/lang/en_US/LC_MESSAGES/messages.po            | 2025 +++++-----
 html/lang/messages.po                              | 4030 ++++++++++++--------
 html/lang/nl_NL/LC_MESSAGES/messages.po            | 2680 +++++++------
 html/style-classic.css                             |   11 +
 html/style-classic7.css                            |   14 +-
 html/style-light.css                               |   10 +
 include/ajax/ajax_card.php                         |    1 +
 include/ajax/ajax_history.php                      |    2 +
 include/ajax/ajax_ledger.php                       |    3 +-
 include/cfgledger.inc.php                          |    8 +-
 include/class/acc_ledger.class.php                 |   93 +-
 include/class/acc_ledger_fin.class.php             |    2 +-
 include/class/acc_ledger_history_generic.class.php |    3 +
 include/class/acc_ledger_purchase.class.php        |   10 +-
 include/class/acc_ledger_sold.class.php            |   11 +-
 include/class/acc_operation.class.php              |    2 +-
 include/class/anc_balance_simple.class.php         |   24 +-
 include/class/customer.class.php                   |    5 +-
 include/class/fiche.class.php                      |    2 +-
 include/class/follow_up.class.php                  |    2 +-
 include/class/gestion_sold.class.php               |    4 +-
 include/class/periode.class.php                    |   20 +-
 include/class/pre_op_fin.class.php                 |    6 +-
 include/class/pre_operation.class.php              |    4 +-
 include/class/tax_summary.class.php                |  355 ++
 include/compta_ach.inc.php                         |   12 +-
 include/compta_fin.inc.php                         |    6 +-
 include/compta_ods.inc.php                         |   28 +-
 include/compta_ven.inc.php                         |   20 +-
 include/constant.php                               |    2 +-
 include/database.item.php                          |   58 +-
 include/database/currency_history_sql.class.php    |    2 +-
 include/database/currency_sql.class.php            |    2 +-
 include/database/jrn_def_sql.class.php             |  472 +--
 include/database/operation_currency_sql.class.php  |    2 +-
 .../database/v_currency_last_value_sql.class.php   |    2 +-
 include/export/export_printtva_csv.php             |   83 +
 include/export/export_printtva_pdf.php             |  353 ++
 include/lib/database_core.class.php                |    2 +-
 include/lib/html_input.class.php                   |    4 +-
 include/lib/icon_action.class.php                  |   23 +
 include/lib/input_switch.class.php                 |   81 +
 include/lib/manage_table_sql.class.php             |    1 -
 include/lib/message_javascript.php                 |    2 +-
 include/modele.inc.php                             |    3 +-
 include/operation_ods_new.inc.php                  |    2 +-
 include/sql/patch/upgrade135.sql                   |    6 +-
 include/sql/patch/upgrade136.sql                   |   15 +
 include/tax_summary.inc.php                        |   72 +
 .../acc_ledger_history_purchase_extended.php       |    2 +-
 include/template/ledger_detail_bottom.php          |   11 +-
 include/template/param_jrn.php                     |  194 +-
 include/template/tax_summary_display.php           |  375 ++
 include/verif_bilan.inc.php                        |   10 +-
 scenario/HtmlInput.test.php                        |   91 +
 scenario/icon_actionTest.php                       |    7 +-
 unit-test/include/class/acc_account.classTest.php  |   87 +-
 unit-test/include/class/acc_balanceTest.class.php  |   15 +-
 unit-test/include/class/acc_ledgerTest.class.php   |  320 +-
 unit-test/include/class/dossierTest.class.php      |    1 -
 64 files changed, 7188 insertions(+), 4637 deletions(-)

diff --cc html/ajax_misc.php
index 1ecefcd,c209d9d..7462fe8
--- a/html/ajax_misc.php
+++ b/html/ajax_misc.php
@@@ -251,12 -251,10 +251,14 @@@ $path = array
      'update_comment_followUp'=>'ajax_follow_up',
      // TVA param
      "tva_parameter"=>"ajax_tva_parameter",
 -    // Display all cards using an accounting
 -    "display_all_card"=>"ajax_display_all_card",
++     // Currency , add / remove / update currency 
++    "CurrencyManage"=>"ajax_currency",
 +    // Currency  , delete a rate
 +    "CurrencyRateDelete"=>"ajax_currency",
      // payment_method
 -    "payment_method"=>"ajax_payment_method"
 +    "payment_method"=>"ajax_payment_method",
 +    // Display all cards using an accounting
 +    "display_all_card"=>"ajax_display_all_card"
  )    ;
  
  if (array_key_exists($op, $path)) {
diff --cc html/style-classic7.css
index 8f37ce0,66477a6..5233e02
--- a/html/style-classic7.css
+++ b/html/style-classic7.css
@@@ -2282,6 -2279,13 +2280,16 @@@ div.progressbar 
      color:antiquewhite;
      font-weight: bolder;
  }
 +.nowrap td {
 +    white-space: nowrap;
++}
+ /**
+  * Warning
+  */
+ span.warning {
+     color:red;
+     font-style: normal;
+     font-weight: bold;
+     background-color: #eddadd;
+     padding:10px;
  }
diff --cc include/class/acc_ledger.class.php
index 52d3e1f,a251257..939d4a8
--- a/include/class/acc_ledger.class.php
+++ b/include/class/acc_ledger.class.php
@@@ -80,19 -81,9 +81,20 @@@ class Acc_Ledger extends jrn_def_sq
          $this->db=$p_cn;
          $this->row=null;
          $this->nb=MAX_ARTICLE;
-         $this->currency_id=$this->set_currency_id();
++         parent::__construct($p_cn, $p_id);
+         parent::__construct($p_cn, $p_id);
      }
 -
 +    /**
 +     * retrieve currency_id from database
 +     */
 +    function set_currency_id()
 +    {
 +       $this->db->get_value("select currency_id from jrn_def where 
jrn_def_id=$1",
 +            [$this->id]);
 +        if ( $this->currency_id == "") {
 +            $this->currency_id=0;
 +        }
 +    }
      function get_last_pj()
      {
          if (isNumber($this->id)==0)
@@@ -1063,10 -1030,8 +1079,10 @@@
       * permitted card, 5 not in the user's period, 6 closed period
       *
       */
-     function verify($p_array)
+     function verify_operation($p_array)
      {
 +        global $g_parameter;
 +        $http=new HttpInput();
          if (is_array($p_array)==false||empty($p_array))
              throw new Exception("Array empty");
          /*
@@@ -2457,8 -2300,12 +2473,14 @@@
              ["label"=>_("Désactivé"),"value"=>0]
          ];
          $actif->selected=$this->jrn_enable;
 -        
 -        $negative=new 
InputSwitch('negative_amount',$this->jrn_def_negative_amount);
+ 
 +        // -- default currency used : only for financial ledgers
 +        $default_currency=$this->select_default_currency();
++
++        $negative=new 
InputSwitch('negative_amount',$this->jrn_def_negative_amount);
+         $negative_warning=new 
IText("negative_warning",_($this->jrn_def_negative_warning));
+         $negative_warning->size=80;
+         
          require_once NOALYSS_TEMPLATE.'/param_jrn.php';
      }
  
@@@ -2555,7 -2392,9 +2583,10 @@@
          $this->jrn_deb_max_line=($min_row<1)?1:$min_row;
          $this->jrn_def_description=$p_description;
          $this->jrn_enable=$jrn_enable;
 +        $this->currency_id=0;
+         $this->jrn_def_negative_amount=$negative_amount;
+         $this->jrn_def_negative_warning=$negative_warning;
+         
          switch ($this->jrn_def_type)
          {
              case 'ACH':
@@@ -2724,8 -2551,9 +2755,12 @@@
          $cn=$this->db;
          $min_row=new INum("min_row", MAX_ARTICLE);
          $min_row->prec=0;
-         // -- default currency used : only for financial ledgers
++         // -- default currency used : only for financial ledgers
 +        $default_currency=$this->select_default_currency();
++        
+         $negative=new InputSwitch('negative_amount',0);
+         $negative_warning=new IText('negative_warning',_("Attention, ce 
journal doit utiliser des montants négatifs"));
+         $negative_warning->size=80;
          require_once NOALYSS_TEMPLATE.'/param_jrn.php';
      }
  
@@@ -2782,10 -2613,9 +2820,10 @@@
                  if ($result==-1)
                      throw new Exception(_("Aucun compte en banque n'est 
donné"));
                  $this->jrn_def_num_op=(isset($numb_operation))?1:0;
 +                $this->currency_id=$defaultCurrency;
                  break;
          }
- 
+         
          parent::insert();
      }
  
@@@ -3098,46 -2927,22 +3136,63 @@@
          
      }
      /**
 +     * Create a select from value for currency and add javascript to update 
$p_currency_rate and
 +     * $p_eur_amount 
 +     * @param string DOMID $p_currency_code
 +     * @param string DOMID $p_currency_rate
 +     * @param string DOMID $p_eur_amount
 +     */
 +    function CurrencyInput($p_currency_code, $p_currency_rate, $p_eur_amount)
 +    {
 +        $type=$this->get_type();
 +        $currency=new Acc_Currency($this->db);
 +        $select=$currency->select_currency();
 +        if ($type =='ODS')
 +        {
 +            
 +            
$select->javascript=sprintf('onchange="LedgerCurrencyUpdateMisc(\'%s\',\'%s\',\'%s\',\'%s\',\'%s\');'.
 +                    
'$(\'update_p_currency_rate\').innerHTML=$(\'p_currency_rate\').value;"',
 +                    Dossier::id(), $select->name, $p_currency_code, 
$p_currency_rate, $p_eur_amount);
 +        }
 +        elseif ($type == 'ACH' || $type == 'VEN')
 +        {
 +            
 +            
$select->javascript=sprintf('onchange="LedgerCurrencyUpdate(\'%s\',\'%s\',\'%s\',\'%s\',\'%s\');'.
 +                    
'$(\'update_p_currency_rate\').innerHTML=$(\'p_currency_rate\').value;"',
 +                    Dossier::id(), $select->name, $p_currency_code, 
$p_currency_rate, $p_eur_amount);
 +        }
 +        else
 +        {
 +            throw new Exception(_("Journal type non déterminé"));
 +        }
 +        return $select;
 +    }
 +
 +    /**
 +     * @brief returns the code iso of the default currency for this ledger
 +     */
 +    function get_currency()
 +    {
 +        $cr=new Acc_Currency($this->db,$this->currency_id);
 +        return $cr;
 +    }
++    /**
+      * If the amount is positive and the ledger expects a negative amount, il 
will return the saved warning
+      * 
+      * @param int $p_amount amount to check
+      * @throws Exception 1 if invalid ledger
+      */
+     function display_negative_warning($p_amount)
+     {
+         if ($this->id == 0) {
+             throw new Exception(_("Journal invalide"), 1);
+         }
+         $ledger=new Jrn_def_SQL($this->db,$this->id);
+         if ( $p_amount > 0 && $ledger->getp("jrn_def_negative_amount")==1){
+             return _($ledger->getp("jrn_def_negative_warning"));
+         }
+         return "";
+     }
  }
  
  ?>
diff --cc include/database/currency_history_sql.class.php
index 5bec732,0000000..5bc95e0
mode 100644,000000..100644
--- a/include/database/currency_history_sql.class.php
+++ b/include/database/currency_history_sql.class.php
@@@ -1,65 -1,0 +1,65 @@@
 +<?php
 +
 +/*
 + *   This file is part of NOALYSS.
 + *
 + *   PhpCompta is free software; you can redistribute it and/or modify
 + *   it under the terms of the GNU General Public License as published by
 + *   the Free Software Foundation; either version 2 of the License, or
 + *   (at your option) any later version.
 + *
 + *   PhpCompta is distributed in the hope that it will be useful,
 + *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 + *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 + *   GNU General Public License for more details.
 + *
 + *   You should have received a copy of the GNU General Public License
 + *   along with PhpCompta; if not, write to the Free Software
 + *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 + */
 +// Copyright (2018) Author Dany De Bontridder <dany@alchimerys.be>
 +
 +require_once NOALYSS_INCLUDE.'/lib/noalyss_sql.class.php';
- require_once NOALYSS_INCLUDE.'/lib/database.class.php';
++require_once NOALYSS_INCLUDE.'/class/database.class.php';
 +
 +/**
 + * class_currency_history_sql.php
 + *
 + * @file
 + * @brief abstract of the table public.currency_history */
 +class Currency_history_SQL extends Noalyss_SQL
 +{
 +
 +    function __construct(Database $p_cn, $p_id=-1)
 +    {
 +        $this->table="public.currency_history";
 +        $this->primary_key="id";
 +        /*
 +         * List of columns
 +         */
 +        $this->name=array(
 +            "id"=>"id"
 +            , "ch_value"=>"ch_value"
 +            , "ch_from"=>"ch_from"
 +            , "currency_id"=>"currency_id"
 +        );
 +        /*
 +         * Type of columns
 +         */
 +        $this->type=array(
 +            "id"=>"numeric"
 +            , "ch_value"=>"numeric"
 +            , "ch_from"=>"date"
 +            , "currency_id"=>"numeric"
 +        );
 +
 +
 +        $this->default=array(
 +            "id"=>"auto"
 +        );
 +
 +        $this->date_format="DD.MM.YYYY";
 +        parent::__construct($p_cn, $p_id);
 +    }
 +
 +}
diff --cc include/database/currency_sql.class.php
index ef67bcc,0000000..0de0c2a
mode 100644,000000..100644
--- a/include/database/currency_sql.class.php
+++ b/include/database/currency_sql.class.php
@@@ -1,63 -1,0 +1,63 @@@
 +<?php
 +
 +/*
 + *   This file is part of NOALYSS.
 + *
 + *   PhpCompta is free software; you can redistribute it and/or modify
 + *   it under the terms of the GNU General Public License as published by
 + *   the Free Software Foundation; either version 2 of the License, or
 + *   (at your option) any later version.
 + *
 + *   PhpCompta is distributed in the hope that it will be useful,
 + *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 + *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 + *   GNU General Public License for more details.
 + *
 + *   You should have received a copy of the GNU General Public License
 + *   along with PhpCompta; if not, write to the Free Software
 + *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 + */
 +// Copyright (2018) Author Dany De Bontridder <dany@alchimerys.be>
 +
 +require_once NOALYSS_INCLUDE.'/lib/noalyss_sql.class.php';
- require_once NOALYSS_INCLUDE.'/lib/database.class.php';
++require_once NOALYSS_INCLUDE.'/class/database.class.php';
 +
 +/**
 + * class_currency_sql.php
 + *
 + * @file
 + * @brief abstract of the table public.currency */
 +class Currency_SQL extends Noalyss_SQL
 +{
 +
 +    function __construct(Database $p_cn, $p_id=-1)
 +    {
 +        $this->table="public.currency";
 +        $this->primary_key="id";
 +        /*
 +         * List of columns
 +         */
 +        $this->name=array(
 +            "id"=>"id"
 +            , "cr_code_iso"=>"cr_code_iso"
 +            ,"cr_name"=>"cr_name"
 +        );
 +        /*
 +         * Type of columns
 +         */
 +        $this->type=array(
 +            "id"=>"numeric"
 +            , "cr_code_iso"=>"text"
 +            , "cr_name"=>"text"
 +        );
 +
 +
 +        $this->default=array(
 +            "id"=>"auto"
 +        );
 +
 +        $this->date_format="DD.MM.YYYY";
 +        parent::__construct($p_cn, $p_id);
 +    }
 +
 +}
diff --cc include/database/jrn_def_sql.class.php
index 2a8deed,413e4d2..92a42fe
--- a/include/database/jrn_def_sql.class.php
+++ b/include/database/jrn_def_sql.class.php
@@@ -16,411 -18,79 +18,77 @@@
   *   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 danydb@aevalys.eu
- 
- /**
-  * @file
-  * @brief Manage the table public.jrn_def
-  *
-  *
-   Example
-   @code
- 
-   @endcode
-  */
+ require_once NOALYSS_INCLUDE.'/lib/noalyss_sql.class.php';
  require_once NOALYSS_INCLUDE.'/class/database.class.php';
- require_once NOALYSS_INCLUDE.'/lib/ac_common.php';
  
  /**
-  * @brief Manage the table public.jrn_def
-  */
- class Jrn_Def_sql
+  * class_jrn_def_sql.php
+  *
+  * @file
+  * @brief abstract of the table public.jrn_def */
+ class Jrn_def_SQL extends Noalyss_SQL
  {
-       /* example private 
$variable=array("easy_name"=>column_name,"email"=>"column_name_email","val3"=>0);
 */
- 
-       protected $variable = array(
-               "jrn_def_id" => "jrn_def_id",
-               "jrn_def_name" => "jrn_def_name"
-               , "jrn_def_class_deb" => "jrn_def_class_deb"
-               , "jrn_def_class_cred" => "jrn_def_class_cred"
-               , "jrn_def_fiche_deb" => "jrn_def_fiche_deb"
-               , "jrn_def_fiche_cred" => "jrn_def_fiche_cred"
-               , "jrn_deb_max_line" => "jrn_deb_max_line"
-               , "jrn_cred_max_line" => "jrn_cred_max_line"
-               , "jrn_def_ech" => "jrn_def_ech"
-               , "jrn_def_ech_lib" => "jrn_def_ech_lib"
-               , "jrn_def_type" => "jrn_def_type"
-               , "jrn_def_code" => "jrn_def_code"
-               , "jrn_def_pj_pref" => "jrn_def_pj_pref"
-               , "jrn_def_bank" => "jrn_def_bank"
-               , "jrn_def_num_op" => "jrn_def_num_op"
-               , "jrn_def_description" => "jrn_def_description"
-                 ,  "jrn_enable"=>"jrn_enable"
-                 , "currency_id"=>"currency_id"
-       );
- 
-       function __construct(& $p_cn, $p_id=-1)
-       {
-               $this->db = $p_cn;
-               $this->jrn_def_id = $p_id;
- 
-               if ($p_id == -1)
-               {
-                       /* Initialize an empty object */
-                       foreach ($this->variable as $key => $value)
-                               $this->$value = null;
-                       $this->jrn_def_id = $p_id;
-               }
-               else
-               {
-                       /* load it */
- 
-                       $this->load();
-               }
-       }
- 
-       public function get_parameter($p_string)
-       {
-               if (array_key_exists($p_string, $this->variable))
-               {
-                       $idx = $this->variable[$p_string];
-                       return $this->$idx;
-               }
-               else
-                       throw new Exception(__FILE__ . ":" . __LINE__ . 
$p_string . 'Erreur attribut inexistant');
-       }
  
-       public function set_parameter($p_string, $p_value)
-       {
-               if (array_key_exists($p_string, $this->variable))
-               {
-                       $idx = $this->variable[$p_string];
-                       $this->$idx = $p_value;
-               }
-               else
-                       throw new Exception(__FILE__ . ":" . __LINE__ . 
$p_string . 'Erreur attribut inexistant');
-       }
- 
-       public function get_info()
-       {
-               return var_export($this, true);
-       }
- 
-       public function verify_sql()
-       {
-               // Verify that the elt we want to add is correct
-               /* verify only the datatype */
-               if (trim($this->jrn_def_name) == '')
-                       $this->jrn_def_name = null;
-               if (trim($this->jrn_def_class_deb) == '')
-                       $this->jrn_def_class_deb = null;
-               if (trim($this->jrn_def_class_cred) == '')
-                       $this->jrn_def_class_cred = null;
-               if (trim($this->jrn_def_fiche_deb) == '')
-                       $this->jrn_def_fiche_deb = null;
-               if (trim($this->jrn_def_fiche_cred) == '')
-                       $this->jrn_def_fiche_cred = null;
-               if (trim($this->jrn_deb_max_line) == '')
-                       $this->jrn_deb_max_line = null;
-               if ($this->jrn_deb_max_line !== null && 
settype($this->jrn_deb_max_line, 'float') == false)
-                       throw new Exception('DATATYPE jrn_deb_max_line 
$this->jrn_deb_max_line non numerique');
-               if (trim($this->jrn_cred_max_line) == '')
-                       $this->jrn_cred_max_line = null;
-               if ($this->jrn_cred_max_line !== null && 
settype($this->jrn_cred_max_line, 'float') == false)
-                       throw new Exception('DATATYPE jrn_cred_max_line 
$this->jrn_cred_max_line non numerique');
-               if (trim($this->jrn_def_ech) == '')
-                       $this->jrn_def_ech = null;
-               if (trim($this->jrn_def_ech_lib) == '')
-                       $this->jrn_def_ech_lib = null;
-               if (trim($this->jrn_def_type) == '')
-                       $this->jrn_def_type = null;
-               if (trim($this->jrn_def_code) == '')
-                       $this->jrn_def_code = null;
-               if (trim($this->jrn_def_pj_pref) == '')
-                       $this->jrn_def_pj_pref = null;
-               if (trim($this->jrn_def_bank) == '')
-                       $this->jrn_def_bank = null;
-               if ($this->jrn_def_bank !== null && 
settype($this->jrn_def_bank, 'float') == false)
-                       throw new Exception('DATATYPE jrn_def_bank 
$this->jrn_def_bank non numerique');
-               if (trim($this->jrn_def_num_op) == '')
-                       $this->jrn_def_num_op = null;
-               if ($this->jrn_def_num_op !== null && 
settype($this->jrn_def_num_op, 'float') == false)
-                       throw new Exception('DATATYPE jrn_def_num_op 
$this->jrn_def_num_op non numerique');
-       }
- 
-       public function save($p_string='')
-       {
-               /* please adapt */
-               if ($this->jrn_def_id == -1)
-                       $this->insert();
-               else
-                       $this->update();
-       }
- 
-       /**
-        * @brief retrieve array of object thanks a condition
-        * @param $cond condition (where clause) (optional by default all the 
rows are fetched)
-        * you can use this parameter for the order or subselect
-        * @param $p_array array for the SQL stmt
-        * @see Database::exec_sql get_object  Database::num_row
-        * @return the return value of exec_sql
-        */
-       public function seek($cond='', $p_array=null)
-       {
-               $sql = "select * from public.jrn_def  $cond";
-               $aobj = array();
-               $ret = $this->db->exec_sql($sql, $p_array);
-               return $ret;
-       }
- 
-       /**
-        * get_seek return the next object, the return of the query must have 
all the column
-        * of the object
-        * @param $p_ret is the return value of an exec_sql
-        * @param $idx is the index
-        * @see seek
-        * @return object
-        */
-       public function get_object($p_ret, $idx)
-       {
-               // map each row in a object
-               $oobj = new Jrn_Def_sql($this->db);
-               $array = Database::fetch_array($p_ret, $idx);
-               foreach ($array as $idx => $value)
-               {
-                       $oobj->$idx = $value;
-               }
-               return $oobj;
-       }
- 
-       public function insert($p_array=null)
-       {
-               if ($this->verify_sql() != 0)
-                       return;
-               if ($this->jrn_def_id == -1)
-               {
-                       /*  please adapt */
-                       $sql = "insert into public.jrn_def(jrn_def_name
- ,jrn_def_class_deb
- ,jrn_def_class_cred
- ,jrn_def_fiche_deb
- ,jrn_def_fiche_cred
- ,jrn_deb_max_line
- ,jrn_cred_max_line
- ,jrn_def_ech
- ,jrn_def_ech_lib
- ,jrn_def_type
- ,jrn_def_code
- ,jrn_def_pj_pref
- ,jrn_def_bank
- ,jrn_def_num_op
- ,jrn_def_description
- ,currency_id
- ) values ($1
- ,$2
- ,$3
- ,$4
- ,$5
- ,$6
- ,$7
- ,$8
- ,$9
- ,$10
- ,$11
- ,$12
- ,$13
- ,$14
- ,$15
- ,$16
- ) returning jrn_def_id";
- 
-                       $this->jrn_def_id = $this->db->get_value(
-                                       $sql, array($this->jrn_def_name
-                               , $this->jrn_def_class_deb
-                               , $this->jrn_def_class_cred
-                               , $this->jrn_def_fiche_deb
-                               , $this->jrn_def_fiche_cred
-                               , $this->jrn_deb_max_line
-                               , $this->jrn_cred_max_line
-                               , $this->jrn_def_ech
-                               , $this->jrn_def_ech_lib
-                               , $this->jrn_def_type
-                               , $this->jrn_def_code
-                               , $this->jrn_def_pj_pref
-                               , $this->jrn_def_bank
-                               , $this->jrn_def_num_op
-                               , strip_tags($this->jrn_def_description)
-                                 , $this->currency_id
-                                       )
-                       );
-               }
-               else
-               {
-                       $sql = "insert into public.jrn_def(jrn_def_name
- ,jrn_def_class_deb
- ,jrn_def_class_cred
- ,jrn_def_fiche_deb
- ,jrn_def_fiche_cred
- ,jrn_deb_max_line
- ,jrn_cred_max_line
- ,jrn_def_ech
- ,jrn_def_ech_lib
- ,jrn_def_type
- ,jrn_def_code
- ,jrn_def_pj_pref
- ,jrn_def_bank
- ,jrn_def_num_op
- ,jrn_def_id
- ,jrn_def_description,
- jrn_enable) values ($1
- ,$2
- ,$3
- ,$4
- ,$5
- ,$6
- ,$7
- ,$8
- ,$9
- ,$10
- ,$11
- ,$12
- ,$13
- ,$14
- ,$15
- ,$16
- ,1
- ,$17
- ) returning jrn_def_id";
- 
-                       $this->jrn_def_id = $this->db->get_value(
-                                       $sql, array(
-                                   $this->jrn_def_name           // 1
-                               , $this->jrn_def_class_deb      // 2
-                               , $this->jrn_def_class_cred     // 3
-                               , $this->jrn_def_fiche_deb      // 4
-                               , $this->jrn_def_fiche_cred     // 5
-                               , $this->jrn_deb_max_line       // 6 
-                               , $this->jrn_cred_max_line      // 7
-                               , $this->jrn_def_ech            // 8
-                               , $this->jrn_def_ech_lib        // 9 
-                               , $this->jrn_def_type           // 10
-                               , $this->jrn_def_code           // 11
-                               , $this->jrn_def_pj_pref        // 12
-                               , $this->jrn_def_bank           // 13
-                               , $this->jrn_def_num_op         // 14 
-                               , $this->jrn_def_id             // 15
-                                 , strip_tags($this->jrn_def_description)) // 
16
-                                 , $this->currency_id            // 17
-                                 
-                       );
-               }
-       }
- 
-       public function update($p_string='')
-       {
-               if ($this->verify_sql() != 0)
-                       return;
-               /*   please adapt */
-               $sql = " update public.jrn_def set jrn_def_name = $1
- ,jrn_def_class_deb = $2
- ,jrn_def_class_cred = $3
- ,jrn_def_fiche_deb = $4
- ,jrn_def_fiche_cred = $5
- ,jrn_deb_max_line = $6
- ,jrn_cred_max_line = $7
- ,jrn_def_ech = $8
- ,jrn_def_ech_lib = $9
- ,jrn_def_type = $10
- ,jrn_def_code = $11
- ,jrn_def_pj_pref = $12
- ,jrn_def_bank = $13
- ,jrn_def_num_op = $14
- ,jrn_def_description = $15
- ,jrn_enable=$17
- , currency_id = $18
-  where jrn_def_id= $16";
-               $res = $this->db->exec_sql(
-                               $sql, array($this->jrn_def_name
-                       , $this->jrn_def_class_deb
-                       , $this->jrn_def_class_cred
-                       , $this->jrn_def_fiche_deb
-                       , $this->jrn_def_fiche_cred
-                       , $this->jrn_deb_max_line
-                       , $this->jrn_cred_max_line
-                       , $this->jrn_def_ech
-                       , $this->jrn_def_ech_lib
-                       , $this->jrn_def_type
-                       , $this->jrn_def_code
-                       , $this->jrn_def_pj_pref
-                       , $this->jrn_def_bank
-                       , $this->jrn_def_num_op
-                       , strip_tags($this->jrn_def_description)
-                       , $this->jrn_def_id
-                         , $this->jrn_enable
-                         , $this->currency_id
-                         )
-               );
-       }
- 
-       /**
-        * @brief load a object
-        * @return 0 on success -1 the object is not found
-        */
-       public function load()
-       {
- 
-               $sql = "select jrn_def_name
- ,jrn_def_class_deb
- ,jrn_def_class_cred
- ,jrn_def_fiche_deb
- ,jrn_def_fiche_cred
- ,jrn_deb_max_line
- ,jrn_cred_max_line
- ,jrn_def_ech
- ,jrn_def_ech_lib
- ,jrn_def_type
- ,jrn_def_code
- ,jrn_def_pj_pref
- ,jrn_def_bank
- ,jrn_def_num_op
- ,jrn_def_description
- ,jrn_enable
- ,currency_id
-  from public.jrn_def where jrn_def_id=$1";
-               /* please adapt */
-               $res = $this->db->get_array(
-                               $sql, array($this->jrn_def_id)
-               );
- 
-               if (count($res) == 0)
-               {
-                       /* Initialize an empty object */
-                       foreach ($this->variable as $key => $value)
-                               $this->$key = '';
- 
-                       return -1;
-               }
-               foreach ($res[0] as $idx => $value)
-               {
-                       $this->$idx = $value;
-               }
-               return 0;
-       }
- 
-       public function delete()
-       {
-               $sql = "delete from public.jrn_def where jrn_def_id=$1";
-               $res = $this->db->exec_sql($sql, array($this->jrn_def_id));
-       }
- 
-       /**
-        * Unit test for the class
-        */
-       static function test_me()
-       {
-       }
+     function __construct(Database $p_cn, $p_id=-1)
+     {
+         $this->table="public.jrn_def";
+         $this->primary_key="jrn_def_id";
+         /*
+          * List of columns
+          */
+         $this->name=array(
+             "jrn_def_id"=>"jrn_def_id"
+             , "jrn_def_name"=>"jrn_def_name"
+             , "jrn_def_class_deb"=>"jrn_def_class_deb"
+             , "jrn_def_class_cred"=>"jrn_def_class_cred"
+             , "jrn_def_fiche_deb"=>"jrn_def_fiche_deb"
+             , "jrn_def_fiche_cred"=>"jrn_def_fiche_cred"
+             , "jrn_deb_max_line"=>"jrn_deb_max_line"
+             , "jrn_cred_max_line"=>"jrn_cred_max_line"
+             , "jrn_def_ech"=>"jrn_def_ech"
+             , "jrn_def_ech_lib"=>"jrn_def_ech_lib"
+             , "jrn_def_type"=>"jrn_def_type"
+             , "jrn_def_code"=>"jrn_def_code"
+             , "jrn_def_pj_pref"=>"jrn_def_pj_pref"
+             , "jrn_def_bank"=>"jrn_def_bank"
+             , "jrn_def_num_op"=>"jrn_def_num_op"
+             , "jrn_def_description"=>"jrn_def_description"
+             , "jrn_enable"=>"jrn_enable"
+             , "currency_id"=>"currency_id"
+             , "jrn_def_negative_amount"=>"jrn_def_negative_amount"
+             , "jrn_def_negative_warning"=>"jrn_def_negative_warning"
+         );
+         /*
+          * Type of columns
+          */
+         $this->type=array(
+             "jrn_def_id"=>"numeric"
+             , "jrn_def_name"=>"text"
+             , "jrn_def_class_deb"=>"text"
+             , "jrn_def_class_cred"=>"text"
+             , "jrn_def_fiche_deb"=>"text"
+             , "jrn_def_fiche_cred"=>"text"
+             , "jrn_deb_max_line"=>"numeric"
+             , "jrn_cred_max_line"=>"numeric"
+             , "jrn_def_ech"=>"boolean"
+             , "jrn_def_ech_lib"=>"text"
+             , "jrn_def_type"=>"text"
+             , "jrn_def_code"=>"text"
+             , "jrn_def_pj_pref"=>"text"
+             , "jrn_def_bank"=>"numeric"
+             , "jrn_def_num_op"=>"numeric"
+             , "jrn_def_description"=>"text"
+             , "jrn_enable"=>"numeric"
+             , "currency_id"=>"numeric"
+             , "jrn_def_negative_amount"=>"text"
+             ,"jrn_def_negative_warning"=>"text"
 -        );
 -
++            );
+ 
+         $this->default=array(
 -            "jrn_def_id"=>"auto"
 -        );
++            "jrn_def_id"=>"auto");
+ 
+         $this->date_format="DD.MM.YYYY";
+         parent::__construct($p_cn, $p_id);
+     }
  
  }
- 
- // Jrn_Def_sql::test_me();
- ?>
diff --cc include/database/operation_currency_sql.class.php
index f624964,0000000..2aaaf43
mode 100644,000000..100644
--- a/include/database/operation_currency_sql.class.php
+++ b/include/database/operation_currency_sql.class.php
@@@ -1,67 -1,0 +1,67 @@@
 +<?php
 +
 +/**
 + * Autogenerated file 
 + *   This file is part of NOALYSS.
 + *
 + *   NOALYSS is free software; you can redistribute it and/or modify
 + *   it under the terms of the GNU General Public License as published by
 + *   the Free Software Foundation; either version 2 of the License, or
 + *   (at your option) any later version.
 + *
 + *   NOALYSS is distributed in the hope that it will be useful,
 + *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 + *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 + *   GNU General Public License for more details.
 + *
 + *   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
 + */
 +require_once NOALYSS_INCLUDE.'/lib/noalyss_sql.class.php';
- require_once NOALYSS_INCLUDE.'/lib/database.class.php';
++require_once NOALYSS_INCLUDE.'/class/database.class.php';
 +
 +/**
 + * class_operation_currency_sql.php
 + *
 + * @file
 + * @brief abstract of the table public.operation_currency 
 + */
 +class Operation_currency_SQL extends Noalyss_SQL
 +{
 +
 +    function __construct(Database $p_cn, $p_id=-1)
 +    {
 +        $this->table="public.operation_currency";
 +        $this->primary_key="id";
 +        /*
 +         * List of columns
 +         */
 +        $this->name=array(
 +            "id"=>"id"
 +            , "oc_amount"=>"oc_amount"
 +            , "oc_vat_amount"=>"oc_vat_amount"
 +            , "oc_price_unit"=>"oc_price_unit"
 +            , "j_id"=>"j_id"
 +        );
 +        /*
 +         * Type of columns
 +         */
 +        $this->type=array(
 +            "id"=>"numeric"
 +            , "oc_amount"=>"numeric"
 +            , "oc_vat_amount"=>"numeric"
 +            , "oc_price_unit"=>"numeric"
 +            , "j_id"=>"numeric"
 +        );
 +
 +
 +        $this->default=array(
 +            "id"=>"auto"
 +        );
 +
 +        $this->date_format="DD.MM.YYYY";
 +        parent::__construct($p_cn, $p_id);
 +    }
 +
 +}
diff --cc include/database/v_currency_last_value_sql.class.php
index 1edbe57,0000000..1b2387c
mode 100644,000000..100644
--- a/include/database/v_currency_last_value_sql.class.php
+++ b/include/database/v_currency_last_value_sql.class.php
@@@ -1,159 -1,0 +1,159 @@@
 +<?php
 +
 +/*
 + *   This file is part of NOALYSS.
 + *
 + *   PhpCompta is free software; you can redistribute it and/or modify
 + *   it under the terms of the GNU General Public License as published by
 + *   the Free Software Foundation; either version 2 of the License, or
 + *   (at your option) any later version.
 + *
 + *   PhpCompta is distributed in the hope that it will be useful,
 + *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 + *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 + *   GNU General Public License for more details.
 + *
 + *   You should have received a copy of the GNU General Public License
 + *   along with PhpCompta; if not, write to the Free Software
 + *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 + */
 +// Copyright (2018) Author Dany De Bontridder <dany@alchimerys.be>
 +
 +require_once NOALYSS_INCLUDE.'/lib/noalyss_sql.class.php';
- require_once NOALYSS_INCLUDE.'/lib/database.class.php';
++require_once NOALYSS_INCLUDE.'/class/database.class.php';
 +
 +/**
 + * class_currency_history_sql.php
 + *
 + * @file
 + * @brief abstract of the view public.v_currency_last_value
 + */
 +
 +/**
 + * class_currency_history_sql.php
 + *
 + * @class
 + * @brief abstract of the view public.v_currency_last_value
 + */
 +class V_Currency_Last_Value_SQL extends Data_SQL
 +{
 +
 +    function __construct(Database $p_cn, $p_id=-1)
 +    {
 +        $this->table="public.v_currency_last_value";
 +        $this->primary_key="currency_id";
 +        /*
 +         * List of columns
 +         */
 +        $this->name=array(
 +            "currency_id"=>"currency_id"
 +            , "cr_name"=>"cr_name"
 +            , "cr_code_iso"=>"cr_code_iso"
 +            , "currency_history_id"=>"currency_history_id"
 +            , "ch_value"=>"ch_value"
 +            , "str_from"=>"str_from"
 +        );
 +        /*
 +         * Type of columns
 +         */
 +        $this->type=array(
 +            "currency_id"=>"numeric"
 +            , "cr_name"=>"text"
 +            , "cr_code_iso"=>"text"
 +            , "currency_history_id"=>"numeric"
 +            , "ch_value"=>"numeric"
 +            , "str_from"=>"text"
 +        );
 +
 +
 +        $this->default=array(
 +            "currency_id"=>"auto"
 +        );
 +
 +        $this->date_format="DD.MM.YYYY";
 +        parent::__construct($p_cn, $p_id);
 +    }
 +
 +    public function count($p_where="", $p_array=null)
 +    {
 +        $count=$this->cn->get_value("select count(*) from $this->table 
".$p_where, $p_array);
 +        return $count;
 +    }
 +
 +    public function delete()
 +    {
 +        /* check if currency is used */
 +        $is_used = $this->cn->get_value("select count(*) from jrn where 
currency_id=$1",[$this->currency_id]);
 +        
 +        /* if not used , we can delete it */
 +        if ( $is_used <> 0 ) {     throw new Exception (_("Devise 
utilisée"));  }
 +        
 +        // We cannot delete EUR
 +        if ( $this->currency_id == -1 ) {
 +            throw new Exception(_("EUR ne peut pas être effacé"));
 +        }
 +        $this->cn->exec_sql("delete from currency_history where 
currency_id=$1",[$this->currency_id]);
 +        $this->cn->exec_sql("delete from currency where 
id=$1",[$this->currency_id]);
 +        
 +    }
 +
 +    public function exist()
 +    {
 +        $pk=$this->primary_key;
 +        $count=$this->cn->get_value("select count(*) from ".$this->table." 
where ".$this->primary_key."=$1",
 +                array($this->$pk));
 +        return $count;
 +    }
 +
 +    public function insert()
 +    {
 +        
 +    }
 +
 +    public function load()
 +    {
 +        $sql=" select ";
 +        $sep="";
 +        foreach ($this->name as $key)
 +        {
 +            switch ($this->type[$key])
 +            {
 +                case "date":
 +                    $sql.=$sep.'to_char('.$key.",'".$this->date_format."') as 
".$key;
 +                    break;
 +                default:
 +                    $sql.=$sep.$key;
 +            }
 +            $sep=",";
 +        }
 +        $pk=$this->primary_key;
 +        $sql.=" from ".$this->table;
 +
 +        $sql.=" where ".$this->primary_key." = $1";
 +
 +        $result=$this->cn->get_array($sql, array($this->$pk));
 +        if ($this->cn->count()==0)
 +        {
 +            $this->$pk=-1;
 +            return;
 +        }
 +
 +        foreach ($result[0] as $key=> $value)
 +        {
 +            $this->$key=$value;
 +        }
 +    }
 +
 +    function seek($cond='', $p_array=null)
 +    {
 +        $sql="select * from ".$this->table."  $cond";
 +        $ret=$this->cn->exec_sql($sql, $p_array);
 +        return $ret;
 +    }
 +
 +    public function update()
 +    {
 +        
 +    }
 +
 +}
diff --cc include/lib/manage_table_sql.class.php
index e25d9cc,3488a20..68a4da6
--- a/include/lib/manage_table_sql.class.php
+++ b/include/lib/manage_table_sql.class.php
@@@ -834,11 -832,11 +834,10 @@@ function check(
                          }
                      }
  
 -                    if ( ! $found) {
 +                    if (!$found)
 +                    {
                          echo td("--");
 -
                      }
-               }
 -                    
                  } elseif ($this->get_col_type($v)=="custom") {
                      // For custom col
                      echo td($this->display_row_custom($v,$p_row[$v]));
diff --cc include/template/param_jrn.php
index b3cf6e7,b5af8ce..a34580d
--- a/include/template/param_jrn.php
+++ b/include/template/param_jrn.php
@@@ -110,49 -147,35 +147,50 @@@ endif
  
  </TR>
  <?php if ( $new == 0 ) : ?>
- <TR>
- <TD>
-   <?php echo _('Dernière pièce numérotée')?>
-   <?php echo Icon_Action::infobulle(40);?>
- </TD>
- <TD>
- <?php echo $last_seq?>
- </TD>
- </TR>
+     <TR>
+     <TD>
+       <?php echo _('Dernière pièce numérotée')?>
+       <?php echo Icon_Action::infobulle(40);?>
+     </TD>
+     <TD>
+     <?php echo $last_seq?>
+     </TD>
+     </TR>
  
- <tr>
- <TD><?php echo _('N° pièce justificative')?>
-     <?php echo Icon_Action::infobulle(38);?>
- </TD>
- <TD>
-     <?php echo $pj_seq; ?>
-    
- </TD>
- </tr>
- <tr>
-     <td>
-         <?=_("Journal actif")?>
-     </td>
-     <td>
-         <?=$actif->input()?>
-     </td>
+     <tr>
+     <TD><?php echo _('N° pièce justificative')?>
+         <?php echo Icon_Action::infobulle(38);?>
+     </TD>
+     <TD>
+         <?php echo $pj_seq; ?>
+ 
+     </TD>
+     </tr>
+     <tr>
+         <td>
+             <?=_("Journal actif")?>
+         </td>
+         <td>
+             <?=$actif->input()?>
+         </td>
+     </TR>
  <?php endif; ?>
 +<?php
  
 +    // if the ledger is financial and has no operation let choose the currency
 + if ( $new == 1 || $type == 'FIN'):
 +?>
 +<tr id="type_fin3">
 +    <td>
 +        <?php echo _("Devise")?>
 +    </td>
 +    <td>
 +        <?php echo $default_currency->input();?>
 +    </td>
 +</tr>
 +<?php
 +endif;
 +?>
  </TABLE>
  <hr>
      <?php
@@@ -387,7 -410,8 +425,9 @@@
          $('type_ods').style.display='none';
          $('type_fin').style.display='none';
          $('type_fin2').style.display='none';
 +        $('type_fin3').style.display='none';
+         $('neg_amount').style.display='none';
+         $('row_warning').style.display='none';
      }
     function show_ledger_div()
     {
diff --cc unit-test/include/class/acc_ledgerTest.class.php
index efc81cb,1c91653..d22cc5e
--- a/unit-test/include/class/acc_ledgerTest.class.php
+++ b/unit-test/include/class/acc_ledgerTest.class.php
@@@ -746,11 -837,27 +837,27 @@@ class Acc_LedgerTest extends TestCas
       */
      public function testSave_new()
      {
-         // Remove the following lines when you implement this test.
-         $this->markTestIncomplete(
-                 'This test has not been implemented yet.'
-         );
+         global $g_connection;
+         
+         $array=["p_jrn_name"=>"UNITTEST",
+                 "p_ech_lib"=>"",
+                 "p_jrn_deb_max_line"=>7,
+                 'p_jrn_class_deb'=>'4*',
+                 'p_jrn_type'=>'ODS',
+                 'jrn_def_pj_pref'=>'TT/',
+                 'min_row'=>5,
+                 'p_description'=>'LEDGER UNIT TEST',
 -                'jrn_def_negative_amount'=>0,
 -                'jrn_def_negative_warning'=>'Warning'];
++                'negative_amount'=>0,
++                'negative_warning'=>'Warning'];
+         
+ 
+         $this->object->save_new($array);
+         $jrn_def_id=$g_connection->get_value("select jrn_def_id from jrn_def 
where jrn_def_name=$1",[$array['p_jrn_name']]);
+         $this->assertGreaterThan($jrn_def_id,0);
+         $ledger=new Acc_Ledger($g_connection,$jrn_def_id);
+         $ledger->delete_ledger();
+         $jrn_def_id=$g_connection->get_value("select jrn_def_id from jrn_def 
where jrn_def_name=$1",[$array['p_jrn_name']]);
+         $this->assertEquals($jrn_def_id,"");
      }
  
      /**
@@@ -759,10 -866,23 +866,26 @@@
       */
      public function testDelete_ledger()
      {
-         // Remove the following lines when you implement this test.
-         $this->markTestIncomplete(
-                 'This test has not been implemented yet.'
-         );
+         global $g_connection;
+         $array=["p_jrn_name"=>"UNITTEST",
+                 "p_ech_lib"=>"",
+                 "p_jrn_deb_max_line"=>7,
+                 'p_jrn_class_deb'=>'4*',
+                 'p_jrn_type'=>'ODS',
+                 'jrn_def_pj_pref'=>'TT/',
+                 'min_row'=>5,
 -                'p_description'=>'LEDGER UNIT TEST'];
++                'p_description'=>'LEDGER UNIT TEST',
++                'negative_amount'=>0,
++                'negative_warning'=>'Warning'
++            ];
+ 
+         $this->object->save_new($array);
+         $jrn_def_id=$g_connection->get_value("select jrn_def_id from jrn_def 
where jrn_def_name=$1",[$array['p_jrn_name']]);
+         $this->assertGreaterThan($jrn_def_id,0);
+         $ledger=new Acc_Ledger($g_connection,$jrn_def_id);
+         $ledger->delete_ledger();
+         $jrn_def_id=$g_connection->get_value("select jrn_def_id from jrn_def 
where jrn_def_name=$1",[$array['p_jrn_name']]);
+         $this->assertEquals($jrn_def_id,"");
      }
  
      /**
diff --cc unit-test/include/class/dossierTest.class.php
index d4de074,d4de074..21650b1
--- a/unit-test/include/class/dossierTest.class.php
+++ b/unit-test/include/class/dossierTest.class.php
@@@ -1,6 -1,6 +1,5 @@@
  <?php
  use PHPUnit\Framework\TestCase;
--use PHPUnit\Framework\TestCase;
  /**
   * Generated by PHPUnit_SkeletonGenerator on 2016-02-11 at 15:39:21.
   */



reply via email to

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