97 throw new Exception(_(
"Format date invalide").
$date_start);
117 throw new Exception(_(
"Format date invalide").
$date_end);
129 $sql=
"select count(*)
133 j_id in (select j_id from jrnx
135 jrnx.j_jrn_def in (select jrn_def_id from jrn_def where jrn_def_type = 'VEN')
136 and j_date >= to_date($1,'DD.MM.YYYY')
137 and j_date <= to_date($2,'DD.MM.YYYY')
140 $cnt=$this->
db->get_value(
$sql, [$this->date_start, $this->date_end]);
143 throw new Exception(_(
"Données manquantes"),100);
146 $sql=
"select count(*)
150 j_id in (select j_id from jrnx
152 jrnx.j_jrn_def in (select jrn_def_id from jrn_def where jrn_def_type = 'VEN')
153 and j_date >= to_date($1,'DD.MM.YYYY')
154 and j_date <= to_date($2,'DD.MM.YYYY')
157 $cnt=$this->
db->get_value(
$sql, [$this->date_start, $this->date_end]);
160 throw new Exception(_(
"Données manquantes"),100);
166 $sql_ledger=
$g_user->get_ledger_sql(
'ALL', 3);
177 $sql_ledger=
$g_user->get_ledger_sql(
'ACH', 3);
179 if ( $p_group_ledger )
181 $group_ledger=
'j_jrn_def,';
184 $sql=
"with detail_tva as (
186 sum(qp_vat) as amount_vat,
187 sum(qp_vat_sided) as amount_sided,
188 sum(qp_price) as amount_wovat,
189 sum(qp_nd_amount) as amount_noded_amount,
190 sum(qp_nd_tva) as amount_noded_tax,
191 sum(qp_nd_tva_recup) as amount_noded_return,
192 sum(qp_dep_priv) as amount_private,
197 join tva_rate on (qp_vat_code=tva_rate.tva_id)
198 join jrnx on (quant_purchase.j_id=jrnx.j_id)
199 join jrn_def on (jrn_def.jrn_def_id=jrnx.j_jrn_def)
200 join jrn on (jrn.jr_grpt_id=jrnx.j_grpt)
202 if ( $this->tva_type==
"O")
206 j_date >= to_date($1,'DD.MM.YYYY')
207 and j_date <= to_date($2,'DD.MM.YYYY')
209 group by {$group_ledger} qp_vat_code) ";
210 }
elseif ($this->tva_type==
"P") {
213 coalesce(to_char(jr_date_paid,'YYYYMMDD'),'00000000') >=
214 to_char(to_date($1,'DD.MM.YYYY'),'YYYYMMDD')
215 and coalesce(to_char(jr_date_paid,'YYYYMMDD'),'99999999') <=
216 to_char(to_date($2,'DD.MM.YYYY'),'YYYYMMDD')
218 group by {$group_ledger} qp_vat_code) ";
219 }
elseif ($this->tva_type==
"T") {
221 ( tva_rate.tva_payment_purchase='P'
222 and coalesce(to_char(jr_date_paid,'YYYYMMDD'),'00000000') >=
223 to_char(to_date($1,'DD.MM.YYYY'),'YYYYMMDD')
224 and coalesce(to_char(jr_date_paid,'YYYYMMDD'),'99999999') <=
225 to_char(to_date($2,'DD.MM.YYYY'),'YYYYMMDD')
228 ( tva_rate.tva_payment_purchase='O'
229 and coalesce(to_char(jr_date,'YYYYMMDD'),'00000000') >=
230 to_char(to_date($1,'DD.MM.YYYY'),'YYYYMMDD')
231 and coalesce(to_char(jr_date,'YYYYMMDD'),'99999999') <=
232 to_char(to_date($2,'DD.MM.YYYY'),'YYYYMMDD')
235 group by {$group_ledger} qp_vat_code) ";
238 throw new Exception(_(
"Exig TVA invalide"),1001);
253 $sql_ledger=
$g_user->get_ledger_sql(
'VEN', 3);
255 if ( $p_group_ledger )
257 $group_ledger=
'j_jrn_def,';
259 $sql=
"with detail_tva as (
261 sum(qs_vat) as amount_vat,
262 sum(qs_vat_sided) as amount_sided,
263 sum(qs_price) as amount_wovat,
268 join tva_rate on (qs_vat_code=tva_rate.tva_id)
269 join jrnx on (quant_sold.j_id=jrnx.j_id)
270 join jrn_def on (jrn_def.jrn_def_id=jrnx.j_jrn_def)
271 join jrn on (jrn.jr_grpt_id=jrnx.j_grpt)";
272 if ( $this->tva_type==
"O")
276 j_date >= to_date($1,'DD.MM.YYYY')
277 and j_date <= to_date($2,'DD.MM.YYYY')
279 group by {$group_ledger} qs_vat_code) ";
281 }
elseif ($this->tva_type==
"P") {
284 coalesce(to_char(jr_date_paid,'YYYYMMDD'),'00000000') >=
285 to_char(to_date($1,'DD.MM.YYYY'),'YYYYMMDD')
286 and coalesce(to_char(jr_date_paid,'YYYYMMDD'),'99999999') <=
287 to_char(to_date($2,'DD.MM.YYYY'),'YYYYMMDD')
289 group by {$group_ledger} qs_vat_code) ";
291 }
elseif ($this->tva_type==
"T") {
294 ( tva_rate.tva_payment_sale='P'
295 and coalesce(to_char(jr_date_paid,'YYYYMMDD'),'00000000') >=
296 to_char(to_date($1,'DD.MM.YYYY'),'YYYYMMDD')
297 and coalesce(to_char(jr_date_paid,'YYYYMMDD'),'99999999') <=
298 to_char(to_date($2,'DD.MM.YYYY'),'YYYYMMDD')
301 ( tva_rate.tva_payment_sale='O'
302 and coalesce(to_char(jr_date,'YYYYMMDD'),'00000000') >=
303 to_char(to_date($1,'DD.MM.YYYY'),'YYYYMMDD')
304 and coalesce(to_char(jr_date,'YYYYMMDD'),'99999999') <=
305 to_char(to_date($2,'DD.MM.YYYY'),'YYYYMMDD')
308 group by {$group_ledger} qs_vat_code)
312 throw new Exception(_(
"Exig TVA invalide"),1001);
332 tva_payment_sale as tva_type
335 join tva_rate on (tva_rate.tva_id=qs_vat_code)
336 join jrn_def on (jrn_def.jrn_def_id=j_jrn_def)
337 order by jrn_def_name,tva_label";
339 $array=$this->
db->get_array(
$sql, [$this->date_start, $this->date_end]);
364 join tva_rate on (tva_rate.tva_id=qp_vat_code)
365 join jrn_def on (jrn_def.jrn_def_id=j_jrn_def)
366 order by jrn_def_name,tva_label";
367 $array=$this->
db->get_array(
$sql, [$this->date_start, $this->date_end]);
385 tva_rate.tva_payment_sale
388 join tva_rate on (tva_rate.tva_id=qs_vat_code)
390 $array=$this->
db->get_array(
$sql, [$this->date_start, $this->date_end]);
415 join tva_rate on (tva_rate.tva_id=qp_vat_code)
417 $array=$this->
db->get_array(
$sql, [$this->date_start, $this->date_end]);
427 require_once NOALYSS_INCLUDE.
"/template/tax_summary_display.php";
436 $id=uniqid(
"export_");
437 echo
'<form method="GET" action="export.php" ';
438 printf(
'id="%s" onsubmit="download_document_form(\'%s\')">',
$id,
$id);
455 $id=uniqid(
"export_");
456 echo
'<form method="GET" action="export.php" ';
457 printf(
'id="%s" onsubmit="download_document_form(\'%s\')">',
$id,
$id);
global $g_user
if no group available , then stop
contains the class for connecting to Noalyss
static hidden()
return a string to set gDossier into a FORM
Compute , display and export the tax summary.
check()
depends of quant_* table, so we must check first that everything is in these tables
form_export_pdf()
display a form to export in PDF
__construct(Database $db, $p_start, $p_end)
$tva_type
exigibility of VAT : operation , payment date or depending of setting in tva_rate
get_row_sale()
Total for each sales ledger.
display()
display the summary of VAT in the range of date
build_sql_sale($p_group_ledger=TRUE)
Build the SQL for sale vat.
build_sql_purchase($p_group_ledger)
Build the SQL for sale vat.
set_date_start($date_start)
get_summary_sale()
Summary for all sales ledger.
get_summary_purchase()
Summary for all purchase ledger.
get_row_purchase()
Total for each purchase ledger.
form_export_csv()
display a form to export in CSV
if( $delta< 0) elseif( $delta==0)