Task #0001530: Réécriture PRINTJRN : export CSV : Purchase List (L)
This commit is contained in:
parent
eba7117ad6
commit
295dc85a38
4 changed files with 105 additions and 91 deletions
|
|
@ -42,6 +42,9 @@ abstract class Acc_Ledger_History
|
|||
|
||||
function __construct(Database $cn, $pa_ledger, $p_from, $p_to, $p_mode)
|
||||
{
|
||||
if (is_array($pa_ledger) == FALSE) {
|
||||
throw new Exception (_('pa_ledger doit être un tableau'),EXC_PARAM_VALUE);
|
||||
}
|
||||
$this->db=$cn;
|
||||
$this->ma_ledger=$pa_ledger;
|
||||
$this->m_from=$p_from;
|
||||
|
|
|
|||
|
|
@ -151,11 +151,13 @@ class Acc_Ledger_History_Purchase extends Acc_Ledger_History
|
|||
noded_amount,
|
||||
noded_vat,
|
||||
private_amount,
|
||||
novat+vat-tva_sided as tvac
|
||||
novat+vat-tva_sided as tvac,
|
||||
n_text
|
||||
from
|
||||
jrn
|
||||
join row_purchase on (qp_internal=jr_internal)
|
||||
join supplier_detail on (qp_supplier=f_id)
|
||||
left join jrn_note using (jr_id)
|
||||
where
|
||||
jr_def_id in ({$ledger_list})
|
||||
and {$periode}
|
||||
|
|
@ -165,12 +167,11 @@ class Acc_Ledger_History_Purchase extends Acc_Ledger_History
|
|||
|
||||
/**
|
||||
* @brief preprare the query for fetching the detailed VAT of an operation
|
||||
* @staticvar int $prepare
|
||||
*/
|
||||
private function add_vat_info()
|
||||
{
|
||||
$prepare=$this->db->is_prepare("vat_infop");
|
||||
if ($prepare==0)
|
||||
if ($prepare==FALSE)
|
||||
{
|
||||
$this->db->prepare("vat_infop",
|
||||
"
|
||||
|
|
@ -184,7 +185,6 @@ class Acc_Ledger_History_Purchase extends Acc_Ledger_History
|
|||
group by qp_vat_code,qp_internal order by qp_vat_code");
|
||||
}
|
||||
|
||||
$prepare=1;
|
||||
$nb_row=count($this->data);
|
||||
for ($i=0; $i<$nb_row; $i++)
|
||||
{
|
||||
|
|
@ -233,5 +233,95 @@ class Acc_Ledger_History_Purchase extends Acc_Ledger_History
|
|||
{
|
||||
return $this->data;
|
||||
}
|
||||
function export_csv()
|
||||
{
|
||||
$export=new Noalyss_Csv(_('journal'));
|
||||
$export->send_header();
|
||||
|
||||
$this->get_row();
|
||||
$this->prepare_reconcile_date();
|
||||
$this->add_vat_info();
|
||||
|
||||
$own=new Noalyss_Parameter_Folder($this->db);
|
||||
$title=array();
|
||||
$title[]=_('Date');
|
||||
$title[]=_("Paiement");
|
||||
$title[]=_("operation");
|
||||
$title[]=_("Pièce");
|
||||
$title[]=_("Fournisseur");
|
||||
$title[]=_("Note");
|
||||
$title[]=_("interne");
|
||||
$title[]=_("HTVA");
|
||||
$title[]=_("privé");
|
||||
$title[]=_("DNA");
|
||||
$title[]=_("tva non ded.");
|
||||
$title[]=_("TVA NP");
|
||||
|
||||
|
||||
if ( $own->MY_TVA_USE=='Y')
|
||||
{
|
||||
$a_Tva=$this->db->get_array("select tva_id,tva_label from tva_rate order by tva_rate,tva_label,tva_id");
|
||||
foreach($a_Tva as $line_tva)
|
||||
{
|
||||
$title[]="Tva ".$line_tva['tva_label'];
|
||||
}
|
||||
}
|
||||
$title[]=_("TVAC/TTC");
|
||||
$title[]=_("opérations liées");
|
||||
$export->write_header($title);
|
||||
|
||||
foreach ($this->data as $line)
|
||||
{
|
||||
$export->add($line['jr_date']);
|
||||
$export->add($line['jr_date_paid']);
|
||||
$export->add($line['jr_id']);
|
||||
$export->add($line['jr_pj_number']);
|
||||
$export->add($line['name']." ".
|
||||
$line["first_name"]." ".
|
||||
$line["qcode"]); // qp_supplier
|
||||
$export->add($line['jr_comment']);
|
||||
$export->add($line['jr_internal']);
|
||||
$export->add($line['novat'],"number");
|
||||
$export->add($line['private_amount'],"number");
|
||||
$export->add($line['noded_amount'],"number");
|
||||
$export->add($line['noded_vat'],"number");
|
||||
$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' )
|
||||
{
|
||||
foreach ($a_Tva as $line_tva)
|
||||
{
|
||||
$a=$line_tva['tva_id'];
|
||||
$export->add($a_tva_amount[$a],"number");
|
||||
}
|
||||
}
|
||||
$export->add($line['tvac'],"number");
|
||||
/**
|
||||
* Retrieve payment if any
|
||||
*/
|
||||
$ret_reconcile=$this->db->execute('reconcile_date',array($line['jr_id']));
|
||||
$max=Database::num_row($ret_reconcile);
|
||||
if ($max > 0) {
|
||||
for ($e=0;$e<$max;$e++) {
|
||||
$row=Database::fetch_array($ret_reconcile, $e);
|
||||
$export->add($row['jr_date']);
|
||||
$export->add($row['jr_internal']);
|
||||
}
|
||||
}
|
||||
$export->write();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -84,7 +84,7 @@ if ($get_option == 'D')
|
|||
{
|
||||
if ($jrn_type != 'ACH' && $jrn_type != 'VEN' || $Jrn->id == 0)
|
||||
{
|
||||
$get_option = 0;
|
||||
$get_option = 'A';
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -236,92 +236,13 @@ if ($get_option == "L")
|
|||
// One line summary with tiers, amount VAT, DNA, tva code ....
|
||||
//
|
||||
//------------------------------------------------------------------------------
|
||||
if ( $jrn_type=='ACH' || $jrn_type=='VEN')
|
||||
{
|
||||
$Row=$Jrn->get_rowSimple($get_from_periode,
|
||||
$get_to_periode,
|
||||
0);
|
||||
$cn->prepare('reconcile_date',"select to_char(jr_date,'DD.MM.YY') as str_date,* "
|
||||
. "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)");
|
||||
|
||||
$own=new Noalyss_Parameter_Folder($cn);
|
||||
$title=array();
|
||||
$title[]=_('Date');
|
||||
$title[]=_("Paiement");
|
||||
$title[]=_("operation");
|
||||
$title[]=_("Pièce");
|
||||
$title[]=_("Client/Fourn.");
|
||||
$title[]=_("Note");
|
||||
$title[]=_("interne");
|
||||
$title[]=_("HTVA");
|
||||
$title[]=_("privé");
|
||||
$title[]=_("DNA");
|
||||
$title[]=_("tva non ded.");
|
||||
$title[]=_("TVA NP");
|
||||
|
||||
if ( $own->MY_TVA_USE=='Y')
|
||||
{
|
||||
$a_Tva=$cn->get_array("select tva_id,tva_label from tva_rate order by tva_rate,tva_label,tva_id");
|
||||
foreach($a_Tva as $line_tva)
|
||||
{
|
||||
$title[]="Tva ".$line_tva['tva_label'];
|
||||
}
|
||||
if ( $jrn_type == "ACH") {
|
||||
$acc_ledger_history=new Acc_Ledger_History_Purchase($cn,[$Jrn->id],$get_from_periode,$get_to_periode,'D');
|
||||
$acc_ledger_history->export_csv();
|
||||
}
|
||||
$title[]=_("TVAC");
|
||||
$title[]=_("opérations liées");
|
||||
$export->write_header($title);
|
||||
|
||||
foreach ($Row as $line)
|
||||
{
|
||||
$export->add($line['date']);
|
||||
$export->add($line['date_paid']);
|
||||
$export->add($line['num']);
|
||||
$export->add($line['jr_pj_number']);
|
||||
$export->add($Jrn->get_tiers($line['jrn_def_type'],$line['jr_id']));
|
||||
$export->add($line['comment']);
|
||||
$export->add($line['jr_internal']);
|
||||
$export->add($line['HTVA'],"number");
|
||||
$export->add($line['dep_priv'],"number");
|
||||
$export->add($line['dna'],"number");
|
||||
$export->add($line['tva_dna'],"number");
|
||||
$export->add($line['tva_np'],"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['TVA'] as $lineTVA)
|
||||
{
|
||||
$idx_tva=$lineTVA[1][0];
|
||||
$a_tva_amount[$idx_tva]=$lineTVA[1][2];
|
||||
}
|
||||
if ($own->MY_TVA_USE == 'Y' )
|
||||
{
|
||||
foreach ($a_Tva as $line_tva)
|
||||
{
|
||||
$a=$line_tva['tva_id'];
|
||||
$export->add($a_tva_amount[$a],"number");
|
||||
}
|
||||
}
|
||||
$export->add($line['TVAC'],"number");
|
||||
/**
|
||||
* Retrieve payment if any
|
||||
*/
|
||||
$ret_reconcile=$cn->execute('reconcile_date',array($line['jr_id']));
|
||||
$max=Database::num_row($ret_reconcile);
|
||||
if ($max > 0) {
|
||||
for ($e=0;$e<$max;$e++) {
|
||||
$row=Database::fetch_array($ret_reconcile, $e);
|
||||
$export->add($row['str_date']);
|
||||
$export->add($row['jr_internal']);
|
||||
}
|
||||
}
|
||||
$export->write();
|
||||
|
||||
if ( $jrn_type == "VEN") {
|
||||
$acc_ledger_history=new Acc_Ledger_History_Sale($cn,[$Jrn->id],$get_from_periode,$get_to_periode,'D');
|
||||
//@todo to implement $acc_ledger_history->export_csv();
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -116,7 +116,7 @@ foreach ($this->data as $line) {
|
|||
echo "<TD class=\"num\">" . $tva_dna. "</TD>";
|
||||
$a_tva_amount=array();
|
||||
|
||||
foreach ($line['detail_vat'] as $lineTVA)
|
||||
foreach ($line['m'] as $lineTVA)
|
||||
{
|
||||
foreach ($a_Tva as $idx=>$line_tva)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue