31require
'../../main.inc.php';
32require_once DOL_DOCUMENT_ROOT.
'/core/lib/report.lib.php';
33require_once DOL_DOCUMENT_ROOT.
'/core/lib/tax.lib.php';
34require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
35require_once DOL_DOCUMENT_ROOT.
'/compta/tva/class/tva.class.php';
36require_once DOL_DOCUMENT_ROOT.
'/compta/localtax/class/localtax.class.php';
37require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
38require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
39require_once DOL_DOCUMENT_ROOT.
'/compta/paiement/class/paiement.class.php';
40require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.facture.class.php';
41require_once DOL_DOCUMENT_ROOT.
'/fourn/class/paiementfourn.class.php';
42require_once DOL_DOCUMENT_ROOT.
'/expensereport/class/expensereport.class.php';
43require_once DOL_DOCUMENT_ROOT.
'/expensereport/class/paymentexpensereport.class.php';
46$langs->loadLangs(array(
"other",
"compta",
"banks",
"bills",
"companies",
"product",
"trips",
"admin"));
48include DOL_DOCUMENT_ROOT.
'/compta/tva/initdatesforvat.inc.php';
58if (GETPOSTISSET(
"modetax")) {
68 $socid = $user->socid;
79$company_static =
new Societe($db);
80$invoice_customer =
new Facture($db);
83$product_static =
new Product($db);
87$user_static =
new User($db);
90$listofparams = array(
'date_startmonth',
'date_startyear',
'date_startday',
'date_endmonth',
'date_endyear',
'date_endday');
91foreach ($listofparams as $param) {
93 $morequerystring .= ($morequerystring ?
'&' :
'').$param.
'='.
GETPOST($param);
97$special_report =
false;
98if (isset($_REQUEST[
'extra_report']) && $_REQUEST[
'extra_report'] == 1) {
99 $special_report =
true;
102llxHeader(
'', $langs->trans(
"VATReport"),
'',
'', 0, 0,
'',
'', $morequerystring);
104$fsearch =
'<!-- hidden fields for form -->';
105$fsearch .=
'<input type="hidden" name="token" value="'.newToken().
'">';
106$fsearch .=
'<input type="hidden" name="modetax" value="'.$modetax.
'">';
107$fsearch .= $langs->trans(
"SalesTurnoverMinimum").
': ';
108$fsearch .=
'<input type="text" name="min" id="min" value="'.$min.
'" size="6">';
111$name = $langs->trans(
"VATReportByThirdParties");
114 $calcmode = $langs->trans(
'OptionVATDefault');
117 $calcmode = $langs->trans(
'OptionVATDebitOption');
120 $calcmode = $langs->trans(
'OptionPaymentForProductAndServices');
122$calcmode .=
' <span class="opacitymedium">('.$langs->trans(
"TaxModuleSetupToModifyRules", DOL_URL_ROOT.
'/admin/taxes.php').
')</span>';
124$period = $form->selectDate($date_start,
'date_start', 0, 0, 0,
'', 1, 0).
' - '.$form->selectDate($date_end,
'date_end', 0, 0, 0,
'', 1, 0);
125$prevyear = $date_start_year;
128if ($prevquarter > 1) {
134$nextyear = $date_start_year;
136if ($nextquarter < 4) {
145 $description = $langs->trans(
"RulesVATDueProducts");
148 $description .= $langs->trans(
"RulesVATInProducts");
151 $description .=
'<br>'.$langs->trans(
"RulesVATDueServices");
154 $description .=
'<br>'.$langs->trans(
"RulesVATInServices");
157 $description .=
'<br>'.$langs->trans(
"DepositsAreNotIncluded");
160 $description .= $langs->trans(
"SupplierDepositsAreNotIncluded");
162if (isModEnabled(
'accounting')) {
163 $description .=
'<br>'.$langs->trans(
"ThisIsAnEstimatedValue");
167$description .= ($description ?
'<br>' :
'').$fsearch;
169 $description .=
'<br>';
170 $description .=
'<input type="radio" name="extra_report" value="0" '.($special_report ?
'' :
'checked="checked"').
'> ';
171 $description .= $langs->trans(
'SimpleReport');
172 $description .=
'</input>';
173 $description .=
'<br>';
174 $description .=
'<input type="radio" name="extra_report" value="1" '.($special_report ?
'checked="checked"' :
'').
'> ';
175 $description .= $langs->trans(
'AddExtraReport');
176 $description .=
'</input>';
177 $description .=
'<br>';
180$elementcust = $langs->trans(
"CustomersInvoices");
181$productcust = $langs->trans(
"Description");
182$namerate = $langs->trans(
"VATRate");
183$amountcust = $langs->trans(
"AmountHT");
184if ($mysoc->tva_assuj) {
185 $vatcust =
' ('.$langs->trans(
"StatusToPay").
')';
187$elementsup = $langs->trans(
"SuppliersInvoices");
188$productsup = $langs->trans(
"Description");
189$amountsup = $langs->trans(
"AmountHT");
190if ($mysoc->tva_assuj) {
191 $vatsup =
' ('.$langs->trans(
"ToGetBack").
')';
196report_header($name,
'', $period, $periodlink, $description, $builddate, $exportlink, array(), $calcmode);
198$vatcust = $langs->trans(
"VATReceived");
199$vatsup = $langs->trans(
"VATPaid");
203print
'<div class="div-table-responsive">';
204print
"<table class=\"noborder\" width=\"100%\">";
216$x_coll =
tax_by_thirdparty(
'vat', $db, 0, $date_start, $date_end, $modetax,
'sell');
217$x_paye =
tax_by_thirdparty(
'vat', $db, 0, $date_start, $date_end, $modetax,
'buy');
219if (!is_array($x_coll) || !is_array($x_paye)) {
220 $langs->load(
"errors");
222 print
'<tr><td colspan="'.$columns.
'">'.$langs->trans(
"ErrorNoAccountancyModuleLoaded").
'</td></tr>';
223 } elseif ($x_coll == -2) {
224 print
'<tr><td colspan="'.$columns.
'">'.$langs->trans(
"FeatureNotYetAvailable").
'</td></tr>';
226 print
'<tr><td colspan="'.$columns.
'">'.$langs->trans(
"Error").
'</td></tr>';
231 foreach (array_keys($x_coll) as $my_coll_thirdpartyid) {
232 $x_both[$my_coll_thirdpartyid][
'coll'][
'totalht'] = $x_coll[$my_coll_thirdpartyid][
'totalht'];
233 $x_both[$my_coll_thirdpartyid][
'coll'][
'vat'] = $x_coll[$my_coll_thirdpartyid][
'vat'];
234 $x_both[$my_coll_thirdpartyid][
'paye'][
'totalht'] = 0;
235 $x_both[$my_coll_thirdpartyid][
'paye'][
'vat'] = 0;
236 $x_both[$my_coll_thirdpartyid][
'coll'][
'links'] =
'';
237 $x_both[$my_coll_thirdpartyid][
'coll'][
'detail'] = array();
238 foreach ($x_coll[$my_coll_thirdpartyid][
'facid'] as $id => $dummy) {
239 $invoice_customer->id = $x_coll[$my_coll_thirdpartyid][
'facid'][$id];
240 $invoice_customer->ref = $x_coll[$my_coll_thirdpartyid][
'facnum'][$id];
241 $invoice_customer->type = $x_coll[$my_coll_thirdpartyid][
'type'][$id];
244 $company_static->id = $x_coll[$my_coll_thirdpartyid][
'company_id'][$id];
245 $company_static->name = $x_coll[$my_coll_thirdpartyid][
'company_name'][$id];
246 $company_static->name_alias = $x_coll[$my_coll_thirdpartyid][
'company_alias'][$id];
247 $company_static->email = $x_coll[$my_coll_thirdpartyid][
'company_email'][$id];
248 $company_static->tva_intra = isset($x_coll[$my_coll_thirdpartyid][
'tva_intra'][$id]) ? $x_coll[$my_coll_thirdpartyid][
'tva_intra'][$id] : 0;
249 $company_static->client = $x_coll[$my_coll_thirdpartyid][
'company_client'][$id];
250 $company_static->fournisseur = $x_coll[$my_coll_thirdpartyid][
'company_fournisseur'][$id];
251 $company_static->status = $x_coll[$my_coll_thirdpartyid][
'company_status'][$id];
252 $company_static->code_client = $x_coll[$my_coll_thirdpartyid][
'company_customer_code'][$id];
253 $company_static->code_compta_client = $x_coll[$my_coll_thirdpartyid][
'company_customer_accounting_code'][$id];
254 $company_static->code_fournisseur = $x_coll[$my_coll_thirdpartyid][
'company_supplier_code'][$id];
255 $company_static->code_compta_fournisseur = $x_coll[$my_coll_thirdpartyid][
'company_supplier_accounting_code'][$id];
257 $x_both[$my_coll_thirdpartyid][
'coll'][
'detail'][] = array(
258 'id' => $x_coll[$my_coll_thirdpartyid][
'facid'][$id],
259 'descr' => $x_coll[$my_coll_thirdpartyid][
'descr'][$id],
261 'pid' => $x_coll[$my_coll_thirdpartyid][
'pid'][$id],
262 'pref' => isset($x_coll[$my_coll_thirdpartyid][
'pref'][$id]) ? $x_coll[$my_coll_thirdpartyid][
'pref'][$id] :
'',
263 'ptype' => $x_coll[$my_coll_thirdpartyid][
'ptype'][$id],
264 'pstatus' => isset($x_paye[$my_coll_thirdpartyid][
'pstatus'][$id]) ? $x_paye[$my_coll_thirdpartyid][
'pstatus'][$id] :
'',
265 'pstatusbuy' => isset($x_paye[$my_coll_thirdpartyid][
'pstatusbuy'][$id]) ? $x_paye[$my_coll_thirdpartyid][
'pstatusbuy'][$id] :
'',
267 'payment_id' => $x_coll[$my_coll_thirdpartyid][
'payment_id'][$id],
268 'payment_ref' => isset($x_coll[$my_coll_thirdpartyid][
'payment_ref'][$id]) ? $x_coll[$my_coll_thirdpartyid][
'payment_ref'][$id] :
'',
269 'payment_amount' => $x_coll[$my_coll_thirdpartyid][
'payment_amount'][$id],
270 'ftotal_ttc' => $x_coll[$my_coll_thirdpartyid][
'ftotal_ttc'][$id],
271 'dtotal_ttc' => $x_coll[$my_coll_thirdpartyid][
'dtotal_ttc'][$id],
272 'dtype' => $x_coll[$my_coll_thirdpartyid][
'dtype'][$id],
273 'drate' => $x_coll[$my_coll_thirdpartyid][
'drate'][$id],
274 'datef' => $x_coll[$my_coll_thirdpartyid][
'datef'][$id],
275 'datep' => $x_coll[$my_coll_thirdpartyid][
'datep'][$id],
277 'company_link' => $company_static->getNomUrl(1,
'', 20),
279 'ddate_start' => $x_coll[$my_coll_thirdpartyid][
'ddate_start'][$id],
280 'ddate_end' => $x_coll[$my_coll_thirdpartyid][
'ddate_end'][$id],
281 'totalht' => $x_coll[$my_coll_thirdpartyid][
'totalht_list'][$id],
282 'vat' => $x_coll[$my_coll_thirdpartyid][
'vat_list'][$id],
283 'link' => $invoice_customer->getNomUrl(1,
'', 12)
288 foreach (array_keys($x_paye) as $my_paye_thirdpartyid) {
289 $x_both[$my_paye_thirdpartyid][
'paye'][
'totalht'] = $x_paye[$my_paye_thirdpartyid][
'totalht'];
290 $x_both[$my_paye_thirdpartyid][
'paye'][
'vat'] = $x_paye[$my_paye_thirdpartyid][
'vat'];
291 if (!isset($x_both[$my_paye_thirdpartyid][
'coll'][
'totalht'])) {
292 $x_both[$my_paye_thirdpartyid][
'coll'][
'totalht'] = 0;
293 $x_both[$my_paye_thirdpartyid][
'coll'][
'vat'] = 0;
295 $x_both[$my_paye_thirdpartyid][
'paye'][
'links'] =
'';
296 $x_both[$my_paye_thirdpartyid][
'paye'][
'detail'] = array();
298 foreach ($x_paye[$my_paye_thirdpartyid][
'facid'] as $id => $dummy) {
300 if ($x_paye[$my_paye_thirdpartyid][
'ptype'][$id] ==
'ExpenseReportPayment') {
301 $expensereport->id = $x_paye[$my_paye_thirdpartyid][
'facid'][$id];
302 $expensereport->ref = $x_paye[$my_paye_thirdpartyid][
'facnum'][$id];
303 $expensereport->type = $x_paye[$my_paye_thirdpartyid][
'type'][$id];
305 $x_both[$my_paye_thirdpartyid][
'paye'][
'detail'][] = array(
306 'id' => $x_paye[$my_paye_thirdpartyid][
'facid'][$id],
307 'descr' => $x_paye[$my_paye_thirdpartyid][
'descr'][$id],
309 'pid' => $x_paye[$my_paye_thirdpartyid][
'pid'][$id],
310 'pref' => $x_paye[$my_paye_thirdpartyid][
'pref'][$id],
311 'ptype' => $x_paye[$my_paye_thirdpartyid][
'ptype'][$id],
312 'pstatus' => $x_paye[$my_paye_thirdpartyid][
'pstatus'][$id],
313 'pstatusbuy' => $x_paye[$my_paye_thirdpartyid][
'pstatusbuy'][$id],
315 'payment_id' => $x_paye[$my_paye_thirdpartyid][
'payment_id'][$id],
316 'payment_ref' => $x_paye[$my_paye_thirdpartyid][
'payment_ref'][$id],
317 'payment_amount' => $x_paye[$my_paye_thirdpartyid][
'payment_amount'][$id],
318 'ftotal_ttc' =>
price2num($x_paye[$my_paye_thirdpartyid][
'ftotal_ttc'][$id]),
319 'dtotal_ttc' =>
price2num($x_paye[$my_paye_thirdpartyid][
'dtotal_ttc'][$id]),
320 'dtype' => $x_paye[$my_paye_thirdpartyid][
'dtype'][$id],
321 'drate' => $x_paye[$my_coll_thirdpartyid][
'drate'][$id],
322 'ddate_start' => $x_paye[$my_paye_thirdpartyid][
'ddate_start'][$id],
323 'ddate_end' => $x_paye[$my_paye_thirdpartyid][
'ddate_end'][$id],
324 'totalht' =>
price2num($x_paye[$my_paye_thirdpartyid][
'totalht_list'][$id]),
325 'vat' => $x_paye[$my_paye_thirdpartyid][
'vat_list'][$id],
326 'link' => $expensereport->getNomUrl(1)
329 $invoice_supplier->id = $x_paye[$my_paye_thirdpartyid][
'facid'][$id];
330 $invoice_supplier->ref = $x_paye[$my_paye_thirdpartyid][
'facnum'][$id];
331 $invoice_supplier->type = $x_paye[$my_paye_thirdpartyid][
'type'][$id];
334 $company_static->id = $x_paye[$my_paye_thirdpartyid][
'company_id'][$id];
335 $company_static->name = $x_paye[$my_paye_thirdpartyid][
'company_name'][$id];
336 $company_static->name_alias = $x_paye[$my_paye_thirdpartyid][
'company_alias'][$id];
337 $company_static->email = $x_paye[$my_paye_thirdpartyid][
'company_email'][$id];
338 $company_static->tva_intra = $x_paye[$my_paye_thirdpartyid][
'tva_intra'][$id];
339 $company_static->client = $x_paye[$my_paye_thirdpartyid][
'company_client'][$id];
340 $company_static->fournisseur = $x_paye[$my_paye_thirdpartyid][
'company_fournisseur'][$id];
341 $company_static->status = $x_paye[$my_paye_thirdpartyid][
'company_status'][$id];
342 $company_static->code_client = $x_paye[$my_paye_thirdpartyid][
'company_customer_code'][$id];
343 $company_static->code_compta_client = $x_paye[$my_paye_thirdpartyid][
'company_customer_accounting_code'][$id];
344 $company_static->code_fournisseur = $x_paye[$my_paye_thirdpartyid][
'company_supplier_code'][$id];
345 $company_static->code_compta_fournisseur = $x_paye[$my_paye_thirdpartyid][
'company_supplier_accounting_code'][$id];
347 $x_both[$my_paye_thirdpartyid][
'paye'][
'detail'][] = array(
348 'id' => $x_paye[$my_paye_thirdpartyid][
'facid'][$id],
349 'descr' => $x_paye[$my_paye_thirdpartyid][
'descr'][$id],
351 'pid' => $x_paye[$my_paye_thirdpartyid][
'pid'][$id],
352 'pref' => $x_paye[$my_paye_thirdpartyid][
'pref'][$id],
353 'ptype' => $x_paye[$my_paye_thirdpartyid][
'ptype'][$id],
354 'pstatus' => $x_paye[$my_paye_thirdpartyid][
'pstatus'][$id],
355 'pstatusbuy' => $x_paye[$my_paye_thirdpartyid][
'pstatusbuy'][$id],
357 'payment_id' => $x_paye[$my_paye_thirdpartyid][
'payment_id'][$id],
358 'payment_ref' => $x_paye[$my_paye_thirdpartyid][
'payment_ref'][$id],
359 'payment_amount' => $x_paye[$my_paye_thirdpartyid][
'payment_amount'][$id],
360 'ftotal_ttc' =>
price2num($x_paye[$my_paye_thirdpartyid][
'ftotal_ttc'][$id]),
361 'dtotal_ttc' =>
price2num($x_paye[$my_paye_thirdpartyid][
'dtotal_ttc'][$id]),
362 'dtype' => $x_paye[$my_paye_thirdpartyid][
'dtype'][$id],
363 'drate' => $x_paye[$my_coll_thirdpartyid][
'drate'][$id],
364 'datef' => $x_paye[$my_paye_thirdpartyid][
'datef'][$id],
365 'datep' => $x_paye[$my_paye_thirdpartyid][
'datep'][$id],
367 'company_link' => $company_static->getNomUrl(1,
'', 20),
369 'ddate_start' => $x_paye[$my_paye_thirdpartyid][
'ddate_start'][$id],
370 'ddate_end' => $x_paye[$my_paye_thirdpartyid][
'ddate_end'][$id],
371 'totalht' =>
price2num($x_paye[$my_paye_thirdpartyid][
'totalht_list'][$id]),
372 'vat' => $x_paye[$my_paye_thirdpartyid][
'vat_list'][$id],
373 'link' => $invoice_supplier->getNomUrl(1,
'', 12)
391 print
'<tr class="liste_titre">';
392 print
'<td class="left">'.$elementcust.
'</td>';
393 print
'<td class="left">'.$langs->trans(
"DateInvoice").
'</td>';
395 print
'<td class="left">'.$langs->trans(
"DatePayment").
'</td>';
399 print
'<td class="right"></td>';
400 print
'<td class="left">'.$productcust.
'</td>';
402 print
'<td class="right">'.$amountcust.
'</td>';
403 print
'<td class="right">'.$langs->trans(
"Payment").
' ('.$langs->trans(
"PercentOfInvoice").
')</td>';
405 print
'<td class="right">'.$langs->trans(
"AmountHTVATRealReceived").
'</td>';
406 print
'<td class="right">'.$vatcust.
'</td>';
409 $action =
"tvadetail";
410 $parameters[
"mode"] = $modetax;
411 $parameters[
"start"] = $date_start;
412 $parameters[
"end"] = $date_end;
413 $parameters[
"type"] =
'vat';
415 $object = array(&$x_coll, &$x_paye, &$x_both);
417 $hookmanager->initHooks(array(
'externalbalance'));
418 $reshook = $hookmanager->executeHooks(
'addVatLine', $parameters,
$object, $action);
420 foreach (array_keys($x_coll) as $thirdparty_id) {
421 $subtot_coll_total_ht = 0;
422 $subtot_coll_vat = 0;
424 if ($min == 0 || ($min > 0 && $x_both[$thirdparty_id][
'coll'][
'totalht'] > $min)) {
425 if (is_array($x_both[$thirdparty_id][
'coll'][
'detail'])) {
428 print
'<td class="tax_rate">';
429 if (is_numeric($thirdparty_id)) {
430 $company_static->fetch($thirdparty_id);
431 print $langs->trans(
"ThirdParty").
': '.$company_static->getNomUrl(1);
433 $tmpid = preg_replace(
'/userid_/',
'', $thirdparty_id);
434 $user_static->fetch($tmpid);
435 print $langs->trans(
"User").
': '.$user_static->getNomUrl(1);
437 print
'</td><td colspan="'.($span + 1).
'"></td>';
440 foreach ($x_both[$thirdparty_id][
'coll'][
'detail'] as $index => $fields) {
443 $type = (isset($fields[
'dtype']) ? $fields[
'dtype'] : $fields[
'ptype']);
446 if (!empty($fields[
'ddate_start'])) {
449 if (!empty($fields[
'ddate_end'])) {
453 print
'<tr class="oddeven">';
456 print
'<td class="nowrap left">'.$fields[
'link'].
'</td>';
459 print
'<td class="left">'.dol_print_date($fields[
'datef'],
'day').
'</td>';
463 print
'<td class="left">'.dol_print_date($fields[
'datep'],
'day').
'</td>';
469 print
'<td class="right">'.$fields[
'drate'].
'</td>';
472 print
'<td class="left">';
473 if ($fields[
'pid']) {
474 $product_static->id = $fields[
'pid'];
475 $product_static->ref = $fields[
'pref'];
476 $product_static->type = $fields[
'dtype'];
477 $product_static->status = $fields[
'pstatus'];
478 $product_static->status_buy = $fields[
'pstatusbuy'];
480 print $product_static->getNomUrl(1);
486 $text =
img_object($langs->trans(
'Service'),
'service');
488 $text =
img_object($langs->trans(
'Product'),
'product');
490 if (preg_match(
'/^\((.*)\)$/', $fields[
'descr'], $reg)) {
491 if ($reg[1] ==
'DEPOSIT') {
492 $fields[
'descr'] = $langs->transnoentitiesnoconv(
'Deposit');
493 } elseif ($reg[1] ==
'CREDIT_NOTE') {
494 $fields[
'descr'] = $langs->transnoentitiesnoconv(
'CreditNote');
496 $fields[
'descr'] = $langs->transnoentitiesnoconv($reg[1]);
508 print
'<td class="nowrap right"><span class="amount">';
509 print
price($fields[
'totalht']);
512 $ratiolineinvoice = ($fields[
'dtotal_ttc'] / $fields[
'ftotal_ttc']);
515 print
'</span></td>';
519 $ratiopaymentinvoice = 1;
521 print
'<td class="nowrap right">';
523 if ($fields[
'payment_amount'] && $fields[
'ftotal_ttc']) {
524 $payment_static->id = $fields[
'payment_id'];
525 $payment_static->ref = $fields[
'payment_ref'];
526 print $payment_static->getNomUrl(2,
'',
'', 0).
' ';
530 print $langs->trans(
"NA");
532 if (isset($fields[
'payment_amount']) &&
price2num($fields[
'ftotal_ttc'])) {
533 $ratiopaymentinvoice = ($fields[
'payment_amount'] / $fields[
'ftotal_ttc']);
535 print
'<span class="amount">'.price(
price2num($fields[
'payment_amount'],
'MT')).
'</span>';
536 if (isset($fields[
'payment_amount'])) {
537 print
' ('.round($ratiopaymentinvoice * 100, 2).
'%)';
544 print
'<td class="nowrap right"><span class="amount">';
545 $temp_ht = $fields[
'totalht'] * $ratiopaymentinvoice;
547 print
'</span></td>';
550 print
'<td class="nowrap right"><span class="amount">';
551 $temp_vat = $fields[
'vat'] * $ratiopaymentinvoice;
554 print
'</span></td>';
557 $subtot_coll_total_ht += $temp_ht;
558 $subtot_coll_vat += $temp_vat;
559 $x_coll_sum += $temp_vat;
564 print
'<tr class="liste_total">';
565 print
'<td colspan="4"></td>';
566 print
'<td class="right">'.$langs->trans(
"Total").
':</td>';
568 print
'<td class="nowrap right"> </td>';
569 print
'<td class="right"> </td>';
571 print
'<td class="right"><span class="amount">'.price(
price2num($subtot_coll_total_ht,
'MT')).
'</span></td>';
572 print
'<td class="nowrap right"><span class="amount">'.price(
price2num($subtot_coll_vat,
'MT')).
'</span></td>';
577 if (count($x_coll) == 0) {
578 print
'<tr class="liste_total">';
579 print
'<td colspan="4"></td>';
580 print
'<td class="right">'.$langs->trans(
"Total").
':</td>';
582 print
'<td class="nowrap right"> </td>';
583 print
'<td class="right"> </td>';
585 print
'<td class="right">'.price(
price2num(0,
'MT')).
'</td>';
586 print
'<td class="nowrap right">'.price(
price2num(0,
'MT')).
'</td>';
591 print
'<tr><td colspan="'.($span + 1).
'"> </td></tr>';
594 print
'<tr class="liste_titre liste_titre_topborder">';
595 print
'<td class="left">'.$elementsup.
'</td>';
596 print
'<td class="left">'.$langs->trans(
"DateInvoice").
'</td>';
598 print
'<td class="left">'.$langs->trans(
"DatePayment").
'</td>';
602 print
'<td class="left"></td>';
603 print
'<td class="left">'.$productsup.
'</td>';
605 print
'<td class="right">'.$amountsup.
'</td>';
606 print
'<td class="right">'.$langs->trans(
"Payment").
' ('.$langs->trans(
"PercentOfInvoice").
')</td>';
608 print
'<td class="right">'.$langs->trans(
"AmountHTVATRealPaid").
'</td>';
609 print
'<td class="right">'.$vatsup.
'</td>';
612 foreach (array_keys($x_paye) as $thirdparty_id) {
613 $subtot_paye_total_ht = 0;
614 $subtot_paye_vat = 0;
616 if ($min == 0 || ($min > 0 && $x_both[$thirdparty_id][
'paye'][
'totalht'] > $min)) {
617 if (is_array($x_both[$thirdparty_id][
'paye'][
'detail'])) {
619 print
'<td class="tax_rate">';
620 if (is_numeric($thirdparty_id)) {
621 $company_static->fetch($thirdparty_id);
622 print $langs->trans(
"ThirdParty").
': '.$company_static->getNomUrl(1);
624 $tmpid = preg_replace(
'/userid_/',
'', $thirdparty_id);
625 $user_static->fetch($tmpid);
626 print $langs->trans(
"User").
': '.$user_static->getNomUrl(1);
628 print
'<td colspan="'.($span + 1).
'"></td>';
631 foreach ($x_both[$thirdparty_id][
'paye'][
'detail'] as $index => $fields) {
634 $type = (isset($fields[
'dtype']) ? $fields[
'dtype'] : $fields[
'ptype']);
637 if (!empty($fields[
'ddate_start'])) {
640 if (!empty($fields[
'ddate_end'])) {
645 print
'<tr class="oddeven">';
648 print
'<td class="nowrap left">'.$fields[
'link'].
'</td>';
651 print
'<td class="left">'.dol_print_date($fields[
'datef'],
'day').
'</td>';
655 print
'<td class="left">'.dol_print_date($fields[
'datep'],
'day').
'</td>';
661 print
'<td class="tdmaxoverflow150">';
662 print $fields[
'company_link'];
666 print
'<td class="left">';
667 if ($fields[
'pid']) {
668 $product_static->id = $fields[
'pid'];
669 $product_static->ref = $fields[
'pref'];
670 $product_static->type = $fields[
'dtype'];
671 print $product_static->getNomUrl(1);
677 $text =
img_object($langs->trans(
'Service'),
'service');
679 $text =
img_object($langs->trans(
'Product'),
'product');
681 if (preg_match(
'/^\((.*)\)$/', $fields[
'descr'], $reg)) {
682 if ($reg[1] ==
'DEPOSIT') {
683 $fields[
'descr'] = $langs->transnoentitiesnoconv(
'Deposit');
684 } elseif ($reg[1] ==
'CREDIT_NOTE') {
685 $fields[
'descr'] = $langs->transnoentitiesnoconv(
'CreditNote');
687 $fields[
'descr'] = $langs->transnoentitiesnoconv($reg[1]);
699 print
'<td class="nowrap right"><span class="amount">';
700 print
price($fields[
'totalht']);
703 $ratiolineinvoice = ((float) $fields[
'dtotal_ttc'] / (
float) $fields[
'ftotal_ttc']);
706 print
'</span></td>';
710 $ratiopaymentinvoice = 1;
712 print
'<td class="nowrap right">';
713 if ($fields[
'payment_amount'] && $fields[
'ftotal_ttc']) {
714 $paymentfourn_static->id = $fields[
'payment_id'];
715 $paymentfourn_static->ref = $fields[
'payment_ref'];
716 print $paymentfourn_static->getNomUrl(2,
'',
'', 0);
721 print $langs->trans(
"NA");
723 if (isset($fields[
'payment_amount']) && $fields[
'ftotal_ttc']) {
724 $ratiopaymentinvoice = ($fields[
'payment_amount'] / (float) $fields[
'ftotal_ttc']);
726 print
'<span class="amount">'.price(
price2num($fields[
'payment_amount'],
'MT')).
'</span>';
727 if (isset($fields[
'payment_amount'])) {
728 print
' ('.round($ratiopaymentinvoice * 100, 2).
'%)';
735 print
'<td class="nowrap right"><span class="amount">';
736 $temp_ht = (float) $fields[
'totalht'] * $ratiopaymentinvoice;
738 print
'</span></td>';
741 print
'<td class="nowrap right"><span class="amount">';
742 $temp_vat = $fields[
'vat'] * $ratiopaymentinvoice;
745 print
'</span></td>';
748 $subtot_paye_total_ht += $temp_ht;
749 $subtot_paye_vat += $temp_vat;
750 $x_paye_sum += $temp_vat;
754 print
'<tr class="liste_total">';
755 print
'<td colspan="4"></td>';
756 print
'<td class="right">'.$langs->trans(
"Total").
':</td>';
758 print
'<td class="nowrap right"> </td>';
759 print
'<td class="right"> </td>';
761 print
'<td class="right"><span class="amount">'.price(
price2num($subtot_paye_total_ht,
'MT')).
'</span></td>';
762 print
'<td class="nowrap right"><span class="amount">'.price(
price2num($subtot_paye_vat,
'MT')).
'</span></td>';
767 if (count($x_paye) == 0) {
768 print
'<tr class="liste_total">';
769 print
'<td colspan="4"></td>';
770 print
'<td class="right">'.$langs->trans(
"Total").
':</td>';
772 print
'<td class="nowrap right"> </td>';
773 print
'<td class="right"> </td>';
775 print
'<td class="right">'.price(
price2num(0,
'MT')).
'</td>';
776 print
'<td class="nowrap right">'.price(
price2num(0,
'MT')).
'</td>';
781 print
'<tr><td colspan="'.($span + 2).
'"></td></tr>';
783 $diff = $x_coll_sum - $x_paye_sum;
784 print
'<tr class="liste_total">';
785 print
'<td class="liste_total" colspan="'.($span + 1).
'">'.$langs->trans(
"TotalToPay").($q ?
', '.$langs->trans(
"Quadri").
' '.$q :
'').
'</td>';
786 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()
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.
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0)
Show a picto called object_picto (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.
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 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)