noalyss-commit
[Top][All Lists]
Advanced

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

[Noalyss-commit] [noalyss] 08/28: Task #1762 Exigibility VAT : Print led


From: Dany De Bontridder
Subject: [Noalyss-commit] [noalyss] 08/28: Task #1762 Exigibility VAT : Print ledger for paid , unpaid or all operations PHPUNIT Test Files
Date: Sat, 30 Nov 2019 07:51:22 -0500 (EST)

sparkyx pushed a commit to branch master
in repository noalyss.

commit 1854dbd9b18b10006a5ef74a81448150e314022f
Author: Dany De Bontridder <address@hidden>
Date:   Sun Nov 17 14:14:31 2019 +0100

    Task #1762 Exigibility VAT :
    Print ledger for paid , unpaid or all operations
    PHPUNIT Test Files
---
 include/class/pdf.class.php                        |  23 +-
 include/class/print_ledger.class.php               | 329 +++++++++++++--------
 include/class/print_ledger_detail.class.php        |  15 +-
 include/class/print_ledger_detail_item.class.php   |  29 +-
 include/class/print_ledger_fin.class.php           |  20 +-
 include/class/print_ledger_misc.class.php          |  17 +-
 include/class/print_ledger_simple.class.php        |  41 ++-
 .../print_ledger_simple_without_vat.class.php      |  36 +--
 include/export/export_ledger_csv.php               |  12 +-
 include/export/export_ledger_pdf.php               |   7 +-
 unit-test/include/class/print_LedgerTest.php       | 147 +++++++++
 .../class/print_ledger_detail.classTest.php        |  81 +++++
 .../class/print_ledger_detail_item.classTest.php   | 162 ++++++++++
 .../include/class/print_ledger_fin.classTest.php   | 111 +++++++
 .../include/class/print_ledger_misc.classTest.php  |  89 ++++++
 .../class/print_ledger_simple.classTest.php        | 166 +++++++++++
 .../print_ledger_simple_without_vat.classTest.php  | 161 ++++++++++
 17 files changed, 1210 insertions(+), 236 deletions(-)

diff --git a/include/class/pdf.class.php b/include/class/pdf.class.php
index 650dafd..6f059e9 100644
--- a/include/class/pdf.class.php
+++ b/include/class/pdf.class.php
@@ -150,26 +150,5 @@ class PDF extends  PDF_Core
         }
         throw new Exception(_("Filter invalide ".$filter_operation), 5);
     }
-    /**
-     * Build a SQL clause to filter operation depending if they are paid, 
unpaid or no filter
-     * @return string SQL Clause
-     */
-    protected function build_filter_operation()
-    {
-        switch ($this->get_filter_operation())
-        {
-            case 'all':
-                $sql_filter="";
-                break;
-            case 'paid':
-                $sql_filter=" and (jr_date_paid is not null or  jr_rapt 
='paid' ) ";
-                break;
-            case 'unpaid':
-                $sql_filter=" and (jr_date_paid  is null and 
coalesce(jr_rapt,'x') <> 'paid' ) ";
-                break;
-            default:
-                throw new Exception(_("Filtre invalide", 5));
-        }
-        return $sql_filter;
-    }
+
 }
\ No newline at end of file
diff --git a/include/class/print_ledger.class.php 
b/include/class/print_ledger.class.php
index 83f43c1..8b8213f 100644
--- a/include/class/print_ledger.class.php
+++ b/include/class/print_ledger.class.php
@@ -24,20 +24,75 @@
  * @author danydb
  */
 require_once NOALYSS_INCLUDE.'/class/database.class.php';
-require_once NOALYSS_INCLUDE.'/class/print_ledger_detail.class.php';
-require_once NOALYSS_INCLUDE.'/class/print_ledger_simple.class.php';
-require_once 
NOALYSS_INCLUDE.'/class/print_ledger_simple_without_vat.class.php';
-require_once NOALYSS_INCLUDE.'/class/print_ledger_fin.class.php';
-require_once NOALYSS_INCLUDE.'/class/print_ledger_misc.class.php';
-require_once NOALYSS_INCLUDE.'/class/print_ledger_detail_item.class.php';
+require_once NOALYSS_INCLUDE.'/class/pdf.class.php';
 
 /**
  * @brief Strategie class for the print_ledger class
  * 
- */
-class Print_Ledger {
+*/
+class Print_Ledger extends PDF
+{
     protected  $filter_operation; // See Acc_Ledger_History::filter_operation
-    
+    private $ledger ; //!< concerned Ledger 
+    private $from ; //! integer parm_periode.p_id , start periode;
+    private $to ; //! integer parm_periode.p_id , end periode;
+    public function __construct(\Database $p_cn, 
+                                $orientation, 
+                                $unit, 
+                                $format,
+                                Acc_Ledger $p_ledger,
+                                $p_from,
+                                $p_to,
+                                $p_filter_operation)
+    {
+        parent::__construct($p_cn, $orientation, $unit, $format);
+        $this->ledger=$p_ledger;
+        $this->from=$p_from;
+        $this->to=$p_to;
+        $this->set_filter_operation($p_filter_operation);
+    }
+    public function get_ledger()
+    {
+        return $this->ledger;
+    }
+
+    public function get_from()
+    {
+        return $this->from;
+    }
+
+    public function get_to()
+    {
+        return $this->to;
+    }
+
+    public function set_ledger($ledger)
+    {
+        $this->ledger=$ledger;
+        return $this;
+    }
+
+    public function set_from($from)
+    {
+        $this->from=$from;
+        return $this;
+    }
+
+    public function set_to($to)
+    {
+        $this->to=$to;
+        return $this;
+    }
+    function get_filter_operation()
+    {
+        return $this->filter_operation;
+    }
+        /**
+     * Filter the operations , 
+     * @param string $filter_operation : all , paid, unpaid
+     * @return $this
+     * @throws Exception 5 , if filter invalid
+     */
     public function set_filter_operation($filter_operation)
     {
         if (in_array($filter_operation,['all','paid','unpaid']))
@@ -50,122 +105,83 @@ class Print_Ledger {
     /**
      * Create an object Print_Ledger* depending on $p_type_export ( 0 => 
accounting
      * 1-> one row per operation 2-> detail of item)
-     * @param type $cn
-     * @param type $p_type_export
-     * @param type $p_format_output CSV or PDF
+     * @param Database $cn
+     * @param char $p_type_export E(xtended) L(isting) A(ccounting) D(etail)
      * @param Acc_Ledger $ledger
      */
-    static function  factory(Database $cn, $p_type_export, $p_format_output, 
Acc_Ledger $p_ledger,$p_filter_operation) 
+    static function  factory(Database $cn, $p_type_export, Acc_Ledger 
$p_ledger,$p_from,$p_to,$p_filter_operation) 
     {
         /**
-         * For PDF output
+         * @Bug
+         * Strange PHP Bug when autoloader is not used , the require_once 
doesn't seems to
+         * work properly and does not include the files , except if you put 
them here
+         *
+         * if you put them on the top of this file,  export_ledger_pdf.php 
will include the files
+         * but not export_ledger_csv.php
          */
-        if ($p_format_output == 'PDF') {
-            switch ($p_type_export) {
-                case 'D':
-                    $own=new Noalyss_Parameter_Folder($cn);
-                    $jrn_type=$p_ledger->get_type();
-                    //---------------------------------------------
-                    // Detailled Printing (accounting )
-                    //---------------------------------------------
-                    if ($jrn_type=='ACH'||$jrn_type=='VEN')
-                    {
-                        if (
-                                ($jrn_type=='ACH'&&$cn->get_value('select 
count(qp_id) from quant_purchase')
-                                ==0)||
-                                ($jrn_type=='VEN'&&$cn->get_value('select 
count(qs_id) from quant_sold')
-                                ==0)
-                        )
-                        {
-                            $pdf=new Print_Ledger_Simple_without_vat($cn,
-                                    $p_ledger,$p_filter_operation);
-                            $pdf->set_error(_('Ce journal ne peut être imprimé 
en mode simple'));
-                            return $pdf;
-                        }
-                        if ($own->MY_TVA_USE=='Y')
-                        {
-                            $pdf=new Print_Ledger_Simple($cn, 
$p_ledger,$p_filter_operation);
-                            return $pdf;
-                        }
-                        if ($own->MY_TVA_USE=='N')
-                        {
-                            $pdf=new Print_Ledger_Simple_without_vat($cn,
-                                    $p_ledger,$p_filter_operation);
-                            return $pdf;
-                        }
-                    }
-                    elseif ($jrn_type=='FIN')
-                    {
-                        $pdf=new Print_Ledger_Financial($cn, $p_ledger);
-                        return $pdf;
-                    } else 
-                    {
-                        return new Print_Ledger_Detail($cn, $p_ledger);
-                    }
-                    break;
-
-                case 'L':
-                    
//----------------------------------------------------------------------
-                    // Simple Printing Purchase Ledger
-                    
//---------------------------------------------------------------------
-                    $own=new Noalyss_Parameter_Folder($cn);
-                    $jrn_type=$p_ledger->get_type();
+        require_once NOALYSS_INCLUDE.'/class/print_ledger_detail.class.php';
+        require_once NOALYSS_INCLUDE.'/class/print_ledger_simple.class.php';
+        require_once 
NOALYSS_INCLUDE.'/class/print_ledger_simple_without_vat.class.php';
+        require_once NOALYSS_INCLUDE.'/class/print_ledger_fin.class.php';
+        require_once NOALYSS_INCLUDE.'/class/print_ledger_misc.class.php';
+        require_once 
NOALYSS_INCLUDE.'/class/print_ledger_detail_item.class.php';
 
-
-                    if ($jrn_type=='ACH'||$jrn_type=='VEN')
-                    {
-                        if (
-                                ($jrn_type=='ACH'&&$cn->get_value('select 
count(qp_id) from quant_purchase')
-                                ==0)||
-                                ($jrn_type=='VEN'&&$cn->get_value('select 
count(qs_id) from quant_sold')
-                                ==0)
-                        )
-                        {
-                            $pdf=new Print_Ledger_Simple_without_vat($cn,
-                                    $p_ledger,$p_filter_operation);
-                            $pdf->set_error(_('Ce journal ne peut être imprimé 
en mode simple'));
-                            return $pdf;
-                        }
-                        if ($own->MY_TVA_USE=='Y')
-                        {
-                            $pdf=new Print_Ledger_Simple($cn, 
$p_ledger,$p_filter_operation);
-                            return $pdf;
-                        }
-                        if ($own->MY_TVA_USE=='N')
-                        {
-                            $pdf=new Print_Ledger_Simple_without_vat($cn,
-                                    $p_ledger,$p_filter_operation);
-                            return $pdf;
-                        }
-                    }
-
-                    if ($jrn_type=='FIN')
-                    {  
-                        $pdf=new Print_Ledger_Financial($cn, $p_ledger);
-                        return $pdf;
-                    }
-                    if ($jrn_type=='ODS'||$p_ledger->id==0)
+        /**
+         * For PDF output
+         */
+        switch ($p_type_export) {
+            case 'D':
+                $own=new Noalyss_Parameter_Folder($cn);
+                $jrn_type=$p_ledger->get_type();
+                //---------------------------------------------
+                // Detailled Printing (accounting )
+                //---------------------------------------------
+                if ($jrn_type=='ACH'||$jrn_type=='VEN')
+                {
+                    if (
+                            ($jrn_type=='ACH'&&$cn->get_value('select 
count(qp_id) from quant_purchase')
+                            ==0)||
+                            ($jrn_type=='VEN'&&$cn->get_value('select 
count(qs_id) from quant_sold')
+                            ==0)
+                    )
                     {
-                        $pdf=new Print_Ledger_Misc($cn, $p_ledger);
+                        $pdf=new Print_Ledger_Simple_without_vat($cn,
+                                $p_ledger,$p_from,$p_to,$p_filter_operation);
+                        $pdf->set_error(_('Ce journal ne peut être imprimé en 
mode simple'));
                         return $pdf;
                     }
-                    break;
-                case 'E':
-                    /**********************************************************
-                     * Print Detail Operation + Item
-                     * 
********************************************************* */
-                    $own=new Noalyss_Parameter_Folder($cn);
-                    $jrn_type=$p_ledger->get_type();
-                    if ($jrn_type=='FIN')
+                    if ($own->MY_TVA_USE=='Y')
                     {
-                        $pdf=new Print_Ledger_Detail($cn, $p_ledger);
+                        $pdf=new Print_Ledger_Simple($cn, 
$p_ledger,$p_from,$p_to,$p_filter_operation);
                         return $pdf;
                     }
-                    if ($jrn_type=='ODS'||$p_ledger->id==0)
+                    if ($own->MY_TVA_USE=='N')
                     {
-                        $pdf=new Print_Ledger_Detail($cn, $p_ledger);
+                        $pdf=new Print_Ledger_Simple_without_vat($cn,
+                                $p_ledger,$p_from,$p_to,$p_filter_operation);
                         return $pdf;
                     }
+                }
+                elseif ($jrn_type=='FIN')
+                {
+                    $pdf=new Print_Ledger_Financial($cn, 
$p_ledger,$p_from,$p_to);
+                    return $pdf;
+                } else 
+                {
+                    return new Print_Ledger_Detail($cn, 
$p_ledger,$p_from,$p_to);
+                }
+                break;
+
+            case 'L':
+                
//----------------------------------------------------------------------
+                // Simple Printing Purchase Ledger
+                
//---------------------------------------------------------------------
+                $own=new Noalyss_Parameter_Folder($cn);
+                $jrn_type=$p_ledger->get_type();
+
+
+                if ($jrn_type=='ACH'||$jrn_type=='VEN')
+                {
                     if (
                             ($jrn_type=='ACH'&&$cn->get_value('select 
count(qp_id) from quant_purchase')
                             ==0)||
@@ -173,21 +189,69 @@ class Print_Ledger {
                             ==0)
                     )
                     {
-                        $pdf=new Print_Ledger_Simple_without_vat($cn, 
$p_ledger,$p_filter_operation);
-                        $pdf->set_error('Ce journal ne peut être imprimé en 
mode simple');
+                        $pdf=new Print_Ledger_Simple_without_vat($cn,
+                                $p_ledger,$p_from,$p_to,$p_filter_operation);
+                        $pdf->set_error(_('Ce journal ne peut être imprimé en 
mode simple'));
                         return $pdf;
                     }
-                    $pdf=new Print_Ledger_Detail_Item($cn, 
$p_ledger,$p_filter_operation);
+                    if ($own->MY_TVA_USE=='Y')
+                    {
+                        $pdf=new Print_Ledger_Simple($cn, 
$p_ledger,$p_from,$p_to,$p_filter_operation);
+                        return $pdf;
+                    }
+                    if ($own->MY_TVA_USE=='N')
+                    {
+                        $pdf=new Print_Ledger_Simple_without_vat($cn,
+                                $p_ledger,$p_from,$p_to,$p_filter_operation);
+                        return $pdf;
+                    }
+                }
+
+                if ($jrn_type=='FIN')
+                {  
+                    $pdf=new Print_Ledger_Financial($cn, 
$p_ledger,$p_from,$p_to);
+                    return $pdf;
+                }
+                $pdf=new Print_Ledger_Misc($cn, $p_ledger,$p_from,$p_to);
+                return $pdf;
+                break;
+            case 'E':
+                /**********************************************************
+                 * Print Detail Operation + Item
+                 * ********************************************************* */
+                $own=new Noalyss_Parameter_Folder($cn);
+                $jrn_type=$p_ledger->get_type();
+                if ($jrn_type=='FIN')
+                {
+                    $pdf=new Print_Ledger_Detail($cn, $p_ledger,$p_from,$p_to);
                     return $pdf;
-                case 'A':
-                    
/***********************************************************
-                     * Accounting
-                     */
-                    $pdf=new Print_Ledger_Detail($cn, $p_ledger);
+                }
+                if ($jrn_type=='ODS'||$p_ledger->id==0)
+                {
+                    $pdf=new Print_Ledger_Detail($cn, $p_ledger,$p_from,$p_to);
                     return $pdf;
-                    break;
-            } // end switch
-        } // end $p_format == PDF
+                }
+                if (
+                        ($jrn_type=='ACH'&&$cn->get_value('select count(qp_id) 
from quant_purchase')
+                        ==0)||
+                        ($jrn_type=='VEN'&&$cn->get_value('select count(qs_id) 
from quant_sold')
+                        ==0)
+                )
+                {
+                    $pdf=new Print_Ledger_Simple_without_vat($cn, 
$p_ledger,$p_from,$p_to,$p_filter_operation);
+                    $pdf->set_error('Ce journal ne peut être imprimé en mode 
simple');
+                    return $pdf;
+                }
+                $pdf=new Print_Ledger_Detail_Item($cn, 
$p_ledger,$p_from,$p_to,$p_filter_operation);
+                return $pdf;
+            case 'A':
+                /***********************************************************
+                 * Accounting
+                 */
+                $pdf=new Print_Ledger_Detail($cn, $p_ledger,$p_from,$p_to);
+                return $pdf;
+                break;
+        } // end switch
     }
 
 // end function
@@ -246,7 +310,28 @@ class Print_Ledger {
         }
         return $a;
     }
-
+    /**
+     * Build a SQL clause to filter operation depending if they are paid, 
unpaid or no filter
+     * @return string SQL Clause
+     */
+    protected function build_filter_operation()
+    {
+        switch ($this->get_filter_operation())
+        {
+            case 'all':
+                $sql_filter="";
+                break;
+            case 'paid':
+                $sql_filter=" and (jr_date_paid is not null or  jr_rapt 
='paid' ) ";
+                break;
+            case 'unpaid':
+                $sql_filter=" and (jr_date_paid  is null and 
coalesce(jr_rapt,'x') <> 'paid' ) ";
+                break;
+            default:
+                throw new Exception(_("Filtre invalide", 5));
+        }
+        return $sql_filter;
+    }
 }
 
 ?>
diff --git a/include/class/print_ledger_detail.class.php 
b/include/class/print_ledger_detail.class.php
index 2c59ecf..baa7e8f 100644
--- a/include/class/print_ledger_detail.class.php
+++ b/include/class/print_ledger_detail.class.php
@@ -23,19 +23,16 @@
  * \brief this class extends PDF and let you export the detailled printing
  *  of any ledgers
  */
-require_once NOALYSS_INCLUDE.'/class/pdf_land.class.php';
+require_once NOALYSS_INCLUDE.'/class/print_ledger.class.php';
 
-class Print_Ledger_Detail extends PDF
+
+class Print_Ledger_Detail extends Print_Ledger
 {
-    public function __construct ($p_cn = null, Acc_Ledger $ledger)
+    public function __construct (Database $p_cn , Acc_Ledger 
$ledger,$p_from,$p_to)
     {
 
-        if($p_cn == null) die("No database connection. Abort.");
+        parent::__construct($p_cn,'L', 'mm', 'A4',$ledger,$p_from,$p_to,'all');
         
-        parent::__construct($p_cn,'L', 'mm', 'A4');
-        $this->ledger=$ledger;
-        date_default_timezone_set ('Europe/Paris');
-
     }
 
     function setDossierInfo($dossier = "n/a")
@@ -73,7 +70,7 @@ class Print_Ledger_Detail extends PDF
         $rap_deb=0;
         $rap_cred=0;
         // take all operations from jrn
-        
$array=$this->ledger->get_operation($_GET['from_periode'],$_GET['to_periode']);
+        
$array=$this->get_ledger()->get_operation($this->get_from(),$this->get_to());
 
         $this->SetFont('DejaVu','BI',7);
         $this->write_cell(215,7,'report Débit',0,0,'R');
diff --git a/include/class/print_ledger_detail_item.class.php 
b/include/class/print_ledger_detail_item.class.php
index 682c245..c9fca66 100644
--- a/include/class/print_ledger_detail_item.class.php
+++ b/include/class/print_ledger_detail_item.class.php
@@ -25,19 +25,15 @@
  */
 require_once NOALYSS_INCLUDE.'/class/acc_ledger_sold.class.php';
 require_once NOALYSS_INCLUDE.'/class/acc_ledger_purchase.class.php';
-require_once NOALYSS_INCLUDE.'/class/pdf_land.class.php';
+require_once NOALYSS_INCLUDE.'/class/print_ledger.class.php';
 
-class Print_Ledger_Detail_Item extends PDFLand
+class Print_Ledger_Detail_Item extends Print_Ledger
 {
-    public function __construct (Database $p_cn,Acc_Ledger 
$p_jrn,$p_filter_operation)
+    public function __construct (Database $p_cn,Acc_Ledger 
$p_jrn,$p_from,$p_to,$p_filter_operation)
     {
 
-        if($p_cn == null) die("No database connection. Abort.");
-
-        parent::__construct($p_cn,'L', 'mm', 'A4');
-        $this->ledger=$p_jrn;
+        parent::__construct($p_cn,'L', 'mm', 
'A4',$p_jrn,$p_from,$p_to,$p_filter_operation);
         $this->show_col=true;
-        $this->filter_operation=$p_filter_operation;
     }
 
     function setDossierInfo($dossier = "n/a")
@@ -77,7 +73,7 @@ class Print_Ledger_Detail_Item extends PDFLand
     {
         $this->Ln(2);
         $this->SetFont('Arial', 'I', 8);
-        $this->Cell(50,8,' Journal '.$this->ledger->get_name(),0,0,'C');
+        $this->Cell(50,8,' Journal '.$this->get_ledger()->get_name(),0,0,'C');
         //Arial italic 8
         //Page number
         $this->Cell(30,8,'Date '.$this->date." - Page 
".$this->PageNo().'/{nb}',0,0,'L');
@@ -92,18 +88,17 @@ class Print_Ledger_Detail_Item extends PDFLand
     function export()
     {
       bcscale(2);
-      $jrn_type=$this->ledger->get_type();
-      $http=new HttpInput();
+      $jrn_type=$this->get_ledger()->get_type();
 
       switch ($jrn_type)
       {
           case 'VEN':
-              $ledger=new Acc_Ledger_Sold($this->cn, 
$this->ledger->jrn_def_id);
-              
$ret_detail=$ledger->get_detail_sale($http->get('from_periode','number'),$http->get('to_periode','number'),
 $this->filter_operation);
+              $ledger=new Acc_Ledger_Sold($this->cn, 
$this->get_ledger()->jrn_def_id);
+              
$ret_detail=$ledger->get_detail_sale($this->get_from(),$this->get_to(), 
$this->filter_operation);
               break;
           case 'ACH':
-                $ledger=new Acc_Ledger_Purchase($this->cn, 
$this->ledger->jrn_def_id);
-                
$ret_detail=$ledger->get_detail_purchase($http->get('from_periode','number'),$http->get('to_periode','number'),$this->filter_operation);
+                $ledger=new Acc_Ledger_Purchase($this->cn, 
$this->get_ledger()->jrn_def_id);
+                
$ret_detail=$ledger->get_detail_purchase($this->get_from(),$this->get_to(),$this->filter_operation);
               break;
           default:
               die (__FILE__.":".__LINE__.'Journal invalide');
@@ -111,7 +106,7 @@ class Print_Ledger_Detail_Item extends PDFLand
       }
         if ( $ret_detail == null ) return;
         
-        $prepared_query=new Prepared_Query($this->ledger->db);
+        $prepared_query=new Prepared_Query($this->cn);
         $prepared_query->prepare_reconcile_date();
 
         $nb=Database::num_row($ret_detail);
@@ -141,7 +136,7 @@ class Print_Ledger_Detail_Item extends PDFLand
                 $this->line_new(6);
                 // Payment info
                 // Prepare the query for reconcile date
-                $ret_reconcile=$this->ledger->db->execute('reconcile_date', 
array($row['jr_id']));
+                $ret_reconcile=$this->cn->execute('reconcile_date', 
array($row['jr_id']));
                 $max=Database::num_row($ret_reconcile);
                 for ($e=0; $e<$max; $e++)
                 {
diff --git a/include/class/print_ledger_fin.class.php 
b/include/class/print_ledger_fin.class.php
index 3fa367f..da9eadf 100644
--- a/include/class/print_ledger_fin.class.php
+++ b/include/class/print_ledger_fin.class.php
@@ -22,16 +22,16 @@
 /*!\file
  * \brief print a listing of financial
  */
-require_once NOALYSS_INCLUDE.'/class/pdf.class.php';
-class Print_Ledger_Financial extends PDF
+require_once NOALYSS_INCLUDE.'/class/print_ledger.class.php';
+
+class Print_Ledger_Financial extends Print_Ledger
 {
     private $rap_amount; /* amount from begining exercice */
     private $tp_amount; /* amount total page */
     
-    function __construct($p_cn,  Acc_Ledger $p_jrn)
+    function __construct(Database $p_cn,  Acc_Ledger $p_jrn,$p_from,$p_to)
     {
-        parent::__construct($p_cn,'P','mm','A4');
-        $this->ledger=$p_jrn;
+        parent::__construct($p_cn,'P','mm','A4',$p_jrn,$p_from,$p_to,'all');
         $this->jrn_type=$p_jrn->get_type();
         
         // report from begin exercice
@@ -40,7 +40,7 @@ class Print_Ledger_Financial extends PDF
         // total page
         $this->tp_amount=0;
         
-        $amount=$this->ledger->previous_amount($_GET['from_periode']);
+        $amount=$this->get_ledger()->previous_amount($this->get_from());
         $this->rap_amount=$amount['amount'];
     }
     function Header()
@@ -92,11 +92,13 @@ class Print_Ledger_Financial extends PDF
      */
     function export()
     {
-        $a_jrn=$this->ledger->get_operation($_GET['from_periode'],
-                                            $_GET['to_periode']);
+        $ledger=$this->get_ledger();
+        $a_jrn=$ledger->get_operation($this->get_from(),$this->get_to());
+        
         $this->SetFont('DejaVu', '', 6);
         if ( $a_jrn == null ) return;
         bcscale(2);
+        
         for ( $i=0;$i<count($a_jrn);$i++)
         {
             $row=$a_jrn[$i];
@@ -104,7 +106,7 @@ class Print_Ledger_Financial extends PDF
             $this->write_cell(10,5,$row['date_fmt']);
             $this->write_cell(15,5,$row['internal']);
 
-            $name=$this->ledger->get_tiers($this->jrn_type,$row['id']);
+            $name=$ledger->get_tiers($this->jrn_type,$row['id']);
             $this->write_cell(40,5,$name,0,'L');
 
 
diff --git a/include/class/print_ledger_misc.class.php 
b/include/class/print_ledger_misc.class.php
index 037f537..726e375 100644
--- a/include/class/print_ledger_misc.class.php
+++ b/include/class/print_ledger_misc.class.php
@@ -22,14 +22,13 @@
 /*!\file
  * \brief print a listing of financial
  */
-require_once NOALYSS_INCLUDE.'/class/pdf.class.php';
-class Print_Ledger_Misc extends PDF
+require_once NOALYSS_INCLUDE.'/class/print_ledger.class.php';
+
+class Print_Ledger_Misc extends Print_Ledger
 {
-    function __construct($p_cn,$p_jrn)
+    function __construct(Database $p_cn,$p_jrn,$p_from,$p_to)
     {
-        parent::__construct($p_cn,'P','mm','A4');
-        $this->ledger=$p_jrn;
-        $this->jrn_type=$p_jrn->get_type();
+        parent::__construct($p_cn,'P','mm','A4',$p_jrn,$p_from,$p_to,"all");
     }
     function Header()
     {
@@ -70,10 +69,10 @@ class Print_Ledger_Misc extends PDF
      */
     function export()
     {
-        $a_jrn=$this->ledger->get_rowSimple($_GET['from_periode'],
-                                            $_GET['to_periode']);
+        
$a_jrn=$this->get_ledger()->get_rowSimple($this->get_from(),$this->get_to());
         $this->SetFont('DejaVu', '', 6);
         if ( $a_jrn == null ) return;
+        $ledger=$this->get_ledger();
         for ( $i=0;$i<count($a_jrn);$i++)
         {
             $row=$a_jrn[$i];
@@ -82,7 +81,7 @@ class Print_Ledger_Misc extends PDF
             $this->LongLine(30,5,$row['jr_pj_number']);
             $this->write_cell(20,5,$row['jr_internal']);
            $type=$this->cn->get_value("select jrn_def_type from jrn_def where 
jrn_def_id=$1",array($a_jrn[$i]['jr_def_id']));
-           
$other=mb_substr($this->ledger->get_tiers($type,$a_jrn[$i]['jr_id']),0,25);
+           
$other=mb_substr($ledger->get_tiers($type,$a_jrn[$i]['jr_id']),0,25);
            $this->LongLine(25,5,$other,0,'L');
             $positive=$row['montant'];
             $this->LongLine(80,5,$row['comment'],0,'L');
diff --git a/include/class/print_ledger_simple.class.php 
b/include/class/print_ledger_simple.class.php
index 26aa342..399a8a5 100644
--- a/include/class/print_ledger_simple.class.php
+++ b/include/class/print_ledger_simple.class.php
@@ -23,21 +23,17 @@
  * \brief this class extends PDF and let you export the detailled printing
  *  of any ledgers
  */
-require_once NOALYSS_INCLUDE.'/class/pdf.class.php';
+require_once NOALYSS_INCLUDE.'/class/print_ledger.class.php';
 require_once NOALYSS_INCLUDE.'/lib/http_input.class.php';
 
-class Print_Ledger_Simple extends PDF
+class Print_Ledger_Simple extends  \Print_Ledger
 {
-    public function __construct ($p_cn,  Acc_Ledger $p_jrn,$p_filter_operation)
+    public function __construct ($p_cn,  Acc_Ledger 
$p_jrn,$p_from,$p_to,$p_filter_operation)
     {
 
-        $http=new HttpInput();
-        $this->filter_operation=$p_filter_operation;
-        if($p_cn == null) die("No database connection. Abort.");
-
-        parent::__construct($p_cn,'L', 'mm', 'A4');
-        $this->ledger=$p_jrn;
-        $this->a_Tva=$this->ledger->existing_vat();
+        parent::__construct($p_cn,'L', 'mm', 
'A4',$p_jrn,$p_from,$p_to,$p_filter_operation);
+        
+        $this->a_Tva=$this->get_ledger()->existing_vat();
         foreach($this->a_Tva as $line_tva)
         {
             //initialize Amount TVA
@@ -51,8 +47,8 @@ class Print_Ledger_Simple extends PDF
          * get rappel to initialize amount rap_xx
          *the easiest way is to compute sum from quant_
          */
-        $from_periode=$http->get('from_periode',"number");
-        $this->previous=$this->ledger->previous_amount($from_periode);
+        $from_periode=$this->get_from();
+        $this->previous=$this->get_ledger()->previous_amount($from_periode);
 
         /* initialize the amount to report */
         foreach($this->previous['tva'] as $line_tva)
@@ -219,15 +215,14 @@ class Print_Ledger_Simple extends PDF
      */
     function export()
     {
-      bcscale(2);
-        $http=new HttpInput();
-
+        bcscale(2);
+        $ledger=$this->get_ledger();
         $ledger_history=Acc_Ledger_History::factory($this->cn, 
-                                        array($this->ledger->id), 
-                                        $http->get('from_periode','number'), 
-                                        $http->get('to_periode','number'), 
+                                        array($ledger->id), 
+                                        $this->get_from(), 
+                                        $this->get_to(), 
                                         'D', 
-                                        $this->filter_operation);
+                                        $this->get_filter_operation());
         $ledger_history->get_row();
         $a_jrn=$ledger_history->get_data();
 
@@ -237,7 +232,7 @@ class Print_Ledger_Simple extends PDF
         $flag_tva=(count($this->a_Tva) > 4)?true:false;
         
         // Prepare the query for reconcile date
-        $prepared_query=new Prepared_Query($this->ledger->db);
+        $prepared_query=new Prepared_Query($ledger->db);
         $prepared_query->prepare_reconcile_date();
         
         for ( $i=0;$i<count($a_jrn);$i++)
@@ -250,7 +245,7 @@ class Print_Ledger_Simple extends PDF
             }
 
             // retrieve info from ledger
-            $aAmountVat=$this->ledger->vat_operation($a_jrn[$i]['jr_grpt_id']);
+            $aAmountVat=$ledger->vat_operation($a_jrn[$i]['jr_grpt_id']);
 
             // put vat into array
             for ($f=0;$f<count($aAmountVat);$f++)
@@ -262,7 +257,7 @@ class Print_Ledger_Simple extends PDF
                 
             }
             $row=$a_jrn[$i];
-            
$ret_reconcile=$this->ledger->db->execute('reconcile_date',array($row['jr_id']));
+            
$ret_reconcile=$ledger->db->execute('reconcile_date',array($row['jr_id']));
             $this->LongLine(15,5,($row['jr_pj_number']),0);
             $this->write_cell(10,5,$row['str_date_short'],0,0);
             $this->write_cell(13,5,$row['jr_internal'],0,0);
@@ -274,7 +269,7 @@ class Print_Ledger_Simple extends PDF
             }
 
             /* get other amount (without vat, total vat included, private, ND 
*/
-            $other=$this->ledger->get_other_amount($a_jrn[$i]['jr_grpt_id']);
+            $other=$ledger->get_other_amount($a_jrn[$i]['jr_grpt_id']);
             
             $this->write_cell(15,5,nbm($other['price']),0,0,'R');
             
diff --git a/include/class/print_ledger_simple_without_vat.class.php 
b/include/class/print_ledger_simple_without_vat.class.php
index 751961c..bbc3c5f 100644
--- a/include/class/print_ledger_simple_without_vat.class.php
+++ b/include/class/print_ledger_simple_without_vat.class.php
@@ -23,18 +23,15 @@
  * \brief this class extends PDF and let you export the detailled printing
  *  of any ledgers
  */
-require_once NOALYSS_INCLUDE.'/class/pdf.class.php';
+require_once NOALYSS_INCLUDE.'/class/print_ledger.class.php';
 
-class Print_Ledger_Simple_Without_Vat extends PDF
+class Print_Ledger_Simple_Without_Vat extends Print_Ledger
 {
-    private $filter_operation;
-    public function __construct ($p_cn,$p_jrn,$p_filter_operation)
+    public function __construct 
($p_cn,$p_jrn,$p_from,$p_to,$p_filter_operation)
     {
 
-        if($p_cn == null) die("No database connection. Abort.");
 
-        parent::__construct($p_cn,'L', 'mm', 'A4');
-        $this->ledger=$p_jrn;
+        parent::__construct($p_cn,'L', 'mm', 
'A4',$p_jrn,$p_from,$p_to,$p_filter_operation);
         $this->jrn_type=$p_jrn->get_type();
         
//----------------------------------------------------------------------
         /* report
@@ -42,13 +39,12 @@ class Print_Ledger_Simple_Without_Vat extends PDF
          * get rappel to initialize amount rap_xx
          *the easiest way is to compute sum from quant_
          */
-        $this->previous=$this->ledger->previous_amount($_GET['from_periode']);
+        $this->previous=$this->get_ledger()->previous_amount($p_from);
 
 
         $this->rap_htva=$this->previous['price'];
         $this->rap_tvac=$this->previous['price'];
         $this->rap_priv=$this->previous['priv'];
-        $this->filter_operation=$p_filter_operation;
 
     }
 
@@ -142,21 +138,25 @@ class Print_Ledger_Simple_Without_Vat extends PDF
      */
     function export()
     {
-        $http=new HttpInput;
+        
         $ledger_history=Acc_Ledger_History::factory($this->cn, 
-                                                array($this->ledger->id), 
-                                                
$http->get('from_periode','number'), 
-                                                
$http->get('to_periode','number'), 
+                                                
array($this->get_ledger()->id), 
+                                                $this->get_from(), 
+                                                $this->get_to(), 
                                                 'D', 
-                                                $this->filter_operation);
-        $a_jrn=$ledger_history->get_row();
+                                                $this->get_filter_operation());
+        
+        $ledger_history->get_row();
+        $a_jrn=$ledger_history->get_data();
         
-        if ( $a_jrn == null ) return;
+        if ( empty($a_jrn ) ) return;
         
          // Prepare the query for reconcile date
         $prepared_query=new Prepared_Query($this->cn);
         $prepared_query->prepare_reconcile_date();
         
+        $ledger=$this->get_ledger();
+        
         for ( $i=0;$i<count($a_jrn);$i++)
         {
 
@@ -171,7 +171,7 @@ class Print_Ledger_Simple_Without_Vat extends PDF
             $this->LongLine(105,5,$row['jr_comment'],0,'L');
 
             /* get other amount (without vat, total vat included, private, ND 
*/
-            $other=$this->ledger->get_other_amount($a_jrn[$i]['jr_grpt_id']);
+            $other=$ledger->get_other_amount($a_jrn[$i]['jr_grpt_id']);
             $this->tp_htva+=$other['price'];
             $this->tp_priv+=$other['priv'];
             $this->rap_htva+=$other['price'];
@@ -184,7 +184,7 @@ class Print_Ledger_Simple_Without_Vat extends PDF
             }
 
             $this->write_cell(15,5,sprintf("%.2f",$other['price']),0,0,'R');
-            
$ret_reconcile=$this->cn->execute('reconcile_date',array($row['id']));
+            
$ret_reconcile=$this->cn->execute('reconcile_date',array($row['jr_id']));
             $max=Database::num_row($ret_reconcile);
             $str_payment="";
             if ($max > 0) {
diff --git a/include/export/export_ledger_csv.php 
b/include/export/export_ledger_csv.php
index 8249fc9..b18377b 100644
--- a/include/export/export_ledger_csv.php
+++ b/include/export/export_ledger_csv.php
@@ -28,19 +28,22 @@
  */
 if (!defined('ALLOWED'))
     die('Appel direct ne sont pas permis');
+
 include_once NOALYSS_INCLUDE."/lib/ac_common.php";
 require_once NOALYSS_INCLUDE.'/class/noalyss_parameter_folder.class.php';
 require_once NOALYSS_INCLUDE.'/class/acc_ledger_sold.class.php';
 require_once NOALYSS_INCLUDE.'/class/acc_ledger_purchase.class.php';
 require_once NOALYSS_INCLUDE.'/class/print_ledger.class.php';
-require_once NOALYSS_INCLUDE.'/class/dossier.class.php';
-$gDossier=dossier::id();
 
+
+require_once NOALYSS_INCLUDE.'/class/dossier.class.php';
 require_once NOALYSS_INCLUDE.'/class/database.class.php';
 require_once NOALYSS_INCLUDE.'/class/acc_ledger.class.php';
 require_once NOALYSS_INCLUDE.'/lib/noalyss_csv.class.php';
-
 require_once NOALYSS_INCLUDE.'/lib/http_input.class.php';
+
+
+$gDossier=dossier::id();
 $http=new HttpInput();
 
 $export=new Noalyss_Csv(_('journal'));
@@ -87,12 +90,13 @@ if ($get_jrn==0)
 {
     // find out all the available ledgers for the current user
     $a_jrn=Print_Ledger::available_ledger($get_from_periode);
+    $Jrn=new Acc_Ledger($cn,0);
 }
 else
 {
     $a_jrn=$get_jrn;
+    $Jrn=new Acc_Ledger($cn, $get_jrn);
 }
-$Jrn=new Acc_Ledger($cn, $get_jrn);
 
 $Jrn->get_name();
 $jrn_type=$Jrn->get_type();
diff --git a/include/export/export_ledger_pdf.php 
b/include/export/export_ledger_pdf.php
index 7cdbb18..9ed69aa 100644
--- a/include/export/export_ledger_pdf.php
+++ b/include/export/export_ledger_pdf.php
@@ -47,6 +47,8 @@ try
     $jrn_id=$http->get('jrn_id',"number");
     $p_simple=$http->get('p_simple',"string");
     $filter_operation=$http->get("operation_type");
+    $from=$http->get("from_periode","number");
+    $to=$http->get("to_periode","number");
     
 }
 catch (Exception $exc)
@@ -71,11 +73,10 @@ if ($jrn_id != 0 && $g_user->check_jrn($jrn_id) == 'X') {
 }
 
 $ret = "";
-
+if ( $jrn_id == 0 ) $Jrn->id=0;
 $jrn_type = $Jrn->get_type();
 
-$pdf = Print_Ledger::factory($cn, $p_simple, "PDF", $Jrn,$filter_operation);
-$pdf->set_filter_operation($filter_operation);
+$pdf = Print_Ledger::factory($cn, $p_simple, $Jrn,$from,$to,$filter_operation);
 $pdf->setDossierInfo($Jrn->jrn_def_name);
 $pdf->AliasNbPages();
 $pdf->AddPage();
diff --git a/unit-test/include/class/print_LedgerTest.php 
b/unit-test/include/class/print_LedgerTest.php
new file mode 100644
index 0000000..9286dc1
--- /dev/null
+++ b/unit-test/include/class/print_LedgerTest.php
@@ -0,0 +1,147 @@
+<?php
+
+use PHPUnit\Framework\TestCase;
+
+/*
+ *   This file is part of NOALYSS.
+ *
+ *   PhpCompta is free software; you can redistribute it and/or modify
+ *   it under the terms of the GNU General Public License as published by
+ *   the Free Software Foundation; either version 2 of the License, or
+ *   (at your option) any later version.
+ *
+ *   PhpCompta is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with PhpCompta; if not, write to the Free Software
+ *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+// Copyright (2002-2019) Author Dany De Bontridder <address@hidden>
+
+/**
+ * @file
+ * @brief concerne print_LedgerTest
+ * @coversDefaultClass Print_Ledger
+ */
+class print_LedgerTest extends TestCase
+{
+
+    /**
+     * @var 
+     */
+    protected $object;
+
+    /**
+     * Sets up the fixture, for example, opens a network connection.
+     * This method is called before a test is executed.
+     */
+    protected function setUp()
+    {
+        include 'global.php';
+        // Exercice 2018
+        $this->from=92;
+        $this->to=103;
+    }
+
+    /**
+     * Tears down the fixture, for example, closes a network connection.
+     * This method is called after a test is executed.
+     */
+    protected function tearDown()
+    {
+        
+    }
+    /**
+     * 
+     * @covers ::factory
+     */
+    function testFactory()
+    {
+        global $g_connection;
+        $ledger_sale=new Acc_Ledger_Sold($g_connection,2);
+        $p_from=$this->from;
+        $p_to=$this->to;
+        
+        // Check Sales
+        $ledger=\Print_Ledger::factory($g_connection,"D",  $ledger_sale, 
$p_from, $p_to, "paid");
+        $this->assertTrue($ledger instanceof Print_Ledger_Simple
+                ,"Sale Detail returns Print_Ledger_Simple");
+        
+        $ledger=\Print_Ledger::factory($g_connection,"L",  $ledger_sale, 
$p_from, $p_to, "paid");
+        $this->assertTrue($ledger instanceof Print_Ledger_Simple
+                ,"Sale Listing returns Print_Ledger_Simple");
+        
+        $ledger=\Print_Ledger::factory($g_connection,"E",  $ledger_sale, 
$p_from, $p_to, "paid");
+        $this->assertTrue($ledger instanceof Print_Ledger_Detail_Item
+                ,"Sale Extended returns Print_Ledger_Detail_Item");
+        
+        $ledger=\Print_Ledger::factory($g_connection,"A",  $ledger_sale, 
$p_from, $p_to, "paid");
+        $this->assertTrue($ledger instanceof Print_Ledger_Detail,
+                "Sale Accounting returns Print_Ledger_Detail");
+        
+        // Check Purchase
+        $ledger_purchase=new Acc_Ledger_Purchase($g_connection,3);
+        $ledger=\Print_Ledger::factory($g_connection,"D",  $ledger_purchase, 
$p_from, $p_to, "paid");
+        $this->assertTrue($ledger instanceof Print_Ledger_Simple
+                ,"Purchase Detail returns Print_Ledger_Simple");
+        
+        $ledger=\Print_Ledger::factory($g_connection,"L",  $ledger_purchase, 
$p_from, $p_to, "paid");
+        $this->assertTrue($ledger instanceof Print_Ledger_Simple
+                ,"Purchase Listing returns Print_Ledger_Simple");
+        
+        $ledger=\Print_Ledger::factory($g_connection,"E",  $ledger_purchase, 
$p_from, $p_to, "paid");
+        $this->assertTrue($ledger instanceof Print_Ledger_Detail_Item
+                ,"Purchase Extended returns Print_Ledger_Detail_Item");
+        
+        $ledger=\Print_Ledger::factory($g_connection,"A",  $ledger_purchase, 
$p_from, $p_to, "paid");
+        $this->assertTrue($ledger instanceof Print_Ledger_Detail
+                ,"Purchase Accounting returns Print_Ledger_Detail");
+        
+        // Check Misc
+        $ledger_misc=new Acc_Ledger($g_connection,4);
+        $ledger=\Print_Ledger::factory($g_connection,"D",  $ledger_misc, 
$p_from, $p_to, "paid");
+        $this->assertTrue($ledger instanceof Print_Ledger_Detail
+                 ,"Misc. Detail returns Print_Ledger_Detail");
+        
+        $ledger=\Print_Ledger::factory($g_connection,"L",  $ledger_misc, 
$p_from, $p_to, "paid");
+        $this->assertTrue($ledger instanceof Print_Ledger_Misc
+                ,"Misc. Listing returns Print_Ledger_Misc");
+        
+        $ledger=\Print_Ledger::factory($g_connection,"E",  $ledger_misc, 
$p_from, $p_to, "paid");
+        $this->assertTrue($ledger instanceof Print_Ledger_Detail
+                ,"Misc. Extended returns Print_Ledger_Detail");
+        
+        $ledger=\Print_Ledger::factory($g_connection,"A",  $ledger_misc, 
$p_from, $p_to, "paid");
+        $this->assertTrue($ledger instanceof Print_Ledger_Detail
+                ,"Misc. Accounting returns Print_Ledger_Detail");
+        
+        // Financial
+        $ledger_fin=new Acc_Ledger_Fin($g_connection,1);
+        $ledger=\Print_Ledger::factory($g_connection,"D",  $ledger_fin, 
$p_from, $p_to, "paid");
+        $this->assertTrue($ledger instanceof Print_Ledger_Financial
+                ,"Fin. Detail returns Print_Ledger_Financial");
+        
+        $ledger=\Print_Ledger::factory($g_connection,"L",  $ledger_fin, 
$p_from, $p_to, "paid");
+        $this->assertTrue($ledger instanceof Print_Ledger_Financial
+                ,"Fin. Detail returns Print_Ledger_Financial");
+        
+        $ledger=\Print_Ledger::factory($g_connection,"E",  $ledger_fin, 
$p_from, $p_to, "paid");
+        $this->assertTrue($ledger instanceof Print_Ledger_Detail
+                ,"Fin. Detail returns Print_Ledger_Financial");
+        
+        $ledger=\Print_Ledger::factory($g_connection,"A",  $ledger_fin, 
$p_from, $p_to, "paid");
+        $this->assertTrue($ledger instanceof Print_Ledger_Detail
+                ,"Fin. Detail returns Print_Ledger_Detail");
+        
+    }
+    //@covers \Print_Ledger::available_ledger
+    function test_availableLedger()
+    {
+        $a_jrn=\Print_Ledger::available_ledger(94);
+        $this->assertEquals(6,count($a_jrn),"Number of available ledger 
correct");
+    }
+
+}
diff --git a/unit-test/include/class/print_ledger_detail.classTest.php 
b/unit-test/include/class/print_ledger_detail.classTest.php
new file mode 100644
index 0000000..769e486
--- /dev/null
+++ b/unit-test/include/class/print_ledger_detail.classTest.php
@@ -0,0 +1,81 @@
+<?php
+
+use PHPUnit\Framework\TestCase;
+
+/*
+ *   This file is part of NOALYSS.
+ *
+ *   PhpCompta is free software; you can redistribute it and/or modify
+ *   it under the terms of the GNU General Public License as published by
+ *   the Free Software Foundation; either version 2 of the License, or
+ *   (at your option) any later version.
+ *
+ *   PhpCompta is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with PhpCompta; if not, write to the Free Software
+ *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+// Copyright (2002-2019) Author Dany De Bontridder <address@hidden>
+
+/**
+ * @file
+ * @brief concerne print_ledger_detail
+ * @coversDefaultClass Print_Ledger_Detail
+ */
+include_once 'global.php';
+
+class Print_Ledger_DetailTest extends TestCase
+{
+
+    /**
+     * @var 
+     */
+    protected $object;
+
+    /**
+     * Sets up the fixture, for example, opens a network connection.
+     * This method is called before a test is executed.
+     */
+    protected function setUp()
+    {
+        $this->from=92;
+        $this->to=103;
+    }
+
+    /**
+     * Tears down the fixture, for example, closes a network connection.
+     * This method is called after a test is executed.
+     */
+    protected function tearDown()
+    {
+        
+        
+
+    }
+    function test_export()
+    {
+         global $g_connection;
+        $p_from=$this->from;
+        $p_to=$this->to;
+        
+        // Financial
+        $ledger_fin=new Acc_Ledger($g_connection,4);
+        $ledger=\Print_Ledger::factory($g_connection,"D",  $ledger_fin, 
$p_from, $p_to, "paid");
+        $this->assertTrue($ledger instanceof Print_Ledger_Detail
+                ,"Misc. Detail returns Print_Ledger");
+       
+        $ledger->setDossierInfo($ledger_fin->jrn_def_name);
+        $ledger->AliasNbPages();
+        $ledger->AddPage();
+        $ledger->SetAuthor('NOALYSS');
+        $ledger->setTitle(_("Journal"), true);
+        $ledger->export();
+        $ledger->Output(__DIR__."/file/misc-detail.pdf","F");
+        $this->assertFileExists(__DIR__."/file/misc-detail.pdf");
+    }
+
+}
diff --git a/unit-test/include/class/print_ledger_detail_item.classTest.php 
b/unit-test/include/class/print_ledger_detail_item.classTest.php
new file mode 100644
index 0000000..56cbd24
--- /dev/null
+++ b/unit-test/include/class/print_ledger_detail_item.classTest.php
@@ -0,0 +1,162 @@
+<?php
+
+use PHPUnit\Framework\TestCase;
+
+/*
+ *   This file is part of NOALYSS.
+ *
+ *   PhpCompta is free software; you can redistribute it and/or modify
+ *   it under the terms of the GNU General Public License as published by
+ *   the Free Software Foundation; either version 2 of the License, or
+ *   (at your option) any later version.
+ *
+ *   PhpCompta is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with PhpCompta; if not, write to the Free Software
+ *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+// Copyright (2002-2019) Author Dany De Bontridder <address@hidden>
+
+/**
+ * @file
+ * @brief concerne print_ledger_detail_item.classTest
+ * @coversDefaultClass print_ledger_detail_item
+ */
+class Print_Ledger_Detail_ItemTest extends TestCase
+{
+
+    /**
+     * @var 
+     */
+    protected $object;
+
+    /**
+     * Sets up the fixture, for example, opens a network connection.
+     * This method is called before a test is executed.
+     */
+    protected function setUp()
+    {
+        include 'global.php';
+        $this->from=92;
+        $this->to=103;
+    }
+
+    /**
+     * Tears down the fixture, for example, closes a network connection.
+     * This method is called after a test is executed.
+     */
+    protected function tearDown()
+    {
+        
+    }
+
+    public function test_Export()
+    {
+        global $g_connection;
+        $p_from=$this->from;
+        $p_to=$this->to;
+        
//-------------------------------------------------------------------------------------------------------------
+        // Purchase
+        
//-------------------------------------------------------------------------------------------------------------
+
+        $ledger_purchase=new Acc_Ledger_Purchase($g_connection,3);
+
+        // Paid 
+        //------------
+        $ledger=\Print_Ledger::factory($g_connection, "E", $ledger_purchase, 
$p_from, $p_to, "paid");
+        $this->assertTrue($ledger instanceof Print_Ledger_Detail_Item
+                , "Purchase Extended returns Print_Ledger_Detail_Item");
+        
+        $ledger->setDossierInfo($ledger_purchase->jrn_def_name);
+        $ledger->AliasNbPages();
+        $ledger->AddPage();
+        $ledger->SetAuthor('NOALYSS');
+        $ledger->setTitle(_("Journal Achat Payé"), true);
+        $ledger->export();
+        
$ledger->Output(__DIR__."/file/print_ledger_detail_purchase_paid.pdf","F");
+
+        // Unpaid
+        //------------
+        $ledger=\Print_Ledger::factory($g_connection, "E", $ledger_purchase, 
$p_from, $p_to, "unpaid");
+        $this->assertTrue($ledger instanceof Print_Ledger_Detail_Item
+                , "Purchase Extended returns Print_Ledger_Detail_Item");
+        
+        $ledger->setDossierInfo($ledger_purchase->jrn_def_name);
+        $ledger->AliasNbPages();
+        $ledger->AddPage();
+        $ledger->SetAuthor('NOALYSS');
+        $ledger->setTitle(_("Journal Non Payé"), true);
+        $ledger->export();
+        
$ledger->Output(__DIR__."/file/print_ledger_detail_purchase_unpaid.pdf","F");
+        
$this->assertFileExists(__DIR__."/file/print_ledger_detail_purchase_unpaid.pdf");
+        
+        // All
+        //------------
+        $ledger=\Print_Ledger::factory($g_connection, "E", $ledger_purchase, 
$p_from, $p_to, "all");
+        $this->assertTrue($ledger instanceof Print_Ledger_Detail_Item
+                , "Purchase Extended returns Print_Ledger_Detail_Item");
+        
+        $ledger->setDossierInfo($ledger_purchase->jrn_def_name);
+        $ledger->AliasNbPages();
+        $ledger->AddPage();
+        $ledger->SetAuthor('NOALYSS');
+        $ledger->setTitle(_("Journal Achat tous"), true);
+        $ledger->export();
+        
$ledger->Output(__DIR__."/file/print_ledger_detail_purchase_all.pdf","F");
+        
$this->assertFileExists(__DIR__."/file/print_ledger_detail_purchase_all.pdf");
+        
+        
//-------------------------------------------------------------------------------------------------------------
+        // Sale
+        
//-------------------------------------------------------------------------------------------------------------
+        $ledger_sale=new Acc_Ledger_Sold($g_connection,2);
+
+        // Paid
+        //-----------------
+        $ledger=\Print_Ledger::factory($g_connection, "E", $ledger_sale, 
$p_from, $p_to, "paid");
+        $this->assertTrue($ledger instanceof Print_Ledger_Detail_Item
+                , "Purchase Extended returns Print_Ledger_Detail_Item");
+        
+        $ledger->setDossierInfo($ledger_sale->jrn_def_name);
+        $ledger->AliasNbPages();
+        $ledger->AddPage();
+        $ledger->SetAuthor('NOALYSS');
+        $ledger->setTitle(_("Journal Vente Payé"), true);
+        $ledger->export();
+        $ledger->Output(__DIR__."/file/print_ledger_detail_sale_paid.pdf","F");
+
+        // Unpaid
+        //-----------------
+        $ledger=\Print_Ledger::factory($g_connection, "E", $ledger_sale, 
$p_from, $p_to, "unpaid");
+        $this->assertTrue($ledger instanceof Print_Ledger_Detail_Item
+                , "Purchase Extended returns Print_Ledger_Detail_Item");
+        
+        $ledger->setDossierInfo($ledger_sale->jrn_def_name);
+        $ledger->AliasNbPages();
+        $ledger->AddPage();
+        $ledger->SetAuthor('NOALYSS');
+        $ledger->setTitle(_("Journal Non Payé"), true);
+        $ledger->export();
+        
$ledger->Output(__DIR__."/file/print_ledger_detail_sale_unpaid.pdf","F");
+        
$this->assertFileExists(__DIR__."/file/print_ledger_detail_sale_unpaid.pdf");
+        
+        // All
+        //-----------------
+        $ledger=\Print_Ledger::factory($g_connection, "E", $ledger_sale, 
$p_from, $p_to, "all");
+        $this->assertTrue($ledger instanceof Print_Ledger_Detail_Item
+                , "Purchase Extended returns Print_Ledger_Detail_Item");
+        
+        $ledger->setDossierInfo($ledger_sale->jrn_def_name);
+        $ledger->AliasNbPages();
+        $ledger->AddPage();
+        $ledger->SetAuthor('NOALYSS');
+        $ledger->setTitle(_("Journal Vente tous"), true);
+        $ledger->export();
+        $ledger->Output(__DIR__."/file/print_ledger_detail_sale_all.pdf","F");
+        
$this->assertFileExists(__DIR__."/file/print_ledger_detail_sale_all.pdf");
+    }
+
+}
diff --git a/unit-test/include/class/print_ledger_fin.classTest.php 
b/unit-test/include/class/print_ledger_fin.classTest.php
new file mode 100644
index 0000000..8c63778
--- /dev/null
+++ b/unit-test/include/class/print_ledger_fin.classTest.php
@@ -0,0 +1,111 @@
+<?php
+
+use PHPUnit\Framework\TestCase;
+
+/*
+ *   This file is part of NOALYSS.
+ *
+ *   PhpCompta is free software; you can redistribute it and/or modify
+ *   it under the terms of the GNU General Public License as published by
+ *   the Free Software Foundation; either version 2 of the License, or
+ *   (at your option) any later version.
+ *
+ *   PhpCompta is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with PhpCompta; if not, write to the Free Software
+ *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+// Copyright (2002-2019) Author Dany De Bontridder <address@hidden>
+
+/**
+ * @file
+ * @brief concerne print_ledger_fin.classTest
+ * @coversDefaultClass Print_Ledger_Fin
+ */
+class Print_Ledger_FinTest extends TestCase
+{
+
+    /**
+     * @var 
+     */
+    protected $object;
+
+    /**
+     * Sets up the fixture, for example, opens a network connection.
+     * This method is called before a test is executed.
+     */
+    protected function setUp()
+    {
+        include 'global.php';
+        $this->from=92;
+        $this->to=103;
+    }
+
+    /**
+     * Tears down the fixture, for example, closes a network connection.
+     * This method is called after a test is executed.
+     */
+    protected function tearDown()
+    {
+        
+    }
+    public function test_Export()
+    {
+        global $g_connection;
+        $p_from=$this->from;
+        $p_to=$this->to;
+        
+        // Financial
+        $ledger_fin=new Acc_Ledger_Fin($g_connection,1);
+        $ledger=\Print_Ledger::factory($g_connection,"D",  $ledger_fin, 
$p_from, $p_to, "paid");
+        $this->assertTrue($ledger instanceof Print_Ledger_Financial
+                ,"Fin. Detail returns Print_Ledger_Financial");
+       
+        $ledger->setDossierInfo($ledger_fin->jrn_def_name);
+        $ledger->AliasNbPages();
+        $ledger->AddPage();
+        $ledger->SetAuthor('NOALYSS');
+        $ledger->setTitle(_("Journal"), true);
+        $ledger->export();
+        $ledger->Output(__DIR__."/file/financial-detail.pdf","F");
+        
+        $ledger=\Print_Ledger::factory($g_connection,"L",  $ledger_fin, 
$p_from, $p_to, "paid");
+        $this->assertTrue($ledger instanceof Print_Ledger_Financial
+                ,"Fin. Detail returns Print_Ledger_Financial");
+         $ledger->setDossierInfo($ledger_fin->jrn_def_name);
+        $ledger->AliasNbPages();
+        $ledger->AddPage();
+        $ledger->SetAuthor('NOALYSS');
+        $ledger->setTitle(_("Journal"), true);
+        $ledger->export();
+        $ledger->Output(__DIR__."/file/financial-listing.pdf","F");
+
+        
+        $ledger=\Print_Ledger::factory($g_connection,"E",  $ledger_fin, 
$p_from, $p_to, "paid");
+        $this->assertTrue($ledger instanceof Print_Ledger_Detail
+                ,"Fin. Detail returns Print_Ledger_Financial");
+         $ledger->setDossierInfo($ledger_fin->jrn_def_name);
+        $ledger->AliasNbPages();
+        $ledger->AddPage();
+        $ledger->SetAuthor('NOALYSS');
+        $ledger->setTitle(_("Journal"), true);
+        $ledger->export();
+        $ledger->Output(__DIR__."/file/financial-extended.pdf","F");
+        
+        $ledger=\Print_Ledger::factory($g_connection,"A",  $ledger_fin, 
$p_from, $p_to, "paid");
+        $this->assertTrue($ledger instanceof Print_Ledger_Detail
+                ,"Fin. Detail returns Print_Ledger_Detail");
+         $ledger->setDossierInfo($ledger_fin->jrn_def_name);
+        $ledger->AliasNbPages();
+        $ledger->AddPage();
+        $ledger->SetAuthor('NOALYSS');
+        $ledger->setTitle(_("Journal"), true);
+        $ledger->export();
+        $ledger->Output(__DIR__."/file/financial-accounting.pdf","F");
+    }
+
+}
diff --git a/unit-test/include/class/print_ledger_misc.classTest.php 
b/unit-test/include/class/print_ledger_misc.classTest.php
new file mode 100644
index 0000000..938ca76
--- /dev/null
+++ b/unit-test/include/class/print_ledger_misc.classTest.php
@@ -0,0 +1,89 @@
+<?php
+
+use PHPUnit\Framework\TestCase;
+
+/*
+ *   This file is part of NOALYSS.
+ *
+ *   PhpCompta is free software; you can redistribute it and/or modify
+ *   it under the terms of the GNU General Public License as published by
+ *   the Free Software Foundation; either version 2 of the License, or
+ *   (at your option) any later version.
+ *
+ *   PhpCompta is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with PhpCompta; if not, write to the Free Software
+ *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+// Copyright (2002-2019) Author Dany De Bontridder <address@hidden>
+
+/**
+ * @file
+ * @brief concerne print_ledger_misc.classTest
+ */
+class Print_Ledger_MiscTest extends TestCase
+{
+
+    /**
+     * @var 
+     */
+    protected $object;
+
+    /**
+     * Sets up the fixture, for example, opens a network connection.
+     * This method is called before a test is executed.
+     */
+    protected function setUp()
+    {
+        include 'global.php';
+        // Exercice 2018
+        $this->from=92;
+        $this->to=103;
+    }
+
+    /**
+     * Tears down the fixture, for example, closes a network connection.
+     * This method is called after a test is executed.
+     */
+    protected function tearDown()
+    {
+        
+    }
+
+    function test_export()
+    {
+        global $g_connection;
+        $p_from=$this->from;
+        $p_to=$this->to;
+
+        // Check Misc
+        $ledger_misc=new Acc_Ledger($g_connection, 4);
+        $ledger=\Print_Ledger::factory($g_connection, "D", $ledger_misc, 
$p_from, $p_to, "all");
+        $this->assertTrue($ledger instanceof Print_Ledger_Detail
+                , "Misc. Detail returns Print_Ledger_Detail");
+
+        $ledger->setDossierInfo($ledger_misc->jrn_def_name);
+        $ledger->AliasNbPages();
+        $ledger->AddPage();
+        $ledger->SetAuthor('NOALYSS');
+        $ledger->setTitle(_("Journal Opérations diverses "), true);
+        $ledger->export();
+        $ledger->Output(__DIR__."/file/print_ledger_detail_misc.pdf", "F");
+
+        $ledger=\Print_Ledger::factory($g_connection, "L", $ledger_misc, 
$p_from, $p_to, "all");
+        $this->assertTrue($ledger instanceof Print_Ledger_Misc
+                , "Misc. Listing returns Print_Ledger_Misc");
+        $ledger->setDossierInfo($ledger_misc->jrn_def_name);
+        $ledger->AliasNbPages();
+        $ledger->AddPage();
+        $ledger->SetAuthor('NOALYSS');
+        $ledger->setTitle(_("Journal Opérations diverses"), true);
+        $ledger->export();
+        $ledger->Output(__DIR__."/file/print_ledger_misc.pdf", "F");
+    }
+
+}
diff --git a/unit-test/include/class/print_ledger_simple.classTest.php 
b/unit-test/include/class/print_ledger_simple.classTest.php
new file mode 100644
index 0000000..1cf7105
--- /dev/null
+++ b/unit-test/include/class/print_ledger_simple.classTest.php
@@ -0,0 +1,166 @@
+<?php
+
+use PHPUnit\Framework\TestCase;
+
+/*
+ *   This file is part of NOALYSS.
+ *
+ *   PhpCompta is free software; you can redistribute it and/or modify
+ *   it under the terms of the GNU General Public License as published by
+ *   the Free Software Foundation; either version 2 of the License, or
+ *   (at your option) any later version.
+ *
+ *   PhpCompta is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with PhpCompta; if not, write to the Free Software
+ *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+// Copyright (2002-2019) Author Dany De Bontridder <address@hidden>
+
+/**
+ * @file
+ * @brief concern Print_Ledger_Simple
+ * @coversDefaultClass  Print_Ledger_Simple
+ */
+class print_ledger_simpleTest extends TestCase
+{
+
+    /**
+     * @var 
+     */
+    protected $object;
+
+    /**
+     * Sets up the fixture, for example, opens a network connection.
+     * This method is called before a test is executed.
+     */
+    protected function setUp()
+    {
+        include 'global.php';
+        // Exercice 2018
+        $this->from=92;
+        $this->to=103;
+    }
+
+    /**
+     * Tears down the fixture, for example, closes a network connection.
+     * This method is called after a test is executed.
+     */
+    protected function tearDown()
+    {
+        
+    }
+
+    /**
+     * @covers ::export
+     */
+    function test_export()
+    {
+        global $g_connection;
+        $p_from=$this->from;
+        $p_to=$this->to;
+        
//-------------------------------------------------------------------------------------------------------------
+        // Purchase
+        
//-------------------------------------------------------------------------------------------------------------
+
+        $ledger_purchase=new Acc_Ledger_Purchase($g_connection, 3);
+
+        // Paid 
+        //------------
+        $ledger=\Print_Ledger::factory($g_connection, "E", $ledger_purchase, 
$p_from, $p_to, "paid");
+        $this->assertTrue($ledger instanceof Print_Ledger_Detail_Item
+                , "Purchase Extended returns Print_Ledger_Detail_Item");
+
+        $ledger->setDossierInfo($ledger_purchase->jrn_def_name);
+        $ledger->AliasNbPages();
+        $ledger->AddPage();
+        $ledger->SetAuthor('NOALYSS');
+        $ledger->setTitle(_("Journal Achat Payé"), true);
+        $ledger->export();
+        $ledger->Output(__DIR__."/file/print_ledger_simple_purchase_paid.pdf", 
"F");
+
+        // Unpaid
+        //------------
+        $ledger=\Print_Ledger::factory($g_connection, "E", $ledger_purchase, 
$p_from, $p_to, "unpaid");
+        $this->assertTrue($ledger instanceof Print_Ledger_Detail_Item
+                , "Purchase Extended returns Print_Ledger_Detail_Item");
+
+        $ledger->setDossierInfo($ledger_purchase->jrn_def_name);
+        $ledger->AliasNbPages();
+        $ledger->AddPage();
+        $ledger->SetAuthor('NOALYSS');
+        $ledger->setTitle(_("Journal Non Payé"), true);
+        $ledger->export();
+        
$ledger->Output(__DIR__."/file/print_ledger_simple_purchase_unpaid.pdf", "F");
+        
$this->assertFileExists(__DIR__."/file/print_ledger_simple_purchase_unpaid.pdf");
+
+        // All
+        //------------
+        $ledger=\Print_Ledger::factory($g_connection, "E", $ledger_purchase, 
$p_from, $p_to, "all");
+        $this->assertTrue($ledger instanceof Print_Ledger_Detail_Item
+                , "Purchase Extended returns Print_Ledger_Detail_Item");
+
+        $ledger->setDossierInfo($ledger_purchase->jrn_def_name);
+        $ledger->AliasNbPages();
+        $ledger->AddPage();
+        $ledger->SetAuthor('NOALYSS');
+        $ledger->setTitle(_("Journal Achat tous"), true);
+        $ledger->export();
+        $ledger->Output(__DIR__."/file/print_ledger_simple_purchase_all.pdf", 
"F");
+        
$this->assertFileExists(__DIR__."/file/print_ledger_simple_purchase_all.pdf");
+
+        
//-------------------------------------------------------------------------------------------------------------
+        // Sale
+        
//-------------------------------------------------------------------------------------------------------------
+        $ledger_sale=new Acc_Ledger_Sold($g_connection, 2);
+
+        // Paid
+        //-----------------
+        $ledger=\Print_Ledger::factory($g_connection, "E", $ledger_sale, 
$p_from, $p_to, "paid");
+        $this->assertTrue($ledger instanceof Print_Ledger_Detail_Item
+                , "Purchase Extended returns Print_Ledger_Detail_Item");
+
+        $ledger->setDossierInfo($ledger_sale->jrn_def_name);
+        $ledger->AliasNbPages();
+        $ledger->AddPage();
+        $ledger->SetAuthor('NOALYSS');
+        $ledger->setTitle(_("Journal Vente Payé"), true);
+        $ledger->export();
+        $ledger->Output(__DIR__."/file/print_ledger_simple_sale_paid.pdf", 
"F");
+
+        // Unpaid
+        //-----------------
+        $ledger=\Print_Ledger::factory($g_connection, "E", $ledger_sale, 
$p_from, $p_to, "unpaid");
+        $this->assertTrue($ledger instanceof Print_Ledger_Detail_Item
+                , "Purchase Extended returns Print_Ledger_Detail_Item");
+
+        $ledger->setDossierInfo($ledger_sale->jrn_def_name);
+        $ledger->AliasNbPages();
+        $ledger->AddPage();
+        $ledger->SetAuthor('NOALYSS');
+        $ledger->setTitle(_("Journal Non Payé"), true);
+        $ledger->export();
+        $ledger->Output(__DIR__."/file/print_ledger_simple_sale_unpaid.pdf", 
"F");
+        
$this->assertFileExists(__DIR__."/file/print_ledger_simple_sale_unpaid.pdf");
+
+        // All
+        //-----------------
+        $ledger=\Print_Ledger::factory($g_connection, "E", $ledger_sale, 
$p_from, $p_to, "all");
+        $this->assertTrue($ledger instanceof Print_Ledger_Detail_Item
+                , "Purchase Extended returns Print_Ledger_Detail_Item");
+
+        $ledger->setDossierInfo($ledger_sale->jrn_def_name);
+        $ledger->AliasNbPages();
+        $ledger->AddPage();
+        $ledger->SetAuthor('NOALYSS');
+        $ledger->setTitle(_("Journal Vente tous"), true);
+        $ledger->export();
+        $ledger->Output(__DIR__."/file/print_ledger_simple_sale_all.pdf", "F");
+        
$this->assertFileExists(__DIR__."/file/print_ledger_simple_sale_all.pdf");
+    }
+
+}
diff --git 
a/unit-test/include/class/print_ledger_simple_without_vat.classTest.php 
b/unit-test/include/class/print_ledger_simple_without_vat.classTest.php
new file mode 100644
index 0000000..865aa80
--- /dev/null
+++ b/unit-test/include/class/print_ledger_simple_without_vat.classTest.php
@@ -0,0 +1,161 @@
+<?php
+
+use PHPUnit\Framework\TestCase;
+
+/*
+ *   This file is part of NOALYSS.
+ *
+ *   PhpCompta is free software; you can redistribute it and/or modify
+ *   it under the terms of the GNU General Public License as published by
+ *   the Free Software Foundation; either version 2 of the License, or
+ *   (at your option) any later version.
+ *
+ *   PhpCompta is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with PhpCompta; if not, write to the Free Software
+ *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+// Copyright (2002-2019) Author Dany De Bontridder <address@hidden>
+
+/**
+ * @file
+ * @brief concern print_ledger_simple_without_vat
+ * @coversDefaultClass  print_ledger_simple_without_vat
+ */
+class Print_Ledger_Simple_Without_VatTest extends TestCase
+{
+
+    /**
+     * @var 
+     */
+    protected $object;
+
+    /**
+     * Sets up the fixture, for example, opens a network connection.
+     * This method is called before a test is executed.
+     */
+    protected function setUp()
+    {
+        include 'global.php';
+        // Exercice 2018
+        $this->from=92;
+        $this->to=103;
+    }
+
+    /**
+     * Tears down the fixture, for example, closes a network connection.
+     * This method is called after a test is executed.
+     */
+    protected function tearDown()
+    {
+        
+    }
+
+    /**
+     * @covers ::export
+     */
+    function test_export()
+    {
+        global $g_connection;
+        $p_from=$this->from;
+        $p_to=$this->to;
+        
//-------------------------------------------------------------------------------------------------------------
+        // Purchase
+        
//-------------------------------------------------------------------------------------------------------------
+
+        $ledger_purchase=new Acc_Ledger_Purchase($g_connection, 3);
+
+        // Paid 
+        //------------
+
+        $ledger=new Print_Ledger_Simple_Without_Vat($g_connection, 
+                $ledger_purchase, $p_from, $p_to, "paid");
+
+        $ledger->setDossierInfo($ledger_purchase->jrn_def_name);
+        $ledger->AliasNbPages();
+        $ledger->AddPage();
+        $ledger->SetAuthor('NOALYSS');
+        $ledger->setTitle(_("Journal Achat Payé"), true);
+        $ledger->export();
+        
$ledger->Output(__DIR__."/file/print_Ledger_simple_without_vat_purchase_paid.pdf",
 "F");
+
+        // Unpaid   
+        //------------
+        $ledger=new Print_Ledger_Simple_Without_Vat($g_connection,
+                $ledger_purchase, $p_from, $p_to, "unpaid");
+
+        $ledger->setDossierInfo($ledger_purchase->jrn_def_name);
+        $ledger->AliasNbPages();
+        $ledger->AddPage();
+        $ledger->SetAuthor('NOALYSS');
+        $ledger->setTitle(_("Journal Non Payé"), true);
+        $ledger->export();
+        
$ledger->Output(__DIR__."/file/print_Ledger_simple_without_vat_purchase_unpaid.pdf",
 "F");
+        
$this->assertFileExists(__DIR__."/file/print_Ledger_simple_without_vat_purchase_unpaid.pdf");
+
+        // All
+        //------------
+        $ledger=new Print_Ledger_Simple_Without_Vat($g_connection, 
+                $ledger_purchase, $p_from, $p_to, "all");
+
+        $ledger->setDossierInfo($ledger_purchase->jrn_def_name);
+        $ledger->AliasNbPages();
+        $ledger->AddPage();
+        $ledger->SetAuthor('NOALYSS');
+        $ledger->setTitle(_("Journal Achat tous"), true);
+        $ledger->export();
+        
$ledger->Output(__DIR__."/file/print_Ledger_simple_without_vat_purchase_all.pdf",
 "F");
+        
$this->assertFileExists(__DIR__."/file/print_Ledger_simple_without_vat_purchase_all.pdf");
+
+        
//-------------------------------------------------------------------------------------------------------------
+        // Sale
+        
//-------------------------------------------------------------------------------------------------------------
+        $ledger_sale=new Acc_Ledger_Sold($g_connection, 2);
+
+        // Paid
+        //-----------------
+        $ledger=new Print_Ledger_Simple_Without_Vat($g_connection, 
+                $ledger_sale, $p_from, $p_to, "paid");
+
+        $ledger->setDossierInfo($ledger_sale->jrn_def_name);
+        $ledger->AliasNbPages();
+        $ledger->AddPage();
+        $ledger->SetAuthor('NOALYSS');
+        $ledger->setTitle(_("Journal Vente Payé"), true);
+        $ledger->export();
+        
$ledger->Output(__DIR__."/file/print_Ledger_simple_without_vat_sale_paid.pdf", 
"F");
+
+        // Unpaid
+        //-----------------
+        $ledger=new Print_Ledger_Simple_Without_Vat($g_connection, 
+                $ledger_sale, $p_from, $p_to, "unpaid");
+
+        $ledger->setDossierInfo($ledger_sale->jrn_def_name);
+        $ledger->AliasNbPages();
+        $ledger->AddPage();
+        $ledger->SetAuthor('NOALYSS');
+        $ledger->setTitle(_("Journal Non Payé"), true);
+        $ledger->export();
+        
$ledger->Output(__DIR__."/file/print_Ledger_simple_without_vat_sale_unpaid.pdf",
 "F");
+        
$this->assertFileExists(__DIR__."/file/print_Ledger_simple_without_vat_sale_unpaid.pdf");
+
+        // All
+        //-----------------
+        $ledger=new Print_Ledger_Simple_Without_Vat($g_connection, 
+                    $ledger_sale, $p_from, $p_to, "all");
+
+        $ledger->setDossierInfo($ledger_sale->jrn_def_name);
+        $ledger->AliasNbPages();
+        $ledger->AddPage();
+        $ledger->SetAuthor('NOALYSS');
+        $ledger->setTitle(_("Journal Vente tous"), true);
+        $ledger->export();
+        
$ledger->Output(__DIR__."/file/print_Ledger_simple_without_vat_sale_all.pdf", 
"F");
+        
$this->assertFileExists(__DIR__."/file/print_Ledger_simple_without_vat_sale_all.pdf");
+    }
+
+}



reply via email to

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