[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Noalyss-commit] [noalyss] 04/04: Test for Acc_Ledger_Search for tva_sea
From: |
dwm |
Subject: |
[Noalyss-commit] [noalyss] 04/04: Test for Acc_Ledger_Search for tva_search_id |
Date: |
Thu, 27 Jul 2023 14:23:32 -0400 (EDT) |
sparkyx pushed a commit to branch devel
in repository noalyss.
commit 9cfb489c419caf1944515bb541223e60d2658d2a
Author: sparkyx <danydb@noalyss.eu>
AuthorDate: Tue Jul 25 19:29:38 2023 +0200
Test for Acc_Ledger_Search for tva_search_id
---
unit-test/include/class/acc_ledger_searchTest.php | 108 +++++++++++++++++++++-
1 file changed, 107 insertions(+), 1 deletion(-)
diff --git a/unit-test/include/class/acc_ledger_searchTest.php
b/unit-test/include/class/acc_ledger_searchTest.php
index f4c3be247..6d9b1f8a5 100644
--- a/unit-test/include/class/acc_ledger_searchTest.php
+++ b/unit-test/include/class/acc_ledger_searchTest.php
@@ -89,10 +89,11 @@ class Acc_Ledger_searchTest extends TestCase
$r=$ledger->display_search_form();
\Noalyss\Facility::save_file(__DIR__."/file",
"acc_ledger_search-test_display_search_form.html", $r);
$filesize=strlen($r);
- $this->assertTrue($filesize==9685||$filesize==9678,"Size of the html
string for display_search_form see "
+ $this->assertTrue($filesize==10332||$filesize==9678,"Size of the html
string for display_search_form see "
.
__DIR__."/file/acc_ledger_search-test_display_search_form.html ");
}
/**
+ * @testdox Build the search filter
* @covers ::build_search_filter
*/
function test_build_search_filter()
@@ -132,4 +133,109 @@ class Acc_Ledger_searchTest extends TestCase
$this->assertEquals($ret,$result,"Build filter for ODS");
}
+ /**
+ * @testdox Build the SQL and where clause : no condition
+ * @covers ::build_search_sql
+ */
+ public function testBuild_search_sql_nocondition()
+ {
+ global $g_connection;
+ $ledger=new Acc_Ledger_Search('ALL');
+ $result=$ledger->build_search_sql([]);
+
+ $this->assertEquals(" jrn_def_id in (3,83,152,1,35,4,2,36,-1) and
jr_date >= to_date('02.01.2019','DD.MM.YYYY') and jr_date <=
to_date('31.01.2019','DD.MM.YYYY')",$result[1],"Filter on date incorrect");
+ $row=$g_connection->get_array($result[0]);
+ $this->assertEquals(4,count($row),"wrong number on row found");
+
+
+ }
+ /**
+ * @testdox Build the SQL and where clause : conditon on amount
+ * @covers ::build_search_sql
+ */
+ public function testBuild_search_sql_amount()
+ {
+ global $g_connection;
+ $ledger=new Acc_Ledger_Search('ALL');
+
$result=$ledger->build_search_sql(['amount_min'=>150,'amount_max'=>200]);
+
+ $this->assertEquals(" jrn_def_id in (3,83,152,1,35,4,2,36,-1) and
jr_montant >=150 and jr_montant <=200",$result[1],"Filter incorrect");
+ $row=$g_connection->get_array($result[0]);
+ $this->assertEquals(13,count($row),"wrong number on row found");
+ foreach ($row as $row_item) {
+ $this->assertTrue(
+ $row_item['jr_montant']>=150
+ && $row_item['jr_montant'] <= 200,
+ " Filter on amount failed found {$row_item['jr_montant']} ");
+ }
+
+ }
+ /**
+ * @testdox Build the SQL and where clause : conditon on accounting
+ * @covers ::build_search_sql
+ */
+ public function testBuild_search_sql_account()
+ {
+ global $g_connection;
+ $ledger=new Acc_Ledger_Search('ALL');
+ $result=$ledger->build_search_sql(["accounting"=>"40"]);
+
+ $result[1]=str_replace([" ","\n"],"",$result[1]);
+ $expected=str_replace ([" ","\n"],"","jrn_def_id in
(3,83,152,1,35,4,2,36,-1) and jr_date >= to_date('02.01.2019','DD.MM.YYYY')
and jr_date <= to_date('31.01.2019','DD.MM.YYYY') and jr_grpt_id in (select
j_grpt from jrnx where j_poste::text like '40%' )");
+
+ $this->assertEquals($expected,$result[1],"Filter incorrect");
+ $row=$g_connection->get_array($result[0]);
+ $this->assertEquals(2,count($row),"wrong number on row found");
+
+ }
+
+ /**
+ * @testdox Build the SQL and where clause : conditon on card
+ * @covers ::build_search_sql
+ */
+ public function testBuild_search_sql_card()
+ {
+ global $g_connection;
+ $ledger=new Acc_Ledger_Search('ALL');
+ $result=$ledger->build_search_sql(["qcode"=>"FOURNI1"]);
+
+ $result[1]=str_replace([" ","\n"],"",$result[1]);
+ $expected=str_replace ([" "],"","jrn_def_id in
(3,83,152,1,35,4,2,36,-1) and jr_date >= to_date('02.01.2019','DD.MM.YYYY')
and jr_date <= to_date('31.01.2019','DD.MM.YYYY') and jr_grpt_id in ( select
j_grpt fromjrnx where trim(j_qcode) = upper(trim('FOURNI1')))");
+
+ $this->assertEquals($expected,$result[1],"Filter incorrect");
+ $row=$g_connection->get_array($result[0]);
+ $this->assertEquals(1,count($row),"wrong number on row found");
+
+ }
+ /**
+ * @testdox Build the SQL and where clause : conditon on TVA id between
01.01.2010 and 31.12.2019
+ * @covers ::build_search_sql
+ */
+ public function testBuild_search_sql_TVA()
+ {
+ global $g_connection;
+ $ledger=new Acc_Ledger_Search('ALL');
+ $result=$ledger->build_search_sql(["tva_id_search"=>"1"
+ ,"amount_min"=>0
+ ,"amount_max"=>0
+ ,"date_start"=>"01.01.2010"
+ ,"date_end"=>"31.12.2019"]);
+
+ $result[1]=str_replace([" ","\n"],"",$result[1]);
+ $expected=str_replace ([" ","\n"],""," jrn_def_id in
(3,83,152,1,35,4,2,36,-1) and jr_date >= to_date('01.01.2010','DD.MM.YYYY')
and jr_date <= to_date('31.12.2019','DD.MM.YYYY') and jr_internal in
+ ( select distinct qp_internal
+ from quant_purchase
+ where qp_vat_code=1 union all
+ select distinct qs_internal
+ from quant_sold
+ where qs_vat_code=1)
+
+");
+
+ $this->assertEquals($expected,$result[1],"Filter incorrect");
+ $row=$g_connection->get_array($result[0]);
+ $this->assertEquals(18,count($row),"wrong number on row found");
+
+ }
+
}