From 2f0207f93b5932f2c5511661056c236aa8b45577 Mon Sep 17 00:00:00 2001 From: Dany De Bontridder Date: Sat, 2 Nov 2019 22:55:16 +0100 Subject: [PATCH 01/19] TEST fix bug in acc_balanceTest --- .../include/class/acc_balanceTest.class.php | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/unit-test/include/class/acc_balanceTest.class.php b/unit-test/include/class/acc_balanceTest.class.php index c54860537..5f8193707 100644 --- a/unit-test/include/class/acc_balanceTest.class.php +++ b/unit-test/include/class/acc_balanceTest.class.php @@ -63,8 +63,10 @@ class Acc_BalanceTest extends TestCase $this->object->jrn=1; $this->object->filter_cat(array()); $this->assertEquals($this->object->jrn,null); - $this->object->filter_cat(array('FIN')); - $this->assertEquals($this->object->jrn[0],2); + $this->object->filter_cat(array('2'=>'FIN')); + $this->assertEquals($this->object->jrn,[1]); + $this->object->filter_cat(array('1'=>'ACH','2'=>'FIN')); + $this->assertEquals($this->object->jrn,[3,35,1]); } /** *@covers Acc_Balance::summary_add @@ -102,15 +104,7 @@ class Acc_BalanceTest extends TestCase } - /** - *@covers Acc_Balance::summary_add - */ - public function testSummary_display_pdf() - { - // No test since a PDF is modified and cannot be tested - // by PHPUNIT - $this->markTestSkipped("Summary_display_pdf cannot be tested since it modify a PDF"); - } + /** *@covers Acc_Balance::summary_init */ From 1df3a3a60e03cf9a8313206d03e831a53dc6acbe Mon Sep 17 00:00:00 2001 From: Dany De Bontridder Date: Sat, 2 Nov 2019 22:56:04 +0100 Subject: [PATCH 02/19] Documentation --- include/class/acc_balance.class.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/include/class/acc_balance.class.php b/include/class/acc_balance.class.php index d2ecc88ca..6fbf2fc36 100644 --- a/include/class/acc_balance.class.php +++ b/include/class/acc_balance.class.php @@ -298,8 +298,9 @@ class Acc_Balance } /** - * set the $this->jrn to the cat - * @todo Cette function semble ne pas fonctionner correctement + * set the $this->jrn to the cat, filter the ledger thanks the type (key in the array) + * @param array of integer 0->Sale,1->Purchase,2->Financial,3->ODS + * @see Acc_Ledgger::array_cat */ function filter_cat($p_array) { From 5715a582f86c2d97a166b24e575f8f8876707907 Mon Sep 17 00:00:00 2001 From: Dany De Bontridder Date: Wed, 27 Nov 2019 22:19:57 +0100 Subject: [PATCH 03/19] Acc_Ledger_Search , fix small bug + Test file --- include/class/acc_ledger_search.class.php | 30 ++-- include/export/export_histo_csv.php | 5 +- include/template/ledger_search.php | 2 +- .../include/class/acc_ledger_search.Test.php | 133 ++++++++++++++++++ 4 files changed, 156 insertions(+), 14 deletions(-) create mode 100644 unit-test/include/class/acc_ledger_search.Test.php diff --git a/include/class/acc_ledger_search.class.php b/include/class/acc_ledger_search.class.php index 9ffc29292..12ba84e18 100644 --- a/include/class/acc_ledger_search.class.php +++ b/include/class/acc_ledger_search.class.php @@ -19,8 +19,7 @@ */ // Copyright (2016) Author Dany De Bontridder -if (!defined('ALLOWED')) - die('Appel direct ne sont pas permis'); +// if (!defined('ALLOWED')) die('Appel direct ne sont pas permis'); /** * @file @@ -36,8 +35,8 @@ class Acc_Ledger_Search /** * @brief return a HTML string with the form for the search - * @param $p_type if the type of ledger possible values=ALL,VEN,ACH,ODS,FIN - * @param $all_type_ledger + * @param $p_type if the type of ledger possible values=ALL,VEN,ACH,ODS,FIN: uppercase ! + * @param $all_type_ledger * values : * - 1 means all the ledger of this type * - 0 No have the "Tous les journaux" availables @@ -50,7 +49,7 @@ class Acc_Ledger_Search function __construct($p_type, $p_all=1, $p_div="") { $this->cn=Dossier::connect(); - $this->type=$p_type; + $this->set_type($p_type); $this->all=$p_all; $this->div=$p_div; } @@ -72,6 +71,10 @@ class Acc_Ledger_Search public function set_type($type) { + if (! in_array($type, ["ALL","VEN","ACH","ODS","FIN"])) + { + throw new Exception ("ALS02 : type invalide $type",EXC_PARAM_VALUE); + } $this->type=$type; } @@ -265,7 +268,7 @@ class Acc_Ledger_Search * @brief this function will create a sql stmt to use to create the list for * the ledger, * @param $p_array is usually the $_GET, - * @param $p_order the order of the row + * @param $p_order the order of the row --> not used * @param $p_where is the sql condition if not null then the $p_array will not be used * \note the p_action will be used to filter the ledger but gl means ALL * struct array $p_array @@ -407,7 +410,7 @@ class Acc_Ledger_Search $and=''; $g_user=new User($this->cn); - $p_action=$ledger_type; + $p_action=(isset ($ledger_type)) ? $ledger_type:$this->type; if ($p_action=='') $p_action='ALL'; if ($r_jrn==-1) @@ -571,6 +574,8 @@ class Acc_Ledger_Search $where=$fil_ledger.$fil_amount.$fil_date.$fil_desc.$fil_sec.$fil_amount. $fil_qcode.$fil_paid.$fil_account.$fil_date_paid.$fil_hide_operation; $sql.=" where ".$where; + + // Q?? Why do we return where if it is included in SQL ? return array($sql, $where); } @@ -583,6 +588,7 @@ class Acc_Ledger_Search */ function display_search_form() { + $http=new HttpInput(); $r=''; $r.='