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';
64if (GETPOSTISSET(
"modetax")) {
76 $socid = $user->socid;
86$company_static =
new Societe($db);
87$invoice_customer =
new Facture($db);
90$product_static =
new Product($db);
96$listofparams = array(
'date_startmonth',
'date_startyear',
'date_startday',
'date_endmonth',
'date_endyear',
'date_endday');
97foreach ($listofparams as $param) {
99 $morequerystring .= ($morequerystring ?
'&' :
'') . $param .
'=' .
GETPOST($param);
103$title = $langs->trans(
"VATReport") .
" " .
dol_print_date($date_start,
'',
'tzserver') .
" -> " .
dol_print_date($date_end,
'',
'tzserver');
104llxHeader(
'', $title,
'',
'', 0, 0,
'',
'', $morequerystring);
110$fsearch =
'<!-- hidden fields for form -->';
111$fsearch .=
'<input type="hidden" name="token" value="' .
newToken() .
'">';
112$fsearch .=
'<input type="hidden" name="modetax" value="' . $modetax .
'">';
118$name = $langs->trans(
"VATReportByRates");
121 $calcmode = $langs->trans(
'OptionVATDefault');
124 $calcmode = $langs->trans(
'OptionVATDebitOption');
127 $calcmode = $langs->trans(
'OptionPaymentForProductAndServices');
129$calcmode .=
' <span class="opacitymedium">(' . $langs->trans(
"TaxModuleSetupToModifyRules", DOL_URL_ROOT .
'/admin/taxes.php') .
')</span>';
131$period = $form->selectDate($date_start,
'date_start', 0, 0, 0,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'',
'',
'tzserver');
133$period .= $form->selectDate($date_end,
'date_end', 0, 0, 0,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'',
'',
'tzserver');
134$prevyear = $date_start_year;
137if ($prevquarter > 1) {
143$nextyear = $date_start_year;
145if ($nextquarter < 4) {
151$description = $fsearch;
155 $description .= $langs->trans(
"RulesVATDueProducts");
158 $description .= $langs->trans(
"RulesVATInProducts");
161 $description .=
'<br>' . $langs->trans(
"RulesVATDueServices");
164 $description .=
'<br>' . $langs->trans(
"RulesVATInServices");
167 $description .=
'<br>' . $langs->trans(
"DepositsAreNotIncluded");
170 $description .= $langs->trans(
"SupplierDepositsAreNotIncluded");
172if (isModEnabled(
'accounting')) {
173 $description .=
'<br>' . $langs->trans(
"ThisIsAnEstimatedValue");
177$elementcust = $langs->trans(
"CustomersInvoices");
178$productcust = $langs->trans(
"ProductOrService");
179$amountcust = $langs->trans(
"AmountHT");
180$vatcust = $langs->trans(
"VATReceived");
181$namecust = $langs->trans(
"Name");
182if ($mysoc->tva_assuj) {
183 $vatcust .=
' (' . $langs->trans(
"VATToPay") .
')';
187$elementsup = $langs->trans(
"SuppliersInvoices");
188$productsup = $productcust;
189$amountsup = $amountcust;
190$vatsup = $langs->trans(
"VATPaid");
192if ($mysoc->tva_assuj) {
193 $vatsup .=
' (' . $langs->trans(
"ToGetBack") .
')';
196$optioncss =
GETPOST(
'optioncss',
'alpha');
200if ($optioncss !=
"print") {
201 report_header($name,
'', $period, $periodlink, $description, $builddate, $exportlink, array(), $calcmode);
204$vatcust = $langs->trans(
"VATReceived");
205$vatsup = $langs->trans(
"VATPaid");
206$vatexpensereport = $langs->trans(
"VATPaid");
210print
'<div class="div-table-responsive">';
211print
'<table class="liste noborder centpercent">';
223$x_coll =
tax_by_rate(
'vat', $db, 0, 0, $date_start, $date_end, $modetax,
'sell');
224$x_paye =
tax_by_rate(
'vat', $db, 0, 0, $date_start, $date_end, $modetax,
'buy');
226if (!is_array($x_coll) || !is_array($x_paye)) {
227 $langs->load(
"errors");
229 print
'<tr><td colspan="' . $columns .
'">' . $langs->trans(
"ErrorNoAccountancyModuleLoaded") .
'</td></tr>';
230 } elseif ($x_coll == -2) {
231 print
'<tr><td colspan="' . $columns .
'">' . $langs->trans(
"FeatureNotYetAvailable") .
'</td></tr>';
233 print
'<tr><td colspan="' . $columns .
'">' . $langs->trans(
"Error") .
'</td></tr>';
238 foreach (array_keys($x_coll) as $my_coll_rate) {
239 $x_both[$my_coll_rate][
'coll'][
'totalht'] = $x_coll[$my_coll_rate][
'totalht'];
240 $x_both[$my_coll_rate][
'coll'][
'vat'] = $x_coll[$my_coll_rate][
'vat'];
241 $x_both[$my_coll_rate][
'paye'][
'totalht'] = 0;
242 $x_both[$my_coll_rate][
'paye'][
'vat'] = 0;
243 $x_both[$my_coll_rate][
'coll'][
'links'] =
'';
244 $x_both[$my_coll_rate][
'coll'][
'detail'] = array();
245 foreach ($x_coll[$my_coll_rate][
'facid'] as
$id => $dummy) {
246 $invoice_customer->id = $x_coll[$my_coll_rate][
'facid'][
$id];
247 $invoice_customer->ref = $x_coll[$my_coll_rate][
'facnum'][
$id];
248 $invoice_customer->type = $x_coll[$my_coll_rate][
'type'][
$id];
251 $company_static->id = $x_coll[$my_coll_rate][
'company_id'][
$id];
252 $company_static->name = $x_coll[$my_coll_rate][
'company_name'][
$id];
253 $company_static->name_alias = $x_coll[$my_coll_rate][
'company_alias'][
$id];
254 $company_static->email = $x_coll[$my_coll_rate][
'company_email'][
$id];
255 $company_static->tva_intra = isset($x_coll[$my_coll_rate][
'tva_intra'][
$id]) ? $x_coll[$my_coll_rate][
'tva_intra'][
$id] : 0;
256 $company_static->client = $x_coll[$my_coll_rate][
'company_client'][
$id];
257 $company_static->fournisseur = $x_coll[$my_coll_rate][
'company_fournisseur'][
$id];
258 $company_static->status = $x_coll[$my_coll_rate][
'company_status'][
$id];
259 $company_static->code_client = $x_coll[$my_coll_rate][
'company_customer_code'][
$id];
260 $company_static->code_compta_client = $x_coll[$my_coll_rate][
'company_customer_accounting_code'][
$id];
261 $company_static->code_fournisseur = $x_coll[$my_coll_rate][
'company_supplier_code'][
$id];
262 $company_static->code_compta_fournisseur = $x_coll[$my_coll_rate][
'company_supplier_accounting_code'][
$id];
264 $x_both[$my_coll_rate][
'coll'][
'detail'][] = array(
265 'id' => $x_coll[$my_coll_rate][
'facid'][
$id],
266 'descr' => $x_coll[$my_coll_rate][
'descr'][
$id],
267 'pid' => $x_coll[$my_coll_rate][
'pid'][
$id],
268 'pref' => $x_coll[$my_coll_rate][
'pref'][
$id],
269 'ptype' => $x_coll[$my_coll_rate][
'ptype'][
$id],
270 'payment_id' => $x_coll[$my_coll_rate][
'payment_id'][
$id],
271 'payment_ref' => $x_coll[$my_coll_rate][
'payment_ref'][
$id],
272 'payment_amount' => $x_coll[$my_coll_rate][
'payment_amount'][
$id],
273 'ftotal_ttc' => $x_coll[$my_coll_rate][
'ftotal_ttc'][
$id],
274 'dtotal_ttc' => $x_coll[$my_coll_rate][
'dtotal_ttc'][
$id],
275 'dtype' => $x_coll[$my_coll_rate][
'dtype'][
$id],
276 'datef' => $x_coll[$my_coll_rate][
'datef'][
$id],
277 'datep' => $x_coll[$my_coll_rate][
'datep'][
$id],
279 'company_link' => $company_static->getNomUrl(1,
'', 20),
281 'ddate_start' => $x_coll[$my_coll_rate][
'ddate_start'][
$id],
282 'ddate_end' => $x_coll[$my_coll_rate][
'ddate_end'][
$id],
283 'totalht' => $x_coll[$my_coll_rate][
'totalht_list'][
$id],
284 'vat' => $x_coll[$my_coll_rate][
'vat_list'][
$id],
285 'link' => $invoice_customer->getNomUrl(1,
'', 12)
290 foreach (array_keys($x_paye) as $my_paye_rate) {
291 $x_both[$my_paye_rate][
'paye'][
'totalht'] = $x_paye[$my_paye_rate][
'totalht'];
292 $x_both[$my_paye_rate][
'paye'][
'vat'] = $x_paye[$my_paye_rate][
'vat'];
293 if (!isset($x_both[$my_paye_rate][
'coll'][
'totalht'])) {
294 $x_both[$my_paye_rate][
'coll'][
'totalht'] = 0;
295 $x_both[$my_paye_rate][
'coll'][
'vat'] = 0;
297 $x_both[$my_paye_rate][
'paye'][
'links'] =
'';
298 $x_both[$my_paye_rate][
'paye'][
'detail'] = array();
300 foreach ($x_paye[$my_paye_rate][
'facid'] as
$id => $dummy) {
302 if ($x_paye[$my_paye_rate][
'ptype'][
$id] ==
'ExpenseReportPayment') {
303 $expensereport->id = $x_paye[$my_paye_rate][
'facid'][
$id];
304 $expensereport->ref = $x_paye[$my_paye_rate][
'facnum'][
$id];
305 $expensereport->type = $x_paye[$my_paye_rate][
'type'][
$id];
307 $x_both[$my_paye_rate][
'paye'][
'detail'][] = array(
308 'id' => $x_paye[$my_paye_rate][
'facid'][
$id],
309 'descr' => $x_paye[$my_paye_rate][
'descr'][
$id],
310 'pid' => $x_paye[$my_paye_rate][
'pid'][
$id],
311 'pref' => $x_paye[$my_paye_rate][
'pref'][
$id],
312 'ptype' => $x_paye[$my_paye_rate][
'ptype'][
$id],
313 'payment_id' => $x_paye[$my_paye_rate][
'payment_id'][
$id],
314 'payment_ref' => $x_paye[$my_paye_rate][
'payment_ref'][
$id],
315 'payment_amount' => $x_paye[$my_paye_rate][
'payment_amount'][
$id],
316 'ftotal_ttc' =>
price2num($x_paye[$my_paye_rate][
'ftotal_ttc'][
$id]),
317 'dtotal_ttc' =>
price2num($x_paye[$my_paye_rate][
'dtotal_ttc'][
$id]),
318 'dtype' => $x_paye[$my_paye_rate][
'dtype'][
$id],
319 'ddate_start' => $x_paye[$my_paye_rate][
'ddate_start'][
$id],
320 'ddate_end' => $x_paye[$my_paye_rate][
'ddate_end'][
$id],
321 'totalht' =>
price2num($x_paye[$my_paye_rate][
'totalht_list'][
$id]),
322 'vat' => $x_paye[$my_paye_rate][
'vat_list'][
$id],
323 'link' => $expensereport->getNomUrl(1)
326 $invoice_supplier->id = $x_paye[$my_paye_rate][
'facid'][
$id];
327 $invoice_supplier->ref = $x_paye[$my_paye_rate][
'facnum'][
$id];
328 $invoice_supplier->type = $x_paye[$my_paye_rate][
'type'][
$id];
330 $company_static->id = $x_paye[$my_paye_rate][
'company_id'][
$id];
331 $company_static->name = $x_paye[$my_paye_rate][
'company_name'][
$id];
332 $company_static->name_alias = $x_paye[$my_paye_rate][
'company_alias'][
$id];
333 $company_static->email = $x_paye[$my_paye_rate][
'company_email'][
$id];
334 $company_static->tva_intra = $x_paye[$my_paye_rate][
'tva_intra'][
$id];
335 $company_static->client = $x_paye[$my_paye_rate][
'company_client'][
$id];
336 $company_static->fournisseur = $x_paye[$my_paye_rate][
'company_fournisseur'][
$id];
337 $company_static->status = $x_paye[$my_paye_rate][
'company_status'][
$id];
338 $company_static->code_client = $x_paye[$my_paye_rate][
'company_customer_code'][
$id];
339 $company_static->code_compta_client = $x_paye[$my_paye_rate][
'company_customer_accounting_code'][
$id];
340 $company_static->code_fournisseur = $x_paye[$my_paye_rate][
'company_supplier_code'][
$id];
341 $company_static->code_compta_fournisseur = $x_paye[$my_paye_rate][
'company_supplier_accounting_code'][
$id];
343 $x_both[$my_paye_rate][
'paye'][
'detail'][] = array(
344 'id' => $x_paye[$my_paye_rate][
'facid'][
$id],
345 'descr' => $x_paye[$my_paye_rate][
'descr'][
$id],
346 'pid' => $x_paye[$my_paye_rate][
'pid'][
$id],
347 'pref' => $x_paye[$my_paye_rate][
'pref'][
$id],
348 'ptype' => $x_paye[$my_paye_rate][
'ptype'][
$id],
349 'payment_id' => $x_paye[$my_paye_rate][
'payment_id'][
$id],
350 'payment_ref' => $x_paye[$my_paye_rate][
'payment_ref'][
$id],
351 'payment_amount' => $x_paye[$my_paye_rate][
'payment_amount'][
$id],
352 'ftotal_ttc' =>
price2num($x_paye[$my_paye_rate][
'ftotal_ttc'][
$id]),
353 'dtotal_ttc' =>
price2num($x_paye[$my_paye_rate][
'dtotal_ttc'][
$id]),
354 'dtype' => $x_paye[$my_paye_rate][
'dtype'][
$id],
355 'datef' => $x_paye[$my_paye_rate][
'datef'][
$id],
356 'datep' => $x_paye[$my_paye_rate][
'datep'][
$id],
358 'company_link' => $company_static->getNomUrl(1,
'', 20),
360 'ddate_start' => $x_paye[$my_paye_rate][
'ddate_start'][
$id],
361 'ddate_end' => $x_paye[$my_paye_rate][
'ddate_end'][
$id],
362 'totalht' =>
price2num($x_paye[$my_paye_rate][
'totalht_list'][
$id]),
363 'vat' => $x_paye[$my_paye_rate][
'vat_list'][
$id],
364 'link' => $invoice_supplier->getNomUrl(1,
'', 12)
382 print
'<tr class="liste_titre">';
383 print
'<td class="left">' . $elementcust .
'</td>';
384 print
'<td class="left">' . $langs->trans(
"DateInvoice") .
'</td>';
386 print
'<td class="left">' . $langs->trans(
"DatePayment") .
'</td>';
390 print
'<td class="left">' . $namecust .
'</td>';
391 print
'<td class="left">' . $productcust .
'</td>';
393 print
'<td class="right">' . $amountcust .
'</td>';
394 print
'<td class="right">' . $langs->trans(
"Payment") .
' (' . $langs->trans(
"PercentOfInvoice") .
')</td>';
396 print
'<td class="right">' . $langs->trans(
"AmountHTVATRealReceived") .
'</td>';
397 print
'<td class="right">' . $vatcust .
'</td>';
400 $action =
"tvadetail";
401 $parameters[
"mode"] = $modetax;
402 $parameters[
"start"] = $date_start;
403 $parameters[
"end"] = $date_end;
404 $parameters[
"type"] =
'vat';
406 $object = array(&$x_coll, &$x_paye, &$x_both);
408 $hookmanager->initHooks(array(
'externalbalance'));
409 $reshook = $hookmanager->executeHooks(
'addVatLine', $parameters, $object, $action);
411 foreach (array_keys($x_coll) as $rate) {
412 $subtot_coll_total_ht = 0;
413 $subtot_coll_vat = 0;
415 if (is_array($x_both[$rate][
'coll'][
'detail'])) {
418 print
'<td class="tax_rate" colspan="' . ($span + 1) .
'">';
419 print $langs->trans(
'Rate') .
' : ' .
vatrate($rate) .
'%';
420 print
' - <a href="' . DOL_URL_ROOT .
'/compta/tva/quadri_detail.php?invoice_type=customer';
421 if ($invoice_type !=
'customer' || !GETPOSTISSET(
'vat_rate_show') ||
GETPOST(
'vat_rate_show') != $rate) {
422 print
'&vat_rate_show=' . urlencode($rate);
424 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>';
426 print
'</tr>' .
"\n";
428 foreach ($x_both[$rate][
'coll'][
'detail'] as $index => $fields) {
431 $type = (isset($fields[
'dtype']) ? $fields[
'dtype'] : $fields[
'ptype']);
434 if (!empty($fields[
'ddate_start'])) {
437 if (!empty($fields[
'ddate_end'])) {
442 $ratiopaymentinvoice = 1;
447 if (isset($fields[
'payment_amount']) &&
price2num($fields[
'ftotal_ttc'])) {
448 $ratiopaymentinvoice = ($fields[
'payment_amount'] / $fields[
'ftotal_ttc']);
454 $temp_ht = $fields[
'totalht'] * $ratiopaymentinvoice;
457 $temp_vat = $fields[
'vat'] * $ratiopaymentinvoice;
459 $subtot_coll_total_ht += $temp_ht;
460 $subtot_coll_vat += $temp_vat;
461 $x_coll_sum += $temp_vat;
465 if ($invoice_type ==
'customer' && $vat_rate_show == $rate) {
466 if (is_array($x_both[$rate][
'coll'][
'detail'])) {
467 foreach ($x_both[$rate][
'coll'][
'detail'] as $index => $fields) {
483 $type = (isset($fields[
'dtype']) ? $fields[
'dtype'] : $fields[
'ptype']);
486 if (!empty($fields[
'ddate_start'])) {
489 if (!empty($fields[
'ddate_end'])) {
494 print
'<tr class="oddeven">';
497 print
'<td class="nowrap left">' . $fields[
'link'] .
'</td>';
500 print
'<td class="left">' .
dol_print_date($fields[
'datef'],
'day') .
'</td>';
504 print
'<td class="left">' .
dol_print_date($fields[
'datep'],
'day') .
'</td>';
510 print
'<td class="tdmaxoverflow150">';
512 print $fields[
'company_link'];
516 print
'<td class="left">';
517 if ($fields[
'pid']) {
518 $product_static->id = $fields[
'pid'];
519 $product_static->ref = $fields[
'pref'];
520 $product_static->type = $fields[
'dtype'];
521 print $product_static->getNomUrl(1);
527 $text =
img_object($langs->trans(
'Service'),
'service');
529 $text =
img_object($langs->trans(
'Product'),
'product');
531 if (preg_match(
'/^\((.*)\)$/', $fields[
'descr'], $reg)) {
532 if ($reg[1] ==
'DEPOSIT') {
533 $fields[
'descr'] = $langs->transnoentitiesnoconv(
'Deposit');
534 } elseif ($reg[1] ==
'CREDIT_NOTE') {
535 $fields[
'descr'] = $langs->transnoentitiesnoconv(
'CreditNote');
537 $fields[
'descr'] = $langs->transnoentitiesnoconv($reg[1]);
549 print
'<td class="nowrap right">';
550 print
price($fields[
'totalht']);
553 $ratiolineinvoice = ($fields[
'dtotal_ttc'] / $fields[
'ftotal_ttc']);
560 $ratiopaymentinvoice = 1;
562 print
'<td class="nowrap right">';
564 if ($fields[
'payment_amount'] && $fields[
'ftotal_ttc']) {
565 $payment_static->id = $fields[
'payment_id'];
566 $payment_static->ref = $fields[
'payment_ref'];
567 print $payment_static->getNomUrl(2,
'',
'', 0) .
' ';
571 print $langs->trans(
"NA");
573 if (isset($fields[
'payment_amount']) &&
price2num($fields[
'ftotal_ttc'])) {
574 $ratiopaymentinvoice = ($fields[
'payment_amount'] / $fields[
'ftotal_ttc']);
577 if (isset($fields[
'payment_amount'])) {
578 print
' (' . round($ratiopaymentinvoice * 100, 2) .
'%)';
585 print
'<td class="nowrap right">';
586 $temp_ht = $fields[
'totalht'] * $ratiopaymentinvoice;
591 print
'<td class="nowrap right">';
592 $temp_vat = $fields[
'vat'] * $ratiopaymentinvoice;
605 print
'<tr class="liste_total">';
606 print
'<td colspan="4"></td>';
607 print
'<td class="right">' . $langs->trans(
"Total") .
':</td>';
609 print
'<td class="nowrap right"> </td>';
610 print
'<td class="right"> </td>';
612 print
'<td class="right"><span class="amount">' .
price(
price2num($subtot_coll_total_ht,
'MT')) .
'</span></td>';
613 print
'<td class="nowrap right"><span class="amount">' .
price(
price2num($subtot_coll_vat,
'MT')) .
'</span></td>';
617 if (count($x_coll) == 0) {
618 print
'<tr class="liste_total">';
619 print
'<td colspan="4"></td>';
620 print
'<td class="right">' . $langs->trans(
"Total") .
':</td>';
622 print
'<td class="nowrap right"> </td>';
623 print
'<td class="right"> </td>';
626 print
'<td class="nowrap right">' .
price(
price2num(0,
'MT')) .
'</td>';
631 print
'<tr><td colspan="' . ($span + 2) .
'"> </td></tr>';
634 print
'<tr class="liste_titre liste_titre_topborder">';
635 print
'<td class="left">' . $elementsup .
'</td>';
636 print
'<td class="left">' . $langs->trans(
"DateInvoice") .
'</td>';
638 print
'<td class="left">' . $langs->trans(
"DatePayment") .
'</td>';
642 print
'<td class="left">' . $namesup .
'</td>';
643 print
'<td class="left">' . $productsup .
'</td>';
645 print
'<td class="right">' . $amountsup .
'</td>';
646 print
'<td class="right">' . $langs->trans(
"Payment") .
' (' . $langs->trans(
"PercentOfInvoice") .
')</td>';
648 print
'<td class="right">' . $langs->trans(
"AmountHTVATRealPaid") .
'</td>';
649 print
'<td class="right">' . $vatsup .
'</td>';
650 print
'</tr>' .
"\n";
652 foreach (array_keys($x_paye) as $rate) {
653 $subtot_paye_total_ht = 0;
654 $subtot_paye_vat = 0;
656 if (is_array($x_both[$rate][
'paye'][
'detail'])) {
658 print
'<td class="tax_rate" colspan="' . ($span + 1) .
'">';
659 print $langs->trans(
'Rate') .
' : ' .
vatrate($rate) .
'%';
660 print
' - <a href="' . DOL_URL_ROOT .
'/compta/tva/quadri_detail.php?invoice_type=supplier';
661 if ($invoice_type !=
'supplier' || !GETPOSTISSET(
'vat_rate_show') ||
GETPOST(
'vat_rate_show') != $rate) {
662 print
'&vat_rate_show=' . urlencode($rate);
664 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>';
666 print
'</tr>' .
"\n";
668 foreach ($x_both[$rate][
'paye'][
'detail'] as $index => $fields) {
671 $type = (isset($fields[
'dtype']) ? $fields[
'dtype'] : $fields[
'ptype']);
674 if (!empty($fields[
'ddate_start'])) {
677 if (!empty($fields[
'ddate_end'])) {
682 $ratiopaymentinvoice = 1;
687 if (isset($fields[
'payment_amount']) && $fields[
'ftotal_ttc']) {
688 $ratiopaymentinvoice = ($fields[
'payment_amount'] / (float) $fields[
'ftotal_ttc']);
694 $temp_ht = (float) $fields[
'totalht'] * $ratiopaymentinvoice;
697 $temp_vat = $fields[
'vat'] * $ratiopaymentinvoice;
699 $subtot_paye_total_ht += $temp_ht;
700 $subtot_paye_vat += $temp_vat;
701 $x_paye_sum += $temp_vat;
704 if ($invoice_type ==
'supplier' && $vat_rate_show == $rate) {
705 foreach ($x_both[$rate][
'paye'][
'detail'] as $index => $fields) {
721 $type = (isset($fields[
'dtype']) ? $fields[
'dtype'] : $fields[
'ptype']);
724 if (!empty($fields[
'ddate_start'])) {
727 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($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...