33require
'../../main.inc.php';
34require_once DOL_DOCUMENT_ROOT .
'/core/lib/report.lib.php';
35require_once DOL_DOCUMENT_ROOT .
'/core/lib/tax.lib.php';
36require_once DOL_DOCUMENT_ROOT .
'/core/lib/date.lib.php';
37require_once DOL_DOCUMENT_ROOT .
'/compta/tva/class/tva.class.php';
38require_once DOL_DOCUMENT_ROOT .
'/compta/localtax/class/localtax.class.php';
39require_once DOL_DOCUMENT_ROOT .
'/compta/facture/class/facture.class.php';
40require_once DOL_DOCUMENT_ROOT .
'/product/class/product.class.php';
41require_once DOL_DOCUMENT_ROOT .
'/compta/paiement/class/paiement.class.php';
42require_once DOL_DOCUMENT_ROOT .
'/fourn/class/fournisseur.facture.class.php';
43require_once DOL_DOCUMENT_ROOT .
'/fourn/class/paiementfourn.class.php';
44require_once DOL_DOCUMENT_ROOT .
'/expensereport/class/expensereport.class.php';
45require_once DOL_DOCUMENT_ROOT .
'/expensereport/class/paymentexpensereport.class.php';
57$langs->loadLangs(array(
"other",
"compta",
"banks",
"bills",
"companies",
"product",
"trips",
"admin"));
59$refresh = (GETPOSTISSET(
'submit') || GETPOSTISSET(
'vat_rate_show') || GETPOSTISSET(
'invoice_type'));
60$invoice_type = GETPOSTISSET(
'invoice_type') ?
GETPOST(
'invoice_type',
'alpha') :
'';
61$vat_rate_show = GETPOSTISSET(
'vat_rate_show') ?
GETPOST(
'vat_rate_show',
'alphanohtml') : -1;
64include DOL_DOCUMENT_ROOT .
'/compta/tva/initdatesforvat.inc.php';
67@phan-var-force int $date_start
68@phan-var-force int $date_end
69@phan-var-force string $date_start_month
70@phan-var-force string $date_start_year
71@phan-var-force string $date_start_day
72@phan-var-force string $date_end_month
73@phan-var-force string $date_end_year
74@phan-var-force string $date_end_day
85if (GETPOSTISSET(
"modetax")) {
97 $socid = $user->socid;
106$form =
new Form($db);
107$company_static =
new Societe($db);
108$invoice_customer =
new Facture($db);
111$product_static =
new Product($db);
116$morequerystring =
'';
117$listofparams = array(
'date_startmonth',
'date_startyear',
'date_startday',
'date_endmonth',
'date_endyear',
'date_endday');
118foreach ($listofparams as $param) {
120 $morequerystring .= ($morequerystring ?
'&' :
'') . $param .
'=' .
GETPOST($param);
124$title = $langs->trans(
"VATReport") .
" " .
dol_print_date($date_start,
'',
'tzserver') .
" -> " .
dol_print_date($date_end,
'',
'tzserver');
125llxHeader(
'', $title,
'',
'', 0, 0,
'',
'', $morequerystring);
131$fsearch =
'<!-- hidden fields for form -->';
132$fsearch .=
'<input type="hidden" name="token" value="' .
newToken() .
'">';
133$fsearch .=
'<input type="hidden" name="modetax" value="' . $modetax .
'">';
139$name = $langs->trans(
"VATReportByRates");
142 $calcmode = $langs->trans(
'OptionVATDefault');
145 $calcmode = $langs->trans(
'OptionVATDebitOption');
148 $calcmode = $langs->trans(
'OptionPaymentForProductAndServices');
150$calcmode .=
' <span class="opacitymedium">(' . $langs->trans(
"TaxModuleSetupToModifyRules", DOL_URL_ROOT .
'/admin/taxes.php') .
')</span>';
152$period = $form->selectDate($date_start,
'date_start', 0, 0, 0,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'',
'',
'tzserver');
154$period .= $form->selectDate($date_end,
'date_end', 0, 0, 0,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'',
'',
'tzserver');
155$prevyear = $date_start_year;
158if ($prevquarter > 1) {
164$nextyear = $date_start_year;
166if ($nextquarter < 4) {
172$description = $fsearch;
176 $description .= $langs->trans(
"RulesVATDueProducts");
179 $description .= $langs->trans(
"RulesVATInProducts");
182 $description .=
'<br>' . $langs->trans(
"RulesVATDueServices");
185 $description .=
'<br>' . $langs->trans(
"RulesVATInServices");
189 $description .=
'<br>' . $langs->trans(
"DepositsAreNotIncluded");
191 $description .=
'<br>' . $langs->trans(
"DepositsAreNotIncluded").
' (for services)';
193 $description .=
'<br>' . $langs->trans(
"DepositsAreNotIncluded").
' (for products)';
198 $description .=
'<br>' . $langs->trans(
"SupplierDepositsAreNotIncluded");
200 $description .=
'<br>' . $langs->trans(
"SupplierDepositsAreNotIncluded").
' (for services)';
202 $description .=
'<br>' . $langs->trans(
"SupplierDepositsAreNotIncluded").
' (for products)';
205if (isModEnabled(
'accounting')) {
206 $description .=
'<br>' . $langs->trans(
"ThisIsAnEstimatedValue");
210$elementcust = $langs->trans(
"CustomersInvoices");
211$productcust = $langs->trans(
"ProductOrService");
212$amountcust = $langs->trans(
"AmountHT");
213$vatcust = $langs->trans(
"VATReceived");
214$namecust = $langs->trans(
"Name");
215if ($mysoc->tva_assuj) {
216 $vatcust .=
' (' . $langs->trans(
"VATToPay") .
')';
220$elementsup = $langs->trans(
"SuppliersInvoices");
221$productsup = $productcust;
222$amountsup = $amountcust;
223$vatsup = $langs->trans(
"VATPaid");
225if ($mysoc->tva_assuj) {
226 $vatsup .=
' (' . $langs->trans(
"ToGetBack") .
')';
229$optioncss =
GETPOST(
'optioncss',
'alpha');
233if ($optioncss !=
"print") {
234 report_header($name,
'', $period, $periodlink, $description, $builddate, $exportlink, array(), $calcmode);
237$vatcust = $langs->trans(
"VATReceived");
238$vatsup = $langs->trans(
"VATPaid");
239$vatexpensereport = $langs->trans(
"VATPaid");
243print
'<div class="div-table-responsive">';
244print
'<table class="liste noborder centpercent">';
256$x_coll =
tax_by_rate(
'vat', $db, 0, 0, $date_start, $date_end, $modetax,
'sell');
257$x_paye =
tax_by_rate(
'vat', $db, 0, 0, $date_start, $date_end, $modetax,
'buy');
259if (!is_array($x_coll) || !is_array($x_paye)) {
260 $langs->load(
"errors");
262 print
'<tr><td colspan="' . $columns .
'">' . $langs->trans(
"ErrorNoAccountancyModuleLoaded") .
'</td></tr>';
263 } elseif ($x_coll == -2) {
264 print
'<tr><td colspan="' . $columns .
'">' . $langs->trans(
"FeatureNotYetAvailable") .
'</td></tr>';
266 print
'<tr><td colspan="' . $columns .
'">' . $langs->trans(
"Error") .
'</td></tr>';
271 foreach (array_keys($x_coll) as $my_coll_rate) {
272 $x_both[$my_coll_rate] = array(
276 $x_both[$my_coll_rate][
'coll'][
'totalht'] = $x_coll[$my_coll_rate][
'totalht'];
277 $x_both[$my_coll_rate][
'coll'][
'vat'] = $x_coll[$my_coll_rate][
'vat'];
278 $x_both[$my_coll_rate][
'paye'][
'totalht'] = 0;
279 $x_both[$my_coll_rate][
'paye'][
'vat'] = 0;
280 $x_both[$my_coll_rate][
'coll'][
'links'] =
'';
281 $x_both[$my_coll_rate][
'coll'][
'detail'] = array();
282 foreach ($x_coll[$my_coll_rate][
'facid'] as
$id => $dummy) {
283 $invoice_customer->id = $x_coll[$my_coll_rate][
'facid'][
$id];
284 $invoice_customer->ref = $x_coll[$my_coll_rate][
'facnum'][
$id];
285 $invoice_customer->type = $x_coll[$my_coll_rate][
'type'][
$id];
288 $company_static->id = $x_coll[$my_coll_rate][
'company_id'][
$id];
289 $company_static->name = $x_coll[$my_coll_rate][
'company_name'][
$id];
290 $company_static->name_alias = $x_coll[$my_coll_rate][
'company_alias'][
$id];
291 $company_static->email = $x_coll[$my_coll_rate][
'company_email'][
$id];
292 $company_static->tva_intra = isset($x_coll[$my_coll_rate][
'tva_intra'][
$id]) ? $x_coll[$my_coll_rate][
'tva_intra'][
$id] :
'0';
293 $company_static->client = $x_coll[$my_coll_rate][
'company_client'][
$id];
294 $company_static->fournisseur = $x_coll[$my_coll_rate][
'company_fournisseur'][
$id];
295 $company_static->status = $x_coll[$my_coll_rate][
'company_status'][
$id];
296 $company_static->code_client = $x_coll[$my_coll_rate][
'company_customer_code'][
$id];
297 $company_static->code_compta_client = $x_coll[$my_coll_rate][
'company_customer_accounting_code'][
$id];
298 $company_static->code_fournisseur = $x_coll[$my_coll_rate][
'company_supplier_code'][
$id];
299 $company_static->code_compta_fournisseur = $x_coll[$my_coll_rate][
'company_supplier_accounting_code'][
$id];
301 $x_both[$my_coll_rate][
'coll'][
'detail'][] = array(
302 'id' => $x_coll[$my_coll_rate][
'facid'][
$id],
303 'descr' => $x_coll[$my_coll_rate][
'descr'][
$id],
304 'pid' => $x_coll[$my_coll_rate][
'pid'][
$id],
305 'pref' => $x_coll[$my_coll_rate][
'pref'][
$id],
306 'ptype' => $x_coll[$my_coll_rate][
'ptype'][
$id],
307 'payment_id' => $x_coll[$my_coll_rate][
'payment_id'][
$id],
308 'payment_ref' => $x_coll[$my_coll_rate][
'payment_ref'][
$id],
309 'payment_amount' => $x_coll[$my_coll_rate][
'payment_amount'][
$id],
310 'ftotal_ttc' => $x_coll[$my_coll_rate][
'ftotal_ttc'][
$id],
311 'dtotal_ttc' => $x_coll[$my_coll_rate][
'dtotal_ttc'][
$id],
312 'dtype' => $x_coll[$my_coll_rate][
'dtype'][
$id],
313 'datef' => $x_coll[$my_coll_rate][
'datef'][
$id],
314 'datep' => $x_coll[$my_coll_rate][
'datep'][
$id],
316 'company_link' => $company_static->getNomUrl(1,
'', 20),
318 'ddate_start' => $x_coll[$my_coll_rate][
'ddate_start'][
$id],
319 'ddate_end' => $x_coll[$my_coll_rate][
'ddate_end'][
$id],
320 'totalht' => $x_coll[$my_coll_rate][
'totalht_list'][
$id],
321 'vat' => $x_coll[$my_coll_rate][
'vat_list'][
$id],
322 'link' => $invoice_customer->getNomUrl(1,
'', 12)
327 foreach (array_keys($x_paye) as $my_paye_rate) {
328 $x_both[$my_paye_rate][
'paye'][
'totalht'] = $x_paye[$my_paye_rate][
'totalht'];
329 $x_both[$my_paye_rate][
'paye'][
'vat'] = $x_paye[$my_paye_rate][
'vat'];
330 if (!isset($x_both[$my_paye_rate][
'coll'][
'totalht'])) {
331 $x_both[$my_paye_rate][
'coll'][
'totalht'] = 0;
332 $x_both[$my_paye_rate][
'coll'][
'vat'] = 0;
334 $x_both[$my_paye_rate][
'paye'][
'links'] =
'';
335 $x_both[$my_paye_rate][
'paye'][
'detail'] = array();
337 foreach ($x_paye[$my_paye_rate][
'facid'] as
$id => $dummy) {
339 if ($x_paye[$my_paye_rate][
'ptype'][
$id] ===
'ExpenseReportPayment') {
340 $expensereport->id = $x_paye[$my_paye_rate][
'facid'][
$id];
341 $expensereport->ref = $x_paye[$my_paye_rate][
'facnum'][
$id];
342 $expensereport->type = $x_paye[$my_paye_rate][
'type'][
$id];
344 $x_both[$my_paye_rate][
'paye'][
'detail'][] = array(
345 'id' => $x_paye[$my_paye_rate][
'facid'][
$id],
346 'descr' => $x_paye[$my_paye_rate][
'descr'][
$id],
347 'pid' => $x_paye[$my_paye_rate][
'pid'][
$id],
348 'pref' => $x_paye[$my_paye_rate][
'pref'][
$id],
349 'ptype' => $x_paye[$my_paye_rate][
'ptype'][
$id],
350 'payment_id' => $x_paye[$my_paye_rate][
'payment_id'][
$id],
351 'payment_ref' => $x_paye[$my_paye_rate][
'payment_ref'][
$id],
352 'payment_amount' => $x_paye[$my_paye_rate][
'payment_amount'][
$id],
353 'ftotal_ttc' =>
price2num($x_paye[$my_paye_rate][
'ftotal_ttc'][
$id]),
354 'dtotal_ttc' =>
price2num($x_paye[$my_paye_rate][
'dtotal_ttc'][
$id]),
355 'dtype' => $x_paye[$my_paye_rate][
'dtype'][
$id],
356 'ddate_start' => $x_paye[$my_paye_rate][
'ddate_start'][
$id],
357 'ddate_end' => $x_paye[$my_paye_rate][
'ddate_end'][
$id],
358 'totalht' =>
price2num($x_paye[$my_paye_rate][
'totalht_list'][
$id]),
359 'vat' => $x_paye[$my_paye_rate][
'vat_list'][
$id],
360 'link' => $expensereport->getNomUrl(1)
363 $invoice_supplier->id = $x_paye[$my_paye_rate][
'facid'][
$id];
364 $invoice_supplier->ref = $x_paye[$my_paye_rate][
'facnum'][
$id];
365 $invoice_supplier->type = $x_paye[$my_paye_rate][
'type'][
$id];
367 $company_static->id = $x_paye[$my_paye_rate][
'company_id'][
$id];
368 $company_static->name = $x_paye[$my_paye_rate][
'company_name'][
$id];
369 $company_static->name_alias = $x_paye[$my_paye_rate][
'company_alias'][
$id];
370 $company_static->email = $x_paye[$my_paye_rate][
'company_email'][
$id];
371 $company_static->tva_intra = $x_paye[$my_paye_rate][
'tva_intra'][
$id];
372 $company_static->client = $x_paye[$my_paye_rate][
'company_client'][
$id];
373 $company_static->fournisseur = $x_paye[$my_paye_rate][
'company_fournisseur'][
$id];
374 $company_static->status = $x_paye[$my_paye_rate][
'company_status'][
$id];
375 $company_static->code_client = $x_paye[$my_paye_rate][
'company_customer_code'][
$id];
376 $company_static->code_compta_client = $x_paye[$my_paye_rate][
'company_customer_accounting_code'][
$id];
377 $company_static->code_fournisseur = $x_paye[$my_paye_rate][
'company_supplier_code'][
$id];
378 $company_static->code_compta_fournisseur = $x_paye[$my_paye_rate][
'company_supplier_accounting_code'][
$id];
380 $x_both[$my_paye_rate][
'paye'][
'detail'][] = array(
381 'id' => $x_paye[$my_paye_rate][
'facid'][
$id],
382 'descr' => $x_paye[$my_paye_rate][
'descr'][
$id],
383 'pid' => $x_paye[$my_paye_rate][
'pid'][
$id],
384 'pref' => $x_paye[$my_paye_rate][
'pref'][
$id],
385 'ptype' => $x_paye[$my_paye_rate][
'ptype'][
$id],
386 'payment_id' => $x_paye[$my_paye_rate][
'payment_id'][
$id],
387 'payment_ref' => $x_paye[$my_paye_rate][
'payment_ref'][
$id],
388 'payment_amount' => $x_paye[$my_paye_rate][
'payment_amount'][
$id],
389 'ftotal_ttc' =>
price2num($x_paye[$my_paye_rate][
'ftotal_ttc'][
$id]),
390 'dtotal_ttc' =>
price2num($x_paye[$my_paye_rate][
'dtotal_ttc'][
$id]),
391 'dtype' => $x_paye[$my_paye_rate][
'dtype'][
$id],
392 'datef' => $x_paye[$my_paye_rate][
'datef'][
$id],
393 'datep' => $x_paye[$my_paye_rate][
'datep'][
$id],
395 'company_link' => $company_static->getNomUrl(1,
'', 20),
397 'ddate_start' => $x_paye[$my_paye_rate][
'ddate_start'][
$id],
398 'ddate_end' => $x_paye[$my_paye_rate][
'ddate_end'][
$id],
399 'totalht' =>
price2num($x_paye[$my_paye_rate][
'totalht_list'][
$id]),
400 'vat' => $x_paye[$my_paye_rate][
'vat_list'][
$id],
401 'link' => $invoice_supplier->getNomUrl(1,
'', 12)
419 print
'<tr class="liste_titre">';
420 print
'<td class="left">' . $elementcust .
'</td>';
421 print
'<td class="left">' . $langs->trans(
"DateInvoice") .
'</td>';
423 print
'<td class="left">' . $langs->trans(
"DatePayment") .
'</td>';
427 print
'<td class="left">' . $namecust .
'</td>';
428 print
'<td class="left">' . $productcust .
'</td>';
430 print
'<td class="right">' . $amountcust .
'</td>';
431 print
'<td class="right">' . $langs->trans(
"Payment") .
' (' . $langs->trans(
"PercentOfInvoice") .
')</td>';
433 print
'<td class="right">' . $langs->trans(
"AmountHTVATRealReceived") .
'</td>';
434 print
'<td class="right">' . $vatcust .
'</td>';
437 $action =
"tvadetail";
438 $parameters[
"mode"] = $modetax;
439 $parameters[
"start"] = $date_start;
440 $parameters[
"end"] = $date_end;
441 $parameters[
"type"] =
'vat';
443 $object = array(&$x_coll, &$x_paye, &$x_both);
445 $hookmanager->initHooks(array(
'externalbalance'));
446 $reshook = $hookmanager->executeHooks(
'addVatLine', $parameters, $object, $action);
448 foreach (array_keys($x_coll) as $rate) {
449 $subtot_coll_total_ht = 0;
450 $subtot_coll_vat = 0;
452 if (is_array($x_both[$rate][
'coll'][
'detail'])) {
455 print
'<td class="tax_rate" colspan="' . ($span + 1) .
'">';
456 print $langs->trans(
'Rate') .
' : ' .
vatrate($rate) .
'%';
457 print
' - <a class="reposition" href="' . DOL_URL_ROOT .
'/compta/tva/quadri_detail.php?invoice_type=customer';
458 if ($invoice_type !=
'customer' || !GETPOSTISSET(
'vat_rate_show') ||
GETPOST(
'vat_rate_show') != $rate) {
459 print
'&vat_rate_show=' . urlencode($rate);
461 print
'&date_startyear=' . urlencode($date_start_year) .
'&date_startmonth=' . urlencode($date_start_month) .
'&date_startday=' . urlencode($date_start_day) .
'&date_endyear=' . urlencode($date_end_year) .
'&date_endmonth=' . urlencode($date_end_month) .
'&date_endday=' . urlencode($date_end_day) .
'">' .
img_picto(
'',
'chevron-down',
'class="paddingrightonly"') . $langs->trans(
'VATReportShowByRateDetails') .
'</a>';
463 print
'</tr>' .
"\n";
465 foreach ($x_both[$rate][
'coll'][
'detail'] as $index => $fields) {
468 $type = (isset($fields[
'dtype']) ? $fields[
'dtype'] : $fields[
'ptype']);
471 if (!empty($fields[
'ddate_start'])) {
474 if (!empty($fields[
'ddate_end'])) {
479 $ratiopaymentinvoice = 1;
484 if (isset($fields[
'payment_amount']) &&
price2num($fields[
'ftotal_ttc'])) {
485 $ratiopaymentinvoice = ($fields[
'payment_amount'] / $fields[
'ftotal_ttc']);
491 $temp_ht = (float) $fields[
'totalht'] * $ratiopaymentinvoice;
494 $temp_vat = $fields[
'vat'] * $ratiopaymentinvoice;
496 $subtot_coll_total_ht += $temp_ht;
497 $subtot_coll_vat += $temp_vat;
498 $x_coll_sum += $temp_vat;
502 if ($invoice_type ==
'customer' && $vat_rate_show == $rate) {
503 if (is_array($x_both[$rate][
'coll'][
'detail'])) {
504 foreach ($x_both[$rate][
'coll'][
'detail'] as $index => $fields) {
520 $type = (isset($fields[
'dtype']) ? $fields[
'dtype'] : $fields[
'ptype']);
523 if (!empty($fields[
'ddate_start'])) {
526 if (!empty($fields[
'ddate_end'])) {
531 print
'<tr class="oddeven">';
534 print
'<td class="nowrap left">' . $fields[
'link'] .
'</td>';
537 print
'<td class="left">' .
dol_print_date($fields[
'datef'],
'day') .
'</td>';
541 print
'<td class="left">' .
dol_print_date($fields[
'datep'],
'day') .
'</td>';
547 print
'<td class="tdmaxoverflow150">';
549 print $fields[
'company_link'];
553 print
'<td class="left">';
554 if ($fields[
'pid']) {
555 $product_static->id = $fields[
'pid'];
556 $product_static->ref = $fields[
'pref'];
557 $product_static->type = $fields[
'dtype'];
558 print $product_static->getNomUrl(1);
564 $text =
img_object($langs->trans(
'Service'),
'service');
566 $text =
img_object($langs->trans(
'Product'),
'product');
568 if (preg_match(
'/^\((.*)\)$/', $fields[
'descr'], $reg)) {
569 if ($reg[1] ==
'DEPOSIT') {
570 $fields[
'descr'] = $langs->transnoentitiesnoconv(
'Deposit');
571 } elseif ($reg[1] ==
'CREDIT_NOTE') {
572 $fields[
'descr'] = $langs->transnoentitiesnoconv(
'CreditNote');
574 $fields[
'descr'] = $langs->transnoentitiesnoconv($reg[1]);
586 print
'<td class="nowrap right">';
587 print
price($fields[
'totalht']);
590 $ratiolineinvoice = ($fields[
'dtotal_ttc'] / $fields[
'ftotal_ttc']);
597 $ratiopaymentinvoice = 1;
599 print
'<td class="nowrap right">';
601 if ($fields[
'payment_amount'] && $fields[
'ftotal_ttc']) {
602 $payment_static->id = $fields[
'payment_id'];
603 $payment_static->ref = $fields[
'payment_ref'];
604 print $payment_static->getNomUrl(2,
'',
'', 0) .
' ';
608 print $langs->trans(
"NA");
610 if (isset($fields[
'payment_amount']) &&
price2num($fields[
'ftotal_ttc'])) {
611 $ratiopaymentinvoice = ($fields[
'payment_amount'] / $fields[
'ftotal_ttc']);
614 if (isset($fields[
'payment_amount'])) {
615 print
' (' . round($ratiopaymentinvoice * 100, 2) .
'%)';
622 print
'<td class="nowrap right">';
623 $temp_ht = (float) $fields[
'totalht'] * $ratiopaymentinvoice;
628 print
'<td class="nowrap right">';
629 $temp_vat = $fields[
'vat'] * $ratiopaymentinvoice;
642 print
'<tr class="liste_total">';
643 print
'<td colspan="4"></td>';
644 print
'<td class="right">' . $langs->trans(
"Total") .
':</td>';
646 print
'<td class="nowrap right"> </td>';
647 print
'<td class="right"> </td>';
649 print
'<td class="right"><span class="amount">' .
price(
price2num($subtot_coll_total_ht,
'MT')) .
'</span></td>';
650 print
'<td class="nowrap right"><span class="amount">' .
price(
price2num($subtot_coll_vat,
'MT')) .
'</span></td>';
654 if (count($x_coll) == 0) {
655 print
'<tr class="liste_total">';
656 print
'<td colspan="4"></td>';
657 print
'<td class="right">' . $langs->trans(
"Total") .
':</td>';
659 print
'<td class="nowrap right"> </td>';
660 print
'<td class="right"> </td>';
663 print
'<td class="nowrap right">' .
price(
price2num(0,
'MT')) .
'</td>';
668 print
'<tr><td colspan="' . ($span + 2) .
'"> </td></tr>';
671 print
'<tr class="liste_titre liste_titre_topborder">';
672 print
'<td class="left">' . $elementsup .
'</td>';
673 print
'<td class="left">' . $langs->trans(
"DateInvoice") .
'</td>';
675 print
'<td class="left">' . $langs->trans(
"DatePayment") .
'</td>';
679 print
'<td class="left">' . $namesup .
'</td>';
680 print
'<td class="left">' . $productsup .
'</td>';
682 print
'<td class="right">' . $amountsup .
'</td>';
683 print
'<td class="right">' . $langs->trans(
"Payment") .
' (' . $langs->trans(
"PercentOfInvoice") .
')</td>';
685 print
'<td class="right">' . $langs->trans(
"AmountHTVATRealPaid") .
'</td>';
686 print
'<td class="right">' . $vatsup .
'</td>';
687 print
'</tr>' .
"\n";
689 foreach (array_keys($x_paye) as $rate) {
690 $subtot_paye_total_ht = 0;
691 $subtot_paye_vat = 0;
693 if (is_array($x_both[$rate][
'paye'][
'detail'])) {
695 print
'<td class="tax_rate" colspan="' . ($span + 1) .
'">';
696 print $langs->trans(
'Rate') .
' : ' .
vatrate($rate) .
'%';
697 print
' - <a class="reposition" href="' . DOL_URL_ROOT .
'/compta/tva/quadri_detail.php?invoice_type=supplier';
698 if ($invoice_type !=
'supplier' || !GETPOSTISSET(
'vat_rate_show') ||
GETPOST(
'vat_rate_show') != $rate) {
699 print
'&vat_rate_show=' . urlencode($rate);
701 print
'&date_startyear=' . urlencode($date_start_year) .
'&date_startmonth=' . urlencode($date_start_month) .
'&date_startday=' . urlencode($date_start_day) .
'&date_endyear=' . urlencode($date_end_year) .
'&date_endmonth=' . urlencode($date_end_month) .
'&date_endday=' . urlencode($date_end_day) .
'">' .
img_picto(
'',
'chevron-down',
'class="paddingrightonly"') . $langs->trans(
'VATReportShowByRateDetails') .
'</a>';
703 print
'</tr>' .
"\n";
705 foreach ($x_both[$rate][
'paye'][
'detail'] as $index => $fields) {
708 $type = (isset($fields[
'dtype']) ? $fields[
'dtype'] : $fields[
'ptype']);
711 if (!empty($fields[
'ddate_start'])) {
714 if (!empty($fields[
'ddate_end'])) {
719 $ratiopaymentinvoice = 1;
724 if (isset($fields[
'payment_amount']) && $fields[
'ftotal_ttc']) {
725 $ratiopaymentinvoice = ($fields[
'payment_amount'] / (float) $fields[
'ftotal_ttc']);
731 $temp_ht = (float) $fields[
'totalht'] * $ratiopaymentinvoice;
734 $temp_vat = $fields[
'vat'] * $ratiopaymentinvoice;
736 $subtot_paye_total_ht += $temp_ht;
737 $subtot_paye_vat += $temp_vat;
738 $x_paye_sum += $temp_vat;
741 if ($invoice_type ==
'supplier' && $vat_rate_show == $rate) {
742 foreach ($x_both[$rate][
'paye'][
'detail'] as $index => $fields) {
758 $type = (isset($fields[
'dtype']) ? $fields[
'dtype'] : $fields[
'ptype']);
761 if (!empty($fields[
'ddate_start'])) {
764 if (!empty($fields[
'ddate_end'])) {
768 print
'<tr class="oddeven">';
771 print
'<td class="nowrap left">' . $fields[
'link'] .
'</td>';
774 print
'<td class="left">' .
dol_print_date($fields[
'datef'],
'day') .
'</td>';
778 print
'<td class="left">' .
dol_print_date($fields[
'datep'],
'day') .
'</td>';
784 print
'<td class="tdmaxoverflow150">';
786 print $fields[
'company_link'];
790 print
'<td class="left">';
791 if ($fields[
'pid']) {
792 $product_static->id = $fields[
'pid'];
793 $product_static->ref = $fields[
'pref'];
794 $product_static->type = $fields[
'dtype'];
795 print $product_static->getNomUrl(1);
801 $text =
img_object($langs->trans(
'Service'),
'service');
803 $text =
img_object($langs->trans(
'Product'),
'product');
805 if (preg_match(
'/^\((.*)\)$/', $fields[
'descr'], $reg)) {
806 if ($reg[1] ==
'DEPOSIT') {
807 $fields[
'descr'] = $langs->transnoentitiesnoconv(
'Deposit');
808 } elseif ($reg[1] ==
'CREDIT_NOTE') {
809 $fields[
'descr'] = $langs->transnoentitiesnoconv(
'CreditNote');
811 $fields[
'descr'] = $langs->transnoentitiesnoconv($reg[1]);
823 print
'<td class="nowrap right">';
824 print
price($fields[
'totalht']);
827 $ratiolineinvoice = ((float) $fields[
'dtotal_ttc'] / (
float) $fields[
'ftotal_ttc']);
834 $ratiopaymentinvoice = 1;
836 print
'<td class="nowrap right">';
837 if ($fields[
'payment_amount'] && $fields[
'ftotal_ttc']) {
838 $paymentfourn_static->id = $fields[
'payment_id'];
839 $paymentfourn_static->ref = $fields[
'payment_ref'];
840 print $paymentfourn_static->getNomUrl(2,
'',
'', 0) .
' ';
845 print $langs->trans(
"NA");
847 if (isset($fields[
'payment_amount']) && $fields[
'ftotal_ttc']) {
848 $ratiopaymentinvoice = ($fields[
'payment_amount'] / (float) $fields[
'ftotal_ttc']);
851 if (isset($fields[
'payment_amount'])) {
852 print
' (' . round($ratiopaymentinvoice * 100, 2) .
'%)';
859 print
'<td class="nowrap right">';
860 $temp_ht = (float) $fields[
'totalht'] * $ratiopaymentinvoice;
865 print
'<td class="nowrap right">';
866 $temp_vat = $fields[
'vat'] * $ratiopaymentinvoice;
880 print
'<tr class="liste_total">';
881 print
'<td colspan="4"></td>';
882 print
'<td class="right">' . $langs->trans(
"Total") .
':</td>';
884 print
'<td class="nowrap right"> </td>';
885 print
'<td class="right"> </td>';
887 print
'<td class="right"><span class="amount">' .
price(
price2num($subtot_paye_total_ht,
'MT')) .
'</span></td>';
888 print
'<td class="nowrap right"><span class="amount">' .
price(
price2num($subtot_paye_vat,
'MT')) .
'</span></td>';
892 if (count($x_paye) == 0) {
893 print
'<tr class="liste_total">';
894 print
'<td colspan="4"></td>';
895 print
'<td class="right">' . $langs->trans(
"Total") .
':</td>';
897 print
'<td class="nowrap right"> </td>';
898 print
'<td class="right"> </td>';
900 print
'<td class="right"><span class="amount">' .
price(
price2num(0,
'MT')) .
'</span></td>';
901 print
'<td class="nowrap right"><span class="amount">' .
price(
price2num(0,
'MT')) .
'</span></td>';
910 print
'<table class="noborder centpercent">';
911 $diff = $x_coll_sum - $x_paye_sum;
912 print
'<tr class="liste_total">';
913 print
'<td class="liste_total" colspan="' . $span .
'">' . $langs->trans(
"TotalToPay") . ($q ?
', ' . $langs->trans(
"Quadri") .
' ' . $q :
'') .
'</td>';
914 print
'<td class="liste_total nowrap right"><b>' .
price(
price2num($diff,
'MT')) .
"</b></td>\n";
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Class to manage Trips and Expenses.
Class to manage suppliers invoices.
Class to manage invoices.
Class to manage payments for supplier invoices.
Class to manage payments of customer invoices.
Class to manage payments of expense report.
Class to manage products or services.
Class to manage third parties objects (customers, suppliers, prospects...)
Class to manage VAT - Value-added tax (also known in French as TVA - Taxe sur la valeur ajoutée)
vatrate($rate, $addpercent=false, $info_bits=0, $usestarfornpr=0, $html=0)
Return a string with VAT rate label formatted for view output Used into pdf and HTML pages.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2, $allowothertags=array())
Show picto whatever it's its name (generic function)
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_string_nohtmltag($stringtoclean, $removelinefeed=1, $pagecodeto='UTF-8', $strip_tags=0, $removedoublespaces=1)
Clean a string from all HTML tags and entities.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $allowothertags=array())
Show a picto called object_picto (generic function)
price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code='')
Function to format a value into an amount for visual output Function used into PDF and HTML pages.
dol_now($mode='auto')
Return date for now.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
newToken()
Return the value of token currently saved into session with name 'newtoken'.
print_date_range($date_start, $date_end, $format='', $outputlangs=null)
Format output for start and end date.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_trunc($string, $size=40, $trunc='right', $stringencoding='UTF-8', $nodot=0, $display=0)
Truncate a string to a particular length adding '…' if string larger than length.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
report_header($reportname, $notused, $period, $periodlink, $description, $builddate, $exportlink='', $moreparam=array(), $calcmode='', $varlink='')
Show header of a report.
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.
tax_by_rate($type, $db, $y, $q, $date_start, $date_end, $modetax, $direction, $m=0)
Gets Tax to collect for the given year (and given quarter or month) The function gets the Tax in spli...