32 require
'../../main.inc.php';
33 require_once DOL_DOCUMENT_ROOT.
'/core/lib/report.lib.php';
34 require_once DOL_DOCUMENT_ROOT.
'/core/lib/tax.lib.php';
35 require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
36 require_once DOL_DOCUMENT_ROOT.
'/compta/tva/class/tva.class.php';
37 require_once DOL_DOCUMENT_ROOT.
'/compta/localtax/class/localtax.class.php';
38 require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
39 require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
40 require_once DOL_DOCUMENT_ROOT.
'/compta/paiement/class/paiement.class.php';
41 require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.facture.class.php';
42 require_once DOL_DOCUMENT_ROOT.
'/fourn/class/paiementfourn.class.php';
43 require_once DOL_DOCUMENT_ROOT.
'/expensereport/class/expensereport.class.php';
44 require_once DOL_DOCUMENT_ROOT.
'/expensereport/class/paymentexpensereport.class.php';
47 $langs->loadLangs(array(
"other",
"compta",
"banks",
"bills",
"companies",
"product",
"trips",
"admin"));
51 $vat_rate_show =
GETPOSTISSET(
'vat_rate_show') ?
GETPOST(
'vat_rate_show',
'alphanohtml') : -1;
53 include DOL_DOCUMENT_ROOT.
'/compta/tva/initdatesforvat.inc.php';
62 $modetax = (empty($conf->global->TAX_MODE) ? 0 : $conf->global->TAX_MODE);
66 if (empty($modetax)) {
70 $object =
new Tva($db);
75 $socid = $user->socid;
85 $company_static =
new Societe($db);
86 $invoice_customer =
new Facture($db);
89 $product_static =
new Product($db);
94 $morequerystring =
'';
95 $listofparams = array(
'date_startmonth',
'date_startyear',
'date_startday',
'date_endmonth',
'date_endyear',
'date_endday');
96 foreach ($listofparams as $param) {
98 $morequerystring .= ($morequerystring ?
'&' :
'').$param.
'='.
GETPOST($param);
103 llxHeader(
'', $title,
'',
'', 0, 0,
'',
'', $morequerystring);
109 $fsearch =
'<!-- hidden fields for form -->';
110 $fsearch .=
'<input type="hidden" name="token" value="'.newToken().
'">';
111 $fsearch .=
'<input type="hidden" name="modetax" value="'.$modetax.
'">';
117 $name = $langs->trans(
"VATReportByRates");
120 $calcmode = $langs->trans(
'OptionVATDefault');
123 $calcmode = $langs->trans(
'OptionVATDebitOption');
126 $calcmode = $langs->trans(
'OptionPaymentForProductAndServices');
128 $calcmode .=
' <span class="opacitymedium">('.$langs->trans(
"TaxModuleSetupToModifyRules", DOL_URL_ROOT.
'/admin/taxes.php').
')</span>';
130 $period =
$form->selectDate($date_start,
'date_start', 0, 0, 0,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'',
'',
'tzserver');
132 $period .=
$form->selectDate($date_end,
'date_end', 0, 0, 0,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'',
'',
'tzserver');
133 $prevyear = $date_start_year;
135 if ($prevquarter > 1) {
141 $nextyear = $date_start_year;
143 if ($nextquarter < 4) {
149 $description .= $fsearch;
152 if ($conf->global->TAX_MODE_SELL_PRODUCT ==
'invoice') {
153 $description .= $langs->trans(
"RulesVATDueProducts");
155 if ($conf->global->TAX_MODE_SELL_PRODUCT ==
'payment') {
156 $description .= $langs->trans(
"RulesVATInProducts");
158 if ($conf->global->TAX_MODE_SELL_SERVICE ==
'invoice') {
159 $description .=
'<br>'.$langs->trans(
"RulesVATDueServices");
161 if ($conf->global->TAX_MODE_SELL_SERVICE ==
'payment') {
162 $description .=
'<br>'.$langs->trans(
"RulesVATInServices");
164 if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
165 $description .=
'<br>'.$langs->trans(
"DepositsAreNotIncluded");
167 if (!empty($conf->global->FACTURE_SUPPLIER_DEPOSITS_ARE_JUST_PAYMENTS)) {
168 $description .= $langs->trans(
"SupplierDepositsAreNotIncluded");
170 if (!empty($conf->global->MAIN_MODULE_ACCOUNTING)) {
171 $description .=
'<br>'.$langs->trans(
"ThisIsAnEstimatedValue");
175 $elementcust = $langs->trans(
"CustomersInvoices");
176 $productcust = $langs->trans(
"ProductOrService");
177 $amountcust = $langs->trans(
"AmountHT");
178 $vatcust = $langs->trans(
"VATReceived");
179 $namecust = $langs->trans(
"Name");
180 if ($mysoc->tva_assuj) {
181 $vatcust .=
' ('.$langs->trans(
"VATToPay").
')';
185 $elementsup = $langs->trans(
"SuppliersInvoices");
186 $productsup = $productcust;
187 $amountsup = $amountcust;
188 $vatsup = $langs->trans(
"VATPaid");
189 $namesup = $namecust;
190 if ($mysoc->tva_assuj) {
191 $vatsup .=
' ('.$langs->trans(
"ToGetBack").
')';
194 $optioncss =
GETPOST(
'optioncss',
'alpha');
195 if ($optioncss !=
"print") {
196 report_header($name,
'', $period, $periodlink, $description, $builddate, $exportlink, array(), $calcmode);
199 $vatcust = $langs->trans(
"VATReceived");
200 $vatsup = $langs->trans(
"VATPaid");
201 $vatexpensereport = $langs->trans(
"VATPaid");
205 print
'<div class="div-table-responsive">';
206 print
'<table class="noborder centpercent">';
218 $x_coll =
tax_by_rate(
'vat', $db, 0, 0, $date_start, $date_end, $modetax,
'sell');
219 $x_paye =
tax_by_rate(
'vat', $db, 0, 0, $date_start, $date_end, $modetax,
'buy');
221 if (!is_array($x_coll) || !is_array($x_paye)) {
222 $langs->load(
"errors");
224 print
'<tr><td colspan="'.$columns.
'">'.$langs->trans(
"ErrorNoAccountancyModuleLoaded").
'</td></tr>';
225 } elseif ($x_coll == -2) {
226 print
'<tr><td colspan="'.$columns.
'">'.$langs->trans(
"FeatureNotYetAvailable").
'</td></tr>';
228 print
'<tr><td colspan="'.$columns.
'">'.$langs->trans(
"Error").
'</td></tr>';
233 foreach (array_keys($x_coll) as $my_coll_rate) {
234 $x_both[$my_coll_rate][
'coll'][
'totalht'] = $x_coll[$my_coll_rate][
'totalht'];
235 $x_both[$my_coll_rate][
'coll'][
'vat'] = $x_coll[$my_coll_rate][
'vat'];
236 $x_both[$my_coll_rate][
'paye'][
'totalht'] = 0;
237 $x_both[$my_coll_rate][
'paye'][
'vat'] = 0;
238 $x_both[$my_coll_rate][
'coll'][
'links'] =
'';
239 $x_both[$my_coll_rate][
'coll'][
'detail'] = array();
240 foreach ($x_coll[$my_coll_rate][
'facid'] as $id => $dummy) {
241 $invoice_customer->id = $x_coll[$my_coll_rate][
'facid'][$id];
242 $invoice_customer->ref = $x_coll[$my_coll_rate][
'facnum'][$id];
243 $invoice_customer->type = $x_coll[$my_coll_rate][
'type'][$id];
246 $company_static->id = $x_coll[$my_coll_rate][
'company_id'][$id];
247 $company_static->name = $x_coll[$my_coll_rate][
'company_name'][$id];
248 $company_static->name_alias = $x_coll[$my_coll_rate][
'company_alias'][$id];
249 $company_static->email = $x_coll[$my_coll_rate][
'company_email'][$id];
250 $company_static->tva_intra = $x_coll[$my_coll_rate][
'tva_intra'][$id];
251 $company_static->client = $x_coll[$my_coll_rate][
'company_client'][$id];
252 $company_static->fournisseur = $x_coll[$my_coll_rate][
'company_fournisseur'][$id];
253 $company_static->status = $x_coll[$my_coll_rate][
'company_status'][$id];
254 $company_static->code_client = $x_coll[$my_coll_rate][
'company_customer_code'][$id];
255 $company_static->code_compta_client = $x_coll[$my_coll_rate][
'company_customer_accounting_code'][$id];
256 $company_static->code_fournisseur = $x_coll[$my_coll_rate][
'company_supplier_code'][$id];
257 $company_static->code_compta_fournisseur = $x_coll[$my_coll_rate][
'company_supplier_accounting_code'][$id];
259 $x_both[$my_coll_rate][
'coll'][
'detail'][] = array(
260 'id' =>$x_coll[$my_coll_rate][
'facid'][$id],
261 'descr' =>$x_coll[$my_coll_rate][
'descr'][$id],
262 'pid' =>$x_coll[$my_coll_rate][
'pid'][$id],
263 'pref' =>$x_coll[$my_coll_rate][
'pref'][$id],
264 'ptype' =>$x_coll[$my_coll_rate][
'ptype'][$id],
265 'payment_id'=>$x_coll[$my_coll_rate][
'payment_id'][$id],
266 'payment_ref'=>$x_coll[$my_coll_rate][
'payment_ref'][$id],
267 'payment_amount'=>$x_coll[$my_coll_rate][
'payment_amount'][$id],
268 'ftotal_ttc'=>$x_coll[$my_coll_rate][
'ftotal_ttc'][$id],
269 'dtotal_ttc'=>$x_coll[$my_coll_rate][
'dtotal_ttc'][$id],
270 'dtype' =>$x_coll[$my_coll_rate][
'dtype'][$id],
271 'datef' =>$x_coll[$my_coll_rate][
'datef'][$id],
272 'datep' =>$x_coll[$my_coll_rate][
'datep'][$id],
274 'company_link'=>$company_static->getNomUrl(1,
'', 20),
276 'ddate_start'=>$x_coll[$my_coll_rate][
'ddate_start'][$id],
277 'ddate_end' =>$x_coll[$my_coll_rate][
'ddate_end'][$id],
278 'totalht' =>$x_coll[$my_coll_rate][
'totalht_list'][$id],
279 'vat' =>$x_coll[$my_coll_rate][
'vat_list'][$id],
280 'link' =>$invoice_customer->getNomUrl(1,
'', 12)
285 foreach (array_keys($x_paye) as $my_paye_rate) {
286 $x_both[$my_paye_rate][
'paye'][
'totalht'] = $x_paye[$my_paye_rate][
'totalht'];
287 $x_both[$my_paye_rate][
'paye'][
'vat'] = $x_paye[$my_paye_rate][
'vat'];
288 if (!isset($x_both[$my_paye_rate][
'coll'][
'totalht'])) {
289 $x_both[$my_paye_rate][
'coll'][
'totalht'] = 0;
290 $x_both[$my_paye_rate][
'coll'][
'vat'] = 0;
292 $x_both[$my_paye_rate][
'paye'][
'links'] =
'';
293 $x_both[$my_paye_rate][
'paye'][
'detail'] = array();
295 foreach ($x_paye[$my_paye_rate][
'facid'] as $id => $dummy) {
297 if ($x_paye[$my_paye_rate][
'ptype'][$id] ==
'ExpenseReportPayment') {
298 $expensereport->id = $x_paye[$my_paye_rate][
'facid'][$id];
299 $expensereport->ref = $x_paye[$my_paye_rate][
'facnum'][$id];
300 $expensereport->type = $x_paye[$my_paye_rate][
'type'][$id];
302 $x_both[$my_paye_rate][
'paye'][
'detail'][] = array(
303 'id' =>$x_paye[$my_paye_rate][
'facid'][$id],
304 'descr' =>$x_paye[$my_paye_rate][
'descr'][$id],
305 'pid' =>$x_paye[$my_paye_rate][
'pid'][$id],
306 'pref' =>$x_paye[$my_paye_rate][
'pref'][$id],
307 'ptype' =>$x_paye[$my_paye_rate][
'ptype'][$id],
308 'payment_id' =>$x_paye[$my_paye_rate][
'payment_id'][$id],
309 'payment_ref' =>$x_paye[$my_paye_rate][
'payment_ref'][$id],
310 'payment_amount' =>$x_paye[$my_paye_rate][
'payment_amount'][$id],
311 'ftotal_ttc' =>
price2num($x_paye[$my_paye_rate][
'ftotal_ttc'][$id]),
312 'dtotal_ttc' =>
price2num($x_paye[$my_paye_rate][
'dtotal_ttc'][$id]),
313 'dtype' =>$x_paye[$my_paye_rate][
'dtype'][$id],
314 'ddate_start' =>$x_paye[$my_paye_rate][
'ddate_start'][$id],
315 'ddate_end' =>$x_paye[$my_paye_rate][
'ddate_end'][$id],
316 'totalht' =>
price2num($x_paye[$my_paye_rate][
'totalht_list'][$id]),
317 'vat' =>$x_paye[$my_paye_rate][
'vat_list'][$id],
318 'link' =>$expensereport->getNomUrl(1)
321 $invoice_supplier->id = $x_paye[$my_paye_rate][
'facid'][$id];
322 $invoice_supplier->ref = $x_paye[$my_paye_rate][
'facnum'][$id];
323 $invoice_supplier->type = $x_paye[$my_paye_rate][
'type'][$id];
325 $company_static->id = $x_paye[$my_paye_rate][
'company_id'][$id];
326 $company_static->name = $x_paye[$my_paye_rate][
'company_name'][$id];
327 $company_static->name_alias = $x_paye[$my_paye_rate][
'company_alias'][$id];
328 $company_static->email = $x_paye[$my_paye_rate][
'company_email'][$id];
329 $company_static->tva_intra = $x_paye[$my_paye_rate][
'tva_intra'][$id];
330 $company_static->client = $x_paye[$my_paye_rate][
'company_client'][$id];
331 $company_static->fournisseur = $x_paye[$my_paye_rate][
'company_fournisseur'][$id];
332 $company_static->status = $x_paye[$my_paye_rate][
'company_status'][$id];
333 $company_static->code_client = $x_paye[$my_paye_rate][
'company_customer_code'][$id];
334 $company_static->code_compta_client = $x_paye[$my_paye_rate][
'company_customer_accounting_code'][$id];
335 $company_static->code_fournisseur = $x_paye[$my_paye_rate][
'company_supplier_code'][$id];
336 $company_static->code_compta_fournisseur = $x_paye[$my_paye_rate][
'company_supplier_accounting_code'][$id];
338 $x_both[$my_paye_rate][
'paye'][
'detail'][] = array(
339 'id' =>$x_paye[$my_paye_rate][
'facid'][$id],
340 'descr' =>$x_paye[$my_paye_rate][
'descr'][$id],
341 'pid' =>$x_paye[$my_paye_rate][
'pid'][$id],
342 'pref' =>$x_paye[$my_paye_rate][
'pref'][$id],
343 'ptype' =>$x_paye[$my_paye_rate][
'ptype'][$id],
344 'payment_id'=>$x_paye[$my_paye_rate][
'payment_id'][$id],
345 'payment_ref'=>$x_paye[$my_paye_rate][
'payment_ref'][$id],
346 'payment_amount'=>$x_paye[$my_paye_rate][
'payment_amount'][$id],
347 'ftotal_ttc'=>
price2num($x_paye[$my_paye_rate][
'ftotal_ttc'][$id]),
348 'dtotal_ttc'=>
price2num($x_paye[$my_paye_rate][
'dtotal_ttc'][$id]),
349 'dtype' =>$x_paye[$my_paye_rate][
'dtype'][$id],
350 'datef' =>$x_paye[$my_paye_rate][
'datef'][$id],
351 'datep' =>$x_paye[$my_paye_rate][
'datep'][$id],
353 'company_link'=>$company_static->getNomUrl(1,
'', 20),
355 'ddate_start'=>$x_paye[$my_paye_rate][
'ddate_start'][$id],
356 'ddate_end' =>$x_paye[$my_paye_rate][
'ddate_end'][$id],
357 'totalht' =>
price2num($x_paye[$my_paye_rate][
'totalht_list'][$id]),
358 'vat' =>$x_paye[$my_paye_rate][
'vat_list'][$id],
359 'link' =>$invoice_supplier->getNomUrl(1,
'', 12)
377 print
'<tr class="liste_titre">';
378 print
'<td class="left">'.$elementcust.
'</td>';
379 print
'<td class="left">'.$langs->trans(
"DateInvoice").
'</td>';
380 if ($conf->global->TAX_MODE_SELL_PRODUCT ==
'payment' || $conf->global->TAX_MODE_SELL_SERVICE ==
'payment') {
381 print
'<td class="left">'.$langs->trans(
"DatePayment").
'</td>';
385 print
'<td class="left">'.$namecust.
'</td>';
386 print
'<td class="left">'.$productcust.
'</td>';
388 print
'<td class="right">'.$amountcust.
'</td>';
389 print
'<td class="right">'.$langs->trans(
"Payment").
' ('.$langs->trans(
"PercentOfInvoice").
')</td>';
391 print
'<td class="right">'.$langs->trans(
"AmountHTVATRealReceived").
'</td>';
392 print
'<td class="right">'.$vatcust.
'</td>';
395 $action =
"tvadetail";
396 $parameters[
"mode"] = $modetax;
397 $parameters[
"start"] = $date_start;
398 $parameters[
"end"] = $date_end;
399 $parameters[
"type"] =
'vat';
401 $object = array(&$x_coll, &$x_paye, &$x_both);
403 $hookmanager->initHooks(array(
'externalbalance'));
404 $reshook = $hookmanager->executeHooks(
'addVatLine', $parameters, $object, $action);
406 foreach (array_keys($x_coll) as $rate) {
407 $subtot_coll_total_ht = 0;
408 $subtot_coll_vat = 0;
410 if (is_array($x_both[$rate][
'coll'][
'detail'])) {
413 print
'<td class="tax_rate" colspan="' . ($span+1) .
'">';
414 print $langs->trans(
'Rate') .
' : ' .
vatrate($rate) .
'%';
415 print
' - <a href="'.DOL_URL_ROOT.
'/compta/tva/quadri_detail.php?invoice_type=customer';
416 if ($invoice_type !=
'customer' || !
GETPOSTISSET(
'vat_rate_show') ||
GETPOST(
'vat_rate_show') != $rate) {
417 print
'&vat_rate_show='.urlencode($rate);
419 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>';
423 foreach ($x_both[$rate][
'coll'][
'detail'] as $index => $fields) {
426 $type = (isset($fields[
'dtype']) ? $fields[
'dtype'] : $fields[
'ptype']);
429 if (!empty($fields[
'ddate_start'])) {
432 if (!empty($fields[
'ddate_end'])) {
437 $ratiopaymentinvoice=1;
439 if (($type == 0 && $conf->global->TAX_MODE_SELL_PRODUCT ==
'invoice')
440 || ($type == 1 && $conf->global->TAX_MODE_SELL_SERVICE ==
'invoice')) {
442 if (isset($fields[
'payment_amount']) &&
price2num($fields[
'ftotal_ttc'])) {
443 $ratiopaymentinvoice=($fields[
'payment_amount']/$fields[
'ftotal_ttc']);
449 $temp_ht=$fields[
'totalht']*$ratiopaymentinvoice;
452 $temp_vat=$fields[
'vat']*$ratiopaymentinvoice;
454 $subtot_coll_total_ht += $temp_ht;
455 $subtot_coll_vat += $temp_vat;
456 $x_coll_sum += $temp_vat;
460 if ($invoice_type ==
'customer' && $vat_rate_show == $rate) {
461 if (is_array($x_both[$rate][
'coll'][
'detail'])) {
462 foreach ($x_both[$rate][
'coll'][
'detail'] as $index => $fields) {
478 $type = (isset($fields[
'dtype']) ? $fields[
'dtype'] : $fields[
'ptype']);
481 if (!empty($fields[
'ddate_start'])) {
484 if (!empty($fields[
'ddate_end'])) {
489 print
'<tr class="oddeven">';
492 print
'<td class="nowrap left">' . $fields[
'link'] .
'</td>';
495 print
'<td class="left">' .
dol_print_date($fields[
'datef'],
'day') .
'</td>';
498 if ($conf->global->TAX_MODE_SELL_PRODUCT ==
'payment' || $conf->global->TAX_MODE_SELL_SERVICE ==
'payment') print
'<td class="left">' .
dol_print_date($fields[
'datep'],
'day') .
'</td>';
499 else print
'<td></td>';
502 print
'<td class="tdmaxoverflow150">';
504 print $fields[
'company_link'];
508 print
'<td class="left">';
509 if ($fields[
'pid']) {
510 $product_static->id = $fields[
'pid'];
511 $product_static->ref = $fields[
'pref'];
512 $product_static->type = $fields[
'dtype'];
513 print $product_static->getNomUrl(1);
519 $text =
img_object($langs->trans(
'Service'),
'service');
521 $text =
img_object($langs->trans(
'Product'),
'product');
523 if (preg_match(
'/^\((.*)\)$/', $fields[
'descr'], $reg)) {
524 if ($reg[1] ==
'DEPOSIT') {
525 $fields[
'descr'] = $langs->transnoentitiesnoconv(
'Deposit');
526 } elseif ($reg[1] ==
'CREDIT_NOTE') {
527 $fields[
'descr'] = $langs->transnoentitiesnoconv(
'CreditNote');
529 $fields[
'descr'] = $langs->transnoentitiesnoconv($reg[1]);
541 print
'<td class="nowrap right">';
542 print
price($fields[
'totalht']);
545 $ratiolineinvoice = ($fields[
'dtotal_ttc'] / $fields[
'ftotal_ttc']);
552 $ratiopaymentinvoice = 1;
554 print
'<td class="nowrap right">';
556 if ($fields[
'payment_amount'] && $fields[
'ftotal_ttc']) {
557 $payment_static->id = $fields[
'payment_id'];
558 $payment_static->ref = $fields[
'payment_ref'];
559 print $payment_static->getNomUrl(2,
'',
'', 0).
' ';
561 if (($type == 0 && $conf->global->TAX_MODE_SELL_PRODUCT ==
'invoice')
562 || ($type == 1 && $conf->global->TAX_MODE_SELL_SERVICE ==
'invoice')) {
563 print $langs->trans(
"NA");
565 if (isset($fields[
'payment_amount']) &&
price2num($fields[
'ftotal_ttc'])) {
566 $ratiopaymentinvoice = ($fields[
'payment_amount'] / $fields[
'ftotal_ttc']);
569 if (isset($fields[
'payment_amount'])) {
570 print
' (' . round($ratiopaymentinvoice * 100, 2) .
'%)';
577 print
'<td class="nowrap right">';
578 $temp_ht = $fields[
'totalht'] * $ratiopaymentinvoice;
583 print
'<td class="nowrap right">';
584 $temp_vat = $fields[
'vat'] * $ratiopaymentinvoice;
597 print
'<tr class="liste_total">';
598 print
'<td colspan="4"></td>';
599 print
'<td class="right">'.$langs->trans(
"Total").
':</td>';
601 print
'<td class="nowrap right"> </td>';
602 print
'<td class="right"> </td>';
604 print
'<td class="right"><span class="amount">'.price(
price2num($subtot_coll_total_ht,
'MT')).
'</span></td>';
605 print
'<td class="nowrap right"><span class="amount">'.price(
price2num($subtot_coll_vat,
'MT')).
'</span></td>';
609 if (count($x_coll) == 0) {
610 print
'<tr class="liste_total">';
611 print
'<td colspan="4"></td>';
612 print
'<td class="right">'.$langs->trans(
"Total").
':</td>';
614 print
'<td class="nowrap right"> </td>';
615 print
'<td class="right"> </td>';
617 print
'<td class="right">'.price(
price2num(0,
'MT')).
'</td>';
618 print
'<td class="nowrap right">'.price(
price2num(0,
'MT')).
'</td>';
623 print
'<tr><td colspan="'.($span+2).
'"> </td></tr>';
626 print
'<tr class="liste_titre liste_titre_topborder">';
627 print
'<td class="left">'.$elementsup.
'</td>';
628 print
'<td class="left">'.$langs->trans(
"DateInvoice").
'</td>';
629 if ($conf->global->TAX_MODE_BUY_PRODUCT ==
'payment' || $conf->global->TAX_MODE_BUY_SERVICE ==
'payment') print
'<td class="left">'.$langs->trans(
"DatePayment").
'</td>';
630 else print
'<td></td>';
631 print
'<td class="left">'.$namesup.
'</td>';
632 print
'<td class="left">'.$productsup.
'</td>';
634 print
'<td class="right">'.$amountsup.
'</td>';
635 print
'<td class="right">'.$langs->trans(
"Payment").
' ('.$langs->trans(
"PercentOfInvoice").
')</td>';
637 print
'<td class="right">'.$langs->trans(
"AmountHTVATRealPaid").
'</td>';
638 print
'<td class="right">'.$vatsup.
'</td>';
641 foreach (array_keys($x_paye) as $rate) {
642 $subtot_paye_total_ht = 0;
643 $subtot_paye_vat = 0;
645 if (is_array($x_both[$rate][
'paye'][
'detail'])) {
647 print
'<td class="tax_rate" colspan="' . ($span+1) .
'">';
648 print $langs->trans(
'Rate') .
' : ' .
vatrate($rate) .
'%';
649 print
' - <a href="'.DOL_URL_ROOT.
'/compta/tva/quadri_detail.php?invoice_type=supplier';
650 if ($invoice_type !=
'supplier' || !
GETPOSTISSET(
'vat_rate_show') ||
GETPOST(
'vat_rate_show') != $rate) {
651 print
'&vat_rate_show='.urlencode($rate);
653 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>';
657 foreach ($x_both[$rate][
'paye'][
'detail'] as $index => $fields) {
660 $type = (isset($fields[
'dtype']) ? $fields[
'dtype'] : $fields[
'ptype']);
663 if (!empty($fields[
'ddate_start'])) {
666 if (!empty($fields[
'ddate_end'])) {
671 $ratiopaymentinvoice = 1;
673 if (($type == 0 && $conf->global->TAX_MODE_BUY_PRODUCT ==
'invoice')
674 || ($type == 1 && $conf->global->TAX_MODE_BUY_SERVICE ==
'invoice')) {
676 if (isset($fields[
'payment_amount']) && $fields[
'ftotal_ttc']) {
677 $ratiopaymentinvoice = ($fields[
'payment_amount'] / $fields[
'ftotal_ttc']);
683 $temp_ht = $fields[
'totalht'] * $ratiopaymentinvoice;
686 $temp_vat = $fields[
'vat'] * $ratiopaymentinvoice;
688 $subtot_paye_total_ht += $temp_ht;
689 $subtot_paye_vat += $temp_vat;
690 $x_paye_sum += $temp_vat;
693 if ($invoice_type ==
'supplier' && $vat_rate_show == $rate) {
694 foreach ($x_both[$rate][
'paye'][
'detail'] as $index => $fields) {
710 $type = (isset($fields[
'dtype']) ? $fields[
'dtype'] : $fields[
'ptype']);
713 if (!empty($fields[
'ddate_start'])) {
716 if (!empty($fields[
'ddate_end'])) {
721 print
'<tr class="oddeven">';
724 print
'<td class="nowrap left">' . $fields[
'link'] .
'</td>';
727 print
'<td class="left">' .
dol_print_date($fields[
'datef'],
'day') .
'</td>';
730 if ($conf->global->TAX_MODE_BUY_PRODUCT ==
'payment' || $conf->global->TAX_MODE_BUY_SERVICE ==
'payment') {
731 print
'<td class="left">' .
dol_print_date($fields[
'datep'],
'day') .
'</td>';
737 print
'<td class="tdmaxoverflow150">';
739 print $fields[
'company_link'];
743 print
'<td class="left">';
744 if ($fields[
'pid']) {
745 $product_static->id = $fields[
'pid'];
746 $product_static->ref = $fields[
'pref'];
747 $product_static->type = $fields[
'dtype'];
748 print $product_static->getNomUrl(1);
754 $text =
img_object($langs->trans(
'Service'),
'service');
756 $text =
img_object($langs->trans(
'Product'),
'product');
758 if (preg_match(
'/^\((.*)\)$/', $fields[
'descr'], $reg)) {
759 if ($reg[1] ==
'DEPOSIT') {
760 $fields[
'descr'] = $langs->transnoentitiesnoconv(
'Deposit');
761 } elseif ($reg[1] ==
'CREDIT_NOTE') {
762 $fields[
'descr'] = $langs->transnoentitiesnoconv(
'CreditNote');
764 $fields[
'descr'] = $langs->transnoentitiesnoconv($reg[1]);
776 print
'<td class="nowrap right">';
777 print
price($fields[
'totalht']);
780 $ratiolineinvoice = ($fields[
'dtotal_ttc'] / $fields[
'ftotal_ttc']);
787 $ratiopaymentinvoice = 1;
789 print
'<td class="nowrap right">';
790 if ($fields[
'payment_amount'] && $fields[
'ftotal_ttc']) {
791 $paymentfourn_static->id = $fields[
'payment_id'];
792 $paymentfourn_static->ref = $fields[
'payment_ref'];
793 print $paymentfourn_static->getNomUrl(2,
'',
'', 0).
' ';
796 if (($type == 0 && $conf->global->TAX_MODE_BUY_PRODUCT ==
'invoice')
797 || ($type == 1 && $conf->global->TAX_MODE_BUY_SERVICE ==
'invoice')) {
798 print $langs->trans(
"NA");
800 if (isset($fields[
'payment_amount']) && $fields[
'ftotal_ttc']) {
801 $ratiopaymentinvoice = ($fields[
'payment_amount'] / $fields[
'ftotal_ttc']);
804 if (isset($fields[
'payment_amount'])) {
805 print
' (' . round($ratiopaymentinvoice * 100, 2) .
'%)';
812 print
'<td class="nowrap right">';
813 $temp_ht = $fields[
'totalht'] * $ratiopaymentinvoice;
818 print
'<td class="nowrap right">';
819 $temp_vat = $fields[
'vat'] * $ratiopaymentinvoice;
833 print
'<tr class="liste_total">';
834 print
'<td colspan="4"></td>';
835 print
'<td class="right">'.$langs->trans(
"Total").
':</td>';
837 print
'<td class="nowrap right"> </td>';
838 print
'<td class="right"> </td>';
840 print
'<td class="right"><span class="amount">'.price(
price2num($subtot_paye_total_ht,
'MT')).
'</span></td>';
841 print
'<td class="nowrap right"><span class="amount">'.price(
price2num($subtot_paye_vat,
'MT')).
'</span></td>';
845 if (count($x_paye) == 0) {
846 print
'<tr class="liste_total">';
847 print
'<td colspan="4"></td>';
848 print
'<td class="right">'.$langs->trans(
"Total").
':</td>';
850 print
'<td class="nowrap right"> </td>';
851 print
'<td class="right"> </td>';
853 print
'<td class="right"><span class="amount">'.price(
price2num(0,
'MT')).
'</span></td>';
854 print
'<td class="nowrap right"><span class="amount">'.price(
price2num(0,
'MT')).
'</span></td>';
863 print
'<table class="noborder centpercent">';
864 $diff = $x_coll_sum - $x_paye_sum;
865 print
'<tr class="liste_total">';
866 print
'<td class="liste_total" colspan="'.$span.
'">'.$langs->trans(
"TotalToPay").($q ?
', '.$langs->trans(
"Quadri").
' '.$q :
'').
'</td>';
867 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...)
Put here description of your class.
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
vatrate($rate, $addpercent=false, $info_bits=0, $usestarfornpr=0, $html=0)
Return a string with VAT rate label formated for view output Used into pdf and HTML pages.
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_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
dol_now($mode='auto')
Return date for now.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
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.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
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...