Task #0001733: Impression moyen paiement

This commit is contained in:
Dany De Bontridder 2019-08-15 11:50:04 +02:00
parent c60d5d49da
commit e669d05efc
17 changed files with 194 additions and 103 deletions

View file

@ -28,8 +28,10 @@ require_once NOALYSS_INCLUDE."/class/acc_ledger_history_generic.class.php";
require_once NOALYSS_INCLUDE."/class/acc_ledger_history_sale.class.php";
require_once NOALYSS_INCLUDE."/class/acc_ledger_history_purchase.class.php";
require_once NOALYSS_INCLUDE."/class/acc_ledger_history_financial.class.php";
require_once NOALYSS_INCLUDE."/class/prepared_query.class.php";
/**
* @brief Display history of operation
* @see acc_ledger_historyTest.php
*/
abstract class Acc_Ledger_History
{
@ -240,32 +242,19 @@ abstract class Acc_Ledger_History
return $tiers;
}
/**
* Prepare the query for fetching the linked operation
* @staticvar int $prepare
*/
protected function prepare_reconcile_date()
{
$prepare=$this->db->is_prepare("reconcile_date");
if ($prepare==FALSE)
{
$this->db->prepare('reconcile_date',
'select *
from
jrn
where
jr_id in
(select
jra_concerned
from
jrn_rapt
where jr_id = $1
union all
select
jr_id
from jrn_rapt
where jra_concerned=$1)');
static $not_done=TRUE;
if ($not_done ) {
$prepare_query = new Prepared_Query($this->db);
$prepare_query->prepare_reconcile_date();
}
$not_done=FALSE;
}
/**
* display accounting of operations m_mode=A

View file

@ -82,6 +82,7 @@ class Acc_Ledger_History_Financial extends Acc_Ledger_History
public function export_oneline_html()
{
$this->get_row();
$this->prepare_reconcile_date();
require_once NOALYSS_TEMPLATE.'/acc_ledger_history_financial_oneline.php';

View file

@ -27,6 +27,7 @@ require_once NOALYSS_INCLUDE."/class/acc_ledger_history.class.php";
/**
* @brief Display the operations for Purchase
* @see acc_ledger_historyTest.php
*/
class Acc_Ledger_History_Purchase extends Acc_Ledger_History
{
@ -236,6 +237,10 @@ class Acc_Ledger_History_Purchase extends Acc_Ledger_History
}
function export_csv()
{
// Prepare the query for reconcile date
$prepared_query=new Prepared_Query($this->db);
$prepared_query->prepare_reconcile_date();
$export=new Noalyss_Csv(_('journal'));
$export->send_header();
@ -258,6 +263,7 @@ class Acc_Ledger_History_Purchase extends Acc_Ledger_History
$title[]=_("tva non ded.");
$title[]=_("TVA NP");
if ( $own->MY_TVA_USE=='Y')
{
@ -268,7 +274,11 @@ class Acc_Ledger_History_Purchase extends Acc_Ledger_History
}
}
$title[]=_("TVAC/TTC");
$title[]=_("opérations liées");
$title[]=_("Date paiement");
$title[]=_("Méthode paiement");
$title[]=_("Montant paiement");
$title[]=_("n° opération");
$export->write_header($title);
foreach ($this->data as $line)
@ -289,22 +299,24 @@ class Acc_Ledger_History_Purchase extends Acc_Ledger_History
$export->add($line['tva_sided'],"number");
$a_tva_amount=array();
//- set all TVA to 0
foreach ($a_Tva as $l) {
$t_id=$l["tva_id"];
$a_tva_amount[$t_id]=0;
}
foreach ($line['detail_vat'] as $lineTVA)
{
$idx_tva=$lineTVA['qp_vat_code'];
$a_tva_amount[$idx_tva]=$lineTVA['vat_amount'];
}
if ($own->MY_TVA_USE == 'Y' )
if ($own->MY_TVA_USE=='Y')
{
//- set all TVA to 0
foreach ($a_Tva as $l)
{
$t_id=$l["tva_id"];
$a_tva_amount[$t_id]=0;
}
foreach ($line['detail_vat'] as $lineTVA)
{
$idx_tva=$lineTVA['qp_vat_code'];
$a_tva_amount[$idx_tva]=$lineTVA['vat_amount'];
}
foreach ($a_Tva as $line_tva)
{
$a=$line_tva['tva_id'];
$export->add($a_tva_amount[$a],"number");
$export->add($a_tva_amount[$a], "number");
}
}
$export->add($line['tvac'],"number");
@ -317,6 +329,8 @@ class Acc_Ledger_History_Purchase extends Acc_Ledger_History
for ($e=0;$e<$max;$e++) {
$row=Database::fetch_array($ret_reconcile, $e);
$export->add($row['jr_date']);
$export->add($row['qcode_bank']);
$export->add($row['jr_montant'],"number");
$export->add($row['jr_internal']);
}
}

View file

@ -260,7 +260,11 @@ class Acc_Ledger_History_Sale extends Acc_Ledger_History
}
}
$title[]=_("TVAC/TTC");
$title[]=_("opérations liées");
$title[]=_("Date paiement");
$title[]=_("Méthode paiement");
$title[]=_("Montant paiement");
$title[]=_("n° opération");
$export->write_header($title);
foreach ($this->data as $line)
@ -279,18 +283,19 @@ class Acc_Ledger_History_Sale extends Acc_Ledger_History
$export->add($line['tva_sided'],"number");
$a_tva_amount=array();
//- set all TVA to 0
foreach ($a_Tva as $l) {
$t_id=$l["tva_id"];
$a_tva_amount[$t_id]=0;
}
foreach ($line['detail_vat'] as $lineTVA)
{
$idx_tva=$lineTVA['qs_vat_code'];
$a_tva_amount[$idx_tva]=$lineTVA['vat_amount'];
}
if ($own->MY_TVA_USE == 'Y' )
{
//- set all TVA to 0
foreach ($a_Tva as $l) {
$t_id=$l["tva_id"];
$a_tva_amount[$t_id]=0;
}
foreach ($line['detail_vat'] as $lineTVA)
{
$idx_tva=$lineTVA['qs_vat_code'];
$a_tva_amount[$idx_tva]=$lineTVA['vat_amount'];
}
foreach ($a_Tva as $line_tva)
{
$a=$line_tva['tva_id'];
@ -307,7 +312,10 @@ class Acc_Ledger_History_Sale extends Acc_Ledger_History
for ($e=0;$e<$max;$e++) {
$row=Database::fetch_array($ret_reconcile, $e);
$export->add($row['jr_date']);
$export->add($row['qcode_bank']);
$export->add($row['jr_montant'],"number");
$export->add($row['jr_internal']);
}
}
$export->write();

View file

@ -267,7 +267,7 @@ class Acc_Payment
}
$s=new ISpan();
$s->name=$a->name.'_label';
$f=_(" paiement par ").$a->input().$s->input();
$f=_(" paiement par ").$a->input().$s->input().$a->search();
}
else

View file

@ -149,7 +149,6 @@ class Print_Ledger {
{
$pdf=new Print_Ledger_Detail($cn, $p_ledger);
return $pdf;
;
}
if ($jrn_type=='ODS'||$p_ledger->id==0)
{

View file

@ -90,21 +90,25 @@ class Print_Ledger_Detail_Item extends PDFLand
{
bcscale(2);
$jrn_type=$this->ledger->get_type();
$http=new HttpInput();
switch ($jrn_type)
{
case 'VEN':
$ledger=new Acc_Ledger_Sold($this->cn, $this->ledger->jrn_def_id);
$ret_detail=$ledger->get_detail_sale($_GET['from_periode'],$_GET['to_periode']);
$ret_detail=$ledger->get_detail_sale($http->get('from_periode','number'),$http->get('to_periode','number'));
break;
case 'ACH':
$ledger=new Acc_Ledger_Purchase($this->cn, $this->ledger->jrn_def_id);
$ret_detail=$ledger->get_detail_purchase($_GET['from_periode'],$_GET['to_periode']);
$ret_detail=$ledger->get_detail_purchase($http->get('from_periode','number'),$http->get('to_periode','number'));
break;
default:
die (__FILE__.":".__LINE__.'Journal invalide');
break;
}
if ( $ret_detail == null ) return;
$prepared_query=new Prepared_Query($this->ledger->db);
$prepared_query->prepare_reconcile_date();
$nb=Database::num_row($ret_detail);
$this->SetFont('DejaVu', '', 6);
$internal="";
@ -130,20 +134,35 @@ class Print_Ledger_Detail_Item extends PDFLand
$this->write_cell(20, $high, nbm($sum), 1, 0, 'R', true);
$internal=$row['jr_internal'];
$this->line_new(6);
// on the first line, the code for each column is displaid
// Payment info
// Prepare the query for reconcile date
$ret_reconcile=$this->ledger->db->execute('reconcile_date', array($row['jr_id']));
$max=Database::num_row($ret_reconcile);
for ($e=0; $e<$max; $e++)
{
$ret_row=Database::fetch_array($ret_reconcile, $e);
$msg=( $ret_row['qcode_bank']!="")?"[".$ret_row['qcode_bank']."]":$ret_row['jr_internal'];
$this->write_cell(200, $high,
sprintf(_("Paiement montant %s date %s methoded %s "), $ret_row['jr_montant'],
$ret_row['jr_date'], $msg
));
$this->line_new(6);
}
// on the first line, the code for each column is displaid
if ( $this->show_col == true ) {
//
// Header detail
$this->LongLine(30,$high,'QuickCode');
$this->write_cell(30,$high,'Poste');
$this->LongLine(70,$high,'Libellé');
$this->write_cell(20,$high,'Prix/Unit',0,0,'R');
$this->write_cell(20,$high,'Quant.',0,0,'R');
$this->write_cell(20,$high,'HTVA',0,0,'R');
$this->write_cell(20,$high,'TVA NP',0,0,'R');
$this->write_cell(20,$high,'Code TVA');
$this->write_cell(20,$high,'TVA',0,0,'R');
$this->write_cell(20,$high,'TVAC',0,0,'R');
$this->LongLine(30,$high,_('QuickCode'));
$this->write_cell(30,$high,_('Poste'));
$this->LongLine(70,$high,_('Libellé'));
$this->write_cell(20,$high,_('Prix/Unit'),0,0,'R');
$this->write_cell(20,$high,_('Quant.'),0,0,'R');
$this->write_cell(20,$high,_('HTVA'),0,0,'R');
$this->write_cell(20,$high,_('TVA NP'),0,0,'R');
$this->write_cell(20,$high,_('Code TVA'));
$this->write_cell(20,$high,_('TVA'),0,0,'R');
$this->write_cell(20,$high,_('TVAC'),0,0,'R');
$this->line_new(6);
$this->show_col=false;
}

View file

@ -96,24 +96,24 @@ class Print_Ledger_Simple extends PDF
$tmp1=$line_tva['tva_id'];
$this->rap_tva[$tmp1]=(isset($this->rap_tva[$tmp1]))?$this->rap_tva[$tmp1]:0;
}
$this->Cell(15,6,'Pièce');
$this->Cell(10,6,'Date');
$this->Cell(13,6,'ref');
$this->Cell(15,6,_('Pièce'));
$this->Cell(10,6,_('Date'));
$this->Cell(13,6,_('ref'));
if ( $this->jrn_type=='ACH')
$this->Cell(40,6,'Client');
$this->Cell(40,6,_('Client'));
else
$this->Cell(40,6,'Fournisseur');
$this->Cell(40,6,_('Fournisseur'));
$flag_tva=(count($this->a_Tva) > 4)?true:false;
if ( !$flag_tva ) $this->Cell(65,6,'Description');
if ( !$flag_tva ) $this->Cell(65,6,_('Description'));
$this->Cell(15,6,'HTVA',0,0,'R');
$this->Cell(15,6,_('HTVA'),0,0,'R');
if ( $this->jrn_type=='ACH')
{
$this->Cell(15,6,'Priv/DNA',0,0,'R');
$this->Cell(15,6,'TVA ND',0,0,'R');
$this->Cell(15,6,_('Priv/DNA'),0,0,'R');
$this->Cell(15,6,_('TVA ND'),0,0,'R');
}
$this->Cell(15,6,'TVA NP',0,0,'R'); // Unpaid TVA --> autoliquidation, NPR
$this->Cell(15,6,_('TVA NP'),0,0,'R'); // Unpaid TVA --> autoliquidation, NPR
foreach($this->a_Tva as $line_tva)
{
$this->Cell(15,6,$line_tva['tva_label'],0,0,'R');
@ -210,8 +210,13 @@ class Print_Ledger_Simple extends PDF
$a_jrn=$this->ledger->get_operation($http->get('from_periode',"number"),
$http->get('to_periode',"number"));
if ( $a_jrn == null ) return;
// Prepare the query for reconcile date
$prepared_query=new Prepared_Query($this->ledger->db);
$prepared_query->prepare_reconcile_date();
for ( $i=0;$i<count($a_jrn);$i++)
{
/* initialize tva */
@ -233,8 +238,8 @@ class Print_Ledger_Simple extends PDF
$this->rap_tva[$l]=bcadd($this->rap_tva[$l],$aAmountVat[$f]['sum_vat']);
}
$row=$a_jrn[$i];
$ret_reconcile=$this->ledger->db->execute('reconcile_date',array($row['id']));
$this->LongLine(15,5,($row['pj']),0);
$this->write_cell(10,5,$row['date_fmt'],0,0);
$this->write_cell(13,5,$row['internal'],0,0);
@ -265,7 +270,24 @@ class Print_Ledger_Simple extends PDF
$l_tvac=bcadd($other['price'], bcsub($other['vat'],$other['tva_np']));
$l_tvac=bcadd($l_tvac,$other['tva_nd']);
$this->write_cell(15,5,nbm($l_tvac),0,0,'R');
$this->line_new(5);
$this->line_new(2);
$this->write_cell(15,5, _("Payé par"));
// Add the payment information on another row
$max=Database::num_row($ret_reconcile);
$str_payment="";
if ($max > 0) {
$sep="";
for ($e=0;$e<$max;$e++) {
$row=Database::fetch_array($ret_reconcile, $e);
$msg=( $row['qcode_bank'] != "")?"[".$row['qcode_bank']."]":$row['jr_internal'];
$str_payment=$row['jr_date'].$msg.$sep;
$sep=' , ';
}
$this->write_cell (120,5,$str_payment);
}
$this->line_new(3);
// Total page
$this->tp_htva=bcadd($this->tp_htva,$other['price']);
$this->tp_tvac=bcadd($this->tp_tvac,$other['price']);

View file

@ -141,11 +141,15 @@ class Print_Ledger_Simple_Without_Vat extends PDF
*/
function export()
{
$a_jrn=$this->ledger->get_operation($_GET['from_periode'],
$_GET['to_periode']);
$http=new HttpInput;
$a_jrn=$this->ledger->get_operation($http->get('from_periode','number'),$http->get('to_periode','number'));
if ( $a_jrn == null ) return;
// Prepare the query for reconcile date
$prepared_query=new Prepared_Query($this->cn);
$prepared_query->prepare_reconcile_date();
for ( $i=0;$i<count($a_jrn);$i++)
{
@ -169,10 +173,23 @@ class Print_Ledger_Simple_Without_Vat extends PDF
if ( $this->jrn_type !='VEN')
{
$this->write_cell(15,6,sprintf("%.2f",$other['priv']),0,0,'R');
$this->write_cell(15,5,sprintf("%.2f",$other['priv']),0,0,'R');
}
$this->write_cell(15,6,sprintf("%.2f",$other['price']),0,0,'R');
$this->write_cell(15,5,sprintf("%.2f",$other['price']),0,0,'R');
$ret_reconcile=$this->cn->execute('reconcile_date',array($row['id']));
$max=Database::num_row($ret_reconcile);
$str_payment="";
if ($max > 0) {
$sep="";
for ($e=0;$e<$max;$e++) {
$row=Database::fetch_array($ret_reconcile, $e);
$msg=( $row['qcode_bank'] != "")?"[".$row['qcode_bank']."]":$row['jr_internal'];
$str_payment=$row['jr_date'].$msg.$sep;
$sep=' , ';
}
$this->write_cell (50,5,$str_payment);
}
$this->line_new(5);
}
}

View file

@ -135,6 +135,18 @@ if ( $get_option=="E")
}
if ($ret_detail==null)
return;
$a_heading[]="";
$a_heading[]="";
$a_heading[]="";
$a_heading[]=_("Date paiement");
$a_heading[]=_("Montant paiement");
$a_heading[]=_("Methode paiement");
$a_heading[]=_("Opération paiement");
// Prepare the query for reconcile date
$prepared_query=new Prepared_Query($cn);
$prepared_query->prepare_reconcile_date();
$nb=Database::num_row($ret_detail);
$title=array();
foreach ($a_heading as $key=> $value)
@ -156,6 +168,16 @@ if ( $get_option=="E")
$type="number";
$export->add($row[$j], $type);
}
//info payment
$ret_reconcile=$cn->execute('reconcile_date',array($row['jr_id']));
$max=Database::num_row($ret_reconcile);
for ($e=0;$e<$max;$e++) {
$row=Database::fetch_array($ret_reconcile, $e);
$export->add($row['jr_date']);
$export->add($row['jr_montant'],"number");
$export->add($row['qcode_bank']);
$export->add($row['jr_internal']);
}
$export->write();
}
}
@ -188,22 +210,10 @@ if ($get_option=="L" && ($jrn_type=='ODS'||$jrn_type=='FIN'||$jrn_type=='GL') )
}else {
$Row=$Jrn->get_rowSimple($get_from_periode, $get_to_periode);
}
$cn->prepare('reconcile_date_csv',
'select *
from
jrn
where
jr_id in
(select
jra_concerned
from
jrn_rapt
where jr_id = $1
union all
select
jr_id
from jrn_rapt
where jra_concerned=$1)');
// Prepare the query for reconcile date
$prepared_query=new Prepared_Query($cn);
$prepared_query->prepare_reconcile_date();
$title=array();
$title[]=_("operation");
$title[]=_("Date");
@ -245,7 +255,7 @@ if ($get_option=="L" && ($jrn_type=='ODS'||$jrn_type=='FIN'||$jrn_type=='GL') )
$export->add($line['montant'], "number");
}
//------ Add reconcilied operation ---------------
$ret_reconcile=$cn->execute('reconcile_date_csv',
$ret_reconcile=$cn->execute('reconcile_date',
array($line['jr_id']));
$max=Database::num_row($ret_reconcile);
if ($max>0)
@ -253,9 +263,11 @@ if ($get_option=="L" && ($jrn_type=='ODS'||$jrn_type=='FIN'||$jrn_type=='GL') )
for ($e=0; $e<$max; $e++)
{
$row=Database::fetch_array($ret_reconcile, $e);
$export->add($row['qcode_bank']);
$export->add($row['jr_date']);
$export->add($row['jr_internal']);
$export->add($row['jr_pj_number']);
$export->add($row['jr_montant'],"number");
}
}
$export->write();

View file

@ -129,7 +129,7 @@ $filter_year = " where p_exercice='" . sql_string($exercice) . "'";
$periode_start = $cn->make_array("select p_id,to_char(p_start,'DD-MM-YYYY') from parm_periode $filter_year order by p_start,p_end");
$w->selected = $from_periode ;
print td('Depuis') . $w->input('from_periode', $periode_start);
print td(_('Depuis')) . $w->input('from_periode', $periode_start);
print '</TR>';
print '<TR>';
@ -140,7 +140,7 @@ $w->selected = $to_periode ;
if ($w->selected== '' ){
$w->selected=$per_max->p_id;
}
print td('Jusque ') . $w->input('to_periode', $periode_end);
print td(_('Jusque')). $w->input('to_periode', $periode_end);
print "</TR><TR>";
$a = array(
array('value' => 'L', 'label' => _('Liste opérations')),
@ -153,7 +153,7 @@ print '</TR>';
print '<TR>';
$simple=$http->get("p_simple","string","L");
$w->selected = $simple;
echo '<td>Style d\'impression '.Icon_Action::infobulle(32).'</td>' . $w->input('p_simple', $a);
echo '<td>'._("Style d'impression")." ".Icon_Action::infobulle(32).'</td>' . $w->input('p_simple', $a);
print "</TR>";
echo '</TABLE>';

View file

@ -151,7 +151,8 @@ foreach ($this->data as $line) {
$sep="";
for ($e=0;$e<$max;$e++) {
$row=Database::fetch_array($ret_reconcile, $e);
echo $sep.HtmlInput::detail_op($row['jr_id'],$row['jr_date'].' '. $row['jr_internal']);
$msg=( $row['qcode_bank'] != "")?"[".$row['qcode_bank']."]":$row['jr_internal'];
echo $sep.HtmlInput::detail_op($row['jr_id'],$row['jr_date'].' '. $msg);
$sep=' ,';
}
}

View file

@ -104,7 +104,8 @@ for ($i=0;$i<$nb_data;$i++):
$sep="";
for ($e=0;$e<$max;$e++) {
$row=Database::fetch_array($ret_reconcile, $e);
echo $sep.HtmlInput::detail_op($row['jr_id'],$row['jr_date'].' '. $row['jr_internal']);
$msg=( $row['qcode_bank'] != "")?"[".$row['qcode_bank']."]":$row['jr_internal'];
echo $sep.HtmlInput::detail_op($row['jr_id'],$row['jr_date'].' '. $msg);
$sep=' ,';
}
} ?>

View file

@ -62,6 +62,9 @@ if (!defined('ALLOWED'))
<th>
<?=_('TVAC')?>
</th>
<th>
<?=_('Lien')?>
</th>
</tr>
<?php
$nb_data=count($this->data);
@ -122,7 +125,8 @@ for ($i=0;$i<$nb_data;$i++):
$sep="";
for ($e=0;$e<$max;$e++) {
$row=Database::fetch_array($ret_reconcile, $e);
echo $sep.HtmlInput::detail_op($row['jr_id'],$row['jr_date'].' '. $row['jr_internal']);
$msg=( $row['qcode_bank'] != "")?"[".$row['qcode_bank']."]":$row['jr_internal'];
echo $sep.HtmlInput::detail_op($row['jr_id'],$row['jr_date'].' '. $msg);
$sep=' ,';
}
} ?>

View file

@ -138,7 +138,8 @@ foreach ($this->data as $line) {
$sep="";
for ($e=0;$e<$max;$e++) {
$row=Database::fetch_array($ret_reconcile, $e);
echo $sep.HtmlInput::detail_op($row['jr_id'],$row['jr_date'].' '. $row['jr_internal']);
$msg=( $row['qcode_bank'] != "")?"[".$row['qcode_bank']."]":$row['jr_internal'];
echo $sep.HtmlInput::detail_op($row['jr_id'],$row['jr_date'].' '. $msg);
$sep=' ,';
}
}

View file

@ -104,7 +104,9 @@ for ($i=0;$i<$nb_data;$i++):
$sep="";
for ($e=0;$e<$max;$e++) {
$row=Database::fetch_array($ret_reconcile, $e);
echo $sep.HtmlInput::detail_op($row['jr_id'],$row['jr_date'].' '. $row['jr_internal']);
$msg=( $row['qcode_bank'] != "")?"[".$row['qcode_bank']."]":$row['jr_internal'];
echo $sep.HtmlInput::detail_op($row['jr_id'],$row['jr_date'].' '. $msg);
$sep=' ,';
}
} ?>

View file

@ -105,7 +105,8 @@ for ($i=0;$i<$nb_data;$i++):
$sep="";
for ($e=0;$e<$max;$e++) {
$row=Database::fetch_array($ret_reconcile, $e);
echo $sep.HtmlInput::detail_op($row['jr_id'],$row['jr_date'].' '. $row['jr_internal']);
$msg=( $row['qcode_bank'] != "")?"[".$row['qcode_bank']."]":$row['jr_internal'];
echo $sep.HtmlInput::detail_op($row['jr_id'],$row['jr_date'].' '. $msg);
$sep=' ,';
}
} ?>