33require
'../../main.inc.php';
42require_once DOL_DOCUMENT_ROOT .
'/core/lib/report.lib.php';
43require_once DOL_DOCUMENT_ROOT .
'/core/lib/tax.lib.php';
44require_once DOL_DOCUMENT_ROOT .
'/core/lib/date.lib.php';
45require_once DOL_DOCUMENT_ROOT .
'/compta/tva/class/tva.class.php';
46require_once DOL_DOCUMENT_ROOT .
'/compta/localtax/class/localtax.class.php';
47require_once DOL_DOCUMENT_ROOT .
'/compta/facture/class/facture.class.php';
48require_once DOL_DOCUMENT_ROOT .
'/product/class/product.class.php';
49require_once DOL_DOCUMENT_ROOT .
'/compta/paiement/class/paiement.class.php';
50require_once DOL_DOCUMENT_ROOT .
'/fourn/class/fournisseur.facture.class.php';
51require_once DOL_DOCUMENT_ROOT .
'/fourn/class/paiementfourn.class.php';
52require_once DOL_DOCUMENT_ROOT .
'/expensereport/class/expensereport.class.php';
53require_once DOL_DOCUMENT_ROOT .
'/expensereport/class/paymentexpensereport.class.php';
56$langs->loadLangs(array(
"other",
"compta",
"banks",
"bills",
"companies",
"product",
"trips",
"admin"));
58$refresh = (GETPOSTISSET(
'submit') || GETPOSTISSET(
'vat_rate_show') || GETPOSTISSET(
'invoice_type'));
59$invoice_type = GETPOSTISSET(
'invoice_type') ?
GETPOST(
'invoice_type',
'alpha') :
'';
60$vat_rate_show = GETPOSTISSET(
'vat_rate_show') ?
GETPOST(
'vat_rate_show',
'alphanohtml') : -1;
63include DOL_DOCUMENT_ROOT.
'/compta/tva/initdatesforvat.inc.php';
76@phan-var-force int $date_start
77@phan-var-force int $date_end
78@phan-var-force int $date_start_month
79@phan-var-force int $date_start_year
80@phan-var-force int $date_start_day
81@phan-var-force int $date_end_month
82@phan-var-force int $date_end_year
83@phan-var-force int $date_end_day
84@phan-var-force int $year_current
95if (GETPOSTISSET(
"modetax")) {
107 $socid = $user->socid;
116$form =
new Form($db);
117$company_static =
new Societe($db);
118$invoice_customer =
new Facture($db);
121$product_static =
new Product($db);
126$morequerystring =
'';
127$listofparams = array(
'date_startmonth',
'date_startyear',
'date_startday',
'date_endmonth',
'date_endyear',
'date_endday');
128foreach ($listofparams as $param) {
130 $morequerystring .= ($morequerystring ?
'&' :
'') . $param .
'=' .
GETPOST($param);
134$title = $langs->trans(
"VATReport") .
" " .
dol_print_date($date_start,
'',
'tzserver') .
" -> " .
dol_print_date($date_end,
'',
'tzserver');
135llxHeader(
'', $title,
'',
'', 0, 0,
'',
'', $morequerystring);
141$fsearch =
'<!-- hidden fields for form -->';
142$fsearch .=
'<input type="hidden" name="token" value="' .
newToken() .
'">';
143$fsearch .=
'<input type="hidden" name="modetax" value="' . $modetax .
'">';
149$name = $langs->trans(
"VATReportByRates");
152 $calcmode = $langs->trans(
'OptionVATDefault');
155 $calcmode = $langs->trans(
'OptionVATDebitOption');
158 $calcmode = $langs->trans(
'OptionPaymentForProductAndServices');
160$calcmode .=
' <span class="opacitymedium">(' . $langs->trans(
"TaxModuleSetupToModifyRules", DOL_URL_ROOT .
'/admin/taxes.php') .
')</span>';
162$period = $form->selectDate($date_start,
'date_start', 0, 0, 0,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'',
'',
'tzserver');
164$period .= $form->selectDate($date_end,
'date_end', 0, 0, 0,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'',
'',
'tzserver');
166$description = $fsearch;
170 $description .= $langs->trans(
"RulesVATDueProducts");
173 $description .= $langs->trans(
"RulesVATInProducts");
176 $description .=
'<br>' . $langs->trans(
"RulesVATDueServices");
179 $description .=
'<br>' . $langs->trans(
"RulesVATInServices");
183 $description .=
'<br>' . $langs->trans(
"DepositsAreNotIncluded");
185 $description .=
'<br>' . $langs->trans(
"DepositsAreNotIncluded").
' (for services)';
187 $description .=
'<br>' . $langs->trans(
"DepositsAreNotIncluded").
' (for products)';
192 $description .=
'<br>' . $langs->trans(
"SupplierDepositsAreNotIncluded");
194 $description .=
'<br>' . $langs->trans(
"SupplierDepositsAreNotIncluded").
' (for services)';
196 $description .=
'<br>' . $langs->trans(
"SupplierDepositsAreNotIncluded").
' (for products)';
200 $description .=
'<br>' . $langs->trans(
"ThisIsAnEstimatedValue");
204$elementcust = $langs->trans(
"CustomersInvoices");
205$productcust = $langs->trans(
"ProductOrService");
206$amountcust = $langs->trans(
"AmountHT");
207$vatcust = $langs->trans(
"VATReceived");
208$namecust = $langs->trans(
"Name");
210 $vatcust .=
' (' . $langs->trans(
"VATToPay") .
')';
214$elementsup = $langs->trans(
"SuppliersInvoices");
215$productsup = $productcust;
216$amountsup = $amountcust;
217$vatsup = $langs->trans(
"VATPaid");
220 $vatsup .=
' (' . $langs->trans(
"ToGetBack") .
')';
223$optioncss =
GETPOST(
'optioncss',
'alpha');
227if ($optioncss !=
"print") {
228 report_header($name,
'', $period, $periodlink, $description, $builddate, $exportlink, array(), $calcmode);
231$vatcust = $langs->trans(
"VATReceived");
232$vatsup = $langs->trans(
"VATPaid");
233$vatexpensereport = $langs->trans(
"VATPaid");
237print
'<div class="div-table-responsive">';
238print
'<table class="liste noborder centpercent">';
250$x_coll =
tax_by_rate(
'vat', $db, 0, 0, $date_start, $date_end, $modetax,
'sell');
251$x_paye =
tax_by_rate(
'vat', $db, 0, 0, $date_start, $date_end, $modetax,
'buy');
253if (!is_array($x_coll) || !is_array($x_paye)) {
254 $langs->load(
"errors");
256 print
'<tr><td colspan="' . $columns .
'">' . $langs->trans(
"ErrorNoAccountancyModuleLoaded") .
'</td></tr>';
257 } elseif ($x_coll == -2) {
258 print
'<tr><td colspan="' . $columns .
'">' . $langs->trans(
"FeatureNotYetAvailable") .
'</td></tr>';
260 print
'<tr><td colspan="' . $columns .
'">' . $langs->trans(
"Error") .
'</td></tr>';
265 foreach (array_keys($x_coll) as $my_coll_rate) {
266 $x_both[$my_coll_rate] = array(
270 $x_both[$my_coll_rate][
'coll'][
'totalht'] = $x_coll[$my_coll_rate][
'totalht'];
271 $x_both[$my_coll_rate][
'coll'][
'vat'] = $x_coll[$my_coll_rate][
'vat'];
272 $x_both[$my_coll_rate][
'paye'][
'totalht'] = 0;
273 $x_both[$my_coll_rate][
'paye'][
'vat'] = 0;
274 $x_both[$my_coll_rate][
'coll'][
'links'] =
'';
275 $x_both[$my_coll_rate][
'coll'][
'detail'] = array();
276 foreach ($x_coll[$my_coll_rate][
'facid'] as
$id => $dummy) {
277 $invoice_customer->id = $x_coll[$my_coll_rate][
'facid'][
$id];
278 $invoice_customer->ref = $x_coll[$my_coll_rate][
'facnum'][
$id];
279 $invoice_customer->type = $x_coll[$my_coll_rate][
'type'][
$id];
282 $company_static->id = $x_coll[$my_coll_rate][
'company_id'][
$id];
283 $company_static->name = $x_coll[$my_coll_rate][
'company_name'][
$id];
284 $company_static->name_alias = $x_coll[$my_coll_rate][
'company_alias'][
$id];
285 $company_static->email = $x_coll[$my_coll_rate][
'company_email'][
$id];
286 $company_static->tva_intra = isset($x_coll[$my_coll_rate][
'company_tva_intra'][
$id]) ? $x_coll[$my_coll_rate][
'company_tva_intra'][
$id] :
'0';
287 $company_static->client = $x_coll[$my_coll_rate][
'company_client'][
$id];
288 $company_static->fournisseur = $x_coll[$my_coll_rate][
'company_fournisseur'][
$id];
289 $company_static->status = $x_coll[$my_coll_rate][
'company_status'][
$id];
290 $company_static->code_client = $x_coll[$my_coll_rate][
'company_customer_code'][
$id];
291 $company_static->code_compta_client = $x_coll[$my_coll_rate][
'company_customer_accounting_code'][
$id];
292 $company_static->code_fournisseur = $x_coll[$my_coll_rate][
'company_supplier_code'][
$id];
293 $company_static->code_compta_fournisseur = $x_coll[$my_coll_rate][
'company_supplier_accounting_code'][
$id];
295 $x_both[$my_coll_rate][
'coll'][
'detail'][] = array(
296 'id' => $x_coll[$my_coll_rate][
'facid'][
$id],
297 'descr' => $x_coll[$my_coll_rate][
'descr'][
$id],
298 'pid' => $x_coll[$my_coll_rate][
'pid'][
$id],
299 'pref' => $x_coll[$my_coll_rate][
'pref'][
$id],
300 'ptype' => $x_coll[$my_coll_rate][
'ptype'][
$id],
301 'payment_id' => $x_coll[$my_coll_rate][
'payment_id'][
$id],
302 'payment_ref' => $x_coll[$my_coll_rate][
'payment_ref'][
$id],
303 'payment_amount' => $x_coll[$my_coll_rate][
'payment_amount'][
$id],
304 'ftotal_ttc' => $x_coll[$my_coll_rate][
'ftotal_ttc'][
$id],
305 'dtotal_ttc' => $x_coll[$my_coll_rate][
'dtotal_ttc'][
$id],
306 'dtype' => $x_coll[$my_coll_rate][
'dtype'][
$id],
307 'datef' => $x_coll[$my_coll_rate][
'datef'][
$id],
308 'datep' => $x_coll[$my_coll_rate][
'datep'][
$id],
310 'company_link' => $company_static->getNomUrl(1,
'', 20),
312 'ddate_start' => $x_coll[$my_coll_rate][
'ddate_start'][
$id],
313 'ddate_end' => $x_coll[$my_coll_rate][
'ddate_end'][
$id],
314 'totalht' => $x_coll[$my_coll_rate][
'totalht_list'][
$id],
315 'vat' => $x_coll[$my_coll_rate][
'vat_list'][
$id],
316 'link' => $invoice_customer->getNomUrl(1,
'', 12)
321 foreach (array_keys($x_paye) as $my_paye_rate) {
322 $x_both[$my_paye_rate][
'paye'][
'totalht'] = $x_paye[$my_paye_rate][
'totalht'];
323 $x_both[$my_paye_rate][
'paye'][
'vat'] = $x_paye[$my_paye_rate][
'vat'];
324 if (!isset($x_both[$my_paye_rate][
'coll'][
'totalht'])) {
325 $x_both[$my_paye_rate][
'coll'][
'totalht'] = 0;
326 $x_both[$my_paye_rate][
'coll'][
'vat'] = 0;
328 $x_both[$my_paye_rate][
'paye'][
'links'] =
'';
329 $x_both[$my_paye_rate][
'paye'][
'detail'] = array();
331 foreach ($x_paye[$my_paye_rate][
'facid'] as
$id => $dummy) {
333 if ($x_paye[$my_paye_rate][
'ptype'][
$id] ===
'ExpenseReportPayment') {
334 $expensereport->id = $x_paye[$my_paye_rate][
'facid'][
$id];
335 $expensereport->ref = $x_paye[$my_paye_rate][
'facnum'][
$id];
336 $expensereport->type = $x_paye[$my_paye_rate][
'type'][
$id];
338 $x_both[$my_paye_rate][
'paye'][
'detail'][] = array(
339 'id' => $x_paye[$my_paye_rate][
'facid'][
$id],
340 'descr' => $x_paye[$my_paye_rate][
'descr'][
$id],
341 'pid' => $x_paye[$my_paye_rate][
'pid'][
$id],
342 'pref' => $x_paye[$my_paye_rate][
'pref'][
$id],
343 'ptype' => $x_paye[$my_paye_rate][
'ptype'][
$id],
344 'payment_id' => $x_paye[$my_paye_rate][
'payment_id'][
$id],
345 'payment_ref' => $x_paye[$my_paye_rate][
'payment_ref'][
$id],
346 'payment_amount' => $x_paye[$my_paye_rate][
'payment_amount'][
$id],
347 'ftotal_ttc' =>
price2num($x_paye[$my_paye_rate][
'ftotal_ttc'][
$id]),
348 'dtotal_ttc' =>
price2num($x_paye[$my_paye_rate][
'dtotal_ttc'][
$id]),
349 'dtype' => $x_paye[$my_paye_rate][
'dtype'][
$id],
350 'ddate_start' => $x_paye[$my_paye_rate][
'ddate_start'][
$id],
351 'ddate_end' => $x_paye[$my_paye_rate][
'ddate_end'][
$id],
352 'totalht' =>
price2num($x_paye[$my_paye_rate][
'totalht_list'][
$id]),
353 'vat' => $x_paye[$my_paye_rate][
'vat_list'][
$id],
354 'link' => $expensereport->getNomUrl(1)
357 $invoice_supplier->id = $x_paye[$my_paye_rate][
'facid'][
$id];
358 $invoice_supplier->ref = $x_paye[$my_paye_rate][
'facnum'][
$id];
359 $invoice_supplier->type = $x_paye[$my_paye_rate][
'type'][
$id];
361 $company_static->id = $x_paye[$my_paye_rate][
'company_id'][
$id];
362 $company_static->name = $x_paye[$my_paye_rate][
'company_name'][
$id];
363 $company_static->name_alias = $x_paye[$my_paye_rate][
'company_alias'][
$id];
364 $company_static->email = $x_paye[$my_paye_rate][
'company_email'][
$id];
365 $company_static->tva_intra = $x_paye[$my_paye_rate][
'company_tva_intra'][
$id];
366 $company_static->client = $x_paye[$my_paye_rate][
'company_client'][
$id];
367 $company_static->fournisseur = $x_paye[$my_paye_rate][
'company_fournisseur'][
$id];
368 $company_static->status = $x_paye[$my_paye_rate][
'company_status'][
$id];
369 $company_static->code_client = $x_paye[$my_paye_rate][
'company_customer_code'][
$id];
370 $company_static->code_compta_client = $x_paye[$my_paye_rate][
'company_customer_accounting_code'][
$id];
371 $company_static->code_fournisseur = $x_paye[$my_paye_rate][
'company_supplier_code'][
$id];
372 $company_static->code_compta_fournisseur = $x_paye[$my_paye_rate][
'company_supplier_accounting_code'][
$id];
374 $x_both[$my_paye_rate][
'paye'][
'detail'][] = array(
375 'id' => $x_paye[$my_paye_rate][
'facid'][
$id],
376 'descr' => $x_paye[$my_paye_rate][
'descr'][
$id],
377 'pid' => $x_paye[$my_paye_rate][
'pid'][
$id],
378 'pref' => $x_paye[$my_paye_rate][
'pref'][
$id],
379 'ptype' => $x_paye[$my_paye_rate][
'ptype'][
$id],
380 'payment_id' => $x_paye[$my_paye_rate][
'payment_id'][
$id],
381 'payment_ref' => $x_paye[$my_paye_rate][
'payment_ref'][
$id],
382 'payment_amount' => $x_paye[$my_paye_rate][
'payment_amount'][
$id],
383 'ftotal_ttc' =>
price2num($x_paye[$my_paye_rate][
'ftotal_ttc'][
$id]),
384 'dtotal_ttc' =>
price2num($x_paye[$my_paye_rate][
'dtotal_ttc'][
$id]),
385 'dtype' => $x_paye[$my_paye_rate][
'dtype'][
$id],
386 'datef' => $x_paye[$my_paye_rate][
'datef'][
$id],
387 'datep' => $x_paye[$my_paye_rate][
'datep'][
$id],
389 'company_link' => $company_static->getNomUrl(1,
'', 20),
391 'ddate_start' => $x_paye[$my_paye_rate][
'ddate_start'][
$id],
392 'ddate_end' => $x_paye[$my_paye_rate][
'ddate_end'][
$id],
393 'totalht' =>
price2num($x_paye[$my_paye_rate][
'totalht_list'][
$id]),
394 'vat' => $x_paye[$my_paye_rate][
'vat_list'][
$id],
395 'link' => $invoice_supplier->getNomUrl(1,
'', 12)
413 print
'<tr class="liste_titre">';
414 print
'<td class="left">' . $elementcust .
'</td>';
415 print
'<td class="left">' . $langs->trans(
"DateInvoice") .
'</td>';
417 print
'<td class="left">' . $langs->trans(
"DatePayment") .
'</td>';
421 print
'<td class="left">' . $namecust .
'</td>';
422 print
'<td class="left">' . $productcust .
'</td>';
424 print
'<td class="right">' . $amountcust .
'</td>';
425 print
'<td class="right">' . $langs->trans(
"Payment") .
' (' . $langs->trans(
"PercentOfInvoice") .
')</td>';
427 print
'<td class="right">' . $langs->trans(
"AmountHTVATRealReceived") .
'</td>';
428 print
'<td class="right">' . $vatcust .
'</td>';
431 $action =
"tvadetail";
432 $parameters[
"mode"] = $modetax;
433 $parameters[
"start"] = $date_start;
434 $parameters[
"end"] = $date_end;
435 $parameters[
"type"] =
'vat';
437 $object = array(&$x_coll, &$x_paye, &$x_both);
439 $hookmanager->initHooks(array(
'externalbalance'));
440 $reshook = $hookmanager->executeHooks(
'addVatLine', $parameters, $object, $action);
442 foreach (array_keys($x_coll) as $rate) {
443 $subtot_coll_total_ht = 0;
444 $subtot_coll_vat = 0;
446 if (is_array($x_both[$rate][
'coll'][
'detail'])) {
449 print
'<td class="tax_rate" colspan="' . ($span + 1) .
'">';
450 print $langs->trans(
'Rate') .
' : ' .
vatrate($rate) .
'%';
451 print
' - <a class="reposition" href="' . DOL_URL_ROOT .
'/compta/tva/quadri_detail.php?invoice_type=customer';
452 if ($invoice_type !=
'customer' || !GETPOSTISSET(
'vat_rate_show') ||
GETPOST(
'vat_rate_show') != $rate) {
453 print
'&vat_rate_show=' . urlencode($rate);
455 print
'&date_startyear=' . ((int) $date_start_year) .
'&date_startmonth=' . ((int) $date_start_month) .
'&date_startday=' . ((int) $date_start_day) .
'&date_endyear=' . ((int) $date_end_year) .
'&date_endmonth=' . ((int) $date_end_month) .
'&date_endday=' . ((int) $date_end_day) .
'">';
456 print
img_picto(
'',
'chevron-down',
'class="paddingrightonly"') . $langs->trans(
'VATReportShowByRateDetails') .
'</a>';
458 print
'</tr>' .
"\n";
460 foreach ($x_both[$rate][
'coll'][
'detail'] as $index => $fields) {
463 $type = (isset($fields[
'dtype']) ? $fields[
'dtype'] : $fields[
'ptype']);
465 if (!empty($fields[
'ddate_start'])) {
468 if (!empty($fields[
'ddate_end'])) {
473 $ratiopaymentinvoice = 1;
478 if (isset($fields[
'payment_amount']) &&
price2num($fields[
'ftotal_ttc'])) {
479 $ratiopaymentinvoice = ($fields[
'payment_amount'] / $fields[
'ftotal_ttc']);
485 $temp_ht = (float) $fields[
'totalht'] * $ratiopaymentinvoice;
488 $temp_vat = $fields[
'vat'] * $ratiopaymentinvoice;
490 $subtot_coll_total_ht += $temp_ht;
491 $subtot_coll_vat += $temp_vat;
492 $x_coll_sum += $temp_vat;
496 if ($invoice_type ==
'customer' && $vat_rate_show == $rate) {
497 if (is_array($x_both[$rate][
'coll'][
'detail'])) {
498 foreach ($x_both[$rate][
'coll'][
'detail'] as $index => $fields) {
514 $type = (isset($fields[
'dtype']) ? $fields[
'dtype'] : $fields[
'ptype']);
516 if (!empty($fields[
'ddate_start'])) {
519 if (!empty($fields[
'ddate_end'])) {
524 print
'<tr class="oddeven">';
527 print
'<td class="nowrap left">' . $fields[
'link'] .
'</td>';
530 print
'<td class="left">' .
dol_print_date($fields[
'datef'],
'day') .
'</td>';
534 print
'<td class="left">' .
dol_print_date($fields[
'datep'],
'day') .
'</td>';
540 print
'<td class="tdoverflowmax150">';
542 print $fields[
'company_link'];
546 print
'<td class="left">';
547 if ($fields[
'pid']) {
548 $product_static->id = $fields[
'pid'];
549 $product_static->ref = $fields[
'pref'];
550 $product_static->type = $fields[
'dtype'];
551 print $product_static->getNomUrl(1);
557 $text =
img_object($langs->trans(
'Service'),
'service');
559 $text =
img_object($langs->trans(
'Product'),
'product');
561 if (preg_match(
'/^\((.*)\)$/', $fields[
'descr'], $reg)) {
562 if ($reg[1] ==
'DEPOSIT') {
563 $fields[
'descr'] = $langs->transnoentitiesnoconv(
'Deposit');
564 } elseif ($reg[1] ==
'CREDIT_NOTE') {
565 $fields[
'descr'] = $langs->transnoentitiesnoconv(
'CreditNote');
567 $fields[
'descr'] = $langs->transnoentitiesnoconv($reg[1]);
579 print
'<td class="nowrap right">';
580 print
price($fields[
'totalht']);
583 $ratiolineinvoice = ($fields[
'dtotal_ttc'] / $fields[
'ftotal_ttc']);
590 $ratiopaymentinvoice = 1;
592 print
'<td class="nowrap right">';
594 if ($fields[
'payment_amount'] && $fields[
'ftotal_ttc']) {
595 $payment_static->id = $fields[
'payment_id'];
596 $payment_static->ref = $fields[
'payment_ref'];
597 print $payment_static->getNomUrl(2,
'',
'', 0) .
' ';
601 print $langs->trans(
"NA");
603 if (isset($fields[
'payment_amount']) &&
price2num($fields[
'ftotal_ttc'])) {
604 $ratiopaymentinvoice = ($fields[
'payment_amount'] / $fields[
'ftotal_ttc']);
607 if (isset($fields[
'payment_amount'])) {
608 print
' (' . round($ratiopaymentinvoice * 100, 2) .
'%)';
615 print
'<td class="nowrap right">';
616 $temp_ht = (float) $fields[
'totalht'] * $ratiopaymentinvoice;
621 print
'<td class="nowrap right">';
622 $temp_vat = $fields[
'vat'] * $ratiopaymentinvoice;
635 print
'<tr class="liste_total">';
636 print
'<td colspan="4"></td>';
637 print
'<td class="right">' . $langs->trans(
"Total") .
':</td>';
639 print
'<td class="nowrap right"> </td>';
640 print
'<td class="right"> </td>';
642 print
'<td class="right"><span class="amount">' .
price(
price2num($subtot_coll_total_ht,
'MT')) .
'</span></td>';
643 print
'<td class="nowrap right"><span class="amount">' .
price(
price2num($subtot_coll_vat,
'MT')) .
'</span></td>';
647 if (count($x_coll) == 0) {
648 print
'<tr class="liste_total">';
649 print
'<td colspan="4"></td>';
650 print
'<td class="right">' . $langs->trans(
"Total") .
':</td>';
652 print
'<td class="nowrap right"> </td>';
653 print
'<td class="right"> </td>';
656 print
'<td class="nowrap right">' .
price(
price2num(0,
'MT')) .
'</td>';
661 print
'<tr><td colspan="' . ($span + 2) .
'"> </td></tr>';
664 print
'<tr class="liste_titre liste_titre_topborder">';
665 print
'<td class="left">' . $elementsup .
'</td>';
666 print
'<td class="left">' . $langs->trans(
"DateInvoice") .
'</td>';
668 print
'<td class="left">' . $langs->trans(
"DatePayment") .
'</td>';
672 print
'<td class="left">' . $namesup .
'</td>';
673 print
'<td class="left">' . $productsup .
'</td>';
675 print
'<td class="right">' . $amountsup .
'</td>';
676 print
'<td class="right">' . $langs->trans(
"Payment") .
' (' . $langs->trans(
"PercentOfInvoice") .
')</td>';
678 print
'<td class="right">' . $langs->trans(
"AmountHTVATRealPaid") .
'</td>';
679 print
'<td class="right">' . $vatsup .
'</td>';
680 print
'</tr>' .
"\n";
682 foreach (array_keys($x_paye) as $rate) {
683 $subtot_paye_total_ht = 0;
684 $subtot_paye_vat = 0;
686 if (is_array($x_both[$rate][
'paye'][
'detail'])) {
688 print
'<td class="tax_rate" colspan="' . ($span + 1) .
'">';
689 print $langs->trans(
'Rate') .
' : ' .
vatrate($rate) .
'%';
690 print
' - <a class="reposition" href="' . DOL_URL_ROOT .
'/compta/tva/quadri_detail.php?invoice_type=supplier';
691 if ($invoice_type !=
'supplier' || !GETPOSTISSET(
'vat_rate_show') ||
GETPOST(
'vat_rate_show') != $rate) {
692 print
'&vat_rate_show=' . urlencode($rate);
694 print
'&date_startyear=' . ((int) $date_start_year) .
'&date_startmonth=' . ((int) $date_start_month) .
'&date_startday=' . ((int) $date_start_day) .
'&date_endyear=' . ((int) $date_end_year) .
'&date_endmonth=' . ((int) $date_end_month) .
'&date_endday=' . ((int) $date_end_day) .
'">';
695 print
img_picto(
'',
'chevron-down',
'class="paddingrightonly"') . $langs->trans(
'VATReportShowByRateDetails') .
'</a>';
697 print
'</tr>' .
"\n";
699 foreach ($x_both[$rate][
'paye'][
'detail'] as $index => $fields) {
702 $type = (isset($fields[
'dtype']) ? $fields[
'dtype'] : $fields[
'ptype']);
704 if (!empty($fields[
'ddate_start'])) {
707 if (!empty($fields[
'ddate_end'])) {
712 $ratiopaymentinvoice = 1;
717 if (isset($fields[
'payment_amount']) && $fields[
'ftotal_ttc']) {
718 $ratiopaymentinvoice = ($fields[
'payment_amount'] / (float) $fields[
'ftotal_ttc']);
724 $temp_ht = (float) $fields[
'totalht'] * $ratiopaymentinvoice;
727 $temp_vat = $fields[
'vat'] * $ratiopaymentinvoice;
729 $subtot_paye_total_ht += $temp_ht;
730 $subtot_paye_vat += $temp_vat;
731 $x_paye_sum += $temp_vat;
734 if ($invoice_type ==
'supplier' && $vat_rate_show == $rate) {
735 foreach ($x_both[$rate][
'paye'][
'detail'] as $index => $fields) {
751 $type = (isset($fields[
'dtype']) ? $fields[
'dtype'] : $fields[
'ptype']);
753 if (!empty($fields[
'ddate_start'])) {
756 if (!empty($fields[
'ddate_end'])) {
760 print
'<tr class="oddeven">';
763 print
'<td class="nowrap left">' . $fields[
'link'] .
'</td>';
766 print
'<td class="left">' .
dol_print_date($fields[
'datef'],
'day') .
'</td>';
770 print
'<td class="left">' .
dol_print_date($fields[
'datep'],
'day') .
'</td>';
776 print
'<td class="tdoverflowmax150">';
778 print $fields[
'company_link'];
782 print
'<td class="left">';
783 if ($fields[
'pid']) {
784 $product_static->id = $fields[
'pid'];
785 $product_static->ref = $fields[
'pref'];
786 $product_static->type = $fields[
'dtype'];
787 print $product_static->getNomUrl(1);
793 $text =
img_object($langs->trans(
'Service'),
'service');
795 $text =
img_object($langs->trans(
'Product'),
'product');
797 if (preg_match(
'/^\((.*)\)$/', $fields[
'descr'], $reg)) {
798 if ($reg[1] ==
'DEPOSIT') {
799 $fields[
'descr'] = $langs->transnoentitiesnoconv(
'Deposit');
800 } elseif ($reg[1] ==
'CREDIT_NOTE') {
801 $fields[
'descr'] = $langs->transnoentitiesnoconv(
'CreditNote');
803 $fields[
'descr'] = $langs->transnoentitiesnoconv($reg[1]);
815 print
'<td class="nowrap right">';
816 print
price($fields[
'totalht']);
819 $ratiolineinvoice = ((float) $fields[
'dtotal_ttc'] / (
float) $fields[
'ftotal_ttc']);
826 $ratiopaymentinvoice = 1;
828 print
'<td class="nowrap right">';
829 if ($fields[
'payment_amount'] && $fields[
'ftotal_ttc']) {
830 $paymentfourn_static->id = $fields[
'payment_id'];
831 $paymentfourn_static->ref = $fields[
'payment_ref'];
832 print $paymentfourn_static->getNomUrl(2,
'',
'', 0) .
' ';
837 print $langs->trans(
"NA");
839 if (isset($fields[
'payment_amount']) && $fields[
'ftotal_ttc']) {
840 $ratiopaymentinvoice = ($fields[
'payment_amount'] / (float) $fields[
'ftotal_ttc']);
843 if (isset($fields[
'payment_amount'])) {
844 print
' (' . round($ratiopaymentinvoice * 100, 2) .
'%)';
851 print
'<td class="nowrap right">';
852 $temp_ht = (float) $fields[
'totalht'] * $ratiopaymentinvoice;
857 print
'<td class="nowrap right">';
858 $temp_vat = $fields[
'vat'] * $ratiopaymentinvoice;
872 print
'<tr class="liste_total">';
873 print
'<td colspan="4"></td>';
874 print
'<td class="right">' . $langs->trans(
"Total") .
':</td>';
876 print
'<td class="nowrap right"> </td>';
877 print
'<td class="right"> </td>';
879 print
'<td class="right"><span class="amount">' .
price(
price2num($subtot_paye_total_ht,
'MT')) .
'</span></td>';
880 print
'<td class="nowrap right"><span class="amount">' .
price(
price2num($subtot_paye_vat,
'MT')) .
'</span></td>';
884 if (count($x_paye) == 0) {
885 print
'<tr class="liste_total">';
886 print
'<td colspan="4"></td>';
887 print
'<td class="right">' . $langs->trans(
"Total") .
':</td>';
889 print
'<td class="nowrap right"> </td>';
890 print
'<td class="right"> </td>';
892 print
'<td class="right"><span class="amount">' .
price(
price2num(0,
'MT')) .
'</span></td>';
893 print
'<td class="nowrap right"><span class="amount">' .
price(
price2num(0,
'MT')) .
'</span></td>';
902 print
'<table class="noborder centpercent">';
903 $diff = $x_coll_sum - $x_paye_sum;
904 print
'<tr class="liste_total">';
905 print
'<td class="liste_total" colspan="' . $span .
'">' . $langs->trans(
"TotalToPay") .
'</td>';
906 print
'<td class="liste_total nowrap right"><b>' .
price(
price2num($diff,
'MT')) .
"</b></td>\n";
$id
Support class for third parties, contacts, members, users or resources.
if(! $sortfield) if(! $sortorder) $object
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Class to manage Trips and Expenses.
Class to manage suppliers invoices.
Class to manage invoices.
Class to manage payments for supplier invoices.
Class to manage payments of customer invoices.
Class to manage payments of expense report.
Class to manage products or services.
Class to manage third parties objects (customers, suppliers, prospects...)
Class to manage VAT - Value-added tax (also known in French as TVA - Taxe sur la valeur ajoutée)
dol_now($mode='gmt')
Return date for now.
vatrate($rate, $addpercent=false, $info_bits=0, $usestarfornpr=0, $html=0)
Return a string with VAT rate label formatted for view output Used into pdf and HTML pages.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2, $allowothertags=array())
Show picto whatever it's its name (generic function)
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_string_nohtmltag($stringtoclean, $removelinefeed=1, $pagecodeto='UTF-8', $strip_tags=0, $removedoublespaces=1)
Clean a string from all HTML tags and entities.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $allowothertags=array())
Show a picto called object_picto (generic function)
price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code='')
Function to format a value into an amount for visual output Function used into PDF and HTML pages.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
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_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false, $decorate=0)
Output date in a string format according to outputlangs (or langs if not defined).
dol_trunc($string, $size=40, $trunc='right', $stringencoding='UTF-8', $nodot=0, $display=0)
Truncate a string to a particular length adding '…' if string larger than length.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
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...