30require
'../../main.inc.php';
31require_once DOL_DOCUMENT_ROOT.
'/core/lib/report.lib.php';
32require_once DOL_DOCUMENT_ROOT.
'/core/lib/tax.lib.php';
33require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
34require_once DOL_DOCUMENT_ROOT.
'/compta/tva/class/tva.class.php';
35require_once DOL_DOCUMENT_ROOT.
'/compta/localtax/class/localtax.class.php';
36require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
37require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
38require_once DOL_DOCUMENT_ROOT.
'/compta/paiement/class/paiement.class.php';
39require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.facture.class.php';
40require_once DOL_DOCUMENT_ROOT.
'/fourn/class/paiementfourn.class.php';
41require_once DOL_DOCUMENT_ROOT.
'/expensereport/class/expensereport.class.php';
42require_once DOL_DOCUMENT_ROOT.
'/expensereport/class/paymentexpensereport.class.php';
45$langs->loadLangs(array(
"other",
"compta",
"banks",
"bills",
"companies",
"product",
"trips",
"admin"));
47include DOL_DOCUMENT_ROOT.
'/compta/tva/initdatesforvat.inc.php';
57if (GETPOSTISSET(
"modetax")) {
67 $socid = $user->socid;
78$company_static =
new Societe($db);
79$invoice_customer =
new Facture($db);
82$product_static =
new Product($db);
86$user_static =
new User($db);
89$listofparams = array(
'date_startmonth',
'date_startyear',
'date_startday',
'date_endmonth',
'date_endyear',
'date_endday');
90foreach ($listofparams as $param) {
92 $morequerystring .= ($morequerystring ?
'&' :
'').$param.
'='.
GETPOST($param);
96$special_report =
false;
97if (isset($_REQUEST[
'extra_report']) && $_REQUEST[
'extra_report'] == 1) {
98 $special_report =
true;
101llxHeader(
'', $langs->trans(
"VATReport"),
'',
'', 0, 0,
'',
'', $morequerystring);
103$fsearch =
'<!-- hidden fields for form -->';
104$fsearch .=
'<input type="hidden" name="token" value="'.newToken().
'">';
105$fsearch .=
'<input type="hidden" name="modetax" value="'.$modetax.
'">';
106$fsearch .= $langs->trans(
"SalesTurnoverMinimum").
': ';
107$fsearch .=
'<input type="text" name="min" id="min" value="'.$min.
'" size="6">';
110$name = $langs->trans(
"VATReportByThirdParties");
113 $calcmode = $langs->trans(
'OptionVATDefault');
116 $calcmode = $langs->trans(
'OptionVATDebitOption');
119 $calcmode = $langs->trans(
'OptionPaymentForProductAndServices');
121$calcmode .=
' <span class="opacitymedium">('.$langs->trans(
"TaxModuleSetupToModifyRules", DOL_URL_ROOT.
'/admin/taxes.php').
')</span>';
123$period = $form->selectDate($date_start,
'date_start', 0, 0, 0,
'', 1, 0).
' - '.$form->selectDate($date_end,
'date_end', 0, 0, 0,
'', 1, 0);
124$prevyear = $date_start_year;
127if ($prevquarter > 1) {
133$nextyear = $date_start_year;
135if ($nextquarter < 4) {
144 $description = $langs->trans(
"RulesVATDueProducts");
147 $description .= $langs->trans(
"RulesVATInProducts");
150 $description .=
'<br>'.$langs->trans(
"RulesVATDueServices");
153 $description .=
'<br>'.$langs->trans(
"RulesVATInServices");
156 $description .=
'<br>'.$langs->trans(
"DepositsAreNotIncluded");
159 $description .= $langs->trans(
"SupplierDepositsAreNotIncluded");
161if (isModEnabled(
'accounting')) {
162 $description .=
'<br>'.$langs->trans(
"ThisIsAnEstimatedValue");
166$description .= ($description ?
'<br>' :
'').$fsearch;
168 $description .=
'<br>';
169 $description .=
'<input type="radio" name="extra_report" value="0" '.($special_report ?
'' :
'checked="checked"').
'> ';
170 $description .= $langs->trans(
'SimpleReport');
171 $description .=
'</input>';
172 $description .=
'<br>';
173 $description .=
'<input type="radio" name="extra_report" value="1" '.($special_report ?
'checked="checked"' :
'').
'> ';
174 $description .= $langs->trans(
'AddExtraReport');
175 $description .=
'</input>';
176 $description .=
'<br>';
179$elementcust = $langs->trans(
"CustomersInvoices");
180$productcust = $langs->trans(
"Description");
181$namerate = $langs->trans(
"VATRate");
182$amountcust = $langs->trans(
"AmountHT");
183if ($mysoc->tva_assuj) {
184 $vatcust =
' ('.$langs->trans(
"StatusToPay").
')';
186$elementsup = $langs->trans(
"SuppliersInvoices");
187$productsup = $langs->trans(
"Description");
188$amountsup = $langs->trans(
"AmountHT");
189if ($mysoc->tva_assuj) {
190 $vatsup =
' ('.$langs->trans(
"ToGetBack").
')';
195report_header($name,
'', $period, $periodlink, $description, $builddate, $exportlink, array(), $calcmode);
197$vatcust = $langs->trans(
"VATReceived");
198$vatsup = $langs->trans(
"VATPaid");
202print
'<div class="div-table-responsive">';
203print
"<table class=\"noborder\" width=\"100%\">";
215$x_coll =
tax_by_thirdparty(
'vat', $db, 0, $date_start, $date_end, $modetax,
'sell');
216$x_paye =
tax_by_thirdparty(
'vat', $db, 0, $date_start, $date_end, $modetax,
'buy');
218if (!is_array($x_coll) || !is_array($x_paye)) {
219 $langs->load(
"errors");
221 print
'<tr><td colspan="'.$columns.
'">'.$langs->trans(
"ErrorNoAccountancyModuleLoaded").
'</td></tr>';
222 } elseif ($x_coll == -2) {
223 print
'<tr><td colspan="'.$columns.
'">'.$langs->trans(
"FeatureNotYetAvailable").
'</td></tr>';
225 print
'<tr><td colspan="'.$columns.
'">'.$langs->trans(
"Error").
'</td></tr>';
230 foreach (array_keys($x_coll) as $my_coll_thirdpartyid) {
231 $x_both[$my_coll_thirdpartyid][
'coll'][
'totalht'] = $x_coll[$my_coll_thirdpartyid][
'totalht'];
232 $x_both[$my_coll_thirdpartyid][
'coll'][
'vat'] = $x_coll[$my_coll_thirdpartyid][
'vat'];
233 $x_both[$my_coll_thirdpartyid][
'paye'][
'totalht'] = 0;
234 $x_both[$my_coll_thirdpartyid][
'paye'][
'vat'] = 0;
235 $x_both[$my_coll_thirdpartyid][
'coll'][
'links'] =
'';
236 $x_both[$my_coll_thirdpartyid][
'coll'][
'detail'] = array();
237 foreach ($x_coll[$my_coll_thirdpartyid][
'facid'] as $id => $dummy) {
238 $invoice_customer->id = $x_coll[$my_coll_thirdpartyid][
'facid'][$id];
239 $invoice_customer->ref = $x_coll[$my_coll_thirdpartyid][
'facnum'][$id];
240 $invoice_customer->type = $x_coll[$my_coll_thirdpartyid][
'type'][$id];
243 $company_static->id = $x_coll[$my_coll_thirdpartyid][
'company_id'][$id];
244 $company_static->name = $x_coll[$my_coll_thirdpartyid][
'company_name'][$id];
245 $company_static->name_alias = $x_coll[$my_coll_thirdpartyid][
'company_alias'][$id];
246 $company_static->email = $x_coll[$my_coll_thirdpartyid][
'company_email'][$id];
247 $company_static->tva_intra = isset($x_coll[$my_coll_thirdpartyid][
'tva_intra'][$id]) ? $x_coll[$my_coll_thirdpartyid][
'tva_intra'][$id] : 0;
248 $company_static->client = $x_coll[$my_coll_thirdpartyid][
'company_client'][$id];
249 $company_static->fournisseur = $x_coll[$my_coll_thirdpartyid][
'company_fournisseur'][$id];
250 $company_static->status = $x_coll[$my_coll_thirdpartyid][
'company_status'][$id];
251 $company_static->code_client = $x_coll[$my_coll_thirdpartyid][
'company_customer_code'][$id];
252 $company_static->code_compta_client = $x_coll[$my_coll_thirdpartyid][
'company_customer_accounting_code'][$id];
253 $company_static->code_fournisseur = $x_coll[$my_coll_thirdpartyid][
'company_supplier_code'][$id];
254 $company_static->code_compta_fournisseur = $x_coll[$my_coll_thirdpartyid][
'company_supplier_accounting_code'][$id];
256 $x_both[$my_coll_thirdpartyid][
'coll'][
'detail'][] = array(
257 'id' =>$x_coll[$my_coll_thirdpartyid][
'facid'][$id],
258 'descr' =>$x_coll[$my_coll_thirdpartyid][
'descr'][$id],
260 'pid' =>$x_coll[$my_coll_thirdpartyid][
'pid'][$id],
261 'pref' =>isset($x_coll[$my_coll_thirdpartyid][
'pref'][$id]) ? $x_coll[$my_coll_thirdpartyid][
'pref'][$id] :
'',
262 'ptype' =>$x_coll[$my_coll_thirdpartyid][
'ptype'][$id],
263 'pstatus' =>isset($x_paye[$my_coll_thirdpartyid][
'pstatus'][$id]) ? $x_paye[$my_coll_thirdpartyid][
'pstatus'][$id] :
'',
264 'pstatusbuy'=>isset($x_paye[$my_coll_thirdpartyid][
'pstatusbuy'][$id]) ? $x_paye[$my_coll_thirdpartyid][
'pstatusbuy'][$id] :
'',
266 'payment_id'=>$x_coll[$my_coll_thirdpartyid][
'payment_id'][$id],
267 'payment_ref'=>isset($x_coll[$my_coll_thirdpartyid][
'payment_ref'][$id]) ? $x_coll[$my_coll_thirdpartyid][
'payment_ref'][$id] :
'',
268 'payment_amount'=>$x_coll[$my_coll_thirdpartyid][
'payment_amount'][$id],
269 'ftotal_ttc'=>$x_coll[$my_coll_thirdpartyid][
'ftotal_ttc'][$id],
270 'dtotal_ttc'=>$x_coll[$my_coll_thirdpartyid][
'dtotal_ttc'][$id],
271 'dtype' =>$x_coll[$my_coll_thirdpartyid][
'dtype'][$id],
272 'drate' =>$x_coll[$my_coll_thirdpartyid][
'drate'][$id],
273 'datef' =>$x_coll[$my_coll_thirdpartyid][
'datef'][$id],
274 'datep' =>$x_coll[$my_coll_thirdpartyid][
'datep'][$id],
276 'company_link'=>$company_static->getNomUrl(1,
'', 20),
278 'ddate_start'=>$x_coll[$my_coll_thirdpartyid][
'ddate_start'][$id],
279 'ddate_end' =>$x_coll[$my_coll_thirdpartyid][
'ddate_end'][$id],
280 'totalht' =>$x_coll[$my_coll_thirdpartyid][
'totalht_list'][$id],
281 'vat' =>$x_coll[$my_coll_thirdpartyid][
'vat_list'][$id],
282 'link' =>$invoice_customer->getNomUrl(1,
'', 12)
287 foreach (array_keys($x_paye) as $my_paye_thirdpartyid) {
288 $x_both[$my_paye_thirdpartyid][
'paye'][
'totalht'] = $x_paye[$my_paye_thirdpartyid][
'totalht'];
289 $x_both[$my_paye_thirdpartyid][
'paye'][
'vat'] = $x_paye[$my_paye_thirdpartyid][
'vat'];
290 if (!isset($x_both[$my_paye_thirdpartyid][
'coll'][
'totalht'])) {
291 $x_both[$my_paye_thirdpartyid][
'coll'][
'totalht'] = 0;
292 $x_both[$my_paye_thirdpartyid][
'coll'][
'vat'] = 0;
294 $x_both[$my_paye_thirdpartyid][
'paye'][
'links'] =
'';
295 $x_both[$my_paye_thirdpartyid][
'paye'][
'detail'] = array();
297 foreach ($x_paye[$my_paye_thirdpartyid][
'facid'] as $id => $dummy) {
299 if ($x_paye[$my_paye_thirdpartyid][
'ptype'][$id] ==
'ExpenseReportPayment') {
300 $expensereport->id = $x_paye[$my_paye_thirdpartyid][
'facid'][$id];
301 $expensereport->ref = $x_paye[$my_paye_thirdpartyid][
'facnum'][$id];
302 $expensereport->type = $x_paye[$my_paye_thirdpartyid][
'type'][$id];
304 $x_both[$my_paye_thirdpartyid][
'paye'][
'detail'][] = array(
305 'id' =>$x_paye[$my_paye_thirdpartyid][
'facid'][$id],
306 'descr' =>$x_paye[$my_paye_thirdpartyid][
'descr'][$id],
308 'pid' =>$x_paye[$my_paye_thirdpartyid][
'pid'][$id],
309 'pref' =>$x_paye[$my_paye_thirdpartyid][
'pref'][$id],
310 'ptype' =>$x_paye[$my_paye_thirdpartyid][
'ptype'][$id],
311 'pstatus' =>$x_paye[$my_paye_thirdpartyid][
'pstatus'][$id],
312 'pstatusbuy' =>$x_paye[$my_paye_thirdpartyid][
'pstatusbuy'][$id],
314 'payment_id' =>$x_paye[$my_paye_thirdpartyid][
'payment_id'][$id],
315 'payment_ref' =>$x_paye[$my_paye_thirdpartyid][
'payment_ref'][$id],
316 'payment_amount' =>$x_paye[$my_paye_thirdpartyid][
'payment_amount'][$id],
317 'ftotal_ttc' =>
price2num($x_paye[$my_paye_thirdpartyid][
'ftotal_ttc'][$id]),
318 'dtotal_ttc' =>
price2num($x_paye[$my_paye_thirdpartyid][
'dtotal_ttc'][$id]),
319 'dtype' =>$x_paye[$my_paye_thirdpartyid][
'dtype'][$id],
320 'drate' =>$x_paye[$my_coll_thirdpartyid][
'drate'][$id],
321 'ddate_start' =>$x_paye[$my_paye_thirdpartyid][
'ddate_start'][$id],
322 'ddate_end' =>$x_paye[$my_paye_thirdpartyid][
'ddate_end'][$id],
323 'totalht' =>
price2num($x_paye[$my_paye_thirdpartyid][
'totalht_list'][$id]),
324 'vat' =>$x_paye[$my_paye_thirdpartyid][
'vat_list'][$id],
325 'link' =>$expensereport->getNomUrl(1)
328 $invoice_supplier->id = $x_paye[$my_paye_thirdpartyid][
'facid'][$id];
329 $invoice_supplier->ref = $x_paye[$my_paye_thirdpartyid][
'facnum'][$id];
330 $invoice_supplier->type = $x_paye[$my_paye_thirdpartyid][
'type'][$id];
333 $company_static->id = $x_paye[$my_paye_thirdpartyid][
'company_id'][$id];
334 $company_static->name = $x_paye[$my_paye_thirdpartyid][
'company_name'][$id];
335 $company_static->name_alias = $x_paye[$my_paye_thirdpartyid][
'company_alias'][$id];
336 $company_static->email = $x_paye[$my_paye_thirdpartyid][
'company_email'][$id];
337 $company_static->tva_intra = $x_paye[$my_paye_thirdpartyid][
'tva_intra'][$id];
338 $company_static->client = $x_paye[$my_paye_thirdpartyid][
'company_client'][$id];
339 $company_static->fournisseur = $x_paye[$my_paye_thirdpartyid][
'company_fournisseur'][$id];
340 $company_static->status = $x_paye[$my_paye_thirdpartyid][
'company_status'][$id];
341 $company_static->code_client = $x_paye[$my_paye_thirdpartyid][
'company_customer_code'][$id];
342 $company_static->code_compta_client = $x_paye[$my_paye_thirdpartyid][
'company_customer_accounting_code'][$id];
343 $company_static->code_fournisseur = $x_paye[$my_paye_thirdpartyid][
'company_supplier_code'][$id];
344 $company_static->code_compta_fournisseur = $x_paye[$my_paye_thirdpartyid][
'company_supplier_accounting_code'][$id];
346 $x_both[$my_paye_thirdpartyid][
'paye'][
'detail'][] = array(
347 'id' =>$x_paye[$my_paye_thirdpartyid][
'facid'][$id],
348 'descr' =>$x_paye[$my_paye_thirdpartyid][
'descr'][$id],
350 'pid' =>$x_paye[$my_paye_thirdpartyid][
'pid'][$id],
351 'pref' =>$x_paye[$my_paye_thirdpartyid][
'pref'][$id],
352 'ptype' =>$x_paye[$my_paye_thirdpartyid][
'ptype'][$id],
353 'pstatus' =>$x_paye[$my_paye_thirdpartyid][
'pstatus'][$id],
354 'pstatusbuy'=>$x_paye[$my_paye_thirdpartyid][
'pstatusbuy'][$id],
356 'payment_id'=>$x_paye[$my_paye_thirdpartyid][
'payment_id'][$id],
357 'payment_ref'=>$x_paye[$my_paye_thirdpartyid][
'payment_ref'][$id],
358 'payment_amount'=>$x_paye[$my_paye_thirdpartyid][
'payment_amount'][$id],
359 'ftotal_ttc'=>
price2num($x_paye[$my_paye_thirdpartyid][
'ftotal_ttc'][$id]),
360 'dtotal_ttc'=>
price2num($x_paye[$my_paye_thirdpartyid][
'dtotal_ttc'][$id]),
361 'dtype' =>$x_paye[$my_paye_thirdpartyid][
'dtype'][$id],
362 'drate' =>$x_paye[$my_coll_thirdpartyid][
'drate'][$id],
363 'datef' =>$x_paye[$my_paye_thirdpartyid][
'datef'][$id],
364 'datep' =>$x_paye[$my_paye_thirdpartyid][
'datep'][$id],
366 'company_link'=>$company_static->getNomUrl(1,
'', 20),
368 'ddate_start'=>$x_paye[$my_paye_thirdpartyid][
'ddate_start'][$id],
369 'ddate_end' =>$x_paye[$my_paye_thirdpartyid][
'ddate_end'][$id],
370 'totalht' =>
price2num($x_paye[$my_paye_thirdpartyid][
'totalht_list'][$id]),
371 'vat' =>$x_paye[$my_paye_thirdpartyid][
'vat_list'][$id],
372 'link' =>$invoice_supplier->getNomUrl(1,
'', 12)
390 print
'<tr class="liste_titre">';
391 print
'<td class="left">'.$elementcust.
'</td>';
392 print
'<td class="left">'.$langs->trans(
"DateInvoice").
'</td>';
394 print
'<td class="left">'.$langs->trans(
"DatePayment").
'</td>';
398 print
'<td class="right"></td>';
399 print
'<td class="left">'.$productcust.
'</td>';
401 print
'<td class="right">'.$amountcust.
'</td>';
402 print
'<td class="right">'.$langs->trans(
"Payment").
' ('.$langs->trans(
"PercentOfInvoice").
')</td>';
404 print
'<td class="right">'.$langs->trans(
"AmountHTVATRealReceived").
'</td>';
405 print
'<td class="right">'.$vatcust.
'</td>';
408 $action =
"tvadetail";
409 $parameters[
"mode"] = $modetax;
410 $parameters[
"start"] = $date_start;
411 $parameters[
"end"] = $date_end;
412 $parameters[
"type"] =
'vat';
414 $object = array(&$x_coll, &$x_paye, &$x_both);
416 $hookmanager->initHooks(array(
'externalbalance'));
417 $reshook = $hookmanager->executeHooks(
'addVatLine', $parameters, $object, $action);
419 foreach (array_keys($x_coll) as $thirdparty_id) {
420 $subtot_coll_total_ht = 0;
421 $subtot_coll_vat = 0;
423 if ($min == 0 || ($min > 0 && $x_both[$thirdparty_id][
'coll'][
'totalht'] > $min)) {
424 if (is_array($x_both[$thirdparty_id][
'coll'][
'detail'])) {
427 print
'<td class="tax_rate">';
428 if (is_numeric($thirdparty_id)) {
429 $company_static->fetch($thirdparty_id);
430 print $langs->trans(
"ThirdParty").
': '.$company_static->getNomUrl(1);
432 $tmpid = preg_replace(
'/userid_/',
'', $thirdparty_id);
433 $user_static->fetch($tmpid);
434 print $langs->trans(
"User").
': '.$user_static->getNomUrl(1);
436 print
'</td><td colspan="'.($span + 1).
'"></td>';
439 foreach ($x_both[$thirdparty_id][
'coll'][
'detail'] as $index => $fields) {
442 $type = (isset($fields[
'dtype']) ? $fields[
'dtype'] : $fields[
'ptype']);
445 if (!empty($fields[
'ddate_start'])) {
448 if (!empty($fields[
'ddate_end'])) {
452 print
'<tr class="oddeven">';
455 print
'<td class="nowrap left">'.$fields[
'link'].
'</td>';
458 print
'<td class="left">'.dol_print_date($fields[
'datef'],
'day').
'</td>';
462 print
'<td class="left">'.dol_print_date($fields[
'datep'],
'day').
'</td>';
468 print
'<td class="right">'.$fields[
'drate'].
'</td>';
471 print
'<td class="left">';
472 if ($fields[
'pid']) {
473 $product_static->id = $fields[
'pid'];
474 $product_static->ref = $fields[
'pref'];
475 $product_static->type = $fields[
'dtype'];
476 $product_static->status = $fields[
'pstatus'];
477 $product_static->status_buy = $fields[
'pstatusbuy'];
479 print $product_static->getNomUrl(1);
485 $text =
img_object($langs->trans(
'Service'),
'service');
487 $text =
img_object($langs->trans(
'Product'),
'product');
489 if (preg_match(
'/^\((.*)\)$/', $fields[
'descr'], $reg)) {
490 if ($reg[1] ==
'DEPOSIT') {
491 $fields[
'descr'] = $langs->transnoentitiesnoconv(
'Deposit');
492 } elseif ($reg[1] ==
'CREDIT_NOTE') {
493 $fields[
'descr'] = $langs->transnoentitiesnoconv(
'CreditNote');
495 $fields[
'descr'] = $langs->transnoentitiesnoconv($reg[1]);
507 print
'<td class="nowrap right"><span class="amount">';
508 print
price($fields[
'totalht']);
511 $ratiolineinvoice = ($fields[
'dtotal_ttc'] / $fields[
'ftotal_ttc']);
514 print
'</span></td>';
518 $ratiopaymentinvoice = 1;
520 print
'<td class="nowrap right">';
522 if ($fields[
'payment_amount'] && $fields[
'ftotal_ttc']) {
523 $payment_static->id = $fields[
'payment_id'];
524 $payment_static->ref = $fields[
'payment_ref'];
525 print $payment_static->getNomUrl(2,
'',
'', 0).
' ';
529 print $langs->trans(
"NA");
531 if (isset($fields[
'payment_amount']) &&
price2num($fields[
'ftotal_ttc'])) {
532 $ratiopaymentinvoice = ($fields[
'payment_amount'] / $fields[
'ftotal_ttc']);
534 print
'<span class="amount">'.price(
price2num($fields[
'payment_amount'],
'MT')).
'</span>';
535 if (isset($fields[
'payment_amount'])) {
536 print
' ('.round($ratiopaymentinvoice * 100, 2).
'%)';
543 print
'<td class="nowrap right"><span class="amount">';
544 $temp_ht = $fields[
'totalht'] * $ratiopaymentinvoice;
546 print
'</span></td>';
549 print
'<td class="nowrap right"><span class="amount">';
550 $temp_vat = $fields[
'vat'] * $ratiopaymentinvoice;
553 print
'</span></td>';
556 $subtot_coll_total_ht += $temp_ht;
557 $subtot_coll_vat += $temp_vat;
558 $x_coll_sum += $temp_vat;
563 print
'<tr class="liste_total">';
564 print
'<td colspan="4"></td>';
565 print
'<td class="right">'.$langs->trans(
"Total").
':</td>';
567 print
'<td class="nowrap right"> </td>';
568 print
'<td class="right"> </td>';
570 print
'<td class="right"><span class="amount">'.price(
price2num($subtot_coll_total_ht,
'MT')).
'</span></td>';
571 print
'<td class="nowrap right"><span class="amount">'.price(
price2num($subtot_coll_vat,
'MT')).
'</span></td>';
576 if (count($x_coll) == 0) {
577 print
'<tr class="liste_total">';
578 print
'<td colspan="4"></td>';
579 print
'<td class="right">'.$langs->trans(
"Total").
':</td>';
581 print
'<td class="nowrap right"> </td>';
582 print
'<td class="right"> </td>';
584 print
'<td class="right">'.price(
price2num(0,
'MT')).
'</td>';
585 print
'<td class="nowrap right">'.price(
price2num(0,
'MT')).
'</td>';
590 print
'<tr><td colspan="'.($span + 1).
'"> </td></tr>';
593 print
'<tr class="liste_titre liste_titre_topborder">';
594 print
'<td class="left">'.$elementsup.
'</td>';
595 print
'<td class="left">'.$langs->trans(
"DateInvoice").
'</td>';
597 print
'<td class="left">'.$langs->trans(
"DatePayment").
'</td>';
601 print
'<td class="left"></td>';
602 print
'<td class="left">'.$productsup.
'</td>';
604 print
'<td class="right">'.$amountsup.
'</td>';
605 print
'<td class="right">'.$langs->trans(
"Payment").
' ('.$langs->trans(
"PercentOfInvoice").
')</td>';
607 print
'<td class="right">'.$langs->trans(
"AmountHTVATRealPaid").
'</td>';
608 print
'<td class="right">'.$vatsup.
'</td>';
611 foreach (array_keys($x_paye) as $thirdparty_id) {
612 $subtot_paye_total_ht = 0;
613 $subtot_paye_vat = 0;
615 if ($min == 0 || ($min > 0 && $x_both[$thirdparty_id][
'paye'][
'totalht'] > $min)) {
616 if (is_array($x_both[$thirdparty_id][
'paye'][
'detail'])) {
618 print
'<td class="tax_rate">';
619 if (is_numeric($thirdparty_id)) {
620 $company_static->fetch($thirdparty_id);
621 print $langs->trans(
"ThirdParty").
': '.$company_static->getNomUrl(1);
623 $tmpid = preg_replace(
'/userid_/',
'', $thirdparty_id);
624 $user_static->fetch($tmpid);
625 print $langs->trans(
"User").
': '.$user_static->getNomUrl(1);
627 print
'<td colspan="'.($span + 1).
'"></td>';
630 foreach ($x_both[$thirdparty_id][
'paye'][
'detail'] as $index => $fields) {
633 $type = (isset($fields[
'dtype']) ? $fields[
'dtype'] : $fields[
'ptype']);
636 if (!empty($fields[
'ddate_start'])) {
639 if (!empty($fields[
'ddate_end'])) {
644 print
'<tr class="oddeven">';
647 print
'<td class="nowrap left">'.$fields[
'link'].
'</td>';
650 print
'<td class="left">'.dol_print_date($fields[
'datef'],
'day').
'</td>';
654 print
'<td class="left">'.dol_print_date($fields[
'datep'],
'day').
'</td>';
660 print
'<td class="tdmaxoverflow150">';
661 print $fields[
'company_link'];
665 print
'<td class="left">';
666 if ($fields[
'pid']) {
667 $product_static->id = $fields[
'pid'];
668 $product_static->ref = $fields[
'pref'];
669 $product_static->type = $fields[
'dtype'];
670 print $product_static->getNomUrl(1);
676 $text =
img_object($langs->trans(
'Service'),
'service');
678 $text =
img_object($langs->trans(
'Product'),
'product');
680 if (preg_match(
'/^\((.*)\)$/', $fields[
'descr'], $reg)) {
681 if ($reg[1] ==
'DEPOSIT') {
682 $fields[
'descr'] = $langs->transnoentitiesnoconv(
'Deposit');
683 } elseif ($reg[1] ==
'CREDIT_NOTE') {
684 $fields[
'descr'] = $langs->transnoentitiesnoconv(
'CreditNote');
686 $fields[
'descr'] = $langs->transnoentitiesnoconv($reg[1]);
698 print
'<td class="nowrap right"><span class="amount">';
699 print
price($fields[
'totalht']);
702 $ratiolineinvoice = ($fields[
'dtotal_ttc'] / $fields[
'ftotal_ttc']);
705 print
'</span></td>';
709 $ratiopaymentinvoice = 1;
711 print
'<td class="nowrap right">';
712 if ($fields[
'payment_amount'] && $fields[
'ftotal_ttc']) {
713 $paymentfourn_static->id = $fields[
'payment_id'];
714 $paymentfourn_static->ref = $fields[
'payment_ref'];
715 print $paymentfourn_static->getNomUrl(2,
'',
'', 0);
720 print $langs->trans(
"NA");
722 if (isset($fields[
'payment_amount']) && $fields[
'ftotal_ttc']) {
723 $ratiopaymentinvoice = ($fields[
'payment_amount'] / $fields[
'ftotal_ttc']);
725 print
'<span class="amount">'.price(
price2num($fields[
'payment_amount'],
'MT')).
'</span>';
726 if (isset($fields[
'payment_amount'])) {
727 print
' ('.round($ratiopaymentinvoice * 100, 2).
'%)';
734 print
'<td class="nowrap right"><span class="amount">';
735 $temp_ht = $fields[
'totalht'] * $ratiopaymentinvoice;
737 print
'</span></td>';
740 print
'<td class="nowrap right"><span class="amount">';
741 $temp_vat = $fields[
'vat'] * $ratiopaymentinvoice;
744 print
'</span></td>';
747 $subtot_paye_total_ht += $temp_ht;
748 $subtot_paye_vat += $temp_vat;
749 $x_paye_sum += $temp_vat;
753 print
'<tr class="liste_total">';
754 print
'<td colspan="4"></td>';
755 print
'<td class="right">'.$langs->trans(
"Total").
':</td>';
757 print
'<td class="nowrap right"> </td>';
758 print
'<td class="right"> </td>';
760 print
'<td class="right"><span class="amount">'.price(
price2num($subtot_paye_total_ht,
'MT')).
'</span></td>';
761 print
'<td class="nowrap right"><span class="amount">'.price(
price2num($subtot_paye_vat,
'MT')).
'</span></td>';
766 if (count($x_paye) == 0) {
767 print
'<tr class="liste_total">';
768 print
'<td colspan="4"></td>';
769 print
'<td class="right">'.$langs->trans(
"Total").
':</td>';
771 print
'<td class="nowrap right"> </td>';
772 print
'<td class="right"> </td>';
774 print
'<td class="right">'.price(
price2num(0,
'MT')).
'</td>';
775 print
'<td class="nowrap right">'.price(
price2num(0,
'MT')).
'</td>';
780 print
'<tr><td colspan="'.($span + 2).
'"></td></tr>';
782 $diff = $x_coll_sum - $x_paye_sum;
783 print
'<tr class="liste_total">';
784 print
'<td class="liste_total" colspan="'.($span + 1).
'">'.$langs->trans(
"TotalToPay").($q ?
', '.$langs->trans(
"Quadri").
' '.$q :
'').
'</td>';
785 print
'<td class="liste_total nowrap right"><b>'.price(
price2num($diff,
'MT')).
"</b></td>\n";
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader()
Empty header.
Class to manage Trips and Expenses.
Class to manage suppliers invoices.
Class to manage invoices.
Class to manage payments for supplier invoices.
Class to manage payments of customer invoices.
Class to manage payments of expense report.
Class to manage products or services.
Class to manage third parties objects (customers, suppliers, prospects...)
Class to manage Dolibarr users.
GETPOSTINT($paramname, $method=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.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0)
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.
dol_now($mode='auto')
Return date for now.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
print_date_range($date_start, $date_end, $format='', $outputlangs='')
Format output for start and end date.
dol_trunc($string, $size=40, $trunc='right', $stringencoding='UTF-8', $nodot=0, $display=0)
Truncate a string to a particular length adding '…' if string larger than length.
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
report_header($reportname, $notused, $period, $periodlink, $description, $builddate, $exportlink='', $moreparam=array(), $calcmode='', $varlink='')
Show header of a report.
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.
tax_by_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)