noalyss-commit
[Top][All Lists]
Advanced

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

[Noalyss-commit] [noalyss] 102/107: New Task 1728: Aide à l'encodage -


From: Dany De Bontridder
Subject: [Noalyss-commit] [noalyss] 102/107: New Task 1728: Aide à l'encodage - Journaux négatifs (note de crédit)
Date: Mon, 26 Aug 2019 10:32:09 -0400 (EDT)

sparkyx pushed a commit to branch master
in repository noalyss.

commit c997708f95b68bcf6e03a9a716c553cbb4c5616d
Author: Dany De Bontridder <address@hidden>
Date:   Mon Aug 26 15:04:08 2019 +0200

    New Task 1728: Aide à l'encodage - Journaux négatifs (note de crédit)
---
 include/cfgledger.inc.php                         |   8 +-
 include/class/acc_ledger.class.php                |  83 +++-
 include/class/acc_ledger_fin.class.php            |   2 +-
 include/class/acc_ledger_purchase.class.php       |  10 +-
 include/class/acc_ledger_sold.class.php           |  11 +-
 include/class/periode.class.php                   |  20 +-
 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/database/jrn_def_sql.class.php            | 462 ++++------------------
 include/export/export_printtva_csv.php            |  83 ++++
 include/export/export_printtva_pdf.php            | 353 +++++++++++++++++
 include/lib/message_javascript.php                |   2 +-
 include/operation_ods_new.inc.php                 |   2 +-
 include/tax_summary.inc.php                       |  72 ++++
 include/template/param_jrn.php                    | 187 ++++++---
 include/template/tax_summary_display.php          | 375 ++++++++++++++++++
 unit-test/include/class/acc_balanceTest.class.php |  15 +-
 unit-test/include/class/acc_ledgerTest.class.php  | 317 ++++++++++-----
 21 files changed, 1797 insertions(+), 626 deletions(-)

diff --git a/include/cfgledger.inc.php b/include/cfgledger.inc.php
index 9da41a3..679827d 100644
--- a/include/cfgledger.inc.php
+++ b/include/cfgledger.inc.php
@@ -54,7 +54,7 @@ if (  $action_frm == 'update')
 {
        try
        {
-               $ledger->id=$http->post('p_jrn',"number");
+               $ledger->set_ledger_id($http->post('p_jrn',"number"));
                if ( $ledger->load() == -1) throw new Exception (_('Journal 
inexistant'));
                $ledger->verify_ledger($_POST);
                $ledger->update($_POST);
@@ -72,7 +72,7 @@ if (  $action_frm == 'update')
 //////////////////////////////////////////////////////////////////////////
 if ($action_frm == 'delete' )
 {
-       $ledger->id=$http->post('p_jrn',"number");
+       $ledger->set_ledger_id($http->post('p_jrn',"number"));
        $ledger->load();
        $name=$ledger->get_name();
        try {
@@ -104,7 +104,7 @@ if (isset($_POST['add']))
                $ledger->verify_ledger($_POST);
                $ledger->save_new($_POST);
                $sa="detail";
-                $a[]=["key"=>'p_jrn',"value"=>$ledger->id];
+                $a[]=["key"=>'p_jrn',"value"=>$ledger->get_ledger_id()];
                put_global($a);
                 $show_menu=1;
        }
@@ -129,7 +129,7 @@ switch ($sa)
        case 'detail': /* detail of a ledger */
                try
                {
-                       $ledger->id=$http->request('p_jrn',"number");
+                       
$ledger->set_ledger_id($http->request('p_jrn',"number"));
                        echo '<div class="content">';
                        echo '<form id="cfg_ledger_frm"  method="POST">';
                        echo $ledger->display_ledger();
diff --git a/include/class/acc_ledger.class.php 
b/include/class/acc_ledger.class.php
index 7487b7b..a251257 100644
--- a/include/class/acc_ledger.class.php
+++ b/include/class/acc_ledger.class.php
@@ -22,6 +22,7 @@ require_once NOALYSS_INCLUDE.'/lib/iselect.class.php';
 require_once NOALYSS_INCLUDE.'/lib/icard.class.php';
 require_once NOALYSS_INCLUDE.'/lib/ispan.class.php';
 require_once NOALYSS_INCLUDE.'/lib/ihidden.class.php';
+require_once NOALYSS_INCLUDE.'/lib/input_switch.class.php';
 require_once NOALYSS_INCLUDE.'/lib/idate.class.php';
 require_once NOALYSS_INCLUDE.'/lib/itext.class.php';
 require_once NOALYSS_INCLUDE.'/lib/icheckbox.class.php';
@@ -75,11 +76,12 @@ class Acc_Ledger extends jrn_def_sql
     function __construct($p_cn, $p_id)
     {
         $this->id=$p_id;
-        $this->name=&$this->jrn_def_name;
+        $this->ledger_name=&$this->jrn_def_name;
         $this->jrn_def_id=&$this->id;
         $this->db=$p_cn;
         $this->row=null;
         $this->nb=MAX_ARTICLE;
+        parent::__construct($p_cn, $p_id);
     }
 
     function get_last_pj()
@@ -104,7 +106,23 @@ class Acc_Ledger extends jrn_def_sql
             $this->db->create_sequence("s_jrn_pj".$this->id);
         return 0;
     }
-
+    /**
+     * Set the jrn_def.jrn_def_id
+     * @param integer $p_id
+     */
+    function set_ledger_id($p_id)
+    {
+        $this->id=$p_id;
+        $this->jrn_def_id=&$this->id;
+    }
+    /**
+     * Set the jrn_def.jrn_def_id
+     * @return integer
+     */
+    function get_ledger_id()
+    {
+        return $this->id;
+    }
     /**
      * @brief Return the type of a ledger (ACH,VEN,ODS or FIN) or GL
      *
@@ -113,7 +131,7 @@ class Acc_Ledger extends jrn_def_sql
     {
         if ($this->id==0)
         {
-            $this->name=_(" Tous les journaux");
+            $this->ledger_name=_(" Tous les journaux");
             $this->type="GL";
             return "GL";
         }
@@ -370,8 +388,8 @@ class Acc_Ledger extends jrn_def_sql
     {
         if ($this->id==0)
         {
-            $this->name=_("Grand Livre");
-            return $this->name;
+            $this->ledger_name=_("Grand Livre");
+            return $this->ledger_name;
         }
 
         $Res=$this->db->exec_sql("select jrn_def_name from ".
@@ -380,7 +398,7 @@ class Acc_Ledger extends jrn_def_sql
         if ($Max==0)
             return null;
         $ret=Database::fetch_array($Res, 0);
-        $this->name=$ret['jrn_def_name'];
+        $this->ledger_name=$ret['jrn_def_name'];
         return $ret['jrn_def_name'];
     }
 
@@ -417,18 +435,15 @@ class Acc_Ledger extends jrn_def_sql
         if ($this->id==0)
             return;
 
-        $Res=$this->db->exec_sql("select 
jrn_Def_id,jrn_def_name,jrn_def_class_deb,jrn_def_class_cred,jrn_def_type,
-                                 
jrn_deb_max_line,jrn_cred_max_line,jrn_def_ech,jrn_def_ech_lib,jrn_def_code,
-                                 
jrn_def_fiche_deb,jrn_def_fiche_cred,jrn_def_pj_pref
+        $Res=$this->db->get_row("select *
                                  from jrn_Def
                                  where jrn_def_id=$1", array($this->id));
-        $Count=Database::num_row($Res);
-        if ($Count==0)
+        if ($Res == NULL)
         {
             echo '<DIV="redcontent"><H2 class="error">'._('Parametres journaux 
non trouves').'</H2> </DIV>';
             return null;
         }
-        return Database::fetch_array($Res, 0);
+        return $Res;
     }
 
     /**
@@ -1015,7 +1030,7 @@ class Acc_Ledger extends jrn_def_sql
      * permitted card, 5 not in the user's period, 6 closed period
      *
      */
-    function verify($p_array)
+    function verify_operation($p_array)
     {
         if (is_array($p_array)==false||empty($p_array))
             throw new Exception("Array empty");
@@ -2285,6 +2300,12 @@ class Acc_Ledger extends jrn_def_sql
             ["label"=>_("Désactivé"),"value"=>0]
         ];
         $actif->selected=$this->jrn_enable;
+        
+        $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';
     }
 
@@ -2337,6 +2358,12 @@ class Acc_Ledger extends jrn_def_sql
             {
                 throw new Exception(_('Choix du type de journal est 
obligatoire'));
             }
+            if ($negative_amount == 1 && trim($negative_warning)=="") {
+                throw new Exception(_("Avertissement ne peut être vide"));
+            }
+            if ( $negative_amount <> 0 && $negative_amount <> 1 ){
+                  throw new Exception(_("Valeur invalide"));
+            }
         }
         catch (Exception $e)
         {
@@ -2365,6 +2392,9 @@ class Acc_Ledger extends jrn_def_sql
         $this->jrn_deb_max_line=($min_row<1)?1:$min_row;
         $this->jrn_def_description=$p_description;
         $this->jrn_enable=$jrn_enable;
+        $this->jrn_def_negative_amount=$negative_amount;
+        $this->jrn_def_negative_warning=$negative_warning;
+        
         switch ($this->jrn_def_type)
         {
             case 'ACH':
@@ -2521,6 +2551,9 @@ class Acc_Ledger extends jrn_def_sql
         $cn=$this->db;
         $min_row=new INum("min_row", MAX_ARTICLE);
         $min_row->prec=0;
+        $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';
     }
 
@@ -2544,6 +2577,11 @@ class Acc_Ledger extends jrn_def_sql
                 trim(substr($this->jrn_def_type, 0, 1)),
                 Acc_Ledger::next_number($this->db, $this->jrn_def_type));
         $this->jrn_def_description=$p_description;
+        $this->currency_id=0;
+        $this->jrn_def_negative_amount=$negative_amount;
+        $this->jrn_def_negative_warning=$negative_warning;
+        $this->jrn_enable=1;
+        
         switch ($this->jrn_def_type)
         {
             case 'ACH':
@@ -2577,7 +2615,7 @@ class Acc_Ledger extends jrn_def_sql
                 $this->jrn_def_num_op=(isset($numb_operation))?1:0;
                 break;
         }
-
+        
         parent::insert();
     }
 
@@ -2888,6 +2926,23 @@ class Acc_Ledger extends jrn_def_sql
         return FALSE;
         
     }
+    /**
+     * 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 --git a/include/class/acc_ledger_fin.class.php 
b/include/class/acc_ledger_fin.class.php
index d361faa..b9023ac 100644
--- a/include/class/acc_ledger_fin.class.php
+++ b/include/class/acc_ledger_fin.class.php
@@ -53,7 +53,7 @@ class Acc_Ledger_Fin extends Acc_Ledger
         * @throw Exception on error occurs
         */
 
-       public function verify($p_array)
+       public function verify_operation($p_array)
        {
                global $g_user;
                 if (is_array($p_array ) == false || empty($p_array))
diff --git a/include/class/acc_ledger_purchase.class.php 
b/include/class/acc_ledger_purchase.class.php
index 56cb294..f479749 100644
--- a/include/class/acc_ledger_purchase.class.php
+++ b/include/class/acc_ledger_purchase.class.php
@@ -58,7 +58,7 @@ class  Acc_Ledger_Purchase extends Acc_Ledger
      *\return String
      *\throw Exception if an error occurs
      */
-    public function verify($p_array)
+    public function verify_operation($p_array)
     {
         global $g_parameter,$g_user;
         
@@ -1705,7 +1705,13 @@ EOF;
             $r.='<br>';
         }
         // check for upload piece
-
+        /* 
+         * warning if the amount is positive and expecting a negative one
+         */
+        $negative=$this->display_negative_warning($tot);
+        if ( $negative != "") {
+         $r.=span($negative,'class="warning" ');   
+        }
         return $r;
     }
 
diff --git a/include/class/acc_ledger_sold.class.php 
b/include/class/acc_ledger_sold.class.php
index 0536383..ae4535a 100644
--- a/include/class/acc_ledger_sold.class.php
+++ b/include/class/acc_ledger_sold.class.php
@@ -62,7 +62,7 @@ class Acc_Ledger_Sold extends Acc_Ledger {
      * \throw Exception if an error occurs
      */
 
-    public function verify($p_array) {
+    public function verify_operation($p_array) {
         global $g_parameter, $g_user;
         
         if (is_array($p_array ) == false || empty($p_array))
@@ -904,6 +904,8 @@ EOF;
             $r.='<br>Total '.hb($tot);
         }
         $r.='</div>';
+  
+            
         /*  Add hidden */
         $r.=HtmlInput::hidden('e_client', $e_client);
         $r.=HtmlInput::hidden('nb_item', $nb_item);
@@ -958,6 +960,13 @@ EOF;
             }
             $r.=HtmlInput::hidden("e_quant" . $i, ${"e_quant" . $i});
         }
+        /* 
+         * warning if the amount is positive and expecting a negative one
+         */
+        $negative=$this->display_negative_warning($tot);
+        if ( $negative != "") {
+         $r.=span($negative,'class="warning" ');   
+        }
         return $r;
     }
 
diff --git a/include/class/periode.class.php b/include/class/periode.class.php
index 322dd12..734cdba 100644
--- a/include/class/periode.class.php
+++ b/include/class/periode.class.php
@@ -104,18 +104,20 @@ class Periode
     {
         /* if jrn_Def_id == 0 then we check the global otherwise we check
           a ledger */
-        if ($this->jrn_def_id!=0)
+        if ($this->jrn_def_id!=0){
             $sql="select status from jrn_periode ".
-                    " where jrn_def_id=".$this->jrn_def_id.
-                    " and p_id =".$this->p_id;
-        else
+                    " where jrn_def_id=$1 ".
+                    " and p_id = $2";
+            $status=$this->cn->get_value($sql,[$this->jrn_def_id,$this->p_id]);
+        }
+        else {
             $sql="select p_closed as status from parm_periode ".
                     " where ".
-                    " p_id =".$this->p_id;
-        $res=$this->cn->exec_sql($sql);
-        $status=Database::fetch_result($res, 0, 0);
-        if ($status=='OP'||$status=='f')
-            return 1;
+                    " p_id = $1 ";
+            $status=$this->cn->get_value($sql,[$this->p_id]);
+        }
+            
+        if ($status=='OP'||$status=='f')            return 1;
         return 0;
     }
 
diff --git a/include/class/tax_summary.class.php 
b/include/class/tax_summary.class.php
new file mode 100644
index 0000000..8c482b2
--- /dev/null
+++ b/include/class/tax_summary.class.php
@@ -0,0 +1,355 @@
+<?php
+/*
+ *   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
+*/
+
+// Copyright Author Dany De Bontridder address@hidden
+
+/**
+ * @file
+ * @brief Compute , display and export the tax summary
+ *
+ */
+class Tax_Summary
+{
+    private $date_start;
+    private $date_end;
+    private $db;
+
+    function __construct(Database $db,$p_start, $p_end)
+    {
+        $this->db=$db;
+        $this->set_date_start($p_start);
+        $this->set_date_end($p_end);
+
+    }
+
+    /**
+     * @return Database
+     */
+    public function get_db()
+    {
+        return $this->db;
+        return $this;
+    }
+
+    /**
+     * @param Database $db
+     */
+    public function set_db($db)
+    {
+        $this->db = $db;
+        return $this;
+    }
+
+    /**
+     * @return mixed
+     */
+    public function get_date_start()
+    {
+        return $this->date_start;
+        return $this;
+    }
+
+    /**
+     * @param mixed $date_start
+     */
+    public function set_date_start($date_start)
+    {
+        if (isDate($date_start) == NULL) throw Exception(_("Format date 
invalide") . $date_start);
+        $this->date_start = $date_start;
+        return $this;
+    }
+
+    /**
+     * @return mixed
+     */
+    public function get_date_end()
+    {
+        return $this->date_end;
+        return $this;
+    }
+
+    /**
+     * @param mixed $date_end
+     */
+    public function set_date_end($date_end)
+    {
+        if (isDate($date_end) == NULL) throw Exception(_("Format date 
invalide") . $date_end);
+        $this->date_end = $date_end;
+        return $this;
+    }
+
+    /**
+     * @brief depends of quant_* table, so we must check first that everything
+     * is in these tables
+     */
+    function check()
+    {
+       /*-------------SALE ---------------------------------*/
+        $sql="select count(*) 
+             from 
+                jrnx 
+                join quant_sold on (quant_sold.j_id = jrnx.j_id)
+             where  
+                   jrnx.j_jrn_def in (select jrn_def_id from jrn_def where 
jrn_def_type = 'VEN')
+                    and j_date >= to_date($1,'DD.MM.YYYY') 
+                    and j_date <= to_date($2,'DD.MM.YYYY') 
+                  ";
+        $cnt=$this->db->get_value($sql,[$this->date_start,$this->date_end]);
+        if ($cnt == 0) {
+            throw new Exception(_("Aucune Donnée"));
+        }
+        /*-------------Purchase ---------------------------------*/
+        $sql="select count(*) 
+             from 
+                jrnx 
+                join quant_purchase as qp on (jrnx.j_id = qp.j_id)
+             where  
+                   jrnx.j_jrn_def in (select jrn_def_id from jrn_def where 
jrn_def_type = 'ACH')
+                    and j_date >= to_date($1,'DD.MM.YYYY') 
+                    and j_date <= to_date($2,'DD.MM.YYYY') 
+                             ";
+        $cnt=$this->db->get_value($sql,[$this->date_start,$this->date_end]);
+        if ($cnt == 0) {
+            throw new Exception(_("Aucune Donnée"));
+
+        }
+    }
+
+    /**
+     *  Total for each sales ledger
+     * @return array
+     */
+    function get_row_sale()
+    {
+        global $g_user;
+        $sql_ledger=$g_user->get_ledger_sql('ALL',3);
+        $sql="with detail_tva as (
+                    select 
+                        sum(qs_vat) as amount_vat,
+                        sum(qs_vat_sided) as amount_sided,
+                        sum(qs_price) as amount_wovat,
+                        qs_vat_code,
+                        j_jrn_def
+                    from 
+                        quant_sold 
+                        join tva_rate on (qs_vat_code=tva_rate.tva_id) 
+                        join jrnx on (quant_sold.j_id=jrnx.j_id)
+                        join jrn_def on (jrn_def.jrn_def_id=jrnx.j_jrn_def)
+                    where 
+                        j_date >= to_date($1,'DD.MM.YYYY') 
+                        and j_date <= to_date($2,'DD.MM.YYYY') 
+                        and {$sql_ledger}
+                    group by j_jrn_def,qs_vat_code)  
+                    select jrn_def_name,
+                        tva_label ,
+                        qs_vat_code,
+                          tva_rate,
+                    tva_both_side,
+                        amount_vat,
+                        amount_wovat,
+                        amount_sided
+                    from
+                        detail_tva 
+                        join tva_rate on (tva_rate.tva_id=qs_vat_code)
+                        join jrn_def on (jrn_def.jrn_def_id=j_jrn_def)
+                    
+                    order by jrn_def_name,tva_label";
+        $array=$this->db->get_array($sql,[$this->date_start,$this->date_end]);
+        return $array;
+
+    }
+
+
+    /**
+     * Total for each purchase ledger
+     * @return array
+     */
+    function get_row_purchase()
+    {
+        global $g_user;
+        $sql_ledger=$g_user->get_ledger_sql('ALL',3);
+        $sql="with detail_tva as (
+                select 
+                    sum(qp_vat) as amount_vat,
+                    sum(qp_vat_sided) as amount_sided,
+                    sum(qp_price) as amount_wovat,
+                    sum(qp_nd_amount) as amount_noded_amount,
+                    sum(qp_nd_tva) as amount_noded_tax,
+                    sum(qp_nd_tva_recup) as amount_noded_return,
+                    sum(qp_dep_priv) as amount_private,
+                    qp_vat_code,
+                    j_jrn_def
+                from 
+                    quant_purchase 
+                    join tva_rate on (qp_vat_code=tva_rate.tva_id) 
+                    join jrnx on (quant_purchase.j_id=jrnx.j_id)
+                    join jrn_def on (jrn_def.jrn_def_id=jrnx.j_jrn_def)
+                where 
+                    j_date >= to_date($1,'DD.MM.YYYY') 
+                    and j_date <= to_date($2,'DD.MM.YYYY') 
+                    and {$sql_ledger}
+                group by j_jrn_def,qp_vat_code)  
+                select jrn_def_name,
+                    tva_label ,
+                    tva_rate,
+                    tva_both_side,
+                    qp_vat_code,
+                    amount_vat,
+                    amount_wovat,
+                    amount_sided,
+                    amount_noded_amount,
+                    amount_noded_tax,
+                    amount_noded_return,
+                    amount_private
+                from
+                    detail_tva 
+                    join tva_rate on (tva_rate.tva_id=qp_vat_code)
+                    join jrn_def on (jrn_def.jrn_def_id=j_jrn_def)
+                order by jrn_def_name,tva_label";
+        $array=$this->db->get_array($sql,[$this->date_start,$this->date_end]);
+        return $array;
+    }
+
+    /**
+     * Summary for all sales ledger
+     */
+    function get_summary_sale()
+    {
+        global $g_user;
+        $sql_ledger=$g_user->get_ledger_sql('ALL',3);
+        $sql="with detail_tva as (
+                    select 
+                        sum(qs_vat) as amount_vat,
+                        sum(qs_vat_sided) as amount_sided,
+                        sum(qs_price) as amount_wovat,
+                        qs_vat_code
+                    from 
+                        quant_sold 
+                        join tva_rate on (qs_vat_code=tva_rate.tva_id) 
+                        join jrnx on (quant_sold.j_id=jrnx.j_id)
+                        join jrn_def on (jrn_def.jrn_def_id=jrnx.j_jrn_def)
+                    where 
+                        j_date >= to_date($1,'DD.MM.YYYY') 
+                        and j_date <= to_date($2,'DD.MM.YYYY') 
+                         and {$sql_ledger}
+                    group by qs_vat_code)  
+                    select 
+                        tva_label ,
+                        qs_vat_code,
+                          tva_rate,
+                    tva_both_side,
+                        amount_vat,
+                        amount_wovat,
+                        amount_sided
+                    from
+                        detail_tva 
+                        join tva_rate on (tva_rate.tva_id=qs_vat_code)
+                    order by tva_label";
+        $array=$this->db->get_array($sql,[$this->date_start,$this->date_end]);
+        return $array;
+    }
+    /**
+     * Summary for all purchase ledger
+     */
+    function get_summary_purchase()
+    {
+        global $g_user;
+        $sql_ledger=$g_user->get_ledger_sql('ALL',3);
+        $sql="with detail_tva as (
+                select 
+                    sum(qp_vat) as amount_vat,
+                    sum(qp_vat_sided) as amount_sided,
+                    sum(qp_price) as amount_wovat,
+                    sum(qp_nd_amount) as amount_noded_amount,
+                    sum(qp_nd_tva) as amount_noded_tax,
+                    sum(qp_nd_tva_recup) as amount_noded_return,
+                    sum(qp_dep_priv) as amount_private,
+                    qp_vat_code
+                from 
+                    quant_purchase 
+                    join tva_rate on (qp_vat_code=tva_rate.tva_id) 
+                    join jrnx on (quant_purchase.j_id=jrnx.j_id)
+                    join jrn_def on (jrn_def.jrn_def_id=jrnx.j_jrn_def)
+                where 
+                    j_date >= to_date($1,'DD.MM.YYYY') 
+                    and j_date <= to_date($2,'DD.MM.YYYY') 
+                     and {$sql_ledger}
+                group by qp_vat_code)  
+                select 
+                    tva_label ,
+                    tva_rate,
+                    tva_both_side,
+                    qp_vat_code,
+                    amount_vat,
+                    amount_wovat,
+                    amount_sided,
+                    amount_noded_amount,
+                    amount_noded_tax,
+                    amount_noded_return,
+                    amount_private
+                from
+                    detail_tva 
+                    join tva_rate on (tva_rate.tva_id=qp_vat_code)
+                order by tva_label";
+        $array=$this->db->get_array($sql,[$this->date_start,$this->date_end]);
+
+        return $array;
+    }
+    /**
+     * @brief display the summary of VAT in the range of date
+     */
+    function display()
+    {
+        require_once NOALYSS_INCLUDE."/template/tax_summary_display.php";
+    }
+    /**
+     * @brief display a form to export in CSV
+     * @see export_printtva_csv.php
+     */
+    function form_export_csv()
+    {
+        echo '<form method="GET" action="export.php">';
+        echo Dossier::hidden();
+        echo HtmlInput::hidden("act",'CSV:printtva');
+        echo HtmlInput::hidden("date_start",$this->date_start);
+        echo HtmlInput::hidden("date_end",$this->date_end);
+
+        echo HtmlInput::submit("CSV:printtva",_("Export CSV"));
+        echo '</form>';
+    }
+
+    /**
+     * @brief display a form to export in PDF
+     * @see export_printtva_pdf.php
+     */
+    function form_export_pdf()
+    {
+        echo '<form method="GET" action="export.php">';
+        echo Dossier::hidden();
+        echo HtmlInput::hidden("act",'PDF:printtva');
+        echo HtmlInput::hidden("date_start",$this->date_start);
+        echo HtmlInput::hidden("date_end",$this->date_end);
+
+        echo HtmlInput::submit("PDF:printtva",_("Export PDF"));
+        echo '</form>';
+    }
+
+
+}
diff --git a/include/compta_ach.inc.php b/include/compta_ach.inc.php
index 5ad7e6e..71f2af8 100644
--- a/include/compta_ach.inc.php
+++ b/include/compta_ach.inc.php
@@ -54,7 +54,7 @@ if (isset($_POST['view_invoice']))
        $Ledger = new Acc_Ledger_Purchase($cn, $post_jrn);
        try
        {
-               $Ledger->verify($_POST);
+               $Ledger->verify_operation($_POST);
        }
        catch (Exception $e)
        {
@@ -68,10 +68,8 @@ if (isset($_POST['view_invoice']))
                echo '<div class="content">';
                echo '<div id="confirm_div_id" style="width: 47%; float: 
left;">';
                 echo h1(_("Confirmation"));
-                echo '</div>';
-
-                echo '<div id="warning_ven_id" class="notice" style="width: 
50%; margin-left: 0px; float: right;">';
-                echo h2(_("Attention, cette opération n'est pas encore sauvée 
: vous devez encore confirmer"),' class="notice"');
+                echo h1(_("Confirmation"));
+                echo span(_("Vous devez encore confirmer"),' class="notice"');
                 echo '</div>';
 
                echo '<div id="confirm_div_id" style="width: 100%; float: 
left;">';
@@ -136,7 +134,7 @@ if (isset($_POST['record']))
        $Ledger = new Acc_Ledger_Purchase($cn, $post_jrn);
        try
        {
-               $Ledger->verify($_POST);
+               $Ledger->verify_operation($_POST);
        }
        catch (Exception $e)
        {
@@ -252,7 +250,7 @@ echo '</div>';
 
 echo '<div class="content">';
 
-echo '<p class="notice">'.$p_msg.'</p>';
+echo '<span class="warning">'.$p_msg.'</span>';
 try
 {
     $payment=$http->request("e_mp", "string",0);
diff --git a/include/compta_fin.inc.php b/include/compta_fin.inc.php
index 080916d..397b300 100644
--- a/include/compta_fin.inc.php
+++ b/include/compta_fin.inc.php
@@ -65,7 +65,7 @@ if ( isset($_POST['save']))
 {
        try
        {
-               $Ledger->verify($_POST);
+               $Ledger->verify_operation($_POST);
        }
        catch (Exception $e)
        {
@@ -97,7 +97,7 @@ if ( isset($_POST['confirm']))
 {
        try
        {
-               $Ledger->verify($_POST);
+               $Ledger->verify_operation($_POST);
        }
        catch (Exception $e)
        {
@@ -133,7 +133,7 @@ if ( isset($_POST['correct']))
 //----------------------------------------
 // Blank form
 //----------------------------------------
-echo '<p class="notice">'.$p_msg.'</p>';
+echo '<span class="warning">'.$p_msg.'</span>';
 
 echo '<form class="print" name="form_detail" enctype="multipart/form-data" 
class="print" METHOD="POST">';
 echo HtmlInput::hidden('ledger_type','fin');
diff --git a/include/compta_ods.inc.php b/include/compta_ods.inc.php
index cbdabcb..c6360da 100644
--- a/include/compta_ods.inc.php
+++ b/include/compta_ods.inc.php
@@ -72,17 +72,17 @@ if (!isset($_POST['summary']) && !isset($_POST['save']))
 }
 elseif (isset($_POST['summary']))
 {
-       try {
-                       $ledger->verify($_POST);
-                       require_once 
NOALYSS_INCLUDE.'/operation_ods_confirm.inc.php';
-       } catch (Exception $e)
-       {
-               echo alert($e->getMessage());
-                $p_msg=$e->getMessage();
-               require_once NOALYSS_INCLUDE.'/operation_ods_new.inc.php';
-
-       }
-       return;
+    try {
+        $ledger->verify_operation($_POST);
+        require_once NOALYSS_INCLUDE.'/operation_ods_confirm.inc.php';
+    } catch (Exception $e)
+    {
+        echo alert($e->getMessage());
+        $p_msg=$e->getMessage();
+        require_once NOALYSS_INCLUDE.'/operation_ods_new.inc.php';
+
+    }
+    return;
 }
 elseif (isset($_POST['save']))
 {
@@ -120,16 +120,16 @@ elseif (isset($_POST['save']))
                         }
                         catch (Exception $e)
                         {
-                            echo '<p class="notice">'._('Opération non 
extournée').
+                            echo '<span  class="warning">'._('Opération non 
extournée').
                                 $e->getMessage().
-                                '</p>';
+                                '</span>';
                                 
                             }
                     }
                     else
                     {
                         // warning because date is invalid
-                        echo '<p class="notice">'._('Date invalide, opération 
non extournée').'</p>';
+                        echo '<span class="warning">'._('Date invalide, 
opération non extournée').'</span>';
                     }
                 }
                 echo '<ul class="aligned-block">';
diff --git a/include/compta_ven.inc.php b/include/compta_ven.inc.php
index 7564669..702bb71 100644
--- a/include/compta_ven.inc.php
+++ b/include/compta_ven.inc.php
@@ -37,7 +37,7 @@ $str_dossier=dossier::get();
 global $g_parameter;
 $http=new HttpInput();
 $strac=$http->request('ac');
-$ac="ac=".$_REQUEST['ac'];
+$ac="ac=".$strac;
 $p_msg="";
 //----------------------------------------------------------------------
 // Encode a new invoice
@@ -48,7 +48,7 @@ $p_msg="";
 
     // Check privilege
     if ( isset($_REQUEST['p_jrn']) &&
-            $g_user->check_jrn($_REQUEST['p_jrn']) != 'W' )
+            $g_user->check_jrn($http->post("p_jrn","number")) != 'W' )
     {
 
         NoAccess();
@@ -58,10 +58,11 @@ $p_msg="";
     /* if a new invoice is encoded, we display a form for confirmation */
     if ( isset ($_POST['view_invoice'] ) )
     {
-        $Ledger=new Acc_Ledger_Sold($cn,$_POST['p_jrn']);
+        $p_jrn=$http->post("p_jrn","number");
+        $Ledger=new Acc_Ledger_Sold($cn,$p_jrn);
         try
         {
-            $Ledger->verify($_POST);
+            $Ledger->verify_operation($_POST);
         }
         catch (Exception $e)
         {
@@ -76,10 +77,7 @@ $p_msg="";
 
             echo '<div id="confirm_div_id" style="width: 47%; float: left;">';
             echo h1(_("Confirmation"));
-            echo '</div>';
-
-            echo '<div id="warning_ven_id" class="notice" style="width: 50%; 
margin-left: 0px; float: right;">';
-            echo h2(_("Attention, cette opération n'est pas encore sauvée : 
vous devez encore confirmer"),' class="notice"');
+            echo span(_("Vous devez encore confirmer"),' class="notice"');
             echo '</div>';
             
             echo '<div id="confirm_div_id" style="width: 100%; float: left;">';
@@ -152,7 +150,7 @@ show_tabs(a_tab,'facturation_div_id');
         $Ledger=new Acc_Ledger_Sold($cn,$_POST['p_jrn']);
         try
         {
-            $Ledger->verify($_POST);
+            $Ledger->verify_operation($_POST);
         }
         catch (Exception $e)
         {
@@ -272,7 +270,7 @@ echo $op->form_get('do.php?'.$url);
 echo '</div>';
 */
 echo '<div class="content">';
-echo '<p class="notice">'.$p_msg.'</p>';
+echo '<span class="warning">'.$p_msg.'</span>';
 try
 {
     $payment=$http->request("e_mp","string", 0);
@@ -316,7 +314,7 @@ try
     else
     {
         echo HtmlInput::hidden("ledger_type", "VEN");
-        echo HtmlInput::hidden("ac", $_REQUEST['ac']);
+        echo HtmlInput::hidden("ac", $strac);
         echo HtmlInput::hidden("sa", "p");
 
         echo $Ledger->input($array);
diff --git a/include/database/jrn_def_sql.class.php 
b/include/database/jrn_def_sql.class.php
index 4f7afc4..413e4d2 100644
--- a/include/database/jrn_def_sql.class.php
+++ b/include/database/jrn_def_sql.class.php
@@ -1,5 +1,7 @@
 <?php
-/*
+
+/**
+ * Autogenerated file 
  *   This file is part of NOALYSS.
  *
  *   NOALYSS is free software; you can redistribute it and/or modify
@@ -16,399 +18,79 @@
  *   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
- * @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"
-       );
-
-       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
-) values ($1
-,$2
-,$3
-,$4
-,$5
-,$6
-,$7
-,$8
-,$9
-,$10
-,$11
-,$12
-,$13
-,$14
-,$15
-) 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)
-                                       )
-                       );
-               }
-               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
-) 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
-                               , $this->jrn_def_id
-                                , strip_tags($this->jrn_def_description))
-                       );
-               }
-       }
-
-       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
- 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
-                        )
-               );
-       }
-
-       /**
-        * @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
- 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"
+        );
+
+        $this->date_format="DD.MM.YYYY";
+        parent::__construct($p_cn, $p_id);
+    }
 
 }
-
-// Jrn_Def_sql::test_me();
-?>
diff --git a/include/export/export_printtva_csv.php 
b/include/export/export_printtva_csv.php
new file mode 100644
index 0000000..c84ffe2
--- /dev/null
+++ b/include/export/export_printtva_csv.php
@@ -0,0 +1,83 @@
+<?php
+/*
+ *   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
+*/
+
+// Copyright Author Dany De Bontridder address@hidden
+/**
+ * @file
+ * @brief
+ *
+ */
+if ( ! defined ('ALLOWED') ) die('Appel direct ne sont pas permis');
+
+require_once  NOALYSS_INCLUDE."/class/tax_summary.class.php";
+require_once  NOALYSS_INCLUDE."/lib/noalyss_csv.class.php";
+$http=new HttpInput();
+$tax_summary = new 
Tax_Summary($cn,$http->get("date_start"),$http->get("date_end"));
+$tax_summary->check();
+
+$csv=new Noalyss_Csv("summary_tva");
+$csv->send_header();
+// Sale
+$csv->write_header([
+    _("Journal"),
+    ("Code TVA"),
+    _("Taux"),
+    _("Montant HT"),
+    _("Montant TVA"),
+    _("Montant Autoliquidation")]);
+$array=$tax_summary->get_row_sale();
+$nb_array=count($array);
+for ($i=0;$i < $nb_array;$i++) {
+    $csv->add ($array[$i]['jrn_def_name']);
+    $csv->add ($array[$i]['tva_label']);
+    $csv->add ($array[$i]['tva_rate'],'number');
+    $csv->add ($array[$i]['amount_wovat'],'number');
+    $csv->add ($array[$i]['amount_vat'],'number');
+    $csv->add ($array[$i]['amount_sided'],'number');
+    $csv->write();
+}
+//Purchase
+$csv->write_header([
+    _("Journal"),
+    ("Code TVA"),
+    _("Taux"),
+    _("Montant HT"),
+    _("Privée"),
+    _("Montant TVA"),
+    _("Montant Autoliquidation"),
+    _("Montant ND"),
+    _("TVA Non Déd"),
+    _("TVA Non Déd & récup")
+    ]);
+$array=$tax_summary->get_row_purchase();
+$nb_array=count($array);
+for ($i=0;$i < $nb_array;$i++) {
+    $csv->add ($array[$i]['jrn_def_name']);
+    $csv->add ($array[$i]['tva_label']);
+    $csv->add ($array[$i]['tva_rate'],'number');
+    $csv->add ($array[$i]['amount_wovat'],'number');
+    $csv->add ($array[$i]['amount_private'],'number');
+    $csv->add ($array[$i]['amount_vat'],'number');
+    $csv->add ($array[$i]['amount_sided'],'number');
+    $csv->add ($array[$i]['amount_noded_amount'],'number');
+    $csv->add ($array[$i]['amount_noded_tax'],'number');
+    $csv->add ($array[$i]['amount_noded_return'],'number');
+    $csv->write();
+}
diff --git a/include/export/export_printtva_pdf.php 
b/include/export/export_printtva_pdf.php
new file mode 100644
index 0000000..ab337ea
--- /dev/null
+++ b/include/export/export_printtva_pdf.php
@@ -0,0 +1,353 @@
+<?php
+/*
+ *   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
+*/
+
+// Copyright Author Dany De Bontridder address@hidden
+/**
+ * @file
+ * @brief export PDF
+ *
+ */
+if (!defined('ALLOWED')) die('Appel direct ne sont pas permis');
+require_once NOALYSS_INCLUDE . "/class/tax_summary.class.php";
+require_once NOALYSS_INCLUDE . '/class/user.class.php';
+require_once NOALYSS_INCLUDE . '/class/pdf_land.class.php';
+require_once NOALYSS_INCLUDE . '/lib/http_input.class.php';
+bcscale(4);
+$http = new HttpInput();
+
+$from_periode = $http->request("date_start");
+$to_periode = $http->request("date_end");
+
+
+$gDossier = dossier::id();
+
+/* Security */
+$cn = Dossier::connect();
+$tax_summary = new Tax_Summary($cn, $from_periode, $to_periode);
+$pdf = new PDFLand($cn);
+$pdf->setDossierInfo(sprintf(_("Date") . " : %s %s", $from_periode, 
$to_periode));
+$pdf->AliasNbPages();
+$pdf->AddPage();
+$pdf->SetAuthor('NOALYSS');
+$pdf->setTitle(_("Résumé TVA"), true);
+
+
+
+
+//-------------------------------------------------------------------------
+// Sales
+//-------------------------------------------------------------------------
+$a_sale_header = [_("Code TVA"), _("Taux"), _("Montant HT"), _("Montant TVA"),
+    _("Montant Autoliquidation")];
+$nb_sale = count($a_sale_header);
+$array = $tax_summary->get_row_sale();
+// Table header
+$nb_array = count($array);
+$tot_vat = 0;
+$tot_wovat = 0;
+$tot_sided = 0;
+$ledger_name = "";
+//-------------------------------------------------------------------------
+// For each sale ledger
+//-------------------------------------------------------------------------
+// Table with total
+$a_col=['tva_label','tva_rate','amount_wovat','amount_vat','amount_sided'];
+$nb_col=count($a_col);
+$a_tot=[];
+// initialize totals
+for ($e=2;$e<$nb_col;$e++){
+    $a_tot[$a_col[$e]]=0;
+}
+
+for ($i = 0; $i < $nb_array; $i++) {
+    for ($e=2;$e<$nb_col;$e++){
+        $colname=$a_col[$e];
+        $a_tot[$colname]=bcadd($a_tot[$colname],$array[$i][$colname]);
+    }
+
+    if ($i == 0) {
+        // Display ledger name
+
+        $ledger_name = $array[$i]['jrn_def_name'];
+        $pdf->SetFont('DejaVuCond', 'B', 10);
+        $pdf->write_cell(50, 8, $ledger_name);
+        $pdf->line_new();
+
+        // Display Header
+        $pdf->SetFont('DejaVuCond', 'B', 7);
+        for ($e=0;$e<$nb_col;$e++){
+            if ( $e == 0 ) {
+                $pdf->write_cell(40, 5,$a_sale_header[$e], 1, 0, 'L');
+            } else {
+                 $pdf->write_cell(40, 5,$a_sale_header[$e], 1, 0, 'R');
+            }
+            $a_tot[$colname]=0;
+        }
+        $pdf->line_new();
+        $pdf->SetFont('DejaVuCond', '', 7);
+    }
+    if ($ledger_name != $array[$i]['jrn_def_name']) {
+        // Display totals
+        $pdf->SetFont('DejaVuCond', 'B', 7);
+        $pdf->line_new();
+        $pdf->write_cell(70, 5, "");
+        for ($e=2;$e<$nb_col;$e++){
+            $colname=$a_col[$e];
+            $pdf->write_cell(40, 5, nbm($a_tot[$colname]), 0, 0, 'R');
+            $a_tot[$colname]=0;
+        }
+        $pdf->line_new();
+        $pdf->SetFont('DejaVuCond', 'B', 7);
+
+        // Display ledger name
+        $ledger_name = $array[$i]['jrn_def_name'];
+        $pdf->SetFont('DejaVuCond', 'B', 10);
+        $pdf->write_cell(50, 8, $ledger_name);
+        $pdf->line_new();
+
+        // Display Header
+        for ($e=0;$e<$nb_col;$e++){
+            if ( $e == 0 ) {
+                $pdf->write_cell(40, 5,$a_sale_header[$e], 1, 0, 'L');
+            } else {
+                $pdf->write_cell(40, 5,$a_sale_header[$e], 1, 0, 'R');
+            }
+            $a_tot[$colname]=0;
+        }
+    }
+    for ($e=0;$e<$nb_col;$e++){
+        $colname=$a_col[$e];
+        if ( $e ==0 ) {
+            $pdf->write_cell(40, 5, $array[$i][$colname], 1, 0, 'L');
+        } elseif ($e == 1 ){
+            $pdf->write_cell(40, 5, nbm($array[$i][$colname]*100), 1, 0, 'R');
+        }else {
+            $pdf->write_cell(40, 5, nbm($array[$i][$colname]), 1, 0, 'R');
+        }
+    }
+    $pdf->line_new();
+}
+$pdf->SetFont('DejaVuCond', 'B', 7);
+$pdf->write_cell(80, 5, "");
+for ($e=2;$e<$nb_col;$e++){
+    $colname=$a_col[$e];
+    $pdf->write_cell(40, 5, nbm($a_tot[$colname]), 1, 0, 'R');
+}
+
+//-------------------------------------------------------------------------
+// Summary sales
+//-------------------------------------------------------------------------
+$a_sum = $tax_summary->get_summary_sale();
+$pdf->line_new();
+$pdf->SetFont('DejaVuCond', 'B', 10);
+$pdf->write_cell(50, 8, _("Résumé TVA vente"));
+$pdf->line_new();
+
+$pdf->SetFont('DejaVuCond', 'B', 7);
+for ($i = 0; $i < $nb_sale; $i++) {
+    if ($i > 0 ) {
+        $pdf->write_cell(40, 5, $a_sale_header[$i], 1, 0, 'R');
+    } else {
+        $pdf->write_cell(40, 5, $a_sale_header[$i], 1, 0, 'L');
+    }
+}
+$pdf->line_new();
+
+$nb_array = count($array);
+// initialize totals
+for ($e=2;$e<$nb_col;$e++){
+    $a_tot[$a_col[$e]]=0;
+}
+$pdf->SetFont('DejaVuCond', '', 7);
+
+for ($i = 0; $i < $nb_array; $i++) {
+    // display each row
+    for ($e=0;$e<$nb_col;$e++){
+        $colname=$a_col[$e];
+        if ( $e ==0 ) {
+            // first column TVA_LABEL
+            $pdf->write_cell(40, 5, $array[$i][$colname], 1, 0, 'L');
+        } elseif ($e == 1 ){
+            // Secund col. tva rate
+            $pdf->write_cell(40, 5, nbm($array[$i][$colname]*100), 1, 0, 'R');
+        }else {
+            // Other cols,display amount and compute total
+            $a_tot[$colname] = bcadd($a_tot[$colname], $array[$i][$colname]);
+            $pdf->write_cell(40, 5, nbm($array[$i][$colname]), 1, 0, 'R');
+        }
+    }
+    $pdf->line_new();
+}
+$pdf->SetFont('DejaVuCond', 'B', 7);
+$pdf->write_cell(80, 5, "");
+for ($e=2;$e<$nb_col;$e++){
+    $colname=$a_col[$e];
+    $pdf->write_cell(40, 5, nbm($a_tot[$colname]), 1, 0, 'R');
+}
+$pdf->line_new();
+
+//------------------------------------------------------------------------------------------
+// Purchase
+//------------------------------------------------------------------------------------------
+$array = $tax_summary->get_row_purchase();
+$a_colp=['tva_label','tva_rate','amount_wovat','amount_private','amount_vat','amount_sided',
+    'amount_noded_amount','amount_noded_tax','amount_noded_return'];
+$a_purchase_header = [_("Code TVA"), _("Taux"), _("Montant HT"), _("Privée"), 
_("Montant TVA"),
+    _("Montant Autoliquidation"), _("Montant Non Déd"), _("TVA Non Déd"), 
_("TVA Non Déd & récup")];
+$nb_purchase = count($a_purchase_header);
+
+for ($e=2;$e<$nb_col;$e++){
+    $a_tot[$a_col[$e]]=0;
+}
+
+for ($i = 0; $i < $nb_array; $i++) {
+    for ($e=2;$e<$nb_col;$e++){
+        $colname=$a_col[$e];
+        $a_tot[$colname]=bcadd($a_tot[$colname],$array[$i][$colname]);
+    }
+
+    if ($i == 0) {
+        // Display ledger name
+
+        $ledger_name = $array[$i]['jrn_def_name'];
+        $pdf->SetFont('DejaVuCond', 'B', 10);
+        $pdf->write_cell(50, 8, $ledger_name);
+        $pdf->line_new();
+
+        // Display Header
+        $pdf->SetFont('DejaVuCond', 'B', 7);
+        for ($e=0;$e<$nb_col;$e++){
+            if ( $e == 0 ) {
+                $pdf->write_cell(40, 5,$a_purchase_header[$e], 1, 0, 'L');
+            } else {
+                $pdf->write_cell(40, 5,$a_purchase_header[$e], 1, 0, 'R');
+            }
+            $a_tot[$colname]=0;
+        }
+        $pdf->line_new();
+        $pdf->SetFont('DejaVuCond', '', 7);
+    }
+    if ($ledger_name != $array[$i]['jrn_def_name']) {
+        // Display totals
+        $pdf->SetFont('DejaVuCond', 'B', 7);
+        $pdf->line_new();
+        $pdf->write_cell(70, 5, "");
+        for ($e=2;$e<$nb_col;$e++){
+            $colname=$a_col[$e];
+            $pdf->write_cell(40, 5, nbm($a_tot[$colname]), 0, 0, 'R');
+            $a_tot[$colname]=0;
+        }
+        $pdf->line_new();
+        $pdf->SetFont('DejaVuCond', 'B', 7);
+
+        // Display ledger name
+        $ledger_name = $array[$i]['jrn_def_name'];
+        $pdf->SetFont('DejaVuCond', 'B', 10);
+        $pdf->write_cell(50, 8, $ledger_name);
+        $pdf->line_new();
+
+        // Display Header
+        for ($e=0;$e<$nb_col;$e++){
+            if ( $e == 0 ) {
+                $pdf->write_cell(40, 5,$a_purchase_header[$e], 1, 0, 'L');
+            } else {
+                $pdf->write_cell(40, 5,$a_purchase_header[$e], 1, 0, 'R');
+            }
+            $a_tot[$colname]=0;
+        }
+    }
+    for ($e=0;$e<$nb_col;$e++){
+        $colname=$a_col[$e];
+        if ( $e ==0 ) {
+            $pdf->write_cell(40, 5, $array[$i][$colname], 1, 0, 'L');
+        } elseif ($e == 1 ){
+            $pdf->write_cell(40, 5, nbm($array[$i][$colname]*100), 1, 0, 'R');
+        }else {
+            $pdf->write_cell(40, 5, nbm($array[$i][$colname]), 1, 0, 'R');
+        }
+    }
+    $pdf->line_new();
+}
+$pdf->SetFont('DejaVuCond', 'B', 7);
+$pdf->write_cell(80, 5, "");
+for ($e=2;$e<$nb_col;$e++){
+    $colname=$a_col[$e];
+    $pdf->write_cell(40, 5, nbm($a_tot[$colname]), 1, 0, 'R');
+}
+
+//-------------------------------------------------------------------------
+// Summary sales
+//-------------------------------------------------------------------------
+$a_sum = $tax_summary->get_summary_sale();
+$pdf->line_new();
+$pdf->SetFont('DejaVuCond', 'B', 10);
+$pdf->write_cell(50, 8, _("Résumé TVA Achat"));
+$pdf->line_new();
+
+$pdf->SetFont('DejaVuCond', 'B', 7);
+for ($e=0;$e<$nb_col;$e++){
+    if ( $e == 0 ) {
+        $pdf->write_cell(40, 5,$a_purchase_header[$e], 1, 0, 'L');
+    } else {
+        $pdf->write_cell(40, 5,$a_purchase_header[$e], 1, 0, 'R');
+    }
+    $a_tot[$colname]=0;
+}
+$pdf->line_new();
+
+$nb_array = count($array);
+// initialize totals
+for ($e=2;$e<$nb_col;$e++){
+    $a_tot[$a_col[$e]]=0;
+}
+$pdf->SetFont('DejaVuCond', '', 7);
+
+for ($i = 0; $i < $nb_array; $i++) {
+    // display each row
+    for ($e=0;$e<$nb_col;$e++){
+        $colname=$a_col[$e];
+        if ( $e ==0 ) {
+            // first column TVA_LABEL
+            $pdf->write_cell(40, 5, $array[$i][$colname], 1, 0, 'L');
+        } elseif ($e == 1 ){
+            // Secund col. tva rate
+            $pdf->write_cell(40, 5, nbm($array[$i][$colname]*100), 1, 0, 'R');
+        }else {
+            // Other cols,display amount and compute total
+            $a_tot[$colname] = bcadd($a_tot[$colname], $array[$i][$colname]);
+            $pdf->write_cell(40, 5, nbm($array[$i][$colname]), 1, 0, 'R');
+        }
+    }
+    $pdf->line_new();
+}
+$pdf->SetFont('DejaVuCond', 'B', 7);
+$pdf->write_cell(80, 5, "");
+for ($e=2;$e<$nb_col;$e++){
+    $colname=$a_col[$e];
+    $pdf->write_cell(40, 5, nbm($a_tot[$colname]), 1, 0, 'R');
+}
+$pdf->line_new();
+
+
+//---------------------------------- Output 
--------------------------------------------------
+
+$fDate = date('Ymd-Hi');
+
+$pdf->Output('tva-' . $fDate . '.pdf', 'D');
\ No newline at end of file
diff --git a/include/lib/message_javascript.php 
b/include/lib/message_javascript.php
index 03c3f3f..9333a2d 100644
--- a/include/lib/message_javascript.php
+++ b/include/lib/message_javascript.php
@@ -103,5 +103,5 @@ content[69]="<?php echo escape_xml(_("Aucune donnée"))?>";
 content[70]="<?php echo escape_xml(_("Votre demande est en cours de 
traitement"))?>";
 content[71]="<?php echo _('Limite le type de fiche si vous choisissez la fiche 
à la saisie, uniquement avec journaux OD');?>";
 content[72]="<?php echo _("Pour les journaux FIN, ce sera la fiche du 
journal");?>";
-
+content[73]="<?php echo _("Mettre à oui pour un journal dédié uniquement aux 
notes de crédit ou de débit, il affichera un avertissement si le montant n'est 
pas en négatif");?>";
 </script>
\ No newline at end of file
diff --git a/include/operation_ods_new.inc.php 
b/include/operation_ods_new.inc.php
index f3dcacd..9396314 100644
--- a/include/operation_ods_new.inc.php
+++ b/include/operation_ods_new.inc.php
@@ -63,7 +63,7 @@ if ( isset ($_GET['action']) && ! isset($_POST['correct']) && 
! isset($correct)
             $p_post=null;
             if ( isset($_REQUEST['pre_def']) && $_REQUEST['pre_def'] != '')
             {
-                $op->set_od_id($_REQUEST['pre_def']);
+                $op->set_od_id($http->request('pre_def','number'));
                 $p_post=$op->compute_array();
             }
        }
diff --git a/include/tax_summary.inc.php b/include/tax_summary.inc.php
new file mode 100644
index 0000000..650ddbe
--- /dev/null
+++ b/include/tax_summary.inc.php
@@ -0,0 +1,72 @@
+<?php
+/*
+ *   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
+*/
+
+// Copyright Author Dany De Bontridder address@hidden
+/**
+ * @file
+ * @brief display summary of tax (VAT) possible parameter is time range
+ *
+ */
+require_once NOALYSS_INCLUDE.'/class/tax_summary.class.php';
+$http = new HttpInput();
+$limit = $g_user->get_limit_current_exercice();
+
+$start = $http->request("start_date", "date", $limit[0]);
+$end = $http->request("end_date", "date", $limit[1]);
+
+$start_periode = new IDate("start_date", $start);
+$end_periode = new IDate("end_date", $end);
+echo '<FORM METHOD="GET">';
+echo HtmlInput::array_to_hidden(['gDossier','ac'],$_GET);
+echo HtmlInput::hidden("do","display");
+printf(_("Période du %s au %s"),
+    $start_periode->input(),
+    $end_periode->input());
+
+echo HtmlInput::submit("show_tax_summary",_("Afficher"));
+echo '</FORM>';
+echo '<hr>';
+if ( $http->get("do","string","no") == "display")
+{
+    $tax_summary=new 
Tax_Summary($cn,$start_periode->value,$end_periode->value);
+    try {
+        $tax_summary->check();
+        echo '<ul class="aligned-block">';
+        echo '<li>';
+        echo $tax_summary->form_export_csv();
+        echo '</li>';
+        echo '<li>';
+        echo $tax_summary->form_export_pdf();
+        echo '</li>';
+        echo '</ul>';
+        $tax_summary->display();
+        echo '<ul class="aligned-block">';
+        echo '<li>';
+        echo $tax_summary->form_export_csv();
+        echo '</li>';
+        echo '<li>';
+        echo $tax_summary->form_export_pdf();
+        echo '</li>';
+        echo '</ul>';
+
+    } catch (Exception $e) {
+        echo $e->getMessage();
+    }
+}
diff --git a/include/template/param_jrn.php b/include/template/param_jrn.php
index 4e9e505..b5af8ce 100644
--- a/include/template/param_jrn.php
+++ b/include/template/param_jrn.php
@@ -16,10 +16,13 @@
                 <td></td>
 </TR>
 <?php
+//---------------------------------------------------------------------------------------------------------------
+//ODS
+//---------------------------------------------------------------------------------------------------------------
 if ( $new || $type=='ODS' ):
 ?>
 <TR id="type_ods">
-<td><?php echo _('Postes utilisables journal (débit/crédit) ')?>
+<td style="white-space: nowrap"><?php echo _('Postes utilisables journal 
(débit/crédit) ')?>
 </TD>
 <td>
 <?php echo $search;?>
@@ -33,46 +36,87 @@ if ( $new || $type=='ODS' ):
 endif;
 ?>
 <?php
-if ( $new|| $type=='FIN') {
+//---------------------------------------------------------------------------------------------------------------
+//FIN
+//---------------------------------------------------------------------------------------------------------------
+if ( $new|| $type=='FIN') :
 ?>
-<tr id="type_fin">
-<td>
-    <?php echo _('Numérotation de chaque opération')?>
-</td>
-<td>
-    <?php echo $num_op->input();?>
-</td>
-</tr>
-<tr id="type_fin2">
-<TD>
-<?php echo _('Compte en banque')?>
-</td>
-<TD>
-<?php
-$card=new ICard();
-$card->name='bank';
-$card->extra=$cn->make_list('select fd_id from fiche_def where frd_id=4');
-$card->set_dblclick("fill_ipopcard(this);");
-$card->set_function('fill_data');
-$card->set_attribute('ipopup','ipop_card');
-$list=$cn->make_list('select fd_id from fiche_def where frd_id=4');
-$card->set_attribute('typecard',$list);
+    <tr id="type_fin">
+    <td style="white-space: nowrap">
+        <?php echo _('Numérotation de chaque opération')?>
+    </td>
+    <td>
+        <?php echo $num_op->input();?>
+    </td>
+    </tr>
+    <tr id="type_fin2">
+    <TD style="white-space: nowrap">
+    <?php echo _('Compte en banque')?>
+    </td>
+    <TD>
+    <?php
+    $card=new ICard();
+    $card->name='bank';
+    $card->extra=$cn->make_list('select fd_id from fiche_def where frd_id=4');
+    $card->set_dblclick("fill_ipopcard(this);");
+    $card->set_function('fill_data');
+    $card->set_attribute('ipopup','ipop_card');
+    $list=$cn->make_list('select fd_id from fiche_def where frd_id=4');
+    $card->set_attribute('typecard',$list);
 
-$card->value=$qcode_bank;
-echo $card->search();
-echo $card->input();
-echo $str_add_button;
+    $card->value=$qcode_bank;
+    echo $card->search();
+    echo $card->input();
+    echo $str_add_button;
+    ?>
+    </td>
+    <td class="notice" style="white-space: nowrap">
+    <?php echo _("Obligatoire pour les journaux FIN : donner ici la fiche du 
compte en banque utilisée")?>
+    </td>
+    </tr>
+    <?php
+endif;
 ?>
-</td>
-<td class="notice">
-<?php echo _("Obligatoire pour les journaux FIN : donner ici la fiche du 
compte en banque utilisée")?>
-</td>
+        
 <?php
-}
+//---------------------------------------------------------------------------------------------------------------
+//ACH / VEN
+//---------------------------------------------------------------------------------------------------------------
+if ( $type == 'ACH' || $type == 'VEN'||$new):
+    // Display the warning : always used negative amounts
+    ?>
+    
+    <tr id="neg_amount">
+        <td style="white-space: nowrap">
+            
+            <?php 
+            echo _("Uniquement note de débit ou crédit");
+            echo Icon_Action::warnbulle(73);
+            ?>
+        </td>
+        <td>
+           <?php
+                
$negative->javascript="toggle_row_warning_enable('negative_amount','row_warning')";
+                $negative->input();
+            ?>
+        </td>
+    </tr>
+    <tr id="row_warning">
+        <td style="white-space: nowrap">
+            <?php echo _("Avertissement montant positif"); ?>
+        </td>
+        <td>
+            <?php echo $negative_warning->input();?>
+        </td>
+    </tr>
+<?php
+endif;
 ?>
-</TR>
+    
+    
+    
 <tr>
-       <td><?php echo _("Minimum de lignes à afficher")?></td>
+       <td style="white-space: nowrap"><?php echo _("Minimum de lignes à 
afficher")?></td>
 <td><?php echo $min_row->input()?></td>
 </tr>
 <tr>
@@ -103,32 +147,33 @@ echo $str_add_button;
 
 </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; ?>
 
 </TABLE>
@@ -365,6 +410,8 @@ echo $str_add_button;
         $('type_ods').style.display='none';
         $('type_fin').style.display='none';
         $('type_fin2').style.display='none';
+        $('neg_amount').style.display='none';
+        $('row_warning').style.display='none';
     }
    function show_ledger_div()
    {
@@ -381,6 +428,19 @@ echo $str_add_button;
                hide_row();
                $('type_ods').style.display='table-row';
                break;
+           case 'ACH':
+            hide_row();
+               $('neg_amount').style.display='table-row';
+               toggle_row_warning_enable('negative_amount','row_warning');
+
+               break;
+           case 'VEN':
+               hide_row();
+               $('neg_amount').style.display='table-row';
+               toggle_row_warning_enable('negative_amount','row_warning');
+
+               break;
+
            default:
                hide_row();
        }
@@ -396,3 +456,10 @@ echo $str_add_button;
     ?>
 </script>
 <?php endif; ?>
+<?php if ( $type=="ACH" || $type=="VEN") :?>
+<script>
+toggle_row_warning_enable('negative_amount','row_warning');
+</script>
+<?php
+endif;
+?>
\ No newline at end of file
diff --git a/include/template/tax_summary_display.php 
b/include/template/tax_summary_display.php
new file mode 100644
index 0000000..84bb1b5
--- /dev/null
+++ b/include/template/tax_summary_display.php
@@ -0,0 +1,375 @@
+<?php
+/*
+ *   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
+*/
+
+// Copyright Author Dany De Bontridder address@hidden
+
+/**
+ * @file
+ * @brief display the tax summary result
+ * @see Tax_Summary
+ *
+ */?>
+<h2><?php echo _("Vente")?></h2>
+
+<?php
+bcscale(4);
+$array=$this->get_row_sale();
+$nb_array=count($array);
+$ledger="";
+$r=0;
+$tot_vat=0;$tot_wovat=0;$tot_sided=0;
+
+for ($i=0;$i < $nb_array;$i++):
+
+    if ( $ledger != $array[$i]['jrn_def_name']):
+        if ( $ledger != "") :
+            // last row with total
+            echo '<tr class="highlight">';
+            echo td();
+            echo td();
+            echo td(nbm($tot_wovat),' class="num" ');
+            echo td(nbm($tot_vat),' class="num" ');
+            echo td(nbm($tot_sided),' class="num" ');
+            echo '</tr>';
+            echo '</table>';
+        endif;
+        $ledger=$array[$i]['jrn_def_name'];
+        //reinitialize sum
+        $tot_vat=0;$tot_wovat=0;$tot_sided=0;
+
+        printf("<h3>%s</h3>",$ledger);
+        echo '<table class="result">';
+        echo '<tr>';
+        echo th(_("Code TVA"));
+        echo th(_("Taux"),'class="num"');
+        echo th(_("Montant HT"),'class="num"');
+        echo th(_("Montant TVA"),'class="num"');
+        echo th(_("Montant Autoliquidation"),'class="num"');
+        echo '</tr>';
+        $r=0;
+    endif;
+    $color=($r%2==0)?"even":"odd";
+?>
+<tr class="<?php echo $color;?>">
+    <td>
+        <?=$array[$i]['tva_label']?>
+    </td>
+    <td>
+        <?=$array[$i]['tva_rate']*100?>%
+    </td>
+    <td class="num">
+        <?=nbm($array[$i]['amount_wovat'])?>
+    </td>
+    <td class="num">
+        <?=nbm($array[$i]['amount_vat'])?>
+    </td>
+    <td class="num">
+        <?=nbm($array[$i]['amount_sided'])?>
+    </td>
+</tr>
+    <?php
+    $tot_vat=bcadd($tot_vat,$array[$i]['amount_vat']);
+    $tot_wovat=bcadd($tot_wovat,$array[$i]['amount_wovat']);
+    $tot_sided=bcadd($tot_sided,$array[$i]['amount_sided']);
+
+    ?>
+<?php endfor;?>
+<?php
+if ( $nb_array > 0):
+// last row with total
+    echo '<tr class="highlight">';
+    echo td();
+    echo td();
+    echo td(nbm($tot_wovat),' class="num" ');
+    echo td(nbm($tot_vat),' class="num" ');
+    echo td(nbm($tot_sided),' class="num" ');
+    echo '</tr>';
+else:
+    echo _("Aucune donnée");
+endif;
+    echo '</table>';
+?>
+<h3><?=_("Résumé tous les journaux de vente")?></h3>
+<?php
+$a_sum=$this->get_summary_sale();
+?>
+<table class="result">
+    <tr>
+        <th>
+            <?=_("Code TVA")?>
+        </th>
+        <th>
+            <?=_("Taux")?>
+        </th>
+        <th  class="num">
+            <?=_("Montant HT")?>
+        </th>
+        <th class="num">
+            <?=_("Montant TVA")?>
+        </th>
+        <th class="num">
+            <?=_("Montant Autoliquidation")?>
+        </th>
+    </tr>
+    <?php
+    $nb_sum=count($a_sum);
+    $tot_vat=0;$tot_wovat=0;$tot_sided=0;
+
+    for ($e=0;$e < $nb_sum ; $e++):
+        $tot_vat=bcadd($tot_vat,$a_sum[$e]['amount_vat']);
+        $tot_wovat=bcadd($tot_wovat,$a_sum[$e]['amount_wovat']);
+        $tot_sided=bcadd($tot_sided,$a_sum[$e]['amount_sided']);
+
+        ?>
+    <tr>
+
+        <td>
+            <?=$a_sum[$e]['tva_label']?>
+        </td>
+        <td  class="num">
+            <?=$a_sum[$e]['tva_rate']*100?>%
+        </td>
+        <td class="num">
+            <?=nbm($a_sum[$e]['amount_wovat'])?>
+        </td>
+        <td class="num">
+            <?=nbm($a_sum[$e]['amount_vat'])?>
+        </td>
+        <td class="num">
+            <?=nbm($a_sum[$e]['amount_sided'])?>
+        </td>
+    </tr>
+<?php
+    endfor;
+
+    echo '<tr class="highlight">';
+        echo td();
+        echo td();
+        echo td(nbm($tot_wovat),' class="num" ');
+        echo td(nbm($tot_vat),' class="num" ');
+        echo td(nbm($tot_sided),' class="num" ');
+        echo '</tr>';
+        ?>
+</table>
+<?php
+$array =    $this->get_summary_sale();
+
+
+?>
+<h2><?php echo _("Achat")?></h2>
+<?php
+$array=$this->get_row_purchase();
+$nb_array=count($array);
+$ledger="";
+$r=0;
+$tot_vat=0;$tot_wovat=0;$tot_sided=0;$tot_noded_amount=0;$tot_noded_tax=0;$tot_noded_return=0;$tot_private=0;
+for ($i=0;$i < $nb_array;$i++):
+
+    if ( $ledger != $array[$i]['jrn_def_name']):
+        if ( $ledger != "") :
+            // last row with total
+            echo '<tr class="highlight">';
+            echo td();
+            echo td();
+            echo td(nbm($tot_wovat),' class="num" ');
+            echo td(nbm($tot_private),' class="num" ');
+            echo td(nbm($tot_vat),' class="num" ');
+            echo td(nbm($tot_sided),' class="num" ');
+            echo td(nbm($tot_noded_amount),' class="num" ');
+            echo td(nbm($tot_noded_tax),' class="num" ');
+            echo td(nbm($tot_noded_return),' class="num" ');
+            echo '</tr>';
+            echo '</table>';
+        endif;
+        $ledger=$array[$i]['jrn_def_name'];
+        //reinitialize sum
+        
$tot_vat=0;$tot_wovat=0;$tot_sided=0;$tot_noded_amount=0;$tot_noded_tax=0;$tot_noded_return=0;$tot_private=0;
+
+        printf("<h3>%s</h3>",$ledger);
+        echo '<table class="result">';
+        echo '<tr>';
+        echo th(_("Code TVA"));
+        echo th(_("Taux"),'class="num"');
+        echo th(_("Montant HT"),'class="num"');
+        echo th(_("Privée"),'class="num"');
+        echo th(_("Montant TVA"),'class="num"');
+        echo th(_("Montant Autoliquidation"),'class="num"');
+        echo th(_("Montant Non Déd"),'class="num"');
+        echo th(_("TVA Non Déd"),'class="num"');
+        echo th(_("TVA Non Déd & récup"),'class="num"');
+        echo '</tr>';
+        $r=0;
+    endif;
+    $color=($r%2==0)?"even":"odd";
+    ?>
+    <tr class="<?php echo $color;?>">
+        <td>
+            <?=$array[$i]['tva_label']?>
+        </td>
+        <td>
+            <?=$array[$i]['tva_rate']*100?>%
+        </td>
+        <td class="num">
+            <?=nbm($array[$i]['amount_wovat'])?>
+        </td>
+        <td class="num">
+            <?=nbm($array[$i]['amount_private'])?>
+        </td>
+        <td class="num">
+            <?=nbm($array[$i]['amount_vat'])?>
+        </td>
+        <td class="num">
+            <?=nbm($array[$i]['amount_sided'])?>
+        </td>
+        <td class="num">
+            <?=nbm($array[$i]['amount_noded_amount'])?>
+        </td>
+        <td class="num">
+            <?=nbm($array[$i]['amount_noded_tax'])?>
+        </td>
+        <td class="num">
+            <?=nbm($array[$i]['amount_noded_return'])?>
+        </td>
+    </tr>
+    <?php
+    $tot_vat=bcadd($tot_vat,$array[$i]['amount_vat']);
+    $tot_wovat=bcadd($tot_wovat,$array[$i]['amount_wovat']);
+    $tot_sided=bcadd($tot_sided,$array[$i]['amount_sided']);
+    
$tot_noded_amount=bcadd($tot_noded_amount,$array[$i]['amount_noded_amount']);
+    $tot_noded_tax=bcadd($tot_noded_tax,$array[$i]['amount_noded_tax']);
+    
$tot_noded_return=bcadd($tot_noded_return,$array[$i]['amount_noded_return']);
+    $tot_private=bcadd($tot_private,$array[$i]['amount_private']);
+
+    ?>
+<?php endfor;?>
+<?php
+// last row with total
+    if ( $nb_array > 0):
+    echo '<tr class="highlight">';
+    echo td();
+    echo td();
+    echo td(nbm($tot_wovat),' class="num" ');
+    echo td(nbm($tot_private),' class="num" ');
+    echo td(nbm($tot_vat),' class="num" ');
+    echo td(nbm($tot_sided),' class="num" ');
+    echo td(nbm($tot_noded_amount),' class="num" ');
+    echo td(nbm($tot_noded_tax),' class="num" ');
+    echo td(nbm($tot_noded_return),' class="num" ');
+    echo '</tr>';
+else:
+    echo _("Aucune donnée");
+endif;
+echo '</table>';
+?>
+<h3><?=_("Résumé tous les journaux d'achat")?></h3>
+<?php
+$a_sum=$this->get_summary_purchase();
+?>
+<table class="result">
+    <tr>
+        <th>
+            <?=_("Code TVA")?>
+        </th>
+        <th>
+            <?=_("Taux")?>
+        </th>
+        <th  class="num">
+            <?=_("Montant HT")?>
+        </th>
+        <th  class="num">
+            <?=_("Privée")?>
+        </th>
+        <th class="num">
+            <?=_("Montant TVA")?>
+        </th>
+        <th class="num">
+            <?=_("Montant Autoliquidation")?>
+        </th>
+        <th class="num">
+            <?=_("Montant Non Déd")?>
+        </th>
+        <th class="num">
+            <?=_("TVA Non Déd")?>
+        </th>
+        <th class="num">
+            <?=_("TVA Non Déd & récup")?>
+        </th>
+    </tr>
+    <?php
+    $nb_sum=count($a_sum);
+    
$tot_vat=0;$tot_wovat=0;$tot_sided=0;$tot_noded_amount=0;$tot_noded_tax=0;$tot_noded_return=0;$tot_private=0;
+
+    for ($e=0;$e < $nb_sum ; $e++):
+
+        ?>
+        <tr>
+
+            <td>
+                <?=$a_sum[$e]['tva_label']?>
+            </td>
+            <td  class="num">
+                <?=$a_sum[$e]['tva_rate']*100?>%
+            </td>
+            <td class="num">
+                <?=nbm($a_sum[$e]['amount_wovat'])?>
+            </td>
+            <td class="num">
+                <?=nbm($a_sum[$e]['amount_private'])?>
+            </td>
+            <td class="num">
+                <?=nbm($a_sum[$e]['amount_vat'])?>
+            </td>
+            <td class="num">
+                <?=nbm($a_sum[$e]['amount_sided'])?>
+            </td>
+            <td class="num">
+                <?=nbm($a_sum[$e]['amount_noded_amount'])?>
+            </td>
+            <td class="num">
+                <?=nbm($a_sum[$e]['amount_noded_tax'])?>
+            </td>
+            <td class="num">
+                <?=nbm($a_sum[$e]['amount_noded_return'])?>
+            </td>
+        </tr>
+    <?php
+        $tot_vat=bcadd($tot_vat,$a_sum[$e]['amount_vat']);
+        $tot_wovat=bcadd($tot_wovat,$a_sum[$e]['amount_wovat']);
+        $tot_sided=bcadd($tot_sided,$a_sum[$e]['amount_sided']);
+        
$tot_noded_amount=bcadd($tot_noded_amount,$a_sum[$e]['amount_noded_amount']);
+        $tot_noded_tax=bcadd($tot_noded_tax,$a_sum[$e]['amount_noded_tax']);
+        
$tot_noded_return=bcadd($tot_noded_return,$a_sum[$e]['amount_noded_return']);
+        $tot_private=bcadd($tot_private,$a_sum[$e]['amount_private']);
+
+    endfor;
+
+    echo '<tr class="highlight">';
+        echo td();
+        echo td();
+        echo td(nbm($tot_wovat),' class="num" ');
+        echo td(nbm($tot_private),' class="num" ');
+        echo td(nbm($tot_vat),' class="num" ');
+        echo td(nbm($tot_sided),' class="num" ');
+        echo td(nbm($tot_noded_amount),' class="num" ');
+        echo td(nbm($tot_noded_tax),' class="num" ');
+        echo td(nbm($tot_noded_return),' class="num" ');
+        echo '</tr>';
+        ?>
+</table>
diff --git a/unit-test/include/class/acc_balanceTest.class.php 
b/unit-test/include/class/acc_balanceTest.class.php
index 0799c9b..0cb5724 100644
--- a/unit-test/include/class/acc_balanceTest.class.php
+++ b/unit-test/include/class/acc_balanceTest.class.php
@@ -18,11 +18,13 @@ class Acc_BalanceTest extends TestCase
      */
     protected function setUp()
     {
-        global $g_connection, $g_parameter;
+        global $g_connection, $g_parameter,$g_user;
         $_REQUEST['gDossier']=DOSSIER;
         $g_connection=new Database(DOSSIER);
         $g_parameter=new Noalyss_Parameter_Folder($g_connection);
         $this->object=new Acc_Balance($g_connection);
+       
+        
     }
 
     /**
@@ -40,11 +42,12 @@ class Acc_BalanceTest extends TestCase
      */
     public function testGet_row()
     {
-        $this->object->get_row(1,200);
-        // Remove the following lines when you implement this test.
-        $this->markTestIncomplete(
-                'DATA : cannot be tested'
-        );
+        global $g_connection,$g_user;
+        $g_user=new User($g_connection,1);
+        
+        $max=$g_connection->get_value("select max(p_id) from parm_periode");
+        $min=$g_connection->get_value("select min(p_id) from parm_periode");
+        $this->object->get_row($min,$max);
     }
 
     /**
diff --git a/unit-test/include/class/acc_ledgerTest.class.php 
b/unit-test/include/class/acc_ledgerTest.class.php
index efc81cb..1c91653 100644
--- a/unit-test/include/class/acc_ledgerTest.class.php
+++ b/unit-test/include/class/acc_ledgerTest.class.php
@@ -18,6 +18,32 @@ class Acc_LedgerTest extends TestCase
         return $dataSet;
     }
     /**
+     * Get an operation
+     * @global type $g_connection
+     * @return type
+     */
+    private function get_jrn_id($p_ledger='ODS')
+    {
+        global $g_connection;
+        $jr_id=$g_connection->get_value("select max(jr_id) from jrn join 
jrn_def "
+                . "on (jrn_def_id=jr_def_id) "
+                . " where "
+                . " jrn_def_type=$1",[$p_ledger]);
+        return $jr_id;
+    }
+    /**
+     * Return 1 if operation does exist otherwise zero
+     * @global type $g_connection
+     * @param type $p_jr_id
+     * @return type
+     */
+    private function exist_operation($p_jr_id)
+    {
+        global $g_connection;
+        $jr_id=$g_connection->get_value("select count(*) from jrn where 
jr_id=$1",[$p_jr_id]);
+        return $jr_id;
+    }
+    /**
      * Sets up the fixture, for example, opens a network connection.
      * This method is called before a test is executed.
      */
@@ -43,9 +69,10 @@ class Acc_LedgerTest extends TestCase
     public function testGet_last_pj()
     {   
  
-        $this->object->id=1;
-        $array=$this->object->get_last(2);
-        $this->assertEquals(2,count($array));
+        $this->object->id=2;
+        $sPj=$this->object->get_last_pj(2);
+        print_r("get_last_pj $sPj");
+        $this->assertEquals(5,$sPj);
         
     }
 
@@ -78,16 +105,51 @@ class Acc_LedgerTest extends TestCase
      */
     public function testDelete()
     {
+        global $g_connection;
+        $jr_id=$g_connection->get_value("select max(jr_id) from jrn");
+        $this->object->jr_id=$jr_id;
         $this->object->delete();
+        $count=$g_connection->get_value("select count(*) from jrn where 
jr_id=$1",[$jr_id]);
+        $this->assertEquals($count,0);
+    }
+    public function delete_ledger()
+    {
+        global $g_connection;
+        // a . create a ledger and delete it
+        
$array=["p_jrn_def_name"=>"UNITTEST","p_ech_lib"=>"","p_jrn_deb_max_line"=>7,'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'];
+        $this->object->save_new($array);
+        
+        // Get it 
+        $last_ledger_inserted=$g_connection->get_value("select max(jrn_def_id) 
from jrn_def");
+        $name=$g_connection->get_value("select jrn_def_name from jrn_def where 
jrn_def_id=$1",[$last_ledger_inserted]);
+        $this->assertEquals($name,'UNITTEST');
+        
+        // drop it
+        $this->object->delete_ledger();
+        $cnt=$g_connection->get_value("select count(*) from jrn_def where 
jrn_def_id=$1",[$last_ledger_inserted]);
+        $this->assertEquals($cnt,0);
+        $ok=0;
+        // Try to delete a ledger which is used
+        try {
+            $jr_id=$g_connection->get_value("select max(jr_id) from jrn");
+            $ledger_id=$g_connection->get_value("select jr_def_id from jrn 
where jr_id=$1",[$jr_id]);
+            $ledger=new Acc_Legder($g_connection,$ledger_id);
+            $ledger->delete_ledger();
+        } catch (Exception $ex) {
+            $ok=1;
+        }
+        $this->assertEquals($ok,1);
+        $cnt=$g_connection->get_value("select count(*) from jrn_def where 
jrn_def_id=$1",[$ledger_id]);
+        $this->assertEquals($cnt,1);
     }
-
     /**
      * @covers Acc_Ledger::display_warning
      * @todo   Implement testDisplay_warning().
      */
     public function testDisplay_warning()
     {
-        $this->object->display_warning("Alert", "warning");
+        $str=$this->object->display_warning(["First Line","Second Line"], 
"warning");
+        $this->assertEquals('<p class="notice"> warning<ol 
class="notice"><li>First Line</li><li>Second Line</li></ol></p>',$str);
     }
 
     /**
@@ -96,7 +158,22 @@ class Acc_LedgerTest extends TestCase
      */
     public function testReverse()
     {
-        $this->object->reverse('01.01.2014');
+        global $g_connection;
+        $this->object->jr_id=$g_connection->get_value("select max(jr_id) from 
jrn ");
+        $this->assertLessThan($this->object->jr_id,"0","found jr_id 
".$this->object->jr_id);
+        $this->assertFalse(empty($this->object->jr_id),"not found jr_id ");
+        
+        $this->object->id=$g_connection->get_value("select jr_def_id from jrn 
where jr_id=$1",[$this->object->jr_id]);
+        $this->assertGreaterThan($this->object->id,"0","found id 
".$this->object->id);
+        $this->assertFalse(empty($this->object->id),"not found id ");
+        print_r("jr_id = ".$this->object->jr_id);
+        print_r("id = ".$this->object->id);
+        $date=$g_connection->get_value ("select 
to_char(max(p_start),'DD.MM.YYYY') from parm_periode where p_closed='f'");
+        $this->object->reverse($date,'unit test'.$date);
+        $check=$g_connection->get_value("select jr_id from jrn where 
jr_comment=$1",["unit test".$date]);
+        $this->assertFalse(empty($check),"NOT REVERSED" );
+        $this->object->jr_id=$check;
+        $this->object->delete();
     }
 
     /**
@@ -111,27 +188,21 @@ class Acc_LedgerTest extends TestCase
     }
 
     /**
-     * @covers Acc_Ledger::get_row
-     * @todo   Implement testGet_row().
-     */
-    public function testGet_row()
-    {
-        // Remove the following lines when you implement this test.
-        $this->markTestIncomplete(
-                'This test has not been implemented yet.'
-        );
-    }
-
-    /**
      * @covers Acc_Ledger::get_rowSimple
      * @todo   Implement testGet_rowSimple().
      */
     public function testGet_rowSimple()
     {
-        // Remove the following lines when you implement this test.
-        $this->markTestIncomplete(
-                'This test has not been implemented yet.'
-        );
+        global $g_connection;
+        $last=$g_connection->get_value("select max(p_id) from parm_periode");
+        $first=$g_connection->get_value("select min(p_id) from parm_periode");
+        $id=$this->object->id;
+        $this->object->id=2;
+        $array=$this->object->get_rowSimple($first,$last);
+        $this->assertTrue(is_array($array),"get_rowSimple does not return an 
array");
+        $this->assertGreaterThan(0,count($array));
+        $this->object->id=$id;
+        
     }
 
     /**
@@ -140,46 +211,9 @@ class Acc_LedgerTest extends TestCase
      */
     public function testGuess_pj()
     {
-        // Remove the following lines when you implement this test.
-        $this->markTestIncomplete(
-                'This test has not been implemented yet.'
-        );
-    }
-
-    /**
-     * @covers Acc_Ledger::list_operation_to_reconcile
-     * @todo   Implement testList_operation_to_reconcile().
-     */
-    public function testList_operation_to_reconcile()
-    {
-        // Remove the following lines when you implement this test.
-        $this->markTestIncomplete(
-                'This test has not been implemented yet.'
-        );
-    }
-
-    /**
-     * @covers Acc_Ledger::list_operation
-     * @todo   Implement testList_operation().
-     */
-    public function testList_operation()
-    {
-        // Remove the following lines when you implement this test.
-        $this->markTestIncomplete(
-                'This test has not been implemented yet.'
-        );
-    }
-
-    /**
-     * @covers Acc_Ledger::get_detail
-     * @todo   Implement testGet_detail().
-     */
-    public function testGet_detail()
-    {
-        // Remove the following lines when you implement this test.
-        $this->markTestIncomplete(
-                'This test has not been implemented yet.'
-        );
+        $this->object->id=2;
+        $r=$this->object->guess_pj();
+        $this->assertEquals("VEN6",$r);
     }
 
     /**
@@ -188,10 +222,11 @@ class Acc_LedgerTest extends TestCase
      */
     public function testGet_propertie()
     {
-        // Remove the following lines when you implement this test.
-        $this->markTestIncomplete(
-                'This test has not been implemented yet.'
-        );
+        global $g_connection;
+        $this->object->id=2;
+        $array=$this->object->get_propertie();
+        // there are 16 columns in jrn_def
+        $this->assertEquals(count($array),20);
     }
 
     /**
@@ -205,7 +240,38 @@ class Acc_LedgerTest extends TestCase
                 'This test has not been implemented yet.'
         );
     }
-
+    /**
+     * @covers Acc_Ledger::display_negative_warning
+     */
+    public function testDisplay_negative_warning()
+    {
+        global $g_connection;
+        $msg="WARNING ! WARNING !";
+        $acc_ledger=new Jrn_def_SQL($g_connection,2);
+        $acc_ledger_old=clone $acc_ledger;
+        $acc_ledger->setp("jrn_def_negative_amount",1);
+        $acc_ledger->setp("jrn_def_negative_warning",$msg);
+        $acc_ledger->save();
+        $this->object->set_ledger_id(2);
+        $result=$this->object->display_negative_warning(-1);
+        $this->assertEquals($result,"");
+        $result=$this->object->display_negative_warning(1);
+        $this->assertEquals($result,$msg);
+        
+        $acc_ledger_old->save();
+        $id=$this->object->get_ledger_id();
+        $ok=0;
+        try {
+            $this->object->set_ledger_id(0);
+            $result=$this->object->display_negative_warning(1);
+        }        catch (Exception $e) {
+            $this->assertEquals($e->getCode(),1);
+            $ok=1;
+        }
+        $this->assertEquals($ok,1);
+        $this->object->set_ledger_id($id);
+        
+    }
     /**
      * @covers Acc_Ledger::get_solde
      * @todo   Implement testGet_solde().
@@ -666,9 +732,36 @@ class Acc_LedgerTest extends TestCase
      */
     public function testGet_tiers()
     {
-        $this->object->get_tiers($p_jrn_type, $jr_id);
+        global $g_connection;
+        $jr_id=$this->get_jrn_id();
+        $this->assertEquals($this->object->get_tiers("ODS", $jr_id)," ");
+
+        $jr_id=$this->get_jrn_id("ACH");
+        $this->assertTrue($this->object->get_tiers("ACH",$jr_id)!=' '); 
+
+        $jr_id=$this->get_jrn_id("FIN");
+        $this->assertTrue($this->object->get_tiers('FIN',$jr_id)!=' ');
+
+        $jr_id=$this->get_jrn_id("VEN");
+        $this->assertTrue($this->object->get_tiers("VEN",$jr_id)!=' ');
+        
     }
+    public function testGet_tiers_id()
+    {
+        global $g_connection;
+        $jr_id=$this->get_jrn_id();
+        $this->assertEquals($this->object->get_tiers_id("ODS", $jr_id),0);
+
+        $jr_id=$this->get_jrn_id("ACH");
+        $this->assertGreaterThan(0,$this->object->get_tiers_id("ACH",$jr_id));
+
+        $jr_id=$this->get_jrn_id("FIN");
+        $this->assertGreaterThan(0,$this->object->get_tiers_id("FIN",$jr_id));
 
+        $jr_id=$this->get_jrn_id("VEN");
+        $this->assertGreaterThan(0,$this->object->get_tiers_id("VEN",$jr_id));
+        
+    }
     /**
      * @covers Acc_Ledger::listing
      * @todo   Implement testListing().
@@ -719,14 +812,12 @@ class Acc_LedgerTest extends TestCase
 
     /**
      * @covers Acc_Ledger::input_paid
-     * @todo   Implement testInput_paid().
      */
     public function testInput_paid()
     {
-        // Remove the following lines when you implement this test.
-        $this->markTestIncomplete(
-                'This test has not been implemented yet.'
-        );
+        $r=$this->object->input_paid(0);
+        $this->assertStringStartsWith('<div id="payment">',$r);
+        $this->assertStringEndsWith('</div>',$r);
     }
 
     /**
@@ -743,14 +834,30 @@ class Acc_LedgerTest extends TestCase
 
     /**
      * @covers Acc_Ledger::save_new
-     * @todo   Implement testSave_new().
      */
     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'];
+        
+
+        $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 @@ class Acc_LedgerTest extends TestCase
      */
     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'];
+
+        $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,"");
     }
 
     /**
@@ -771,10 +891,15 @@ class Acc_LedgerTest extends TestCase
      */
     public function testGet_operation_date()
     {
-        // Remove the following lines when you implement this test.
-        $this->markTestIncomplete(
-                'This test has not been implemented yet.'
-        );
+        $res=$this->object->get_operation_date('01.01.2010','VEN','>');
+        $this->assertGreaterThan(0,count($res),'Failed VEN');
+        $res=$this->object->get_operation_date('01.01.2010','ACH','>');
+        $this->assertGreaterThan(0,count($res),'Failed ACH ');
+        $res=$this->object->get_operation_date('01.01.2000','VEN','<');
+        $this->assertEquals(count($res),0,'Failed VEN before ');
+        $res=$this->object->get_operation_date('01.01.2000','ACH','<');
+        $this->assertEquals(count($res),0,'Failed ACH before');
+
     }
 
     /**
@@ -783,10 +908,7 @@ class Acc_LedgerTest extends TestCase
      */
     public function testGet_supplier_now()
     {
-        // Remove the following lines when you implement this test.
-        $this->markTestIncomplete(
-                'This test has not been implemented yet.'
-        );
+       $this->assertTrue(is_array($this->object->get_supplier_now()));
     }
 
     /**
@@ -795,10 +917,7 @@ class Acc_LedgerTest extends TestCase
      */
     public function testGet_supplier_late()
     {
-        // Remove the following lines when you implement this test.
-        $this->markTestIncomplete(
-                'This test has not been implemented yet.'
-        );
+       $this->assertTrue(is_array($this->object->get_supplier_late()));
     }
 
     /**
@@ -807,10 +926,7 @@ class Acc_LedgerTest extends TestCase
      */
     public function testGet_customer_now()
     {
-        // Remove the following lines when you implement this test.
-        $this->markTestIncomplete(
-                'This test has not been implemented yet.'
-        );
+         $this->assertTrue(is_array($this->object->get_customer_now()));
     }
 
     /**
@@ -819,10 +935,7 @@ class Acc_LedgerTest extends TestCase
      */
     public function testGet_customer_late()
     {
-        // Remove the following lines when you implement this test.
-        $this->markTestIncomplete(
-                'This test has not been implemented yet.'
-        );
+        $this->assertTrue(is_array($this->object->get_customer_late()));
     }
 
     /**



reply via email to

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