Merge branch 'dev7102'

This commit is contained in:
Dany De Bontridder 2019-10-26 00:42:09 +02:00
commit 0af1b71ee4
15 changed files with 864 additions and 614 deletions

View file

@ -200,6 +200,7 @@ BODY {
left:1px;
background-color: white;
bottom: initial;
width: 20rem;
}
}
@media only screen and (min-width : 1100px) {

File diff suppressed because it is too large Load diff

View file

@ -275,6 +275,7 @@ class Acc_Ledger_History_Purchase extends Acc_Ledger_History
}
$title[]=_("TVAC/TTC");
$title[]=_("Date paiement");
$title[]=_("Code paiement");
$title[]=_("Méthode paiement");
$title[]=_("Montant paiement");
$title[]=_("n° opération");
@ -330,6 +331,7 @@ class Acc_Ledger_History_Purchase extends Acc_Ledger_History
$row=Database::fetch_array($ret_reconcile, $e);
$export->add($row['jr_date']);
$export->add($row['qcode_bank']);
$export->add($row['qcode_name']);
$export->add($row['jr_montant'],"number");
$export->add($row['jr_internal']);
}

View file

@ -261,7 +261,7 @@ class Acc_Ledger_History_Sale extends Acc_Ledger_History
}
$title[]=_("TVAC/TTC");
$title[]=_("Date paiement");
$title[]=_("Méthode paiement");
$title[]=_("Code paiement");
$title[]=_("Montant paiement");
$title[]=_("n° opération");
@ -313,6 +313,7 @@ class Acc_Ledger_History_Sale extends Acc_Ledger_History
$row=Database::fetch_array($ret_reconcile, $e);
$export->add($row['jr_date']);
$export->add($row['qcode_bank']);
$export->add($row['qcode_name']);
$export->add($row['jr_montant'],"number");
$export->add($row['jr_internal']);

View file

@ -338,7 +338,7 @@ class Acc_Operation
$filter_sql=$g_user->get_ledger_sql('ALL',3);
$filter_sql=str_replace('jrn_def_id','jr_def_id',$filter_sql);
if ( $this->jr_id==0 ) return;
$sql=" select jr_date,j_qcode,j_poste,j_montant,jr_internal,case when j_debit = 'f' then 'C' else 'D' end as debit,jr_comment as description,
$sql=" select jr_id,j_id,jr_date,j_qcode,j_poste,j_montant,jr_internal,case when j_debit = 'f' then 'C' else 'D' end as debit,jr_comment as description,
vw_name,pcm_lib,j_debit,coalesce(comptaproc.get_letter_jnt(j_id),-1) as letter,jr_def_id ".
" from jrnx join jrn on (jr_grpt_id=j_grpt)
join tmp_pcmn on (j_poste=pcm_val)

View file

@ -279,7 +279,7 @@ class Print_Ledger_Simple extends PDF
$sep="";
for ($e=0;$e<$max;$e++) {
$row=Database::fetch_array($ret_reconcile, $e);
$msg=( $row['qcode_bank'] != "")?"[".$row['qcode_bank']."]":$row['jr_internal'];
$msg=( $row['qcode_bank'] != "")?"[".$row['qcode_bank']."]".$row['qcode_name']:$row['jr_internal'];
$str_payment=$row['jr_date'].$msg.$sep;
$sep=' , ';
}

View file

@ -141,6 +141,7 @@ if ( $get_option=="E")
$a_heading[]=_("Date paiement");
$a_heading[]=_("Montant paiement");
$a_heading[]=_("Methode paiement");
$a_heading[]=_("Libellé");
$a_heading[]=_("Opération paiement");
// Prepare the query for reconcile date
@ -176,6 +177,7 @@ if ( $get_option=="E")
$export->add($row['jr_date']);
$export->add($row['jr_montant'],"number");
$export->add($row['qcode_bank']);
$export->add($row['qcode_name']);
$export->add($row['jr_internal']);
}
$export->write();
@ -264,6 +266,7 @@ if ($get_option=="L" && ($jrn_type=='ODS'||$jrn_type=='FIN'||$jrn_type=='GL') )
{
$row=Database::fetch_array($ret_reconcile, $e);
$export->add($row['qcode_bank']);
$export->add($row['qcode_name']);
$export->add($row['jr_date']);
$export->add($row['jr_internal']);
$export->add($row['jr_pj_number']);

View file

@ -210,16 +210,20 @@ $array = $tax_summary->get_row_purchase();
$a_colp=['tva_label','tva_rate','amount_wovat','amount_private','amount_vat','amount_sided',
'amount_noded_amount','amount_noded_tax','amount_noded_return'];
$a_purchase_header = [_("Code TVA"), _("Taux"), _("Montant HT"), _("Privée"), _("Montant TVA"),
_("Montant Autoliquidation"), _("Montant Non Déd"), _("TVA Non Déd"), _("TVA Non Déd & récup")];
_("Montant Autoliquidation"), _("Montant Non Déd"), _("TVA ND"), _("TVA ND récup")];
$nb_purchase = count($a_purchase_header);
$a_size=['tva_label'=>40,'tva_rate'=>10,'amount_wovat'=>32,'amount_private'=>32,'amount_vat'=>32,'amount_sided'=>32,
'amount_noded_amount'=>32,'amount_noded_tax'=>32,'amount_noded_return'=>32];
$nb_col=count($a_colp);
for ($e=2;$e<$nb_col;$e++){
$a_tot[$a_col[$e]]=0;
$a_tot[$a_colp[$e]]=0;
}
for ($i = 0; $i < $nb_array; $i++) {
for ($e=2;$e<$nb_col;$e++){
$colname=$a_col[$e];
$colname=$a_colp[$e];
$a_tot[$colname]=bcadd($a_tot[$colname],$array[$i][$colname]);
}
@ -234,10 +238,12 @@ for ($i = 0; $i < $nb_array; $i++) {
// Display Header
$pdf->SetFont('DejaVuCond', 'B', 7);
for ($e=0;$e<$nb_col;$e++){
$t_idx=$a_colp[$e];
if ( $e == 0 ) {
$pdf->write_cell(40, 5,$a_purchase_header[$e], 1, 0, 'L');
$pdf->write_cell($a_size[$t_idx], 5,$a_purchase_header[$e], 1, 0, 'L');
} else {
$pdf->write_cell(40, 5,$a_purchase_header[$e], 1, 0, 'R');
$pdf->write_cell($a_size[$t_idx], 5,$a_purchase_header[$e], 1, 0, 'R');
}
$a_tot[$colname]=0;
}
@ -250,8 +256,9 @@ for ($i = 0; $i < $nb_array; $i++) {
$pdf->line_new();
$pdf->write_cell(70, 5, "");
for ($e=2;$e<$nb_col;$e++){
$t_idx=$a_colp[$e];
$colname=$a_col[$e];
$pdf->write_cell(40, 5, nbm($a_tot[$colname]), 0, 0, 'R');
$pdf->write_cell($a_size[$t_idx], 5, nbm($a_tot[$colname]), 0, 0, 'R');
$a_tot[$colname]=0;
}
$pdf->line_new();
@ -265,37 +272,38 @@ for ($i = 0; $i < $nb_array; $i++) {
// Display Header
for ($e=0;$e<$nb_col;$e++){
$t_idx=$a_colp[$e];
if ( $e == 0 ) {
$pdf->write_cell(40, 5,$a_purchase_header[$e], 1, 0, 'L');
$pdf->write_cell($a_size[$t_idx], 5,$a_purchase_header[$e], 1, 0, 'L');
} else {
$pdf->write_cell(40, 5,$a_purchase_header[$e], 1, 0, 'R');
$pdf->write_cell($a_size[$t_idx], 5,$a_purchase_header[$e], 1, 0, 'R');
}
$a_tot[$colname]=0;
}
}
for ($e=0;$e<$nb_col;$e++){
$colname=$a_col[$e];
$colname=$a_colp[$e];
if ( $e ==0 ) {
$pdf->write_cell(40, 5, $array[$i][$colname], 1, 0, 'L');
$pdf->write_cell($a_size[$colname], 5, $array[$i][$colname], 1, 0, 'L');
} elseif ($e == 1 ){
$pdf->write_cell(40, 5, nbm($array[$i][$colname]*100), 1, 0, 'R');
$pdf->write_cell($a_size[$colname], 5, nbm($array[$i][$colname]*100), 1, 0, 'R');
}else {
$pdf->write_cell(40, 5, nbm($array[$i][$colname]), 1, 0, 'R');
$pdf->write_cell($a_size[$colname], 5, nbm($array[$i][$colname]), 1, 0, 'R');
}
}
$pdf->line_new();
}
$pdf->SetFont('DejaVuCond', 'B', 7);
$pdf->write_cell(80, 5, "");
$pdf->write_cell($a_size['tva_label']+$a_size['tva_rate'], 5, "");
for ($e=2;$e<$nb_col;$e++){
$colname=$a_col[$e];
$pdf->write_cell(40, 5, nbm($a_tot[$colname]), 1, 0, 'R');
$colname=$a_colp[$e];
$pdf->write_cell($a_size[$colname], 5, nbm($a_tot[$colname]), 1, 0, 'R');
}
//-------------------------------------------------------------------------
// Summary sales
// Summary Purchase
//-------------------------------------------------------------------------
$a_sum = $tax_summary->get_summary_sale();
$pdf->line_new();
$pdf->SetFont('DejaVuCond', 'B', 10);
$pdf->write_cell(50, 8, _("Résumé TVA Achat"));
@ -303,10 +311,12 @@ $pdf->line_new();
$pdf->SetFont('DejaVuCond', 'B', 7);
for ($e=0;$e<$nb_col;$e++){
$t_idx=$a_colp[$e];
if ( $e == 0 ) {
$pdf->write_cell(40, 5,$a_purchase_header[$e], 1, 0, 'L');
$pdf->write_cell($a_size[$t_idx], 5,$a_purchase_header[$e], 1, 0, 'L');
} else {
$pdf->write_cell(40, 5,$a_purchase_header[$e], 1, 0, 'R');
$pdf->write_cell($a_size[$t_idx], 5,$a_purchase_header[$e], 1, 0, 'R');
}
$a_tot[$colname]=0;
}
@ -315,33 +325,33 @@ $pdf->line_new();
$nb_array = count($array);
// initialize totals
for ($e=2;$e<$nb_col;$e++){
$a_tot[$a_col[$e]]=0;
$a_tot[$a_colp[$e]]=0;
}
$pdf->SetFont('DejaVuCond', '', 7);
for ($i = 0; $i < $nb_array; $i++) {
// display each row
for ($e=0;$e<$nb_col;$e++){
$colname=$a_col[$e];
$colname=$a_colp[$e];
if ( $e ==0 ) {
// first column TVA_LABEL
$pdf->write_cell(40, 5, $array[$i][$colname], 1, 0, 'L');
$pdf->write_cell($a_size[$colname], 5, $array[$i][$colname], 1, 0, 'L');
} elseif ($e == 1 ){
// Secund col. tva rate
$pdf->write_cell(40, 5, nbm($array[$i][$colname]*100), 1, 0, 'R');
$pdf->write_cell($a_size[$colname], 5, nbm($array[$i][$colname]*100), 1, 0, 'R');
}else {
// Other cols,display amount and compute total
$a_tot[$colname] = bcadd($a_tot[$colname], $array[$i][$colname]);
$pdf->write_cell(40, 5, nbm($array[$i][$colname]), 1, 0, 'R');
$pdf->write_cell($a_size[$colname], 5, nbm($array[$i][$colname]), 1, 0, 'R');
}
}
$pdf->line_new();
}
$pdf->SetFont('DejaVuCond', 'B', 7);
$pdf->write_cell(80, 5, "");
$pdf->write_cell($a_size['tva_label']+$a_size['tva_rate'], 5, "");
for ($e=2;$e<$nb_col;$e++){
$colname=$a_col[$e];
$pdf->write_cell(40, 5, nbm($a_tot[$colname]), 1, 0, 'R');
$colname=$a_colp[$e];
$pdf->write_cell($a_size[$colname], 5, nbm($a_tot[$colname]), 1, 0, 'R');
}
$pdf->line_new();

View file

@ -108,8 +108,8 @@ list($sql, $where) = $Ledger->build_search_sql($p_array);
$max_line = $cn->count_sql($sql);
$step = $_SESSION['g_pagesize'];
$page = (isset($_GET['offset'])) ? $_GET['page'] : 1;
$offset = (isset($_GET['offset'])) ? $_GET['offset'] : 0;
$page = (isset($_GET['offset'])) ? $http->get('page') : 1;
$offset = (isset($_GET['offset'])) ? $http->get('offset') : 0;
// check if number
$page=(isNumber($page)==0)?1:$page;
@ -121,7 +121,7 @@ echo $msg;
echo $Ledger->display_search_form();
echo $bar;
echo '<form method="GET" id="fpaida" class="print">';
echo HtmlInput::hidden("ac", $_REQUEST['ac']);
echo HtmlInput::hidden("ac", $http->request('ac'));
echo HtmlInput::hidden('ledger_type',$ledger_type);
echo dossier::hidden();

View file

@ -54,7 +54,7 @@
<?php echo Icon_Action::clean_zone(uniqid(),sprintf("$('%s').value=0",$f_amount_min->id));
echo $f_amount_min->input(); ?>
<?php echo _('et')?> <?php
echo Icon_Action::clean_zone(uniqid(),sprintf("$('%s').value=0",$f_amount_max->id));
echo HtmlInput::button_action("=",sprintf("$('%s').value=%s.value",$f_amount_max->id,$f_amount_min->id) ,uniqid(), "smallbutton");
echo $f_amount_max->input(); ; ?>
</td>
</tr>

View file

@ -0,0 +1,6 @@
#!/bin/bash
DOSSIER_TEST=dossier48
pg_restore -Fc --no-owner --no-privilege --verbose -d $DOSSIER_TEST db/dossiertest.bin

Binary file not shown.

View file

@ -24,10 +24,11 @@
* Global variables
*/
global $g_connection,$g_parameter,$g_user;
define ("DOSSIER",48);
$_REQUEST['gDossier'] = DOSSIER;
$g_connection=new Database(DOSSIER);
$g_parameter = new Noalyss_Parameter_Folder($g_connection);
$_SESSION['g_user']='phpcompta';
$_SESSION['g_pass']='dany';
$_SESSION['g_pagesize']='50';
$g_user=new User($g_connection);
$g_user=new User($g_connection);

View file

@ -38,7 +38,6 @@ class Acc_BalanceTest extends TestCase
/**
* @covers Acc_Balance::get_row
* @todo Implement testGet_row().
*/
public function testGet_row()
{
@ -47,12 +46,17 @@ class Acc_BalanceTest 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");
$this->object->get_row($min,$max);
$this->object->jrn=NULL;
$array=$this->object->get_row($min,$max);
$this->assertEquals(14,count($array));
$this->object->jrn=[2,4];
$array=$this->object->get_row($min,$max);
$this->assertEquals(8,count($array));
}
/**
* @covers Acc_Balance::filter_cat
* @todo Implement testFilter_cat().
*/
public function testFilter_cat()
{
@ -62,17 +66,61 @@ class Acc_BalanceTest extends TestCase
$this->object->filter_cat(array('FIN'));
$this->assertEquals($this->object->jrn[0],2);
}
/**
* @covers Acc_Balance::test_me
* @todo Implement testTest_me().
*@covers Acc_Balance::summary_add
*@depend Acc_Balance::summary_init
*/
public function testTest_me()
public function testSummary_add()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
$array=$this->object->summary_init();
$result=$this->object->summary_add($array,'600',100,0);
$this->assertEquals(100,$result['6']['deb']);
$result=$this->object->summary_add($result,'6500',50,0);
$this->assertEquals(150,$result['6']['deb']);
$result=$this->object->summary_add($result,'2600',0,100);
$this->assertEquals(100,$result['1_5']['cred']);
$this->assertEquals(0,$result['1_5']['deb']);
$result=$this->object->summary_add($result,'2400',100,0);
$this->assertEquals(100,$result['1_5']['deb']);
}
/**
*@covers Acc_Balance::summary_add
*@depend Acc_Balance::summary_init
*/
public function testSummary_display()
{
$array=$this->object->summary_init();
$output='<table><tr><td >Class 1-5</td><td class="num">0,00</td><td >=</td></tr><tr><td >Class 6</td><td class="num">0,00</td><td >=</td></tr><tr><td >Class 7</td><td class="num">0,00</td><td >=</td></tr><tr><td >Solde 6/7</td><td class="num">0,00</td><td >=</td></tr></table>';
$this->expectOutputString($output);
$this->object->summary_display($array);
}
/**
*@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
*/
public function testsummary_init()
{
$array=$this->object->summary_init();
$this->assertTrue(isset($array['1_5']));
$this->assertTrue(isset($array['6']));
$this->assertTrue(isset($array['7']));
}
}

View file

@ -0,0 +1,164 @@
<?php
use PHPUnit\Framework\TestCase;
/*
* This file is part of NOALYSS.
*
* PhpCompta is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* PhpCompta is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with PhpCompta; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
// Copyright (2002-2019) Author Dany De Bontridder <danydb@noalyss.eu>
/**
* @file
* @brief
*/
class Tax_SummaryTest extends TestCase
{
/**
* @var Acc_Account
*/
protected $object;
/**
* Sets up the fixture, for example, opens a network connection.
* This method is called before a test is executed.
*/
protected function setUp() :void
{
global $g_connection;
$this->object=new \Tax_Summary($g_connection, "01.01.2014", "31.12.2019");
}
function testCheck()
{
// No warning expected
try {
$this->object->check();
$this->assertTrue(TRUE);
} catch(Exception $e) {
$this->assertSame('OK',$e->getMessage());
}
// Warning expected
try {
$this->object->set_date_start("01.01.2090");
$this->object->check();
$this->assertTrue(FALSE);
} catch(Exception $e) {
$this->assertTrue(TRUE);
}
}
function testDisplay()
{
$this->expectOutputRegex("/.*10\.737,34.*\<\/tr\>\<\/table\>\n/");
$this->object->display();
}
function testForm_export_csv()
{
$this->expectOutputRegex("/\<form method=\"GET\".*/");
$this->object->form_export_csv();
}
function testForm_export_pdf()
{
$this->expectOutputRegex("/\<form method=\"GET\".*/");
$this->object->form_export_pdf();
}
function testGet_row_purchase()
{
$array=$this->object->get_row_purchase();
$this->assertSame($array, [['jrn_def_name' => 'Achat',
'tva_label' => '0%',
'tva_rate' => '0.0000',
'tva_both_side' => '0',
'qp_vat_code' => '4',
'amount_vat' => '0.0000',
'amount_wovat' => '658.2500',
'amount_sided' => '0.0000',
'amount_noded_amount' => '0.0000',
'amount_noded_tax' => '0.0000',
'amount_noded_return' => '0.0000',
'amount_private' => '0.0000'
],[
'jrn_def_name' => 'Achat',
'tva_label' => '12%',
'tva_rate' => '0.1200',
'tva_both_side' => '0',
'qp_vat_code' => '2',
'amount_vat' => '84.2200',
'amount_wovat' => '701.7800',
'amount_sided' => '0.0000',
'amount_noded_amount' => '0.0000',
'amount_noded_tax' => '0.0000',
'amount_noded_return' => '0.0000',
'amount_private' => '0.0000']]);
}
function testGet_row_sale()
{
$array=$this->object->get_row_sale();
$this->assertSame($array, [[
'jrn_def_name' => 'Vente',
'tva_label' => '21%',
'qs_vat_code' => '1',
'tva_rate' => '0.2100',
'tva_both_side' => '0',
'amount_vat' => '2254.8400',
'amount_wovat' => '10737.3400',
'amount_sided' => '0.0000'
]]);
}
function testget_summary_purchase()
{
$array=$this->object->get_summary_purchase();
$this->assertSame($array,[[
'tva_label' => '0%'
,'tva_rate' => '0.0000'
,'tva_both_side' => '0'
,'qp_vat_code' => '4'
,'amount_vat' => '0.0000'
,'amount_wovat' => '658.2500'
,'amount_sided' => '0.0000'
,'amount_noded_amount' => '0.0000'
,'amount_noded_tax' => '0.0000'
,'amount_noded_return' => '0.0000'
,'amount_private' => '0.0000'
],[
'tva_label' => '12%'
,'tva_rate' => '0.1200'
,'tva_both_side' => '0'
,'qp_vat_code' => '2'
,'amount_vat' => '84.2200'
,'amount_wovat' => '701.7800'
,'amount_sided' => '0.0000'
,'amount_noded_amount' => '0.0000'
,'amount_noded_tax' => '0.0000'
,'amount_noded_return' => '0.0000'
,'amount_private' => '0.0000'
]]);
}
function testget_summary_sale()
{
$array=$this->object->get_summary_sale();
$this->assertSame($array, [[
'tva_label' => '21%',
'qs_vat_code' => '1',
'tva_rate' => '0.2100',
'tva_both_side' => '0',
'amount_vat' => '2254.8400',
'amount_wovat' => '10737.3400',
'amount_sided' => '0.0000'
]]);
}
}