47 require_once NOALYSS_TEMPLATE.
"/tax_detail-display_form.php";
60 if (
$g_user->get_status_security_ledger()==1 &&
$g_user->isAdmin()==0) {
61 $sSecurity=
$g_user->get_ledger_sql(
'ALL').
" and ";
62 $sSecurity=str_replace(
'jrn_def_id',
'v1.jr_def_id',$sSecurity);
67 $filter_ledger.=
" jr_date >= to_date ($1,'DD.MM.YYYY') and jr_date <= to_date($2,'DD.MM.YYYY')";
71 $aParameter=array($this->
from,$this->
to);
74 if ( !empty($this->tva_code ) )
78 $aParameter[]=$acc_tva->tva_id;
82 if ( $this->ledger_id <> -1 ) {
89with v_amount_tva as (select
92 ,case when j_debit is true then 0-j_montant else j_montant end j_montant
93 , qp_vat_code tva_opid
94 , 0-qp_nd_tva qp_nd_tva
95 , 0-qp_nd_tva_recup qp_nd_tva_recup
96 , 0-qp_dep_priv qp_dep_priv
105 ,to_char(jr2.jr_date,'DD.MM.YY') str_date
109 join jrn jr2 on (jr1.j_grpt = jr2.jr_grpt_id)
110 join quant_purchase q1 using (j_id)
114 ,case when j_debit is true then 0-j_montant else j_montant end
127 ,to_char(jr4.jr_date,'DD.MM.YY')
131 join jrn jr4 on (jr3.j_grpt = jr4.jr_grpt_id)
132 join quant_sold qs using (j_id)
134select *, tva_label,format ('%s (%s)',t1.tva_code ,t1.tva_label) tva_code,tva_rate
136join tva_rate t1 on (v1.tva_opid=t1.tva_id)
138order by jr_date,j_debit
150 require NOALYSS_TEMPLATE.
"/tax_detail-html.php";
154 require NOALYSS_TEMPLATE.
"/tax_detail-button_export_csv.php";
161 $noalyss_csv=
new Noalyss_Csv(sprintf(
"tax_detail-{$this->tva_code}-{$this->from}-{$this->to}"));
164 $header=[
_(
"date"),
_(
'piece'),
_(
"n° interne"),
_(
"fiche"),
_(
"poste"),
_(
"base"),
_(
"privé"),
_(
"code tva"),
_(
"taux"),
_(
"montant tva"),
_(
"non deductible"),
_(
"recup")];
165 $noalyss_csv->send_header();
166 $noalyss_csv->write_header(
$header );
167 foreach (
$data as $item) {
169 $noalyss_csv->add($item[
'str_date']);
170 $noalyss_csv->add($item[
'jr_pj_number']);
171 $noalyss_csv->add($item[
'jr_internal']);
172 $noalyss_csv->add($item[
'j_qcode']);
173 $noalyss_csv->add($item[
'j_poste']);
174 $noalyss_csv->add(
nb($item[
'j_montant'],2),
"number");
175 $noalyss_csv->add(
nb($item[
'qp_dep_priv'],2),
"number");
176 $noalyss_csv->add($item[
'tva_code']);
177 $noalyss_csv->add(
nb($item[
'tva_rate'],2),
"number");
178 $noalyss_csv->add(
nb($item[
'vat_amount'],2),
"number");
179 $noalyss_csv->add(
nb($item[
'qp_nd_tva'],2),
"number");
180 $noalyss_csv->add(
nb($item[
'qp_nd_tva_recup'],2),
"number");
181 $noalyss_csv->write();
nb($p_number)
format the number for the CSV export
global $g_user
if no group available , then stop
_("actif, passif,charge,...")
static build($db, $p_code)
retrieve TVA rate thanks the code that could be the tva_id or tva_code.
Manage the CSV : manage files and write CSV record.
__construct($tva_code, $from, $to, $ledger_id)
html()
display the result in HTML
static display_form()
display a form for giving tva_code and dates
$ledger_id
ledger_id (jrn_def.jrn_def_id) -1, means all ledger Sale + Purchase
csv()
export the result in a CSV file
if(count($a_accounting)==0) $header