diff --git a/include/export/export_gl_csv.php b/include/export/export_gl_csv.php
index 995a68d79..98a7411da 100644
--- a/include/export/export_gl_csv.php
+++ b/include/export/export_gl_csv.php
@@ -53,33 +53,12 @@ $gDossier=dossier::id();
$cn=Dossier::connect();
$export=new Noalyss_Csv(_('grandlivre'));
-$poste_id=$http->get('poste_id',"string","");
+$accounting_item_id=$http->get('poste_id',"string","");
$export->send_header();
- $cond_poste='';
- $sql="select pcm_val from tmp_pcmn ";
- if ($from_poste != '')
- {
- $cond_poste = ' where ';
- $cond_poste .=" pcm_val >= upper ('".Database::escape_string($from_poste)."')";
- }
- if ( $to_poste != '')
- {
- if ( $cond_poste == '')
- {
- $cond_poste = " where pcm_val <= upper ('".Database::escape_string($to_poste)."')";
- }
- else
- {
- $cond_poste.=" and pcm_val <= upper ('".Database::escape_string($to_poste)."')";
- }
- }
+$a_accounting=Acc_Account_Ledger::get_used_accounting($from_periode,$to_periode,$from_poste,$to_poste);
- $sql=$sql.$cond_poste.' order by pcm_val::text';
-
- $a_poste=$cn->get_array($sql);
-
-if ( count($a_poste) == 0 )
+if ( count($a_accounting) == 0 )
{
echo _('Aucun résultat');
printf("\n");
@@ -92,13 +71,13 @@ $header = array( _("Date"), _("Référence"), _("Libellé"), _("Pièce"),_("Lett
$l=(isset($_GET['letter']))?2:0;
$s=(isset($_REQUEST['solded']))?1:0;
-foreach ($a_poste as $poste)
+foreach ($a_accounting as $accounting_item)
{
- $Poste=new Acc_Account_Ledger($cn,$poste['pcm_val']);
+ $acc_account_ledger=new Acc_Account_Ledger($cn,$accounting_item['pcm_val']);
- $array1=$Poste->get_row_date($from_periode,$to_periode,$l,$s);
+ $array1=$acc_account_ledger->get_row_date($from_periode,$to_periode,$l,$s);
// don't print empty account
if ( count($array1) == 0 )
{
@@ -114,7 +93,7 @@ foreach ($a_poste as $poste)
continue;
}
- $export->add(sprintf("%s - %s ",$Poste->id,$Poste->get_name()));
+ $export->add(sprintf("%s - %s ",$accounting_item['pcm_val'],$accounting_item['pcm_lib']));
$export->write();
$export->write_header($header);
@@ -123,7 +102,7 @@ foreach ($a_poste as $poste)
$solde_c = 0.0;
bcscale(2);
$current_exercice="";
- foreach ($Poste->row as $detail)
+ foreach ($acc_account_ledger->row as $detail)
{
/*
@@ -148,7 +127,7 @@ foreach ($a_poste as $poste)
$export->add($current_exercice);
$export->add("");
$export->add("");
- $export->add(_('Total')." ".$Poste->id);
+ $export->add(_('Total')." ".$acc_account_ledger->id);
if ( $solde_d > 0 ) {
$export->add($solde_d,"number");
} else {
@@ -200,7 +179,7 @@ foreach ($a_poste as $poste)
else
$export->add("");
$export->add(abs($solde),"number");
- $export->add($Poste->get_amount_side($solde),"text");
+ $export->add($acc_account_ledger->get_amount_side($solde),"text");
$export->write();
}
@@ -210,7 +189,7 @@ foreach ($a_poste as $poste)
$export->add($current_exercice);
$export->add("");
$export->add("");
- $export->add(_('Total').$Poste->id);
+ $export->add(_('Total').$acc_account_ledger->id);
if ($solde_d > 0 ) $export->add($solde_d,"number"); else $export->add("");
if ($solde_c > 0 ) $export->add($solde_c,"number"); else $export->add("");
$export->add(abs($solde_c-$solde_d),"number");
diff --git a/include/export/export_gl_pdf.php b/include/export/export_gl_pdf.php
index 531a9ef9d..24578f883 100644
--- a/include/export/export_gl_pdf.php
+++ b/include/export/export_gl_pdf.php
@@ -41,29 +41,7 @@ $cn=Dossier::connect();
$g_user->Check();
$g_user->check_dossier($gDossier);
-$sql="select pcm_val from tmp_pcmn ";
-
-$cond_poste="";
-if ($from_poste != '')
- {
- $cond_poste = ' where ';
- $cond_poste .=' pcm_val >= upper (\''.Database::escape_string($from_poste).'\')';
- }
-
-if ( $to_poste != '')
- {
- if ( $cond_poste == '')
- {
- $cond_poste = ' where pcm_val <= upper (\''.Database::escape_string($to_poste).'\')';
- }
- else
- {
- $cond_poste.=' and pcm_val <= upper (\''.Database::escape_string($to_poste).'\')';
- }
- }
-
-$sql=$sql.$cond_poste.' order by pcm_val::text';
-$a_poste=$cn->get_array($sql);
+$a_accounting=Acc_Account_Ledger::get_used_accounting($from_periode,$to_periode,$from_poste,$to_poste);
$pdf = new PDF($cn);
$pdf->setDossierInfo(_(" Periode : ").$from_periode." - ".$to_periode);
@@ -72,7 +50,7 @@ $pdf->AddPage();
$pdf->setTitle("Grand Livre",true);
$pdf->SetAuthor('NOALYSS');
-if ( count($a_poste) == 0 )
+if ( count($a_accounting) == 0 )
{
$pdf->Output();
return;
@@ -87,13 +65,12 @@ $width = array( 13 , 20 , 60 , 15 , 12 , 20 , 20
$l=(isset($_REQUEST['letter']))?2:0;
$s=(isset($_REQUEST['solded']))?1:0;
-foreach ($a_poste as $poste)
+foreach ($a_accounting as $accounting_item)
{
- $Poste=new Acc_Account_Ledger($cn,$poste['pcm_val']);
-
-
- $array1=$Poste->get_row_date($from_periode,$to_periode,$l,$s);
+ $acc_account_ledger=new Acc_Account_Ledger($cn,$accounting_item['pcm_val']);
+
+ $array1=$acc_account_ledger->get_row_date($from_periode,$to_periode,$l,$s);
// don't print empty account
if (empty($array1) || count($array1[0]) == 0 )
{
@@ -104,7 +81,7 @@ foreach ($a_poste as $poste)
$tot_cred=$array1[2];
$pdf->SetFont('DejaVuCond','',10);
- $Libelle=sprintf("%s - %s ",$Poste->id,$Poste->get_name());
+ $Libelle=sprintf("%s - %s ",$accounting_item['pcm_val'],$accounting_item['pcm_lib']);
$pdf->write_cell(0, 7, $Libelle, 1, 1, 'C');
$pdf->SetFont('DejaVuCond','',6);
@@ -119,7 +96,7 @@ foreach ($a_poste as $poste)
$solde_d = 0.0;
$solde_c = 0.0;
$current_exercice="";
- foreach ($Poste->row as $detail)
+ foreach ($acc_account_ledger->row as $detail)
{
/*
@@ -151,7 +128,7 @@ foreach ($a_poste as $poste)
$i++;
$pdf->write_cell($width[$i], 6, '', 0, 0, $lor[$i]);
$i++;
- $pdf->write_cell($width[$i], 6, 'Total du compte '.$Poste->id, 0, 0, 'R');
+ $pdf->write_cell($width[$i], 6, 'Total du compte '.$acc_account_ledger->id, 0, 0, 'R');
$i++;
$pdf->write_cell($width[$i], 6, ($solde_d > 0 ? nbm($solde_d) : ''), 0, 0, $lor[$i]);
$i++;
@@ -184,7 +161,7 @@ foreach ($a_poste as $poste)
}
$i = 0;
- $side=" ".$Poste->get_amount_side($solde);
+ $side=" ".$acc_account_ledger->get_amount_side($solde);
$pdf->LongLine($width[$i], 6, shrink_date($detail['j_date_fmt']), 0, $lor[$i]);
$i++;
$pdf->LongLine($width[$i], 6, $detail['jr_internal'], 0, $lor[$i] );
@@ -220,7 +197,7 @@ foreach ($a_poste as $poste)
$i++;
$pdf->write_cell($width[$i], 6, '', 0, 0, $lor[$i]);
$i++;
- $pdf->write_cell($width[$i], 6, 'Total du compte '.$Poste->id, 0, 0, 'R');
+ $pdf->write_cell($width[$i], 6, 'Total du compte '.$acc_account_ledger->id, 0, 0, 'R');
$i++;
$pdf->write_cell($width[$i], 6, ($solde_d > 0 ? nbm($solde_d) : ''), 0, 0, $lor[$i]);
$i++;
diff --git a/include/impress_gl_comptes.inc.php b/include/impress_gl_comptes.inc.php
index d9122c232..d583e4d14 100644
--- a/include/impress_gl_comptes.inc.php
+++ b/include/impress_gl_comptes.inc.php
@@ -104,44 +104,29 @@ echo '';
//-----------------------------------------------------
if ( isset( $_REQUEST['bt_html'] ) )
{
+ if ( DEBUGNOALYSS > 1 ) \Noalyss\Dbg::timer_start();
+
echo '
';
echo Acc_Account_Ledger::HtmlTableHeader("gl_comptes");
echo '
';
- $sql='select pcm_val from tmp_pcmn ';
- $cond_poste='';
+ try {
+ $from_periode=$http->request("from_periode","date");
+ $to_periode=$http->request("to_periode","date");
- if ($from_poste->value != '')
- {
- $cond_poste = ' where ';
- $cond_poste .=' pcm_val >= upper (\''.Database::escape_string($from_poste->value).'\')';
- }
-
- if ( $to_poste->value != '')
- {
- if ( $cond_poste == '')
- {
- $cond_poste = ' where pcm_val <= upper (\''.Database::escape_string($to_poste->value).'\')';
- }
- else
- {
- $cond_poste.=' and pcm_val <= upper (\''.Database::escape_string($to_poste->value).'\')';
- }
- }
-
- $sql=$sql.$cond_poste.' order by pcm_val::text';
-
- $a_poste=$cn->get_array($sql);
-
- if ( sizeof($a_poste) == 0 )
- {
- die("Nothing here. Strange.");
- exit;
- }
- if ( isDate($_REQUEST['from_periode'])==null || isDate($_REQUEST['to_periode'])==null)
- {
+ } catch (Exception $e) {
echo alert(_('Date malformée, désolée'));
return;
}
+
+
+ $a_accounting=Acc_Account_Ledger::get_used_accounting($from_periode,$to_periode,$from_poste->value,$to_poste->value);
+
+ if ( sizeof($a_accounting) == 0 )
+ {
+ echo_warning(_("Aucune donnée"));
+ return;
+ }
+
echo '';
@@ -150,14 +135,12 @@ if ( isset( $_REQUEST['bt_html'] ) )
$s=(isset($_REQUEST['solded']))?1:0;
- foreach ($a_poste as $poste_id )
+ foreach ($a_accounting as $accounting_id )
{
- $Poste=new Acc_Account_Ledger ($cn, $poste_id['pcm_val']);
- $Poste->load();
+ $acc_account_ledger=new Acc_Account_Ledger ($cn, $accounting_id['pcm_val']);
-
- $Poste->get_row_date( $_GET['from_periode'], $_GET['to_periode'],$l,$s);
- if ( empty($Poste->row))
+ $acc_account_ledger->get_row_date( $from_periode, $to_periode,$l,$s);
+ if ( empty($acc_account_ledger->row))
{
continue;
}
@@ -165,7 +148,7 @@ if ( isset( $_REQUEST['bt_html'] ) )
echo '
- '. $poste_id['pcm_val'].' '.h($Poste->label).'
+ '. $accounting_id['pcm_val'].' '.h($accounting_id['pcm_lib']).'
|
';
@@ -188,7 +171,7 @@ if ( isset( $_REQUEST['bt_html'] ) )
$i=0;
$current_exercice="";
- foreach ($Poste->row as $detail)
+ foreach ($acc_account_ledger->row as $detail)
{
/*
* separation per exercice
@@ -199,7 +182,7 @@ if ( isset( $_REQUEST['bt_html'] ) )
echo '
| '.$current_exercice.' |
'.''.' |
- '._("Total du compte").$poste_id['pcm_val'].' |
+ '._("Total du compte").$accounting_id['pcm_val'].' |
'.''.' | '.td("").
''.($solde_d > 0 ? nbm( $solde_d) : '').' |
'.($solde_c > 0 ? nbm( $solde_c) : '').' |
@@ -232,7 +215,7 @@ if ( isset( $_REQUEST['bt_html'] ) )
$solde = bcadd($solde,$detail['deb_montant']);
$solde_d = bcadd($solde_d,$detail['deb_montant']);
}
- $side=" ".$Poste->get_amount_side($solde);
+ $side=" ".$acc_account_ledger->get_amount_side($solde);
$letter="";
$html_let="";
if ($detail['letter'] > 0) {
@@ -256,7 +239,7 @@ if ( isset( $_REQUEST['bt_html'] ) )
echo '
| '.$current_exercice.' |
'.''.' |
- '.''.'Total du compte '.$poste_id['pcm_val'].''.' |
+ '.''.'Total du compte '.$accounting_id['pcm_val'].''.' |
'.''.' | '.td("").
''.''.($solde_d > 0 ? nbm( $solde_d) : '').''.' |
'.''.($solde_c > 0 ? nbm( $solde_c) : '').''.' |
@@ -272,6 +255,8 @@ if ( isset( $_REQUEST['bt_html'] ) )
echo '';
echo Acc_Account_Ledger::HtmlTableHeader("gl_comptes");
echo "";
- exit;
+ if (DEBUGNOALYSS> 1) echo \Noalyss\Dbg::hidden_info("\$acc_account_ledger", $acc_account_ledger);
+ if ( DEBUGNOALYSS > 1 ) \Noalyss\Dbg::timer_show();
+ return;
}
?>
diff --git a/unit-test/include/class/NoalyssUserTest.php b/unit-test/include/class/NoalyssUserTest.php
index 49cdd55ee..659f8a944 100644
--- a/unit-test/include/class/NoalyssUserTest.php
+++ b/unit-test/include/class/NoalyssUserTest.php
@@ -152,7 +152,7 @@ class UserTest extends TestCase
$this->assertEquals(USE_PASS,$old_password,"Password mismatch");
$this->assertFalse($this->object->save_password("test1","test2"),"Passwords must be identical");
- $this->assertTrue($this->object->save_password("test2","test2"),"Identical passwords seen as different");
+ $this->assertTrue($this->object->save_password("Test2++118","Test2++118"),"Identical passwords seen as different");
$this->object->load();
$new_password = $this->object->getPassword();
$this->assertTrue(($old_password != $new_password),"Password not changed old=$old_password new=$new_password");
diff --git a/unit-test/include/class/acc_account_ledger.Test.php b/unit-test/include/class/acc_account_ledger.Test.php
deleted file mode 100644
index 309524755..000000000
--- a/unit-test/include/class/acc_account_ledger.Test.php
+++ /dev/null
@@ -1,455 +0,0 @@
-object=new Acc_Account_Ledger($g_connection, 400);
- $g_connection->exec_sql("update jrn_def set jrn_def_class_deb='4* 2*' where jrn_def_type='ODS'");
- }
-
- /**
- * Tears down the fixture, for example, closes a network connection.
- * This method is called after a test is executed.
- */
- protected function tearDown():void
- {
-
- }
-
- /**
- * @covers Acc_Account_Ledger::get_row
- */
- public function testGet_row()
- {
- $array=$this->object->get_row(92, 103);
- $this->assertEquals(count($array), 3);
- }
-
- /**
- * @covers Acc_Account_Ledger::get_row_date
- */
- public function testGet_row_date()
- {
- global $g_user, $g_connection;
-
- $accounting=new Acc_Account_Ledger($g_connection, '4511');
- $a_array=$accounting->get_row_date('01.01.2018', '31.12.2018', 0);
- $expected=array(
- 0=>
- array(
- 0=>
- array(
- 'j_id'=>'820',
- 'jr_id'=>'317',
- 'j_date_fmt'=>'01.01.2018',
- 'j_date'=>'2018-01-01',
- 'j_qcode'=>NULL,
- 'deb_montant'=>'0',
- 'cred_montant'=>'8.4000',
- 'description'=>'Ecriture d\'ouverture 2018 TVA à payer 21%',
- 'jrn_name'=>'Opération Diverses',
- 'j_debit'=>'f',
- 'jr_internal'=>'O000172',
- 'jr_pj_number'=>'ODS44',
- 'letter'=>NULL,
- 'pcm_lib'=>'TVA à payer 21%',
- 'jr_optype'=>'OPE',
- 'jr_tech_per'=>'92',
- 'p_exercice'=>'2018',
- '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
- ,'op_analytic' => '0'
-
- ),
- 1=>
- array(
- 'j_id'=>'6',
- 'jr_id'=>'2',
- 'j_date_fmt'=>'24.02.2018',
- 'j_date'=>'2018-02-24',
- 'j_qcode'=>NULL,
- 'deb_montant'=>'0',
- 'cred_montant'=>'8.4000',
- 'description'=>'Déplacement',
- 'jrn_name'=>'Vente',
- 'j_debit'=>'f',
- 'jr_internal'=>'V000002',
- 'jr_pj_number'=>'VEN2',
- 'letter'=>NULL,
- 'pcm_lib'=>'TVA à payer 21%',
- 'jr_optype'=>'NOR',
- 'jr_tech_per'=>'93',
- 'p_exercice'=>'2018',
- '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
- ,'op_analytic' => '0'
-
-
- ),
- 2=>
- array(
- 'j_id'=>'9',
- 'jr_id'=>'3',
- 'j_date_fmt'=>'24.02.2018',
- 'j_date'=>'2018-02-24',
- 'j_qcode'=>NULL,
- 'deb_montant'=>'0',
- 'cred_montant'=>'5.2900',
- 'description'=>'Vente de marchandises',
- 'jrn_name'=>'Vente',
- 'j_debit'=>'f',
- 'jr_internal'=>'V000003',
- 'jr_pj_number'=>'VEN3',
- 'letter'=>NULL,
- 'pcm_lib'=>'TVA à payer 21%',
- 'jr_optype'=>'NOR',
- 'jr_tech_per'=>'93',
- 'p_exercice'=>'2018',
- '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
- ,'op_analytic' => '0'
-
- ),
- 3=>
- array(
- 'j_id'=>'13',
- 'jr_id'=>'4',
- 'j_date_fmt'=>'24.02.2018',
- 'j_date'=>'2018-02-24',
- 'j_qcode'=>NULL,
- 'deb_montant'=>'0',
- 'cred_montant'=>'35.7400',
- 'description'=>'Vente de marchandises',
- 'jrn_name'=>'Vente',
- 'j_debit'=>'f',
- 'jr_internal'=>'V000004',
- 'jr_pj_number'=>'VEN4',
- 'letter'=>NULL,
- 'pcm_lib'=>'TVA à payer 21%',
- 'jr_optype'=>'NOR',
- 'jr_tech_per'=>'93',
- 'p_exercice'=>'2018',
- '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
- ,'op_analytic' => '0'
-
- ),
- 4=>
- array(
- 'j_id'=>'17',
- 'jr_id'=>'5',
- 'j_date_fmt'=>'24.04.2018',
- 'j_date'=>'2018-04-24',
- 'j_qcode'=>NULL,
- 'deb_montant'=>'0',
- 'cred_montant'=>'35.7400',
- 'description'=>'Marchandise et Déplacement',
- 'jrn_name'=>'Vente',
- 'j_debit'=>'f',
- 'jr_internal'=>'V000005',
- 'jr_pj_number'=>'VEN5',
- 'letter'=>NULL,
- 'pcm_lib'=>'TVA à payer 21%',
- 'jr_optype'=>'NOR',
- 'jr_tech_per'=>'95',
- 'p_exercice'=>'2018',
- '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
- ,'op_analytic' => '0'
- ),
- 5=>
- array(
- 'j_id'=>'818',
- 'jr_id'=>'316',
- 'j_date_fmt'=>'12.09.2018',
- 'j_date'=>'2018-09-12',
- 'j_qcode'=>NULL,
- 'deb_montant'=>'0',
- 'cred_montant'=>'21.0000',
- 'description'=>'Vente en OD TVA à payer 21%',
- 'jrn_name'=>'Opération Diverses',
- 'j_debit'=>'f',
- 'jr_internal'=>'O000171',
- 'jr_pj_number'=>'ODS43',
- 'letter'=>NULL,
- 'pcm_lib'=>'TVA à payer 21%',
- 'jr_optype'=>'NOR',
- 'jr_tech_per'=>'100',
- 'p_exercice'=>'2018',
- '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
- ,'op_analytic' => '0'
-
- ),
- ),
- 1=>'0',
- 2=>'114.5700',
- );
- $this->assertEquals($expected, $a_array);
- }
-
- function dataGet_Name()
- {
- return array(
- array('10', 'Capital '),
- array('01', 'Poste inconnu')
- );
- }
-
- /**
- * @covers Acc_Account_Ledger::get_name
- * @dataProvider dataGet_Name
- */
- public function testGet_name($id, $result)
- {
- $this->object->id=$id;
- $this->assertEquals($this->object->get_name(), $result);
- }
-
- /**
- * @covers Acc_Account_Ledger::do_exist
- * @dataProvider dataDo_exist
- */
- public function testDo_exist($p_value, $result)
- {
- $this->object->id=$p_value;
- $this->assertEquals($this->object->do_exist(), $result);
- }
-
- function dataDo_exist()
- {
- return array(
- array('400', 1),
- array('400A', 0),
- array('550', 1),
- array('60BXX', 0)
- );
- }
-
- /**
- * @covers Acc_Account_Ledger::load
- */
- public function testLoad()
- {
- $this->object->load();
- $this->assertTrue($this->object->id==400, "test load");
- }
-
- /**
- * @covers Acc_Account_Ledger::get_solde
- */
- public function testGet_solde()
- {
- global $g_connection;
- $accounting=new Acc_Account_Ledger($g_connection, '4511');
- $this->assertEquals(356.85,$accounting->get_solde(),"get_solde");
- }
-
- /**
- * @covers Acc_Account_Ledger::get_solde_detail
- */
- public function testGet_solde_detail()
- {
- global $g_connection;
- $accounting=new Acc_Account_Ledger($g_connection, '4511');
- $expected=array (
- 'debit' => '0',
- 'credit' => '356.8500',
- 'solde' => 356.85,
- );
- $this->assertEquals($accounting->get_solde_detail(),$expected);
- }
-
- /**
- * @covers Acc_Account_Ledger::isTVA
- */
- public function testIsTVA()
- {
- $this->object->id="4111";
- $this->assertEquals($this->object->isTVA(), 1);
- $this->object->id=10;
- $this->assertEquals($this->object->isTVA(), 0);
- }
-
- /**
- * @covers Acc_Account_Ledger::HtmlTable
- */
- public function testHtmlTable()
- {
- $this->assertTrue(true, 'Ne peut être testé car vue HTML');
- }
-
- public function dataGet_amount_side()
- {
- return array(
- array(0, "="),
- array(1000, 'D'),
- array(-1000, 'C'),
- );
- }
-
- /**
- * @covers Acc_Account_Ledger::get_amount_side
- * @dataProvider dataGet_amount_side
- */
- public function testGet_amount_side($amount, $result)
- {
- $this->assertEquals($this->object->get_amount_side($amount), $result);
- }
-
-
-
- /**
- * @covers Acc_Account_Ledger::belong_ledger
- * @dataProvider DataBelong_ledger
- */
- public function testBelong_ledger($p_jrn, $result)
- {
- $this->assertEquals($this->object->belong_ledger($p_jrn), $result);
- }
-
- function DataBelong_ledger()
- {
- return array(
- array(-1, 0),
- array(1, -1),
- array(3, 0),
- array(2, -1),
- array(4, 0)
- );
- }
-
- public function dataGet_account_ledger()
- {
- return array(
- array(0, array()),
- array(1, array()),
- array(2, array()),
- array(3, array()),
- array(4, array('4*','2*'))
- );
- }
-
- /**
- * @covers Acc_Account_Ledger::get_account_ledger
- * @dataProvider dataGet_account_ledger
- */
- public function testGet_account_ledger($p_jrn, $result)
- {
- $this->assertEquals($this->object->get_account_ledger($p_jrn), $result);
- }
-
- /**
- * @covers Acc_Account_Ledger::build_sql_account
- * @dataProvider DataBuild_Sql_account
- */
- public function testBuild_sql_account($p_jrn, $result)
- {
- $value=$this->object->build_sql_account($p_jrn);
- $this->assertEquals(trim($value), $result);
- }
-
- public function DataBuild_Sql_account()
- {
- return array(
- array(0, ""),
- array(1, ""),
- array(2, ""),
- array(3, ""),
- array(4, "pcm_val::text like '4%' or pcm_val::text like '2%'")
- );
- }
-
- function dataFind_Card()
- {
- return array(
- array('6191', '27'),
- array('6192', '28'),
- array('4400004', '25')
- );
- }
-
- /**
- * @covers Acc_Account_Ledger::find_card
- * @todo Implement testFind_card().
- * @dataProvider dataFind_Card()
- */
- public function testFind_card($p_value, $p_card)
- {
- $this->object->id=$p_value;
- $result=$this->object->find_card();
- $this->assertEquals($p_card, $result[0]['f_id']);
- }
-
-}