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");
165if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
166 $description .=
'<br>' . $langs->trans(
"DepositsAreNotIncluded");
168if (!empty($conf->global->FACTURE_SUPPLIER_DEPOSITS_ARE_JUST_PAYMENTS)) {
169 $description .= $langs->trans(
"SupplierDepositsAreNotIncluded");
171if (!empty($conf->global->MAIN_MODULE_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 else print
'<td></td>';
506 print
'<td class="tdmaxoverflow150">';
508 print $fields[
'company_link'];
512 print
'<td class="left">';
513 if ($fields[
'pid']) {
514 $product_static->id = $fields[
'pid'];
515 $product_static->ref = $fields[
'pref'];
516 $product_static->type = $fields[
'dtype'];
517 print $product_static->getNomUrl(1);
523 $text =
img_object($langs->trans(
'Service'),
'service');
525 $text =
img_object($langs->trans(
'Product'),
'product');
527 if (preg_match(
'/^\((.*)\)$/', $fields[
'descr'], $reg)) {
528 if ($reg[1] ==
'DEPOSIT') {
529 $fields[
'descr'] = $langs->transnoentitiesnoconv(
'Deposit');
530 } elseif ($reg[1] ==
'CREDIT_NOTE') {
531 $fields[
'descr'] = $langs->transnoentitiesnoconv(
'CreditNote');
533 $fields[
'descr'] = $langs->transnoentitiesnoconv($reg[1]);
545 print
'<td class="nowrap right">';
546 print
price($fields[
'totalht']);
549 $ratiolineinvoice = ($fields[
'dtotal_ttc'] / $fields[
'ftotal_ttc']);
556 $ratiopaymentinvoice = 1;
558 print
'<td class="nowrap right">';
560 if ($fields[
'payment_amount'] && $fields[
'ftotal_ttc']) {
561 $payment_static->id = $fields[
'payment_id'];
562 $payment_static->ref = $fields[
'payment_ref'];
563 print $payment_static->getNomUrl(2,
'',
'', 0) .
' ';
567 print $langs->trans(
"NA");
569 if (isset($fields[
'payment_amount']) &&
price2num($fields[
'ftotal_ttc'])) {
570 $ratiopaymentinvoice = ($fields[
'payment_amount'] / $fields[
'ftotal_ttc']);
573 if (isset($fields[
'payment_amount'])) {
574 print
' (' . round($ratiopaymentinvoice * 100, 2) .
'%)';
581 print
'<td class="nowrap right">';
582 $temp_ht = $fields[
'totalht'] * $ratiopaymentinvoice;
587 print
'<td class="nowrap right">';
588 $temp_vat = $fields[
'vat'] * $ratiopaymentinvoice;
601 print
'<tr class="liste_total">';
602 print
'<td colspan="4"></td>';
603 print
'<td class="right">' . $langs->trans(
"Total") .
':</td>';
605 print
'<td class="nowrap right"> </td>';
606 print
'<td class="right"> </td>';
608 print
'<td class="right"><span class="amount">' .
price(
price2num($subtot_coll_total_ht,
'MT')) .
'</span></td>';
609 print
'<td class="nowrap right"><span class="amount">' .
price(
price2num($subtot_coll_vat,
'MT')) .
'</span></td>';
613 if (count($x_coll) == 0) {
614 print
'<tr class="liste_total">';
615 print
'<td colspan="4"></td>';
616 print
'<td class="right">' . $langs->trans(
"Total") .
':</td>';
618 print
'<td class="nowrap right"> </td>';
619 print
'<td class="right"> </td>';
622 print
'<td class="nowrap right">' .
price(
price2num(0,
'MT')) .
'</td>';
627 print
'<tr><td colspan="' . ($span + 2) .
'"> </td></tr>';
630 print
'<tr class="liste_titre liste_titre_topborder">';
631 print
'<td class="left">' . $elementsup .
'</td>';
632 print
'<td class="left">' . $langs->trans(
"DateInvoice") .
'</td>';
633 if (
getDolGlobalString(
'TAX_MODE_BUY_PRODUCT') ==
'payment' ||
getDolGlobalString(
'TAX_MODE_BUY_SERVICE') ==
'payment') print
'<td class="left">' . $langs->trans(
"DatePayment") .
'</td>';
634 else print
'<td></td>';
635 print
'<td class="left">' . $namesup .
'</td>';
636 print
'<td class="left">' . $productsup .
'</td>';
638 print
'<td class="right">' . $amountsup .
'</td>';
639 print
'<td class="right">' . $langs->trans(
"Payment") .
' (' . $langs->trans(
"PercentOfInvoice") .
')</td>';
641 print
'<td class="right">' . $langs->trans(
"AmountHTVATRealPaid") .
'</td>';
642 print
'<td class="right">' . $vatsup .
'</td>';
643 print
'</tr>' .
"\n";
645 foreach (array_keys($x_paye) as $rate) {
646 $subtot_paye_total_ht = 0;
647 $subtot_paye_vat = 0;
649 if (is_array($x_both[$rate][
'paye'][
'detail'])) {
651 print
'<td class="tax_rate" colspan="' . ($span + 1) .
'">';
652 print $langs->trans(
'Rate') .
' : ' .
vatrate($rate) .
'%';
653 print
' - <a href="' . DOL_URL_ROOT .
'/compta/tva/quadri_detail.php?invoice_type=supplier';
654 if ($invoice_type !=
'supplier' || !GETPOSTISSET(
'vat_rate_show') ||
GETPOST(
'vat_rate_show') != $rate) {
655 print
'&vat_rate_show=' . urlencode($rate);
657 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>';
659 print
'</tr>' .
"\n";
661 foreach ($x_both[$rate][
'paye'][
'detail'] as $index => $fields) {
664 $type = (isset($fields[
'dtype']) ? $fields[
'dtype'] : $fields[
'ptype']);
667 if (!empty($fields[
'ddate_start'])) {
670 if (!empty($fields[
'ddate_end'])) {
675 $ratiopaymentinvoice = 1;
680 if (isset($fields[
'payment_amount']) && $fields[
'ftotal_ttc']) {
681 $ratiopaymentinvoice = ($fields[
'payment_amount'] / $fields[
'ftotal_ttc']);
687 $temp_ht = $fields[
'totalht'] * $ratiopaymentinvoice;
690 $temp_vat = $fields[
'vat'] * $ratiopaymentinvoice;
692 $subtot_paye_total_ht += $temp_ht;
693 $subtot_paye_vat += $temp_vat;
694 $x_paye_sum += $temp_vat;
697 if ($invoice_type ==
'supplier' && $vat_rate_show == $rate) {
698 foreach ($x_both[$rate][
'paye'][
'detail'] as $index => $fields) {
714 $type = (isset($fields[
'dtype']) ? $fields[
'dtype'] : $fields[
'ptype']);
717 if (!empty($fields[
'ddate_start'])) {
720 if (!empty($fields[
'ddate_end'])) {
725 print
'<tr class="oddeven">';
728 print
'<td class="nowrap left">' . $fields[
'link'] .
'</td>';
731 print
'<td class="left">' .
dol_print_date($fields[
'datef'],
'day') .
'</td>';
735 print
'<td class="left">' .
dol_print_date($fields[
'datep'],
'day') .
'</td>';
741 print
'<td class="tdmaxoverflow150">';
743 print $fields[
'company_link'];
747 print
'<td class="left">';
748 if ($fields[
'pid']) {
749 $product_static->id = $fields[
'pid'];
750 $product_static->ref = $fields[
'pref'];
751 $product_static->type = $fields[
'dtype'];
752 print $product_static->getNomUrl(1);
758 $text =
img_object($langs->trans(
'Service'),
'service');
760 $text =
img_object($langs->trans(
'Product'),
'product');
762 if (preg_match(
'/^\((.*)\)$/', $fields[
'descr'], $reg)) {
763 if ($reg[1] ==
'DEPOSIT') {
764 $fields[
'descr'] = $langs->transnoentitiesnoconv(
'Deposit');
765 } elseif ($reg[1] ==
'CREDIT_NOTE') {
766 $fields[
'descr'] = $langs->transnoentitiesnoconv(
'CreditNote');
768 $fields[
'descr'] = $langs->transnoentitiesnoconv($reg[1]);
780 print
'<td class="nowrap right">';
781 print
price($fields[
'totalht']);
784 $ratiolineinvoice = ($fields[
'dtotal_ttc'] / $fields[
'ftotal_ttc']);
791 $ratiopaymentinvoice = 1;
793 print
'<td class="nowrap right">';
794 if ($fields[
'payment_amount'] && $fields[
'ftotal_ttc']) {
795 $paymentfourn_static->id = $fields[
'payment_id'];
796 $paymentfourn_static->ref = $fields[
'payment_ref'];
797 print $paymentfourn_static->getNomUrl(2,
'',
'', 0) .
' ';
802 print $langs->trans(
"NA");
804 if (isset($fields[
'payment_amount']) && $fields[
'ftotal_ttc']) {
805 $ratiopaymentinvoice = ($fields[
'payment_amount'] / $fields[
'ftotal_ttc']);
808 if (isset($fields[
'payment_amount'])) {
809 print
' (' . round($ratiopaymentinvoice * 100, 2) .
'%)';
816 print
'<td class="nowrap right">';
817 $temp_ht = $fields[
'totalht'] * $ratiopaymentinvoice;
822 print
'<td class="nowrap right">';
823 $temp_vat = $fields[
'vat'] * $ratiopaymentinvoice;
837 print
'<tr class="liste_total">';
838 print
'<td colspan="4"></td>';
839 print
'<td class="right">' . $langs->trans(
"Total") .
':</td>';
841 print
'<td class="nowrap right"> </td>';
842 print
'<td class="right"> </td>';
844 print
'<td class="right"><span class="amount">' .
price(
price2num($subtot_paye_total_ht,
'MT')) .
'</span></td>';
845 print
'<td class="nowrap right"><span class="amount">' .
price(
price2num($subtot_paye_vat,
'MT')) .
'</span></td>';
849 if (count($x_paye) == 0) {
850 print
'<tr class="liste_total">';
851 print
'<td colspan="4"></td>';
852 print
'<td class="right">' . $langs->trans(
"Total") .
':</td>';
854 print
'<td class="nowrap right"> </td>';
855 print
'<td class="right"> </td>';
857 print
'<td class="right"><span class="amount">' .
price(
price2num(0,
'MT')) .
'</span></td>';
858 print
'<td class="nowrap right"><span class="amount">' .
price(
price2num(0,
'MT')) .
'</span></td>';
867 print
'<table class="noborder centpercent">';
868 $diff = $x_coll_sum - $x_paye_sum;
869 print
'<tr class="liste_total">';
870 print
'<td class="liste_total" colspan="' . $span .
'">' . $langs->trans(
"TotalToPay") . ($q ?
', ' . $langs->trans(
"Quadri") .
' ' . $q :
'') .
'</td>';
871 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 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...