Merge branch 'devel'

This commit is contained in:
sparkyx 2024-01-17 19:35:53 +01:00
commit 9fa37baa88
16 changed files with 708 additions and 123 deletions

View file

@ -3396,4 +3396,18 @@ li.li-active {
background-color: rgba(246, 180, 157, 0.58);
color:red;
}
/** followup : detail : list of concerned actions **/
div.concerned_action {
height: 11rem;
overflow: auto;
background-color: white;
border:navy 1px solid;
width: 100%;
scroll-padding-right: 20px;
}
div.FullDetailActionChildren {
z-index: 12;
position: absolute;
height: auto;
}

View file

@ -303,11 +303,7 @@ p#breakhere {page-break-before: always}
{
font-size:9pt;
margin-top:10pt;
word-break: normal;
word-wrap: break-word;
white-space: pre-wrap;
}
.tinybutton {
display:none;
@ -325,4 +321,6 @@ span.inplace_edit_input
}
.inum {
text-align: right;
}
}
.concerned_action {display:block;}

View file

@ -437,8 +437,21 @@ if ( isset($_GET['view'] ) )
echo '<TR class="'.$tr.'">';
echo td($view_history);
echo td(h($r['label']));
// label + warning if the saldo is incorrect
$label=$r['label'];
if (in_array($r['type'],array('CHA','ACT','PASINV','PROINV')) && $r['sum_deb']<$r['sum_cred'])
{
$label.=" ".Icon_Action::warnbulle(85);
}
if (in_array($r['type'],array('PRO','PAS','ACTINV','CHAINV')) && $r['sum_deb']>$r['sum_cred'])
{
$label.=" ".Icon_Action::warnbulle(86);
}
print '<td>';
print $label;
print '</td>';
if ($previous == 1 ) {
echo td(nbm($r['sum_deb_previous']),' class="previous_year"');
echo td(nbm($r['sum_cred_previous']),' class="previous_year" ');

View file

@ -85,7 +85,7 @@ $menu[]=array('href'=>$root.'&sc=bal', 'label'=>_('Balance'), 'alt'=>_('Balance
$menu[]=array('href'=>$root.'&sc=balag', 'label'=>_('Balance âgée'), 'alt'=>_('Balance âgée du tiers'));
$menu[]=array('href'=>$root.'&sc=let', 'label'=>_('Lettrage'), 'alt'=>_('Opérations & Lettrages'));
echo '<ul class="tabs" style="padding-top:0px">';
echo '<ul class="tabs noprint" style="padding-top:0px">';
for ($i=0; $i<count($menu); $i++)
{
$style=($def==($i+1))?"tabs_selected":"tabs";

View file

@ -231,6 +231,7 @@ class Acc_Balance
$a['poste']=$r['poste'];
$a['label']=mb_substr($poste->get_lib(),0,40);
$a['type']=$poste->get_parameter("pcm_type");
$a['sum_deb']=round($r['sum_deb'],2);
$a['sum_cred']=round($r['sum_cred'],2);
$a['solde_deb']=round(( $a['sum_deb'] >= $a['sum_cred'] )? $a['sum_deb']- $a['sum_cred']:0,2);

View file

@ -616,12 +616,12 @@ class Follow_Up
/* upload the documents */
$doc=new Document($this->db);
$doc->upload($this->ag_id);
if (trim($this->ag_comment??"")!='' && Document_Option::can_add_comment($this->ag_id))
if (noalyss_trim($this->ag_comment??"")!='' && Document_Option::can_add_comment($this->ag_id))
{
$this->db->exec_sql("insert into action_gestion_comment (ag_id,tech_user,agc_comment,agc_comment_raw) values ($1,$2,$3,$4)"
, array($this->ag_id, $_SESSION[SESSION_KEY.'g_user'], strip_tags($this->ag_description),$this->ag_comment));
}
if (trim($this->ag_description)!='' && Document_Option::can_add_comment($this->ag_id))
if (noalyss_trim($this->ag_description)!='' && Document_Option::can_add_comment($this->ag_id))
{
$this->db->exec_sql("insert into action_gestion_comment (ag_id,tech_user,agc_comment,agc_comment_raw) values ($1,$2,$3,$4)"
, array($this->ag_id, $_SESSION[SESSION_KEY.'g_user'],strip_tags($this->ag_description), $this->ag_description));
@ -1918,7 +1918,7 @@ where
}
}
/**
* Return the first parent of the event tree, or -1 if not found. The parent is an action with a lower id,
* @brief Return the first parent of the event tree, or -1 if not found. The parent is an action with a lower id,
* so it can happen than an action has several ones
* @return arrary of integer (ag_id)
*/
@ -1977,7 +1977,7 @@ where
from
action_gestion join t on (ag_id=aga_greatest)
join document_type on (ag_type=dt_id)
order by key_path
";
$ret_array=$this->db->get_array($sql,array($p_id));
// Empty returns
@ -1996,82 +1996,80 @@ where
/*
* First we retrieve the parent
*/
$parent=$this->get_parent();
$parent_id=$this->db->get_value("select min( get_follow_up_tree) from comptaproc.get_follow_up_tree($1)",[$this->ag_id]);
$http=new HttpInput();
$base=HtmlInput::request_to_string(array("gDossier", "ac", "sb", "sc",
"f_id"))."&amp;sa=detail";
if ($parent==-1)
$parent=array();
if (empty($parent_id))
{
echo _('Principal');
$parent=array();
$parent [0]['aga_least']= $this->ag_id;
$parent_id= $this->ag_id;
}
$nb_parent=count($parent);
for ($i=0;$i< $nb_parent;$i++)
$fu_parent=new Follow_Up($this->db, $parent_id);
$fu_parent->get();
echo'<span class="highlight">';
$xaction=sprintf('view_action(%d,%d,%d)', $fu_parent->ag_id,
Dossier::id(), 1);
$showAction='<a class="line" href="javascript:'.$xaction.'">';
echo $showAction.
$fu_parent->ag_timestamp," ",
h($fu_parent->ag_title),
'('.h($fu_parent->ag_ref).')',
'</a>';
echo "</span>";
echo '<ul style="padding-left:10px;list-style-type: none;">';
$action=$this->get_children($parent_id);
for ($o=0; $o<count($action); $o++)
{
$fu_parent=new Follow_Up($this->db, $parent[$i]['aga_least']);
$fu_parent->get();
echo'<span class="highlight">';
$xaction=sprintf('view_action(%d,%d,%d)', $fu_parent->ag_id,
Dossier::id(), 1);
$showAction='<a class="line" href="javascript:'.$xaction.'">';
echo $showAction.
$fu_parent->ag_timestamp," ",
h($fu_parent->ag_title),
'('.h($fu_parent->ag_ref).')',
'</a>';
$class=($this->ag_id == $action[$o]['aga_greatest'])?' class="highlight" ':'';
echo "</span>";
echo '<ul style="padding-left:10px;list-style-type: none;">';
// Count the number of direct parents
$count_parent =$this->db->get_value('select count(*) from action_gestion_related where aga_greatest = $1',array($action[$o]['aga_greatest']));
$direct_parent=($count_parent > 1 ) ? _('direct parent ').$count_parent:"";
$action=$this->get_children($parent[$i]['aga_least']);
for ($o=0; $o<count($action); $o++)
$margin=($action[$o]['depth']>1 )?str_repeat("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;",$action[$o]['depth']-1)."&#8680;":"";
if ($p_view!='READ'&&$p_base!='ajax')
{
$class=($this->ag_id == $action[$o]['aga_greatest'])?' class="highlight" ':'';
// Count the number of direct parents
$count_parent =$this->db->get_value('select count(*) from action_gestion_related where aga_greatest = $1',array($action[$o]['aga_greatest']));
$direct_parent=($count_parent > 1 ) ? _('direct parent ').$count_parent:"";
$margin=($action[$o]['depth']>1 )?str_repeat("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;",$action[$o]['depth']-1)."&#8680;":"";
if ($p_view!='READ'&&$p_base!='ajax')
{
$rmAction=sprintf("return confirm_box(null,'"._('Voulez-vous effacer cette action ')."', function () {remove_action('%s','%s','%s');});",
dossier::id(), $action[$o]['aga_greatest'],
$http->request('ag_id',"number"));
$showAction='<a class="line" href="'.$base."&ag_id=".$action[$o]['aga_greatest'].'">';
$js=Icon_Action::trash("acact".$action[$o]['aga_greatest'], $rmAction);
echo '<li '.$class.' id="act'.$action[$o]['aga_greatest'].'">'.$margin.$showAction.$action[$o]['str_date'].
h($action[$o]['title']).'('.h($action[$o]['action_ref']).')'.$direct_parent.'</a>'." "
.$js.'</li>';
}
else
/*
* Display detail requested from Ajax Div
*/
if ($p_base=='ajax')
{
$xaction=sprintf('view_action(%d,%d,%d)', $action[$o]['aga_greatest'],
Dossier::id(), 1);
$showAction='<a class="line" href="javascript:'.$xaction.'">';
echo '<li '.$class.' >'.$margin.$showAction.$action[$o]['str_date']." ".
h($action[$o]['title']).'('.h($action[$o]['action_ref']).')'.$direct_parent.'</a>'." "
.'</li>';
}
/*
* READ ONLY
*/
else
{
$showAction='<a class="line" href="'.$base."&ag_id=".$action[$o]['aga_greatest'].'">';
echo '<li '.$class.' >'.$margin.$showAction.$action[$o]['str_date']." ".
h($action[$o]['title']).'('.h($action[$o]['action_ref']).')'.$direct_parent.'</a>'." "
.'</li>';
}
$rmAction=sprintf("return confirm_box(null,'"._('Voulez-vous effacer cette action ')."', function () {remove_action('%s','%s','%s');});",
dossier::id(), $action[$o]['aga_greatest'],
$http->request('ag_id',"number"));
$showAction='<a class="line" href="'.$base."&ag_id=".$action[$o]['aga_greatest'].'">';
$js=Icon_Action::trash("acact".$action[$o]['aga_greatest'], $rmAction);
echo '<li '.$class.' id="act'.$action[$o]['aga_greatest'].'">'.$margin.$showAction.$action[$o]['str_date'].
h($action[$o]['title']).'('.h($action[$o]['action_ref']).')'.$direct_parent.'</a>'." "
.$js.'</li>';
}
else
/*
* Display detail requested from Ajax Div
*/
if ($p_base=='ajax')
{
$xaction=sprintf('view_action(%d,%d,%d)', $action[$o]['aga_greatest'],
Dossier::id(), 1);
$showAction='<a class="line" href="javascript:'.$xaction.'">';
echo '<li '.$class.' >'.$margin.$showAction.$action[$o]['str_date']." ".
h($action[$o]['title']).'('.h($action[$o]['action_ref']).')'.$direct_parent.'</a>'." "
.'</li>';
}
/*
* READ ONLY
*/
else
{
$showAction='<a class="line" href="'.$base."&ag_id=".$action[$o]['aga_greatest'].'">';
echo '<li '.$class.' >'.$margin.$showAction.$action[$o]['str_date']." ".
h($action[$o]['title']).'('.h($action[$o]['action_ref']).')'.$direct_parent.'</a>'." "
.'</li>';
}
echo '</ul>';
}
echo '</ul>';
}
/**
* @brief Display the list of parent of the current Follow_Up
@ -2084,18 +2082,23 @@ where
{
$a_parent=$this->db->get_array(
"
select ag_id,ag_title as title ,to_char(ag_timestamp,'DD/MM/YY') as str_date,ag_ref||' '||dt_value as action_ref
from
action_gestion
join document_type on (ag_type=dt_id)
where ag_id in (select aga_least from action_gestion_related where aga_greatest = $1)
order by ag_id
select ag1.ag_id
,ag1.ag_title as title
,to_char(ag1.ag_timestamp,'DD/MM/YY') as str_date
,ag1.ag_ref||' '||dt_value as action_ref
from
action_gestion ag1
join document_type on (ag_type=dt_id)
join (select distinct get_follow_up_tree from comptaproc.get_follow_up_tree($1)) tree_ag
on (tree_ag.get_follow_up_tree=ag1.ag_id)
order by ag_id
", array($this->ag_id)
);
if ( empty($a_parent ) ) return;
echo '<ul style="padding-left:10px;list-style-type: none;">';
$base=HtmlInput::request_to_string(array("gDossier", "ac", "sa", "sb", "sc",
"f_id"));
$http=new HttpInput();
for ($o=0; $o<count($a_parent); $o++)
{
$class=($this->ag_id == $a_parent[$o]['ag_id'])?' class="highlight" ':'';
@ -2104,9 +2107,11 @@ where
{
$rmAction=sprintf("return confirm_box(null,'"._('Voulez-vous effacer cette action ')."', function () {remove_action('%s','%s','%s');});",
dossier::id(), $a_parent[$o]['ag_id'],
$_REQUEST['ag_id']);
$http->request('ag_id',"number"));
$showAction='<a class="line" href="'.$base."&ag_id=".$a_parent[$o]['ag_id'].'">';
$js='<a class="tinybutton" id="acact'.$a_parent[$o]['ag_id'].'" href="javascript:void(0)" onclick="'.$rmAction.'">'.SMALLX.'</a>';
$js=\Icon_Action::trash('acact'.$a_parent[$o]['ag_id'],$rmAction);
echo '<li '.$class.' id="act'.$a_parent[$o]['ag_id'].'">'.$showAction.$a_parent[$o]['str_date'].
h($a_parent[$o]['title']).'('.h($a_parent[$o]['action_ref']).')'.'</a>'." "
.$js.'</li>';

View file

@ -123,7 +123,7 @@ if (!defined("NOALYSS_PACKAGE_REPOSITORY")) {
if (!defined("SYSINFO_DISPLAY")) {
define("SYSINFO_DISPLAY", TRUE);
}
define("DBVERSION", 191);
define("DBVERSION", 192);
define("MONO_DATABASE", 25);
define("DBVERSIONREPO", 20);
define('NOTFOUND', '--not found--');

View file

@ -212,7 +212,18 @@ if (!empty($array)) {
$fill=$pdf->is_fill($i);
$pdf->LongLine(30, 6, $value['poste'], 0, 'L', $fill);
$label=$value['poste'];
if (in_array($r['type'],array('CHA','ACT','PASINV','PROINV')) && $value['sum_deb']<$value['sum_cred'])
{
$label.=" ".mb_chr(0x26a0);
}
if (in_array($r['type'],array('PRO','PAS','ACTINV','CHAINV')) && $value['sum_deb']>$value['sum_cred'])
{
$label.=" ".mb_chr(0x26a0);
}
$pdf->LongLine(30, 6, $label, 0, 'L', $fill);
$pdf->LongLine(60, 6, $value['label'], 0, 'L', $fill);
$summary_tab = $bal->summary_add($summary_tab, $value['poste'],
$value['sum_deb'],

View file

@ -118,4 +118,6 @@ content[81]="<?php echo htmlspecialchars(_("Recommendé d'avoir un poste propre"
content[82]="<?php echo htmlspecialchars(_("valeur en % "),ENT_QUOTES)?>";
content[83]="<?php echo htmlspecialchars(_("Données invalides "),ENT_QUOTES)?>";
content[84]="<?php echo htmlspecialchars(_("En Belgique, l'exercice commence par un report des comptes de 0 à 5, mais pas en France, ce solde est calculé depuis le tout premier exercice"),ENT_QUOTES)?>";
content[85]="<?php echo htmlspecialchars(_("Solde créditeur au lieu de débiteur"),ENT_QUOTES)?>";
content[86]="<?php echo htmlspecialchars(_("Solde débiteur au lieu de créditeur"),ENT_QUOTES)?>";
</script>

View file

@ -0,0 +1,31 @@
begin;
CREATE OR REPLACE FUNCTION comptaproc.get_follow_up_tree(action_gestion_id integer)
RETURNS SETOF integer
LANGUAGE plpgsql
AS $function$
declare
i int;
x int;
e int;
begin
for x in select aga_least
from action_gestion_related
where
aga_greatest = action_gestion_id
loop
return next x;
for e in select * from comptaproc.get_follow_up_tree(x)
loop
return next e;
end loop;
end loop;
return;
end;
$function$;
insert into version (val,v_description) values (192,'2323 : tree for depending event');
commit;

View file

@ -3,13 +3,14 @@
//This file is part of NOALYSS and is under GPL
//see licence.txt
$uniq=uniqid("tab",TRUE);
?><div>
?>
<div>
<?php
\Noalyss\Dbg::echo_file(__FILE__);
?>
<div style="float:left;">
<div class="row">
<div class="col">
<table>
<tr class="highlight">
<TD>
@ -110,9 +111,10 @@ if ($this->ag_id > 0 && Document_Option::is_enable_contact_multiple($this->dt_id
<?php endif; ?>
</table>
<?php if ($p_view != 'READ') echo $str_add_button;?>
</div>
<div style="float:left">
<div class="col">
<table>
@ -186,16 +188,19 @@ if ($this->ag_id > 0 && Document_Option::is_enable_contact_multiple($this->dt_id
</table>
</div>
<div id="choice_other_info_div" style="float:left;">
<div id="choice_other_info_div" class="col-12 col-lg-6">
<div class="row">
<ul class="tabs noprint" >
<li id="related_action_tab<?php echo $uniq?>" class="tabs_selected"><?php echo _("Actions concernées")?></li>
<li id="related_operation_tab<?php echo $uniq?>" class="tabs"><?php echo _('Opérations concernées')?></li>
<li id="dependant_action_tab<?php echo $uniq?>" class="tabs"><?php echo _('Dépendant')?></li>
</ul>
<div style="clear:both"></div>
<div id="related_operation_div<?php echo $uniq?>" style="display:none" class="print">
</div>
<div class="row">
<div id="related_operation_div<?php echo $uniq?>" style="display:none;" class="print concerned_action">
<?php if ($p_view != 'READ') echo '<span class="noprint">'.$iconcerned->input().'</span>';?>
<ol>
<?php
@ -218,27 +223,35 @@ if ($this->ag_id > 0 && Document_Option::is_enable_contact_multiple($this->dt_id
?>
</ol>
<?php if ($p_view != 'READ') echo '<span class="noprint">'.$iconcerned->input().'</span>';?>
</div>
<div id="related_action_div<?php echo $uniq?>" class="print concerned_action" style="width: 95%" >
<div class="" style="display:block">
<div>
<div id="related_action_div<?php echo $uniq?>" class="print">
<?php if ( $p_view != 'READ') echo $iaction->input();?>
<?=\Icon_Action::detail('SmallDetailActionChildren'.$uniq.'_bt', "$('related_action_div{$uniq}').addClassName('FullDetailActionChildren');$('FullDetailActionChildren{$uniq}_bt').show();$('SmallDetailActionChildren{$uniq}_bt').hide()")?>
<?php
echo \Icon_Action::hide_icon("FullDetailActionChildren{$uniq}_bt"
, "$('related_action_div{$uniq}').removeClassName('FullDetailActionChildren');$('FullDetailActionChildren{$uniq}_bt').hide();$('SmallDetailActionChildren{$uniq}_bt').show()");?>
</div>
<?php
$this->display_children($p_view,$p_base);
<?php
$this->display_children($p_view,$p_base);
?>
<?php if ( $p_view != 'READ') echo '<span class="noprint">'.$iaction->input().'</span>';?>
?>
<script>$('FullDetailActionChildren<?=$uniq?>_bt').hide()</script>
</div>
</div>
<div id="dependant_action_div<?php echo $uniq?>" style="display:none" class="print">
<div id="dependant_action_div<?php echo $uniq?>" style="display:none" class="print concerned_action">
<?php
//@todo a enlever obsolete
$this->display_parent($p_view,$p_base);
?>
</div>
</div>
</div>
</div>
</div>
<div style="clear: both"></div>
<div id="div_action_description">
@ -256,7 +269,7 @@ function small(p_id_textarea){
}
</script>
<p style="margin-left:10px;">
<p style="margin-left:5%;">
<?php echo $title->input();
?>
</p>

View file

@ -21,6 +21,8 @@
if (!defined('ALLOWED'))
die('Appel direct ne sont pas permis');
\Noalyss\Dbg::echo_file(__FILE__);
$sup_parameter=HtmlInput::array_to_string(["sc","sb","f_id","qcode"], $_REQUEST,"&amp;");
$cn=Dossier::connect();
/**
@ -34,10 +36,10 @@ if ( ! empty ($g_user->get_writable_profile()))
'onclick="document.getElementById(\'action_add_d\').style.display=\'block\';"');
}
?>
<div id="action_add_d" class="inner_box" style="width:25rem;display:none;top:10rem;">
<div id="action_add_d" class="inner_box" style="position:fixed;min-width:25rem;display:none;top:10rem;">
<?php echo HtmlInput::title_box(_("Choississez une action"), "action_add_d"); ?>
<div style="text-align: center">
<?=\Noalyss\Dbg::echo_file(__FILE__)?>
<form method="get" >
<?php
@ -71,3 +73,5 @@ if ( ! empty ($g_user->get_writable_profile()))
</form>
</div>
</div>
<?php
include "show-all-variable.php";

View file

@ -30,15 +30,15 @@ global $g_user;
global $g_parameter;
//-------------------------------------------------------------------------------------------
// if DEBUG then show both , otherwise if MY_REPORT=Y shows opening otherwise , shows only closing
// Show opening if report == Y or NOALYSS > 1
//
// Show opening
//-------------------------------------------------------------------------------------------
if ( $g_parameter->MY_REPORT=="Y" || DEBUGNOALYSS > 1) :
?>
<div class="content">
<div class="row">
<div class="col">
<div class="col-lg">
<FORM method="POST">
<div class="" id="opening_div">
@ -91,15 +91,14 @@ if ( $g_parameter->MY_REPORT=="Y" || DEBUGNOALYSS > 1) :
</div>
</FORM>
<?php
endif;
//-------------------------------------------------------------------------------------------
// Show closing if report == N or NOALYSS > 1
// Show closing
//-------------------------------------------------------------------------------------------
if ( $g_parameter->MY_REPORT=="N" || DEBUGNOALYSS > 1) :
?>
</div>
<div class="col">
<div class="col-lg">
<FORM method="POST">
<div class="" id="closing_div" style="display:grid">
@ -123,7 +122,4 @@ if ( $g_parameter->MY_REPORT=="N" || DEBUGNOALYSS > 1) :
</FORM>
</div>
</div>
<?php
endif;
?>
</div>

View file

@ -37,6 +37,7 @@ $aUrl = ["ac" => $http->request("ac"), "gDossier" => Dossier::id()];
$checkbox=new ICheckBox("operation_list[]");
$checkbox->set_range("operation_range");
?>
<h2><?=_("Liste des opérations")?></h2>
<form method="POST">
<?php
echo \HtmlInput::array_to_hidden(["gDossier", "sa"], $_REQUEST);

View file

@ -0,0 +1,12 @@
<?php
/**
* @file
* @brief to be included , show all the variables, only for development purpopse
*
*/
if (DEBUGNOALYSS <= 1 ) return;
$variable = get_defined_vars();
echo \Noalyss\Dbg::hidden_info("All variables", $variable);

View file

@ -0,0 +1,484 @@
<?php
use PHPUnit\Framework\TestCase;
/**
* Generated by PHPUnit_SkeletonGenerator on 2014-10-31 at 20:33:22.
*
*/
class Acc_Account_LedgerTest extends TestCase
{
/**
* @var Acc_Account_Ledger
*/
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, $g_parameter, $g_user;
$_REQUEST['gDossier']=DOSSIER;
$g_connection=new Database(DOSSIER);
$g_parameter=new Noalyss_Parameter_Folder($g_connection);
$g_user=new Noalyss_user($g_connection);
$this->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']);
}
public function dataGet_used_accounting()
{
$array=array(
["01.01.2020","31.12.2020",5,7,4]
,["01.01.2019","31.12.2020",5,7,10]
,["01.01.2019","31.12.2020",5,6,3]
,["01.01.2019","31.12.2020",5,5,0]
,["01.01.2019","31.12.2020",5,2,0]
,["01.01.2019","31.12.2020",5,2,0]
,["01.01.2019","31.14.2020",5,7,0]
,["01.13.2019","31.14.2020",5,7,0]
);
return $array;
}
/**
* @brief test function Acc_Account_Ledger::get_used_accounting
* @covers Acc_Account_Ledger::get_used_accounting
* @dataProvider dataGet_used_accounting
*/
public function testGet_UsedAcccounting($from_date,$to_date,$from_accounting,$to_accounting,$nb_accounting)
{
$a_result=Acc_Account_Ledger::get_used_accounting(from_date:$from_date
,to_date:$to_date
,from_accounting:$from_accounting
,to_accounting:$to_accounting);
$this->assertEquals($nb_accounting,count($a_result)
,"number of accounting incorrect for (\$from_date,\$to_date,\$from_accounting,\$to_accounting,\$nb_accounting : ($from_date,$to_date,$from_accounting,$to_accounting,$nb_accounting");
}
}