Currency : export PDF and CSV with currency for printing financial ledger listing(oneline)

This commit is contained in:
Dany De Bontridder 2018-12-03 13:53:30 +01:00
parent dd8bc6750f
commit 18bb3ec046
7 changed files with 96 additions and 22 deletions

View file

@ -1753,7 +1753,6 @@ class Acc_Ledger extends jrn_def_sql
* @brief retrieve operation from jrn
* @param $p_from periode (id)
* @param $p_to periode (id)
* @return Anc_Plan array
*/
function get_operation($p_from, $p_to)
{

View file

@ -124,12 +124,20 @@ class Acc_Ledger_History_Financial extends Acc_Ledger_History
jr_internal,
jrn.jr_comment,
jr_pj_name,
qf_amount
qf_amount,
currency_id,
currency_rate,
currency_rate_ref,
oc_amount,
oc_vat_amount,
currency.cr_code_iso
from
jrn
join quant_fin using (jr_id)
join detail as tiers on (tiers.f_id=qf_other)
join detail as bk on (bk.f_id=qf_bank)
left join operation_currency using(j_id)
join currency on (currency.id=jrn.currency_id)
where
jr_def_id in ({$ledger_list})
and {$periode}

View file

@ -433,8 +433,25 @@ class Acc_Ledger_History_Generic extends Acc_Ledger_History
jrn.jr_grpt_id as grpt_id,
jrn.jr_pj_name as pj,
jrn_def_type,
jrn.jr_tech_per
jrn.jr_tech_per,
jrn.currency_id,
jrn.currency_rate,
jrn.currency_rate_ref,
currency.cr_code_iso,
coalesce(sum_ocamount,0) as sum_ocamount,
coalesce(sum_ocvat_amount,0) as sum_ocvat_amount
FROM jrn join jrn_def on (jrn_def_id=jr_def_id)
join currency on (currency.id=jrn.currency_id)
left join (
select jrn2.jr_id , sum(coalesce(oc_amount,0)) as sum_ocamount,sum(coalesce(oc_vat_amount,0)) as sum_ocvat_amount
from operation_currency
join jrnx using (j_id)
join jrn as jrn2 on (j_grpt=jrn2.jr_grpt_Id)
where
j_id in (select j_id from jrnx where j_grpt=jrn2.jr_grpt_id)
and j_debit='t'
group by jr_id
) as OC1 using (jr_id)
WHERE $periode and $jrn order by jr_date,substring(jrn.jr_pj_number,'[0-9]+$')::numeric asc $cond_limite";
$Res=$this->db->exec_sql($sql);
$Max=Database::num_row($Res);
@ -503,9 +520,13 @@ class Acc_Ledger_History_Generic extends Acc_Ledger_History
j_qcode,
jrn_def_type,
jr_rapt as oc, j_tech_per as periode,
j_id
from jrnx left join jrn on
jr_grpt_id=j_grpt
j_id,
currency_id,
currency_rate,
currency_rate_ref
from jrnx
join jrn on (jr_grpt_id=j_grpt )
left join operation_currency using (j_id)
left join tmp_pcmn on pcm_val=j_poste
join jrn_def on (jrn_def_id=jr_def_id)
where j_jrn_def in (".$ledger_list.")

View file

@ -56,12 +56,13 @@ class Print_Ledger_Financial extends PDF
$this->Cell(40,6,nbm($this->rap_amount),0,0,'R');
$this->Ln(6);
$this->SetFont('DejaVu', 'B', 7);
$this->Cell(15,6,'Piece');
$this->Cell(10,6,'Date');
$this->Cell(15,6,'Interne');
$this->Cell(40,6,'Dest/Orig');
$this->Cell(80,6,'Commentaire');
$this->Cell(20,6,'Montant');
$this->Cell(15,6,_('Piece'));
$this->Cell(10,6,_('Date'));
$this->Cell(10,6,_('Interne'));
$this->Cell(40,6,_('Dest/Orig'));
$this->Cell(60,6,_('Commentaire'));
$this->Cell(20,6,_('Device'),0,0,'R');
$this->Cell(20,6,_('Montant'),0,0,'R');
$this->Ln(6);
}
@ -92,24 +93,47 @@ class Print_Ledger_Financial 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'));
$this->SetFont('DejaVu', '', 6);
if ( $a_jrn == null ) return;
bcscale(2);
$this->ledger->load();
$currency=$this->ledger->get_currency()->get_code();
$currency_id=$this->ledger->get_currency()->get_id();
$this->cn->prepare("amount_cur",
"select jrn2.jr_id ,
sum(coalesce(oc_amount,0)) as sum_ocamount,
sum(coalesce(oc_vat_amount,0)) as sum_ocvat_amount
from operation_currency
join jrnx using (j_id)
join jrn as jrn2 on (j_grpt=jrn2.jr_grpt_Id)
where
j_id in (select j_id from jrnx where j_grpt=jrn2.jr_grpt_id and j_debit='t')
and jr_id=$1
group by jr_id"
);
for ( $i=0;$i<count($a_jrn);$i++)
{
$row=$a_jrn[$i];
$this->write_cell(15,5,$row['pj']);
$this->write_cell(10,5,$row['date_fmt']);
$this->write_cell(15,5,$row['internal']);
$this->write_cell(10,5,$row['internal']);
$name=$this->ledger->get_tiers($this->jrn_type,$row['id']);
$this->write_cell(40,5,$name,0,'L');
$this->write_cell(40,5,$name,0,0,'L');
$this->LongLine(80,5,$row['comment'],0,'L');
$this->LongLine(60,5,$row['comment'],0,'L');
$amount=$this->cn->get_value('select qf_amount from quant_fin where jr_id=$1',array( $row['id']));
if ( $currency_id != 0) {
$ret_amount_cur=$this->cn->execute("amount_cur",array($row['id']));
if ( $this->cn->count($ret_amount_cur) == 1) {
$amount_cur=Database::fetch_result($ret_amount_cur, 0,1);
$this->write_cell(20,5,sprintf('%s %s',nbm($amount_cur),$currency),0,0,'R');
}
}
$this->write_cell(20,5,sprintf('%s',nbm($amount)),0,0,'R');
$this->line_new(5);
$this->tp_amount=bcadd($this->tp_amount,$amount);

View file

@ -271,7 +271,10 @@ if ( ! file_exists($ps2pdf) )
/**
* Outil pour manipuler les PDF
*/
$pdftk='/usr/bin/pdftk';
if ( ! isset ($pdftk))
{
$pdftk='/usr/bin/pdftk';
}
if (file_exists($pdftk))
{
define ('PDFTK',$pdftk);

View file

@ -213,6 +213,8 @@ if ($get_option=="L" && ($jrn_type=='ODS'||$jrn_type=='FIN'||$jrn_type=='GL') )
$title[]=_("commentaire");
$title[]=_("internal");
$title[]=_("montant");
$title[]=_("montant devise");
$title[]=_("devise");
$export->write_header($title);
foreach ($Row as $line)
{
@ -238,12 +240,15 @@ if ($get_option=="L" && ($jrn_type=='ODS'||$jrn_type=='FIN'||$jrn_type=='GL') )
" where jr_id=$1", array($line['jr_id']));
$export->add($positive, "number");
$export->add("");
//$export->add("");
}
else
{
$export->add($line['montant'], "number");
}
//-- add currency
$export->add(bcadd($line['sum_ocamount'],$line['sum_ocvat_amount']),"number");
$export->add($line['cr_code_iso']);
//------ Add reconcilied operation ---------------
$ret_reconcile=$cn->execute('reconcile_date_csv',
array($line['jr_id']));

View file

@ -30,10 +30,13 @@ if (!defined('ALLOWED'))
<tr>
<th><?= _('Date') ?></th>
<th><?= _('Banque') ?></th>
<th><?= _("Interne") ?></th>
<th><?=_('Pièce')?></th>
<th><?= _("Tiers") ?></th>
<th><?= _("Libellé") ?></th>
<th><?= _("Montant") ?></th>
<th class="num"><?= _("Montant") ?></th>
<th class="num"><?= _("M. Devise") ?></th>
<th><?= _("Devise") ?></th>
<th><?= _("Opérations rapprochées") ?></th>
</tr>
<?php
@ -49,6 +52,11 @@ if (!defined('ALLOWED'))
<td>
<?= $this->data[$i]['bk_qcode']; ?>
</td>
<td>
<?php
echo HtmlInput::detail_op($this->data[$i]['jr_id'], $this->data[$i]['jr_internal']);
?>
</td>
<td>
<?= $this->data[$i]['jr_pj_number']; ?>
</td>
@ -61,9 +69,15 @@ if (!defined('ALLOWED'))
<td>
<?= h($this->data[$i]['jr_comment']) ?>
</td>
<td>
<td class="num">
<?= nbm($this->data[$i]['qf_amount']) ?>
</td>
<td class="num">
<?=nbm($this->data[$i]['oc_amount'])?>
</td>
<td>
<?=$this->data[$i]['cr_code_iso']?>
</td>
<td>
<?php
$ret_reconcile=$this->db->execute('reconcile_date',