noalyss-commit
[Top][All Lists]
Advanced

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

[Noalyss-commit] [noalyss] 30/33: Task #0002088: Export PDF de ANCBCC


From: Dany De Bontridder
Subject: [Noalyss-commit] [noalyss] 30/33: Task #0002088: Export PDF de ANCBCC
Date: Thu, 11 Nov 2021 06:02:52 -0500 (EST)

sparkyx pushed a commit to branch master
in repository noalyss.

commit dba0f1e6fc1a80cfbf565596c2b2def461c087f5
Author: sparkyx <danydb@noalyss.eu>
AuthorDate: Sun Nov 7 21:47:20 2021 +0100

    Task #0002088: Export PDF de ANCBCC
---
 include/class/anc_acc_link.class.php              |   2 +
 include/class/anc_acc_list.class.php              |  44 ++--
 include/class/pdf_anc_acc_list.class.php          | 279 ++++++++++++++++++++++
 include/constant.php                              |   5 +-
 include/export/export_anc_acc_list_pdf.php        |  34 +++
 include/sql/patch/upgrade169.sql                  |   6 +
 unit-test/include/class/pdf_anc_acc_list.Test.php | 163 +++++++++++++
 7 files changed, 514 insertions(+), 19 deletions(-)

diff --git a/include/class/anc_acc_link.class.php 
b/include/class/anc_acc_link.class.php
index 48321a0..aeea0bb 100644
--- a/include/class/anc_acc_link.class.php
+++ b/include/class/anc_acc_link.class.php
@@ -31,6 +31,8 @@ class Anc_Acc_Link extends Anc_Print
 {
   function __contruct($p_cn)
   {
+    parent::__construct($p_cn);
+    //@todo to remove = useless since the parent has a database object $db
     $this->cn=$p_cn;
   }
 
diff --git a/include/class/anc_acc_list.class.php 
b/include/class/anc_acc_list.class.php
index 2b62f86..3677b34 100644
--- a/include/class/anc_acc_list.class.php
+++ b/include/class/anc_acc_list.class.php
@@ -20,7 +20,8 @@
 // Copyright Author Dany De Bontridder danydb@aevalys.eu
 
 /*!\file
- * \brief
+ * \brief Anc_Acc_List Manage the class for reporting about Analytic 
Accountancy and Accountancy : card - analytic account,
+ * accounting - analytic account,
  */
 
 /*!
@@ -130,12 +131,10 @@ with m as (select oa_id, po_id,
           WHERE fiche_detail.ad_id = 1 AND fiche_detail.f_id = 
operation_analytique.f_id)
          end
           AS name,
-           case when jrnx.j_poste is not null then
-        jrnx.j_poste
-        when jrnx.j_poste is null then
-        (SELECT fiche_detail.ad_value
-           FROM fiche_detail
-          WHERE fiche_detail.ad_id = 5 AND fiche_detail.f_id = 
operation_analytique.f_id) end as j_qcode
+           case when jrnx.j_qcode is not null then
+            jrnx.j_qcode
+            when jrnx.j_qcode is null then
+            jrnx.j_poste end as j_qcode
    FROM operation_analytique
    left JOIN jrnx USING (j_id) )        
 SELECT po.po_id, po.pa_id, po.po_name, po.po_description, sum(
@@ -321,6 +320,19 @@ order by
     $r.= dossier::hidden();
     $r.=HtmlInput::submit('bt_csv',"Export en CSV");
     $r.= '</form>';
+    $r.= '<form method="GET" action="export.php"  style="display:inline">';
+    $r.= HtmlInput::hidden("act","PDF:AncAccList");
+    $r.= HtmlInput::hidden("to",$this->to);
+    $r.= HtmlInput::hidden("from",$this->from);
+    $r.= HtmlInput::hidden("pa_id",$this->pa_id);
+    $r.= HtmlInput::hidden("from_poste",$this->from_poste);
+    $r.= HtmlInput::hidden("to_poste",$this->to_poste);
+    $r.= HtmlInput::hidden("card_poste",$this->card_poste);
+
+    $r.= $p_hidden;
+    $r.= dossier::hidden();
+    $r.=HtmlInput::submit('bt_pdf',"Export en PDF");
+    $r.= '</form>';
     return $r;
   }
   /**
@@ -571,20 +583,18 @@ order by
 
        for ($i=0;$i<count($this->arow);$i++)
          {
-            $idx=0;
-            $a_csv=array();
             
-            $a_csv[$idx]=$this->arow[$i]['j_qcode']; $idx++;
-            $a_csv[$idx]=$this->arow[$i]['name'];$idx++;
-            $a_csv[$idx]=$this->arow[$i]['name'];$idx++;
-            $a_csv[$idx]=$this->arow[$i]['po_name'];$idx++;
-            $a_csv[$idx]=$this->arow[$i]['po_description'];$idx++;
+            $csv->add($this->arow[$i]['j_qcode']); 
+            $csv->add($this->arow[$i]['name']);
+            $csv->add($this->arow[$i]['name']);
+            $csv->add($this->arow[$i]['po_name']);
+            $csv->add($this->arow[$i]['po_description']);
 
            $amount=$this->arow[$i]['sum_amount'];
             if ($amount==null)$amount=0;
-            $a_csv[$idx]=$amount;$idx++;
+            $csv->add($amount,"number");
             
-            $csv->write_header($a_csv);
+            $csv->write();
          }
       }
     
//---------------------------------------------------------------------------
@@ -674,5 +684,5 @@ order by
 
 
   }
-
+  
 }
\ No newline at end of file
diff --git a/include/class/pdf_anc_acc_list.class.php 
b/include/class/pdf_anc_acc_list.class.php
new file mode 100644
index 0000000..8be98fe
--- /dev/null
+++ b/include/class/pdf_anc_acc_list.class.php
@@ -0,0 +1,279 @@
+<?php
+
+/*
+ *   This file is part of NOALYSS.
+ *
+ *   PhpCompta is free software; you can redistribute it and/or modify
+ *   it under the terms of the GNU General Public License as published by
+ *   the Free Software Foundation; either version 2 of the License, or
+ *   (at your option) any later version.
+ *
+ *   PhpCompta is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with PhpCompta; if not, write to the Free Software
+ *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+// Copyright (2002-2021) Author Dany De Bontridder <danydb@noalyss.eu>
+
+/**
+ * @file
+ * @brief 
+ */
+/* !
+ * \class 
+ * \brief export  Anc_Acc_List (ANCBCC) to PDF
+ */
+
+class PDF_Anc_Acc_List extends PDF
+{
+
+    private $anc_acc_list;
+    private $str_title;
+    private $a_size;
+
+    function __construct(Anc_Acc_List $p_anc_acc_list)
+    {
+        parent::__construct($p_anc_acc_list->db);
+        $this->anc_acc_list=$p_anc_acc_list;
+        $a_title=array(
+            1=>_('Comptabilité Analytique Fiche/Activité'),
+            2=>_("Comptabilité Analytique Poste comptable/Activité"),
+            3=>_('Comptabilité Analytique Activité/Fiche'),
+            4=>_('Comptabilité Analytique Activité/Poste Comptable'));
+        if (!isset($a_title[$p_anc_acc_list->card_poste]))
+        {
+            throw new Exception("PAAL.46 : invalid object");
+        }
+        $this->str_title=$a_title[$p_anc_acc_list->card_poste];
+    }
+    /**
+     * @brief Display the total amount
+     * @param type $p_pdf
+     * @param type $p_total
+     */
+    private function put_total($a_size,$p_pdf, $p_total)
+    {
+        $p_pdf->SetFont('DejaVu', 'B', 7);
+        $p_pdf->write_cell($a_size['po_name']+$a_size['po_description'], 5, 
_("Total"));
+        $p_pdf->write_cell($a_size['po_amount'], 5, nbm($p_total, 2), 0, 0, 
'R');
+        $p_pdf->line_new(5);
+    }
+    /**
+     * @brief Print the title
+     * @param PDF $p_pdf
+     * @param int $n_row_idx , idx of anc_acc_list->arow
+     */
+    private function put_title($p_pdf, $n_row_idx)
+    {
+        $p_pdf->SetFont('DejaVu', 'BU', 10);
+        switch ($this->anc_acc_list->card_poste)
+        {
+            case 1:
+
+                $p_pdf->write_cell(190, 12,
+                        $this->anc_acc_list->arow[$n_row_idx]['j_qcode']." ".
+                        $this->anc_acc_list->arow[$n_row_idx]['name']);
+
+                break;
+            case 2:
+
+                $p_pdf->write_cell(190, 12,
+                        $this->anc_acc_list->arow[$n_row_idx]['j_poste']." ".
+                        $this->anc_acc_list->arow[$n_row_idx]['name']);
+
+                break;
+            case 3:
+
+                $p_pdf->write_cell(190, 12,
+                        $this->anc_acc_list->arow[$n_row_idx]['po_name']." ".
+                        
$this->anc_acc_list->arow[$n_row_idx]['po_description']);
+
+                break;
+            case 4:
+
+                $p_pdf->write_cell(190, 12,
+                        $this->anc_acc_list->arow[$n_row_idx]['po_name']." ".
+                        
$this->anc_acc_list->arow[$n_row_idx]['po_description']);
+
+                break;
+            default:
+                break;
+        }
+        $p_pdf->line_new();
+    }
+    /**
+     * @brief Return the previous item : card or account or activity depending 
of the crossing method
+     * @param type $n_row_idx
+     * @return type
+     */
+    private function get_previous($n_row_idx)
+    {
+        switch ($this->anc_acc_list->card_poste)
+        {
+            case 1:
+                return $this->anc_acc_list->arow[$n_row_idx]['f_id'];
+                break;
+            case 2:
+                return $this->anc_acc_list->arow[$n_row_idx]['j_poste'];
+                break;
+            case 3:
+                return $this->anc_acc_list->arow[$n_row_idx]['po_id'];
+                break;
+            case 4:
+                return $this->anc_acc_list->arow[$n_row_idx]['po_id'];
+                break;
+        }
+    }
+    /**
+     * @brief 
+     * @return \PDF
+     */
+    private function pdf_card()
+    {
+        $pdf=new PDF($this->anc_acc_list->db);
+        $pdf->setDossierInfo(_("Balance croisée A/C"));
+        $pdf->SetTitle($this->str_title);
+        $pdf->AddPage();
+        $pdf->SetFont('DejaVu', 'B', 12);
+        $pdf->write_cell(190, 12, $this->str_title, 1);
+        $pdf->AliasNbPages();
+
+        $nb_row=count($this->anc_acc_list->arow);
+        $a_size=array("po_name"=>60, "po_description"=>100, "po_amount"=>30);
+        $pdf->line_new(20);
+        $pdf->SetFont('DejaVu', '', 7);
+        $tot_card=0; $tot_glob=0;
+        for ($i=0; $i<$nb_row; $i++)
+        {
+            $fill=$pdf->is_fill($i+1);
+            if ($i==0)
+            {
+                $prev=$this->get_previous($i);
+                $this->put_title($pdf, $i);
+                $pdf->SetFont('DejaVu', '', 7);
+            }
+            if ($prev!=$this->get_previous($i))
+            {
+                $prev=$this->get_previous($i);
+                $this->put_total($a_size,$pdf,$tot_card);
+                
+                $this->put_title($pdf, $i);
+                $pdf->SetFont('DejaVu', '', 7);
+                $tot_card=0;
+            }
+            
$this->anc_acc_list->arow[$i]['sum_amount']=($this->anc_acc_list->arow[$i]['sum_amount']=="")?0:
+                    $this->anc_acc_list->arow[$i]['sum_amount'];
+
+            $tot_card=bcadd($tot_card, 
$this->anc_acc_list->arow[$i]['sum_amount'], 2);
+            $tot_glob=bcadd($tot_glob, 
$this->anc_acc_list->arow[$i]['sum_amount'], 2);
+            if ($this->anc_acc_list->card_poste<3)
+            {
+                $pdf->write_cell($a_size['po_name'], 4, 
$this->anc_acc_list->arow[$i]['po_name'], 0, 0, 'L', $fill);
+                $pdf->write_cell($a_size['po_description'], 4, 
$this->anc_acc_list->arow[$i]['po_description'], 0, 0,
+                        'L', $fill);
+                $pdf->write_cell($a_size['po_amount'], 4, 
nbm($this->anc_acc_list->arow[$i]['sum_amount'], 2), 0, 0,
+                        'R', $fill);
+            }
+            elseif ($this->anc_acc_list->card_poste==3)
+            {
+                $pdf->write_cell($a_size['po_name'], 4, 
$this->anc_acc_list->arow[$i]['j_qcode'], 0, 0, 'L', $fill);
+                $pdf->write_cell($a_size['po_description'], 4, 
$this->anc_acc_list->arow[$i]['name'], 0, 0, 'L', $fill);
+                $pdf->write_cell($a_size['po_amount'], 4, 
nbm($this->anc_acc_list->arow[$i]['sum_amount'], 2), 0, 0,
+                        'R', $fill);
+            }
+            elseif ($this->anc_acc_list->card_poste==4)
+            {
+                $pdf->write_cell($a_size['po_name'], 4, 
$this->anc_acc_list->arow[$i]['j_poste'], 0, 0, 'L', $fill);
+                $pdf->write_cell($a_size['po_description'], 4, 
$this->anc_acc_list->arow[$i]['name'], 0, 0, 'L', $fill);
+                $pdf->write_cell($a_size['po_amount'], 4, 
nbm($this->anc_acc_list->arow[$i]['sum_amount'], 2), 0, 0,
+                        'R', $fill);
+            }
+            $pdf->line_new();
+        }
+        $this->put_total($a_size,$pdf,$tot_card);
+        $pdf->SetFont('DejaVu', '', 7);
+        
+        $pdf->line_new(5);
+        $pdf->write_cell($a_size['po_name']+$a_size['po_description'], 10, 
_("Total Global"),'LBT');
+        $pdf->write_cell($a_size['po_amount'], 10, nbm($tot_glob, 2), 'RBT', 
0, 'R');
+        $pdf->line_new();
+        return $pdf;
+    }
+
+    public function get_a_size()
+    {
+        return $this->a_size;
+    }
+
+    public function set_a_size($a_size): PDF_Anc_Acc_List
+    {
+        $this->a_size=$a_size;
+        return $this;
+    }
+
+    public function get_anc_acc_list()
+    {
+        return $this->anc_acc_list;
+    }
+
+    public function get_str_title()
+    {
+        return $this->str_title;
+    }
+
+    public function set_anc_acc_list($anc_acc_list): PDF_Anc_Acc_List
+    {
+        $this->anc_acc_list=$anc_acc_list;
+        return $this;
+    }
+
+    public function set_str_title($str_title): PDF_Anc_Acc_List
+    {
+        $this->str_title=$str_title;
+        return $this;
+    }
+    /**
+     * @brief Main function , export the ANCBCC list to PDF, crossed by 
activity , account or card
+     * @return type
+     * @throws Exception
+     */
+    function export_pdf()
+    {
+
+        if ($this->anc_acc_list->check()!=0)
+        {
+            throw new Exception(_("date invalide"));
+        }
+        switch ($this->anc_acc_list->card_poste)
+        {
+            case 1:
+                // Card  - Acc
+                $this->anc_acc_list->load_card();
+                return $this->pdf_card();
+                break;
+            case 2:
+                // Accountancy - Analytic
+                $this->anc_acc_list->load_poste();
+                return $this->pdf_card();
+                break;
+            case 3:
+                // Acc after card
+                $this->anc_acc_list->load_anc_card();
+                return $this->pdf_card();
+                break;
+            case 4:
+                // Analytic - Accountancy
+                $this->anc_acc_list->load_anc_account();
+                return $this->pdf_card();
+                break;
+            default:
+                throw new Exception('AAL700:unknown export');
+        }
+        return;
+    }
+
+}
diff --git a/include/constant.php b/include/constant.php
index ce5670e..22cb41e 100644
--- a/include/constant.php
+++ b/include/constant.php
@@ -116,7 +116,7 @@ if ( !defined ("NOALYSS_PACKAGE_REPOSITORY")) {
 if ( ! defined ("SYSINFO_DISPLAY")) {
     define ("SYSINFO_DISPLAY",TRUE);
 }
-define ("DBVERSION",169);
+define ("DBVERSION",170);
 define ("MONO_DATABASE",25);
 define ("DBVERSIONREPO",20);
 define ('NOTFOUND','--not found--');
@@ -597,7 +597,8 @@ function noalyss_class_autoloader($class) {
         "mobile_device_mtable"=>"class/mobile_device_mtable.class.php",
         "html_input_noalyss"=>"class/html_input_noalyss.class.php",
         "card_property"=>"class/card_property.class.php",
-        "pdfland"=>"class/pdf_land.class.php"
+        "pdfland"=>"class/pdf_land.class.php",
+        "pdf_anc_acc_list"=>"class/pdf_anc_acc_list.class.php"
     );
     if ( isset ($aClass[$class]) ) {
         require_once NOALYSS_INCLUDE."/".$aClass[$class];
diff --git a/include/export/export_anc_acc_list_pdf.php 
b/include/export/export_anc_acc_list_pdf.php
new file mode 100644
index 0000000..35e6487
--- /dev/null
+++ b/include/export/export_anc_acc_list_pdf.php
@@ -0,0 +1,34 @@
+<?php
+
+/*
+ *   This file is part of NOALYSS.
+ *
+ *   PhpCompta is free software; you can redistribute it and/or modify
+ *   it under the terms of the GNU General Public License as published by
+ *   the Free Software Foundation; either version 2 of the License, or
+ *   (at your option) any later version.
+ *
+ *   PhpCompta is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with PhpCompta; if not, write to the Free Software
+ *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+// Copyright (2002-2021) Author Dany De Bontridder <danydb@noalyss.eu>
+
+if (!defined('ALLOWED'))     die('Appel direct ne sont pas permis');
+
+/**
+ * @file
+ * @brief export ANCBCC in PDF
+ */
+
+$bal=new Anc_Acc_List($cn);
+$bal->get_request();
+$pdf=new PDF_Anc_Acc_List($bal);
+$fDate=date('dmy-Hi');
+
+$pdf->export_pdf()->Output( "balance-acc-anc-$fDate.pdf", 'D');
diff --git a/include/sql/patch/upgrade169.sql b/include/sql/patch/upgrade169.sql
new file mode 100644
index 0000000..a8bf261
--- /dev/null
+++ b/include/sql/patch/upgrade169.sql
@@ -0,0 +1,6 @@
+begin;
+INSERT INTO public.menu_ref (me_code, me_menu, me_file, me_url, 
me_description, me_parameter, me_javascript, me_type, me_description_etendue) 
VALUES('PDF:AncAccList', 'Export Historique Compt. Analytique', 
'export_anc_acc_list_pdf.php', NULL, NULL, NULL, NULL, 'PR', NULL);
+
+insert into profile_menu (me_code,p_id,p_type_displayn,pm_default) select  
'PDF:AncAccList',p_id,p_type_display,pm_default from profile_menu pm where 
me_code='CSV:AncAccList';
+insert into version (val,v_description) values (170,'new : export in PDF 
balance Analytic / Accountancy');
+commit ;
\ No newline at end of file
diff --git a/unit-test/include/class/pdf_anc_acc_list.Test.php 
b/unit-test/include/class/pdf_anc_acc_list.Test.php
new file mode 100644
index 0000000..fbbfd3b
--- /dev/null
+++ b/unit-test/include/class/pdf_anc_acc_list.Test.php
@@ -0,0 +1,163 @@
+<?php
+
+/*
+ * * Copyright (C) 2021 Dany De Bontridder <dany@alchimerys.be>
+ *
+ * This program 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.
+ *
+ * This program 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 this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+
+ * 
+ * Author : Dany De Bontridder danydb@noalyss.eu
+ * 
+ */
+
+/**
+ * @file
+ * @brief 
+ */
+use PHPUnit\Framework\TestCase;
+
+/**
+ * @backupGlobals enabled
+ */
+require 'global.php';
+
+class PDF_Anc_Acc_ListTest extends TestCase
+{
+
+    /**
+     * @var Fiche
+     */
+    protected $object;
+
+    /**
+     * Sets up the fixture, for example, opens a network connection.
+     * This method is called before a test method is executed.
+     */
+    protected function setUp()
+    {
+        include 'global.php';
+        
+    }
+
+    /**
+     * Tears down the fixture, for example, closes a network connection.
+     * This method is called after a test method is executed.
+     */
+    protected function tearDown()
+    {
+        
+    }
+
+    /**
+     * the setUpBeforeClass() template methods is called before the first test 
of the test case
+     *  class is run 
+     */
+    public static function setUpBeforeClass()
+    {
+        include 'global.php';
+        // insert data into operation_analytique
+        $sql=<<<EOF
+INSERT INTO public.operation_analytique (oa_id, po_id, oa_amount, 
oa_description, oa_debit, j_id, oa_group, oa_date, oa_row, oa_jrnx_id_source, 
oa_positive, f_id) VALUES(85, 2, 20.0000, 'Vente Service', false, 444, 887, 
'2019-01-02', 0, NULL, 'Y', NULL);
+INSERT INTO public.operation_analytique (oa_id, po_id, oa_amount, 
oa_description, oa_debit, j_id, oa_group, oa_date, oa_row, oa_jrnx_id_source, 
oa_positive, f_id) VALUES(86, 3, 35.2000, 'Vente Service', false, 444, 887, 
'2019-01-02', 1, NULL, 'Y', NULL);
+INSERT INTO public.operation_analytique (oa_id, po_id, oa_amount, 
oa_description, oa_debit, j_id, oa_group, oa_date, oa_row, oa_jrnx_id_source, 
oa_positive, f_id) VALUES(87, 1, 95.3600, 'Vente Service', false, 444, 887, 
'2019-01-02', 2, NULL, 'Y', NULL);
+INSERT INTO public.operation_analytique (oa_id, po_id, oa_amount, 
oa_description, oa_debit, j_id, oa_group, oa_date, oa_row, oa_jrnx_id_source, 
oa_positive, f_id) VALUES(88, 4, 85.0000, 'Note Electricité janvier', true, 
336, 888, '2019-01-02', 0, NULL, 'Y', NULL);
+INSERT INTO public.operation_analytique (oa_id, po_id, oa_amount, 
oa_description, oa_debit, j_id, oa_group, oa_date, oa_row, oa_jrnx_id_source, 
oa_positive, f_id) VALUES(89, 1, 79.2500, 'Note Electricité janvier', true, 
336, 888, '2019-01-02', 1, NULL, 'Y', NULL);
+INSERT INTO public.operation_analytique (oa_id, po_id, oa_amount, 
oa_description, oa_debit, j_id, oa_group, oa_date, oa_row, oa_jrnx_id_source, 
oa_positive, f_id) VALUES(90, 2, 164.2500, 'Note Electricité janvier', true, 
342, 889, '2019-03-02', 0, NULL, 'Y', NULL);
+INSERT INTO public.operation_analytique (oa_id, po_id, oa_amount, 
oa_description, oa_debit, j_id, oa_group, oa_date, oa_row, oa_jrnx_id_source, 
oa_positive, f_id) VALUES(91, 1, 164.2500, 'Note Electricité janvier', true, 
347, 890, '2019-04-02', 0, NULL, 'Y', NULL);
+INSERT INTO public.operation_analytique (oa_id, po_id, oa_amount, 
oa_description, oa_debit, j_id, oa_group, oa_date, oa_row, oa_jrnx_id_source, 
oa_positive, f_id) VALUES(92, 2, 169.1800, 'Electricité', true, 352, 891, 
'2019-05-02', 0, NULL, 'Y', NULL);
+INSERT INTO public.operation_analytique (oa_id, po_id, oa_amount, 
oa_description, oa_debit, j_id, oa_group, oa_date, oa_row, oa_jrnx_id_source, 
oa_positive, f_id) VALUES(93, 4, 50.0000, 'Frais de formation', true, 408, 892, 
'2019-07-02', 0, NULL, 'Y', NULL);
+INSERT INTO public.operation_analytique (oa_id, po_id, oa_amount, 
oa_description, oa_debit, j_id, oa_group, oa_date, oa_row, oa_jrnx_id_source, 
oa_positive, f_id) VALUES(94, 1, 50.0000, 'Frais de formation', true, 408, 892, 
'2019-07-02', 1, NULL, 'Y', NULL);
+INSERT INTO public.operation_analytique (oa_id, po_id, oa_amount, 
oa_description, oa_debit, j_id, oa_group, oa_date, oa_row, oa_jrnx_id_source, 
oa_positive, f_id) VALUES(95, 4, 750.0000, 'Frais de formation', true, 409, 
893, '2019-07-02', 0, NULL, 'Y', NULL);
+INSERT INTO public.operation_analytique (oa_id, po_id, oa_amount, 
oa_description, oa_debit, j_id, oa_group, oa_date, oa_row, oa_jrnx_id_source, 
oa_positive, f_id) VALUES(96, 1, 770.2000, 'Frais de formation', true, 409, 
893, '2019-07-02', 1, NULL, 'Y', NULL);
+INSERT INTO public.operation_analytique (oa_id, po_id, oa_amount, 
oa_description, oa_debit, j_id, oa_group, oa_date, oa_row, oa_jrnx_id_source, 
oa_positive, f_id) VALUES(97, 2, 100.0000, 'Frais de formation', true, 410, 
894, '2019-07-02', 0, NULL, 'Y', NULL);
+INSERT INTO public.operation_analytique (oa_id, po_id, oa_amount, 
oa_description, oa_debit, j_id, oa_group, oa_date, oa_row, oa_jrnx_id_source, 
oa_positive, f_id) VALUES(98, 4, 259.8000, 'Frais de formation', true, 411, 
895, '2019-07-02', 0, NULL, 'Y', NULL);
+INSERT INTO public.operation_analytique (oa_id, po_id, oa_amount, 
oa_description, oa_debit, j_id, oa_group, oa_date, oa_row, oa_jrnx_id_source, 
oa_positive, f_id) VALUES(99, 3, 1250.0000, 'Frais de formation', true, 412, 
896, '2019-07-02', 0, NULL, 'Y', NULL);
+INSERT INTO public.operation_analytique (oa_id, po_id, oa_amount, 
oa_description, oa_debit, j_id, oa_group, oa_date, oa_row, oa_jrnx_id_source, 
oa_positive, f_id) VALUES(100, 4, 183.0000, 'Eau', false, 380, 897, 
'2019-04-17', 0, NULL, 'N', NULL);
+INSERT INTO public.operation_analytique (oa_id, po_id, oa_amount, 
oa_description, oa_debit, j_id, oa_group, oa_date, oa_row, oa_jrnx_id_source, 
oa_positive, f_id) VALUES(101, 2, 366.0000, 'Eau', true, 380, 897, 
'2019-04-17', 1, NULL, 'Y', NULL);
+
+EOF;
+        global $g_connection;
+        $g_connection->exec_sql($sql);
+    }
+
+    /**
+     *  tearDownAfterClass() template methods is calleafter the last test of 
the test case class is run,
+     *
+     */
+    static function tearDownAfterClass()
+    {
+             include 'global.php';
+             global $g_connection;
+             $g_connection->exec_sql("delete from operation_analytique");
+    }
+
+
+    /**
+     * @brief 
+     * @testdox Export to PDF
+     * @param type $p_param
+     * @covers
+     */
+    public function testPdf_Card()
+    {
+        global $g_connection;
+        
+        // By card
+        
+        $anc_acc_list=new Anc_Acc_List($g_connection);
+        $anc_acc_list->to='31.12.2019';
+        $anc_acc_list->from='01.01.2019';
+        $anc_acc_list->pa_id=1;
+        $anc_acc_list->card_poste=1;
+        $pdf_anc_acc=new PDF_Anc_Acc_List($anc_acc_list);
+        
$pdf_anc_acc->export_pdf()->Output(__DIR__."/file/pdf_anc_acc_list-card-activity.pdf","F");
+        
$this->assertEquals(76920,filesize(__DIR__."/file/pdf_anc_acc_list-card-activity.pdf"),
+                __DIR__."/file/pdf_anc_acc_list-card-activity.pdf incorrect");
+        
+        // By Account / Activity
+        $anc_acc_list=new Anc_Acc_List($g_connection);
+        $anc_acc_list->to='31.12.2019';
+        $anc_acc_list->from='01.01.2019';
+        $anc_acc_list->pa_id=1;
+        $anc_acc_list->card_poste=2;
+        $pdf_anc_acc=new PDF_Anc_Acc_List($anc_acc_list);
+        
$pdf_anc_acc->export_pdf()->Output(__DIR__."/file/pdf_anc_acc_list-account-activity.pdf","F");
+        
$this->assertEquals(77152,filesize(__DIR__."/file/pdf_anc_acc_list-account-activity.pdf"),
+               __DIR__."/file/pdf_anc_acc_list-account-activity.pdf incorrect 
");
+        
+        // By Activity / Card
+        $anc_acc_list=new Anc_Acc_List($g_connection);
+        $anc_acc_list->to='31.12.2019';
+        $anc_acc_list->from='01.01.2019';
+        $anc_acc_list->pa_id=1;
+        $anc_acc_list->card_poste=3;
+        $pdf_anc_acc=new PDF_Anc_Acc_List($anc_acc_list);
+        
$pdf_anc_acc->export_pdf()->Output(__DIR__."/file/pdf_anc_acc_list-activity-card.pdf","F");
+        
$this->assertEquals(77690,filesize(__DIR__."/file/pdf_anc_acc_list-activity-card.pdf"),
+                __DIR__."/file/pdf_anc_acc_list-activity-card.pdf incorrect");
+        
+          // By Activity / Account
+         $anc_acc_list=new Anc_Acc_List($g_connection);
+        $anc_acc_list->to='31.12.2019';
+        $anc_acc_list->from='01.01.2019';
+        $anc_acc_list->pa_id=1;
+        $anc_acc_list->card_poste=4;
+        $pdf_anc_acc=new PDF_Anc_Acc_List($anc_acc_list);
+        
$pdf_anc_acc->export_pdf()->Output(__DIR__."/file/pdf_anc_acc_list-activity-account.pdf","F");
+        
$this->assertEquals(76411,filesize(__DIR__."/file/pdf_anc_acc_list-activity-account.pdf"),
+                __DIR__."/file/pdf_anc_acc_list-activity-account.pdf 
incorrect");
+    }
+
+}



reply via email to

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