32require
'../../main.inc.php';
33require_once DOL_DOCUMENT_ROOT .
'/core/lib/report.lib.php';
34require_once DOL_DOCUMENT_ROOT .
'/core/lib/tax.lib.php';
35require_once DOL_DOCUMENT_ROOT .
'/core/lib/date.lib.php';
36require_once DOL_DOCUMENT_ROOT .
'/compta/tva/class/tva.class.php';
37require_once DOL_DOCUMENT_ROOT .
'/compta/localtax/class/localtax.class.php';
38require_once DOL_DOCUMENT_ROOT .
'/compta/facture/class/facture.class.php';
39require_once DOL_DOCUMENT_ROOT .
'/product/class/product.class.php';
40require_once DOL_DOCUMENT_ROOT .
'/compta/paiement/class/paiement.class.php';
41require_once DOL_DOCUMENT_ROOT .
'/fourn/class/fournisseur.facture.class.php';
42require_once DOL_DOCUMENT_ROOT .
'/fourn/class/paiementfourn.class.php';
43require_once DOL_DOCUMENT_ROOT .
'/expensereport/class/expensereport.class.php';
44require_once DOL_DOCUMENT_ROOT .
'/expensereport/class/paymentexpensereport.class.php';
47$langs->loadLangs(array(
"other",
"compta",
"banks",
"bills",
"companies",
"product",
"trips",
"admin"));
49$refresh = (GETPOSTISSET(
'submit') || GETPOSTISSET(
'vat_rate_show') || GETPOSTISSET(
'invoice_type')) ?
true : false;
50$invoice_type = GETPOSTISSET(
'invoice_type') ?
GETPOST(
'invoice_type',
'alpha') :
'';
51$vat_rate_show = GETPOSTISSET(
'vat_rate_show') ?
GETPOST(
'vat_rate_show',
'alphanohtml') : -1;
53include DOL_DOCUMENT_ROOT .
'/compta/tva/initdatesforvat.inc.php';
63if (GETPOSTISSET(
"modetax")) {
70$object =
new Tva($db);
75 $socid = $user->socid;
85$company_static =
new Societe($db);
86$invoice_customer =
new Facture($db);
89$product_static =
new Product($db);
95$listofparams = array(
'date_startmonth',
'date_startyear',
'date_startday',
'date_endmonth',
'date_endyear',
'date_endday');
96foreach ($listofparams as $param) {
98 $morequerystring .= ($morequerystring ?
'&' :
'') . $param .
'=' .
GETPOST($param);
102$title = $langs->trans(
"VATReport") .
" " .
dol_print_date($date_start,
'',
'tzserver') .
" -> " .
dol_print_date($date_end,
'',
'tzserver');
103llxHeader(
'', $title,
'',
'', 0, 0,
'',
'', $morequerystring);
109$fsearch =
'<!-- hidden fields for form -->';
110$fsearch .=
'<input type="hidden" name="token" value="' . newToken() .
'">';
111$fsearch .=
'<input type="hidden" name="modetax" value="' . $modetax .
'">';
117$name = $langs->trans(
"VATReportByRates");
120 $calcmode = $langs->trans(
'OptionVATDefault');
123 $calcmode = $langs->trans(
'OptionVATDebitOption');
126 $calcmode = $langs->trans(
'OptionPaymentForProductAndServices');
128$calcmode .=
' <span class="opacitymedium">(' . $langs->trans(
"TaxModuleSetupToModifyRules", DOL_URL_ROOT .
'/admin/taxes.php') .
')</span>';
130$period = $form->selectDate($date_start,
'date_start', 0, 0, 0,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'',
'',
'tzserver');
132$period .= $form->selectDate($date_end,
'date_end', 0, 0, 0,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'',
'',
'tzserver');
133$prevyear = $date_start_year;
136if ($prevquarter > 1) {
142$nextyear = $date_start_year;
144if ($nextquarter < 4) {
150$description = $fsearch;
154 $description .= $langs->trans(
"RulesVATDueProducts");
157 $description .= $langs->trans(
"RulesVATInProducts");
160 $description .=
'<br>' . $langs->trans(
"RulesVATDueServices");
163 $description .=
'<br>' . $langs->trans(
"RulesVATInServices");
166 $description .=
'<br>' . $langs->trans(
"DepositsAreNotIncluded");
169 $description .= $langs->trans(
"SupplierDepositsAreNotIncluded");
171if (isModEnabled(
'accounting')) {
172 $description .=
'<br>' . $langs->trans(
"ThisIsAnEstimatedValue");
176$elementcust = $langs->trans(
"CustomersInvoices");
177$productcust = $langs->trans(
"ProductOrService");
178$amountcust = $langs->trans(
"AmountHT");
179$vatcust = $langs->trans(
"VATReceived");
180$namecust = $langs->trans(
"Name");
181if ($mysoc->tva_assuj) {
182 $vatcust .=
' (' . $langs->trans(
"VATToPay") .
')';
186$elementsup = $langs->trans(
"SuppliersInvoices");
187$productsup = $productcust;
188$amountsup = $amountcust;
189$vatsup = $langs->trans(
"VATPaid");
191if ($mysoc->tva_assuj) {
192 $vatsup .=
' (' . $langs->trans(
"ToGetBack") .
')';
195$optioncss =
GETPOST(
'optioncss',
'alpha');
199if ($optioncss !=
"print") {
200 report_header($name,
'', $period, $periodlink, $description, $builddate, $exportlink, array(), $calcmode);
203$vatcust = $langs->trans(
"VATReceived");
204$vatsup = $langs->trans(
"VATPaid");
205$vatexpensereport = $langs->trans(
"VATPaid");
209print
'<div class="div-table-responsive">';
210print
'<table class="liste noborder centpercent">';
222$x_coll =
tax_by_rate(
'vat', $db, 0, 0, $date_start, $date_end, $modetax,
'sell');
223$x_paye =
tax_by_rate(
'vat', $db, 0, 0, $date_start, $date_end, $modetax,
'buy');
225if (!is_array($x_coll) || !is_array($x_paye)) {
226 $langs->load(
"errors");
228 print
'<tr><td colspan="' . $columns .
'">' . $langs->trans(
"ErrorNoAccountancyModuleLoaded") .
'</td></tr>';
229 } elseif ($x_coll == -2) {
230 print
'<tr><td colspan="' . $columns .
'">' . $langs->trans(
"FeatureNotYetAvailable") .
'</td></tr>';
232 print
'<tr><td colspan="' . $columns .
'">' . $langs->trans(
"Error") .
'</td></tr>';
237 foreach (array_keys($x_coll) as $my_coll_rate) {
238 $x_both[$my_coll_rate][
'coll'][
'totalht'] = $x_coll[$my_coll_rate][
'totalht'];
239 $x_both[$my_coll_rate][
'coll'][
'vat'] = $x_coll[$my_coll_rate][
'vat'];
240 $x_both[$my_coll_rate][
'paye'][
'totalht'] = 0;
241 $x_both[$my_coll_rate][
'paye'][
'vat'] = 0;
242 $x_both[$my_coll_rate][
'coll'][
'links'] =
'';
243 $x_both[$my_coll_rate][
'coll'][
'detail'] = array();
244 foreach ($x_coll[$my_coll_rate][
'facid'] as $id => $dummy) {
245 $invoice_customer->id = $x_coll[$my_coll_rate][
'facid'][$id];
246 $invoice_customer->ref = $x_coll[$my_coll_rate][
'facnum'][$id];
247 $invoice_customer->type = $x_coll[$my_coll_rate][
'type'][$id];
250 $company_static->id = $x_coll[$my_coll_rate][
'company_id'][$id];
251 $company_static->name = $x_coll[$my_coll_rate][
'company_name'][$id];
252 $company_static->name_alias = $x_coll[$my_coll_rate][
'company_alias'][$id];
253 $company_static->email = $x_coll[$my_coll_rate][
'company_email'][$id];
254 $company_static->tva_intra = isset($x_coll[$my_coll_rate][
'tva_intra'][$id]) ? $x_coll[$my_coll_rate][
'tva_intra'][$id] : 0;
255 $company_static->client = $x_coll[$my_coll_rate][
'company_client'][$id];
256 $company_static->fournisseur = $x_coll[$my_coll_rate][
'company_fournisseur'][$id];
257 $company_static->status = $x_coll[$my_coll_rate][
'company_status'][$id];
258 $company_static->code_client = $x_coll[$my_coll_rate][
'company_customer_code'][$id];
259 $company_static->code_compta_client = $x_coll[$my_coll_rate][
'company_customer_accounting_code'][$id];
260 $company_static->code_fournisseur = $x_coll[$my_coll_rate][
'company_supplier_code'][$id];
261 $company_static->code_compta_fournisseur = $x_coll[$my_coll_rate][
'company_supplier_accounting_code'][$id];
263 $x_both[$my_coll_rate][
'coll'][
'detail'][] = array(
264 'id' => $x_coll[$my_coll_rate][
'facid'][$id],
265 'descr' => $x_coll[$my_coll_rate][
'descr'][$id],
266 'pid' => $x_coll[$my_coll_rate][
'pid'][$id],
267 'pref' => $x_coll[$my_coll_rate][
'pref'][$id],
268 'ptype' => $x_coll[$my_coll_rate][
'ptype'][$id],
269 'payment_id' => $x_coll[$my_coll_rate][
'payment_id'][$id],
270 'payment_ref' => $x_coll[$my_coll_rate][
'payment_ref'][$id],
271 'payment_amount' => $x_coll[$my_coll_rate][
'payment_amount'][$id],
272 'ftotal_ttc' => $x_coll[$my_coll_rate][
'ftotal_ttc'][$id],
273 'dtotal_ttc' => $x_coll[$my_coll_rate][
'dtotal_ttc'][$id],
274 'dtype' => $x_coll[$my_coll_rate][
'dtype'][$id],
275 'datef' => $x_coll[$my_coll_rate][
'datef'][$id],
276 'datep' => $x_coll[$my_coll_rate][
'datep'][$id],
278 'company_link' => $company_static->getNomUrl(1,
'', 20),
280 'ddate_start' => $x_coll[$my_coll_rate][
'ddate_start'][$id],
281 'ddate_end' => $x_coll[$my_coll_rate][
'ddate_end'][$id],
282 'totalht' => $x_coll[$my_coll_rate][
'totalht_list'][$id],
283 'vat' => $x_coll[$my_coll_rate][
'vat_list'][$id],
284 'link' => $invoice_customer->getNomUrl(1,
'', 12)
289 foreach (array_keys($x_paye) as $my_paye_rate) {
290 $x_both[$my_paye_rate][
'paye'][
'totalht'] = $x_paye[$my_paye_rate][
'totalht'];
291 $x_both[$my_paye_rate][
'paye'][
'vat'] = $x_paye[$my_paye_rate][
'vat'];
292 if (!isset($x_both[$my_paye_rate][
'coll'][
'totalht'])) {
293 $x_both[$my_paye_rate][
'coll'][
'totalht'] = 0;
294 $x_both[$my_paye_rate][
'coll'][
'vat'] = 0;
296 $x_both[$my_paye_rate][
'paye'][
'links'] =
'';
297 $x_both[$my_paye_rate][
'paye'][
'detail'] = array();
299 foreach ($x_paye[$my_paye_rate][
'facid'] as $id => $dummy) {
301 if ($x_paye[$my_paye_rate][
'ptype'][$id] ==
'ExpenseReportPayment') {
302 $expensereport->id = $x_paye[$my_paye_rate][
'facid'][$id];
303 $expensereport->ref = $x_paye[$my_paye_rate][
'facnum'][$id];
304 $expensereport->type = $x_paye[$my_paye_rate][
'type'][$id];
306 $x_both[$my_paye_rate][
'paye'][
'detail'][] = array(
307 'id' => $x_paye[$my_paye_rate][
'facid'][$id],
308 'descr' => $x_paye[$my_paye_rate][
'descr'][$id],
309 'pid' => $x_paye[$my_paye_rate][
'pid'][$id],
310 'pref' => $x_paye[$my_paye_rate][
'pref'][$id],
311 'ptype' => $x_paye[$my_paye_rate][
'ptype'][$id],
312 'payment_id' => $x_paye[$my_paye_rate][
'payment_id'][$id],
313 'payment_ref' => $x_paye[$my_paye_rate][
'payment_ref'][$id],
314 'payment_amount' => $x_paye[$my_paye_rate][
'payment_amount'][$id],
315 'ftotal_ttc' =>
price2num($x_paye[$my_paye_rate][
'ftotal_ttc'][$id]),
316 'dtotal_ttc' =>
price2num($x_paye[$my_paye_rate][
'dtotal_ttc'][$id]),
317 'dtype' => $x_paye[$my_paye_rate][
'dtype'][$id],
318 'ddate_start' => $x_paye[$my_paye_rate][
'ddate_start'][$id],
319 'ddate_end' => $x_paye[$my_paye_rate][
'ddate_end'][$id],
320 'totalht' =>
price2num($x_paye[$my_paye_rate][
'totalht_list'][$id]),
321 'vat' => $x_paye[$my_paye_rate][
'vat_list'][$id],
322 'link' => $expensereport->getNomUrl(1)
325 $invoice_supplier->id = $x_paye[$my_paye_rate][
'facid'][$id];
326 $invoice_supplier->ref = $x_paye[$my_paye_rate][
'facnum'][$id];
327 $invoice_supplier->type = $x_paye[$my_paye_rate][
'type'][$id];
329 $company_static->id = $x_paye[$my_paye_rate][
'company_id'][$id];
330 $company_static->name = $x_paye[$my_paye_rate][
'company_name'][$id];
331 $company_static->name_alias = $x_paye[$my_paye_rate][
'company_alias'][$id];
332 $company_static->email = $x_paye[$my_paye_rate][
'company_email'][$id];
333 $company_static->tva_intra = $x_paye[$my_paye_rate][
'tva_intra'][$id];
334 $company_static->client = $x_paye[$my_paye_rate][
'company_client'][$id];
335 $company_static->fournisseur = $x_paye[$my_paye_rate][
'company_fournisseur'][$id];
336 $company_static->status = $x_paye[$my_paye_rate][
'company_status'][$id];
337 $company_static->code_client = $x_paye[$my_paye_rate][
'company_customer_code'][$id];
338 $company_static->code_compta_client = $x_paye[$my_paye_rate][
'company_customer_accounting_code'][$id];
339 $company_static->code_fournisseur = $x_paye[$my_paye_rate][
'company_supplier_code'][$id];
340 $company_static->code_compta_fournisseur = $x_paye[$my_paye_rate][
'company_supplier_accounting_code'][$id];
342 $x_both[$my_paye_rate][
'paye'][
'detail'][] = array(
343 'id' => $x_paye[$my_paye_rate][
'facid'][$id],
344 'descr' => $x_paye[$my_paye_rate][
'descr'][$id],
345 'pid' => $x_paye[$my_paye_rate][
'pid'][$id],
346 'pref' => $x_paye[$my_paye_rate][
'pref'][$id],
347 'ptype' => $x_paye[$my_paye_rate][
'ptype'][$id],
348 'payment_id' => $x_paye[$my_paye_rate][
'payment_id'][$id],
349 'payment_ref' => $x_paye[$my_paye_rate][
'payment_ref'][$id],
350 'payment_amount' => $x_paye[$my_paye_rate][
'payment_amount'][$id],
351 'ftotal_ttc' =>
price2num($x_paye[$my_paye_rate][
'ftotal_ttc'][$id]),
352 'dtotal_ttc' =>
price2num($x_paye[$my_paye_rate][
'dtotal_ttc'][$id]),
353 'dtype' => $x_paye[$my_paye_rate][
'dtype'][$id],
354 'datef' => $x_paye[$my_paye_rate][
'datef'][$id],
355 'datep' => $x_paye[$my_paye_rate][
'datep'][$id],
357 'company_link' => $company_static->getNomUrl(1,
'', 20),
359 'ddate_start' => $x_paye[$my_paye_rate][
'ddate_start'][$id],
360 'ddate_end' => $x_paye[$my_paye_rate][
'ddate_end'][$id],
361 'totalht' =>
price2num($x_paye[$my_paye_rate][
'totalht_list'][$id]),
362 'vat' => $x_paye[$my_paye_rate][
'vat_list'][$id],
363 'link' => $invoice_supplier->getNomUrl(1,
'', 12)
381 print
'<tr class="liste_titre">';
382 print
'<td class="left">' . $elementcust .
'</td>';
383 print
'<td class="left">' . $langs->trans(
"DateInvoice") .
'</td>';
385 print
'<td class="left">' . $langs->trans(
"DatePayment") .
'</td>';
389 print
'<td class="left">' . $namecust .
'</td>';
390 print
'<td class="left">' . $productcust .
'</td>';
392 print
'<td class="right">' . $amountcust .
'</td>';
393 print
'<td class="right">' . $langs->trans(
"Payment") .
' (' . $langs->trans(
"PercentOfInvoice") .
')</td>';
395 print
'<td class="right">' . $langs->trans(
"AmountHTVATRealReceived") .
'</td>';
396 print
'<td class="right">' . $vatcust .
'</td>';
399 $action =
"tvadetail";
400 $parameters[
"mode"] = $modetax;
401 $parameters[
"start"] = $date_start;
402 $parameters[
"end"] = $date_end;
403 $parameters[
"type"] =
'vat';
405 $object = array(&$x_coll, &$x_paye, &$x_both);
407 $hookmanager->initHooks(array(
'externalbalance'));
408 $reshook = $hookmanager->executeHooks(
'addVatLine', $parameters, $object, $action);
410 foreach (array_keys($x_coll) as $rate) {
411 $subtot_coll_total_ht = 0;
412 $subtot_coll_vat = 0;
414 if (is_array($x_both[$rate][
'coll'][
'detail'])) {
417 print
'<td class="tax_rate" colspan="' . ($span + 1) .
'">';
418 print $langs->trans(
'Rate') .
' : ' .
vatrate($rate) .
'%';
419 print
' - <a href="' . DOL_URL_ROOT .
'/compta/tva/quadri_detail.php?invoice_type=customer';
420 if ($invoice_type !=
'customer' || !GETPOSTISSET(
'vat_rate_show') ||
GETPOST(
'vat_rate_show') != $rate) {
421 print
'&vat_rate_show=' . urlencode($rate);
423 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>';
425 print
'</tr>' .
"\n";
427 foreach ($x_both[$rate][
'coll'][
'detail'] as $index => $fields) {
430 $type = (isset($fields[
'dtype']) ? $fields[
'dtype'] : $fields[
'ptype']);
433 if (!empty($fields[
'ddate_start'])) {
436 if (!empty($fields[
'ddate_end'])) {
441 $ratiopaymentinvoice = 1;
446 if (isset($fields[
'payment_amount']) &&
price2num($fields[
'ftotal_ttc'])) {
447 $ratiopaymentinvoice = ($fields[
'payment_amount'] / $fields[
'ftotal_ttc']);
453 $temp_ht = $fields[
'totalht'] * $ratiopaymentinvoice;
456 $temp_vat = $fields[
'vat'] * $ratiopaymentinvoice;
458 $subtot_coll_total_ht += $temp_ht;
459 $subtot_coll_vat += $temp_vat;
460 $x_coll_sum += $temp_vat;
464 if ($invoice_type ==
'customer' && $vat_rate_show == $rate) {
465 if (is_array($x_both[$rate][
'coll'][
'detail'])) {
466 foreach ($x_both[$rate][
'coll'][
'detail'] as $index => $fields) {
482 $type = (isset($fields[
'dtype']) ? $fields[
'dtype'] : $fields[
'ptype']);
485 if (!empty($fields[
'ddate_start'])) {
488 if (!empty($fields[
'ddate_end'])) {
493 print
'<tr class="oddeven">';
496 print
'<td class="nowrap left">' . $fields[
'link'] .
'</td>';
499 print
'<td class="left">' .
dol_print_date($fields[
'datef'],
'day') .
'</td>';
503 print
'<td class="left">' .
dol_print_date($fields[
'datep'],
'day') .
'</td>';
509 print
'<td class="tdmaxoverflow150">';
511 print $fields[
'company_link'];
515 print
'<td class="left">';
516 if ($fields[
'pid']) {
517 $product_static->id = $fields[
'pid'];
518 $product_static->ref = $fields[
'pref'];
519 $product_static->type = $fields[
'dtype'];
520 print $product_static->getNomUrl(1);
526 $text =
img_object($langs->trans(
'Service'),
'service');
528 $text =
img_object($langs->trans(
'Product'),
'product');
530 if (preg_match(
'/^\((.*)\)$/', $fields[
'descr'], $reg)) {
531 if ($reg[1] ==
'DEPOSIT') {
532 $fields[
'descr'] = $langs->transnoentitiesnoconv(
'Deposit');
533 } elseif ($reg[1] ==
'CREDIT_NOTE') {
534 $fields[
'descr'] = $langs->transnoentitiesnoconv(
'CreditNote');
536 $fields[
'descr'] = $langs->transnoentitiesnoconv($reg[1]);
548 print
'<td class="nowrap right">';
549 print
price($fields[
'totalht']);
552 $ratiolineinvoice = ($fields[
'dtotal_ttc'] / $fields[
'ftotal_ttc']);
559 $ratiopaymentinvoice = 1;
561 print
'<td class="nowrap right">';
563 if ($fields[
'payment_amount'] && $fields[
'ftotal_ttc']) {
564 $payment_static->id = $fields[
'payment_id'];
565 $payment_static->ref = $fields[
'payment_ref'];
566 print $payment_static->getNomUrl(2,
'',
'', 0) .
' ';
570 print $langs->trans(
"NA");
572 if (isset($fields[
'payment_amount']) &&
price2num($fields[
'ftotal_ttc'])) {
573 $ratiopaymentinvoice = ($fields[
'payment_amount'] / $fields[
'ftotal_ttc']);
576 if (isset($fields[
'payment_amount'])) {
577 print
' (' . round($ratiopaymentinvoice * 100, 2) .
'%)';
584 print
'<td class="nowrap right">';
585 $temp_ht = $fields[
'totalht'] * $ratiopaymentinvoice;
590 print
'<td class="nowrap right">';
591 $temp_vat = $fields[
'vat'] * $ratiopaymentinvoice;
604 print
'<tr class="liste_total">';
605 print
'<td colspan="4"></td>';
606 print
'<td class="right">' . $langs->trans(
"Total") .
':</td>';
608 print
'<td class="nowrap right"> </td>';
609 print
'<td class="right"> </td>';
611 print
'<td class="right"><span class="amount">' .
price(
price2num($subtot_coll_total_ht,
'MT')) .
'</span></td>';
612 print
'<td class="nowrap right"><span class="amount">' .
price(
price2num($subtot_coll_vat,
'MT')) .
'</span></td>';
616 if (count($x_coll) == 0) {
617 print
'<tr class="liste_total">';
618 print
'<td colspan="4"></td>';
619 print
'<td class="right">' . $langs->trans(
"Total") .
':</td>';
621 print
'<td class="nowrap right"> </td>';
622 print
'<td class="right"> </td>';
625 print
'<td class="nowrap right">' .
price(
price2num(0,
'MT')) .
'</td>';
630 print
'<tr><td colspan="' . ($span + 2) .
'"> </td></tr>';
633 print
'<tr class="liste_titre liste_titre_topborder">';
634 print
'<td class="left">' . $elementsup .
'</td>';
635 print
'<td class="left">' . $langs->trans(
"DateInvoice") .
'</td>';
637 print
'<td class="left">' . $langs->trans(
"DatePayment") .
'</td>';
641 print
'<td class="left">' . $namesup .
'</td>';
642 print
'<td class="left">' . $productsup .
'</td>';
644 print
'<td class="right">' . $amountsup .
'</td>';
645 print
'<td class="right">' . $langs->trans(
"Payment") .
' (' . $langs->trans(
"PercentOfInvoice") .
')</td>';
647 print
'<td class="right">' . $langs->trans(
"AmountHTVATRealPaid") .
'</td>';
648 print
'<td class="right">' . $vatsup .
'</td>';
649 print
'</tr>' .
"\n";
651 foreach (array_keys($x_paye) as $rate) {
652 $subtot_paye_total_ht = 0;
653 $subtot_paye_vat = 0;
655 if (is_array($x_both[$rate][
'paye'][
'detail'])) {
657 print
'<td class="tax_rate" colspan="' . ($span + 1) .
'">';
658 print $langs->trans(
'Rate') .
' : ' .
vatrate($rate) .
'%';
659 print
' - <a href="' . DOL_URL_ROOT .
'/compta/tva/quadri_detail.php?invoice_type=supplier';
660 if ($invoice_type !=
'supplier' || !GETPOSTISSET(
'vat_rate_show') ||
GETPOST(
'vat_rate_show') != $rate) {
661 print
'&vat_rate_show=' . urlencode($rate);
663 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>';
665 print
'</tr>' .
"\n";
667 foreach ($x_both[$rate][
'paye'][
'detail'] as $index => $fields) {
670 $type = (isset($fields[
'dtype']) ? $fields[
'dtype'] : $fields[
'ptype']);
673 if (!empty($fields[
'ddate_start'])) {
676 if (!empty($fields[
'ddate_end'])) {
681 $ratiopaymentinvoice = 1;
686 if (isset($fields[
'payment_amount']) && $fields[
'ftotal_ttc']) {
687 $ratiopaymentinvoice = ($fields[
'payment_amount'] / $fields[
'ftotal_ttc']);
693 $temp_ht = $fields[
'totalht'] * $ratiopaymentinvoice;
696 $temp_vat = $fields[
'vat'] * $ratiopaymentinvoice;
698 $subtot_paye_total_ht += $temp_ht;
699 $subtot_paye_vat += $temp_vat;
700 $x_paye_sum += $temp_vat;
703 if ($invoice_type ==
'supplier' && $vat_rate_show == $rate) {
704 foreach ($x_both[$rate][
'paye'][
'detail'] as $index => $fields) {
720 $type = (isset($fields[
'dtype']) ? $fields[
'dtype'] : $fields[
'ptype']);
723 if (!empty($fields[
'ddate_start'])) {
726 if (!empty($fields[
'ddate_end'])) {
731 print
'<tr class="oddeven">';
734 print
'<td class="nowrap left">' . $fields[
'link'] .
'</td>';
737 print
'<td class="left">' .
dol_print_date($fields[
'datef'],
'day') .
'</td>';
741 print
'<td class="left">' .
dol_print_date($fields[
'datep'],
'day') .
'</td>';
747 print
'<td class="tdmaxoverflow150">';
749 print $fields[
'company_link'];
753 print
'<td class="left">';
754 if ($fields[
'pid']) {
755 $product_static->id = $fields[
'pid'];
756 $product_static->ref = $fields[
'pref'];
757 $product_static->type = $fields[
'dtype'];
758 print $product_static->getNomUrl(1);
764 $text =
img_object($langs->trans(
'Service'),
'service');
766 $text =
img_object($langs->trans(
'Product'),
'product');
768 if (preg_match(
'/^\((.*)\)$/', $fields[
'descr'], $reg)) {
769 if ($reg[1] ==
'DEPOSIT') {
770 $fields[
'descr'] = $langs->transnoentitiesnoconv(
'Deposit');
771 } elseif ($reg[1] ==
'CREDIT_NOTE') {
772 $fields[
'descr'] = $langs->transnoentitiesnoconv(
'CreditNote');
774 $fields[
'descr'] = $langs->transnoentitiesnoconv($reg[1]);
786 print
'<td class="nowrap right">';
787 print
price($fields[
'totalht']);
790 $ratiolineinvoice = ($fields[
'dtotal_ttc'] / $fields[
'ftotal_ttc']);
797 $ratiopaymentinvoice = 1;
799 print
'<td class="nowrap right">';
800 if ($fields[
'payment_amount'] && $fields[
'ftotal_ttc']) {
801 $paymentfourn_static->id = $fields[
'payment_id'];
802 $paymentfourn_static->ref = $fields[
'payment_ref'];
803 print $paymentfourn_static->getNomUrl(2,
'',
'', 0) .
' ';
808 print $langs->trans(
"NA");
810 if (isset($fields[
'payment_amount']) && $fields[
'ftotal_ttc']) {
811 $ratiopaymentinvoice = ($fields[
'payment_amount'] / $fields[
'ftotal_ttc']);
814 if (isset($fields[
'payment_amount'])) {
815 print
' (' . round($ratiopaymentinvoice * 100, 2) .
'%)';
822 print
'<td class="nowrap right">';
823 $temp_ht = $fields[
'totalht'] * $ratiopaymentinvoice;
828 print
'<td class="nowrap right">';
829 $temp_vat = $fields[
'vat'] * $ratiopaymentinvoice;
843 print
'<tr class="liste_total">';
844 print
'<td colspan="4"></td>';
845 print
'<td class="right">' . $langs->trans(
"Total") .
':</td>';
847 print
'<td class="nowrap right"> </td>';
848 print
'<td class="right"> </td>';
850 print
'<td class="right"><span class="amount">' .
price(
price2num($subtot_paye_total_ht,
'MT')) .
'</span></td>';
851 print
'<td class="nowrap right"><span class="amount">' .
price(
price2num($subtot_paye_vat,
'MT')) .
'</span></td>';
855 if (count($x_paye) == 0) {
856 print
'<tr class="liste_total">';
857 print
'<td colspan="4"></td>';
858 print
'<td class="right">' . $langs->trans(
"Total") .
':</td>';
860 print
'<td class="nowrap right"> </td>';
861 print
'<td class="right"> </td>';
863 print
'<td class="right"><span class="amount">' .
price(
price2num(0,
'MT')) .
'</span></td>';
864 print
'<td class="nowrap right"><span class="amount">' .
price(
price2num(0,
'MT')) .
'</span></td>';
873 print
'<table class="noborder centpercent">';
874 $diff = $x_coll_sum - $x_paye_sum;
875 print
'<tr class="liste_total">';
876 print
'<td class="liste_total" colspan="' . $span .
'">' . $langs->trans(
"TotalToPay") . ($q ?
', ' . $langs->trans(
"Quadri") .
' ' . $q :
'') .
'</td>';
877 print
'<td class="liste_total nowrap right"><b>' .
price(
price2num($diff,
'MT')) .
"</b></td>\n";
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader()
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...)
Put here description of your class.
vatrate($rate, $addpercent=false, $info_bits=0, $usestarfornpr=0, $html=0)
Return a string with VAT rate label formated for view output Used into pdf and HTML pages.
GETPOSTINT($paramname, $method=0)
Return value of a param into GET or POST supervariable.
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=false, $srconly=0, $notitle=0)
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_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
dol_now($mode='auto')
Return date for now.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
print_date_range($date_start, $date_end, $format='', $outputlangs='')
Format output for start and end date.
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 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...