29 require
'../../main.inc.php';
30 require_once DOL_DOCUMENT_ROOT.
'/core/lib/report.lib.php';
31 require_once DOL_DOCUMENT_ROOT.
'/core/lib/tax.lib.php';
32 require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
33 require_once DOL_DOCUMENT_ROOT.
'/compta/tva/class/tva.class.php';
34 require_once DOL_DOCUMENT_ROOT.
'/compta/localtax/class/localtax.class.php';
35 require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
36 require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
37 require_once DOL_DOCUMENT_ROOT.
'/compta/paiement/class/paiement.class.php';
38 require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.facture.class.php';
39 require_once DOL_DOCUMENT_ROOT.
'/fourn/class/paiementfourn.class.php';
40 require_once DOL_DOCUMENT_ROOT.
'/expensereport/class/expensereport.class.php';
41 require_once DOL_DOCUMENT_ROOT.
'/expensereport/class/paymentexpensereport.class.php';
44 $langs->loadLangs(array(
"other",
"compta",
"banks",
"bills",
"companies",
"product",
"trips",
"admin"));
49 if (empty($conf->global->SOCIETE_FISCAL_MONTH_START)) $conf->global->SOCIETE_FISCAL_MONTH_START = 1;
55 $year_current = $current_date[
'year'];
56 $year_start = $year_current;
58 $year_current = $year;
64 if (empty($date_start) || empty($date_end))
70 if (empty($conf->global->MAIN_INFO_VAT_RETURN) || $conf->global->MAIN_INFO_VAT_RETURN == 2) {
71 $date_start =
dol_time_plus_duree(
dol_get_first_day($year_start, $current_date[
'mon'],
false), -3 - (($current_date[
'mon'] - $conf->global->SOCIETE_FISCAL_MONTH_START) % 3),
'm');
73 } elseif ($conf->global->MAIN_INFO_VAT_RETURN == 3) {
74 if ($current_date[
'mon'] < $conf->global->SOCIETE_FISCAL_MONTH_START) {
75 if (($conf->global->SOCIETE_FISCAL_MONTH_START - $current_date[
'mon']) > 6) {
79 if (($current_date[
'mon'] - $conf->global->SOCIETE_FISCAL_MONTH_START) < 6) {
83 $date_start =
dol_get_first_day($year_start, $conf->global->SOCIETE_FISCAL_MONTH_START,
false);
85 } elseif ($conf->global->MAIN_INFO_VAT_RETURN == 1) {
99 if (empty($min)) $min = 0;
103 $modetax = $conf->global->TAX_MODE;
105 if (empty($modetax)) $modetax = 0;
108 $socid =
GETPOST(
'socid',
'int');
109 if ($user->socid) $socid = $user->socid;
118 $form =
new Form($db);
119 $company_static =
new Societe($db);
120 $invoice_customer =
new Facture($db);
123 $product_static =
new Product($db);
124 $payment_static =
new Paiement($db);
127 $user_static =
new User($db);
129 $morequerystring =
'';
130 $listofparams = array(
'date_startmonth',
'date_startyear',
'date_startday',
'date_endmonth',
'date_endyear',
'date_endday');
131 foreach ($listofparams as $param)
133 if (
GETPOST($param) !=
'') $morequerystring .= ($morequerystring ?
'&' :
'').$param.
'='.
GETPOST($param);
136 $special_report =
false;
137 if (isset($_REQUEST[
'extra_report']) && $_REQUEST[
'extra_report'] == 1) {
138 $special_report =
true;
141 llxHeader(
'', $langs->trans(
"VATReport"),
'',
'', 0, 0,
'',
'', $morequerystring);
143 $fsearch =
'<!-- hidden fields for form -->';
144 $fsearch .=
'<input type="hidden" name="token" value="'.newToken().
'">';
145 $fsearch .=
'<input type="hidden" name="modetax" value="'.$modetax.
'">';
146 $fsearch .= $langs->trans(
"SalesTurnoverMinimum").
': ';
147 $fsearch .=
'<input type="text" name="min" id="min" value="'.$min.
'" size="6">';
150 $name = $langs->trans(
"VATReportByThirdParties");
152 if ($modetax == 0) $calcmode = $langs->trans(
'OptionVATDefault');
153 if ($modetax == 1) $calcmode = $langs->trans(
'OptionVATDebitOption');
154 if ($modetax == 2) $calcmode = $langs->trans(
'OptionPaymentForProductAndServices');
155 $calcmode .=
' <span class="opacitymedium">('.$langs->trans(
"TaxModuleSetupToModifyRules", DOL_URL_ROOT.
'/admin/taxes.php').
')</span>';
157 $period = $form->selectDate($date_start,
'date_start', 0, 0, 0,
'', 1, 0).
' - '.$form->selectDate($date_end,
'date_end', 0, 0, 0,
'', 1, 0);
158 $prevyear = $year_start;
160 if ($prevquarter > 1) {
166 $nextyear = $year_start;
168 if ($nextquarter < 4) {
176 if ($conf->global->TAX_MODE_SELL_PRODUCT ==
'invoice') $description .= $langs->trans(
"RulesVATDueProducts");
177 if ($conf->global->TAX_MODE_SELL_PRODUCT ==
'payment') $description .= $langs->trans(
"RulesVATInProducts");
178 if ($conf->global->TAX_MODE_SELL_SERVICE ==
'invoice') $description .=
'<br>'.$langs->trans(
"RulesVATDueServices");
179 if ($conf->global->TAX_MODE_SELL_SERVICE ==
'payment') $description .=
'<br>'.$langs->trans(
"RulesVATInServices");
180 if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
181 $description .=
'<br>'.$langs->trans(
"DepositsAreNotIncluded");
183 if (!empty($conf->global->MAIN_MODULE_ACCOUNTING)) $description .=
'<br>'.$langs->trans(
"ThisIsAnEstimatedValue");
186 $description .= ($description ?
'<br>' :
'').$fsearch;
187 if (!empty($conf->global->TAX_REPORT_EXTRA_REPORT))
189 $description .=
'<br>';
190 $description .=
'<input type="radio" name="extra_report" value="0" '.($special_report ?
'' :
'checked="checked"').
'> ';
191 $description .= $langs->trans(
'SimpleReport');
192 $description .=
'</input>';
193 $description .=
'<br>';
194 $description .=
'<input type="radio" name="extra_report" value="1" '.($special_report ?
'checked="checked"' :
'').
'> ';
195 $description .= $langs->trans(
'AddExtraReport');
196 $description .=
'</input>';
197 $description .=
'<br>';
200 $elementcust = $langs->trans(
"CustomersInvoices");
201 $productcust = $langs->trans(
"Description");
202 $namerate = $langs->trans(
"VATRate");
203 $amountcust = $langs->trans(
"AmountHT");
204 if ($mysoc->tva_assuj) {
205 $vatcust .=
' ('.$langs->trans(
"StatusToPay").
')';
207 $elementsup = $langs->trans(
"SuppliersInvoices");
208 $productsup = $langs->trans(
"Description");
209 $amountsup = $langs->trans(
"AmountHT");
210 if ($mysoc->tva_assuj) {
211 $vatsup .=
' ('.$langs->trans(
"ToGetBack").
')';
213 report_header($name,
'', $period, $periodlink, $description, $builddate, $exportlink, array(), $calcmode);
215 $vatcust = $langs->trans(
"VATReceived");
216 $vatsup = $langs->trans(
"VATPaid");
220 print '<div class="div-table-responsive">';
221 print "<table class=\"noborder\" width=\"100%\">";
229 $x_coll =
tax_by_thirdparty(
'vat', $db, 0, $date_start, $date_end, $modetax,
'sell');
230 $x_paye =
tax_by_thirdparty(
'vat', $db, 0, $date_start, $date_end, $modetax,
'buy');
232 if (!is_array($x_coll) || !is_array($x_paye))
234 $langs->load(
"errors");
236 print '<tr><td colspan="'.$columns.
'">'.$langs->trans(
"ErrorNoAccountancyModuleLoaded").
'</td></tr>';
237 } elseif ($x_coll == -2) {
238 print '<tr><td colspan="'.$columns.
'">'.$langs->trans(
"FeatureNotYetAvailable").
'</td></tr>';
240 print '<tr><td colspan="'.$columns.
'">'.$langs->trans(
"Error").
'</td></tr>';
245 foreach (array_keys($x_coll) as $my_coll_thirdpartyid)
247 $x_both[$my_coll_thirdpartyid][
'coll'][
'totalht'] = $x_coll[$my_coll_thirdpartyid][
'totalht'];
248 $x_both[$my_coll_thirdpartyid][
'coll'][
'vat'] = $x_coll[$my_coll_thirdpartyid][
'vat'];
249 $x_both[$my_coll_thirdpartyid][
'paye'][
'totalht'] = 0;
250 $x_both[$my_coll_thirdpartyid][
'paye'][
'vat'] = 0;
251 $x_both[$my_coll_thirdpartyid][
'coll'][
'links'] =
'';
252 $x_both[$my_coll_thirdpartyid][
'coll'][
'detail'] = array();
253 foreach ($x_coll[$my_coll_thirdpartyid][
'facid'] as $id=>$dummy) {
254 $invoice_customer->id = $x_coll[$my_coll_thirdpartyid][
'facid'][$id];
255 $invoice_customer->ref = $x_coll[$my_coll_thirdpartyid][
'facnum'][$id];
256 $invoice_customer->type = $x_coll[$my_coll_thirdpartyid][
'type'][$id];
257 $company_static->fetch($x_coll[$my_coll_thirdpartyid][
'company_id'][$id]);
258 $x_both[$my_coll_thirdpartyid][
'coll'][
'detail'][] = array(
259 'id' =>$x_coll[$my_coll_thirdpartyid][
'facid'][$id],
260 'descr' =>$x_coll[$my_coll_thirdpartyid][
'descr'][$id],
261 'pid' =>$x_coll[$my_coll_thirdpartyid][
'pid'][$id],
262 'pref' =>$x_coll[$my_coll_thirdpartyid][
'pref'][$id],
263 'ptype' =>$x_coll[$my_coll_thirdpartyid][
'ptype'][$id],
264 'payment_id'=>$x_coll[$my_coll_thirdpartyid][
'payment_id'][$id],
265 'payment_amount'=>$x_coll[$my_coll_thirdpartyid][
'payment_amount'][$id],
266 'ftotal_ttc'=>$x_coll[$my_coll_thirdpartyid][
'ftotal_ttc'][$id],
267 'dtotal_ttc'=>$x_coll[$my_coll_thirdpartyid][
'dtotal_ttc'][$id],
268 'dtype' =>$x_coll[$my_coll_thirdpartyid][
'dtype'][$id],
269 'drate' =>$x_coll[$my_coll_thirdpartyid][
'drate'][$id],
270 'datef' =>$x_coll[$my_coll_thirdpartyid][
'datef'][$id],
271 'datep' =>$x_coll[$my_coll_thirdpartyid][
'datep'][$id],
272 'company_link'=>$company_static->getNomUrl(1,
'', 20),
273 'ddate_start'=>$x_coll[$my_coll_thirdpartyid][
'ddate_start'][$id],
274 'ddate_end' =>$x_coll[$my_coll_thirdpartyid][
'ddate_end'][$id],
275 'totalht' =>$x_coll[$my_coll_thirdpartyid][
'totalht_list'][$id],
276 'vat' =>$x_coll[$my_coll_thirdpartyid][
'vat_list'][$id],
277 'link' =>$invoice_customer->getNomUrl(1,
'', 12)
282 foreach (array_keys($x_paye) as $my_paye_thirdpartyid) {
283 $x_both[$my_paye_thirdpartyid][
'paye'][
'totalht'] = $x_paye[$my_paye_thirdpartyid][
'totalht'];
284 $x_both[$my_paye_thirdpartyid][
'paye'][
'vat'] = $x_paye[$my_paye_thirdpartyid][
'vat'];
285 if (!isset($x_both[$my_paye_thirdpartyid][
'coll'][
'totalht'])) {
286 $x_both[$my_paye_thirdpartyid][
'coll'][
'totalht'] = 0;
287 $x_both[$my_paye_thirdpartyid][
'coll'][
'vat'] = 0;
289 $x_both[$my_paye_thirdpartyid][
'paye'][
'links'] =
'';
290 $x_both[$my_paye_thirdpartyid][
'paye'][
'detail'] = array();
292 foreach ($x_paye[$my_paye_thirdpartyid][
'facid'] as $id=>$dummy)
295 if ($x_paye[$my_paye_thirdpartyid][
'ptype'][$id] ==
'ExpenseReportPayment')
297 $expensereport->id = $x_paye[$my_paye_thirdpartyid][
'facid'][$id];
298 $expensereport->ref = $x_paye[$my_paye_thirdpartyid][
'facnum'][$id];
299 $expensereport->type = $x_paye[$my_paye_thirdpartyid][
'type'][$id];
301 $x_both[$my_paye_thirdpartyid][
'paye'][
'detail'][] = array(
302 'id' =>$x_paye[$my_paye_thirdpartyid][
'facid'][$id],
303 'descr' =>$x_paye[$my_paye_thirdpartyid][
'descr'][$id],
304 'pid' =>$x_paye[$my_paye_thirdpartyid][
'pid'][$id],
305 'pref' =>$x_paye[$my_paye_thirdpartyid][
'pref'][$id],
306 'ptype' =>$x_paye[$my_paye_thirdpartyid][
'ptype'][$id],
307 'payment_id' =>$x_paye[$my_paye_thirdpartyid][
'payment_id'][$id],
308 'payment_amount' =>$x_paye[$my_paye_thirdpartyid][
'payment_amount'][$id],
309 'ftotal_ttc' =>
price2num($x_paye[$my_paye_thirdpartyid][
'ftotal_ttc'][$id]),
310 'dtotal_ttc' =>
price2num($x_paye[$my_paye_thirdpartyid][
'dtotal_ttc'][$id]),
311 'dtype' =>$x_paye[$my_paye_thirdpartyid][
'dtype'][$id],
312 'drate' =>$x_paye[$my_coll_thirdpartyid][
'drate'][$id],
313 'ddate_start' =>$x_paye[$my_paye_thirdpartyid][
'ddate_start'][$id],
314 'ddate_end' =>$x_paye[$my_paye_thirdpartyid][
'ddate_end'][$id],
315 'totalht' =>
price2num($x_paye[$my_paye_thirdpartyid][
'totalht_list'][$id]),
316 'vat' =>$x_paye[$my_paye_thirdpartyid][
'vat_list'][$id],
317 'link' =>$expensereport->getNomUrl(1)
320 $invoice_supplier->id = $x_paye[$my_paye_thirdpartyid][
'facid'][$id];
321 $invoice_supplier->ref = $x_paye[$my_paye_thirdpartyid][
'facnum'][$id];
322 $invoice_supplier->type = $x_paye[$my_paye_thirdpartyid][
'type'][$id];
323 $company_static->fetch($x_paye[$my_paye_thirdpartyid][
'company_id'][$id]);
324 $x_both[$my_paye_thirdpartyid][
'paye'][
'detail'][] = array(
325 'id' =>$x_paye[$my_paye_thirdpartyid][
'facid'][$id],
326 'descr' =>$x_paye[$my_paye_thirdpartyid][
'descr'][$id],
327 'pid' =>$x_paye[$my_paye_thirdpartyid][
'pid'][$id],
328 'pref' =>$x_paye[$my_paye_thirdpartyid][
'pref'][$id],
329 'ptype' =>$x_paye[$my_paye_thirdpartyid][
'ptype'][$id],
330 'payment_id'=>$x_paye[$my_paye_thirdpartyid][
'payment_id'][$id],
331 'payment_amount'=>$x_paye[$my_paye_thirdpartyid][
'payment_amount'][$id],
332 'ftotal_ttc'=>
price2num($x_paye[$my_paye_thirdpartyid][
'ftotal_ttc'][$id]),
333 'dtotal_ttc'=>
price2num($x_paye[$my_paye_thirdpartyid][
'dtotal_ttc'][$id]),
334 'dtype' =>$x_paye[$my_paye_thirdpartyid][
'dtype'][$id],
335 'drate' =>$x_paye[$my_coll_thirdpartyid][
'drate'][$id],
336 'datef' =>$x_paye[$my_paye_thirdpartyid][
'datef'][$id],
337 'datep' =>$x_paye[$my_paye_thirdpartyid][
'datep'][$id],
338 'company_link'=>$company_static->getNomUrl(1,
'', 20),
339 'ddate_start'=>$x_paye[$my_paye_thirdpartyid][
'ddate_start'][$id],
340 'ddate_end' =>$x_paye[$my_paye_thirdpartyid][
'ddate_end'][$id],
341 'totalht' =>
price2num($x_paye[$my_paye_thirdpartyid][
'totalht_list'][$id]),
342 'vat' =>$x_paye[$my_paye_thirdpartyid][
'vat_list'][$id],
343 'link' =>$invoice_supplier->getNomUrl(1,
'', 12)
359 if ($modetax != 1) $span += 2;
364 print '<tr class="liste_titre">';
365 print '<td class="left">'.$elementcust.
'</td>';
366 print '<td class="left">'.$langs->trans(
"DateInvoice").
'</td>';
367 if ($conf->global->TAX_MODE_SELL_PRODUCT ==
'payment' || $conf->global->TAX_MODE_SELL_SERVICE ==
'payment')
print '<td class="left">'.$langs->trans(
"DatePayment").
'</td>';
368 else print '<td></td>';
369 print '<td class="right">'.$namerate.
'</td>';
370 print '<td class="left">'.$productcust.
'</td>';
373 print '<td class="right">'.$amountcust.
'</td>';
374 print '<td class="right">'.$langs->trans(
"Payment").
' ('.$langs->trans(
"PercentOfInvoice").
')</td>';
376 print '<td class="right">'.$langs->trans(
"AmountHTVATRealReceived").
'</td>';
377 print '<td class="right">'.$vatcust.
'</td>';
380 $action =
"tvadetail";
381 $parameters[
"mode"] = $modetax;
382 $parameters[
"start"] = $date_start;
383 $parameters[
"end"] = $date_end;
384 $parameters[
"type"] =
'vat';
386 $object = array(&$x_coll, &$x_paye, &$x_both);
388 $hookmanager->initHooks(array(
'externalbalance'));
389 $reshook = $hookmanager->executeHooks(
'addVatLine', $parameters, $object, $action);
391 foreach (array_keys($x_coll) as $thirdparty_id) {
392 $subtot_coll_total_ht = 0;
393 $subtot_coll_vat = 0;
395 if ($min == 0 || ($min > 0 && $x_both[$thirdparty_id][
'coll'][
'totalht'] > $min))
397 if (is_array($x_both[$thirdparty_id][
'coll'][
'detail']))
401 print '<td class="tax_rate">';
402 if (is_numeric($thirdparty_id)) {
403 $company_static->fetch($thirdparty_id);
404 print $langs->trans(
"ThirdParty").
': '.$company_static->getNomUrl(1);
406 $tmpid = preg_replace(
'/userid_/',
'', $thirdparty_id);
407 $user_static->fetch($tmpid);
408 print $langs->trans(
"User").
': '.$user_static->getNomUrl(1);
410 print '</td><td colspan="'.($span + 1).
'"></td>';
413 foreach ($x_both[$thirdparty_id][
'coll'][
'detail'] as $index => $fields) {
416 $type = (isset($fields[
'dtype']) ? $fields[
'dtype'] : $fields[
'ptype']);
419 if (!empty($fields[
'ddate_start'])) {
422 if (!empty($fields[
'ddate_end'])) {
426 print '<tr class="oddeven">';
429 print '<td class="nowrap left">'.$fields[
'link'].
'</td>';
432 print '<td class="left">'.dol_print_date($fields[
'datef'],
'day').
'</td>';
435 if ($conf->global->TAX_MODE_SELL_PRODUCT ==
'payment' || $conf->global->TAX_MODE_SELL_SERVICE ==
'payment') {
436 print '<td class="left">'.dol_print_date($fields[
'datep'],
'day').
'</td>';
442 print '<td class="right">'.$fields[
'drate'].
'</td>';
445 print '<td class="left">';
446 if ($fields[
'pid']) {
447 $product_static->id = $fields[
'pid'];
448 $product_static->ref = $fields[
'pref'];
449 $product_static->type = $fields[
'dtype'];
450 print $product_static->getNomUrl(1);
456 $text =
img_object($langs->trans(
'Service'),
'service');
458 $text =
img_object($langs->trans(
'Product'),
'product');
460 if (preg_match(
'/^\((.*)\)$/', $fields[
'descr'], $reg)) {
461 if ($reg[1] ==
'DEPOSIT') {
462 $fields[
'descr'] = $langs->transnoentitiesnoconv(
'Deposit');
463 } elseif ($reg[1] ==
'CREDIT_NOTE') {
464 $fields[
'descr'] = $langs->transnoentitiesnoconv(
'CreditNote');
466 $fields[
'descr'] = $langs->transnoentitiesnoconv($reg[1]);
478 print '<td class="nowrap right">';
482 $ratiolineinvoice = ($fields[
'dtotal_ttc'] / $fields[
'ftotal_ttc']);
489 $ratiopaymentinvoice = 1;
491 print '<td class="nowrap right">';
493 if ($fields[
'payment_amount'] && $fields[
'ftotal_ttc']) {
494 $payment_static->id = $fields[
'payment_id'];
495 print $payment_static->getNomUrl(2);
497 if (($type == 0 && $conf->global->TAX_MODE_SELL_PRODUCT ==
'invoice')
498 || ($type == 1 && $conf->global->TAX_MODE_SELL_SERVICE ==
'invoice')) {
499 print $langs->trans(
"NA");
501 if (isset($fields[
'payment_amount']) &&
price2num($fields[
'ftotal_ttc'])) {
502 $ratiopaymentinvoice = ($fields[
'payment_amount'] / $fields[
'ftotal_ttc']);
505 if (isset($fields[
'payment_amount'])) {
506 print ' ('.round($ratiopaymentinvoice * 100, 2).
'%)';
513 print '<td class="nowrap right">';
514 $temp_ht = $fields[
'totalht'] * $ratiopaymentinvoice;
519 print '<td class="nowrap right">';
520 $temp_vat = $fields[
'vat'] * $ratiopaymentinvoice;
526 $subtot_coll_total_ht += $temp_ht;
527 $subtot_coll_vat += $temp_vat;
528 $x_coll_sum += $temp_vat;
532 print '<tr class="liste_total">';
533 print '<td colspan="4"></td>';
534 print '<td class="right">'.$langs->trans(
"Total").
':</td>';
536 print '<td class="nowrap right"> </td>';
537 print '<td class="right"> </td>';
539 print '<td class="right">'.price(
price2num($subtot_coll_total_ht,
'MT')).
'</td>';
540 print '<td class="nowrap right">'.price(
price2num($subtot_coll_vat,
'MT')).
'</td>';
545 if (count($x_coll) == 0)
547 print '<tr class="liste_total">';
548 print '<td colspan="4"></td>';
549 print '<td class="right">'.$langs->trans(
"Total").
':</td>';
551 print '<td class="nowrap right"> </td>';
552 print '<td class="right"> </td>';
555 print '<td class="nowrap right">'.price(
price2num(0,
'MT')).
'</td>';
560 print '<tr><td colspan="'.($span + 1).
'"> </td></tr>';
563 print '<tr class="liste_titre liste_titre_topborder">';
564 print
'<td class="left">'.$elementsup.
'</td>';
565 print
'<td class="left">'.$langs->trans(
"DateInvoice").
'</td>';
566 if ($conf->global->TAX_MODE_BUY_PRODUCT ==
'payment' || $conf->global->TAX_MODE_BUY_SERVICE ==
'payment') print
'<td class="left">'.$langs->trans(
"DatePayment").
'</td>';
567 else print
'<td></td>';
568 print
'<td class="left">'.$namesup.
'</td>';
569 print
'<td class="left">'.$productsup.
'</td>';
571 print
'<td class="right">'.$amountsup.
'</td>';
572 print
'<td class="right">'.$langs->trans(
"Payment").
' ('.$langs->trans(
"PercentOfInvoice").
')</td>';
574 print
'<td class="right">'.$langs->trans(
"AmountHTVATRealPaid").
'</td>';
575 print
'<td class="right">'.$vatsup.
'</td>';
578 foreach (array_keys($x_paye) as $thirdparty_id)
580 $subtot_paye_total_ht = 0;
581 $subtot_paye_vat = 0;
583 if ($min == 0 || ($min > 0 && $x_both[$thirdparty_id][
'paye'][
'totalht'] > $min)) {
584 if (is_array($x_both[$thirdparty_id][
'paye'][
'detail'])) {
586 print
'<td class="tax_rate">';
587 if (is_numeric($thirdparty_id)) {
588 $company_static->fetch($thirdparty_id);
589 print $langs->trans(
"ThirdParty").
': '.$company_static->getNomUrl(1);
591 $tmpid = preg_replace(
'/userid_/',
'', $thirdparty_id);
592 $user_static->fetch($tmpid);
593 print $langs->trans(
"User").
': '.$user_static->getNomUrl(1);
595 print
'<td colspan="'.($span + 1).
'"></td>';
598 foreach ($x_both[$thirdparty_id][
'paye'][
'detail'] as $index => $fields) {
601 $type = (isset($fields[
'dtype']) ? $fields[
'dtype'] : $fields[
'ptype']);
604 if (!empty($fields[
'ddate_start'])) {
607 if (!empty($fields[
'ddate_end'])) {
612 print
'<tr class="oddeven">';
615 print
'<td class="nowrap left">'.$fields[
'link'].
'</td>';
618 print
'<td class="left">'.dol_print_date($fields[
'datef'],
'day').
'</td>';
621 if ($conf->global->TAX_MODE_BUY_PRODUCT ==
'payment' || $conf->global->TAX_MODE_BUY_SERVICE ==
'payment') {
622 print
'<td class="left">'.dol_print_date($fields[
'datep'],
'day').
'</td>';
628 print
'<td class="left">'.$fields[
'company_link'].
'</td>';
631 print
'<td class="left">';
632 if ($fields[
'pid']) {
633 $product_static->id = $fields[
'pid'];
634 $product_static->ref = $fields[
'pref'];
635 $product_static->type = $fields[
'dtype'];
636 print $product_static->getNomUrl(1);
642 $text =
img_object($langs->trans(
'Service'),
'service');
644 $text =
img_object($langs->trans(
'Product'),
'product');
646 if (preg_match(
'/^\((.*)\)$/', $fields[
'descr'], $reg)) {
647 if ($reg[1] ==
'DEPOSIT') {
648 $fields[
'descr'] = $langs->transnoentitiesnoconv(
'Deposit');
649 } elseif ($reg[1] ==
'CREDIT_NOTE') {
650 $fields[
'descr'] = $langs->transnoentitiesnoconv(
'CreditNote');
652 $fields[
'descr'] = $langs->transnoentitiesnoconv($reg[1]);
664 print
'<td class="nowrap right">';
665 print
price($fields[
'totalht']);
668 $ratiolineinvoice = ($fields[
'dtotal_ttc'] / $fields[
'ftotal_ttc']);
675 $ratiopaymentinvoice = 1;
678 print
'<td class="nowrap right">';
679 if ($fields[
'payment_amount'] && $fields[
'ftotal_ttc'])
681 $paymentfourn_static->id = $fields[
'payment_id'];
682 print $paymentfourn_static->getNomUrl(2);
685 if (($type == 0 && $conf->global->TAX_MODE_BUY_PRODUCT ==
'invoice')
686 || ($type == 1 && $conf->global->TAX_MODE_BUY_SERVICE ==
'invoice'))
688 print $langs->trans(
"NA");
690 if (isset($fields[
'payment_amount']) && $fields[
'ftotal_ttc']) {
691 $ratiopaymentinvoice = ($fields[
'payment_amount'] / $fields[
'ftotal_ttc']);
694 if (isset($fields[
'payment_amount'])) {
695 print
' ('.round($ratiopaymentinvoice * 100, 2).
'%)';
702 print
'<td class="nowrap right">';
703 $temp_ht = $fields[
'totalht'] * $ratiopaymentinvoice;
708 print
'<td class="nowrap right">';
709 $temp_vat = $fields[
'vat'] * $ratiopaymentinvoice;
715 $subtot_paye_total_ht += $temp_ht;
716 $subtot_paye_vat += $temp_vat;
717 $x_paye_sum += $temp_vat;
721 print
'<tr class="liste_total">';
722 print
'<td colspan="4"></td>';
723 print
'<td class="right">'.$langs->trans(
"Total").
':</td>';
725 print
'<td class="nowrap right"> </td>';
726 print
'<td class="right"> </td>';
728 print
'<td class="right">'.price(
price2num($subtot_paye_total_ht,
'MT')).
'</td>';
729 print
'<td class="nowrap right">'.price(
price2num($subtot_paye_vat,
'MT')).
'</td>';
734 if (count($x_paye) == 0) {
735 print
'<tr class="liste_total">';
736 print
'<td colspan="4"></td>';
737 print
'<td class="right">'.$langs->trans(
"Total").
':</td>';
739 print
'<td class="nowrap right"> </td>';
740 print
'<td class="right"> </td>';
742 print
'<td class="right">'.price(
price2num(0,
'MT')).
'</td>';
743 print
'<td class="nowrap right">'.price(
price2num(0,
'MT')).
'</td>';
748 print
'<tr><td colspan="'.($span + 2).
'"></td></tr>';
750 $diff = $x_coll_sum - $x_paye_sum;
751 print
'<tr class="liste_total">';
752 print
'<td class="liste_total" colspan="'.($span + 1).
'">'.$langs->trans(
"TotalToPay").($q ?
', '.$langs->trans(
"Quadri").
' '.$q :
'').
'</td>';
753 print
'<td class="liste_total nowrap right"><b>'.price(
price2num($diff,
'MT')).
"</b></td>\n";
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_string_nohtmltag($stringtoclean, $removelinefeed=1, $pagecodeto= 'UTF-8', $strip_tags=0, $removedoublespaces=1)
Clean a string from all HTML tags and entities.
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm= 'auto', $check=1)
Return a timestamp date built from detailed informations (by default a local PHP server timestamp) Re...
tax_by_thirdparty($type, $db, $y, $date_start, $date_end, $modetax, $direction, $m=0, $q=0)
Look for collectable VAT clients in the chosen year (and month)
Class to manage products or services.
dol_now($mode= 'auto')
Return date for now.
Class to manage Dolibarr users.
report_header($reportname, $notused, $period, $periodlink, $description, $builddate, $exportlink= '', $moreparam=array(), $calcmode= '', $varlink= '')
Show header of a report.
dol_get_first_day($year, $month=1, $gm=false)
Return GMT time for first day of a month or year.
Class to manage suppliers invoices.
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...
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname.
Class to manage third parties objects (customers, suppliers, prospects...)
price2num($amount, $rounding= '', $option=0)
Function that return a number with universal decimal format (decimal separator is '...
Class to manage payments of customer invoices.
dol_getdate($timestamp, $fast=false, $forcetimezone= '')
Return an array with locale date info.
img_object($titlealt, $picto, $moreatt= '', $pictoisfullpath=false, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
restrictedArea($user, $features, $objectid=0, $tableandshare= '', $feature2= '', $dbt_keyfield= 'fk_soc', $dbt_select= 'rowid', $isdraft=0)
Check permissions of a user to show a page and an object.
Class to manage Trips and Expenses.
dol_get_last_day($year, $month=12, $gm=false)
Return GMT time for last day of a month or year.
print
Draft customers invoices.
Class to manage payments of expense report.
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.
print_date_range($date_start, $date_end, $format= '', $outputlangs= '')
Format output for start and end date.
Class to manage invoices.
Class to manage payments for supplier invoices.
dol_time_plus_duree($time, $duration_value, $duration_unit)
Add a delay to a date.