noalyss-commit
[Top][All Lists]
Advanced

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

[Noalyss-commit] [noalyss] 21/27: Bug : export PDF for PRINTTVA doesn't


From: Dany De Bontridder
Subject: [Noalyss-commit] [noalyss] 21/27: Bug : export PDF for PRINTTVA doesn't print all the ledgers
Date: Sat, 2 Nov 2019 18:12:19 -0400 (EDT)

sparkyx pushed a commit to branch master
in repository noalyss.

commit 986a480e907346ddeb3715f7f4ba6938dd299a24
Author: Dany De Bontridder <address@hidden>
Date:   Sat Nov 2 22:23:08 2019 +0100

    Bug : export PDF for PRINTTVA doesn't print
    all the ledgers
---
 include/export/export_printtva_pdf.php            |   7 +-
 unit-test/include/class/tax_summaryTest.class.php | 655 +++++++++++++++++++---
 2 files changed, 578 insertions(+), 84 deletions(-)

diff --git a/include/export/export_printtva_pdf.php 
b/include/export/export_printtva_pdf.php
index 932fd82..028db71 100644
--- a/include/export/export_printtva_pdf.php
+++ b/include/export/export_printtva_pdf.php
@@ -114,7 +114,6 @@ for ($i = 0; $i < $nb_array; $i++) {
             $a_tot[$colname]=0;
         }
         $pdf->line_new();
-        $pdf->SetFont('DejaVuCond', 'B', 7);
 
         // Display ledger name
         $ledger_name = $array[$i]['jrn_def_name'];
@@ -123,6 +122,7 @@ for ($i = 0; $i < $nb_array; $i++) {
         $pdf->line_new();
 
         // Display Header
+        $pdf->SetFont('DejaVuCond', 'B', 7);
         for ($e=0;$e<$nb_col;$e++){
             if ( $e == 0 ) {
                 $pdf->write_cell(40, 5,$a_sale_header[$e], 1, 0, 'L');
@@ -131,6 +131,8 @@ for ($i = 0; $i < $nb_array; $i++) {
             }
             $a_tot[$colname]=0;
         }
+        $pdf->line_new();
+        $pdf->SetFont('DejaVuCond', '', 7);
     }
     for ($e=0;$e<$nb_col;$e++){
         $colname=$a_col[$e];
@@ -220,7 +222,7 @@ $nb_col=count($a_colp);
 for ($e=2;$e<$nb_col;$e++){
     $a_tot[$a_colp[$e]]=0;
 }
-
+$nb_array=count($array);
 for ($i = 0; $i < $nb_array; $i++) {
     for ($e=2;$e<$nb_col;$e++){
         $colname=$a_colp[$e];
@@ -282,6 +284,7 @@ for ($i = 0; $i < $nb_array; $i++) {
             $a_tot[$colname]=0;
         }
     }
+    $pdf->SetFont('DejaVuCond', '', 7);
     for ($e=0;$e<$nb_col;$e++){
         $colname=$a_colp[$e];
         
diff --git a/unit-test/include/class/tax_summaryTest.class.php 
b/unit-test/include/class/tax_summaryTest.class.php
index 24ead32..1b1643c 100644
--- a/unit-test/include/class/tax_summaryTest.class.php
+++ b/unit-test/include/class/tax_summaryTest.class.php
@@ -1,5 +1,7 @@
 <?php
+
 use PHPUnit\Framework\TestCase;
+
 /*
  *   This file is part of NOALYSS.
  *
@@ -23,10 +25,10 @@ use PHPUnit\Framework\TestCase;
  * @file
  * @brief 
  */
-
 class Tax_SummaryTest extends TestCase
 {
-     /**
+
+    /**
      * @var Acc_Account
      */
     protected $object;
@@ -35,130 +37,619 @@ class Tax_SummaryTest extends TestCase
      * Sets up the fixture, for example, opens a network connection.
      * This method is called before a test is executed.
      */
-    protected function setUp() :void
+    protected function setUp(): void
     {
         global $g_connection;
         $this->object=new \Tax_Summary($g_connection, "01.01.2014", 
"31.12.2019");
     }
+
     function testCheck()
     {
         // No warning expected
-        try {
+        try
+        {
             $this->object->check();
             $this->assertTrue(TRUE);
-        } catch(Exception $e) {
-            $this->assertSame('OK',$e->getMessage());
+        }
+        catch (Exception $e)
+        {
+            $this->assertSame('OK', $e->getMessage());
         }
         // Warning expected
-        try {
+        try
+        {
             $this->object->set_date_start("01.01.2090");
             $this->object->check();
             $this->assertTrue(FALSE);
-        } catch(Exception $e) {
+        }
+        catch (Exception $e)
+        {
             $this->assertTrue(TRUE);
         }
     }
+
     function testDisplay()
     {
-        $this->expectOutputRegex("/.*10\.737,34.*\<\/tr\>\<\/table\>\n/");
+        $this->expectOutputRegex("/.*0,00.*\<\/tr\>\<\/table\>\n/");
         $this->object->display();
     }
+
     function testForm_export_csv()
     {
         $this->expectOutputRegex("/\<form method=\"GET\".*/");
         $this->object->form_export_csv();
     }
+
     function testForm_export_pdf()
     {
         $this->expectOutputRegex("/\<form method=\"GET\".*/");
         $this->object->form_export_pdf();
     }
+
     function testGet_row_purchase()
     {
         $array=$this->object->get_row_purchase();
-        $this->assertSame($array, [['jrn_def_name' => 'Achat',
-                                'tva_label' => '0%',
-                                'tva_rate' => '0.0000',
-                                'tva_both_side' => '0',
-                                'qp_vat_code' => '4',
-                                'amount_vat' => '0.0000',
-                                'amount_wovat' => '658.2500',
-                                'amount_sided' => '0.0000',
-                                'amount_noded_amount' => '0.0000',
-                                'amount_noded_tax' => '0.0000',
-                                'amount_noded_return' => '0.0000',
-                                'amount_private' => '0.0000'
-                                ],[
-                                'jrn_def_name' => 'Achat',
-                                 'tva_label' => '12%',
-                                 'tva_rate' => '0.1200',
-                                 'tva_both_side' => '0',
-                                 'qp_vat_code' => '2',
-                                 'amount_vat' => '84.2200',
-                                 'amount_wovat' => '701.7800',
-                                 'amount_sided' => '0.0000',
-                                 'amount_noded_amount' => '0.0000',
-                                 'amount_noded_tax' => '0.0000',
-                                 'amount_noded_return' => '0.0000',
-                                 'amount_private' => '0.0000']]);
+        //-- For creating the array
+        Noalyss\Facility::save_file(__DIR__."/file", 
"tax_summary_getrow_purchase.txt", print_r($array, TRUE));
+        $a_result=array
+            (
+            "0"=>array
+                (
+                "jrn_def_name"=>"Achat",
+                "tva_label"=>"0%",
+                "tva_rate"=>0.0000,
+                "tva_both_side"=>0,
+                "qp_vat_code"=>4,
+                "amount_vat"=>0.0000,
+                "amount_wovat"=>658.2500,
+                "amount_sided"=>0.0000,
+                "amount_noded_amount"=>0.0000,
+                "amount_noded_tax"=>0.0000,
+                "amount_noded_return"=>0.0000,
+                "amount_private"=>0.0000
+            ),
+            "1"=>array
+                (
+                "jrn_def_name"=>"Achat",
+                "tva_label"=>"12%",
+                "tva_rate"=>0.1200,
+                "tva_both_side"=>0,
+                "qp_vat_code"=>2,
+                "amount_vat"=>109.8000,
+                "amount_wovat"=>915.0000,
+                "amount_sided"=>0.0000,
+                "amount_noded_amount"=>0.0000,
+                "amount_noded_tax"=>0.0000,
+                "amount_noded_return"=>0.0000,
+                "amount_private"=>0.0000
+            ),
+            "2"=>array
+                (
+                "jrn_def_name"=>"Achat",
+                "tva_label"=>"21%",
+                "tva_rate"=>0.2100,
+                "tva_both_side"=>0,
+                "qp_vat_code"=>1,
+                "amount_vat"=>6.1000,
+                "amount_wovat"=>29.0000,
+                "amount_sided"=>0.0000,
+                "amount_noded_amount"=>0.0000,
+                "amount_noded_tax"=>0.0000,
+                "amount_noded_return"=>0.0000,
+                "amount_private"=>0.0000
+            ),
+            "3"=>array
+                (
+                "jrn_def_name"=>"Achat",
+                "tva_label"=>"6%",
+                "tva_rate"=>0.0600,
+                "tva_both_side"=>0,
+                "qp_vat_code"=>3,
+                "amount_vat"=>5.2800,
+                "amount_wovat"=>88.3200,
+                "amount_sided"=>0.0000,
+                "amount_noded_amount"=>0.0000,
+                "amount_noded_tax"=>0.0000,
+                "amount_noded_return"=>0.0000,
+                "amount_private"=>0.0000
+            ),
+            "4"=>array
+                (
+                "jrn_def_name"=>"Achat",
+                "tva_label"=>"ART44",
+                "tva_rate"=>0.0000,
+                "tva_both_side"=>0,
+                "qp_vat_code"=>8,
+                "amount_vat"=>0.0000,
+                "amount_wovat"=>315.2000,
+                "amount_sided"=>0.0000,
+                "amount_noded_amount"=>0.0000,
+                "amount_noded_tax"=>0.0000,
+                "amount_noded_return"=>0.0000,
+                "amount_private"=>0.0000
+            ),
+            "5"=>array
+                (
+                "jrn_def_name"=>"Achat",
+                "tva_label"=>"EXPORT",
+                "tva_rate"=>0.0000,
+                "tva_both_side"=>0,
+                "qp_vat_code"=>6,
+                "amount_vat"=>0.0000,
+                "amount_wovat"=>286.9500,
+                "amount_sided"=>0.0000,
+                "amount_noded_amount"=>0.0000,
+                "amount_noded_tax"=>0.0000,
+                "amount_noded_return"=>0.0000,
+                "amount_private"=>0.0000
+            ),
+            "6"=>array
+                (
+                "jrn_def_name"=>"Achat",
+                "tva_label"=>"IMMO",
+                "tva_rate"=>0.2100,
+                "tva_both_side"=>0,
+                "qp_vat_code"=>1002,
+                "amount_vat"=>319.2400,
+                "amount_wovat"=>1520.2000,
+                "amount_sided"=>0.0000,
+                "amount_noded_amount"=>0.0000,
+                "amount_noded_tax"=>0.0000,
+                "amount_noded_return"=>0.0000,
+                "amount_private"=>0.0000
+            ),
+            "7"=>array
+                (
+                "jrn_def_name"=>"Achat",
+                "tva_label"=>"VOIT",
+                "tva_rate"=>0.2100,
+                "tva_both_side"=>0,
+                "qp_vat_code"=>1003,
+                "amount_vat"=>21.0000,
+                "amount_wovat"=>100.0000,
+                "amount_sided"=>0.0000,
+                "amount_noded_amount"=>0.0000,
+                "amount_noded_tax"=>0.0000,
+                "amount_noded_return"=>0.0000,
+                "amount_private"=>0.0000
+            ),
+            "8"=>array
+                (
+                "jrn_def_name"=>"Frais Divers",
+                "tva_label"=>"21%",
+                "tva_rate"=>0.2100,
+                "tva_both_side"=>0,
+                "qp_vat_code"=>1,
+                "amount_vat"=>244.5500,
+                "amount_wovat"=>1164.5400,
+                "amount_sided"=>0.0000,
+                "amount_noded_amount"=>0.0000,
+                "amount_noded_tax"=>0.0000,
+                "amount_noded_return"=>0.0000,
+                "amount_private"=>0.0000
+            ),
+            "9"=>array
+                (
+                "jrn_def_name"=>"Frais Divers",
+                "tva_label"=>"EXPORT",
+                "tva_rate"=>0.0000,
+                "tva_both_side"=>0,
+                "qp_vat_code"=>6,
+                "amount_vat"=>0.0000,
+                "amount_wovat"=>259.8000,
+                "amount_sided"=>0.0000,
+                "amount_noded_amount"=>0.0000,
+                "amount_noded_tax"=>0.0000,
+                "amount_noded_return"=>0.0000,
+                "amount_private"=>0.0000
+            ),
+            "10"=>array
+                (
+                "jrn_def_name"=>"Frais Divers",
+                "tva_label"=>"IMMO",
+                "tva_rate"=>0.2100,
+                "tva_both_side"=>0,
+                "qp_vat_code"=>1002,
+                "amount_vat"=>319.2400,
+                "amount_wovat"=>1520.2000,
+                "amount_sided"=>0.0000,
+                "amount_noded_amount"=>0.0000,
+                "amount_noded_tax"=>0.0000,
+                "amount_noded_return"=>0.0000,
+                "amount_private"=>0.0000
+            ),
+            "11"=>array
+                (
+                "jrn_def_name"=>"Frais Divers",
+                "tva_label"=>"INTRA",
+                "tva_rate"=>0.0000,
+                "tva_both_side"=>0,
+                "qp_vat_code"=>5,
+                "amount_vat"=>0.0000,
+                "amount_wovat"=>1250.0000,
+                "amount_sided"=>0.0000,
+                "amount_noded_amount"=>0.0000,
+                "amount_noded_tax"=>0.0000,
+                "amount_noded_return"=>0.0000,
+                "amount_private"=>0.0000
+            ),
+            "12"=>array
+                (
+                "jrn_def_name"=>"Frais Divers",
+                "tva_label"=>"VOIT",
+                "tva_rate"=>0.2100,
+                "tva_both_side"=>0,
+                "qp_vat_code"=>1003,
+                "amount_vat"=>42.0000,
+                "amount_wovat"=>200.0000,
+                "amount_sided"=>0.0000,
+                "amount_noded_amount"=>0.0000,
+                "amount_noded_tax"=>0.0000,
+                "amount_noded_return"=>0.0000,
+                "amount_private"=>0.0000,
+            )
+        );
+        $nb_result=count($a_result);
+        $nb_array=count($array);
+        $this->assertEquals($nb_result, $nb_array);
+        $ix=0;
+        for ($i=0; $i<$nb_result; $i++)
+        {
+            $row=$a_result[$i];
+            for ($e=0; $e<$nb_array; $e++)
+            {
+                if (
+                        $row['qp_vat_code']==$array[$e]['qp_vat_code']
+                        && $row['jrn_def_name'] == $array[$e]["jrn_def_name"]
+                    )
+                {
+                    $this->assertEquals($row['amount_vat'], 
$array[$e]['amount_vat']
+                            ,sprintf("Code %s ",$row['qp_vat_code']));
+                    $this->assertEquals($row['amount_wovat'], 
$array[$e]['amount_wovat']
+                            ,sprintf("Code %s ",$row['qp_vat_code']));
+                    $this->assertEquals($row['amount_sided'], 
$array[$e]['amount_sided']
+                            ,sprintf("Code %s ",$row['qp_vat_code']));
+                    $this->assertEquals($row['amount_noded_amount'], 
$array[$e]['amount_noded_amount']
+                            ,sprintf("Code %s ",$row['qp_vat_code']));
+                    $this->assertEquals($row['amount_noded_tax'], 
$array[$e]['amount_noded_tax']
+                            ,sprintf("Code %s ",$row['qp_vat_code']));
+                    $this->assertEquals($row['amount_noded_return'], 
$array[$e]['amount_noded_return']
+                            ,sprintf("Code %s ",$row['qp_vat_code']));
+                    $this->assertEquals($row['amount_private'], 
$array[$e]['amount_private']
+                            ,sprintf("Code %s ",$row['qp_vat_code']));
+                    $ix++;
+                }
+            }
+        }
+        $this->assertEquals($nb_array, $ix, 'Not all VAT CODE found');
     }
+
     function testGet_row_sale()
     {
         $array=$this->object->get_row_sale();
-        $this->assertSame($array, [[
-                            'jrn_def_name' => 'Vente',
-                            'tva_label' => '21%',
-                            'qs_vat_code' => '1',
-                            'tva_rate' => '0.2100',
-                            'tva_both_side' => '0',
-                            'amount_vat' => '2254.8400',
-                            'amount_wovat' => '10737.3400',
-                            'amount_sided' => '0.0000'
-                            ]]);
-       
+        //-- For creating the array
+       //Noalyss\Facility::save_file(__DIR__."/file", 
"tax_summary_getrow_sale.txt", print_r($array, TRUE));
+        $a_result=array
+            (
+            "0"=>array
+                (
+                "jrn_def_name"=>"Vente",
+                "tva_label"=>"21%",
+                "qs_vat_code"=>1,
+                "tva_rate"=>0.2100,
+                "tva_both_side"=>0,
+                "amount_vat"=>219.5700,
+                "amount_wovat"=>1045.6000,
+                "amount_sided"=>0.0000
+            ),
+            "1"=>array
+                (
+                "jrn_def_name"=>"Vente",
+                "tva_label"=>"EXPORT",
+                "qs_vat_code"=>6,
+                "tva_rate"=>0.0000,
+                "tva_both_side"=>0,
+                "amount_vat"=>0.0000,
+                "amount_wovat"=>1047.9000,
+                "amount_sided"=>0.0000
+            ),
+            "2"=>array
+                (
+                "jrn_def_name"=>"Vente",
+                "tva_label"=>"INTRA",
+                "qs_vat_code"=>5,
+                "tva_rate"=>0.0000,
+                "tva_both_side"=>0,
+                "amount_vat"=>0.0000,
+                "amount_wovat"=>1800.0000,
+                "amount_sided"=>0.0000
+            ),
+            "3"=>array
+                (
+                "jrn_def_name"=>"Vente",
+                "tva_label"=>"VOIT",
+                "qs_vat_code"=>1003,
+                "tva_rate"=>0.2100,
+                "tva_both_side"=>0,
+                "amount_vat"=>8.4000,
+                "amount_wovat"=>40.0000,
+                "amount_sided"=>0.0000
+            ),
+            "4"=>Array
+                (
+                "jrn_def_name"=>"Vente différée",
+                "tva_label"=>"EXPORT",
+                "qs_vat_code"=>6,
+                "tva_rate"=>0.0000,
+                "tva_both_side"=>0,
+                "amount_vat"=>0.0000,
+                "amount_wovat"=>150.5600,
+                "amount_sided"=>0.0000
+            )
+        );
+        $nb_result=count($a_result);
+        $nb_array=count($array);
+        $this->assertEquals($nb_result, $nb_array);
+        $ix=0;
+        for ($i=0; $i<$nb_result; $i++)
+        {
+            $row=$a_result[$i];
+            for ($e=0; $e<$nb_array; $e++)
+            {
+                if (
+                        
$row['qs_vat_code']==$array[$e]['qs_vat_code']&&$row['jrn_def_name']==$array[$e]["jrn_def_name"]
+                )
+                {
+                    $this->assertEquals($row['amount_vat'], 
$array[$e]['amount_vat']
+                            , sprintf("Code %s ", $row['qs_vat_code']));
+                    $this->assertEquals($row['amount_wovat'], 
$array[$e]['amount_wovat']
+                            , sprintf("Code %s ", $row['qs_vat_code']));
+                    $this->assertEquals($row['amount_sided'], 
$array[$e]['amount_sided']
+                            , sprintf("Code %s ", $row['qs_vat_code']));
+                    $ix++;
+                }
+            }
+        }
+        $this->assertEquals($nb_array, $ix, 'Not all VAT CODE found');
     }
+
     function testget_summary_purchase()
     {
         $array=$this->object->get_summary_purchase();
-        $this->assertSame($array,[[
-                'tva_label' => '0%'
-                 ,'tva_rate' => '0.0000'
-                    ,'tva_both_side' => '0'
-                    ,'qp_vat_code' => '4'
-                    ,'amount_vat' => '0.0000'
-                    ,'amount_wovat' => '658.2500'
-                    ,'amount_sided' => '0.0000'
-                    ,'amount_noded_amount' => '0.0000'
-                    ,'amount_noded_tax' => '0.0000'
-                    ,'amount_noded_return' => '0.0000'
-                    ,'amount_private' => '0.0000'
-                        ],[
-                            'tva_label' => '12%'
-                    ,'tva_rate' => '0.1200'
-                    ,'tva_both_side' => '0'
-                    ,'qp_vat_code' => '2'
-                    ,'amount_vat' => '84.2200'
-                    ,'amount_wovat' => '701.7800'
-                    ,'amount_sided' => '0.0000'
-                    ,'amount_noded_amount' => '0.0000'
-                    ,'amount_noded_tax' => '0.0000'
-                    ,'amount_noded_return' => '0.0000'
-                    ,'amount_private' => '0.0000'
-            ]]);
-
+        //-- For creating the array
+        // \Noalyss\Facility::save_file(__DIR__."/file", 
"tax_summary_summary_purchase.txt", print_r($array, TRUE));
+        $a_result=array
+            (
+            "0"=>array
+                (
+                "tva_label"=>"0%",
+                "tva_rate"=>0.0000,
+                "tva_both_side"=>0,
+                "qp_vat_code"=>4,
+                "amount_vat"=>0.0000,
+                "amount_wovat"=>658.2500,
+                "amount_sided"=>0.0000,
+                "amount_noded_amount"=>0.0000,
+                "amount_noded_tax"=>0.0000,
+                "amount_noded_return"=>0.0000,
+                "amount_private"=>0.0000
+            ),
+            "1"=>array
+                (
+                "tva_label"=>"12%",
+                "tva_rate"=>0.1200,
+                "tva_both_side"=>0,
+                "qp_vat_code"=>2,
+                "amount_vat"=>109.8000,
+                "amount_wovat"=>915.0000,
+                "amount_sided"=>0.0000,
+                "amount_noded_amount"=>0.0000,
+                "amount_noded_tax"=>0.0000,
+                "amount_noded_return"=>0.0000,
+                "amount_private"=>0.0000
+            ),
+            "2"=>array
+                (
+                "tva_label"=>"21%",
+                "tva_rate"=>0.2100,
+                "tva_both_side"=>0,
+                "qp_vat_code"=>1,
+                "amount_vat"=>250.6500,
+                "amount_wovat"=>1193.5400,
+                "amount_sided"=>0.0000,
+                "amount_noded_amount"=>0.0000,
+                "amount_noded_tax"=>0.0000,
+                "amount_noded_return"=>0.0000,
+                "amount_private"=>0.0000
+            ),
+            "3"=>array
+                (
+                "tva_label"=>"6%",
+                "tva_rate"=>0.0600,
+                "tva_both_side"=>0,
+                "qp_vat_code"=>3,
+                "amount_vat"=>5.2800,
+                "amount_wovat"=>88.3200,
+                "amount_sided"=>0.0000,
+                "amount_noded_amount"=>0.0000,
+                "amount_noded_tax"=>0.0000,
+                "amount_noded_return"=>0.0000,
+                "amount_private"=>0.0000
+            ),
+            "4"=>array
+                (
+                "tva_label"=>"ART44",
+                "tva_rate"=>0.0000,
+                "tva_both_side"=>0,
+                "qp_vat_code"=>8,
+                "amount_vat"=>0.0000,
+                "amount_wovat"=>315.2000,
+                "amount_sided"=>0.0000,
+                "amount_noded_amount"=>0.0000,
+                "amount_noded_tax"=>0.0000,
+                "amount_noded_return"=>0.0000,
+                "amount_private"=>0.0000
+            ),
+            "5"=>array
+                (
+                "tva_label"=>"EXPORT",
+                "tva_rate"=>0.0000,
+                "tva_both_side"=>0,
+                "qp_vat_code"=>6,
+                "amount_vat"=>0.0000,
+                "amount_wovat"=>546.7500,
+                "amount_sided"=>0.0000,
+                "amount_noded_amount"=>0.0000,
+                "amount_noded_tax"=>0.0000,
+                "amount_noded_return"=>0.0000,
+                "amount_private"=>0.0000
+            ),
+            "6"=>array
+                (
+                "tva_label"=>"IMMO",
+                "tva_rate"=>0.2100,
+                "tva_both_side"=>0,
+                "qp_vat_code"=>1002,
+                "amount_vat"=>638.4800,
+                "amount_wovat"=>3040.4000,
+                "amount_sided"=>0.0000,
+                "amount_noded_amount"=>0.0000,
+                "amount_noded_tax"=>0.0000,
+                "amount_noded_return"=>0.0000,
+                "amount_private"=>0.0000
+            ),
+            "7"=>array
+                (
+                "tva_label"=>"INTRA",
+                "tva_rate"=>0.0000,
+                "tva_both_side"=>0,
+                "qp_vat_code"=>5,
+                "amount_vat"=>0.0000,
+                "amount_wovat"=>1250.0000,
+                "amount_sided"=>0.0000,
+                "amount_noded_amount"=>0.0000,
+                "amount_noded_tax"=>0.0000,
+                "amount_noded_return"=>0.0000,
+                "amount_private"=>0.0000
+            ),
+            "8"=>array
+                (
+                "tva_label"=>"VOIT",
+                "tva_rate"=>0.2100,
+                "tva_both_side"=>0,
+                "qp_vat_code"=>1003,
+                "amount_vat"=>63.0000,
+                "amount_wovat"=>300.0000,
+                "amount_sided"=>0.0000,
+                "amount_noded_amount"=>0.0000,
+                "amount_noded_tax"=>0.0000,
+                "amount_noded_return"=>0.0000,
+                "amount_private"=>0.0000
+            )
+        );
+        $nb_result=count($a_result);
+        $nb_array=count($array);
+        $this->assertEquals($nb_result, $nb_array);
+        $ix=0;
+        for ($i=0; $i<$nb_result; $i++)
+        {
+            $row=$a_result[$i];
+            for ($e=0; $e<$nb_array; $e++)
+            {
+                if ($row['qp_vat_code']==$array[$e]['qp_vat_code'])
+                {
+                    $this->assertEquals($row['amount_vat'], 
$array[$e]['amount_vat']
+                            ,sprintf("Code %s ",$row['qp_vat_code']));
+                    $this->assertEquals($row['amount_wovat'], 
$array[$e]['amount_wovat']
+                            ,sprintf("Code %s ",$row['qp_vat_code']));
+                    $this->assertEquals($row['amount_sided'], 
$array[$e]['amount_sided']
+                            ,sprintf("Code %s ",$row['qp_vat_code']));
+                    $this->assertEquals($row['amount_noded_amount'], 
$array[$e]['amount_noded_amount']
+                            ,sprintf("Code %s ",$row['qp_vat_code']));
+                    $this->assertEquals($row['amount_noded_tax'], 
$array[$e]['amount_noded_tax']
+                            ,sprintf("Code %s ",$row['qp_vat_code']));
+                    $this->assertEquals($row['amount_noded_return'], 
$array[$e]['amount_noded_return']
+                            ,sprintf("Code %s ",$row['qp_vat_code']));
+                    $this->assertEquals($row['amount_private'], 
$array[$e]['amount_private']
+                            ,sprintf("Code %s ",$row['qp_vat_code']));
+                    $ix++;
+                }
+            }
+        }
+        $this->assertEquals($nb_array, $ix, 'Not all VAT CODE found');
     }
+
     function testget_summary_sale()
     {
         $array=$this->object->get_summary_sale();
-         $this->assertSame($array, [[
-                            'tva_label' => '21%',
-                            'qs_vat_code' => '1',
-                            'tva_rate' => '0.2100',
-                            'tva_both_side' => '0',
-                            'amount_vat' => '2254.8400',
-                            'amount_wovat' => '10737.3400',
-                            'amount_sided' => '0.0000'
-                            ]]);
+        //-- For creating the array
+        // Noalyss\Facility::save_file(__DIR__."/file", 
"tax_summary_summary_sale.txt", print_r($array, TRUE));
+
+        $a_result=array
+            (
+            array
+                (
+                "tva_label"=>"21%",
+                "qs_vat_code"=>1,
+                "tva_rate"=>0.2100,
+                "tva_both_side"=>0,
+                "amount_vat"=>219.5700,
+                "amount_wovat"=>1045.6000,
+                "amount_sided"=>0.0000
+            ),
+            array
+                (
+                "tva_label"=>"EXPORT",
+                "qs_vat_code"=>6,
+                "tva_rate"=>0.0000,
+                "tva_both_side"=>0,
+                "amount_vat"=>0.0000,
+                "amount_wovat"=>1198.4600,
+                "amount_sided"=>0.0000
+            ),
+            array
+                (
+                "tva_label"=>"INTRA",
+                "qs_vat_code"=>5,
+                "tva_rate"=>0.0000,
+                "tva_both_side"=>0,
+                "amount_vat"=>0.0000,
+                "amount_wovat"=>1800.0000,
+                "amount_sided"=>0.0000
+            ),
+            array
+                (
+                "tva_label"=>"VOIT",
+                "qs_vat_code"=>1003,
+                "tva_rate"=>0.2100,
+                "tva_both_side"=>0,
+                "amount_vat"=>8.4000,
+                "amount_wovat"=>40.0000,
+                "amount_sided"=>0.0000
+            )
+        );
+        $nb_result=count($a_result);
+        $nb_array=count($array);
+        $this->assertEquals($nb_result, $nb_array);
+        $ix=0;
+        for ($i=0; $i<$nb_result; $i++)
+        {
+            $row=$a_result[$i];
+            for ($e=0; $e<$nb_array; $e++)
+            {
+                if ($row['qs_vat_code']==$array[$e]['qs_vat_code'])
+                {
+                    $this->assertEquals($row['amount_vat'], 
$array[$e]['amount_vat']
+                            ,sprintf("Code %s ",$row['qs_vat_code']));
+                    $this->assertEquals($row['amount_wovat'], 
$array[$e]['amount_wovat']
+                            ,sprintf("Code %s ",$row['qs_vat_code']));
+                    $this->assertEquals($row['amount_sided'], 
$array[$e]['amount_sided']
+                            ,sprintf("Code %s ",$row['qs_vat_code']));
+                    $ix++;
+                }
+            }
+        }
+        $this->assertEquals($nb_array, $ix, 'Not all VAT CODE found');
     }
-    
-}
\ No newline at end of file
+
+}



reply via email to

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