34require
'../../main.inc.php';
43require_once DOL_DOCUMENT_ROOT .
'/core/lib/report.lib.php';
44require_once DOL_DOCUMENT_ROOT .
'/core/lib/tax.lib.php';
45require_once DOL_DOCUMENT_ROOT .
'/core/lib/date.lib.php';
46require_once DOL_DOCUMENT_ROOT .
'/compta/tva/class/tva.class.php';
47require_once DOL_DOCUMENT_ROOT .
'/compta/localtax/class/localtax.class.php';
48require_once DOL_DOCUMENT_ROOT .
'/compta/facture/class/facture.class.php';
49require_once DOL_DOCUMENT_ROOT .
'/product/class/product.class.php';
50require_once DOL_DOCUMENT_ROOT .
'/compta/paiement/class/paiement.class.php';
51require_once DOL_DOCUMENT_ROOT .
'/fourn/class/fournisseur.facture.class.php';
52require_once DOL_DOCUMENT_ROOT .
'/fourn/class/paiementfourn.class.php';
53require_once DOL_DOCUMENT_ROOT .
'/expensereport/class/expensereport.class.php';
54require_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';
77@phan-var-force int $date_start
78@phan-var-force int $date_end
79@phan-var-force int $date_start_month
80@phan-var-force int $date_start_year
81@phan-var-force int $date_start_day
82@phan-var-force int $date_end_month
83@phan-var-force int $date_end_year
84@phan-var-force int $date_end_day
85@phan-var-force int $year_current
96if (GETPOSTISSET(
"modetax")) {
108 $socid = $user->socid;
127$morequerystring =
'';
128$listofparams = array(
'date_startmonth',
'date_startyear',
'date_startday',
'date_endmonth',
'date_endyear',
'date_endday');
129foreach ($listofparams as $param) {
131 $morequerystring .= ($morequerystring ?
'&' :
'') . $param .
'=' .
GETPOST($param);
136llxHeader(
'', $title,
'',
'', 0, 0,
'',
'', $morequerystring);
142$fsearch =
'<!-- hidden fields for form -->';
143$fsearch .=
'<input type="hidden" name="token" value="' . newToken() .
'">';
144$fsearch .=
'<input type="hidden" name="modetax" value="' . $modetax .
'">';
150$name = $langs->trans(
"VATReportByRates");
153 $calcmode = $langs->trans(
'OptionVATDefault');
156 $calcmode = $langs->trans(
'OptionVATDebitOption');
159 $calcmode = $langs->trans(
'OptionPaymentForProductAndServices');
161$calcmode .=
' <span class="opacitymedium">(' . $langs->trans(
"TaxModuleSetupToModifyRules", DOL_URL_ROOT .
'/admin/taxes.php') .
')</span>';
163$period = $form->selectDate(
$date_start,
'date_start', 0, 0, 0,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'',
'',
'tzserver');
165$period .= $form->selectDate($date_end,
'date_end', 0, 0, 0,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'',
'',
'tzserver');
167$description = $fsearch;
171 $description .= $langs->trans(
"RulesVATDueProducts");
174 $description .= $langs->trans(
"RulesVATInProducts");
177 $description .=
'<br>' . $langs->trans(
"RulesVATDueServices");
180 $description .=
'<br>' . $langs->trans(
"RulesVATInServices");
184 $description .=
'<br>' . $langs->trans(
"DepositsAreNotIncluded");
186 $description .=
'<br>' . $langs->trans(
"DepositsAreNotIncluded").
' (for services)';
188 $description .=
'<br>' . $langs->trans(
"DepositsAreNotIncluded").
' (for products)';
193 $description .=
'<br>' . $langs->trans(
"SupplierDepositsAreNotIncluded");
195 $description .=
'<br>' . $langs->trans(
"SupplierDepositsAreNotIncluded").
' (for services)';
197 $description .=
'<br>' . $langs->trans(
"SupplierDepositsAreNotIncluded").
' (for products)';
201 $description .=
'<br>' . $langs->trans(
"ThisIsAnEstimatedValue");
205$elementcust = $langs->trans(
"CustomersInvoices");
206$productcust = $langs->trans(
"ProductOrService");
207$amountcust = $langs->trans(
"AmountHT");
208$vatcust = $langs->trans(
"VATReceived");
209$namecust = $langs->trans(
"Name");
211 $vatcust .=
' (' . $langs->trans(
"VATToPay") .
')';
215$elementsup = $langs->trans(
"SuppliersInvoices");
216$productsup = $productcust;
217$amountsup = $amountcust;
218$vatsup = $langs->trans(
"VATPaid");
221 $vatsup .=
' (' . $langs->trans(
"ToGetBack") .
')';
224$optioncss =
GETPOST(
'optioncss',
'alpha');
228if ($optioncss !=
"print") {
229 report_header($name,
'', $period, $periodlink, $description, $builddate, $exportlink, array(), $calcmode);
232$vatcust = $langs->trans(
"VATReceived");
233$vatsup = $langs->trans(
"VATPaid");
234$vatexpensereport = $langs->trans(
"VATPaid");
236print
'<div class="right nowrap">';
239$url_params = preg_replace(
'/&?showall=1/',
'',
dol_escape_htmltag($_SERVER[
'QUERY_STRING']));
240$url_collapse = $_SERVER[
'PHP_SELF'].
'?'.$url_params;
241$url_expand = $_SERVER[
'PHP_SELF'].
'?'.$url_params.
'&showall=1';
244print
'<a class="showallperms" title="'.dol_escape_htmltag($langs->trans(
"ShowAllPerms")).
'" href="'.$url_expand.
'">';
245print
img_picto($langs->trans(
"ExpandAll"),
'folder-open',
'class="paddingright"');
246print
'<span class="hideonsmartphone">'.$langs->trans(
"ExpandAll").
'</span>';
252print
'<a class="hideallperms" title="'.dol_escape_htmltag($langs->trans(
"HideAllPerms")).
'" href="'.$url_collapse.
'">';
253print
img_picto($langs->trans(
"UndoExpandAll"),
'folder',
'class="paddingright"');
254print
'<span class="hideonsmartphone">'.$langs->trans(
"UndoExpandAll").
'</span>';
258print
'<div class="clearboth"></div>';
261print
'<div class="div-table-responsive">';
262print
'<table class="liste noborder centpercent">';
277if (!is_array($x_coll) || !is_array($x_paye)) {
278 $langs->load(
"errors");
280 print
'<tr><td colspan="' . $columns .
'">' . $langs->trans(
"ErrorNoAccountancyModuleLoaded") .
'</td></tr>';
281 } elseif ($x_coll == -2) {
282 print
'<tr><td colspan="' . $columns .
'">' . $langs->trans(
"FeatureNotYetAvailable") .
'</td></tr>';
284 print
'<tr><td colspan="' . $columns .
'">' . $langs->trans(
"Error") .
'</td></tr>';
289 foreach (array_keys($x_coll) as $my_coll_rate) {
290 $x_both[$my_coll_rate] = array(
294 $x_both[$my_coll_rate][
'coll'][
'totalht'] = $x_coll[$my_coll_rate][
'totalht'];
295 $x_both[$my_coll_rate][
'coll'][
'vat'] = $x_coll[$my_coll_rate][
'vat'];
296 $x_both[$my_coll_rate][
'paye'][
'totalht'] = 0;
297 $x_both[$my_coll_rate][
'paye'][
'vat'] = 0;
298 $x_both[$my_coll_rate][
'coll'][
'links'] =
'';
299 $x_both[$my_coll_rate][
'coll'][
'detail'] = array();
300 foreach ($x_coll[$my_coll_rate][
'facid'] as
$id => $dummy) {
301 $invoice_customer->id = $x_coll[$my_coll_rate][
'facid'][
$id];
302 $invoice_customer->ref = $x_coll[$my_coll_rate][
'facnum'][
$id];
303 $invoice_customer->type = $x_coll[$my_coll_rate][
'type'][
$id];
306 $company_static->id = $x_coll[$my_coll_rate][
'company_id'][
$id];
307 $company_static->name = $x_coll[$my_coll_rate][
'company_name'][
$id];
308 $company_static->name_alias = $x_coll[$my_coll_rate][
'company_alias'][
$id];
309 $company_static->email = $x_coll[$my_coll_rate][
'company_email'][
$id];
310 $company_static->tva_intra = isset($x_coll[$my_coll_rate][
'company_tva_intra'][
$id]) ? $x_coll[$my_coll_rate][
'company_tva_intra'][
$id] :
'0';
311 $company_static->client = $x_coll[$my_coll_rate][
'company_client'][
$id];
312 $company_static->fournisseur = $x_coll[$my_coll_rate][
'company_fournisseur'][
$id];
313 $company_static->status = $x_coll[$my_coll_rate][
'company_status'][
$id];
314 $company_static->code_client = $x_coll[$my_coll_rate][
'company_customer_code'][
$id];
315 $company_static->code_compta_client = $x_coll[$my_coll_rate][
'company_customer_accounting_code'][
$id];
316 $company_static->code_fournisseur = $x_coll[$my_coll_rate][
'company_supplier_code'][
$id];
317 $company_static->code_compta_fournisseur = $x_coll[$my_coll_rate][
'company_supplier_accounting_code'][
$id];
319 $x_both[$my_coll_rate][
'coll'][
'detail'][] = array(
320 'id' => $x_coll[$my_coll_rate][
'facid'][
$id],
321 'descr' => $x_coll[$my_coll_rate][
'descr'][
$id],
322 'pid' => $x_coll[$my_coll_rate][
'pid'][
$id],
323 'pref' => $x_coll[$my_coll_rate][
'pref'][
$id],
324 'ptype' => $x_coll[$my_coll_rate][
'ptype'][
$id],
325 'payment_id' => $x_coll[$my_coll_rate][
'payment_id'][
$id],
326 'payment_ref' => $x_coll[$my_coll_rate][
'payment_ref'][
$id],
327 'payment_amount' => $x_coll[$my_coll_rate][
'payment_amount'][
$id],
328 'ftotal_ttc' => $x_coll[$my_coll_rate][
'ftotal_ttc'][
$id],
329 'dtotal_ttc' => $x_coll[$my_coll_rate][
'dtotal_ttc'][
$id],
330 'dtype' => $x_coll[$my_coll_rate][
'dtype'][
$id],
331 'datef' => $x_coll[$my_coll_rate][
'datef'][
$id],
332 'datep' => $x_coll[$my_coll_rate][
'datep'][
$id],
334 'company_link' => $company_static->getNomUrl(1,
'', 20),
336 'ddate_start' => $x_coll[$my_coll_rate][
'ddate_start'][
$id],
337 'ddate_end' => $x_coll[$my_coll_rate][
'ddate_end'][
$id],
338 'totalht' => $x_coll[$my_coll_rate][
'totalht_list'][
$id],
339 'vat' => $x_coll[$my_coll_rate][
'vat_list'][
$id],
340 'link' => $invoice_customer->getNomUrl(1,
'', 12)
345 foreach (array_keys($x_paye) as $my_paye_rate) {
346 $x_both[$my_paye_rate][
'paye'][
'totalht'] = $x_paye[$my_paye_rate][
'totalht'];
347 $x_both[$my_paye_rate][
'paye'][
'vat'] = $x_paye[$my_paye_rate][
'vat'];
348 if (!isset($x_both[$my_paye_rate][
'coll'][
'totalht'])) {
349 $x_both[$my_paye_rate][
'coll'][
'totalht'] = 0;
350 $x_both[$my_paye_rate][
'coll'][
'vat'] = 0;
352 $x_both[$my_paye_rate][
'paye'][
'links'] =
'';
353 $x_both[$my_paye_rate][
'paye'][
'detail'] = array();
355 foreach ($x_paye[$my_paye_rate][
'facid'] as
$id => $dummy) {
357 if ($x_paye[$my_paye_rate][
'ptype'][
$id] ===
'ExpenseReportPayment') {
358 $expensereport->id = $x_paye[$my_paye_rate][
'facid'][
$id];
359 $expensereport->ref = $x_paye[$my_paye_rate][
'facnum'][
$id];
360 $expensereport->type = $x_paye[$my_paye_rate][
'type'][
$id];
362 $x_both[$my_paye_rate][
'paye'][
'detail'][] = array(
363 'id' => $x_paye[$my_paye_rate][
'facid'][
$id],
364 'descr' => $x_paye[$my_paye_rate][
'descr'][
$id],
365 'pid' => $x_paye[$my_paye_rate][
'pid'][
$id],
366 'pref' => $x_paye[$my_paye_rate][
'pref'][
$id],
367 'ptype' => $x_paye[$my_paye_rate][
'ptype'][
$id],
368 'payment_id' => $x_paye[$my_paye_rate][
'payment_id'][
$id],
369 'payment_ref' => $x_paye[$my_paye_rate][
'payment_ref'][
$id],
370 'payment_amount' => $x_paye[$my_paye_rate][
'payment_amount'][
$id],
371 'ftotal_ttc' =>
price2num($x_paye[$my_paye_rate][
'ftotal_ttc'][
$id]),
372 'dtotal_ttc' =>
price2num($x_paye[$my_paye_rate][
'dtotal_ttc'][
$id]),
373 'dtype' => $x_paye[$my_paye_rate][
'dtype'][
$id],
374 'ddate_start' => $x_paye[$my_paye_rate][
'ddate_start'][
$id],
375 'ddate_end' => $x_paye[$my_paye_rate][
'ddate_end'][
$id],
376 'totalht' =>
price2num($x_paye[$my_paye_rate][
'totalht_list'][
$id]),
377 'vat' => $x_paye[$my_paye_rate][
'vat_list'][
$id],
378 'link' => $expensereport->getNomUrl(1)
381 $invoice_supplier->id = $x_paye[$my_paye_rate][
'facid'][
$id];
382 $invoice_supplier->ref = $x_paye[$my_paye_rate][
'facnum'][
$id];
383 $invoice_supplier->type = $x_paye[$my_paye_rate][
'type'][
$id];
385 $company_static->id = $x_paye[$my_paye_rate][
'company_id'][
$id];
386 $company_static->name = $x_paye[$my_paye_rate][
'company_name'][
$id];
387 $company_static->name_alias = $x_paye[$my_paye_rate][
'company_alias'][
$id];
388 $company_static->email = $x_paye[$my_paye_rate][
'company_email'][
$id];
389 $company_static->tva_intra = $x_paye[$my_paye_rate][
'company_tva_intra'][
$id];
390 $company_static->client = $x_paye[$my_paye_rate][
'company_client'][
$id];
391 $company_static->fournisseur = $x_paye[$my_paye_rate][
'company_fournisseur'][
$id];
392 $company_static->status = $x_paye[$my_paye_rate][
'company_status'][
$id];
393 $company_static->code_client = $x_paye[$my_paye_rate][
'company_customer_code'][
$id];
394 $company_static->code_compta_client = $x_paye[$my_paye_rate][
'company_customer_accounting_code'][
$id];
395 $company_static->code_fournisseur = $x_paye[$my_paye_rate][
'company_supplier_code'][
$id];
396 $company_static->code_compta_fournisseur = $x_paye[$my_paye_rate][
'company_supplier_accounting_code'][
$id];
398 $x_both[$my_paye_rate][
'paye'][
'detail'][] = array(
399 'id' => $x_paye[$my_paye_rate][
'facid'][
$id],
400 'descr' => $x_paye[$my_paye_rate][
'descr'][
$id],
401 'pid' => $x_paye[$my_paye_rate][
'pid'][
$id],
402 'pref' => $x_paye[$my_paye_rate][
'pref'][
$id],
403 'ptype' => $x_paye[$my_paye_rate][
'ptype'][
$id],
404 'payment_id' => $x_paye[$my_paye_rate][
'payment_id'][
$id],
405 'payment_ref' => $x_paye[$my_paye_rate][
'payment_ref'][
$id],
406 'payment_amount' => $x_paye[$my_paye_rate][
'payment_amount'][
$id],
407 'ftotal_ttc' =>
price2num($x_paye[$my_paye_rate][
'ftotal_ttc'][
$id]),
408 'dtotal_ttc' =>
price2num($x_paye[$my_paye_rate][
'dtotal_ttc'][
$id]),
409 'dtype' => $x_paye[$my_paye_rate][
'dtype'][
$id],
410 'datef' => $x_paye[$my_paye_rate][
'datef'][
$id],
411 'datep' => $x_paye[$my_paye_rate][
'datep'][
$id],
413 'company_link' => $company_static->getNomUrl(1,
'', 20),
415 'ddate_start' => $x_paye[$my_paye_rate][
'ddate_start'][
$id],
416 'ddate_end' => $x_paye[$my_paye_rate][
'ddate_end'][
$id],
417 'totalht' =>
price2num($x_paye[$my_paye_rate][
'totalht_list'][
$id]),
418 'vat' => $x_paye[$my_paye_rate][
'vat_list'][
$id],
419 'link' => $invoice_supplier->getNomUrl(1,
'', 12)
437 print
'<tr class="liste_titre">';
438 print
'<td class="left">' . $elementcust .
'</td>';
439 print
'<td class="left">' . $langs->trans(
"DateInvoice") .
'</td>';
441 print
'<td class="left">' . $langs->trans(
"DatePayment") .
'</td>';
445 print
'<td class="left">' . $namecust .
'</td>';
446 print
'<td class="left">' . $productcust .
'</td>';
448 print
'<td class="right">' . $amountcust .
'</td>';
449 print
'<td class="right">' . $langs->trans(
"Payment") .
' (' . $langs->trans(
"PercentOfInvoice") .
')</td>';
451 print
'<td class="right">' . $langs->trans(
"AmountHTVATRealReceived") .
'</td>';
452 print
'<td class="right">' . $vatcust .
'</td>';
455 $action =
"tvadetail";
456 $parameters = array();
457 $parameters[
"mode"] = $modetax;
459 $parameters[
"end"] = $date_end;
460 $parameters[
"type"] =
'vat';
462 $object = array(&$x_coll, &$x_paye, &$x_both);
464 $hookmanager->initHooks(array(
'externalbalance'));
465 $reshook = $hookmanager->executeHooks(
'addVatLine', $parameters, $object, $action);
467 foreach (array_keys($x_coll) as $rate) {
468 $subtot_coll_total_ht = 0;
469 $subtot_coll_vat = 0;
471 if (is_array($x_both[$rate][
'coll'][
'detail'])) {
474 print
'<td class="tax_rate" colspan="' . ($span + 1) .
'">';
475 print $langs->trans(
'Rate') .
' : ' .
vatrate($rate) .
'%';
476 print
' - <a class="reposition" href="' . DOL_URL_ROOT .
'/compta/tva/quadri_detail.php?invoice_type=customer';
477 if ($invoice_type !=
'customer' || !GETPOSTISSET(
'vat_rate_show') ||
GETPOST(
'vat_rate_show') != $rate) {
478 print
'&vat_rate_show=' . urlencode($rate);
480 print
'&date_startyear=' . ((int) $date_start_year) .
'&date_startmonth=' . ((int) $date_start_month) .
'&date_startday=' . ((int) $date_start_day) .
'&date_endyear=' . ((int) $date_end_year) .
'&date_endmonth=' . ((int) $date_end_month) .
'&date_endday=' . ((int) $date_end_day) .
'">';
481 print
img_picto(
'',
'chevron-down',
'class="paddingrightonly"') . $langs->trans(
'VATReportShowByRateDetails') .
'</a>';
483 print
'</tr>' .
"\n";
485 foreach ($x_both[$rate][
'coll'][
'detail'] as $index => $fields) {
488 $type = (isset($fields[
'dtype']) ? $fields[
'dtype'] : $fields[
'ptype']);
490 if (!empty($fields[
'ddate_start'])) {
493 if (!empty($fields[
'ddate_end'])) {
498 $ratiopaymentinvoice = 1;
503 if (isset($fields[
'payment_amount']) &&
price2num($fields[
'ftotal_ttc'])) {
504 $ratiopaymentinvoice = ($fields[
'payment_amount'] / $fields[
'ftotal_ttc']);
510 $temp_ht = (float) $fields[
'totalht'] * $ratiopaymentinvoice;
513 $temp_vat = $fields[
'vat'] * $ratiopaymentinvoice;
515 $subtot_coll_total_ht += $temp_ht;
516 $subtot_coll_vat += $temp_vat;
517 $x_coll_sum += $temp_vat;
521 if (
GETPOST(
'showall',
'int') == 1 || ($invoice_type ==
'customer' && $vat_rate_show == $rate)) {
522 if (is_array($x_both[$rate][
'coll'][
'detail'])) {
523 foreach ($x_both[$rate][
'coll'][
'detail'] as $index => $fields) {
539 $type = (isset($fields[
'dtype']) ? $fields[
'dtype'] : $fields[
'ptype']);
541 if (!empty($fields[
'ddate_start'])) {
544 if (!empty($fields[
'ddate_end'])) {
549 print
'<tr class="oddeven">';
552 print
'<td class="nowrap left">' . $fields[
'link'] .
'</td>';
555 print
'<td class="left">' .
dol_print_date($fields[
'datef'],
'day') .
'</td>';
559 print
'<td class="left">' .
dol_print_date($fields[
'datep'],
'day') .
'</td>';
565 print
'<td class="tdoverflowmax150">';
567 print $fields[
'company_link'];
571 print
'<td class="left">';
572 if ($fields[
'pid']) {
573 $product_static->id = $fields[
'pid'];
574 $product_static->ref = $fields[
'pref'];
575 $product_static->type = $fields[
'dtype'];
576 print $product_static->getNomUrl(1);
582 $text =
img_object($langs->trans(
'Service'),
'service');
584 $text =
img_object($langs->trans(
'Product'),
'product');
586 if (preg_match(
'/^\((.*)\)$/', $fields[
'descr'], $reg)) {
587 if ($reg[1] ==
'DEPOSIT') {
588 $fields[
'descr'] = $langs->transnoentitiesnoconv(
'Deposit');
589 } elseif ($reg[1] ==
'CREDIT_NOTE') {
590 $fields[
'descr'] = $langs->transnoentitiesnoconv(
'CreditNote');
592 $fields[
'descr'] = $langs->transnoentitiesnoconv($reg[1]);
604 print
'<td class="nowrap right">';
605 print
price($fields[
'totalht']);
608 $ratiolineinvoice = ($fields[
'dtotal_ttc'] / $fields[
'ftotal_ttc']);
615 $ratiopaymentinvoice = 1;
617 print
'<td class="nowrap right">';
619 if ($fields[
'payment_amount'] && $fields[
'ftotal_ttc']) {
620 $payment_static->id = $fields[
'payment_id'];
621 $payment_static->ref = $fields[
'payment_ref'];
622 print $payment_static->getNomUrl(2,
'',
'', 0) .
' ';
626 print $langs->trans(
"NA");
628 if (isset($fields[
'payment_amount']) &&
price2num($fields[
'ftotal_ttc'])) {
629 $ratiopaymentinvoice = ($fields[
'payment_amount'] / $fields[
'ftotal_ttc']);
632 if (isset($fields[
'payment_amount'])) {
633 print
' (' . round($ratiopaymentinvoice * 100, 2) .
'%)';
640 print
'<td class="nowrap right">';
641 $temp_ht = (float) $fields[
'totalht'] * $ratiopaymentinvoice;
646 print
'<td class="nowrap right">';
647 $temp_vat = $fields[
'vat'] * $ratiopaymentinvoice;
660 print
'<tr class="liste_total">';
661 print
'<td colspan="4"></td>';
662 print
'<td class="right">' . $langs->trans(
"Total") .
':</td>';
664 print
'<td class="nowrap right"> </td>';
665 print
'<td class="right"> </td>';
667 print
'<td class="right"><span class="amount">' .
price(
price2num($subtot_coll_total_ht,
'MT')) .
'</span></td>';
668 print
'<td class="nowrap right"><span class="amount">' .
price(
price2num($subtot_coll_vat,
'MT')) .
'</span></td>';
672 if (count($x_coll) == 0) {
673 print
'<tr class="liste_total">';
674 print
'<td colspan="4"></td>';
675 print
'<td class="right">' . $langs->trans(
"Total") .
':</td>';
677 print
'<td class="nowrap right"> </td>';
678 print
'<td class="right"> </td>';
681 print
'<td class="nowrap right">' .
price(
price2num(0,
'MT')) .
'</td>';
686 print
'<tr><td colspan="' . ($span + 2) .
'"> </td></tr>';
689 print
'<tr class="liste_titre liste_titre_topborder">';
690 print
'<td class="left">' . $elementsup .
'</td>';
691 print
'<td class="left">' . $langs->trans(
"DateInvoice") .
'</td>';
693 print
'<td class="left">' . $langs->trans(
"DatePayment") .
'</td>';
697 print
'<td class="left">' . $namesup .
'</td>';
698 print
'<td class="left">' . $productsup .
'</td>';
700 print
'<td class="right">' . $amountsup .
'</td>';
701 print
'<td class="right">' . $langs->trans(
"Payment") .
' (' . $langs->trans(
"PercentOfInvoice") .
')</td>';
703 print
'<td class="right">' . $langs->trans(
"AmountHTVATRealPaid") .
'</td>';
704 print
'<td class="right">' . $vatsup .
'</td>';
705 print
'</tr>' .
"\n";
707 foreach (array_keys($x_paye) as $rate) {
708 $subtot_paye_total_ht = 0;
709 $subtot_paye_vat = 0;
711 if (is_array($x_both[$rate][
'paye'][
'detail'])) {
713 print
'<td class="tax_rate" colspan="' . ($span + 1) .
'">';
714 print $langs->trans(
'Rate') .
' : ' .
vatrate($rate) .
'%';
715 print
' - <a class="reposition" href="' . DOL_URL_ROOT .
'/compta/tva/quadri_detail.php?invoice_type=supplier';
716 if ($invoice_type !=
'supplier' || !GETPOSTISSET(
'vat_rate_show') ||
GETPOST(
'vat_rate_show') != $rate) {
717 print
'&vat_rate_show=' . urlencode($rate);
719 print
'&date_startyear=' . ((int) $date_start_year) .
'&date_startmonth=' . ((int) $date_start_month) .
'&date_startday=' . ((int) $date_start_day) .
'&date_endyear=' . ((int) $date_end_year) .
'&date_endmonth=' . ((int) $date_end_month) .
'&date_endday=' . ((int) $date_end_day) .
'">';
720 print
img_picto(
'',
'chevron-down',
'class="paddingrightonly"') . $langs->trans(
'VATReportShowByRateDetails') .
'</a>';
722 print
'</tr>' .
"\n";
724 foreach ($x_both[$rate][
'paye'][
'detail'] as $index => $fields) {
727 $type = (isset($fields[
'dtype']) ? $fields[
'dtype'] : $fields[
'ptype']);
729 if (!empty($fields[
'ddate_start'])) {
732 if (!empty($fields[
'ddate_end'])) {
737 $ratiopaymentinvoice = 1;
742 if (isset($fields[
'payment_amount']) && $fields[
'ftotal_ttc']) {
743 $ratiopaymentinvoice = ($fields[
'payment_amount'] / (float) $fields[
'ftotal_ttc']);
749 $temp_ht = (float) $fields[
'totalht'] * $ratiopaymentinvoice;
752 $temp_vat = $fields[
'vat'] * $ratiopaymentinvoice;
754 $subtot_paye_total_ht += $temp_ht;
755 $subtot_paye_vat += $temp_vat;
756 $x_paye_sum += $temp_vat;
759 if (
GETPOST(
'showall',
'int') == 1 || ($invoice_type ==
'supplier' && $vat_rate_show == $rate)) {
760 foreach ($x_both[$rate][
'paye'][
'detail'] as $index => $fields) {
776 $type = (isset($fields[
'dtype']) ? $fields[
'dtype'] : $fields[
'ptype']);
778 if (!empty($fields[
'ddate_start'])) {
781 if (!empty($fields[
'ddate_end'])) {
785 print
'<tr class="oddeven">';
788 print
'<td class="nowrap left">' . $fields[
'link'] .
'</td>';
791 print
'<td class="left">' .
dol_print_date($fields[
'datef'],
'day') .
'</td>';
795 print
'<td class="left">' .
dol_print_date($fields[
'datep'],
'day') .
'</td>';
801 print
'<td class="tdoverflowmax150">';
803 print $fields[
'company_link'];
807 print
'<td class="left">';
808 if ($fields[
'pid']) {
809 $product_static->id = $fields[
'pid'];
810 $product_static->ref = $fields[
'pref'];
811 $product_static->type = $fields[
'dtype'];
812 print $product_static->getNomUrl(1);
818 $text =
img_object($langs->trans(
'Service'),
'service');
820 $text =
img_object($langs->trans(
'Product'),
'product');
822 if (preg_match(
'/^\((.*)\)$/', $fields[
'descr'], $reg)) {
823 if ($reg[1] ==
'DEPOSIT') {
824 $fields[
'descr'] = $langs->transnoentitiesnoconv(
'Deposit');
825 } elseif ($reg[1] ==
'CREDIT_NOTE') {
826 $fields[
'descr'] = $langs->transnoentitiesnoconv(
'CreditNote');
828 $fields[
'descr'] = $langs->transnoentitiesnoconv($reg[1]);
840 print
'<td class="nowrap right">';
841 print
price($fields[
'totalht']);
844 $ratiolineinvoice = ((float) $fields[
'dtotal_ttc'] / (
float) $fields[
'ftotal_ttc']);
851 $ratiopaymentinvoice = 1;
853 print
'<td class="nowrap right">';
854 if ($fields[
'payment_amount'] && $fields[
'ftotal_ttc']) {
855 $paymentfourn_static->id = $fields[
'payment_id'];
856 $paymentfourn_static->ref = $fields[
'payment_ref'];
857 print $paymentfourn_static->getNomUrl(2,
'',
'', 0) .
' ';
862 print $langs->trans(
"NA");
864 if (isset($fields[
'payment_amount']) && $fields[
'ftotal_ttc']) {
865 $ratiopaymentinvoice = ($fields[
'payment_amount'] / (float) $fields[
'ftotal_ttc']);
868 if (isset($fields[
'payment_amount'])) {
869 print
' (' . round($ratiopaymentinvoice * 100, 2) .
'%)';
876 print
'<td class="nowrap right">';
877 $temp_ht = (float) $fields[
'totalht'] * $ratiopaymentinvoice;
882 print
'<td class="nowrap right">';
883 $temp_vat = $fields[
'vat'] * $ratiopaymentinvoice;
897 print
'<tr class="liste_total">';
898 print
'<td colspan="4"></td>';
899 print
'<td class="right">' . $langs->trans(
"Total") .
':</td>';
901 print
'<td class="nowrap right"> </td>';
902 print
'<td class="right"> </td>';
904 print
'<td class="right"><span class="amount">' .
price(
price2num($subtot_paye_total_ht,
'MT')) .
'</span></td>';
905 print
'<td class="nowrap right"><span class="amount">' .
price(
price2num($subtot_paye_vat,
'MT')) .
'</span></td>';
909 if (count($x_paye) == 0) {
910 print
'<tr class="liste_total">';
911 print
'<td colspan="4"></td>';
912 print
'<td class="right">' . $langs->trans(
"Total") .
':</td>';
914 print
'<td class="nowrap right"> </td>';
915 print
'<td class="right"> </td>';
917 print
'<td class="right"><span class="amount">' .
price(
price2num(0,
'MT')) .
'</span></td>';
918 print
'<td class="nowrap right"><span class="amount">' .
price(
price2num(0,
'MT')) .
'</span></td>';
927 print
'<table class="noborder centpercent">';
928 $diff = $x_coll_sum - $x_paye_sum;
929 print
'<tr class="liste_total">';
930 print
'<td class="liste_total" colspan="' . $span .
'">' . $langs->trans(
"TotalToPay") .
'</td>';
931 print
'<td class="liste_total nowrap right"><b>' .
price(
price2num($diff,
'MT')) .
"</b></td>\n";
$id
Support class for third parties, contacts, members, users or resources.
if(! $sortfield) if(! $sortorder) $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)
$date_start
Variables from include:
dol_now($mode='gmt')
Return date for now.
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.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
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_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false, $decorate=0)
Output date in a string format according to outputlangs (or langs if not defined).
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.
isModEnabled($module)
Is Dolibarr module enabled.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
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...