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");
188 $description .=
'<br>' . $langs->trans(
"DepositsAreNotIncluded");
191 $description .= $langs->trans(
"SupplierDepositsAreNotIncluded");
193if (isModEnabled(
'accounting')) {
194 $description .=
'<br>' . $langs->trans(
"ThisIsAnEstimatedValue");
198$elementcust = $langs->trans(
"CustomersInvoices");
199$productcust = $langs->trans(
"ProductOrService");
200$amountcust = $langs->trans(
"AmountHT");
201$vatcust = $langs->trans(
"VATReceived");
202$namecust = $langs->trans(
"Name");
203if ($mysoc->tva_assuj) {
204 $vatcust .=
' (' . $langs->trans(
"VATToPay") .
')';
208$elementsup = $langs->trans(
"SuppliersInvoices");
209$productsup = $productcust;
210$amountsup = $amountcust;
211$vatsup = $langs->trans(
"VATPaid");
213if ($mysoc->tva_assuj) {
214 $vatsup .=
' (' . $langs->trans(
"ToGetBack") .
')';
217$optioncss =
GETPOST(
'optioncss',
'alpha');
221if ($optioncss !=
"print") {
222 report_header($name,
'', $period, $periodlink, $description, $builddate, $exportlink, array(), $calcmode);
225$vatcust = $langs->trans(
"VATReceived");
226$vatsup = $langs->trans(
"VATPaid");
227$vatexpensereport = $langs->trans(
"VATPaid");
231print
'<div class="div-table-responsive">';
232print
'<table class="liste noborder centpercent">';
244$x_coll =
tax_by_rate(
'vat', $db, 0, 0, $date_start, $date_end, $modetax,
'sell');
245$x_paye =
tax_by_rate(
'vat', $db, 0, 0, $date_start, $date_end, $modetax,
'buy');
247if (!is_array($x_coll) || !is_array($x_paye)) {
248 $langs->load(
"errors");
250 print
'<tr><td colspan="' . $columns .
'">' . $langs->trans(
"ErrorNoAccountancyModuleLoaded") .
'</td></tr>';
251 } elseif ($x_coll == -2) {
252 print
'<tr><td colspan="' . $columns .
'">' . $langs->trans(
"FeatureNotYetAvailable") .
'</td></tr>';
254 print
'<tr><td colspan="' . $columns .
'">' . $langs->trans(
"Error") .
'</td></tr>';
259 foreach (array_keys($x_coll) as $my_coll_rate) {
260 $x_both[$my_coll_rate] = array(
264 $x_both[$my_coll_rate][
'coll'][
'totalht'] = $x_coll[$my_coll_rate][
'totalht'];
265 $x_both[$my_coll_rate][
'coll'][
'vat'] = $x_coll[$my_coll_rate][
'vat'];
266 $x_both[$my_coll_rate][
'paye'][
'totalht'] = 0;
267 $x_both[$my_coll_rate][
'paye'][
'vat'] = 0;
268 $x_both[$my_coll_rate][
'coll'][
'links'] =
'';
269 $x_both[$my_coll_rate][
'coll'][
'detail'] = array();
270 foreach ($x_coll[$my_coll_rate][
'facid'] as
$id => $dummy) {
271 $invoice_customer->id = $x_coll[$my_coll_rate][
'facid'][
$id];
272 $invoice_customer->ref = $x_coll[$my_coll_rate][
'facnum'][
$id];
273 $invoice_customer->type = $x_coll[$my_coll_rate][
'type'][
$id];
276 $company_static->id = $x_coll[$my_coll_rate][
'company_id'][
$id];
277 $company_static->name = $x_coll[$my_coll_rate][
'company_name'][
$id];
278 $company_static->name_alias = $x_coll[$my_coll_rate][
'company_alias'][
$id];
279 $company_static->email = $x_coll[$my_coll_rate][
'company_email'][
$id];
280 $company_static->tva_intra = isset($x_coll[$my_coll_rate][
'tva_intra'][
$id]) ? $x_coll[$my_coll_rate][
'tva_intra'][
$id] :
'0';
281 $company_static->client = $x_coll[$my_coll_rate][
'company_client'][
$id];
282 $company_static->fournisseur = $x_coll[$my_coll_rate][
'company_fournisseur'][
$id];
283 $company_static->status = $x_coll[$my_coll_rate][
'company_status'][
$id];
284 $company_static->code_client = $x_coll[$my_coll_rate][
'company_customer_code'][
$id];
285 $company_static->code_compta_client = $x_coll[$my_coll_rate][
'company_customer_accounting_code'][
$id];
286 $company_static->code_fournisseur = $x_coll[$my_coll_rate][
'company_supplier_code'][
$id];
287 $company_static->code_compta_fournisseur = $x_coll[$my_coll_rate][
'company_supplier_accounting_code'][
$id];
289 $x_both[$my_coll_rate][
'coll'][
'detail'][] = array(
290 'id' => $x_coll[$my_coll_rate][
'facid'][
$id],
291 'descr' => $x_coll[$my_coll_rate][
'descr'][
$id],
292 'pid' => $x_coll[$my_coll_rate][
'pid'][
$id],
293 'pref' => $x_coll[$my_coll_rate][
'pref'][
$id],
294 'ptype' => $x_coll[$my_coll_rate][
'ptype'][
$id],
295 'payment_id' => $x_coll[$my_coll_rate][
'payment_id'][
$id],
296 'payment_ref' => $x_coll[$my_coll_rate][
'payment_ref'][
$id],
297 'payment_amount' => $x_coll[$my_coll_rate][
'payment_amount'][
$id],
298 'ftotal_ttc' => $x_coll[$my_coll_rate][
'ftotal_ttc'][
$id],
299 'dtotal_ttc' => $x_coll[$my_coll_rate][
'dtotal_ttc'][
$id],
300 'dtype' => $x_coll[$my_coll_rate][
'dtype'][
$id],
301 'datef' => $x_coll[$my_coll_rate][
'datef'][
$id],
302 'datep' => $x_coll[$my_coll_rate][
'datep'][
$id],
304 'company_link' => $company_static->getNomUrl(1,
'', 20),
306 'ddate_start' => $x_coll[$my_coll_rate][
'ddate_start'][
$id],
307 'ddate_end' => $x_coll[$my_coll_rate][
'ddate_end'][
$id],
308 'totalht' => $x_coll[$my_coll_rate][
'totalht_list'][
$id],
309 'vat' => $x_coll[$my_coll_rate][
'vat_list'][
$id],
310 'link' => $invoice_customer->getNomUrl(1,
'', 12)
315 foreach (array_keys($x_paye) as $my_paye_rate) {
316 $x_both[$my_paye_rate][
'paye'][
'totalht'] = $x_paye[$my_paye_rate][
'totalht'];
317 $x_both[$my_paye_rate][
'paye'][
'vat'] = $x_paye[$my_paye_rate][
'vat'];
318 if (!isset($x_both[$my_paye_rate][
'coll'][
'totalht'])) {
319 $x_both[$my_paye_rate][
'coll'][
'totalht'] = 0;
320 $x_both[$my_paye_rate][
'coll'][
'vat'] = 0;
322 $x_both[$my_paye_rate][
'paye'][
'links'] =
'';
323 $x_both[$my_paye_rate][
'paye'][
'detail'] = array();
325 foreach ($x_paye[$my_paye_rate][
'facid'] as
$id => $dummy) {
327 if ($x_paye[$my_paye_rate][
'ptype'][
$id] ===
'ExpenseReportPayment') {
328 $expensereport->id = $x_paye[$my_paye_rate][
'facid'][
$id];
329 $expensereport->ref = $x_paye[$my_paye_rate][
'facnum'][
$id];
330 $expensereport->type = $x_paye[$my_paye_rate][
'type'][
$id];
332 $x_both[$my_paye_rate][
'paye'][
'detail'][] = array(
333 'id' => $x_paye[$my_paye_rate][
'facid'][
$id],
334 'descr' => $x_paye[$my_paye_rate][
'descr'][
$id],
335 'pid' => $x_paye[$my_paye_rate][
'pid'][
$id],
336 'pref' => $x_paye[$my_paye_rate][
'pref'][
$id],
337 'ptype' => $x_paye[$my_paye_rate][
'ptype'][
$id],
338 'payment_id' => $x_paye[$my_paye_rate][
'payment_id'][
$id],
339 'payment_ref' => $x_paye[$my_paye_rate][
'payment_ref'][
$id],
340 'payment_amount' => $x_paye[$my_paye_rate][
'payment_amount'][
$id],
341 'ftotal_ttc' =>
price2num($x_paye[$my_paye_rate][
'ftotal_ttc'][
$id]),
342 'dtotal_ttc' =>
price2num($x_paye[$my_paye_rate][
'dtotal_ttc'][
$id]),
343 'dtype' => $x_paye[$my_paye_rate][
'dtype'][
$id],
344 'ddate_start' => $x_paye[$my_paye_rate][
'ddate_start'][
$id],
345 'ddate_end' => $x_paye[$my_paye_rate][
'ddate_end'][
$id],
346 'totalht' =>
price2num($x_paye[$my_paye_rate][
'totalht_list'][
$id]),
347 'vat' => $x_paye[$my_paye_rate][
'vat_list'][
$id],
348 'link' => $expensereport->getNomUrl(1)
351 $invoice_supplier->id = $x_paye[$my_paye_rate][
'facid'][
$id];
352 $invoice_supplier->ref = $x_paye[$my_paye_rate][
'facnum'][
$id];
353 $invoice_supplier->type = $x_paye[$my_paye_rate][
'type'][
$id];
355 $company_static->id = $x_paye[$my_paye_rate][
'company_id'][
$id];
356 $company_static->name = $x_paye[$my_paye_rate][
'company_name'][
$id];
357 $company_static->name_alias = $x_paye[$my_paye_rate][
'company_alias'][
$id];
358 $company_static->email = $x_paye[$my_paye_rate][
'company_email'][
$id];
359 $company_static->tva_intra = $x_paye[$my_paye_rate][
'tva_intra'][
$id];
360 $company_static->client = $x_paye[$my_paye_rate][
'company_client'][
$id];
361 $company_static->fournisseur = $x_paye[$my_paye_rate][
'company_fournisseur'][
$id];
362 $company_static->status = $x_paye[$my_paye_rate][
'company_status'][
$id];
363 $company_static->code_client = $x_paye[$my_paye_rate][
'company_customer_code'][
$id];
364 $company_static->code_compta_client = $x_paye[$my_paye_rate][
'company_customer_accounting_code'][
$id];
365 $company_static->code_fournisseur = $x_paye[$my_paye_rate][
'company_supplier_code'][
$id];
366 $company_static->code_compta_fournisseur = $x_paye[$my_paye_rate][
'company_supplier_accounting_code'][
$id];
368 $x_both[$my_paye_rate][
'paye'][
'detail'][] = array(
369 'id' => $x_paye[$my_paye_rate][
'facid'][
$id],
370 'descr' => $x_paye[$my_paye_rate][
'descr'][
$id],
371 'pid' => $x_paye[$my_paye_rate][
'pid'][
$id],
372 'pref' => $x_paye[$my_paye_rate][
'pref'][
$id],
373 'ptype' => $x_paye[$my_paye_rate][
'ptype'][
$id],
374 'payment_id' => $x_paye[$my_paye_rate][
'payment_id'][
$id],
375 'payment_ref' => $x_paye[$my_paye_rate][
'payment_ref'][
$id],
376 'payment_amount' => $x_paye[$my_paye_rate][
'payment_amount'][
$id],
377 'ftotal_ttc' =>
price2num($x_paye[$my_paye_rate][
'ftotal_ttc'][
$id]),
378 'dtotal_ttc' =>
price2num($x_paye[$my_paye_rate][
'dtotal_ttc'][
$id]),
379 'dtype' => $x_paye[$my_paye_rate][
'dtype'][
$id],
380 'datef' => $x_paye[$my_paye_rate][
'datef'][
$id],
381 'datep' => $x_paye[$my_paye_rate][
'datep'][
$id],
383 'company_link' => $company_static->getNomUrl(1,
'', 20),
385 'ddate_start' => $x_paye[$my_paye_rate][
'ddate_start'][
$id],
386 'ddate_end' => $x_paye[$my_paye_rate][
'ddate_end'][
$id],
387 'totalht' =>
price2num($x_paye[$my_paye_rate][
'totalht_list'][
$id]),
388 'vat' => $x_paye[$my_paye_rate][
'vat_list'][
$id],
389 'link' => $invoice_supplier->getNomUrl(1,
'', 12)
407 print
'<tr class="liste_titre">';
408 print
'<td class="left">' . $elementcust .
'</td>';
409 print
'<td class="left">' . $langs->trans(
"DateInvoice") .
'</td>';
411 print
'<td class="left">' . $langs->trans(
"DatePayment") .
'</td>';
415 print
'<td class="left">' . $namecust .
'</td>';
416 print
'<td class="left">' . $productcust .
'</td>';
418 print
'<td class="right">' . $amountcust .
'</td>';
419 print
'<td class="right">' . $langs->trans(
"Payment") .
' (' . $langs->trans(
"PercentOfInvoice") .
')</td>';
421 print
'<td class="right">' . $langs->trans(
"AmountHTVATRealReceived") .
'</td>';
422 print
'<td class="right">' . $vatcust .
'</td>';
425 $action =
"tvadetail";
426 $parameters[
"mode"] = $modetax;
427 $parameters[
"start"] = $date_start;
428 $parameters[
"end"] = $date_end;
429 $parameters[
"type"] =
'vat';
431 $object = array(&$x_coll, &$x_paye, &$x_both);
433 $hookmanager->initHooks(array(
'externalbalance'));
434 $reshook = $hookmanager->executeHooks(
'addVatLine', $parameters, $object, $action);
436 foreach (array_keys($x_coll) as $rate) {
437 $subtot_coll_total_ht = 0;
438 $subtot_coll_vat = 0;
440 if (is_array($x_both[$rate][
'coll'][
'detail'])) {
443 print
'<td class="tax_rate" colspan="' . ($span + 1) .
'">';
444 print $langs->trans(
'Rate') .
' : ' .
vatrate($rate) .
'%';
445 print
' - <a class="reposition" href="' . DOL_URL_ROOT .
'/compta/tva/quadri_detail.php?invoice_type=customer';
446 if ($invoice_type !=
'customer' || !GETPOSTISSET(
'vat_rate_show') ||
GETPOST(
'vat_rate_show') != $rate) {
447 print
'&vat_rate_show=' . urlencode($rate);
449 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>';
451 print
'</tr>' .
"\n";
453 foreach ($x_both[$rate][
'coll'][
'detail'] as $index => $fields) {
456 $type = (isset($fields[
'dtype']) ? $fields[
'dtype'] : $fields[
'ptype']);
459 if (!empty($fields[
'ddate_start'])) {
462 if (!empty($fields[
'ddate_end'])) {
467 $ratiopaymentinvoice = 1;
472 if (isset($fields[
'payment_amount']) &&
price2num($fields[
'ftotal_ttc'])) {
473 $ratiopaymentinvoice = ($fields[
'payment_amount'] / $fields[
'ftotal_ttc']);
479 $temp_ht = (float) $fields[
'totalht'] * $ratiopaymentinvoice;
482 $temp_vat = $fields[
'vat'] * $ratiopaymentinvoice;
484 $subtot_coll_total_ht += $temp_ht;
485 $subtot_coll_vat += $temp_vat;
486 $x_coll_sum += $temp_vat;
490 if ($invoice_type ==
'customer' && $vat_rate_show == $rate) {
491 if (is_array($x_both[$rate][
'coll'][
'detail'])) {
492 foreach ($x_both[$rate][
'coll'][
'detail'] as $index => $fields) {
508 $type = (isset($fields[
'dtype']) ? $fields[
'dtype'] : $fields[
'ptype']);
511 if (!empty($fields[
'ddate_start'])) {
514 if (!empty($fields[
'ddate_end'])) {
519 print
'<tr class="oddeven">';
522 print
'<td class="nowrap left">' . $fields[
'link'] .
'</td>';
525 print
'<td class="left">' .
dol_print_date($fields[
'datef'],
'day') .
'</td>';
529 print
'<td class="left">' .
dol_print_date($fields[
'datep'],
'day') .
'</td>';
535 print
'<td class="tdmaxoverflow150">';
537 print $fields[
'company_link'];
541 print
'<td class="left">';
542 if ($fields[
'pid']) {
543 $product_static->id = $fields[
'pid'];
544 $product_static->ref = $fields[
'pref'];
545 $product_static->type = $fields[
'dtype'];
546 print $product_static->getNomUrl(1);
552 $text =
img_object($langs->trans(
'Service'),
'service');
554 $text =
img_object($langs->trans(
'Product'),
'product');
556 if (preg_match(
'/^\((.*)\)$/', $fields[
'descr'], $reg)) {
557 if ($reg[1] ==
'DEPOSIT') {
558 $fields[
'descr'] = $langs->transnoentitiesnoconv(
'Deposit');
559 } elseif ($reg[1] ==
'CREDIT_NOTE') {
560 $fields[
'descr'] = $langs->transnoentitiesnoconv(
'CreditNote');
562 $fields[
'descr'] = $langs->transnoentitiesnoconv($reg[1]);
574 print
'<td class="nowrap right">';
575 print
price($fields[
'totalht']);
578 $ratiolineinvoice = ($fields[
'dtotal_ttc'] / $fields[
'ftotal_ttc']);
585 $ratiopaymentinvoice = 1;
587 print
'<td class="nowrap right">';
589 if ($fields[
'payment_amount'] && $fields[
'ftotal_ttc']) {
590 $payment_static->id = $fields[
'payment_id'];
591 $payment_static->ref = $fields[
'payment_ref'];
592 print $payment_static->getNomUrl(2,
'',
'', 0) .
' ';
596 print $langs->trans(
"NA");
598 if (isset($fields[
'payment_amount']) &&
price2num($fields[
'ftotal_ttc'])) {
599 $ratiopaymentinvoice = ($fields[
'payment_amount'] / $fields[
'ftotal_ttc']);
602 if (isset($fields[
'payment_amount'])) {
603 print
' (' . round($ratiopaymentinvoice * 100, 2) .
'%)';
610 print
'<td class="nowrap right">';
611 $temp_ht = (float) $fields[
'totalht'] * $ratiopaymentinvoice;
616 print
'<td class="nowrap right">';
617 $temp_vat = $fields[
'vat'] * $ratiopaymentinvoice;
630 print
'<tr class="liste_total">';
631 print
'<td colspan="4"></td>';
632 print
'<td class="right">' . $langs->trans(
"Total") .
':</td>';
634 print
'<td class="nowrap right"> </td>';
635 print
'<td class="right"> </td>';
637 print
'<td class="right"><span class="amount">' .
price(
price2num($subtot_coll_total_ht,
'MT')) .
'</span></td>';
638 print
'<td class="nowrap right"><span class="amount">' .
price(
price2num($subtot_coll_vat,
'MT')) .
'</span></td>';
642 if (count($x_coll) == 0) {
643 print
'<tr class="liste_total">';
644 print
'<td colspan="4"></td>';
645 print
'<td class="right">' . $langs->trans(
"Total") .
':</td>';
647 print
'<td class="nowrap right"> </td>';
648 print
'<td class="right"> </td>';
651 print
'<td class="nowrap right">' .
price(
price2num(0,
'MT')) .
'</td>';
656 print
'<tr><td colspan="' . ($span + 2) .
'"> </td></tr>';
659 print
'<tr class="liste_titre liste_titre_topborder">';
660 print
'<td class="left">' . $elementsup .
'</td>';
661 print
'<td class="left">' . $langs->trans(
"DateInvoice") .
'</td>';
663 print
'<td class="left">' . $langs->trans(
"DatePayment") .
'</td>';
667 print
'<td class="left">' . $namesup .
'</td>';
668 print
'<td class="left">' . $productsup .
'</td>';
670 print
'<td class="right">' . $amountsup .
'</td>';
671 print
'<td class="right">' . $langs->trans(
"Payment") .
' (' . $langs->trans(
"PercentOfInvoice") .
')</td>';
673 print
'<td class="right">' . $langs->trans(
"AmountHTVATRealPaid") .
'</td>';
674 print
'<td class="right">' . $vatsup .
'</td>';
675 print
'</tr>' .
"\n";
677 foreach (array_keys($x_paye) as $rate) {
678 $subtot_paye_total_ht = 0;
679 $subtot_paye_vat = 0;
681 if (is_array($x_both[$rate][
'paye'][
'detail'])) {
683 print
'<td class="tax_rate" colspan="' . ($span + 1) .
'">';
684 print $langs->trans(
'Rate') .
' : ' .
vatrate($rate) .
'%';
685 print
' - <a class="reposition" href="' . DOL_URL_ROOT .
'/compta/tva/quadri_detail.php?invoice_type=supplier';
686 if ($invoice_type !=
'supplier' || !GETPOSTISSET(
'vat_rate_show') ||
GETPOST(
'vat_rate_show') != $rate) {
687 print
'&vat_rate_show=' . urlencode($rate);
689 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>';
691 print
'</tr>' .
"\n";
693 foreach ($x_both[$rate][
'paye'][
'detail'] as $index => $fields) {
696 $type = (isset($fields[
'dtype']) ? $fields[
'dtype'] : $fields[
'ptype']);
699 if (!empty($fields[
'ddate_start'])) {
702 if (!empty($fields[
'ddate_end'])) {
707 $ratiopaymentinvoice = 1;
712 if (isset($fields[
'payment_amount']) && $fields[
'ftotal_ttc']) {
713 $ratiopaymentinvoice = ($fields[
'payment_amount'] / (float) $fields[
'ftotal_ttc']);
719 $temp_ht = (float) $fields[
'totalht'] * $ratiopaymentinvoice;
722 $temp_vat = $fields[
'vat'] * $ratiopaymentinvoice;
724 $subtot_paye_total_ht += $temp_ht;
725 $subtot_paye_vat += $temp_vat;
726 $x_paye_sum += $temp_vat;
729 if ($invoice_type ==
'supplier' && $vat_rate_show == $rate) {
730 foreach ($x_both[$rate][
'paye'][
'detail'] as $index => $fields) {
746 $type = (isset($fields[
'dtype']) ? $fields[
'dtype'] : $fields[
'ptype']);
749 if (!empty($fields[
'ddate_start'])) {
752 if (!empty($fields[
'ddate_end'])) {
756 print
'<tr class="oddeven">';
759 print
'<td class="nowrap left">' . $fields[
'link'] .
'</td>';
762 print
'<td class="left">' .
dol_print_date($fields[
'datef'],
'day') .
'</td>';
766 print
'<td class="left">' .
dol_print_date($fields[
'datep'],
'day') .
'</td>';
772 print
'<td class="tdmaxoverflow150">';
774 print $fields[
'company_link'];
778 print
'<td class="left">';
779 if ($fields[
'pid']) {
780 $product_static->id = $fields[
'pid'];
781 $product_static->ref = $fields[
'pref'];
782 $product_static->type = $fields[
'dtype'];
783 print $product_static->getNomUrl(1);
789 $text =
img_object($langs->trans(
'Service'),
'service');
791 $text =
img_object($langs->trans(
'Product'),
'product');
793 if (preg_match(
'/^\((.*)\)$/', $fields[
'descr'], $reg)) {
794 if ($reg[1] ==
'DEPOSIT') {
795 $fields[
'descr'] = $langs->transnoentitiesnoconv(
'Deposit');
796 } elseif ($reg[1] ==
'CREDIT_NOTE') {
797 $fields[
'descr'] = $langs->transnoentitiesnoconv(
'CreditNote');
799 $fields[
'descr'] = $langs->transnoentitiesnoconv($reg[1]);
811 print
'<td class="nowrap right">';
812 print
price($fields[
'totalht']);
815 $ratiolineinvoice = ((float) $fields[
'dtotal_ttc'] / (
float) $fields[
'ftotal_ttc']);
822 $ratiopaymentinvoice = 1;
824 print
'<td class="nowrap right">';
825 if ($fields[
'payment_amount'] && $fields[
'ftotal_ttc']) {
826 $paymentfourn_static->id = $fields[
'payment_id'];
827 $paymentfourn_static->ref = $fields[
'payment_ref'];
828 print $paymentfourn_static->getNomUrl(2,
'',
'', 0) .
' ';
833 print $langs->trans(
"NA");
835 if (isset($fields[
'payment_amount']) && $fields[
'ftotal_ttc']) {
836 $ratiopaymentinvoice = ($fields[
'payment_amount'] / (float) $fields[
'ftotal_ttc']);
839 if (isset($fields[
'payment_amount'])) {
840 print
' (' . round($ratiopaymentinvoice * 100, 2) .
'%)';
847 print
'<td class="nowrap right">';
848 $temp_ht = (float) $fields[
'totalht'] * $ratiopaymentinvoice;
853 print
'<td class="nowrap right">';
854 $temp_vat = $fields[
'vat'] * $ratiopaymentinvoice;
868 print
'<tr class="liste_total">';
869 print
'<td colspan="4"></td>';
870 print
'<td class="right">' . $langs->trans(
"Total") .
':</td>';
872 print
'<td class="nowrap right"> </td>';
873 print
'<td class="right"> </td>';
875 print
'<td class="right"><span class="amount">' .
price(
price2num($subtot_paye_total_ht,
'MT')) .
'</span></td>';
876 print
'<td class="nowrap right"><span class="amount">' .
price(
price2num($subtot_paye_vat,
'MT')) .
'</span></td>';
880 if (count($x_paye) == 0) {
881 print
'<tr class="liste_total">';
882 print
'<td colspan="4"></td>';
883 print
'<td class="right">' . $langs->trans(
"Total") .
':</td>';
885 print
'<td class="nowrap right"> </td>';
886 print
'<td class="right"> </td>';
888 print
'<td class="right"><span class="amount">' .
price(
price2num(0,
'MT')) .
'</span></td>';
889 print
'<td class="nowrap right"><span class="amount">' .
price(
price2num(0,
'MT')) .
'</span></td>';
898 print
'<table class="noborder centpercent">';
899 $diff = $x_coll_sum - $x_paye_sum;
900 print
'<tr class="liste_total">';
901 print
'<td class="liste_total" colspan="' . $span .
'">' . $langs->trans(
"TotalToPay") . ($q ?
', ' . $langs->trans(
"Quadri") .
' ' . $q :
'') .
'</td>';
902 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
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)
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
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)
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 '.
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...