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'));
51$invoice_type = GETPOSTISSET(
'invoice_type') ?
GETPOST(
'invoice_type',
'alpha') :
'';
52$vat_rate_show = GETPOSTISSET(
'vat_rate_show') ?
GETPOST(
'vat_rate_show',
'alphanohtml') : -1;
54include DOL_DOCUMENT_ROOT .
'/compta/tva/initdatesforvat.inc.php';
57@phan-var-force int $date_start
58@phan-var-force int $date_end
59@phan-var-force string $date_start_month
60@phan-var-force string $date_start_year
61@phan-var-force string $date_start_day
62@phan-var-force string $date_end_month
63@phan-var-force string $date_end_year
64@phan-var-force string $date_end_day
75if (GETPOSTISSET(
"modetax")) {
87 $socid = $user->socid;
97$company_static =
new Societe($db);
98$invoice_customer =
new Facture($db);
101$product_static =
new Product($db);
106$morequerystring =
'';
107$listofparams = array(
'date_startmonth',
'date_startyear',
'date_startday',
'date_endmonth',
'date_endyear',
'date_endday');
108foreach ($listofparams as $param) {
110 $morequerystring .= ($morequerystring ?
'&' :
'') . $param .
'=' .
GETPOST($param);
114$title = $langs->trans(
"VATReport") .
" " .
dol_print_date($date_start,
'',
'tzserver') .
" -> " .
dol_print_date($date_end,
'',
'tzserver');
115llxHeader(
'', $title,
'',
'', 0, 0,
'',
'', $morequerystring);
121$fsearch =
'<!-- hidden fields for form -->';
122$fsearch .=
'<input type="hidden" name="token" value="' .
newToken() .
'">';
123$fsearch .=
'<input type="hidden" name="modetax" value="' . $modetax .
'">';
129$name = $langs->trans(
"VATReportByRates");
132 $calcmode = $langs->trans(
'OptionVATDefault');
135 $calcmode = $langs->trans(
'OptionVATDebitOption');
138 $calcmode = $langs->trans(
'OptionPaymentForProductAndServices');
140$calcmode .=
' <span class="opacitymedium">(' . $langs->trans(
"TaxModuleSetupToModifyRules", DOL_URL_ROOT .
'/admin/taxes.php') .
')</span>';
142$period = $form->selectDate($date_start,
'date_start', 0, 0, 0,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'',
'',
'tzserver');
144$period .= $form->selectDate($date_end,
'date_end', 0, 0, 0,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'',
'',
'tzserver');
145$prevyear = $date_start_year;
148if ($prevquarter > 1) {
154$nextyear = $date_start_year;
156if ($nextquarter < 4) {
162$description = $fsearch;
166 $description .= $langs->trans(
"RulesVATDueProducts");
169 $description .= $langs->trans(
"RulesVATInProducts");
172 $description .=
'<br>' . $langs->trans(
"RulesVATDueServices");
175 $description .=
'<br>' . $langs->trans(
"RulesVATInServices");
178 $description .=
'<br>' . $langs->trans(
"DepositsAreNotIncluded");
181 $description .= $langs->trans(
"SupplierDepositsAreNotIncluded");
183if (isModEnabled(
'accounting')) {
184 $description .=
'<br>' . $langs->trans(
"ThisIsAnEstimatedValue");
188$elementcust = $langs->trans(
"CustomersInvoices");
189$productcust = $langs->trans(
"ProductOrService");
190$amountcust = $langs->trans(
"AmountHT");
191$vatcust = $langs->trans(
"VATReceived");
192$namecust = $langs->trans(
"Name");
193if ($mysoc->tva_assuj) {
194 $vatcust .=
' (' . $langs->trans(
"VATToPay") .
')';
198$elementsup = $langs->trans(
"SuppliersInvoices");
199$productsup = $productcust;
200$amountsup = $amountcust;
201$vatsup = $langs->trans(
"VATPaid");
203if ($mysoc->tva_assuj) {
204 $vatsup .=
' (' . $langs->trans(
"ToGetBack") .
')';
207$optioncss =
GETPOST(
'optioncss',
'alpha');
211if ($optioncss !=
"print") {
212 report_header($name,
'', $period, $periodlink, $description, $builddate, $exportlink, array(), $calcmode);
215$vatcust = $langs->trans(
"VATReceived");
216$vatsup = $langs->trans(
"VATPaid");
217$vatexpensereport = $langs->trans(
"VATPaid");
221print
'<div class="div-table-responsive">';
222print
'<table class="liste noborder centpercent">';
234$x_coll =
tax_by_rate(
'vat', $db, 0, 0, $date_start, $date_end, $modetax,
'sell');
235$x_paye =
tax_by_rate(
'vat', $db, 0, 0, $date_start, $date_end, $modetax,
'buy');
237if (!is_array($x_coll) || !is_array($x_paye)) {
238 $langs->load(
"errors");
240 print
'<tr><td colspan="' . $columns .
'">' . $langs->trans(
"ErrorNoAccountancyModuleLoaded") .
'</td></tr>';
241 } elseif ($x_coll == -2) {
242 print
'<tr><td colspan="' . $columns .
'">' . $langs->trans(
"FeatureNotYetAvailable") .
'</td></tr>';
244 print
'<tr><td colspan="' . $columns .
'">' . $langs->trans(
"Error") .
'</td></tr>';
249 foreach (array_keys($x_coll) as $my_coll_rate) {
250 $x_both[$my_coll_rate] = array(
254 $x_both[$my_coll_rate][
'coll'][
'totalht'] = $x_coll[$my_coll_rate][
'totalht'];
255 $x_both[$my_coll_rate][
'coll'][
'vat'] = $x_coll[$my_coll_rate][
'vat'];
256 $x_both[$my_coll_rate][
'paye'][
'totalht'] = 0;
257 $x_both[$my_coll_rate][
'paye'][
'vat'] = 0;
258 $x_both[$my_coll_rate][
'coll'][
'links'] =
'';
259 $x_both[$my_coll_rate][
'coll'][
'detail'] = array();
260 foreach ($x_coll[$my_coll_rate][
'facid'] as
$id => $dummy) {
261 $invoice_customer->id = $x_coll[$my_coll_rate][
'facid'][
$id];
262 $invoice_customer->ref = $x_coll[$my_coll_rate][
'facnum'][
$id];
263 $invoice_customer->type = $x_coll[$my_coll_rate][
'type'][
$id];
266 $company_static->id = $x_coll[$my_coll_rate][
'company_id'][
$id];
267 $company_static->name = $x_coll[$my_coll_rate][
'company_name'][
$id];
268 $company_static->name_alias = $x_coll[$my_coll_rate][
'company_alias'][
$id];
269 $company_static->email = $x_coll[$my_coll_rate][
'company_email'][
$id];
270 $company_static->tva_intra = isset($x_coll[$my_coll_rate][
'tva_intra'][
$id]) ? $x_coll[$my_coll_rate][
'tva_intra'][
$id] :
'0';
271 $company_static->client = $x_coll[$my_coll_rate][
'company_client'][
$id];
272 $company_static->fournisseur = $x_coll[$my_coll_rate][
'company_fournisseur'][
$id];
273 $company_static->status = $x_coll[$my_coll_rate][
'company_status'][
$id];
274 $company_static->code_client = $x_coll[$my_coll_rate][
'company_customer_code'][
$id];
275 $company_static->code_compta_client = $x_coll[$my_coll_rate][
'company_customer_accounting_code'][
$id];
276 $company_static->code_fournisseur = $x_coll[$my_coll_rate][
'company_supplier_code'][
$id];
277 $company_static->code_compta_fournisseur = $x_coll[$my_coll_rate][
'company_supplier_accounting_code'][
$id];
279 $x_both[$my_coll_rate][
'coll'][
'detail'][] = array(
280 'id' => $x_coll[$my_coll_rate][
'facid'][
$id],
281 'descr' => $x_coll[$my_coll_rate][
'descr'][
$id],
282 'pid' => $x_coll[$my_coll_rate][
'pid'][
$id],
283 'pref' => $x_coll[$my_coll_rate][
'pref'][
$id],
284 'ptype' => $x_coll[$my_coll_rate][
'ptype'][
$id],
285 'payment_id' => $x_coll[$my_coll_rate][
'payment_id'][
$id],
286 'payment_ref' => $x_coll[$my_coll_rate][
'payment_ref'][
$id],
287 'payment_amount' => $x_coll[$my_coll_rate][
'payment_amount'][
$id],
288 'ftotal_ttc' => $x_coll[$my_coll_rate][
'ftotal_ttc'][
$id],
289 'dtotal_ttc' => $x_coll[$my_coll_rate][
'dtotal_ttc'][
$id],
290 'dtype' => $x_coll[$my_coll_rate][
'dtype'][
$id],
291 'datef' => $x_coll[$my_coll_rate][
'datef'][
$id],
292 'datep' => $x_coll[$my_coll_rate][
'datep'][
$id],
294 'company_link' => $company_static->getNomUrl(1,
'', 20),
296 'ddate_start' => $x_coll[$my_coll_rate][
'ddate_start'][
$id],
297 'ddate_end' => $x_coll[$my_coll_rate][
'ddate_end'][
$id],
298 'totalht' => $x_coll[$my_coll_rate][
'totalht_list'][
$id],
299 'vat' => $x_coll[$my_coll_rate][
'vat_list'][
$id],
300 'link' => $invoice_customer->getNomUrl(1,
'', 12)
305 foreach (array_keys($x_paye) as $my_paye_rate) {
306 $x_both[$my_paye_rate][
'paye'][
'totalht'] = $x_paye[$my_paye_rate][
'totalht'];
307 $x_both[$my_paye_rate][
'paye'][
'vat'] = $x_paye[$my_paye_rate][
'vat'];
308 if (!isset($x_both[$my_paye_rate][
'coll'][
'totalht'])) {
309 $x_both[$my_paye_rate][
'coll'][
'totalht'] = 0;
310 $x_both[$my_paye_rate][
'coll'][
'vat'] = 0;
312 $x_both[$my_paye_rate][
'paye'][
'links'] =
'';
313 $x_both[$my_paye_rate][
'paye'][
'detail'] = array();
315 foreach ($x_paye[$my_paye_rate][
'facid'] as
$id => $dummy) {
317 if ($x_paye[$my_paye_rate][
'ptype'][
$id] ==
'ExpenseReportPayment') {
318 $expensereport->id = $x_paye[$my_paye_rate][
'facid'][
$id];
319 $expensereport->ref = $x_paye[$my_paye_rate][
'facnum'][
$id];
320 $expensereport->type = $x_paye[$my_paye_rate][
'type'][
$id];
322 $x_both[$my_paye_rate][
'paye'][
'detail'][] = array(
323 'id' => $x_paye[$my_paye_rate][
'facid'][
$id],
324 'descr' => $x_paye[$my_paye_rate][
'descr'][
$id],
325 'pid' => $x_paye[$my_paye_rate][
'pid'][
$id],
326 'pref' => $x_paye[$my_paye_rate][
'pref'][
$id],
327 'ptype' => $x_paye[$my_paye_rate][
'ptype'][
$id],
328 'payment_id' => $x_paye[$my_paye_rate][
'payment_id'][
$id],
329 'payment_ref' => $x_paye[$my_paye_rate][
'payment_ref'][
$id],
330 'payment_amount' => $x_paye[$my_paye_rate][
'payment_amount'][
$id],
331 'ftotal_ttc' =>
price2num($x_paye[$my_paye_rate][
'ftotal_ttc'][
$id]),
332 'dtotal_ttc' =>
price2num($x_paye[$my_paye_rate][
'dtotal_ttc'][
$id]),
333 'dtype' => $x_paye[$my_paye_rate][
'dtype'][
$id],
334 'ddate_start' => $x_paye[$my_paye_rate][
'ddate_start'][
$id],
335 'ddate_end' => $x_paye[$my_paye_rate][
'ddate_end'][
$id],
336 'totalht' =>
price2num($x_paye[$my_paye_rate][
'totalht_list'][
$id]),
337 'vat' => $x_paye[$my_paye_rate][
'vat_list'][
$id],
338 'link' => $expensereport->getNomUrl(1)
341 $invoice_supplier->id = $x_paye[$my_paye_rate][
'facid'][
$id];
342 $invoice_supplier->ref = $x_paye[$my_paye_rate][
'facnum'][
$id];
343 $invoice_supplier->type = $x_paye[$my_paye_rate][
'type'][
$id];
345 $company_static->id = $x_paye[$my_paye_rate][
'company_id'][
$id];
346 $company_static->name = $x_paye[$my_paye_rate][
'company_name'][
$id];
347 $company_static->name_alias = $x_paye[$my_paye_rate][
'company_alias'][
$id];
348 $company_static->email = $x_paye[$my_paye_rate][
'company_email'][
$id];
349 $company_static->tva_intra = $x_paye[$my_paye_rate][
'tva_intra'][
$id];
350 $company_static->client = $x_paye[$my_paye_rate][
'company_client'][
$id];
351 $company_static->fournisseur = $x_paye[$my_paye_rate][
'company_fournisseur'][
$id];
352 $company_static->status = $x_paye[$my_paye_rate][
'company_status'][
$id];
353 $company_static->code_client = $x_paye[$my_paye_rate][
'company_customer_code'][
$id];
354 $company_static->code_compta_client = $x_paye[$my_paye_rate][
'company_customer_accounting_code'][
$id];
355 $company_static->code_fournisseur = $x_paye[$my_paye_rate][
'company_supplier_code'][
$id];
356 $company_static->code_compta_fournisseur = $x_paye[$my_paye_rate][
'company_supplier_accounting_code'][
$id];
358 $x_both[$my_paye_rate][
'paye'][
'detail'][] = array(
359 'id' => $x_paye[$my_paye_rate][
'facid'][
$id],
360 'descr' => $x_paye[$my_paye_rate][
'descr'][
$id],
361 'pid' => $x_paye[$my_paye_rate][
'pid'][
$id],
362 'pref' => $x_paye[$my_paye_rate][
'pref'][
$id],
363 'ptype' => $x_paye[$my_paye_rate][
'ptype'][
$id],
364 'payment_id' => $x_paye[$my_paye_rate][
'payment_id'][
$id],
365 'payment_ref' => $x_paye[$my_paye_rate][
'payment_ref'][
$id],
366 'payment_amount' => $x_paye[$my_paye_rate][
'payment_amount'][
$id],
367 'ftotal_ttc' =>
price2num($x_paye[$my_paye_rate][
'ftotal_ttc'][
$id]),
368 'dtotal_ttc' =>
price2num($x_paye[$my_paye_rate][
'dtotal_ttc'][
$id]),
369 'dtype' => $x_paye[$my_paye_rate][
'dtype'][
$id],
370 'datef' => $x_paye[$my_paye_rate][
'datef'][
$id],
371 'datep' => $x_paye[$my_paye_rate][
'datep'][
$id],
373 'company_link' => $company_static->getNomUrl(1,
'', 20),
375 'ddate_start' => $x_paye[$my_paye_rate][
'ddate_start'][
$id],
376 'ddate_end' => $x_paye[$my_paye_rate][
'ddate_end'][
$id],
377 'totalht' =>
price2num($x_paye[$my_paye_rate][
'totalht_list'][
$id]),
378 'vat' => $x_paye[$my_paye_rate][
'vat_list'][
$id],
379 'link' => $invoice_supplier->getNomUrl(1,
'', 12)
397 print
'<tr class="liste_titre">';
398 print
'<td class="left">' . $elementcust .
'</td>';
399 print
'<td class="left">' . $langs->trans(
"DateInvoice") .
'</td>';
401 print
'<td class="left">' . $langs->trans(
"DatePayment") .
'</td>';
405 print
'<td class="left">' . $namecust .
'</td>';
406 print
'<td class="left">' . $productcust .
'</td>';
408 print
'<td class="right">' . $amountcust .
'</td>';
409 print
'<td class="right">' . $langs->trans(
"Payment") .
' (' . $langs->trans(
"PercentOfInvoice") .
')</td>';
411 print
'<td class="right">' . $langs->trans(
"AmountHTVATRealReceived") .
'</td>';
412 print
'<td class="right">' . $vatcust .
'</td>';
415 $action =
"tvadetail";
416 $parameters[
"mode"] = $modetax;
417 $parameters[
"start"] = $date_start;
418 $parameters[
"end"] = $date_end;
419 $parameters[
"type"] =
'vat';
421 $object = array(&$x_coll, &$x_paye, &$x_both);
423 $hookmanager->initHooks(array(
'externalbalance'));
424 $reshook = $hookmanager->executeHooks(
'addVatLine', $parameters, $object, $action);
426 foreach (array_keys($x_coll) as $rate) {
427 $subtot_coll_total_ht = 0;
428 $subtot_coll_vat = 0;
430 if (is_array($x_both[$rate][
'coll'][
'detail'])) {
433 print
'<td class="tax_rate" colspan="' . ($span + 1) .
'">';
434 print $langs->trans(
'Rate') .
' : ' .
vatrate($rate) .
'%';
435 print
' - <a href="' . DOL_URL_ROOT .
'/compta/tva/quadri_detail.php?invoice_type=customer';
436 if ($invoice_type !=
'customer' || !GETPOSTISSET(
'vat_rate_show') ||
GETPOST(
'vat_rate_show') != $rate) {
437 print
'&vat_rate_show=' . urlencode($rate);
439 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>';
441 print
'</tr>' .
"\n";
443 foreach ($x_both[$rate][
'coll'][
'detail'] as $index => $fields) {
446 $type = (isset($fields[
'dtype']) ? $fields[
'dtype'] : $fields[
'ptype']);
449 if (!empty($fields[
'ddate_start'])) {
452 if (!empty($fields[
'ddate_end'])) {
457 $ratiopaymentinvoice = 1;
462 if (isset($fields[
'payment_amount']) &&
price2num($fields[
'ftotal_ttc'])) {
463 $ratiopaymentinvoice = ($fields[
'payment_amount'] / $fields[
'ftotal_ttc']);
469 $temp_ht = (float) $fields[
'totalht'] * $ratiopaymentinvoice;
472 $temp_vat = $fields[
'vat'] * $ratiopaymentinvoice;
474 $subtot_coll_total_ht += $temp_ht;
475 $subtot_coll_vat += $temp_vat;
476 $x_coll_sum += $temp_vat;
480 if ($invoice_type ==
'customer' && $vat_rate_show == $rate) {
481 if (is_array($x_both[$rate][
'coll'][
'detail'])) {
482 foreach ($x_both[$rate][
'coll'][
'detail'] as $index => $fields) {
498 $type = (isset($fields[
'dtype']) ? $fields[
'dtype'] : $fields[
'ptype']);
501 if (!empty($fields[
'ddate_start'])) {
504 if (!empty($fields[
'ddate_end'])) {
509 print
'<tr class="oddeven">';
512 print
'<td class="nowrap left">' . $fields[
'link'] .
'</td>';
515 print
'<td class="left">' .
dol_print_date($fields[
'datef'],
'day') .
'</td>';
519 print
'<td class="left">' .
dol_print_date($fields[
'datep'],
'day') .
'</td>';
525 print
'<td class="tdmaxoverflow150">';
527 print $fields[
'company_link'];
531 print
'<td class="left">';
532 if ($fields[
'pid']) {
533 $product_static->id = $fields[
'pid'];
534 $product_static->ref = $fields[
'pref'];
535 $product_static->type = $fields[
'dtype'];
536 print $product_static->getNomUrl(1);
542 $text =
img_object($langs->trans(
'Service'),
'service');
544 $text =
img_object($langs->trans(
'Product'),
'product');
546 if (preg_match(
'/^\((.*)\)$/', $fields[
'descr'], $reg)) {
547 if ($reg[1] ==
'DEPOSIT') {
548 $fields[
'descr'] = $langs->transnoentitiesnoconv(
'Deposit');
549 } elseif ($reg[1] ==
'CREDIT_NOTE') {
550 $fields[
'descr'] = $langs->transnoentitiesnoconv(
'CreditNote');
552 $fields[
'descr'] = $langs->transnoentitiesnoconv($reg[1]);
564 print
'<td class="nowrap right">';
565 print
price($fields[
'totalht']);
568 $ratiolineinvoice = ($fields[
'dtotal_ttc'] / $fields[
'ftotal_ttc']);
575 $ratiopaymentinvoice = 1;
577 print
'<td class="nowrap right">';
579 if ($fields[
'payment_amount'] && $fields[
'ftotal_ttc']) {
580 $payment_static->id = $fields[
'payment_id'];
581 $payment_static->ref = $fields[
'payment_ref'];
582 print $payment_static->getNomUrl(2,
'',
'', 0) .
' ';
586 print $langs->trans(
"NA");
588 if (isset($fields[
'payment_amount']) &&
price2num($fields[
'ftotal_ttc'])) {
589 $ratiopaymentinvoice = ($fields[
'payment_amount'] / $fields[
'ftotal_ttc']);
592 if (isset($fields[
'payment_amount'])) {
593 print
' (' . round($ratiopaymentinvoice * 100, 2) .
'%)';
600 print
'<td class="nowrap right">';
601 $temp_ht = (float) $fields[
'totalht'] * $ratiopaymentinvoice;
606 print
'<td class="nowrap right">';
607 $temp_vat = $fields[
'vat'] * $ratiopaymentinvoice;
620 print
'<tr class="liste_total">';
621 print
'<td colspan="4"></td>';
622 print
'<td class="right">' . $langs->trans(
"Total") .
':</td>';
624 print
'<td class="nowrap right"> </td>';
625 print
'<td class="right"> </td>';
627 print
'<td class="right"><span class="amount">' .
price(
price2num($subtot_coll_total_ht,
'MT')) .
'</span></td>';
628 print
'<td class="nowrap right"><span class="amount">' .
price(
price2num($subtot_coll_vat,
'MT')) .
'</span></td>';
632 if (count($x_coll) == 0) {
633 print
'<tr class="liste_total">';
634 print
'<td colspan="4"></td>';
635 print
'<td class="right">' . $langs->trans(
"Total") .
':</td>';
637 print
'<td class="nowrap right"> </td>';
638 print
'<td class="right"> </td>';
641 print
'<td class="nowrap right">' .
price(
price2num(0,
'MT')) .
'</td>';
646 print
'<tr><td colspan="' . ($span + 2) .
'"> </td></tr>';
649 print
'<tr class="liste_titre liste_titre_topborder">';
650 print
'<td class="left">' . $elementsup .
'</td>';
651 print
'<td class="left">' . $langs->trans(
"DateInvoice") .
'</td>';
653 print
'<td class="left">' . $langs->trans(
"DatePayment") .
'</td>';
657 print
'<td class="left">' . $namesup .
'</td>';
658 print
'<td class="left">' . $productsup .
'</td>';
660 print
'<td class="right">' . $amountsup .
'</td>';
661 print
'<td class="right">' . $langs->trans(
"Payment") .
' (' . $langs->trans(
"PercentOfInvoice") .
')</td>';
663 print
'<td class="right">' . $langs->trans(
"AmountHTVATRealPaid") .
'</td>';
664 print
'<td class="right">' . $vatsup .
'</td>';
665 print
'</tr>' .
"\n";
667 foreach (array_keys($x_paye) as $rate) {
668 $subtot_paye_total_ht = 0;
669 $subtot_paye_vat = 0;
671 if (is_array($x_both[$rate][
'paye'][
'detail'])) {
673 print
'<td class="tax_rate" colspan="' . ($span + 1) .
'">';
674 print $langs->trans(
'Rate') .
' : ' .
vatrate($rate) .
'%';
675 print
' - <a href="' . DOL_URL_ROOT .
'/compta/tva/quadri_detail.php?invoice_type=supplier';
676 if ($invoice_type !=
'supplier' || !GETPOSTISSET(
'vat_rate_show') ||
GETPOST(
'vat_rate_show') != $rate) {
677 print
'&vat_rate_show=' . urlencode($rate);
679 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>';
681 print
'</tr>' .
"\n";
683 foreach ($x_both[$rate][
'paye'][
'detail'] as $index => $fields) {
686 $type = (isset($fields[
'dtype']) ? $fields[
'dtype'] : $fields[
'ptype']);
689 if (!empty($fields[
'ddate_start'])) {
692 if (!empty($fields[
'ddate_end'])) {
697 $ratiopaymentinvoice = 1;
702 if (isset($fields[
'payment_amount']) && $fields[
'ftotal_ttc']) {
703 $ratiopaymentinvoice = ($fields[
'payment_amount'] / (float) $fields[
'ftotal_ttc']);
709 $temp_ht = (float) $fields[
'totalht'] * $ratiopaymentinvoice;
712 $temp_vat = $fields[
'vat'] * $ratiopaymentinvoice;
714 $subtot_paye_total_ht += $temp_ht;
715 $subtot_paye_vat += $temp_vat;
716 $x_paye_sum += $temp_vat;
719 if ($invoice_type ==
'supplier' && $vat_rate_show == $rate) {
720 foreach ($x_both[$rate][
'paye'][
'detail'] as $index => $fields) {
736 $type = (isset($fields[
'dtype']) ? $fields[
'dtype'] : $fields[
'ptype']);
739 if (!empty($fields[
'ddate_start'])) {
742 if (!empty($fields[
'ddate_end'])) {
747 print
'<tr class="oddeven">';
750 print
'<td class="nowrap left">' . $fields[
'link'] .
'</td>';
753 print
'<td class="left">' .
dol_print_date($fields[
'datef'],
'day') .
'</td>';
757 print
'<td class="left">' .
dol_print_date($fields[
'datep'],
'day') .
'</td>';
763 print
'<td class="tdmaxoverflow150">';
765 print $fields[
'company_link'];
769 print
'<td class="left">';
770 if ($fields[
'pid']) {
771 $product_static->id = $fields[
'pid'];
772 $product_static->ref = $fields[
'pref'];
773 $product_static->type = $fields[
'dtype'];
774 print $product_static->getNomUrl(1);
780 $text =
img_object($langs->trans(
'Service'),
'service');
782 $text =
img_object($langs->trans(
'Product'),
'product');
784 if (preg_match(
'/^\((.*)\)$/', $fields[
'descr'], $reg)) {
785 if ($reg[1] ==
'DEPOSIT') {
786 $fields[
'descr'] = $langs->transnoentitiesnoconv(
'Deposit');
787 } elseif ($reg[1] ==
'CREDIT_NOTE') {
788 $fields[
'descr'] = $langs->transnoentitiesnoconv(
'CreditNote');
790 $fields[
'descr'] = $langs->transnoentitiesnoconv($reg[1]);
802 print
'<td class="nowrap right">';
803 print
price($fields[
'totalht']);
806 $ratiolineinvoice = ((float) $fields[
'dtotal_ttc'] / (
float) $fields[
'ftotal_ttc']);
813 $ratiopaymentinvoice = 1;
815 print
'<td class="nowrap right">';
816 if ($fields[
'payment_amount'] && $fields[
'ftotal_ttc']) {
817 $paymentfourn_static->id = $fields[
'payment_id'];
818 $paymentfourn_static->ref = $fields[
'payment_ref'];
819 print $paymentfourn_static->getNomUrl(2,
'',
'', 0) .
' ';
824 print $langs->trans(
"NA");
826 if (isset($fields[
'payment_amount']) && $fields[
'ftotal_ttc']) {
827 $ratiopaymentinvoice = ($fields[
'payment_amount'] / (float) $fields[
'ftotal_ttc']);
830 if (isset($fields[
'payment_amount'])) {
831 print
' (' . round($ratiopaymentinvoice * 100, 2) .
'%)';
838 print
'<td class="nowrap right">';
839 $temp_ht = (float) $fields[
'totalht'] * $ratiopaymentinvoice;
844 print
'<td class="nowrap right">';
845 $temp_vat = $fields[
'vat'] * $ratiopaymentinvoice;
859 print
'<tr class="liste_total">';
860 print
'<td colspan="4"></td>';
861 print
'<td class="right">' . $langs->trans(
"Total") .
':</td>';
863 print
'<td class="nowrap right"> </td>';
864 print
'<td class="right"> </td>';
866 print
'<td class="right"><span class="amount">' .
price(
price2num($subtot_paye_total_ht,
'MT')) .
'</span></td>';
867 print
'<td class="nowrap right"><span class="amount">' .
price(
price2num($subtot_paye_vat,
'MT')) .
'</span></td>';
871 if (count($x_paye) == 0) {
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(0,
'MT')) .
'</span></td>';
880 print
'<td class="nowrap right"><span class="amount">' .
price(
price2num(0,
'MT')) .
'</span></td>';
889 print
'<table class="noborder centpercent">';
890 $diff = $x_coll_sum - $x_paye_sum;
891 print
'<tr class="liste_total">';
892 print
'<td class="liste_total" colspan="' . $span .
'">' . $langs->trans(
"TotalToPay") . ($q ?
', ' . $langs->trans(
"Quadri") .
' ' . $q :
'') .
'</td>';
893 print
'<td class="liste_total nowrap right"><b>' .
price(
price2num($diff,
'MT')) .
"</b></td>\n";
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Class to manage Trips and Expenses.
Class to manage suppliers invoices.
Class to manage invoices.
Class to manage payments for supplier invoices.
Class to manage payments of customer invoices.
Class to manage payments of expense report.
Class to manage products or services.
Class to manage third parties objects (customers, suppliers, prospects...)
Class to manage VAT - Value-added tax (also known in French as TVA - Taxe sur la valeur ajoutée)
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
vatrate($rate, $addpercent=false, $info_bits=0, $usestarfornpr=0, $html=0)
Return a string with VAT rate label formatted for view output Used into pdf and HTML pages.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_string_nohtmltag($stringtoclean, $removelinefeed=1, $pagecodeto='UTF-8', $strip_tags=0, $removedoublespaces=1)
Clean a string from all HTML tags and entities.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code='')
Function to format a value into an amount for visual output Function used into PDF and HTML pages.
dol_now($mode='auto')
Return date for now.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
newToken()
Return the value of token currently saved into session with name 'newtoken'.
print_date_range($date_start, $date_end, $format='', $outputlangs=null)
Format output for start and end date.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_trunc($string, $size=40, $trunc='right', $stringencoding='UTF-8', $nodot=0, $display=0)
Truncate a string to a particular length adding '…' if string larger than length.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
report_header($reportname, $notused, $period, $periodlink, $description, $builddate, $exportlink='', $moreparam=array(), $calcmode='', $varlink='')
Show header of a report.
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.
tax_by_rate($type, $db, $y, $q, $date_start, $date_end, $modetax, $direction, $m=0)
Gets Tax to collect for the given year (and given quarter or month) The function gets the Tax in spli...