';
$r.=HtmlInput::title_box(_('Recherche'), "search_form", "hide", "", "n");
@@ -597,18 +648,18 @@ class Acc_Ledger_Search
- $r.=HtmlInput::hidden('ac', $_REQUEST['ac']);
+ $r.=HtmlInput::hidden('ac', $http->request('ac'));
/* when called from commercial.php some hidden values are needed */
if (isset($_REQUEST['sa']))
- $r.=HtmlInput::hidden("sa", $_REQUEST['sa']);
+ $r.=HtmlInput::hidden("sa", $http->request('sa'));
if (isset($_REQUEST['sb']))
- $r.=HtmlInput::hidden("sb", $_REQUEST['sb']);
+ $r.=HtmlInput::hidden("sb", $http->request('sb'));
if (isset($_REQUEST['sc']))
- $r.=HtmlInput::hidden("sc", $_REQUEST['sc']);
+ $r.=HtmlInput::hidden("sc", $http->request('sc'));
if (isset($_REQUEST['f_id']))
- $r.=HtmlInput::hidden("f_id", $_REQUEST['f_id']);
+ $r.=HtmlInput::hidden("f_id", $http->request('f_id'));
@@ -1063,7 +1114,7 @@ class Acc_Ledger_Search
}
$r.="
";
- $r.=( $positive!=0 )?" - ".nbm($row['jr_montant'])."":nbm($row['jr_montant']);
+ $r.=( $positive!=0 )?" - ".nbm($row['total_invoice'])."":nbm($row['total_invoice']);
$r.=" | ";
diff --git a/include/class/acc_ledger_sold.class.php b/include/class/acc_ledger_sold.class.php
index eeb0fcbd7..b4c807738 100644
--- a/include/class/acc_ledger_sold.class.php
+++ b/include/class/acc_ledger_sold.class.php
@@ -361,6 +361,7 @@ class Acc_Ledger_Sold extends Acc_Ledger {
$l = new Acc_Tva($this->db, $idx_tva);
$l->load();
$tva_item_currency = bcmul($amount, $l->get_parameter('rate'));
+ $tva_item=round($tva_item,2);
}
$tva_item=bcdiv($tva_item_currency,$p_currency_rate);
$tva_item=round($tva_item,2);
diff --git a/include/class/anc_account_table.class.php b/include/class/anc_account_table.class.php
index a1beb3942..d92b0f909 100644
--- a/include/class/anc_account_table.class.php
+++ b/include/class/anc_account_table.class.php
@@ -28,7 +28,7 @@ if (!defined('ALLOWED'))
*
*/
/**
- * @class
+ * @class Anc_Account_Table
* @brief derived from Manage_Table_SQL ,
*/
require_once NOALYSS_INCLUDE."/lib/manage_table_sql.class.php";
@@ -90,4 +90,4 @@ class Anc_Account_Table extends Manage_Table_SQL
if ($is_error==0)return TRUE;
return FALSE;
}
-}
\ No newline at end of file
+}
diff --git a/include/class/anc_balance_double.class.php b/include/class/anc_balance_double.class.php
index 0851e5bb6..f2cb55d21 100644
--- a/include/class/anc_balance_double.class.php
+++ b/include/class/anc_balance_double.class.php
@@ -32,7 +32,7 @@ require_once NOALYSS_INCLUDE.'/class/anc_print.class.php';
require_once NOALYSS_INCLUDE.'/class/anc_plan.class.php';
require_once NOALYSS_INCLUDE.'/class/pdf.class.php';
/**
- * @class
+ * @class Anc_Balance_Double
* @brief Print the crossed balance between 2 plan
*
*/
diff --git a/include/class/package_plugin.class.php b/include/class/package_plugin.class.php
index 2a6ddc7d4..5d89b38d0 100644
--- a/include/class/package_plugin.class.php
+++ b/include/class/package_plugin.class.php
@@ -26,7 +26,7 @@
require_once NOALYSS_INCLUDE."/class/package_noalyss.class.php";
/**
- * @class
+ * @class Package_Plugin
* @brief Manage the installation of plug
*/
class Package_Plugin extends Package_Noalyss
diff --git a/include/class/template_card_category.class.php b/include/class/template_card_category.class.php
index ee2e743c8..fc8be4d71 100644
--- a/include/class/template_card_category.class.php
+++ b/include/class/template_card_category.class.php
@@ -28,7 +28,7 @@ require_once NOALYSS_INCLUDE.'/database/fiche_def_ref_sql.class.php';
*/
/**
- * @class
+ * @class Template_Card_Category
* @brief Manage the template of card category
*/
class Template_Card_Category extends Manage_Table_SQL
diff --git a/include/class/tva_rate_mtable.class.php b/include/class/tva_rate_mtable.class.php
index 4ffba15ac..403f513ab 100644
--- a/include/class/tva_rate_mtable.class.php
+++ b/include/class/tva_rate_mtable.class.php
@@ -29,7 +29,7 @@ require_once NOALYSS_INCLUDE."/database/v_tva_rate_sql.class.php";
require_once NOALYSS_INCLUDE."/database/tva_rate_sql.class.php";
/**
- * @class
+ * @class Tva_Rate_MTable
* @brief Configure the tva : code , rate, label ...
* When using Manage_Table_SQL
*/
diff --git a/include/export/export_fiche_balance_csv.php b/include/export/export_fiche_balance_csv.php
index 6a87bebc1..7cdb97bf2 100644
--- a/include/export/export_fiche_balance_csv.php
+++ b/include/export/export_fiche_balance_csv.php
@@ -181,13 +181,13 @@ else
if ($row['j_debit'] == 't')
{
$export->add($row['j_montant'],"number");
- $export->add("");
+ $export->add(0,"number");
$amount_deb=bcadd($amount_deb,$row['j_montant']);
$prog = bcadd($prog, $row['j_montant']);
}
else
{
- $export->add("");
+ $export->add(0,"number");
$export->add($row['j_montant'],"number");
$amount_cred=bcadd($amount_cred,$row['j_montant']);
$prog = bcsub($prog, $row['j_montant']);
diff --git a/include/export/export_fiche_csv.php b/include/export/export_fiche_csv.php
index d178ab9fc..a03e14635 100644
--- a/include/export/export_fiche_csv.php
+++ b/include/export/export_fiche_csv.php
@@ -30,6 +30,7 @@ require_once NOALYSS_INCLUDE.'/lib/noalyss_csv.class.php';
$gDossier=dossier::id();
$cn=Dossier::connect();
+$http=new HttpInput();
require_once NOALYSS_INCLUDE.'/class/user.class.php';
@@ -40,7 +41,7 @@ $export->send_header();
if ( isset ($_GET['fd_id']))
{
- $fiche_def=new Fiche_Def($cn,$_GET ['fd_id']);
+ $fiche_def=new Fiche_Def($cn,$http->get('fd_id',"number"));
$fiche=new Fiche($cn);
$e=$fiche_def->get_by_type();
$o=0;
diff --git a/include/export/export_gl_csv.php b/include/export/export_gl_csv.php
index a908c9a97..0a23f8f49 100644
--- a/include/export/export_gl_csv.php
+++ b/include/export/export_gl_csv.php
@@ -22,7 +22,7 @@
/*! \file
* \brief create GL comptes as CSV.
* Argument $_GET
- * @code
+ @code
* Array
(
[gDossier] => 10104
@@ -35,7 +35,7 @@
[from_poste] =>
[to_poste] =>
)
- * @encode
+@encode
*/
if ( ! defined ('ALLOWED') ) die('Appel direct ne sont pas permis');
diff --git a/include/export/export_histo_csv.php b/include/export/export_histo_csv.php
index 847ceaebe..251fe0fe8 100644
--- a/include/export/export_histo_csv.php
+++ b/include/export/export_histo_csv.php
@@ -26,7 +26,10 @@ if ( ! defined ('ALLOWED') ) die('Appel direct ne sont pas permis');
require_once NOALYSS_INCLUDE.'/lib/noalyss_csv.class.php';
require_once NOALYSS_INCLUDE.'/class/acc_ledger_search.class.php';
-$ledger=new Acc_Ledger_Search($cn,0);
+$http=new HttpInput();
+
+$ledger=new Acc_Ledger_Search($http->get("ledger_type"),0);
+
list($sql,$where)=$ledger->build_search_sql($_GET);
$order=" order by jr_date_order asc,substring(jr_pj_number,'[0-9]+$')::numeric asc ";
diff --git a/include/history_operation.inc.php b/include/history_operation.inc.php
index 6a64386f2..e1ab03296 100644
--- a/include/history_operation.inc.php
+++ b/include/history_operation.inc.php
@@ -128,7 +128,8 @@ echo dossier::hidden();
list($count, $html) = $Ledger->list_operation($sql, $offset, $ask_pay);
echo $html;
echo $bar;
-$r = HtmlInput::get_to_hidden(array('search_opnb_jrn',
+$r = HtmlInput::get_to_hidden(array('search_opnb_jrn',
+ 'operation_filter',
'search_opqcode',
'l',
'date_start',
@@ -154,7 +155,7 @@ if (isset($_GET['r_jrn']))
}
if (isset($_GET['search_opr_jrn']))
{
- $a_search_opr_jrn=$http->get('search_opr_jrn','array');
+ $a_search_opr_jrn=$http->get('search_opr_jrn');
foreach ($a_search_opr_jrn as $k => $v)
if (isNumber($v)) $r.=HtmlInput::hidden('r_jrn[' . $k . ']', $v);
}
@@ -168,8 +169,8 @@ echo '';
* Export to csv
*/
$r = HtmlInput::get_to_hidden(array('l', 'date_paid_start','date_paid_end',
- 'date_start', 'date_end', 'desc', 'amount_min', 'amount_max', 'qcode',
- 'accounting', 'unpaid', 'gDossier', 'ledger_type', 'p_action'));
+ 'date_start', 'date_end', 'desc', 'amount_min', 'amount_max', 'qcode','operation_filter',
+ 'accounting', 'unpaid', 'gDossier', 'ledger_type', 'p_action'));
if (isset($_GET['search_opr_jrn']))
{
foreach ($a_search_opr_jrn as $k => $v)
diff --git a/include/lib/http_input.class.php b/include/lib/http_input.class.php
index 68d9648d1..60b03a103 100644
--- a/include/lib/http_input.class.php
+++ b/include/lib/http_input.class.php
@@ -34,13 +34,36 @@ class HttpInput
{
private $array;
+ private $empty; //!< if empty that replace by $empty
function _construct()
{
$this->array=null;
+ $this->empty="";
+ }
+ public function get_array()
+ {
+ return $this->array;
}
- /**
+ public function get_empty()
+ {
+ return $this->empty;
+ }
+
+ public function set_array($array)
+ {
+ $this->array=$array;
+ return $this;
+ }
+ // $empty replace the empty value
+ public function set_empty($empty)
+ {
+ $this->empty=$empty;
+ return $this;
+ }
+
+ /**
* Check the type of the value
* @param $p_name name of the variable
* @param $p_type type of the variable (number,string,date,array)
@@ -53,10 +76,17 @@ class HttpInput
{
// no check on string
if ($p_type=="string")
+ {
return;
+ }
// Check if number
else if ($p_type=="number")
{
+ if (trim($this->array[$p_name]) == "")
+ {
+ $this->array[$p_name]=$this->empty;
+ }
+
if ( isNumber($this->array[$p_name])==0 )
{
throw new Exception(_("Type invalide")."[ $p_name ] = {$this->array[$p_name]}"
@@ -67,6 +97,10 @@ class HttpInput
// Check if date dd.mm.yyyy
else if ($p_type=="date")
{
+ if (trim($this->array[$p_name]) == "" )
+ {
+ $this->array[$p_name]=$this->empty;
+ }
if (isDate($this->array[$p_name]) <> $this->array[$p_name])
{
throw new Exception(_("Type invalide")."[ $p_name ] = {$this->array[$p_name]}"
@@ -76,6 +110,10 @@ class HttpInput
}
else if ($p_type=="array")
{
+ if ( empty($this->array[$p_name]) )
+ {
+ $this->array[$p_name]=$this->empty;
+ }
if (!is_array($this->array[$p_name]) ) {
throw new Exception(_("Type invalide")."[ $p_name ] = {$this->array[$p_name]}"
, EXC_PARAM_TYPE);
diff --git a/include/lib/inplace_edit.class.php b/include/lib/inplace_edit.class.php
index 391375744..0d372de17 100644
--- a/include/lib/inplace_edit.class.php
+++ b/include/lib/inplace_edit.class.php
@@ -25,7 +25,7 @@
* @brief Inplace_edit class for ajax update of HtmlInput object
*/
/**
- * @class
+ * @class Inplace_Edit
* @brief Inplace_edit class for ajax update of HtmlInput object.
* You need an ajax to response and modify the data. Some parameters will be sent
* by default when you click on the element
@@ -205,4 +205,4 @@ EOF;
function set_message($p_str) {
$this->message=$p_str;
}
-}
\ No newline at end of file
+}
diff --git a/include/lib/user_menu.php b/include/lib/user_menu.php
index 6444cb3c7..2f33dca4f 100644
--- a/include/lib/user_menu.php
+++ b/include/lib/user_menu.php
@@ -27,11 +27,10 @@ require_once NOALYSS_INCLUDE.'/lib/idate.class.php';
require_once NOALYSS_INCLUDE.'/lib/icard.class.php';
require_once NOALYSS_INCLUDE.'/lib/ispan.class.php';
-/*! MenuAdmin */
-/* \brief show the menu for user/database management
-/*
-/* \return HTML code with the menu
-*/
+/*! MenuAdmin
+ * \brief show the menu for user/database management
+ * \return HTML code with the menu
+ */
function MenuAdmin()
{
@@ -142,4 +141,4 @@ function menu_acc_plan($p_start=1)
\ No newline at end of file
+?>
diff --git a/include/sql/patch/upgrade140.sql b/include/sql/patch/upgrade140.sql
new file mode 100644
index 000000000..6a2662c92
--- /dev/null
+++ b/include/sql/patch/upgrade140.sql
@@ -0,0 +1,10 @@
+begin;
+alter table user_filter rename unpaid to operation_filter;
+alter table user_filter alter column operation_filter type text;
+update user_filter set operation_filter = 'paid' where operation_filter is not null;
+update user_filter set operation_filter = 'all' where operation_filter is null;
+comment on column user_filter.operation_filter is 'Status of the operation : paid, unpaid or all operation';
+alter table user_filter alter operation_filter set not null;
+
+insert into version (val,v_description) values (141,'Search filter with operation status');
+commit ;
diff --git a/include/template/ledger_search.php b/include/template/ledger_search.php
index c22dd2086..a6a1e00e5 100644
--- a/include/template/ledger_search.php
+++ b/include/template/ledger_search.php
@@ -80,7 +80,7 @@ echo $f_accounting->input(); ?>
|
-
+
|
diff --git a/scenario/acc_ledger_historyTest.php b/scenario/acc_ledger_historyTest.php
index 48d6c474e..2800d542d 100644
--- a/scenario/acc_ledger_historyTest.php
+++ b/scenario/acc_ledger_historyTest.php
@@ -32,7 +32,7 @@ echo Dossier::hidden();
global $cn, $g_user, $g_succeed, $g_failed;
$cn=Dossier::connect();
-$ledger_history=Acc_Ledger_History::factory($cn, $ledger, $min, $max, "E");
+$ledger_history=Acc_Ledger_History::factory($cn, $ledger, $min, $max, "E","all");
echo h1("Detailled Accounting");
echo h2(_("export detail html all ledgers result = Detailled Accounting from Acc_Ledger_History_Generic"));
$ledger_history->export_detail_html();
@@ -42,7 +42,7 @@ $ledger_history->set_m_mode("D");
$ledger_history->export_html();
echo h1(_("Only VEN from Acc_Ledger_History_Sale"));
-$ledger_history=Acc_Ledger_History::factory($cn, [2], $min , $max , "L");
+$ledger_history=Acc_Ledger_History::factory($cn, [2], $min , $max , "L","all");
$ledger_history->export_detail_html();
echo h2(_("Only VEN one line"));
@@ -61,13 +61,13 @@ $ledger_history->set_m_mode("E");
$ledger_history->export_html();
echo h2("VEN + ACH");
-$ledger_history=Acc_Ledger_History::factory($cn, [3,2], $min, $max , "L");
+$ledger_history=Acc_Ledger_History::factory($cn, [3,2], $min, $max , "L","all");
$ledger_history->export_oneline_html();
echo h1("ACH from Acc_Ledger_History_Purchase");
echo h2("Detailled accouting");
-$ledger_history=new Acc_Ledger_History_Purchase($cn,[3],$max,$min,"A");
+$ledger_history=new Acc_Ledger_History_Purchase($cn,[3],$max,$min,"A","all");
$ledger_history->export_html();
echo h2("Ach one line");
$ledger_history->set_m_mode("L");
@@ -81,7 +81,7 @@ $ledger_history->export_html();
echo h1("FIN from Acc_Ledger_History_Financial");
echo h2("Detailled accouting");
-$ledger_history=new Acc_Ledger_History_Financial($cn,[11,16],$min,$max,"A");
+$ledger_history=new Acc_Ledger_History_Financial($cn,[11,16],$min,$max,"A","all");
$ledger_history->export_html();
echo h2("FIN one line");
$ledger_history->set_m_mode("L");
diff --git a/unit-test/include/class/acc_ledger_search.Test.php b/unit-test/include/class/acc_ledger_search.Test.php
new file mode 100644
index 000000000..a0e672e87
--- /dev/null
+++ b/unit-test/include/class/acc_ledger_search.Test.php
@@ -0,0 +1,133 @@
+
+if ( ! defined("ALLOWED")) {
+ define('ALLOWED',1);
+}
+/**
+ * @file
+ * @brief concern acc_ledger_search
+ * @coversDefaultClass acc_ledger_search
+ */
+class Acc_Ledger_Test 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';
+ global $g_user;
+ $g_user->set_periode(119);
+ }
+
+ /**
+ * Tears down the fixture, for example, closes a network connection.
+ * This method is called after a test is executed.
+ */
+ protected function tearDown()
+ {
+
+ }
+
+ /**
+ * @covers ::build_search_sql
+ */
+ function test_all_ledger()
+ {
+ global $g_connection;
+ // all legder
+ $ledger=new Acc_Ledger_Search('ALL');
+ $result=$ledger->build_search_sql(NULL);
+ $a_result=$g_connection->get_array($result[0]);
+ $this->assertEquals(4,count($a_result));
+ $this->assertEquals(" jrn_def_id in (3,83,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]);
+
+ // Expect exception
+ try {
+ $ledger=new Acc_Ledger_Search('ALL1');
+ $this->assertTrue(FALSE,"Exception not thrown with invalide type");
+ } catch (Exception $e) {
+ $this->assertEquals($e->getCode(),1005,"Exception is type invalide");
+ }
+
+ }
+ /**
+ * @covers ::display_search_form
+ */
+ function test_display_search_form()
+ {
+ put_global(array(["key"=>"ac","value"=>"phpunit"]));
+ $ledger=new Acc_Ledger_Search('ALL');
+ $r=$ledger->display_search_form();
+ $this->assertEquals(9068,strlen($r),"Size of the html string for display_search_form");
+ }
+ /**
+ * @covers ::build_search_filter
+ */
+ function test_build_search_filter()
+ {
+ $ledger=new Acc_Ledger_Search('ALL');
+ $ret = $ledger->build_search_filter();
+ $result=sprintf("manage_search_filter({'div':'','ledger_type':'ALL','all_type':1,'dossier':%d})"
+ ,Dossier::id());
+ $this->assertEquals($ret,$result,"Build filter for ALL");
+
+ $ledger=new Acc_Ledger_Search('FIN');
+ $this->assertEquals($ret,$result);
+ $ret = $ledger->build_search_filter();
+ $result=sprintf("manage_search_filter({'div':'','ledger_type':'FIN','all_type':1,'dossier':%d})"
+ ,Dossier::id());
+ $this->assertEquals($ret,$result,"Build filter for FIN");
+
+ $ledger=new Acc_Ledger_Search('VEN');
+ $this->assertEquals($ret,$result);
+ $ret = $ledger->build_search_filter();
+ $result=sprintf("manage_search_filter({'div':'','ledger_type':'VEN','all_type':1,'dossier':%d})"
+ ,Dossier::id());
+ $this->assertEquals($ret,$result,"Build filter for VEN");
+
+ $ledger=new Acc_Ledger_Search('ACH');
+ $this->assertEquals($ret,$result);
+ $ret = $ledger->build_search_filter();
+ $result=sprintf("manage_search_filter({'div':'','ledger_type':'ACH','all_type':1,'dossier':%d})"
+ ,Dossier::id());
+ $this->assertEquals($ret,$result,"Build filter for ACH");
+
+ $ledger=new Acc_Ledger_Search('ODS');
+ $this->assertEquals($ret,$result);
+ $ret = $ledger->build_search_filter();
+ $result=sprintf("manage_search_filter({'div':'','ledger_type':'ODS','all_type':1,'dossier':%d})"
+ ,Dossier::id());
+
+ $this->assertEquals($ret,$result,"Build filter for ODS");
+
+ }
+}
diff --git a/unit-test/include/class/acc_ledger_sold.Test.php b/unit-test/include/class/acc_ledger_sold.Test.php
index 3ec3e876e..726f69ad6 100644
--- a/unit-test/include/class/acc_ledger_sold.Test.php
+++ b/unit-test/include/class/acc_ledger_sold.Test.php
@@ -148,7 +148,7 @@ class Acc_Ledger_SoldTest extends TestCase
$array["mt"]="1572714478.3155";
$array['e_march1_tva_amount']="";
$this->object->insert($array);
- $this->assertEquals(254.6250,$g_connection->get_value("select qs_vat ".$sql));
+ $this->assertEquals(254.63,$g_connection->get_value("select qs_vat ".$sql));
$this->clean_operation();
// Test space in e_march1_tva_amount instead of zero must be calculated
|