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';
48$langs->loadLangs(array(
"other",
"compta",
"banks",
"bills",
"companies",
"product",
"trips",
"admin"));
50$refresh = (GETPOSTISSET(
'submit') || GETPOSTISSET(
'vat_rate_show') || GETPOSTISSET(
'invoice_type')) ?
true : false;
51$invoice_type = GETPOSTISSET(
'invoice_type') ?
GETPOST(
'invoice_type',
'alpha') :
'';
52$vat_rate_show = GETPOSTISSET(
'vat_rate_show') ?
GETPOST(
'vat_rate_show',
'alphanohtml') : -1;
55include DOL_DOCUMENT_ROOT .
'/compta/tva/initdatesforvat.inc.php';
65if (GETPOSTISSET(
"modetax")) {
77 $socid = $user->socid;
87$company_static =
new Societe($db);
88$invoice_customer =
new Facture($db);
91$product_static =
new Product($db);
97$listofparams = array(
'date_startmonth',
'date_startyear',
'date_startday',
'date_endmonth',
'date_endyear',
'date_endday');
98foreach ($listofparams as $param) {
100 $morequerystring .= ($morequerystring ?
'&' :
'') . $param .
'=' .
GETPOST($param);
104$title = $langs->trans(
"VATReport") .
" " .
dol_print_date($date_start,
'',
'tzserver') .
" -> " .
dol_print_date($date_end,
'',
'tzserver');
105llxHeader(
'', $title,
'',
'', 0, 0,
'',
'', $morequerystring);
111$fsearch =
'<!-- hidden fields for form -->';
112$fsearch .=
'<input type="hidden" name="token" value="' .
newToken() .
'">';
113$fsearch .=
'<input type="hidden" name="modetax" value="' . $modetax .
'">';
119$name = $langs->trans(
"VATReportByRates");
122 $calcmode = $langs->trans(
'OptionVATDefault');
125 $calcmode = $langs->trans(
'OptionVATDebitOption');
128 $calcmode = $langs->trans(
'OptionPaymentForProductAndServices');
130$calcmode .=
' <span class="opacitymedium">(' . $langs->trans(
"TaxModuleSetupToModifyRules", DOL_URL_ROOT .
'/admin/taxes.php') .
')</span>';
132$period = $form->selectDate($date_start,
'date_start', 0, 0, 0,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'',
'',
'tzserver');
134$period .= $form->selectDate($date_end,
'date_end', 0, 0, 0,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'',
'',
'tzserver');
135$prevyear = $date_start_year;
138if ($prevquarter > 1) {
144$nextyear = $date_start_year;
146if ($nextquarter < 4) {
152$description = $fsearch;
156 $description .= $langs->trans(
"RulesVATDueProducts");
159 $description .= $langs->trans(
"RulesVATInProducts");
162 $description .=
'<br>' . $langs->trans(
"RulesVATDueServices");
165 $description .=
'<br>' . $langs->trans(
"RulesVATInServices");
168 $description .=
'<br>' . $langs->trans(
"DepositsAreNotIncluded");
171 $description .= $langs->trans(
"SupplierDepositsAreNotIncluded");
173if (isModEnabled(
'accounting')) {
174 $description .=
'<br>' . $langs->trans(
"ThisIsAnEstimatedValue");
178$elementcust = $langs->trans(
"CustomersInvoices");
179$productcust = $langs->trans(
"ProductOrService");
180$amountcust = $langs->trans(
"AmountHT");
181$vatcust = $langs->trans(
"VATReceived");
182$namecust = $langs->trans(
"Name");
183if ($mysoc->tva_assuj) {
184 $vatcust .=
' (' . $langs->trans(
"VATToPay") .
')';
188$elementsup = $langs->trans(
"SuppliersInvoices");
189$productsup = $productcust;
190$amountsup = $amountcust;
191$vatsup = $langs->trans(
"VATPaid");
193if ($mysoc->tva_assuj) {
194 $vatsup .=
' (' . $langs->trans(
"ToGetBack") .
')';
197$optioncss =
GETPOST(
'optioncss',
'alpha');
201if ($optioncss !=
"print") {
202 report_header($name,
'', $period, $periodlink, $description, $builddate, $exportlink, array(), $calcmode);
205$vatcust = $langs->trans(
"VATReceived");
206$vatsup = $langs->trans(
"VATPaid");
207$vatexpensereport = $langs->trans(
"VATPaid");
211print
'<div class="div-table-responsive">';
212print
'<table class="liste noborder centpercent">';
224$x_coll =
tax_by_rate(
'vat', $db, 0, 0, $date_start, $date_end, $modetax,
'sell');
225$x_paye =
tax_by_rate(
'vat', $db, 0, 0, $date_start, $date_end, $modetax,
'buy');
227if (!is_array($x_coll) || !is_array($x_paye)) {
228 $langs->load(
"errors");
230 print
'<tr><td colspan="' . $columns .
'">' . $langs->trans(
"ErrorNoAccountancyModuleLoaded") .
'</td></tr>';
231 } elseif ($x_coll == -2) {
232 print
'<tr><td colspan="' . $columns .
'">' . $langs->trans(
"FeatureNotYetAvailable") .
'</td></tr>';
234 print
'<tr><td colspan="' . $columns .
'">' . $langs->trans(
"Error") .
'</td></tr>';
239 foreach (array_keys($x_coll) as $my_coll_rate) {
240 $x_both[$my_coll_rate][
'coll'][
'totalht'] = $x_coll[$my_coll_rate][
'totalht'];
241 $x_both[$my_coll_rate][
'coll'][
'vat'] = $x_coll[$my_coll_rate][
'vat'];
242 $x_both[$my_coll_rate][
'paye'][
'totalht'] = 0;
243 $x_both[$my_coll_rate][
'paye'][
'vat'] = 0;
244 $x_both[$my_coll_rate][
'coll'][
'links'] =
'';
245 $x_both[$my_coll_rate][
'coll'][
'detail'] = array();
246 foreach ($x_coll[$my_coll_rate][
'facid'] as $id => $dummy) {
247 $invoice_customer->id = $x_coll[$my_coll_rate][
'facid'][$id];
248 $invoice_customer->ref = $x_coll[$my_coll_rate][
'facnum'][$id];
249 $invoice_customer->type = $x_coll[$my_coll_rate][
'type'][$id];
252 $company_static->id = $x_coll[$my_coll_rate][
'company_id'][$id];
253 $company_static->name = $x_coll[$my_coll_rate][
'company_name'][$id];
254 $company_static->name_alias = $x_coll[$my_coll_rate][
'company_alias'][$id];
255 $company_static->email = $x_coll[$my_coll_rate][
'company_email'][$id];
256 $company_static->tva_intra = isset($x_coll[$my_coll_rate][
'tva_intra'][$id]) ? $x_coll[$my_coll_rate][
'tva_intra'][$id] : 0;
257 $company_static->client = $x_coll[$my_coll_rate][
'company_client'][$id];
258 $company_static->fournisseur = $x_coll[$my_coll_rate][
'company_fournisseur'][$id];
259 $company_static->status = $x_coll[$my_coll_rate][
'company_status'][$id];
260 $company_static->code_client = $x_coll[$my_coll_rate][
'company_customer_code'][$id];
261 $company_static->code_compta_client = $x_coll[$my_coll_rate][
'company_customer_accounting_code'][$id];
262 $company_static->code_fournisseur = $x_coll[$my_coll_rate][
'company_supplier_code'][$id];
263 $company_static->code_compta_fournisseur = $x_coll[$my_coll_rate][
'company_supplier_accounting_code'][$id];
265 $x_both[$my_coll_rate][
'coll'][
'detail'][] = array(
266 'id' => $x_coll[$my_coll_rate][
'facid'][$id],
267 'descr' => $x_coll[$my_coll_rate][
'descr'][$id],
268 'pid' => $x_coll[$my_coll_rate][
'pid'][$id],
269 'pref' => $x_coll[$my_coll_rate][
'pref'][$id],
270 'ptype' => $x_coll[$my_coll_rate][
'ptype'][$id],
271 'payment_id' => $x_coll[$my_coll_rate][
'payment_id'][$id],
272 'payment_ref' => $x_coll[$my_coll_rate][
'payment_ref'][$id],
273 'payment_amount' => $x_coll[$my_coll_rate][
'payment_amount'][$id],
274 'ftotal_ttc' => $x_coll[$my_coll_rate][
'ftotal_ttc'][$id],
275 'dtotal_ttc' => $x_coll[$my_coll_rate][
'dtotal_ttc'][$id],
276 'dtype' => $x_coll[$my_coll_rate][
'dtype'][$id],
277 'datef' => $x_coll[$my_coll_rate][
'datef'][$id],
278 'datep' => $x_coll[$my_coll_rate][
'datep'][$id],
280 'company_link' => $company_static->getNomUrl(1,
'', 20),
282 'ddate_start' => $x_coll[$my_coll_rate][
'ddate_start'][$id],
283 'ddate_end' => $x_coll[$my_coll_rate][
'ddate_end'][$id],
284 'totalht' => $x_coll[$my_coll_rate][
'totalht_list'][$id],
285 'vat' => $x_coll[$my_coll_rate][
'vat_list'][$id],
286 'link' => $invoice_customer->getNomUrl(1,
'', 12)
291 foreach (array_keys($x_paye) as $my_paye_rate) {
292 $x_both[$my_paye_rate][
'paye'][
'totalht'] = $x_paye[$my_paye_rate][
'totalht'];
293 $x_both[$my_paye_rate][
'paye'][
'vat'] = $x_paye[$my_paye_rate][
'vat'];
294 if (!isset($x_both[$my_paye_rate][
'coll'][
'totalht'])) {
295 $x_both[$my_paye_rate][
'coll'][
'totalht'] = 0;
296 $x_both[$my_paye_rate][
'coll'][
'vat'] = 0;
298 $x_both[$my_paye_rate][
'paye'][
'links'] =
'';
299 $x_both[$my_paye_rate][
'paye'][
'detail'] = array();
301 foreach ($x_paye[$my_paye_rate][
'facid'] as $id => $dummy) {
303 if ($x_paye[$my_paye_rate][
'ptype'][$id] ===
'ExpenseReportPayment') {
304 $expensereport->id = $x_paye[$my_paye_rate][
'facid'][$id];
305 $expensereport->ref = $x_paye[$my_paye_rate][
'facnum'][$id];
306 $expensereport->type = $x_paye[$my_paye_rate][
'type'][$id];
308 $x_both[$my_paye_rate][
'paye'][
'detail'][] = array(
309 'id' => $x_paye[$my_paye_rate][
'facid'][$id],
310 'descr' => $x_paye[$my_paye_rate][
'descr'][$id],
311 'pid' => $x_paye[$my_paye_rate][
'pid'][$id],
312 'pref' => $x_paye[$my_paye_rate][
'pref'][$id],
313 'ptype' => $x_paye[$my_paye_rate][
'ptype'][$id],
314 'payment_id' => $x_paye[$my_paye_rate][
'payment_id'][$id],
315 'payment_ref' => $x_paye[$my_paye_rate][
'payment_ref'][$id],
316 'payment_amount' => $x_paye[$my_paye_rate][
'payment_amount'][$id],
317 'ftotal_ttc' =>
price2num($x_paye[$my_paye_rate][
'ftotal_ttc'][$id]),
318 'dtotal_ttc' =>
price2num($x_paye[$my_paye_rate][
'dtotal_ttc'][$id]),
319 'dtype' => $x_paye[$my_paye_rate][
'dtype'][$id],
320 'ddate_start' => $x_paye[$my_paye_rate][
'ddate_start'][$id],
321 'ddate_end' => $x_paye[$my_paye_rate][
'ddate_end'][$id],
322 'totalht' =>
price2num($x_paye[$my_paye_rate][
'totalht_list'][$id]),
323 'vat' => $x_paye[$my_paye_rate][
'vat_list'][$id],
324 'link' => $expensereport->getNomUrl(1)
327 $invoice_supplier->id = $x_paye[$my_paye_rate][
'facid'][$id];
328 $invoice_supplier->ref = $x_paye[$my_paye_rate][
'facnum'][$id];
329 $invoice_supplier->type = $x_paye[$my_paye_rate][
'type'][$id];
331 $company_static->id = $x_paye[$my_paye_rate][
'company_id'][$id];
332 $company_static->name = $x_paye[$my_paye_rate][
'company_name'][$id];
333 $company_static->name_alias = $x_paye[$my_paye_rate][
'company_alias'][$id];
334 $company_static->email = $x_paye[$my_paye_rate][
'company_email'][$id];
335 $company_static->tva_intra = $x_paye[$my_paye_rate][
'tva_intra'][$id];
336 $company_static->client = $x_paye[$my_paye_rate][
'company_client'][$id];
337 $company_static->fournisseur = $x_paye[$my_paye_rate][
'company_fournisseur'][$id];
338 $company_static->status = $x_paye[$my_paye_rate][
'company_status'][$id];
339 $company_static->code_client = $x_paye[$my_paye_rate][
'company_customer_code'][$id];
340 $company_static->code_compta_client = $x_paye[$my_paye_rate][
'company_customer_accounting_code'][$id];
341 $company_static->code_fournisseur = $x_paye[$my_paye_rate][
'company_supplier_code'][$id];
342 $company_static->code_compta_fournisseur = $x_paye[$my_paye_rate][
'company_supplier_accounting_code'][$id];
344 $x_both[$my_paye_rate][
'paye'][
'detail'][] = array(
345 'id' => $x_paye[$my_paye_rate][
'facid'][$id],
346 'descr' => $x_paye[$my_paye_rate][
'descr'][$id],
347 'pid' => $x_paye[$my_paye_rate][
'pid'][$id],
348 'pref' => $x_paye[$my_paye_rate][
'pref'][$id],
349 'ptype' => $x_paye[$my_paye_rate][
'ptype'][$id],
350 'payment_id' => $x_paye[$my_paye_rate][
'payment_id'][$id],
351 'payment_ref' => $x_paye[$my_paye_rate][
'payment_ref'][$id],
352 'payment_amount' => $x_paye[$my_paye_rate][
'payment_amount'][$id],
353 'ftotal_ttc' =>
price2num($x_paye[$my_paye_rate][
'ftotal_ttc'][$id]),
354 'dtotal_ttc' =>
price2num($x_paye[$my_paye_rate][
'dtotal_ttc'][$id]),
355 'dtype' => $x_paye[$my_paye_rate][
'dtype'][$id],
356 'datef' => $x_paye[$my_paye_rate][
'datef'][$id],
357 'datep' => $x_paye[$my_paye_rate][
'datep'][$id],
359 'company_link' => $company_static->getNomUrl(1,
'', 20),
361 'ddate_start' => $x_paye[$my_paye_rate][
'ddate_start'][$id],
362 'ddate_end' => $x_paye[$my_paye_rate][
'ddate_end'][$id],
363 'totalht' =>
price2num($x_paye[$my_paye_rate][
'totalht_list'][$id]),
364 'vat' => $x_paye[$my_paye_rate][
'vat_list'][$id],
365 'link' => $invoice_supplier->getNomUrl(1,
'', 12)
383 print
'<tr class="liste_titre">';
384 print
'<td class="left">' . $elementcust .
'</td>';
385 print
'<td class="left">' . $langs->trans(
"DateInvoice") .
'</td>';
387 print
'<td class="left">' . $langs->trans(
"DatePayment") .
'</td>';
391 print
'<td class="left">' . $namecust .
'</td>';
392 print
'<td class="left">' . $productcust .
'</td>';
394 print
'<td class="right">' . $amountcust .
'</td>';
395 print
'<td class="right">' . $langs->trans(
"Payment") .
' (' . $langs->trans(
"PercentOfInvoice") .
')</td>';
397 print
'<td class="right">' . $langs->trans(
"AmountHTVATRealReceived") .
'</td>';
398 print
'<td class="right">' . $vatcust .
'</td>';
401 $action =
"tvadetail";
402 $parameters[
"mode"] = $modetax;
403 $parameters[
"start"] = $date_start;
404 $parameters[
"end"] = $date_end;
405 $parameters[
"type"] =
'vat';
407 $object = array(&$x_coll, &$x_paye, &$x_both);
409 $hookmanager->initHooks(array(
'externalbalance'));
410 $reshook = $hookmanager->executeHooks(
'addVatLine', $parameters, $object, $action);
412 foreach (array_keys($x_coll) as $rate) {
413 $subtot_coll_total_ht = 0;
414 $subtot_coll_vat = 0;
416 if (is_array($x_both[$rate][
'coll'][
'detail'])) {
419 print
'<td class="tax_rate" colspan="' . ($span + 1) .
'">';
420 print $langs->trans(
'Rate') .
' : ' .
vatrate($rate) .
'%';
421 print
' - <a class="reposition" href="' . DOL_URL_ROOT .
'/compta/tva/quadri_detail.php?invoice_type=customer';
422 if ($invoice_type !=
'customer' || !GETPOSTISSET(
'vat_rate_show') ||
GETPOST(
'vat_rate_show') != $rate) {
423 print
'&vat_rate_show=' . urlencode($rate);
425 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>';
427 print
'</tr>' .
"\n";
429 foreach ($x_both[$rate][
'coll'][
'detail'] as $index => $fields) {
432 $type = (isset($fields[
'dtype']) ? $fields[
'dtype'] : $fields[
'ptype']);
435 if (!empty($fields[
'ddate_start'])) {
438 if (!empty($fields[
'ddate_end'])) {
443 $ratiopaymentinvoice = 1;
448 if (isset($fields[
'payment_amount']) &&
price2num($fields[
'ftotal_ttc'])) {
449 $ratiopaymentinvoice = ($fields[
'payment_amount'] / $fields[
'ftotal_ttc']);
455 $temp_ht = $fields[
'totalht'] * $ratiopaymentinvoice;
458 $temp_vat = $fields[
'vat'] * $ratiopaymentinvoice;
460 $subtot_coll_total_ht += $temp_ht;
461 $subtot_coll_vat += $temp_vat;
462 $x_coll_sum += $temp_vat;
466 if ($invoice_type ==
'customer' && $vat_rate_show == $rate) {
467 if (is_array($x_both[$rate][
'coll'][
'detail'])) {
468 foreach ($x_both[$rate][
'coll'][
'detail'] as $index => $fields) {
484 $type = (isset($fields[
'dtype']) ? $fields[
'dtype'] : $fields[
'ptype']);
487 if (!empty($fields[
'ddate_start'])) {
490 if (!empty($fields[
'ddate_end'])) {
495 print
'<tr class="oddeven">';
498 print
'<td class="nowrap left">' . $fields[
'link'] .
'</td>';
501 print
'<td class="left">' .
dol_print_date($fields[
'datef'],
'day') .
'</td>';
505 print
'<td class="left">' .
dol_print_date($fields[
'datep'],
'day') .
'</td>';
511 print
'<td class="tdmaxoverflow150">';
513 print $fields[
'company_link'];
517 print
'<td class="left">';
518 if ($fields[
'pid']) {
519 $product_static->id = $fields[
'pid'];
520 $product_static->ref = $fields[
'pref'];
521 $product_static->type = $fields[
'dtype'];
522 print $product_static->getNomUrl(1);
528 $text =
img_object($langs->trans(
'Service'),
'service');
530 $text =
img_object($langs->trans(
'Product'),
'product');
532 if (preg_match(
'/^\((.*)\)$/', $fields[
'descr'], $reg)) {
533 if ($reg[1] ==
'DEPOSIT') {
534 $fields[
'descr'] = $langs->transnoentitiesnoconv(
'Deposit');
535 } elseif ($reg[1] ==
'CREDIT_NOTE') {
536 $fields[
'descr'] = $langs->transnoentitiesnoconv(
'CreditNote');
538 $fields[
'descr'] = $langs->transnoentitiesnoconv($reg[1]);
550 print
'<td class="nowrap right">';
551 print
price($fields[
'totalht']);
554 $ratiolineinvoice = ($fields[
'dtotal_ttc'] / $fields[
'ftotal_ttc']);
561 $ratiopaymentinvoice = 1;
563 print
'<td class="nowrap right">';
565 if ($fields[
'payment_amount'] && $fields[
'ftotal_ttc']) {
566 $payment_static->id = $fields[
'payment_id'];
567 $payment_static->ref = $fields[
'payment_ref'];
568 print $payment_static->getNomUrl(2,
'',
'', 0) .
' ';
572 print $langs->trans(
"NA");
574 if (isset($fields[
'payment_amount']) &&
price2num($fields[
'ftotal_ttc'])) {
575 $ratiopaymentinvoice = ($fields[
'payment_amount'] / $fields[
'ftotal_ttc']);
578 if (isset($fields[
'payment_amount'])) {
579 print
' (' . round($ratiopaymentinvoice * 100, 2) .
'%)';
586 print
'<td class="nowrap right">';
587 $temp_ht = $fields[
'totalht'] * $ratiopaymentinvoice;
592 print
'<td class="nowrap right">';
593 $temp_vat = $fields[
'vat'] * $ratiopaymentinvoice;
606 print
'<tr class="liste_total">';
607 print
'<td colspan="4"></td>';
608 print
'<td class="right">' . $langs->trans(
"Total") .
':</td>';
610 print
'<td class="nowrap right"> </td>';
611 print
'<td class="right"> </td>';
613 print
'<td class="right"><span class="amount">' .
price(
price2num($subtot_coll_total_ht,
'MT')) .
'</span></td>';
614 print
'<td class="nowrap right"><span class="amount">' .
price(
price2num($subtot_coll_vat,
'MT')) .
'</span></td>';
618 if (count($x_coll) == 0) {
619 print
'<tr class="liste_total">';
620 print
'<td colspan="4"></td>';
621 print
'<td class="right">' . $langs->trans(
"Total") .
':</td>';
623 print
'<td class="nowrap right"> </td>';
624 print
'<td class="right"> </td>';
627 print
'<td class="nowrap right">' .
price(
price2num(0,
'MT')) .
'</td>';
632 print
'<tr><td colspan="' . ($span + 2) .
'"> </td></tr>';
635 print
'<tr class="liste_titre liste_titre_topborder">';
636 print
'<td class="left">' . $elementsup .
'</td>';
637 print
'<td class="left">' . $langs->trans(
"DateInvoice") .
'</td>';
639 print
'<td class="left">' . $langs->trans(
"DatePayment") .
'</td>';
643 print
'<td class="left">' . $namesup .
'</td>';
644 print
'<td class="left">' . $productsup .
'</td>';
646 print
'<td class="right">' . $amountsup .
'</td>';
647 print
'<td class="right">' . $langs->trans(
"Payment") .
' (' . $langs->trans(
"PercentOfInvoice") .
')</td>';
649 print
'<td class="right">' . $langs->trans(
"AmountHTVATRealPaid") .
'</td>';
650 print
'<td class="right">' . $vatsup .
'</td>';
651 print
'</tr>' .
"\n";
653 foreach (array_keys($x_paye) as $rate) {
654 $subtot_paye_total_ht = 0;
655 $subtot_paye_vat = 0;
657 if (is_array($x_both[$rate][
'paye'][
'detail'])) {
659 print
'<td class="tax_rate" colspan="' . ($span + 1) .
'">';
660 print $langs->trans(
'Rate') .
' : ' .
vatrate($rate) .
'%';
661 print
' - <a class="reposition" href="' . DOL_URL_ROOT .
'/compta/tva/quadri_detail.php?invoice_type=supplier';
662 if ($invoice_type !=
'supplier' || !GETPOSTISSET(
'vat_rate_show') ||
GETPOST(
'vat_rate_show') != $rate) {
663 print
'&vat_rate_show=' . urlencode($rate);
665 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>';
667 print
'</tr>' .
"\n";
669 foreach ($x_both[$rate][
'paye'][
'detail'] as $index => $fields) {
672 $type = (isset($fields[
'dtype']) ? $fields[
'dtype'] : $fields[
'ptype']);
675 if (!empty($fields[
'ddate_start'])) {
678 if (!empty($fields[
'ddate_end'])) {
683 $ratiopaymentinvoice = 1;
688 if (isset($fields[
'payment_amount']) && $fields[
'ftotal_ttc']) {
689 $ratiopaymentinvoice = ($fields[
'payment_amount'] / (float) $fields[
'ftotal_ttc']);
695 $temp_ht = (float) $fields[
'totalht'] * $ratiopaymentinvoice;
698 $temp_vat = $fields[
'vat'] * $ratiopaymentinvoice;
700 $subtot_paye_total_ht += $temp_ht;
701 $subtot_paye_vat += $temp_vat;
702 $x_paye_sum += $temp_vat;
705 if ($invoice_type ==
'supplier' && $vat_rate_show == $rate) {
706 foreach ($x_both[$rate][
'paye'][
'detail'] as $index => $fields) {
722 $type = (isset($fields[
'dtype']) ? $fields[
'dtype'] : $fields[
'ptype']);
725 if (!empty($fields[
'ddate_start'])) {
728 if (!empty($fields[
'ddate_end'])) {
732 print
'<tr class="oddeven">';
735 print
'<td class="nowrap left">' . $fields[
'link'] .
'</td>';
738 print
'<td class="left">' .
dol_print_date($fields[
'datef'],
'day') .
'</td>';
742 print
'<td class="left">' .
dol_print_date($fields[
'datep'],
'day') .
'</td>';
748 print
'<td class="tdmaxoverflow150">';
750 print $fields[
'company_link'];
754 print
'<td class="left">';
755 if ($fields[
'pid']) {
756 $product_static->id = $fields[
'pid'];
757 $product_static->ref = $fields[
'pref'];
758 $product_static->type = $fields[
'dtype'];
759 print $product_static->getNomUrl(1);
765 $text =
img_object($langs->trans(
'Service'),
'service');
767 $text =
img_object($langs->trans(
'Product'),
'product');
769 if (preg_match(
'/^\((.*)\)$/', $fields[
'descr'], $reg)) {
770 if ($reg[1] ==
'DEPOSIT') {
771 $fields[
'descr'] = $langs->transnoentitiesnoconv(
'Deposit');
772 } elseif ($reg[1] ==
'CREDIT_NOTE') {
773 $fields[
'descr'] = $langs->transnoentitiesnoconv(
'CreditNote');
775 $fields[
'descr'] = $langs->transnoentitiesnoconv($reg[1]);
787 print
'<td class="nowrap right">';
788 print
price($fields[
'totalht']);
791 $ratiolineinvoice = ((float) $fields[
'dtotal_ttc'] / (
float) $fields[
'ftotal_ttc']);
798 $ratiopaymentinvoice = 1;
800 print
'<td class="nowrap right">';
801 if ($fields[
'payment_amount'] && $fields[
'ftotal_ttc']) {
802 $paymentfourn_static->id = $fields[
'payment_id'];
803 $paymentfourn_static->ref = $fields[
'payment_ref'];
804 print $paymentfourn_static->getNomUrl(2,
'',
'', 0) .
' ';
809 print $langs->trans(
"NA");
811 if (isset($fields[
'payment_amount']) && $fields[
'ftotal_ttc']) {
812 $ratiopaymentinvoice = ($fields[
'payment_amount'] / (float) $fields[
'ftotal_ttc']);
815 if (isset($fields[
'payment_amount'])) {
816 print
' (' . round($ratiopaymentinvoice * 100, 2) .
'%)';
823 print
'<td class="nowrap right">';
824 $temp_ht = (float) $fields[
'totalht'] * $ratiopaymentinvoice;
829 print
'<td class="nowrap right">';
830 $temp_vat = $fields[
'vat'] * $ratiopaymentinvoice;
844 print
'<tr class="liste_total">';
845 print
'<td colspan="4"></td>';
846 print
'<td class="right">' . $langs->trans(
"Total") .
':</td>';
848 print
'<td class="nowrap right"> </td>';
849 print
'<td class="right"> </td>';
851 print
'<td class="right"><span class="amount">' .
price(
price2num($subtot_paye_total_ht,
'MT')) .
'</span></td>';
852 print
'<td class="nowrap right"><span class="amount">' .
price(
price2num($subtot_paye_vat,
'MT')) .
'</span></td>';
856 if (count($x_paye) == 0) {
857 print
'<tr class="liste_total">';
858 print
'<td colspan="4"></td>';
859 print
'<td class="right">' . $langs->trans(
"Total") .
':</td>';
861 print
'<td class="nowrap right"> </td>';
862 print
'<td class="right"> </td>';
864 print
'<td class="right"><span class="amount">' .
price(
price2num(0,
'MT')) .
'</span></td>';
865 print
'<td class="nowrap right"><span class="amount">' .
price(
price2num(0,
'MT')) .
'</span></td>';
874 print
'<table class="noborder centpercent">';
875 $diff = $x_coll_sum - $x_paye_sum;
876 print
'<tr class="liste_total">';
877 print
'<td class="liste_total" colspan="' . $span .
'">' . $langs->trans(
"TotalToPay") . ($q ?
', ' . $langs->trans(
"Quadri") .
' ' . $q :
'') .
'</td>';
878 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()
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.
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 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...