diff --git a/unit-test/create-dossier-test.sh b/unit-test/create-dossier-test.sh
index 66a83f5b7..aab6eb6a1 100755
--- a/unit-test/create-dossier-test.sh
+++ b/unit-test/create-dossier-test.sh
@@ -2,7 +2,7 @@
export PGCLUSTER=10/main
DOSSIER_TEST=rel70dossier25
-FILE_TEST=dossiertest210418-1503.sql
+FILE_TEST=dossiertest210516-1503.sql
dropdb $DOSSIER_TEST
createdb $DOSSIER_TEST
diff --git a/unit-test/document/fr_be/bnb.form b/unit-test/document/fr_be/bnb.form
index 25ad085c2..5da29d76f 100644
--- a/unit-test/document/fr_be/bnb.form
+++ b/unit-test/document/fr_be/bnb.form
@@ -1,3 +1,4 @@
-$C70=round([70%],2)
-$C60=round([60%],2)
+$C70=round([70%-S],2)
+$C60=round([60%-s],2)
+$C61=round([61%-s],2)
diff --git a/unit-test/include/class/acc_account_ledger.Test.php b/unit-test/include/class/acc_account_ledger.Test.php
index e4f77a293..affed6972 100644
--- a/unit-test/include/class/acc_account_ledger.Test.php
+++ b/unit-test/include/class/acc_account_ledger.Test.php
@@ -81,6 +81,13 @@ class Acc_Account_LedgerTest extends TestCase
'jrn_def_name'=>'Opération Diverses',
'jrn_def_code'=>'O01',
'delta_letter'=>NULL,
+ 'currency_rate' => '1.000000',
+ 'currency_rate_ref' => '1.000000',
+ 'currency_id' => '0',
+ 'cr_code_iso' => 'EUR',
+ 'j_montant' => '8.4000',
+ 'oc_amount' => null,
+ 'oc_vat_amount' => null
),
1=>
array(
@@ -104,6 +111,14 @@ class Acc_Account_LedgerTest extends TestCase
'jrn_def_name'=>'Vente',
'jrn_def_code'=>'V01',
'delta_letter'=>NULL,
+ 'currency_rate' => '1.000000'
+ ,'currency_rate_ref' => '1.000000'
+ ,'currency_id' => '0'
+ ,'cr_code_iso' => 'EUR'
+ ,'j_montant' => '8.4000'
+ ,'oc_amount' => null
+ ,'oc_vat_amount' => null
+
),
2=>
array(
@@ -127,6 +142,14 @@ class Acc_Account_LedgerTest extends TestCase
'jrn_def_name'=>'Vente',
'jrn_def_code'=>'V01',
'delta_letter'=>NULL,
+ 'currency_rate' => '1.000000'
+ ,'currency_rate_ref' => '1.000000'
+ ,'currency_id' => '0'
+ ,'cr_code_iso' => 'EUR'
+ ,'j_montant' => '5.2900'
+ ,'oc_amount' => null
+ ,'oc_vat_amount' => null
+
),
3=>
array(
@@ -150,6 +173,14 @@ class Acc_Account_LedgerTest extends TestCase
'jrn_def_name'=>'Vente',
'jrn_def_code'=>'V01',
'delta_letter'=>NULL,
+ 'currency_rate' => '1.000000',
+ 'currency_rate_ref' => '1.000000',
+ 'currency_id' => '0',
+ 'cr_code_iso' => 'EUR',
+ 'j_montant' => '35.7400',
+ 'oc_amount' => null,
+ 'oc_vat_amount' => null
+
),
4=>
array(
@@ -173,6 +204,13 @@ class Acc_Account_LedgerTest extends TestCase
'jrn_def_name'=>'Vente',
'jrn_def_code'=>'V01',
'delta_letter'=>NULL,
+ 'currency_rate' => '1.000000',
+ 'currency_rate_ref' => '1.000000',
+ 'currency_id' => '0',
+ 'cr_code_iso' => 'EUR',
+ 'j_montant' => '35.7400',
+ 'oc_amount' => null,
+ 'oc_vat_amount' => null
),
5=>
array(
@@ -196,6 +234,14 @@ class Acc_Account_LedgerTest extends TestCase
'jrn_def_name'=>'Opération Diverses',
'jrn_def_code'=>'O01',
'delta_letter'=>NULL,
+ 'currency_rate' => '1.000000',
+ 'currency_rate_ref' => '1.000000',
+ 'currency_id' => '0',
+ 'cr_code_iso' => 'EUR',
+ 'j_montant' => '21.0000',
+ 'oc_amount' => null,
+ 'oc_vat_amount' => null
+
),
),
1=>'0',
@@ -258,7 +304,7 @@ class Acc_Account_LedgerTest extends TestCase
{
global $g_connection;
$accounting=new Acc_Account_Ledger($g_connection, '4511');
- $this->assertEquals($accounting->get_solde(),248.97);
+ $this->assertEquals(1397.87,$accounting->get_solde(),"get_solde");
}
/**
@@ -270,8 +316,8 @@ class Acc_Account_LedgerTest extends TestCase
$accounting=new Acc_Account_Ledger($g_connection, '4511');
$expected=array (
'debit' => '0',
- 'credit' => '248.9700',
- 'solde' => 248.97,
+ 'credit' => '1397.8700',
+ 'solde' => 1397.87,
);
$this->assertEquals($accounting->get_solde_detail(),$expected);
}
diff --git a/unit-test/include/class/acc_balance.Test.php b/unit-test/include/class/acc_balance.Test.php
index 0a83f9233..cdc38521b 100644
--- a/unit-test/include/class/acc_balance.Test.php
+++ b/unit-test/include/class/acc_balance.Test.php
@@ -48,10 +48,10 @@ class Acc_BalanceTest extends TestCase
$min=$g_connection->get_value("select min(p_id) from parm_periode");
$this->object->jrn=NULL;
$array=$this->object->get_row($min,$max);
- $this->assertEquals(32,count($array));
+ $this->assertEquals(35,count($array));
$this->object->jrn=[2,4];
$array=$this->object->get_row($min,$max);
- $this->assertEquals(12,count($array));
+ $this->assertEquals(16,count($array));
}
diff --git a/unit-test/include/class/acc_bilan.Test.php b/unit-test/include/class/acc_bilan.Test.php
index fa8a5dfc7..be4b7fe85 100644
--- a/unit-test/include/class/acc_bilan.Test.php
+++ b/unit-test/include/class/acc_bilan.Test.php
@@ -137,62 +137,13 @@ class Acc_BilanTest extends TestCase
$this->object->to=103;
$this->object->compute_formula($hFile);
-
- $this->assertTrue(isset($this->object->C70));
- $this->assertTrue(isset($this->object->C60));
+ $this->assertTrue(isset($this->object->C70),"Exist C70");
+ $this->assertTrue(isset($this->object->C60),"Exist C60");
+ $this->assertTrue(isset($this->object->C61),"Exist C61");
$this->assertEquals($this->object->C70,456.8);
$this->assertEquals($this->object->C60,0);
+ $this->assertEquals($this->object->C61,1491.50);
}
- /**
- * @covers Acc_Bilan::generate_odt
- * @todo Implement testGenerate_odt().
- */
- public function testGenerate_odt()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @covers Acc_Bilan::generate_plain
- * @todo Implement testGenerate_plain().
- */
- public function testGenerate_plain()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @covers Acc_Bilan::generate
- * @todo Implement testGenerate().
- */
- public function testGenerate()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @covers Acc_Bilan::send
- * @todo Implement testSend().
- */
- public function testSend()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
-
-
}
diff --git a/unit-test/include/class/acc_compute.Test.php b/unit-test/include/class/acc_compute.Test.php
index 21bc12f76..8943332cf 100644
--- a/unit-test/include/class/acc_compute.Test.php
+++ b/unit-test/include/class/acc_compute.Test.php
@@ -187,8 +187,9 @@ class Acc_ComputeTest extends TestCase
ob_start();
$this->object->display();
$result=ob_get_contents();
+ ob_end_clean();
$this->assertStringStartsWith("key amount Description amount value is 0
key amount_vat Description amount_vat value is 0
",$result);
- $this->assertStringEndsWith("
key amount_perso_rate Description amount_perso_rate value is 0
",$result);
+ $this->assertStringEndsWith("
key amount_vat_currency Description amount_vat_currency value is 0
key currency_rate Description currency_rate value is 0
",$result);
}
public function testCompute()
diff --git a/unit-test/include/class/acc_ledger.Test.php b/unit-test/include/class/acc_ledger.Test.php
index 8edb68d36..bf28be49b 100644
--- a/unit-test/include/class/acc_ledger.Test.php
+++ b/unit-test/include/class/acc_ledger.Test.php
@@ -70,12 +70,12 @@ class Acc_LedgerTest extends TestCase
$this->object->set_ledger_id(2);
$this->assertEquals($this->object->get_type(),'VEN',"Sales ledger");
$a_vat=$this->object->existing_vat();
- $this->assertEquals(2,count($a_vat));
+ $this->assertEquals(4,count($a_vat));
$this->object->set_ledger_id(3);
$this->assertEquals($this->object->get_type(),'ACH',"Purchases ledger");
$a_vat=$this->object->existing_vat();
- $this->assertEquals(5,count($a_vat));
+ $this->assertEquals(6,count($a_vat));
}
/**
* @covers Acc_Ledger::get_last_pj
@@ -293,8 +293,8 @@ class Acc_LedgerTest extends TestCase
$max=$g_connection->get_value("select max(p_id) from parm_periode");
$min=$g_connection->get_value("select min(p_id) from parm_periode");
$solde=$ledger->get_solde($min,$max);
- $this->assertEquals($solde[0],4175.02);
- $this->assertEquals($solde[1],4175.02);
+ $this->assertEquals($solde[1],10936.91);
+ $this->assertEquals($solde[0],10936.91);
}
@@ -372,6 +372,8 @@ class Acc_LedgerTest extends TestCase
"reverse_date"=>"",
"ext_label"=>"",
"jr_optype"=>"NOR",
+ "p_currency_code"=>0,
+ "p_currency_rate" => 1,
"save"=>"Confirmer"
];
$this->object->set_ledger_id(4);
@@ -464,6 +466,7 @@ class Acc_LedgerTest extends TestCase
//-----------------------------------------------
// Must fail
//-----------------------------------------------
+ ob_start();
try {
$array["p_jrn"]="a";
$ledger->verify_ledger($array);
@@ -471,12 +474,14 @@ class Acc_LedgerTest extends TestCase
}catch (\Exception $e) {
$this->assertTrue(TRUE);
}
+ ob_end_clean();
// reset properly ,
$array["p_jrn"]="15";
$ledger->verify_ledger($array);
// fails if negative amount neither 1 nor 0
+ ob_start();
try {
$array["negative_amount"]=2;
$ledger->verify_ledger($array);
@@ -484,8 +489,10 @@ class Acc_LedgerTest extends TestCase
}catch (\Exception $e) {
$this->assertTrue(TRUE);
}
+ ob_end_clean();
// negative amount not set , so fails
+ ob_start();
try {
$array["negative_warning"]="Yes";
$ledger->verify_ledger($array);
@@ -493,6 +500,7 @@ class Acc_LedgerTest extends TestCase
}catch (\Exception $e) {
$this->assertTrue(TRUE);
}
+ ob_end_clean();
}
/**
@@ -539,7 +547,9 @@ class Acc_LedgerTest extends TestCase
"od_description"=>"",
"reverse_date"=>"",
"ext_label"=>"",
- "jr_optype"=>"NOR"
+ "jr_optype"=>"NOR",
+ "p_currency_rate"=>1,
+ "p_currency_code"=>0,
];
global $g_connection;
$ledger=new Acc_Ledger($g_connection,4);
@@ -629,9 +639,12 @@ class Acc_LedgerTest extends TestCase
*/
public function testGet_last_date()
{
+ global $g_connection;
$this->object->set_ledger_id(2);
$last_date=$this->object->get_last_date();
- $this->assertEquals("24.04.2019",$last_date);
+
+ $this->assertEquals($g_connection->get_value("select to_char(max(jr_date),'DD.MM.YYYY') from jrn where jr_def_id=2"),
+ $last_date);
}
/**
@@ -731,7 +744,9 @@ class Acc_LedgerTest extends TestCase
"ld4" => "",
"amount4" =>"",
"jrn_concerned" => "",
- "summary" => "Sauvez"
+ "summary" => "Sauvez",
+ "p_currency_rate"=>1,
+ "p_currency_code"=>0,
];
$ledger=new Acc_Ledger($g_connection,4);
diff --git a/unit-test/include/class/acc_ledger_historyTest.php b/unit-test/include/class/acc_ledger_historyTest.php
index 38f8d4e37..94cb00127 100644
--- a/unit-test/include/class/acc_ledger_historyTest.php
+++ b/unit-test/include/class/acc_ledger_historyTest.php
@@ -23,7 +23,7 @@ use PHPUnit\Framework\TestCase;
/**
* @file
- * @brief concerne acc_ledger_historyTest.class
+ * @brief concerne acc_ledger_historyTest.class , used in "impression journaux"
* @coversDefaultClass Acc_Ledger_History
*/
class Acc_Ledger_HistoryTest extends TestCase
@@ -118,7 +118,7 @@ class Acc_Ledger_HistoryTest extends TestCase
$object=Acc_Ledger_History::factory($g_connection, [2],$p_min_id ,$p_max_id , "D", 'all');
$object->get_row();
$a_row=$object->get_data();
- $this->assertEquals(7,count($a_row));
+ $this->assertEquals(15,count($a_row));
$object->set_filter_operation("paid");
$object->get_row();
@@ -128,7 +128,7 @@ class Acc_Ledger_HistoryTest extends TestCase
$object->set_filter_operation("unpaid");
$object->get_row();
$a_row=$object->get_data();
- $this->assertEquals(4,count($a_row));
+ $this->assertEquals(12,count($a_row));
}
diff --git a/unit-test/include/class/acc_ledger_history_financial.Test.php b/unit-test/include/class/acc_ledger_history_financial.Test.php
index ae420120d..8b736a02a 100644
--- a/unit-test/include/class/acc_ledger_history_financial.Test.php
+++ b/unit-test/include/class/acc_ledger_history_financial.Test.php
@@ -78,7 +78,7 @@ class Acc_Ledger_History_FinancialTest extends TestCase
echo \Noalyss\Facility::page_start();
$this->object->export_html();
$content=ob_get_contents();
-
+ ob_end_clean();
$this->save_file($name, $content);
$this->assertFileExists(__DIR__."/file/".$name);
@@ -89,6 +89,7 @@ class Acc_Ledger_History_FinancialTest extends TestCase
echo \Noalyss\Facility::page_start();
$this->object->export_html();
$content=ob_get_contents();
+ ob_end_clean();
$this->save_file($name, $content);
$this->assertFileExists(__DIR__."/file/".$name);
diff --git a/unit-test/include/class/acc_ledger_history_generic.Test.php b/unit-test/include/class/acc_ledger_history_generic.Test.php
index a7c0436ba..5ca984aa3 100644
--- a/unit-test/include/class/acc_ledger_history_generic.Test.php
+++ b/unit-test/include/class/acc_ledger_history_generic.Test.php
@@ -76,7 +76,7 @@ class Acc_Ledger_History_GenericTest extends TestCase
echo \Noalyss\Facility::page_start();
$this->object->export_html();
$content=ob_get_contents();
-
+ ob_end_clean();
$this->save_file($name, $content);
$this->assertFileExists(__DIR__."/file/".$name);
@@ -87,6 +87,7 @@ class Acc_Ledger_History_GenericTest extends TestCase
echo \Noalyss\Facility::page_start();
$this->object->export_html();
$content=ob_get_contents();
+ ob_end_clean();
$this->save_file($name, $content);
$this->assertFileExists(__DIR__."/file/".$name);
@@ -98,6 +99,7 @@ class Acc_Ledger_History_GenericTest extends TestCase
echo \Noalyss\Facility::page_start();
$this->object->export_html();
$content=ob_get_contents();
+ ob_end_clean();
$this->save_file($name, $content);
$this->assertFileExists(__DIR__."/file/".$name);
@@ -109,6 +111,7 @@ class Acc_Ledger_History_GenericTest extends TestCase
echo \Noalyss\Facility::page_start();
$this->object->export_html();
$content=ob_get_contents();
+ ob_end_clean();
$this->save_file($name, $content);
$this->assertFileExists(__DIR__."/file/".$name);
diff --git a/unit-test/include/class/acc_ledger_history_purchase.Test.php b/unit-test/include/class/acc_ledger_history_purchase.Test.php
index c9eca215e..4934de401 100644
--- a/unit-test/include/class/acc_ledger_history_purchase.Test.php
+++ b/unit-test/include/class/acc_ledger_history_purchase.Test.php
@@ -62,7 +62,7 @@ class Acc_Ledger_History_PurchaseTest extends TestCase
function testGet_Row()
{
$this->object->get_row();
- $this->assertSame(count($this->object->get_data()),14);
+ $this->assertSame(19,count($this->object->get_data()),"Acc_Ledger_History_Purchase->get_data");
}
//@covers Acc_Ledger_History_Financial::export_oneline_html
@@ -75,7 +75,7 @@ class Acc_Ledger_History_PurchaseTest extends TestCase
echo \Noalyss\Facility::page_start();
$this->object->export_html();
$content=ob_get_contents();
-
+ ob_end_clean();
$this->save_file($name, $content);
$this->assertFileExists(__DIR__."/file/".$name);
@@ -86,7 +86,7 @@ class Acc_Ledger_History_PurchaseTest extends TestCase
echo \Noalyss\Facility::page_start();
$this->object->export_html();
$content=ob_get_contents();
-
+ ob_end_clean();
$this->save_file($name, $content);
$this->assertFileExists(__DIR__."/file/".$name);
@@ -97,7 +97,7 @@ class Acc_Ledger_History_PurchaseTest extends TestCase
echo \Noalyss\Facility::page_start();
$this->object->export_html();
$content=ob_get_contents();
-
+ ob_end_clean();
$this->save_file($name, $content);
$this->assertFileExists(__DIR__."/file/".$name);
@@ -108,7 +108,7 @@ class Acc_Ledger_History_PurchaseTest extends TestCase
echo \Noalyss\Facility::page_start();
$this->object->export_html();
$content=ob_get_contents();
-
+ ob_end_clean();
$this->save_file($name, $content);
$this->assertFileExists(__DIR__."/file/".$name);
}
diff --git a/unit-test/include/class/acc_ledger_history_sale.Test.php b/unit-test/include/class/acc_ledger_history_sale.Test.php
index 49ee0e02d..3b622239f 100644
--- a/unit-test/include/class/acc_ledger_history_sale.Test.php
+++ b/unit-test/include/class/acc_ledger_history_sale.Test.php
@@ -55,7 +55,7 @@ class Acc_Ledger_History_SaleTest extends TestCase
function testGet_row()
{
$this->object->get_row();
- $this->assertSame(count($this->object->get_data()),6);
+ $this->assertSame(10,count($this->object->get_data()),"Acc_Ledger_History_Sale->get_row");
}
private function save_file($p_name,$content)
{
@@ -73,7 +73,7 @@ class Acc_Ledger_History_SaleTest extends TestCase
echo \Noalyss\Facility::page_start();
$this->object->export_html();
$content=ob_get_contents();
-
+ ob_end_clean();
$this->save_file($name, $content);
$this->assertFileExists(__DIR__."/file/".$name);
@@ -84,7 +84,7 @@ class Acc_Ledger_History_SaleTest extends TestCase
echo \Noalyss\Facility::page_start();
$this->object->export_html();
$content=ob_get_contents();
-
+ ob_end_clean();
$this->save_file($name, $content);
$this->assertFileExists(__DIR__."/file/".$name);
@@ -95,7 +95,7 @@ class Acc_Ledger_History_SaleTest extends TestCase
echo \Noalyss\Facility::page_start();
$this->object->export_html();
$content=ob_get_contents();
-
+ ob_end_clean();
$this->save_file($name, $content);
$this->assertFileExists(__DIR__."/file/".$name);
@@ -106,7 +106,7 @@ class Acc_Ledger_History_SaleTest extends TestCase
echo \Noalyss\Facility::page_start();
$this->object->export_html();
$content=ob_get_contents();
-
+ ob_end_clean();
$this->save_file($name, $content);
$this->assertFileExists(__DIR__."/file/".$name);
}
diff --git a/unit-test/include/class/acc_ledger_purchase.Test.php b/unit-test/include/class/acc_ledger_purchase.Test.php
index 724105862..499a003c9 100644
--- a/unit-test/include/class/acc_ledger_purchase.Test.php
+++ b/unit-test/include/class/acc_ledger_purchase.Test.php
@@ -116,6 +116,7 @@ class Acc_Ledger_PurchaseTest extends TestCase
$array["amount_t0"]=658.25;
$array['hplan']=array(array(-1));
$array["val"]=array(array(658.25));
+
$this->clean_operation();
$this->assertEquals(0,
@@ -151,7 +152,7 @@ class Acc_Ledger_PurchaseTest extends TestCase
"e_march1_tva_id"=>1,
"e_march1_tva_amount"=>22.08,
"tva_march1"=>3.83,
- "tvac_march1"=>22.05));
+ "tvac_march1"=>22.08));
$this->object->insert($array);
$this->assertEquals(0,$g_connection->get_value("select count(*) ".$sql));
@@ -165,6 +166,8 @@ class Acc_Ledger_PurchaseTest extends TestCase
$array["op"]=array(0);
$array["amount_t0"]=658.25;
$array['hplan']=array(array(-1));
+ $array["p_currency_code"] = 0;
+ $array["p_currency_rate"] = 1;
$array["val"]=array(array(658.25));
$array=array_merge($array, array("e_march1"=>"DOCUME",
"e_march1_price"=>18.25,
@@ -173,7 +176,7 @@ class Acc_Ledger_PurchaseTest extends TestCase
"e_march1_tva_id"=>1,
"e_march1_tva_amount"=>"",
"tva_march1"=>3.83,
- "tvac_march1"=>22.05));
+ "tvac_march1"=>22.08));
$this->object->insert($array);
$this->assertEquals(3.83,$g_connection->get_value("select qp_vat ".$sql));
$this->clean_operation();
@@ -197,7 +200,8 @@ class Acc_Ledger_PurchaseTest extends TestCase
"tvac_march1"=>22.05));
$this->object->insert($array);
- $this->assertEquals(22.08,$g_connection->get_value("select qp_vat ".$sql));
+ // en USD , 22.08 = 20.26€ * 1.09
+ $this->assertEquals(20.26,$g_connection->get_value("select qp_vat ".$sql));
$this->clean_operation();
}
@@ -239,6 +243,9 @@ class Acc_Ledger_PurchaseTest extends TestCase
private function clean_operation()
{
global $g_connection;
+ $g_connection->exec_sql("delete from quant_purchase where j_id in ("
+ . " select j_id from jrnx join jrn on (jr_grpt_id = j_grpt) where "
+ . " jr_mt=$1 ) ", ["1572704002.1732"]);
$g_connection->exec_sql("delete from jrn where jr_mt=$1", ["1572704002.1732"]);
$g_connection->exec_sql("delete from jrnx where j_grpt not in (select jr_grpt_id from jrn)");
$g_connection->exec_sql("alter sequence s_jrn_pj3 restart with 52");
diff --git a/unit-test/include/class/acc_ledger_search.Test.php b/unit-test/include/class/acc_ledger_search.Test.php
index c15e8f431..0e7fb6586 100644
--- a/unit-test/include/class/acc_ledger_search.Test.php
+++ b/unit-test/include/class/acc_ledger_search.Test.php
@@ -87,7 +87,7 @@ class Acc_Ledger_Test extends TestCase
put_global(array(["key"=>"ac","value"=>"phpunit"]));
$ledger=new Acc_Ledger_Search('ALL');
$r=$ledger->display_search_form();
- $this->assertEquals(8983,strlen($r),"Size of the html string for display_search_form");
+ $this->assertEquals(9546,strlen($r),"Size of the html string for display_search_form");
}
/**
* @covers ::build_search_filter
diff --git a/unit-test/include/class/acc_ledger_sold.Test.php b/unit-test/include/class/acc_ledger_sold.Test.php
index 5e7ad60bd..d516bbe14 100644
--- a/unit-test/include/class/acc_ledger_sold.Test.php
+++ b/unit-test/include/class/acc_ledger_sold.Test.php
@@ -207,7 +207,7 @@ class Acc_Ledger_SoldTest extends TestCase
\Noalyss\Facility::page_start().
$info);
$this->assertContains(
- 'NAME="e_client" ID="e_client" VALUE="CLIENT" SIZE="20" ondblclick="fill_ipopcard(this);" ', $info);
+ 'NAME="e_client" ID="e_client" VALUE="CLIENT" ondblclick="fill_ipopcard(this);" ', $info);
$this->assertContains(
'object->heading_detail_sale();
- $this->assertEquals(28,count($a));
+ $this->assertEquals(32,count($a));
}
/**
* @covers Acc_Ledger_Sold::get_detail_sale
diff --git a/unit-test/include/class/data/tax_summary_getrow_purchase_o.php b/unit-test/include/class/data/tax_summary_getrow_purchase_o.php
index f75c5bc60..9d8f6e8d4 100644
--- a/unit-test/include/class/data/tax_summary_getrow_purchase_o.php
+++ b/unit-test/include/class/data/tax_summary_getrow_purchase_o.php
@@ -1,6 +1,6 @@
array (
'jrn_def_name' => 'Achat',
@@ -9,7 +9,7 @@ $a_result=array (
'tva_both_side' => '0',
'qp_vat_code' => '4',
'amount_vat' => '0.0000',
- 'amount_wovat' => '658.2500',
+ 'amount_wovat' => '1262.1500',
'amount_sided' => '0.0000',
'amount_noded_amount' => '0.0000',
'amount_noded_tax' => '0.0000',
@@ -38,8 +38,8 @@ $a_result=array (
'tva_rate' => '0.2100',
'tva_both_side' => '0',
'qp_vat_code' => '1',
- 'amount_vat' => '44.5300',
- 'amount_wovat' => '212.0000',
+ 'amount_vat' => '51.7200',
+ 'amount_wovat' => '246.2500',
'amount_sided' => '0.0000',
'amount_noded_amount' => '0.0000',
'amount_noded_tax' => '0.0000',
@@ -53,8 +53,8 @@ $a_result=array (
'tva_rate' => '0.0600',
'tva_both_side' => '0',
'qp_vat_code' => '3',
- 'amount_vat' => '5.2800',
- 'amount_wovat' => '88.3200',
+ 'amount_vat' => '7.7200',
+ 'amount_wovat' => '129.2200',
'amount_sided' => '0.0000',
'amount_noded_amount' => '0.0000',
'amount_noded_tax' => '0.0000',
@@ -84,7 +84,7 @@ $a_result=array (
'tva_both_side' => '0',
'qp_vat_code' => '6',
'amount_vat' => '0.0000',
- 'amount_wovat' => '286.9500',
+ 'amount_wovat' => '307.5900',
'amount_sided' => '0.0000',
'amount_noded_amount' => '0.0000',
'amount_noded_tax' => '0.0000',
@@ -170,8 +170,8 @@ $a_result=array (
array (
'jrn_def_name' => 'Frais Divers',
'tva_label' => 'INTRA',
- 'tva_rate' => '0.0000',
- 'tva_both_side' => '0',
+ 'tva_rate' => '0.2100',
+ 'tva_both_side' => '1',
'qp_vat_code' => '5',
'amount_vat' => '0.0000',
'amount_wovat' => '1250.0000',
diff --git a/unit-test/include/class/data/tax_summary_getrow_purchase_p.php b/unit-test/include/class/data/tax_summary_getrow_purchase_p.php
index 71caa2136..d3b994091 100644
--- a/unit-test/include/class/data/tax_summary_getrow_purchase_p.php
+++ b/unit-test/include/class/data/tax_summary_getrow_purchase_p.php
@@ -1,5 +1,6 @@
array (
'jrn_def_name' => 'Achat',
@@ -45,4 +46,5 @@ $a_result= array (
'amount_noded_return' => '0.0000',
'amount_private' => '0.0000',
),
-);
+)
+;
diff --git a/unit-test/include/class/data/tax_summary_getrow_purchase_t.php b/unit-test/include/class/data/tax_summary_getrow_purchase_t.php
index 48f440a0a..55308e3ed 100644
--- a/unit-test/include/class/data/tax_summary_getrow_purchase_t.php
+++ b/unit-test/include/class/data/tax_summary_getrow_purchase_t.php
@@ -1,5 +1,6 @@
-
array (
'jrn_def_name' => 'Achat',
@@ -8,7 +9,7 @@ $a_result= array (
'tva_both_side' => '0',
'qp_vat_code' => '4',
'amount_vat' => '0.0000',
- 'amount_wovat' => '658.2500',
+ 'amount_wovat' => '1262.1500',
'amount_sided' => '0.0000',
'amount_noded_amount' => '0.0000',
'amount_noded_tax' => '0.0000',
@@ -37,8 +38,8 @@ $a_result= array (
'tva_rate' => '0.2100',
'tva_both_side' => '0',
'qp_vat_code' => '1',
- 'amount_vat' => '44.5300',
- 'amount_wovat' => '212.0000',
+ 'amount_vat' => '51.7200',
+ 'amount_wovat' => '246.2500',
'amount_sided' => '0.0000',
'amount_noded_amount' => '0.0000',
'amount_noded_tax' => '0.0000',
@@ -52,8 +53,8 @@ $a_result= array (
'tva_rate' => '0.0600',
'tva_both_side' => '0',
'qp_vat_code' => '3',
- 'amount_vat' => '5.2800',
- 'amount_wovat' => '88.3200',
+ 'amount_vat' => '7.7200',
+ 'amount_wovat' => '129.2200',
'amount_sided' => '0.0000',
'amount_noded_amount' => '0.0000',
'amount_noded_tax' => '0.0000',
@@ -83,7 +84,7 @@ $a_result= array (
'tva_both_side' => '0',
'qp_vat_code' => '6',
'amount_vat' => '0.0000',
- 'amount_wovat' => '286.9500',
+ 'amount_wovat' => '307.5900',
'amount_sided' => '0.0000',
'amount_noded_amount' => '0.0000',
'amount_noded_tax' => '0.0000',
@@ -169,8 +170,8 @@ $a_result= array (
array (
'jrn_def_name' => 'Frais Divers',
'tva_label' => 'INTRA',
- 'tva_rate' => '0.0000',
- 'tva_both_side' => '0',
+ 'tva_rate' => '0.2100',
+ 'tva_both_side' => '1',
'qp_vat_code' => '5',
'amount_vat' => '0.0000',
'amount_wovat' => '1250.0000',
@@ -195,4 +196,5 @@ $a_result= array (
'amount_noded_return' => '0.0000',
'amount_private' => '0.0000',
),
-);
+)
+;
diff --git a/unit-test/include/class/data/tax_summary_getrow_sale_o.php b/unit-test/include/class/data/tax_summary_getrow_sale_o.php
index 03674e9ab..f632adaac 100644
--- a/unit-test/include/class/data/tax_summary_getrow_sale_o.php
+++ b/unit-test/include/class/data/tax_summary_getrow_sale_o.php
@@ -1,5 +1,6 @@
array (
'jrn_def_name' => 'Vente',
@@ -7,10 +8,10 @@ $a_result = array (
'qs_vat_code' => '1',
'tva_rate' => '0.2100',
'tva_both_side' => '0',
- 'amount_vat' => '219.5700',
- 'amount_wovat' => '1045.6000',
+ 'amount_vat' => '1343.9600',
+ 'amount_wovat' => '6399.8500',
'amount_sided' => '0.0000',
- 'tva_type' => 'P',
+ 'tva_type' => 'O',
),
1 =>
array (
@@ -20,7 +21,7 @@ $a_result = array (
'tva_rate' => '0.0000',
'tva_both_side' => '0',
'amount_vat' => '0.0000',
- 'amount_wovat' => '1047.9000',
+ 'amount_wovat' => '1102.9500',
'amount_sided' => '0.0000',
'tva_type' => 'O',
),
@@ -29,8 +30,8 @@ $a_result = array (
'jrn_def_name' => 'Vente',
'tva_label' => 'INTRA',
'qs_vat_code' => '5',
- 'tva_rate' => '0.0000',
- 'tva_both_side' => '0',
+ 'tva_rate' => '0.2100',
+ 'tva_both_side' => '1',
'amount_vat' => '0.0000',
'amount_wovat' => '1800.0000',
'amount_sided' => '0.0000',
@@ -46,7 +47,7 @@ $a_result = array (
'amount_vat' => '19.1500',
'amount_wovat' => '91.2000',
'amount_sided' => '0.0000',
- 'tva_type' => 'P',
+ 'tva_type' => 'O',
),
4 =>
array (
diff --git a/unit-test/include/class/data/tax_summary_getrow_sale_p.php b/unit-test/include/class/data/tax_summary_getrow_sale_p.php
index 4c611e3b7..8c6f02b81 100644
--- a/unit-test/include/class/data/tax_summary_getrow_sale_p.php
+++ b/unit-test/include/class/data/tax_summary_getrow_sale_p.php
@@ -1,4 +1,4 @@
-
@@ -11,7 +11,7 @@ array (
'amount_vat' => '16.8000',
'amount_wovat' => '80.0000',
'amount_sided' => '0.0000',
- 'tva_type' => 'P',
+ 'tva_type' => 'O',
),
1 =>
array (
@@ -23,6 +23,7 @@ array (
'amount_vat' => '10.7500',
'amount_wovat' => '51.2000',
'amount_sided' => '0.0000',
- 'tva_type' => 'P',
+ 'tva_type' => 'O',
),
-);
+)
+;
diff --git a/unit-test/include/class/data/tax_summary_getrow_sale_t.php b/unit-test/include/class/data/tax_summary_getrow_sale_t.php
index 40bb4c765..fdea12496 100644
--- a/unit-test/include/class/data/tax_summary_getrow_sale_t.php
+++ b/unit-test/include/class/data/tax_summary_getrow_sale_t.php
@@ -1,5 +1,5 @@
-
array (
@@ -8,10 +8,10 @@ array (
'qs_vat_code' => '1',
'tva_rate' => '0.2100',
'tva_both_side' => '0',
- 'amount_vat' => '219.5700',
- 'amount_wovat' => '1045.6000',
+ 'amount_vat' => '1343.9600',
+ 'amount_wovat' => '6399.8500',
'amount_sided' => '0.0000',
- 'tva_type' => 'P',
+ 'tva_type' => 'O',
),
1 =>
array (
@@ -21,7 +21,7 @@ array (
'tva_rate' => '0.0000',
'tva_both_side' => '0',
'amount_vat' => '0.0000',
- 'amount_wovat' => '1047.9000',
+ 'amount_wovat' => '1102.9500',
'amount_sided' => '0.0000',
'tva_type' => 'O',
),
@@ -30,8 +30,8 @@ array (
'jrn_def_name' => 'Vente',
'tva_label' => 'INTRA',
'qs_vat_code' => '5',
- 'tva_rate' => '0.0000',
- 'tva_both_side' => '0',
+ 'tva_rate' => '0.2100',
+ 'tva_both_side' => '1',
'amount_vat' => '0.0000',
'amount_wovat' => '1800.0000',
'amount_sided' => '0.0000',
@@ -47,7 +47,7 @@ array (
'amount_vat' => '19.1500',
'amount_wovat' => '91.2000',
'amount_sided' => '0.0000',
- 'tva_type' => 'P',
+ 'tva_type' => 'O',
),
4 =>
array (
diff --git a/unit-test/include/class/data/tax_summary_getsummary_purchase_o.php b/unit-test/include/class/data/tax_summary_getsummary_purchase_o.php
index dc6ef6766..0c54bea8a 100644
--- a/unit-test/include/class/data/tax_summary_getsummary_purchase_o.php
+++ b/unit-test/include/class/data/tax_summary_getsummary_purchase_o.php
@@ -1,5 +1,5 @@
array (
@@ -8,7 +8,7 @@ array (
'tva_both_side' => '0',
'qp_vat_code' => '4',
'amount_vat' => '0.0000',
- 'amount_wovat' => '658.2500',
+ 'amount_wovat' => '1262.1500',
'amount_sided' => '0.0000',
'amount_noded_amount' => '0.0000',
'amount_noded_tax' => '0.0000',
@@ -35,8 +35,8 @@ array (
'tva_rate' => '0.2100',
'tva_both_side' => '0',
'qp_vat_code' => '1',
- 'amount_vat' => '289.0800',
- 'amount_wovat' => '1376.5400',
+ 'amount_vat' => '296.2700',
+ 'amount_wovat' => '1410.7900',
'amount_sided' => '0.0000',
'amount_noded_amount' => '0.0000',
'amount_noded_tax' => '0.0000',
@@ -49,8 +49,8 @@ array (
'tva_rate' => '0.0600',
'tva_both_side' => '0',
'qp_vat_code' => '3',
- 'amount_vat' => '5.2800',
- 'amount_wovat' => '88.3200',
+ 'amount_vat' => '7.7200',
+ 'amount_wovat' => '129.2200',
'amount_sided' => '0.0000',
'amount_noded_amount' => '0.0000',
'amount_noded_tax' => '0.0000',
@@ -78,7 +78,7 @@ array (
'tva_both_side' => '0',
'qp_vat_code' => '6',
'amount_vat' => '0.0000',
- 'amount_wovat' => '546.7500',
+ 'amount_wovat' => '567.3900',
'amount_sided' => '0.0000',
'amount_noded_amount' => '0.0000',
'amount_noded_tax' => '0.0000',
@@ -102,8 +102,8 @@ array (
7 =>
array (
'tva_label' => 'INTRA',
- 'tva_rate' => '0.0000',
- 'tva_both_side' => '0',
+ 'tva_rate' => '0.2100',
+ 'tva_both_side' => '1',
'qp_vat_code' => '5',
'amount_vat' => '0.0000',
'amount_wovat' => '1250.0000',
diff --git a/unit-test/include/class/data/tax_summary_getsummary_purchase_t.php b/unit-test/include/class/data/tax_summary_getsummary_purchase_t.php
index a70d697bc..ea4b551d9 100644
--- a/unit-test/include/class/data/tax_summary_getsummary_purchase_t.php
+++ b/unit-test/include/class/data/tax_summary_getsummary_purchase_t.php
@@ -1,5 +1,6 @@
array (
'tva_label' => '0%',
@@ -7,7 +8,7 @@ $a_result = array (
'tva_both_side' => '0',
'qp_vat_code' => '4',
'amount_vat' => '0.0000',
- 'amount_wovat' => '658.2500',
+ 'amount_wovat' => '1262.1500',
'amount_sided' => '0.0000',
'amount_noded_amount' => '0.0000',
'amount_noded_tax' => '0.0000',
@@ -34,8 +35,8 @@ $a_result = array (
'tva_rate' => '0.2100',
'tva_both_side' => '0',
'qp_vat_code' => '1',
- 'amount_vat' => '289.0800',
- 'amount_wovat' => '1376.5400',
+ 'amount_vat' => '296.2700',
+ 'amount_wovat' => '1410.7900',
'amount_sided' => '0.0000',
'amount_noded_amount' => '0.0000',
'amount_noded_tax' => '0.0000',
@@ -48,8 +49,8 @@ $a_result = array (
'tva_rate' => '0.0600',
'tva_both_side' => '0',
'qp_vat_code' => '3',
- 'amount_vat' => '5.2800',
- 'amount_wovat' => '88.3200',
+ 'amount_vat' => '7.7200',
+ 'amount_wovat' => '129.2200',
'amount_sided' => '0.0000',
'amount_noded_amount' => '0.0000',
'amount_noded_tax' => '0.0000',
@@ -77,7 +78,7 @@ $a_result = array (
'tva_both_side' => '0',
'qp_vat_code' => '6',
'amount_vat' => '0.0000',
- 'amount_wovat' => '546.7500',
+ 'amount_wovat' => '567.3900',
'amount_sided' => '0.0000',
'amount_noded_amount' => '0.0000',
'amount_noded_tax' => '0.0000',
@@ -101,8 +102,8 @@ $a_result = array (
7 =>
array (
'tva_label' => 'INTRA',
- 'tva_rate' => '0.0000',
- 'tva_both_side' => '0',
+ 'tva_rate' => '0.2100',
+ 'tva_both_side' => '1',
'qp_vat_code' => '5',
'amount_vat' => '0.0000',
'amount_wovat' => '1250.0000',
diff --git a/unit-test/include/class/data/tax_summary_getsummary_sale_o.php b/unit-test/include/class/data/tax_summary_getsummary_sale_o.php
index 64abaf88a..f72995c46 100644
--- a/unit-test/include/class/data/tax_summary_getsummary_sale_o.php
+++ b/unit-test/include/class/data/tax_summary_getsummary_sale_o.php
@@ -1,16 +1,16 @@
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_vat' => '1343.9600',
+ 'amount_wovat' => '6399.8500',
'amount_sided' => '0.0000',
- 'tva_payment_sale' => 'P',
+ 'tva_payment_sale' => 'O',
),
1 =>
array (
@@ -19,7 +19,7 @@ $a_result = array (
'tva_rate' => '0.0000',
'tva_both_side' => '0',
'amount_vat' => '0.0000',
- 'amount_wovat' => '1198.4600',
+ 'amount_wovat' => '1253.5100',
'amount_sided' => '0.0000',
'tva_payment_sale' => 'O',
),
@@ -27,8 +27,8 @@ $a_result = array (
array (
'tva_label' => 'INTRA',
'qs_vat_code' => '5',
- 'tva_rate' => '0.0000',
- 'tva_both_side' => '0',
+ 'tva_rate' => '0.2100',
+ 'tva_both_side' => '1',
'amount_vat' => '0.0000',
'amount_wovat' => '1800.0000',
'amount_sided' => '0.0000',
@@ -43,6 +43,6 @@ $a_result = array (
'amount_vat' => '19.1500',
'amount_wovat' => '91.2000',
'amount_sided' => '0.0000',
- 'tva_payment_sale' => 'P',
+ 'tva_payment_sale' => 'O',
),
);
diff --git a/unit-test/include/class/data/tax_summary_getsummary_sale_t.php b/unit-test/include/class/data/tax_summary_getsummary_sale_t.php
index 37a88cc5b..e230b45d2 100644
--- a/unit-test/include/class/data/tax_summary_getsummary_sale_t.php
+++ b/unit-test/include/class/data/tax_summary_getsummary_sale_t.php
@@ -1,5 +1,5 @@
array (
@@ -7,8 +7,8 @@ array (
'qs_vat_code' => '1',
'tva_rate' => '0.2100',
'tva_both_side' => '0',
- 'amount_vat' => '219.5700',
- 'amount_wovat' => '1045.6000',
+ 'amount_vat' => '1343.9600',
+ 'amount_wovat' => '6399.8500',
'amount_sided' => '0.0000',
'tva_payment_sale' => 'O',
),
@@ -19,7 +19,7 @@ array (
'tva_rate' => '0.0000',
'tva_both_side' => '0',
'amount_vat' => '0.0000',
- 'amount_wovat' => '1198.4600',
+ 'amount_wovat' => '1253.5100',
'amount_sided' => '0.0000',
'tva_payment_sale' => 'O',
),
@@ -27,8 +27,8 @@ array (
array (
'tva_label' => 'INTRA',
'qs_vat_code' => '5',
- 'tva_rate' => '0.0000',
- 'tva_both_side' => '0',
+ 'tva_rate' => '0.2100',
+ 'tva_both_side' => '1',
'amount_vat' => '0.0000',
'amount_wovat' => '1800.0000',
'amount_sided' => '0.0000',
diff --git a/unit-test/include/class/fiche.Test.php b/unit-test/include/class/fiche.Test.php
index 56d384389..9bb77d84b 100644
--- a/unit-test/include/class/fiche.Test.php
+++ b/unit-test/include/class/fiche.Test.php
@@ -72,7 +72,7 @@ class FicheTest extends TestCase
$a=new Fiche($g_connection,$card_count[0]['f_id']);
try {
$a->get_row(235,238);
- $this->assertFalse(TRUE,"Exception periode non executée");
+ $this->assertFalse(TRUE,"Exception periode invalide");
} catch (\Exception $e) {
$this->assertTrue(TRUE);
}
@@ -81,7 +81,7 @@ class FicheTest extends TestCase
$nb_result=count($a_result);
$this->assertEquals ($nb_result,3,"Size array not correct ");
- $this->assertEquals($a_result[0][24]["deb_montant"],204.71);
+ $this->assertEquals(198.74,$a_result[0][13]["deb_montant"],"Debit from operation 12");
}
/**
diff --git a/unit-test/include/class/impressTest.class.php b/unit-test/include/class/impressTest.class.php
new file mode 100644
index 000000000..f44486625
--- /dev/null
+++ b/unit-test/include/class/impressTest.class.php
@@ -0,0 +1,190 @@
+
+
+/**
+ * @file
+ * @brief test impress.class.php
+ *
+ *
+ */
+class ImpressTest 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';
+ }
+
+ /**
+ * Tears down the fixture, for example, closes a network connection.
+ * This method is called after a test is executed.
+ */
+ protected function tearDown()
+ {
+
+ }
+
+ /**
+ *
+ * @covers Impress::check_formula
+ */
+ function test_check_formula()
+ {
+ $aFormulaTest=array(
+ ['1', true],
+ ['(45+5)', true],
+ ['round([45])', true],
+ ['$A=9', true],
+ ['$S30=($F1 >=0)?$F1:0', true],
+ ['[45%]', true],
+ ['[50]*[51%]', true],
+ ['$A1=[50]*[51%]', true],
+ ['[50]*9', true],
+ ['[50]*9.0', true],
+ ['[50%]*9', true],
+ ['$C1111=[50%]*9', true],
+ ['$C1111=[50%]*9*$D1', true],
+ ['$C10=[10%]', true],
+ ['[50%]*9.0', true],
+ ['[50%]*9.0 FROM=01.2004', true],
+ ['[50%]*9.0FROM=01.2004', true],
+ ['system', false],
+ ['unlink', false],
+ ['ls -1', false],
+ ['', false],
+ ["[45ABC]*1", true],
+ ["[4511-s]", true],
+ ["{TEL}", true],
+ ["{TEL}*45", true],
+ ["{TEL-s}*45", true],
+ ["{1TEL-s}*45", true],
+ ["{1TEL}*45", true],
+ ["{T*EL-s}*45", false],
+ ["{T+EL-s}*45", false],
+ ["{T/EL-s}*45", false]
+ );
+ foreach ($aFormulaTest as $formula)
+ {
+ $this->assertEquals(\Impress::check_formula($formula[0]), $formula[1], " $formula[0] ");
+
+ foreach (array('+', '-', '/') as $b)
+ {
+ $ee=str_replace('*', $b, $formula[0]);
+ $this->assertEquals(\Impress::check_formula($formula[0]), $formula[1], " with $formula[0] ");
+ }
+ for ($e=0; $e<3; $e++)
+ {
+ $formula[0].="*".$formula[0];
+ $this->assertEquals(\Impress::check_formula($formula[0]), $formula[1], " with $formula[0] ");
+ }
+ }
+ }
+
+ /***
+ * @covers Impress::parse_formula
+ */
+
+ function test_compute_amount()
+ {
+ global $g_connection;
+ // filter on period
+ $sql_periode="j_date >= '2018-01-01' and j_date <= '2018-12-31'";
+
+ // 0 = formula , 1 is the expected value
+ $aFormula=array(
+ ["[70%-s]", -456.8000],
+ ["[61%-s]", 1491.5000],
+ ["[61%-S]", -1491.5000],
+ ["[61%-d]", 1591.50],
+ ["[61%-c]", 100.00]
+ );
+ foreach ($aFormula as $formula) {
+ $this->assertEquals($formula[1],\Impress::compute_amount($g_connection,$formula[0],$sql_periode),
+ " {$formula[0]} = {$formula[1]}");
+ }
+ }
+
+ /**
+ * Test pattern
+ *
+ */
+ function test_pattern()
+ {
+ $a_formula=array(
+ ["[4500%-s]+[60]-[770-d]+120",3],
+ ["{TEL}+[60]*5",2],
+ ["{TEL-s}+[60]",2],
+ ["{TEL-S}+[60]",2],
+ ["{TEL}+[60-s]",2],
+ ["{{TEL}}+[60-s]",2]
+ );
+ foreach ($a_formula as $p_formula)
+ {
+ $formula=$p_formula[0];
+ $result=$p_formula[1];
+ $this->assertEquals(preg_match_all(\Impress::STR_PATTERN, $formula, $e),$result,
+ " check $formula returns $result");
+
+
+ }
+ }
+ /**
+ * @covers compute_periode
+ */
+ function test_computePeriode()
+ {
+ global $g_connection,$g_parameter,$g_user;
+ $g_user->set_periode(110);
+ $this->assertEquals(trim("j_tech_per in (select p_id from parm_periode where p_start >= to_date('01.01.2017','DD.MM.YYYY') and p_end <= to_date('30.11.2017','DD.MM.YYYY'))"),trim(\Impress::compute_periode($g_connection, "00.0000",115))
+ ," SQL from 01.01.2017 to 01.11.2017");
+ $this->assertEquals(
+ trim("j_tech_per in (select p_id from parm_periode where p_start >= to_date('01.02.2017','DD.MM.YYYY') and p_end <= to_date('31.10.2017','DD.MM.YYYY'))"),
+ trim(\Impress::compute_periode($g_connection, "02.2017",114)),
+ " SQL from 01.02.2017 to 01.10.2017");
+
+
+ }
+ function test_parse_formula()
+ {
+ global $g_connection,$g_user;
+ $a_formula=array(
+ array("sum 70% (credit is negative)", "[70%-s]",-456.80),
+ array("sum 70% (credit is negative)", "0-round([70%-s],2)",456.80),
+ );
+ foreach ($a_formula as $formula)
+ {
+ $result=\Impress::parse_formula($g_connection,$formula[0], $formula[1], 92, 103);
+ $this->assertEquals($formula[2],$result['montant'],$formula[0]);
+
+ }
+ }
+}
diff --git a/unit-test/include/class/print_operation_currencyTest.php b/unit-test/include/class/print_operation_currencyTest.php
index 8a5b4dff3..a7e24f7be 100644
--- a/unit-test/include/class/print_operation_currencyTest.php
+++ b/unit-test/include/class/print_operation_currencyTest.php
@@ -41,10 +41,10 @@ class Print_Operation_CurrencyTest extends TestCase
function testFilter_data_currency_card_categoryTest()
{
$cn=Dossier::connect();
- $from_date='01.01.2000';
- $to_date='01.01.2099';
+ $from_date='01.01.2020';
+ $to_date='31.12.2020';
$currency_id=0;
- $card_category=4;
+ $card_category=2;
$object=new Filter_Data_Currency_Card_Category($cn,
$from_date,
$to_date,
@@ -54,12 +54,12 @@ class Print_Operation_CurrencyTest extends TestCase
$this->assertContains(" and jrnx.f_id in ( select f_id from fiche where fd_id=$4)",$sql);
$array=$object->get_data();
- $this->assertEquals(count($array),29,"operation in EURO");
+ $this->assertEquals(count($array),2,"operation in EURO");
$object->setCurrency_id(1);
$array=$object->get_data();
- $this->assertEquals(count($array),3,"operations in Dollars");
+ $this->assertEquals(count($array),2,"operations in Dollars");
}
/**
@@ -69,8 +69,8 @@ class Print_Operation_CurrencyTest extends TestCase
function testData_currency_operationTest()
{
$cn=Dossier::connect();
- $from_date='01.01.2000';
- $to_date='01.01.2099';
+ $from_date='01.01.2020';
+ $to_date='31.12.2020';
$currency_id=0;
$object=new Data_Currency_Operation($cn,
@@ -82,12 +82,12 @@ class Print_Operation_CurrencyTest extends TestCase
$this->assertContains("where jrn.currency_id = $1 and",$sql);
$array=$object->get_data();
- $this->assertEquals(count($array),142,"operation in EURO");
+ $this->assertEquals(count($array),7,"operation in EURO");
$object->setCurrency_id(1);
$array=$object->get_data();
- $this->assertEquals(count($array),21,"operations in Dollars");
+ $this->assertEquals(count($array),8,"operations in Dollars");
}
/**
* @brief test Filter_Data_Currency_Card
@@ -96,10 +96,10 @@ class Print_Operation_CurrencyTest extends TestCase
function testFilter_data_currency_cardTest()
{
$cn=Dossier::connect();
- $from_date='01.01.2000';
- $to_date='01.01.2099';
+ $from_date='01.01.2020';
+ $to_date='31.12.2020';
$currency_id=0;
- $card='FOURNI';
+ $card='FOURNI1';
$object=new Filter_Data_Currency_Card($cn,
$from_date,
$to_date,
@@ -109,13 +109,13 @@ class Print_Operation_CurrencyTest extends TestCase
$this->assertContains("and f_id=$4",$sql);
$array=$object->get_data();
- $this->assertEquals(count($array),4,"operation in EURO");
+ $this->assertEquals(count($array),1,"operation in EURO");
$object->setCurrency_id(1);
$object->setCard("FOURNI1");
$array=$object->get_data();
- $this->assertEquals(count($array),3,"operations in Dollars");
+ $this->assertEquals(count($array),1,"operations in Dollars");
}
/**
* @brief test Filter_Data_Currency_Card_Accounting
@@ -124,8 +124,8 @@ class Print_Operation_CurrencyTest extends TestCase
function testFilter_data_currency_accounting()
{
$cn=Dossier::connect();
- $from_date='01.01.2000';
- $to_date='01.01.2099';
+ $from_date='01.01.2020';
+ $to_date='31.12.2020';
$currency_id=0;
$from_poste='40';
$to_poste='450';
@@ -139,18 +139,18 @@ class Print_Operation_CurrencyTest extends TestCase
$sql=$object->SQL_Condition();
$this->assertContains("and j_poste >= $4 and j_poste <= $5",$sql);
$array=$object->get_data();
- $this->assertEquals(72,count($array),"operation in EURO");
+ $this->assertEquals(3,count($array),"operation in EURO");
$object->setCurrency_id(1);
$array=$object->get_data();
- $this->assertEquals(10,count($array),"operations in Dollars");
+ $this->assertEquals(3,count($array),"operations in Dollars");
}
function testPrint_operation_currency()
{
$_REQUEST['from_date']='01.01.2000';
- $_REQUEST['to_date']='01.01.2099';
+ $_REQUEST['to_date']='31.12.2020';
$_REQUEST['p_currency_code']=0;
$_REQUEST['from_account']='40';
$_REQUEST['to_account']='450';
@@ -170,7 +170,7 @@ class Print_Operation_CurrencyTest extends TestCase
Noalyss\Facility::save_file(__DIR__."/file", "print_operation_currency_by_accounting.csv",
$csv);
- $this->assertEquals(72,count($array),"by_accounting operation in EURO");
+ $this->assertEquals(5,count($array),"by_accounting operation in EURO");
$_REQUEST['p_currency_code']=1;
$print_operation=Print_Operation_Currency::build("by_card");
@@ -188,11 +188,11 @@ class Print_Operation_CurrencyTest extends TestCase
- $this->assertEquals(3,count($array),"by_card operation in USD");
+ $this->assertEquals(4,count($array),"by_card operation in USD");
$print_operation=Print_Operation_Currency::build("all");
$array=$print_operation->getData_operation()->get_data();
- $this->assertEquals(count($array),21,"all operations in Dollars");
+ $this->assertEquals(22,count($array),"all operations in Dollars");
ob_start();
$print_operation->export_csv($export);
$csv=ob_get_contents();
diff --git a/unit-test/include/class/tax_summary.Test.php b/unit-test/include/class/tax_summary.Test.php
index 2b6d37058..02d7501bb 100644
--- a/unit-test/include/class/tax_summary.Test.php
+++ b/unit-test/include/class/tax_summary.Test.php
@@ -174,7 +174,7 @@ class Tax_SummaryTest extends TestCase
$this->object->set_tva_type("T");
$array=$this->object->get_row_purchase();
//-- For creating the array
- // Noalyss\Facility::save_file(__DIR__."/file", "tax_summary_getrow_purchase.txt", var_export($array, TRUE));
+ Noalyss\Facility::save_file(__DIR__."/file", "tax_summary_getrow_purchase.txt", var_export($array, TRUE));
require __DIR__."/data/tax_summary_getrow_purchase_t.php";
$this->check_result("tva_type = T , get_row_purchase",$array,$a_result,'ACH');
@@ -188,7 +188,7 @@ class Tax_SummaryTest extends TestCase
$this->object->set_tva_type("O");
$array=$this->object->get_row_sale();
//-- For creating the array
- // Noalyss\Facility::save_file(__DIR__."/file", "tax_summary_getrow_sale_o.txt", var_export($array, TRUE));
+ Noalyss\Facility::save_file(__DIR__."/file", "tax_summary_getrow_sale_o.txt", var_export($array, TRUE));
require __DIR__."/data/tax_summary_getrow_sale_o.php";
$this->check_result("tva_type = O , get_row_sale",$array,$a_result,'VEN');
@@ -196,7 +196,7 @@ class Tax_SummaryTest extends TestCase
$this->object->set_tva_type("P");
$array=$this->object->get_row_sale();
//-- For creating the array
- //Noalyss\Facility::save_file(__DIR__."/file", "tax_summary_getrow_sale_p.txt", var_export($array, TRUE));
+ Noalyss\Facility::save_file(__DIR__."/file", "tax_summary_getrow_sale_p.txt", var_export($array, TRUE));
require __DIR__."/data/tax_summary_getrow_sale_p.php";
$this->check_result("tva_type = P , get_row_sale",$array,$a_result,'VEN');
@@ -204,7 +204,7 @@ class Tax_SummaryTest extends TestCase
$this->object->set_tva_type("T");
$array=$this->object->get_row_sale();
//-- For creating the array
- //Noalyss\Facility::save_file(__DIR__."/file", "tax_summary_getrow_sale_t.txt", var_export($array, TRUE));
+ Noalyss\Facility::save_file(__DIR__."/file", "tax_summary_getrow_sale_t.txt", var_export($array, TRUE));
require __DIR__."/data/tax_summary_getrow_sale_t.php";
$this->check_result("tva_type = T , get_row_sale",$array,$a_result,'VEN');
@@ -222,14 +222,14 @@ class Tax_SummaryTest extends TestCase
$this->object->set_tva_type("O");
$array=$this->object->get_summary_purchase();
//-- For creating the array
- // Noalyss\Facility::save_file(__DIR__."/file", "tax_summary_getsummary_purchase_o.txt", var_export($array, TRUE));
+ Noalyss\Facility::save_file(__DIR__."/file", "tax_summary_getsummary_purchase_o.txt", var_export($array, TRUE));
require __DIR__."/data/tax_summary_getsummary_purchase_o.php";
$this->check_result("tva_type = O , get_summary_purchase",$array,$a_result,'SMRACH');
$this->object->set_tva_type("P");
$array=$this->object->get_summary_purchase();
//-- For creating the array
- // Noalyss\Facility::save_file(__DIR__."/file", "tax_summary_getsummary_purchase_p.txt", var_export($array, TRUE));
+ Noalyss\Facility::save_file(__DIR__."/file", "tax_summary_getsummary_purchase_p.txt", var_export($array, TRUE));
require __DIR__."/data/tax_summary_getsummary_purchase_p.php";
$this->check_result("tva_type = P , get_summary_purchase",$array,$a_result,'SMRACH');
@@ -241,7 +241,7 @@ class Tax_SummaryTest extends TestCase
$this->object->set_tva_type("O");
$array=$this->object->get_summary_sale();
//-- For creating the array
- // Noalyss\Facility::save_file(__DIR__."/file", "tax_summary_getsummary_sale_o.txt", var_export($array, TRUE));
+ Noalyss\Facility::save_file(__DIR__."/file", "tax_summary_getsummary_sale_o.txt", var_export($array, TRUE));
require __DIR__."/data/tax_summary_getsummary_sale_o.php";
$this->check_result("tva_type = O , get_summary_sale",$array,$a_result,'SMRVEN');
diff --git a/unit-test/include/lib/ac_common.php b/unit-test/include/lib/ac_commonTest.php
similarity index 87%
rename from unit-test/include/lib/ac_common.php
rename to unit-test/include/lib/ac_commonTest.php
index 750fe4f77..25ce794a1 100644
--- a/unit-test/include/lib/ac_common.php
+++ b/unit-test/include/lib/ac_commonTest.php
@@ -142,6 +142,7 @@ class Ac_CommonTest extends TestCase
/**
* @covers sql_filter_per
+ * @covers transform_sql_filter
*/
function testSQL_filter_per()
{
@@ -151,21 +152,38 @@ class Ac_CommonTest extends TestCase
"p_start >= to_date('01.07.2018','DD.MM.YYYY') and p_end <= to_date('31.08.2018','DD.MM.YYYY'))";
$this->assertEquals(
$result, trim(sql_filter_per($g_connection, "01.07.2018", "31.08.2018", "date", "jr_tech_per")));
-
+ // transform cond for analytic
+ $anc_result="( oa_date >= to_date('01.07.2018','DD.MM.YYYY') and oa_date <= to_date('31.08.2018','DD.MM.YYYY'))";
+ $this->assertEquals(
+ $anc_result, transform_sql_filter_per($result),"1. convert $result to $anc_result");
+
$result="j_tech_per in (select p_id from parm_periode where ".
"p_start >= to_date('01.07.2018','DD.MM.YYYY') and p_end <= to_date('31.08.2018','DD.MM.YYYY'))";
$this->assertEquals(
$result, trim(sql_filter_per($g_connection, "01.07.2018", "31.08.2018", "date", "j_tech_per")));
-
+ // transform cond for analytic
+ $anc_result="( oa_date >= to_date('01.07.2018','DD.MM.YYYY') and oa_date <= to_date('31.08.2018','DD.MM.YYYY'))";
+ $this->assertEquals(
+ $anc_result, transform_sql_filter_per($result),"2. convert $result to $anc_result");
+
$result="j_tech_per = (select p_id from parm_periode where ".
" p_start = to_date('01.07.2018','DD.MM.YYYY'))";
$this->assertEquals(
$result, trim(sql_filter_per($g_connection, "01.07.2018", "01.07.2018", "date", "j_tech_per")));
-
+ // transform cond for analytic
+ $anc_result="( oa_date = to_date('01.07.2018','DD.MM.YYYY'))";
+ $this->assertEquals(
+ $anc_result, transform_sql_filter_per($result),"3. convert $result to $anc_result");
+
+
$result="j_tech_per in (select p_id from parm_periode where ".
"p_start >= to_date('01.07.2018','DD.MM.YYYY') and p_end <= to_date('31.08.2018','DD.MM.YYYY'))";
$this->assertEquals(
$result, trim(sql_filter_per($g_connection, 98, 99, "p_id", "j_tech_per")));
+ // transform cond for analytic
+ $anc_result="( oa_date >= to_date('01.07.2018','DD.MM.YYYY') and oa_date <= to_date('31.08.2018','DD.MM.YYYY'))";
+ $this->assertEquals(
+ $anc_result, transform_sql_filter_per($result),"4. convert $result to $anc_result");
}
/***
* @covers add_http_link