31 require
'../../main.inc.php';
32 require_once DOL_DOCUMENT_ROOT.
'/core/lib/report.lib.php';
33 require_once DOL_DOCUMENT_ROOT.
'/core/lib/tax.lib.php';
34 require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
35 require_once DOL_DOCUMENT_ROOT.
'/compta/tva/class/tva.class.php';
36 require_once DOL_DOCUMENT_ROOT.
'/compta/localtax/class/localtax.class.php';
37 require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
38 require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
39 require_once DOL_DOCUMENT_ROOT.
'/compta/paiement/class/paiement.class.php';
40 require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.facture.class.php';
41 require_once DOL_DOCUMENT_ROOT.
'/fourn/class/paiementfourn.class.php';
42 require_once DOL_DOCUMENT_ROOT.
'/expensereport/class/expensereport.class.php';
43 require_once DOL_DOCUMENT_ROOT.
'/expensereport/class/paymentexpensereport.class.php';
46 $langs->loadLangs(array(
"other",
"compta",
"banks",
"bills",
"companies",
"product",
"trips",
"admin"));
50 $vat_rate_show =
GETPOSTISSET(
'vat_rate_show') ?
GETPOST(
'vat_rate_show',
'alphanohtml') : -1;
52 include DOL_DOCUMENT_ROOT.
'/compta/tva/initdatesforvat.inc.php';
61 $modetax = (empty($conf->global->TAX_MODE) ? 0 : $conf->global->TAX_MODE);
65 if (empty($modetax)) {
69 $object =
new Tva($db);
74 $socid = $user->socid;
84 $company_static =
new Societe($db);
85 $invoice_customer =
new Facture($db);
88 $product_static =
new Product($db);
93 $morequerystring =
'';
94 $listofparams = array(
'date_startmonth',
'date_startyear',
'date_startday',
'date_endmonth',
'date_endyear',
'date_endday');
95 foreach ($listofparams as $param) {
97 $morequerystring .= ($morequerystring ?
'&' :
'').$param.
'='.
GETPOST($param);
102 llxHeader(
'', $title,
'',
'', 0, 0,
'',
'', $morequerystring);
108 $fsearch =
'<!-- hidden fields for form -->';
109 $fsearch .=
'<input type="hidden" name="token" value="'.newToken().
'">';
110 $fsearch .=
'<input type="hidden" name="modetax" value="'.$modetax.
'">';
116 $name = $langs->trans(
"VATReportByRates");
119 $calcmode = $langs->trans(
'OptionVATDefault');
122 $calcmode = $langs->trans(
'OptionVATDebitOption');
125 $calcmode = $langs->trans(
'OptionPaymentForProductAndServices');
127 $calcmode .=
' <span class="opacitymedium">('.$langs->trans(
"TaxModuleSetupToModifyRules", DOL_URL_ROOT.
'/admin/taxes.php').
')</span>';
129 $period =
$form->selectDate($date_start,
'date_start', 0, 0, 0,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'',
'',
'tzserver');
131 $period .=
$form->selectDate($date_end,
'date_end', 0, 0, 0,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'',
'',
'tzserver');
132 $prevyear = $date_start_year;
134 if ($prevquarter > 1) {
140 $nextyear = $date_start_year;
142 if ($nextquarter < 4) {
148 $description .= $fsearch;
151 if ($conf->global->TAX_MODE_SELL_PRODUCT ==
'invoice') {
152 $description .= $langs->trans(
"RulesVATDueProducts");
154 if ($conf->global->TAX_MODE_SELL_PRODUCT ==
'payment') {
155 $description .= $langs->trans(
"RulesVATInProducts");
157 if ($conf->global->TAX_MODE_SELL_SERVICE ==
'invoice') {
158 $description .=
'<br>'.$langs->trans(
"RulesVATDueServices");
160 if ($conf->global->TAX_MODE_SELL_SERVICE ==
'payment') {
161 $description .=
'<br>'.$langs->trans(
"RulesVATInServices");
163 if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
164 $description .=
'<br>'.$langs->trans(
"DepositsAreNotIncluded");
166 if (!empty($conf->global->MAIN_MODULE_ACCOUNTING)) {
167 $description .=
'<br>'.$langs->trans(
"ThisIsAnEstimatedValue");
171 $elementcust = $langs->trans(
"CustomersInvoices");
172 $productcust = $langs->trans(
"ProductOrService");
173 $amountcust = $langs->trans(
"AmountHT");
174 $vatcust = $langs->trans(
"VATReceived");
175 $namecust = $langs->trans(
"Name");
176 if ($mysoc->tva_assuj) {
177 $vatcust .=
' ('.$langs->trans(
"VATToPay").
')';
181 $elementsup = $langs->trans(
"SuppliersInvoices");
182 $productsup = $productcust;
183 $amountsup = $amountcust;
184 $vatsup = $langs->trans(
"VATPaid");
185 $namesup = $namecust;
186 if ($mysoc->tva_assuj) {
187 $vatsup .=
' ('.$langs->trans(
"ToGetBack").
')';
190 $optioncss =
GETPOST(
'optioncss',
'alpha');
191 if ($optioncss !=
"print") {
192 report_header($name,
'', $period, $periodlink, $description, $builddate, $exportlink, array(), $calcmode);
195 $vatcust = $langs->trans(
"VATReceived");
196 $vatsup = $langs->trans(
"VATPaid");
197 $vatexpensereport = $langs->trans(
"VATPaid");
201 print
'<div class="div-table-responsive">';
202 print
'<table class="noborder centpercent">';
214 $x_coll =
tax_by_rate(
'vat', $db, 0, 0, $date_start, $date_end, $modetax,
'sell');
215 $x_paye =
tax_by_rate(
'vat', $db, 0, 0, $date_start, $date_end, $modetax,
'buy');
217 if (!is_array($x_coll) || !is_array($x_paye)) {
218 $langs->load(
"errors");
220 print
'<tr><td colspan="'.$columns.
'">'.$langs->trans(
"ErrorNoAccountancyModuleLoaded").
'</td></tr>';
221 } elseif ($x_coll == -2) {
222 print
'<tr><td colspan="'.$columns.
'">'.$langs->trans(
"FeatureNotYetAvailable").
'</td></tr>';
224 print
'<tr><td colspan="'.$columns.
'">'.$langs->trans(
"Error").
'</td></tr>';
229 foreach (array_keys($x_coll) as $my_coll_rate) {
230 $x_both[$my_coll_rate][
'coll'][
'totalht'] = $x_coll[$my_coll_rate][
'totalht'];
231 $x_both[$my_coll_rate][
'coll'][
'vat'] = $x_coll[$my_coll_rate][
'vat'];
232 $x_both[$my_coll_rate][
'paye'][
'totalht'] = 0;
233 $x_both[$my_coll_rate][
'paye'][
'vat'] = 0;
234 $x_both[$my_coll_rate][
'coll'][
'links'] =
'';
235 $x_both[$my_coll_rate][
'coll'][
'detail'] = array();
236 foreach ($x_coll[$my_coll_rate][
'facid'] as $id => $dummy) {
237 $invoice_customer->id = $x_coll[$my_coll_rate][
'facid'][$id];
238 $invoice_customer->ref = $x_coll[$my_coll_rate][
'facnum'][$id];
239 $invoice_customer->type = $x_coll[$my_coll_rate][
'type'][$id];
242 $company_static->id = $x_coll[$my_coll_rate][
'company_id'][$id];
243 $company_static->name = $x_coll[$my_coll_rate][
'company_name'][$id];
244 $company_static->name_alias = $x_coll[$my_coll_rate][
'company_alias'][$id];
245 $company_static->email = $x_coll[$my_coll_rate][
'company_email'][$id];
246 $company_static->tva_intra = $x_coll[$my_coll_rate][
'tva_intra'][$id];
247 $company_static->client = $x_coll[$my_coll_rate][
'company_client'][$id];
248 $company_static->fournisseur = $x_coll[$my_coll_rate][
'company_fournisseur'][$id];
249 $company_static->status = $x_coll[$my_coll_rate][
'company_status'][$id];
250 $company_static->code_client = $x_coll[$my_coll_rate][
'company_customer_code'][$id];
251 $company_static->code_compta_client = $x_coll[$my_coll_rate][
'company_customer_accounting_code'][$id];
252 $company_static->code_fournisseur = $x_coll[$my_coll_rate][
'company_supplier_code'][$id];
253 $company_static->code_compta_fournisseur = $x_coll[$my_coll_rate][
'company_supplier_accounting_code'][$id];
255 $x_both[$my_coll_rate][
'coll'][
'detail'][] = array(
256 'id' =>$x_coll[$my_coll_rate][
'facid'][$id],
257 'descr' =>$x_coll[$my_coll_rate][
'descr'][$id],
258 'pid' =>$x_coll[$my_coll_rate][
'pid'][$id],
259 'pref' =>$x_coll[$my_coll_rate][
'pref'][$id],
260 'ptype' =>$x_coll[$my_coll_rate][
'ptype'][$id],
261 'payment_id'=>$x_coll[$my_coll_rate][
'payment_id'][$id],
262 'payment_ref'=>$x_coll[$my_coll_rate][
'payment_ref'][$id],
263 'payment_amount'=>$x_coll[$my_coll_rate][
'payment_amount'][$id],
264 'ftotal_ttc'=>$x_coll[$my_coll_rate][
'ftotal_ttc'][$id],
265 'dtotal_ttc'=>$x_coll[$my_coll_rate][
'dtotal_ttc'][$id],
266 'dtype' =>$x_coll[$my_coll_rate][
'dtype'][$id],
267 'datef' =>$x_coll[$my_coll_rate][
'datef'][$id],
268 'datep' =>$x_coll[$my_coll_rate][
'datep'][$id],
270 'company_link'=>$company_static->getNomUrl(1,
'', 20),
272 'ddate_start'=>$x_coll[$my_coll_rate][
'ddate_start'][$id],
273 'ddate_end' =>$x_coll[$my_coll_rate][
'ddate_end'][$id],
274 'totalht' =>$x_coll[$my_coll_rate][
'totalht_list'][$id],
275 'vat' =>$x_coll[$my_coll_rate][
'vat_list'][$id],
276 'link' =>$invoice_customer->getNomUrl(1,
'', 12)
281 foreach (array_keys($x_paye) as $my_paye_rate) {
282 $x_both[$my_paye_rate][
'paye'][
'totalht'] = $x_paye[$my_paye_rate][
'totalht'];
283 $x_both[$my_paye_rate][
'paye'][
'vat'] = $x_paye[$my_paye_rate][
'vat'];
284 if (!isset($x_both[$my_paye_rate][
'coll'][
'totalht'])) {
285 $x_both[$my_paye_rate][
'coll'][
'totalht'] = 0;
286 $x_both[$my_paye_rate][
'coll'][
'vat'] = 0;
288 $x_both[$my_paye_rate][
'paye'][
'links'] =
'';
289 $x_both[$my_paye_rate][
'paye'][
'detail'] = array();
291 foreach ($x_paye[$my_paye_rate][
'facid'] as $id => $dummy) {
293 if ($x_paye[$my_paye_rate][
'ptype'][$id] ==
'ExpenseReportPayment') {
294 $expensereport->id = $x_paye[$my_paye_rate][
'facid'][$id];
295 $expensereport->ref = $x_paye[$my_paye_rate][
'facnum'][$id];
296 $expensereport->type = $x_paye[$my_paye_rate][
'type'][$id];
298 $x_both[$my_paye_rate][
'paye'][
'detail'][] = array(
299 'id' =>$x_paye[$my_paye_rate][
'facid'][$id],
300 'descr' =>$x_paye[$my_paye_rate][
'descr'][$id],
301 'pid' =>$x_paye[$my_paye_rate][
'pid'][$id],
302 'pref' =>$x_paye[$my_paye_rate][
'pref'][$id],
303 'ptype' =>$x_paye[$my_paye_rate][
'ptype'][$id],
304 'payment_id' =>$x_paye[$my_paye_rate][
'payment_id'][$id],
305 'payment_ref' =>$x_paye[$my_paye_rate][
'payment_ref'][$id],
306 'payment_amount' =>$x_paye[$my_paye_rate][
'payment_amount'][$id],
307 'ftotal_ttc' =>
price2num($x_paye[$my_paye_rate][
'ftotal_ttc'][$id]),
308 'dtotal_ttc' =>
price2num($x_paye[$my_paye_rate][
'dtotal_ttc'][$id]),
309 'dtype' =>$x_paye[$my_paye_rate][
'dtype'][$id],
310 'ddate_start' =>$x_paye[$my_paye_rate][
'ddate_start'][$id],
311 'ddate_end' =>$x_paye[$my_paye_rate][
'ddate_end'][$id],
312 'totalht' =>
price2num($x_paye[$my_paye_rate][
'totalht_list'][$id]),
313 'vat' =>$x_paye[$my_paye_rate][
'vat_list'][$id],
314 'link' =>$expensereport->getNomUrl(1)
317 $invoice_supplier->id = $x_paye[$my_paye_rate][
'facid'][$id];
318 $invoice_supplier->ref = $x_paye[$my_paye_rate][
'facnum'][$id];
319 $invoice_supplier->type = $x_paye[$my_paye_rate][
'type'][$id];
321 $company_static->id = $x_paye[$my_paye_rate][
'company_id'][$id];
322 $company_static->name = $x_paye[$my_paye_rate][
'company_name'][$id];
323 $company_static->name_alias = $x_paye[$my_paye_rate][
'company_alias'][$id];
324 $company_static->email = $x_paye[$my_paye_rate][
'company_email'][$id];
325 $company_static->tva_intra = $x_paye[$my_paye_rate][
'tva_intra'][$id];
326 $company_static->client = $x_paye[$my_paye_rate][
'company_client'][$id];
327 $company_static->fournisseur = $x_paye[$my_paye_rate][
'company_fournisseur'][$id];
328 $company_static->status = $x_paye[$my_paye_rate][
'company_status'][$id];
329 $company_static->code_client = $x_paye[$my_paye_rate][
'company_customer_code'][$id];
330 $company_static->code_compta_client = $x_paye[$my_paye_rate][
'company_customer_accounting_code'][$id];
331 $company_static->code_fournisseur = $x_paye[$my_paye_rate][
'company_supplier_code'][$id];
332 $company_static->code_compta_fournisseur = $x_paye[$my_paye_rate][
'company_supplier_accounting_code'][$id];
334 $x_both[$my_paye_rate][
'paye'][
'detail'][] = array(
335 'id' =>$x_paye[$my_paye_rate][
'facid'][$id],
336 'descr' =>$x_paye[$my_paye_rate][
'descr'][$id],
337 'pid' =>$x_paye[$my_paye_rate][
'pid'][$id],
338 'pref' =>$x_paye[$my_paye_rate][
'pref'][$id],
339 'ptype' =>$x_paye[$my_paye_rate][
'ptype'][$id],
340 'payment_id'=>$x_paye[$my_paye_rate][
'payment_id'][$id],
341 'payment_ref'=>$x_paye[$my_paye_rate][
'payment_ref'][$id],
342 'payment_amount'=>$x_paye[$my_paye_rate][
'payment_amount'][$id],
343 'ftotal_ttc'=>
price2num($x_paye[$my_paye_rate][
'ftotal_ttc'][$id]),
344 'dtotal_ttc'=>
price2num($x_paye[$my_paye_rate][
'dtotal_ttc'][$id]),
345 'dtype' =>$x_paye[$my_paye_rate][
'dtype'][$id],
346 'datef' =>$x_paye[$my_paye_rate][
'datef'][$id],
347 'datep' =>$x_paye[$my_paye_rate][
'datep'][$id],
349 'company_link'=>$company_static->getNomUrl(1,
'', 20),
351 'ddate_start'=>$x_paye[$my_paye_rate][
'ddate_start'][$id],
352 'ddate_end' =>$x_paye[$my_paye_rate][
'ddate_end'][$id],
353 'totalht' =>
price2num($x_paye[$my_paye_rate][
'totalht_list'][$id]),
354 'vat' =>$x_paye[$my_paye_rate][
'vat_list'][$id],
355 'link' =>$invoice_supplier->getNomUrl(1,
'', 12)
373 print
'<tr class="liste_titre">';
374 print
'<td class="left">'.$elementcust.
'</td>';
375 print
'<td class="left">'.$langs->trans(
"DateInvoice").
'</td>';
376 if ($conf->global->TAX_MODE_SELL_PRODUCT ==
'payment' || $conf->global->TAX_MODE_SELL_SERVICE ==
'payment') {
377 print
'<td class="left">'.$langs->trans(
"DatePayment").
'</td>';
381 print
'<td class="left">'.$namecust.
'</td>';
382 print
'<td class="left">'.$productcust.
'</td>';
384 print
'<td class="right">'.$amountcust.
'</td>';
385 print
'<td class="right">'.$langs->trans(
"Payment").
' ('.$langs->trans(
"PercentOfInvoice").
')</td>';
387 print
'<td class="right">'.$langs->trans(
"AmountHTVATRealReceived").
'</td>';
388 print
'<td class="right">'.$vatcust.
'</td>';
391 $action =
"tvadetail";
392 $parameters[
"mode"] = $modetax;
393 $parameters[
"start"] = $date_start;
394 $parameters[
"end"] = $date_end;
395 $parameters[
"type"] =
'vat';
397 $object = array(&$x_coll, &$x_paye, &$x_both);
399 $hookmanager->initHooks(array(
'externalbalance'));
400 $reshook = $hookmanager->executeHooks(
'addVatLine', $parameters, $object, $action);
402 foreach (array_keys($x_coll) as $rate) {
403 $subtot_coll_total_ht = 0;
404 $subtot_coll_vat = 0;
406 if (is_array($x_both[$rate][
'coll'][
'detail'])) {
409 print
'<td class="tax_rate" colspan="' . ($span+1) .
'">';
410 print $langs->trans(
'Rate') .
' : ' .
vatrate($rate) .
'%';
411 print
' - <a href="'.DOL_URL_ROOT.
'/compta/tva/quadri_detail.php?invoice_type=customer';
412 if ($invoice_type !=
'customer' || !
GETPOSTISSET(
'vat_rate_show') ||
GETPOST(
'vat_rate_show') != $rate) {
413 print
'&vat_rate_show='.urlencode($rate);
415 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>';
419 foreach ($x_both[$rate][
'coll'][
'detail'] as $index => $fields) {
422 $type = (isset($fields[
'dtype']) ? $fields[
'dtype'] : $fields[
'ptype']);
425 if (!empty($fields[
'ddate_start'])) {
428 if (!empty($fields[
'ddate_end'])) {
433 $ratiopaymentinvoice=1;
435 if (($type == 0 && $conf->global->TAX_MODE_SELL_PRODUCT ==
'invoice')
436 || ($type == 1 && $conf->global->TAX_MODE_SELL_SERVICE ==
'invoice')) {
438 if (isset($fields[
'payment_amount']) &&
price2num($fields[
'ftotal_ttc'])) {
439 $ratiopaymentinvoice=($fields[
'payment_amount']/$fields[
'ftotal_ttc']);
445 $temp_ht=$fields[
'totalht']*$ratiopaymentinvoice;
448 $temp_vat=$fields[
'vat']*$ratiopaymentinvoice;
450 $subtot_coll_total_ht += $temp_ht;
451 $subtot_coll_vat += $temp_vat;
452 $x_coll_sum += $temp_vat;
456 if ($invoice_type ==
'customer' && $vat_rate_show == $rate) {
457 if (is_array($x_both[$rate][
'coll'][
'detail'])) {
458 foreach ($x_both[$rate][
'coll'][
'detail'] as $index => $fields) {
474 $type = (isset($fields[
'dtype']) ? $fields[
'dtype'] : $fields[
'ptype']);
477 if (!empty($fields[
'ddate_start'])) {
480 if (!empty($fields[
'ddate_end'])) {
485 print
'<tr class="oddeven">';
488 print
'<td class="nowrap left">' . $fields[
'link'] .
'</td>';
491 print
'<td class="left">' .
dol_print_date($fields[
'datef'],
'day') .
'</td>';
494 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>';
495 else print
'<td></td>';
498 print
'<td class="tdmaxoverflow150">';
500 print $fields[
'company_link'];
504 print
'<td class="left">';
505 if ($fields[
'pid']) {
506 $product_static->id = $fields[
'pid'];
507 $product_static->ref = $fields[
'pref'];
508 $product_static->type = $fields[
'dtype'];
509 print $product_static->getNomUrl(1);
515 $text =
img_object($langs->trans(
'Service'),
'service');
517 $text =
img_object($langs->trans(
'Product'),
'product');
519 if (preg_match(
'/^\((.*)\)$/', $fields[
'descr'], $reg)) {
520 if ($reg[1] ==
'DEPOSIT') {
521 $fields[
'descr'] = $langs->transnoentitiesnoconv(
'Deposit');
522 } elseif ($reg[1] ==
'CREDIT_NOTE') {
523 $fields[
'descr'] = $langs->transnoentitiesnoconv(
'CreditNote');
525 $fields[
'descr'] = $langs->transnoentitiesnoconv($reg[1]);
537 print
'<td class="nowrap right">';
538 print
price($fields[
'totalht']);
541 $ratiolineinvoice = ($fields[
'dtotal_ttc'] / $fields[
'ftotal_ttc']);
548 $ratiopaymentinvoice = 1;
550 print
'<td class="nowrap right">';
552 if ($fields[
'payment_amount'] && $fields[
'ftotal_ttc']) {
553 $payment_static->id = $fields[
'payment_id'];
554 $payment_static->ref = $fields[
'payment_ref'];
555 print $payment_static->getNomUrl(2,
'',
'', 0).
' ';
557 if (($type == 0 && $conf->global->TAX_MODE_SELL_PRODUCT ==
'invoice')
558 || ($type == 1 && $conf->global->TAX_MODE_SELL_SERVICE ==
'invoice')) {
559 print $langs->trans(
"NA");
561 if (isset($fields[
'payment_amount']) &&
price2num($fields[
'ftotal_ttc'])) {
562 $ratiopaymentinvoice = ($fields[
'payment_amount'] / $fields[
'ftotal_ttc']);
565 if (isset($fields[
'payment_amount'])) {
566 print
' (' . round($ratiopaymentinvoice * 100, 2) .
'%)';
573 print
'<td class="nowrap right">';
574 $temp_ht = $fields[
'totalht'] * $ratiopaymentinvoice;
579 print
'<td class="nowrap right">';
580 $temp_vat = $fields[
'vat'] * $ratiopaymentinvoice;
593 print
'<tr class="liste_total">';
594 print
'<td colspan="4"></td>';
595 print
'<td class="right">'.$langs->trans(
"Total").
':</td>';
597 print
'<td class="nowrap right"> </td>';
598 print
'<td class="right"> </td>';
600 print
'<td class="right"><span class="amount">'.price(
price2num($subtot_coll_total_ht,
'MT')).
'</span></td>';
601 print
'<td class="nowrap right"><span class="amount">'.price(
price2num($subtot_coll_vat,
'MT')).
'</span></td>';
605 if (count($x_coll) == 0) {
606 print
'<tr class="liste_total">';
607 print
'<td colspan="4"></td>';
608 print
'<td class="right">'.$langs->trans(
"Total").
':</td>';
610 print
'<td class="nowrap right"> </td>';
611 print
'<td class="right"> </td>';
613 print
'<td class="right">'.price(
price2num(0,
'MT')).
'</td>';
614 print
'<td class="nowrap right">'.price(
price2num(0,
'MT')).
'</td>';
619 print
'<tr><td colspan="'.($span+2).
'"> </td></tr>';
622 print
'<tr class="liste_titre liste_titre_topborder">';
623 print
'<td class="left">'.$elementsup.
'</td>';
624 print
'<td class="left">'.$langs->trans(
"DateInvoice").
'</td>';
625 if ($conf->global->TAX_MODE_BUY_PRODUCT ==
'payment' || $conf->global->TAX_MODE_BUY_SERVICE ==
'payment') print
'<td class="left">'.$langs->trans(
"DatePayment").
'</td>';
626 else print
'<td></td>';
627 print
'<td class="left">'.$namesup.
'</td>';
628 print
'<td class="left">'.$productsup.
'</td>';
630 print
'<td class="right">'.$amountsup.
'</td>';
631 print
'<td class="right">'.$langs->trans(
"Payment").
' ('.$langs->trans(
"PercentOfInvoice").
')</td>';
633 print
'<td class="right">'.$langs->trans(
"AmountHTVATRealPaid").
'</td>';
634 print
'<td class="right">'.$vatsup.
'</td>';
637 foreach (array_keys($x_paye) as $rate) {
638 $subtot_paye_total_ht = 0;
639 $subtot_paye_vat = 0;
641 if (is_array($x_both[$rate][
'paye'][
'detail'])) {
643 print
'<td class="tax_rate" colspan="' . ($span+1) .
'">';
644 print $langs->trans(
'Rate') .
' : ' .
vatrate($rate) .
'%';
645 print
' - <a href="'.DOL_URL_ROOT.
'/compta/tva/quadri_detail.php?invoice_type=supplier';
646 if ($invoice_type !=
'supplier' || !
GETPOSTISSET(
'vat_rate_show') ||
GETPOST(
'vat_rate_show') != $rate) {
647 print
'&vat_rate_show='.urlencode($rate);
649 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>';
653 foreach ($x_both[$rate][
'paye'][
'detail'] as $index => $fields) {
656 $type = (isset($fields[
'dtype']) ? $fields[
'dtype'] : $fields[
'ptype']);
659 if (!empty($fields[
'ddate_start'])) {
662 if (!empty($fields[
'ddate_end'])) {
667 $ratiopaymentinvoice = 1;
669 if (($type == 0 && $conf->global->TAX_MODE_BUY_PRODUCT ==
'invoice')
670 || ($type == 1 && $conf->global->TAX_MODE_BUY_SERVICE ==
'invoice')) {
672 if (isset($fields[
'payment_amount']) && $fields[
'ftotal_ttc']) {
673 $ratiopaymentinvoice = ($fields[
'payment_amount'] / $fields[
'ftotal_ttc']);
679 $temp_ht = $fields[
'totalht'] * $ratiopaymentinvoice;
682 $temp_vat = $fields[
'vat'] * $ratiopaymentinvoice;
684 $subtot_paye_total_ht += $temp_ht;
685 $subtot_paye_vat += $temp_vat;
686 $x_paye_sum += $temp_vat;
689 if ($invoice_type ==
'supplier' && $vat_rate_show == $rate) {
690 foreach ($x_both[$rate][
'paye'][
'detail'] as $index => $fields) {
706 $type = (isset($fields[
'dtype']) ? $fields[
'dtype'] : $fields[
'ptype']);
709 if (!empty($fields[
'ddate_start'])) {
712 if (!empty($fields[
'ddate_end'])) {
717 print
'<tr class="oddeven">';
720 print
'<td class="nowrap left">' . $fields[
'link'] .
'</td>';
723 print
'<td class="left">' .
dol_print_date($fields[
'datef'],
'day') .
'</td>';
726 if ($conf->global->TAX_MODE_BUY_PRODUCT ==
'payment' || $conf->global->TAX_MODE_BUY_SERVICE ==
'payment') {
727 print
'<td class="left">' .
dol_print_date($fields[
'datep'],
'day') .
'</td>';
733 print
'<td class="tdmaxoverflow150">';
735 print $fields[
'company_link'];
739 print
'<td class="left">';
740 if ($fields[
'pid']) {
741 $product_static->id = $fields[
'pid'];
742 $product_static->ref = $fields[
'pref'];
743 $product_static->type = $fields[
'dtype'];
744 print $product_static->getNomUrl(1);
750 $text =
img_object($langs->trans(
'Service'),
'service');
752 $text =
img_object($langs->trans(
'Product'),
'product');
754 if (preg_match(
'/^\((.*)\)$/', $fields[
'descr'], $reg)) {
755 if ($reg[1] ==
'DEPOSIT') {
756 $fields[
'descr'] = $langs->transnoentitiesnoconv(
'Deposit');
757 } elseif ($reg[1] ==
'CREDIT_NOTE') {
758 $fields[
'descr'] = $langs->transnoentitiesnoconv(
'CreditNote');
760 $fields[
'descr'] = $langs->transnoentitiesnoconv($reg[1]);
772 print
'<td class="nowrap right">';
773 print
price($fields[
'totalht']);
776 $ratiolineinvoice = ($fields[
'dtotal_ttc'] / $fields[
'ftotal_ttc']);
783 $ratiopaymentinvoice = 1;
785 print
'<td class="nowrap right">';
786 if ($fields[
'payment_amount'] && $fields[
'ftotal_ttc']) {
787 $paymentfourn_static->id = $fields[
'payment_id'];
788 $paymentfourn_static->ref = $fields[
'payment_ref'];
789 print $paymentfourn_static->getNomUrl(2,
'',
'', 0).
' ';
792 if (($type == 0 && $conf->global->TAX_MODE_BUY_PRODUCT ==
'invoice')
793 || ($type == 1 && $conf->global->TAX_MODE_BUY_SERVICE ==
'invoice')) {
794 print $langs->trans(
"NA");
796 if (isset($fields[
'payment_amount']) && $fields[
'ftotal_ttc']) {
797 $ratiopaymentinvoice = ($fields[
'payment_amount'] / $fields[
'ftotal_ttc']);
800 if (isset($fields[
'payment_amount'])) {
801 print
' (' . round($ratiopaymentinvoice * 100, 2) .
'%)';
808 print
'<td class="nowrap right">';
809 $temp_ht = $fields[
'totalht'] * $ratiopaymentinvoice;
814 print
'<td class="nowrap right">';
815 $temp_vat = $fields[
'vat'] * $ratiopaymentinvoice;
829 print
'<tr class="liste_total">';
830 print
'<td colspan="4"></td>';
831 print
'<td class="right">'.$langs->trans(
"Total").
':</td>';
833 print
'<td class="nowrap right"> </td>';
834 print
'<td class="right"> </td>';
836 print
'<td class="right"><span class="amount">'.price(
price2num($subtot_paye_total_ht,
'MT')).
'</span></td>';
837 print
'<td class="nowrap right"><span class="amount">'.price(
price2num($subtot_paye_vat,
'MT')).
'</span></td>';
841 if (count($x_paye) == 0) {
842 print
'<tr class="liste_total">';
843 print
'<td colspan="4"></td>';
844 print
'<td class="right">'.$langs->trans(
"Total").
':</td>';
846 print
'<td class="nowrap right"> </td>';
847 print
'<td class="right"> </td>';
849 print
'<td class="right"><span class="amount">'.price(
price2num(0,
'MT')).
'</span></td>';
850 print
'<td class="nowrap right"><span class="amount">'.price(
price2num(0,
'MT')).
'</span></td>';
859 print
'<table class="noborder centpercent">';
860 $diff = $x_coll_sum - $x_paye_sum;
861 print
'<tr class="liste_total">';
862 print
'<td class="liste_total" colspan="'.$span.
'">'.$langs->trans(
"TotalToPay").($q ?
', '.$langs->trans(
"Quadri").
' '.$q :
'').
'</td>';
863 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.
if($cancel &&!$id) if($action== 'add'&&!$cancel) if($action== 'delete') if($id) $form
Actions.
Class to manage products or services.
dol_now($mode= 'auto')
Return date for now.
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOCSRFCHECK')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
report_header($reportname, $notused, $period, $periodlink, $description, $builddate, $exportlink= '', $moreparam=array(), $calcmode= '', $varlink= '')
Show header of a report.
Class to manage suppliers invoices.
Put here description of your class.
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...
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...
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form...
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 '...
img_picto($titlealt, $picto, $moreatt= '', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt= '', $morecss= '', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
Class to manage payments of customer invoices.
GETPOSTINT($paramname, $method=0)
Return value of a param into GET or POST supervariable.
img_object($titlealt, $picto, $moreatt= '', $pictoisfullpath=false, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
Class to manage Trips and Expenses.
restrictedArea($user, $features, $objectid=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.
dol_print_date($time, $format= '', $tzoutput= 'auto', $outputlangs= '', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
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.
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...