Code rewriting and improve of P0RAP for linked operations

This commit is contained in:
sparkyx 2025-06-21 18:48:23 +02:00
parent a48140d3cc
commit 4a0c11d6c7
6 changed files with 735 additions and 580 deletions

View file

@ -3952,3 +3952,44 @@ h2.h-section {
.nav-pills {
font-family:var(--font-title) !important;
}
/**
* Style for ACC_RECONCILIATION P0RAP
*/
.rpm_main {
display:grid;
grid-template-columns:1fr ;
row-gap: 0.5rem;
}
.rpm_operation {
display:grid;
grid-template-columns:10rem 10rem 10rem 10rem 1fr 1fr ;
}
.rpm_title {
color:white;
background-color: navy;
}
.rpm_detail {
justify-self: stretch;
grid-column: 1 / span 6;
}
.rpm_detail > table {
width:90%;
margin-left:5%;
}
.rpm_detail > .highlight {
font-size: 130%;
font-stretch: extra-expanded;
color:blue;
margin-left:min(40rem,20%);
border: 1px navy dotted;
width: max(60%,40rem);
padding: 0.2rem;
margin-top: 0.5rem;
margin-bottom: 0.5rem;
border-radius: 5px;
}

File diff suppressed because it is too large Load diff

View file

@ -22,7 +22,7 @@ try
}
catch (Exception $exc)
{
error_log($exc->getTraceAsString());
record_log($exc);
return;
}

View file

@ -19,25 +19,24 @@
// Copyright Author Dany De Bontridder danydb@aevalys.eu
/*!\file
/*!
* \file
* \brief print the all the operation reconciled or not, with or without the same amount
*/
if ( ! defined ('ALLOWED') ) die('Appel direct ne sont pas permis');
global $g_user;
$http=new HttpInput();
/**
*@file
*/
$aledger=$g_user->get_ledger('ALL',3);
echo '<div class="noprint">';
echo '<div class="content">';
$rjrn='';
$radio=new IRadio('choice');
$choice=(isset($_GET['choice']))?$_GET['choice']:0;
$r_jrn=(isset($_GET['r_jrn']))?$_GET['r_jrn']:'';
$choice=$http->get("choice","string",0);
$r_jrn=$http->get("r_jrn","string","");
echo '<form method="GET">';
echo dossier::hidden().HtmlInput::hidden('ac',$_GET['ac']).HtmlInput::hidden('type','rec');
echo dossier::hidden().HtmlInput::hidden('ac',$http->request('ac')).HtmlInput::hidden('type','rec');
echo _('Filtre par journal');
HtmlInput::button_choice_ledger(array('div'=>'','type'=>'ALL','all_type'=>1));
echo '<br/>';
@ -61,30 +60,20 @@ try {
}
echo "Opérations entre ".$dstart->input()." jusque ".$dend->input();
echo '<ol style="list-style-type:none;">';
$radio->selected=($choice==0)?true:false;
$radio->value=0;
echo '<li>'.$radio->input()._('Opérations rapprochées').'</li>';
$radio->selected=($choice==1)?true:false;
$radio->value=1;
echo '<li>'.$radio->input()._('Opérations rapprochées avec des montants différents').'</li>';
$radio->selected=($choice==2)?true:false;
$radio->value=2;
echo '<li>'.$radio->input()._('Opérations rapprochées avec des montants identiques').'</li>';
$radio->selected=($choice==3)?true:false;
$radio->value=3;
echo '<li>'.$radio->input()._('Opérations non rapprochées').'</li>';
echo '</ol>';
$select=new ISelect("choice");
$select->transform([
0=>_('Opérations rapprochées')
,1=>_('Opérations rapprochées avec des montants différents')
,2=>_('Opérations rapprochées avec des montants identiques')
,3=>_('Opérations non rapprochées')
]
);
$select->selected=$choice;
echo $select->input();
echo '<p>';
echo HtmlInput::submit('vis',_('Visualisation'));
echo '</p>';
echo '</form>';
echo '<hr>';
echo '</div>';
@ -96,7 +85,7 @@ $acc_reconciliation=new Acc_Reconciliation($cn);
$acc_reconciliation->a_jrn=$r_jrn;
$acc_reconciliation->start_day=$dstart->value;
$acc_reconciliation->end_day=$dend->value;
$acc_reconciliation->prepare_query_detail_quant();
$array=$acc_reconciliation->get_data($choice);
$gDossier=Dossier::id();

View file

@ -1,71 +1,96 @@
<?php
//This file is part of NOALYSS and is under GPL
//see licence.txt
?><table class="result">
<tr>
<th>
<?php echo _("")?>
</th>
<th>
<?php echo _("Date")?>
</th>
<th>
<?php echo _("N° op")?>
</th>
<th>
<?php echo _("n° pièce")?>
</th>
<th>
<?php echo _("Libellé")?>
</th>
<th style="text-align:right">
<?php echo _("Montant")?>
</th>
</tr>
<?php
for ($i=0;$i<count($array);$i++) {
$tot=$acc_reconciliation->get_amount_noautovat($array[$i]['first']['jr_id'],$array[$i]['first']['jr_montant']);
$r='';
$r.=td($i);
$r.=td(format_date($array[$i]['first']['jr_date']));
$detail = HtmlInput::detail_op($array[$i]['first']['jr_id'], $array[$i]['first']['jr_internal']);
$r.=td($detail);
$r.=td($array[$i]['first']['jr_pj_number']);
$r.=td($array[$i]['first']['jr_comment']);
$r.=td(nbm($tot),'style="text-align:right"');
echo tr($r);
// check if operation does exist in v_detail_quant
$ret=$acc_reconciliation->db->execute('detail_quant',array($array[$i]['first']['jr_id']));
$acc_reconciliation->show_detail($ret);
if ( isset($array[$i]['depend']) )
{
$tot2=0;
$limit=count($array[$i]['depend'])-1;
for ($e=0;$e<count($array[$i]['depend']);$e++) {
$r='';
$r.=td($i);
$r.=td(format_date($array[$i]['depend'][$e]['jr_date']));
$detail = HtmlInput::detail_op($array[$i]['depend'][$e]['jr_id'], $array[$i]['depend'][$e]['jr_internal']);
$r.=td($detail);
$r.=td($array[$i]['depend'][$e]['jr_pj_number']);
$r.=td($array[$i]['depend'][$e]['jr_comment']);
$r.=td(nbm($array[$i]['depend'][$e]['jr_montant']),'style="text-align:right"');
$amount_dep=$acc_reconciliation->get_amount_noautovat($array[$i]['depend'][$e]['jr_id'],$array[$i]['depend'][$e]['jr_montant']);
$tot2=bcadd($tot2,$amount_dep);
if ( $e==$limit)
echo '<tr>'.$r.'</tr>';
else
echo tr($r);
$ret=$acc_reconciliation->db->execute('detail_quant',array($array[$i]['depend'][$e]['jr_id']));
$acc_reconciliation->show_detail($ret);
}
echo tr(td(_('Total ')).td(_('opération')).td(nbm($tot)).td(_('opérations dépendantes')).td(nbm($tot2)).td(_('Delta')).td(bcsub($tot,$tot2)),' class="highlight"');
echo tr(td('<hr>',' colspan="6" style="witdh:auto"'));
}
}
?>
</table>
<div class="rpm_main">
<?php
for ($i = 0; $i < count($array); $i++) {
?>
<div class="rpm_operation rpm_title">
<div >
<?php echo _("") ?>
</div>
<div >
<?php echo _("Date") ?>
</div>
<div>
<?php echo _("Interne") ?>
</div>
<div>
<?php echo _("N° pièce") ?>
</div>
<div>
<?php echo _("Libellé") ?>
</div>
<div>
<?php echo _("Montant") ?>
</div>
<div></div>
</div>
<div class="rpm_operation ">
<div><?= $i ?></div>
<div><?=$array[$i]['str_jr1_jr_date']?></div>
<div><?= HtmlInput::detail_op($array[$i]['jr1_jr_id'], $array[$i]['jr1_jr_internal']) ?></div>
<div><?= $array[$i]['jr1_jr_pj_number'] ?></div>
<div><?= $array[$i]['jr1_jr_comment'] ?></div>
<?php
$x=($array[$i]['to1_sum_amount']!=0)?$array[$i]['to1_sum_amount']:$array[$i]['jr1_jr_montant'];
?>
<div><?=nbm($x)?></div>
<div class="rpm_detail">
<?php
$r = '';
// check if operation does exist in v_detail_quant
// $ret = $acc_reconciliation->db->execute('detail_quant', array($array[$i]['jr1_jr_id']));
// echo '<table>';
// $acc_reconciliation->show_detail($ret);
// echo '</table>';
if ( $array[$i]['depend_count']>0) {
$depend=$acc_reconciliation->db->get_array("select *
from temp_total_operation
where
jr1_jr_id=$1 and ra1_jra_concerned != jr1_jr_id"
,[$array[$i]['jr1_jr_id']]);
$nb_depend = count($depend);
$totdepend=0;$delta=$x;
?>
<div class="rpm_detail">
<h4><?=_("Opération liée")?></h4>
<?php
for ($e = 0; $e < $nb_depend ; $e++) {
$y=($depend[$e]['to2_sum_amount']!=0)?$depend[$e]['to2_sum_amount']:$depend[$e]['jr2_jr_montant'];
$totdepend=bcadd($totdepend,$y,2);
$delta=bcsub($delta,$y,2);
?>
<div class="rpm_operation">
<div><?= $i ?></div>
<div><?=$depend[$e]["str_jr2_jr_date"] ?></div>
<div><?= HtmlInput::detail_op($depend[$e]["ra1_jra_concerned"],$depend[$e]["jr2_jr_internal"]) ?></div>
<div><?=$depend[$e]["jr2_jr_pj_number"] ?></div>
<div><?=$depend[$e]["jr2_jr_comment"] ?></div>
<div><?= nbm($y) ?></div>
<?php
?></div>
<?php
} // end for ($e = 0; $e < count($array[$i]['depend']); $e++)
?></div>
<div class="rpm_detail highlight">
<?=sprintf(_("Total opération liée : %.2f Delta %.2f"),$totdepend,$delta)?>
</div>
<?php
} // if ( $array[$i]['depend_count']>1)
?>
</div>
</div>
<?php
} // end for ($i=0;$i<count($array);$i++)
?>
</div>

View file

@ -0,0 +1,105 @@
<?php
/*
*
* This program 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.
*
* This program 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 this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
*
* Author : Dany De Bontridder danydb@noalyss.eu
* Copyright (C) 2025 Dany De Bontridder <dany@alchimerys.be>
*
*/
/**
* @file
* @brief noalyss
*/
use PHPUnit\Framework\TestCase;
/**
* @testdox Class Acc_Reconciliation for operations links
* @backupGlobals enabled
* @coversDefaultClass Acc_Reconciliation
*/
class Acc_ReconciliationTest extends TestCase {
/**
* @var Fiche
*/
protected $object;
protected $connection;
private $g_user;
/**
* @backupGlobals enabled
* Sets up the fixture, for example, opens a network connection.
* This method is called before a test method is executed.
*/
protected function setUp(): void {
require DIRTEST . '/global.php';
$this->connection = $g_connection;
$this->g_user = $g_user;
}
/**
* @testdox Count rows not linked
* @global $g_connection
*/
function testNotReconcilied() {
$acc_reconciliation = new \Acc_Reconciliation($this->connection);
$acc_reconciliation->prepare_query_detail_quant();
$array = $acc_reconciliation->get_data(3);
$this->assertEquals(18, count($array), "count number of rows found");
}
/**
* @brief build an object Acc_Reconciliation
* @return \Acc_Reconciliation
*/
function build_object() {
$acc_reconciliation = new \Acc_Reconciliation($this->connection);
$acc_reconciliation->start_day = '01.01.2019';
$acc_reconciliation->end_day = '01.01.2019';
return $acc_reconciliation;
}
/**
* @testdox Count rows linked
* @backupGlobals enabled
*/
function testReconcilied() {
$acc_reconciliation = $this->build_object();
$array = $acc_reconciliation->get_data(0);
$this->assertEquals(8, count($array), "count number of rows found");
}
/**
* @testdox Count rows linked but with different amount
* @backupGlobals enabled
*/
function testReconciliedDifferentAmount() {
$acc_reconciliation = new \Acc_Reconciliation($this->connection);
$array = $acc_reconciliation->get_data(1);
$this->assertEquals(0, count($array), "count number of rows found");
}
function testBuild_temp_total_operation() {
$acc_reconciliation = new \Acc_Reconciliation($this->connection);
$acc_reconciliation->build_temp_total_operation();
$acc_reconciliation->build_temp_total_operation();
$acc_reconciliation->build_temp_total_operation();
$cnt = $this->connection->get_value("select count(*) from temp_total_operation");
$this->assertEquals(16, $cnt, " incorrect number of rows");
}
}