32require
'../../main.inc.php';
33require_once DOL_DOCUMENT_ROOT.
'/core/lib/report.lib.php';
34require_once DOL_DOCUMENT_ROOT.
'/core/lib/tax.lib.php';
35require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
36require_once DOL_DOCUMENT_ROOT.
'/compta/tva/class/tva.class.php';
37require_once DOL_DOCUMENT_ROOT.
'/compta/localtax/class/localtax.class.php';
38require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
39require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
40require_once DOL_DOCUMENT_ROOT.
'/compta/paiement/class/paiement.class.php';
41require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.facture.class.php';
42require_once DOL_DOCUMENT_ROOT.
'/fourn/class/paiementfourn.class.php';
43require_once DOL_DOCUMENT_ROOT.
'/expensereport/class/expensereport.class.php';
44require_once DOL_DOCUMENT_ROOT.
'/expensereport/class/paymentexpensereport.class.php';
47$langs->loadLangs(array(
"other",
"compta",
"banks",
"bills",
"companies",
"product",
"trips",
"admin"));
54 $year_start = $year_current;
56 $year_current = $year;
62if (empty($date_start) || empty($date_end)) {
108if (GETPOSTISSET(
"modetax")) {
111if (empty($modetax)) {
118 $socid = $user->socid;
133$form =
new Form($db);
134$company_static =
new Societe($db);
135$invoice_customer =
new Facture($db);
138$product_static =
new Product($db);
143$morequerystring =
'';
144$listofparams = array(
'date_startmonth',
'date_startyear',
'date_startday',
'date_endmonth',
'date_endyear',
'date_endday');
145foreach ($listofparams as $param) {
147 $morequerystring .= ($morequerystring ?
'&' :
'').$param.
'='.
GETPOST($param);
151llxHeader(
'', $langs->trans(
"LocalTaxReport"),
'',
'', 0, 0,
'',
'', $morequerystring);
153$fsearch =
'<!-- hidden fields for form -->';
154$fsearch .=
'<input type="hidden" name="token" value="'.newToken().
'">';
155$fsearch .=
'<input type="hidden" name="modetax" value="'.$modetax.
'">';
156$fsearch .=
'<input type="hidden" name="localTaxType" value="'.$local.
'">';
158$name = $langs->transcountry($local == 1 ?
"LT1ReportByQuarters" :
"LT2ReportByQuarters", $mysoc->country_code);
161 $calcmode = $langs->trans(
'OptionVATDefault');
164 $calcmode = $langs->trans(
'OptionVATDebitOption');
167 $calcmode = $langs->trans(
'OptionPaymentForProductAndServices');
169$calcmode .=
' <span class="opacitymedium">('.$langs->trans(
"TaxModuleSetupToModifyRules", DOL_URL_ROOT.
'/admin/taxes.php').
')</span>';
171$period = $form->selectDate($date_start,
'date_start', 0, 0, 0,
'', 1, 0).
' - '.$form->selectDate($date_end,
'date_end', 0, 0, 0,
'', 1, 0);
172$prevyear = $year_start;
175if ($prevquarter > 1) {
181$nextyear = $year_start;
183if ($nextquarter < 4) {
189$description = $fsearch;
203if (isModEnabled(
'accounting')) {
204 $description .= $langs->trans(
"ThisIsAnEstimatedValue");
208$elementcust = $langs->trans(
"CustomersInvoices");
209$productcust = $langs->trans(
"ProductOrService");
210$amountcust = $langs->trans(
"AmountHT");
211$vatcust = $langs->trans(
"VATReceived");
212$namecust = $langs->trans(
"Name");
213if ($mysoc->tva_assuj) {
214 $vatcust .=
' ('.$langs->trans(
"StatusToPay").
')';
218$elementsup = $langs->trans(
"SuppliersInvoices");
219$productsup = $productcust;
220$amountsup = $amountcust;
221$vatsup = $langs->trans(
"VATPaid");
223if ($mysoc->tva_assuj) {
224 $vatsup .=
' ('.$langs->trans(
"ToGetBack").
')';
230report_header($name,
'', $period, $periodlink, $description, $builddate, $exportlink, array(), $calcmode);
233 $vatcust = $langs->transcountry(
"LT1", $mysoc->country_code);
234 $vatsup = $langs->transcountry(
"LT1", $mysoc->country_code);
235 $vatexpensereport = $langs->transcountry(
"LT1", $mysoc->country_code);
237 $vatcust = $langs->transcountry(
"LT2", $mysoc->country_code);
238 $vatsup = $langs->transcountry(
"LT2", $mysoc->country_code);
239 $vatexpensereport = $langs->transcountry(
"LT2", $mysoc->country_code);
243print
'<div class="div-table-responsive">';
244echo
'<table class="noborder centpercent">';
252$x_coll =
tax_by_rate(
'localtax'.$local, $db, 0, 0, $date_start, $date_end, $modetax,
'sell');
253$x_paye =
tax_by_rate(
'localtax'.$local, $db, 0, 0, $date_start, $date_end, $modetax,
'buy');
255if (!is_array($x_coll) || !is_array($x_paye)) {
256 $langs->load(
"errors");
258 print
'<tr><td colspan="'.$columns.
'">'.$langs->trans(
"ErrorNoAccountancyModuleLoaded").
'</td></tr>';
259 } elseif ($x_coll == -2) {
260 print
'<tr><td colspan="'.$columns.
'">'.$langs->trans(
"FeatureNotYetAvailable").
'</td></tr>';
262 print
'<tr><td colspan="'.$columns.
'">'.$langs->trans(
"Error").
'</td></tr>';
268 foreach (array_keys($x_coll) as $my_coll_rate) {
269 $x_both[$my_coll_rate][
'coll'][
'totalht'] = $x_coll[$my_coll_rate][
'totalht'];
270 $x_both[$my_coll_rate][
'coll'][
'localtax'.$local] = $x_coll[$my_coll_rate][
'localtax'.$local];
271 $x_both[$my_coll_rate][
'paye'][
'totalht'] = 0;
272 $x_both[$my_coll_rate][
'paye'][
'localtax'.$local] = 0;
273 $x_both[$my_coll_rate][
'coll'][
'links'] =
'';
274 $x_both[$my_coll_rate][
'coll'][
'detail'] = array();
275 foreach ($x_coll[$my_coll_rate][
'facid'] as $id => $dummy) {
276 $invoice_customer->id = $x_coll[$my_coll_rate][
'facid'][$id];
277 $invoice_customer->ref = $x_coll[$my_coll_rate][
'facnum'][$id];
278 $invoice_customer->type = $x_coll[$my_coll_rate][
'type'][$id];
279 $company_static->fetch($x_coll[$my_coll_rate][
'company_id'][$id]);
280 $x_both[$my_coll_rate][
'coll'][
'detail'][] = array(
281 'id' => $x_coll[$my_coll_rate][
'facid'][$id],
282 'descr' => $x_coll[$my_coll_rate][
'descr'][$id],
283 'pid' => $x_coll[$my_coll_rate][
'pid'][$id],
284 'pref' => $x_coll[$my_coll_rate][
'pref'][$id],
285 'ptype' => $x_coll[$my_coll_rate][
'ptype'][$id],
286 'payment_id' => $x_coll[$my_coll_rate][
'payment_id'][$id],
287 'payment_amount' => $x_coll[$my_coll_rate][
'payment_amount'][$id],
288 'ftotal_ttc' => $x_coll[$my_coll_rate][
'ftotal_ttc'][$id],
289 'dtotal_ttc' => $x_coll[$my_coll_rate][
'dtotal_ttc'][$id],
290 'dtype' => $x_coll[$my_coll_rate][
'dtype'][$id],
291 'datef' => $x_coll[$my_coll_rate][
'datef'][$id],
292 'datep' => $x_coll[$my_coll_rate][
'datep'][$id],
293 'company_link' => $company_static->getNomUrl(1,
'', 20),
294 'ddate_start' => $x_coll[$my_coll_rate][
'ddate_start'][$id],
295 'ddate_end' => $x_coll[$my_coll_rate][
'ddate_end'][$id],
296 'totalht' => $x_coll[$my_coll_rate][
'totalht_list'][$id],
297 'localtax1' => $x_coll[$my_coll_rate][
'localtax1_list'][$id],
298 'localtax2' => $x_coll[$my_coll_rate][
'localtax2_list'][$id],
299 'vat' => $x_coll[$my_coll_rate][
'vat_list'][$id],
300 'link' => $invoice_customer->getNomUrl(1,
'', 12)
305 foreach (array_keys($x_paye) as $my_paye_rate) {
306 $x_both[$my_paye_rate][
'paye'][
'totalht'] = $x_paye[$my_paye_rate][
'totalht'];
307 $x_both[$my_paye_rate][
'paye'][
'vat'] = $x_paye[$my_paye_rate][
'vat'];
308 if (!isset($x_both[$my_paye_rate][
'coll'][
'totalht'])) {
309 $x_both[$my_paye_rate][
'coll'][
'totalht'] = 0;
310 $x_both[$my_paye_rate][
'coll'][
'vat'] = 0;
312 $x_both[$my_paye_rate][
'paye'][
'links'] =
'';
313 $x_both[$my_paye_rate][
'paye'][
'detail'] = array();
315 foreach ($x_paye[$my_paye_rate][
'facid'] as $id => $dummy) {
316 $invoice_supplier->id = $x_paye[$my_paye_rate][
'facid'][$id];
317 $invoice_supplier->ref = $x_paye[$my_paye_rate][
'facnum'][$id];
318 $invoice_supplier->type = $x_paye[$my_paye_rate][
'type'][$id];
319 $x_both[$my_paye_rate][
'paye'][
'detail'][] = array(
320 'id' => $x_paye[$my_paye_rate][
'facid'][$id],
321 'descr' => $x_paye[$my_paye_rate][
'descr'][$id],
322 'pid' => $x_paye[$my_paye_rate][
'pid'][$id],
323 'pref' => $x_paye[$my_paye_rate][
'pref'][$id],
324 'ptype' => $x_paye[$my_paye_rate][
'ptype'][$id],
325 'payment_id' => $x_paye[$my_paye_rate][
'payment_id'][$id],
326 'payment_amount' => $x_paye[$my_paye_rate][
'payment_amount'][$id],
327 'ftotal_ttc' =>
price2num($x_paye[$my_paye_rate][
'ftotal_ttc'][$id]),
328 'dtotal_ttc' =>
price2num($x_paye[$my_paye_rate][
'dtotal_ttc'][$id]),
329 'dtype' => $x_paye[$my_paye_rate][
'dtype'][$id],
330 'datef' => $x_paye[$my_paye_rate][
'datef'][$id],
331 'datep' => $x_paye[$my_paye_rate][
'datep'][$id],
332 'company_link' => $company_static->getNomUrl(1,
'', 20),
333 'ddate_start' => $x_paye[$my_paye_rate][
'ddate_start'][$id],
334 'ddate_end' => $x_paye[$my_paye_rate][
'ddate_end'][$id],
335 'totalht' =>
price2num($x_paye[$my_paye_rate][
'totalht_list'][$id]),
336 'localtax1' => $x_paye[$my_paye_rate][
'localtax1_list'][$id],
337 'localtax2' => $x_paye[$my_paye_rate][
'localtax2_list'][$id],
338 'vat' => $x_paye[$my_paye_rate][
'vat_list'][$id],
339 'link' => $invoice_supplier->getNomUrl(1,
'', 12)
352 $span = $columns - 1;
361 print
'<tr class="liste_titre">';
362 print
'<td class="left">'.$elementcust.
'</td>';
363 print
'<td class="left">'.$productcust.
'</td>';
365 print
'<td class="right">'.$amountcust.
'</td>';
368 print
'<td class="right">'.$langs->trans(
"Payment").
' ('.$langs->trans(
"PercentOfInvoice").
')</td>';
370 print
'<td class="right">'.$langs->trans(
"BI").
'</td>';
371 print
'<td class="right">'.$vatcust.
'</td>';
377 foreach (array_keys($x_coll) as $rate) {
378 $subtot_coll_total_ht = 0;
379 $subtot_coll_vat = 0;
381 if (is_array($x_both[$rate][
'coll'][
'detail'])) {
385 print
'<td class="tax_rate">'.$langs->trans(
"Rate").
': '.
vatrate($rate).
'%</td><td colspan="'.$span.
'"></td>';
388 foreach ($x_both[$rate][
'coll'][
'detail'] as $index => $fields) {
389 if (($local == 1 && $fields[
'localtax1'] != 0) || ($local == 2 && $fields[
'localtax2'] != 0)) {
391 $type = ($fields[
'dtype'] ? $fields[
'dtype'] : $fields[
'ptype']);
394 if (!empty($fields[
'ddate_start'])) {
397 if (!empty($fields[
'ddate_end'])) {
402 print
'<tr class="oddeven">';
405 print
'<td class="nowrap left">'.$fields[
'link'].
'</td>';
408 print
'<td class="left">';
409 if ($fields[
'pid']) {
410 $product_static->id = $fields[
'pid'];
411 $product_static->ref = $fields[
'pref'];
412 $product_static->type = $fields[
'ptype'];
413 print $product_static->getNomUrl(1);
419 $text =
img_object($langs->trans(
'Service'),
'service');
421 $text =
img_object($langs->trans(
'Product'),
'product');
423 if (preg_match(
'/^\((.*)\)$/', $fields[
'descr'], $reg)) {
424 if ($reg[1] ==
'DEPOSIT') {
425 $fields[
'descr'] = $langs->transnoentitiesnoconv(
'Deposit');
426 } elseif ($reg[1] ==
'CREDIT_NOTE') {
427 $fields[
'descr'] = $langs->transnoentitiesnoconv(
'CreditNote');
429 $fields[
'descr'] = $langs->transnoentitiesnoconv($reg[1]);
441 print
'<td class="nowrap right">';
442 print
price($fields[
'totalht']);
444 $ratiolineinvoice = ($fields[
'dtotal_ttc'] / $fields[
'ftotal_ttc']);
450 $ratiopaymentinvoice = 1;
452 if (isset($fields[
'payment_amount']) && $fields[
'ftotal_ttc']) {
453 $ratiopaymentinvoice = ($fields[
'payment_amount'] / $fields[
'ftotal_ttc']);
455 print
'<td class="nowrap right">';
456 if ($fields[
'payment_amount'] && $fields[
'ftotal_ttc']) {
457 $payment_static->id = $fields[
'payment_id'];
458 print $payment_static->getNomUrl(2);
461 print $langs->trans(
"NotUsedForGoods");
463 print
price($fields[
'payment_amount']);
464 if (isset($fields[
'payment_amount'])) {
465 print
' ('.round($ratiopaymentinvoice * 100, 2).
'%)';
472 print
'<td class="nowrap right">';
473 $temp_ht = $fields[
'totalht'];
475 $temp_ht = $fields[
'totalht'] * $ratiopaymentinvoice;
481 print
'<td class="nowrap right">';
482 $temp_vat = $local == 1 ? $fields[
'localtax1'] : $fields[
'localtax2'];
488 $subtot_coll_total_ht += $temp_ht;
489 $subtot_coll_vat += $temp_vat;
490 $x_coll_sum += $temp_vat;
496 print
'<tr class="liste_total">';
498 print
'<td class="right">'.$langs->trans(
"Total").
':</td>';
500 print
'<td class="nowrap right"> </td>';
501 print
'<td class="right"> </td>';
503 print
'<td class="right"><span class="amount">'.price(
price2num($subtot_coll_total_ht,
'MT')).
'</span></td>';
504 print
'<td class="nowrap right"><span class="amount">'.price(
price2num($subtot_coll_vat,
'MT')).
'</span></td>';
508 if (count($x_coll) == 0) {
509 print
'<tr class="liste_total">';
510 print
'<td> </td>';
511 print
'<td class="right">'.$langs->trans(
"Total").
':</td>';
513 print
'<td class="nowrap right"> </td>';
514 print
'<td class="right"> </td>';
516 print
'<td class="right"><span class="amount">'.price(
price2num(0,
'MT')).
'</span></td>';
517 print
'<td class="nowrap right"><span class="amount">'.price(
price2num(0,
'MT')).
'</span></td>';
522 print
'<tr><td colspan="'.($span + 1).
'"> </td></tr>';
528 print
'<tr class="liste_titre">';
529 print
'<td class="left">'.$elementsup.
'</td>';
530 print
'<td class="left">'.$productsup.
'</td>';
532 print
'<td class="right">'.$amountsup.
'</td>';
533 print
'<td class="right">'.$langs->trans(
"Payment").
' ('.$langs->trans(
"PercentOfInvoice").
')</td>';
535 print
'<td class="right">'.$langs->trans(
"BI").
'</td>';
536 print
'<td class="right">'.$vatsup.
'</td>';
539 foreach (array_keys($x_paye) as $rate) {
540 $subtot_paye_total_ht = 0;
541 $subtot_paye_vat = 0;
543 if (is_array($x_both[$rate][
'paye'][
'detail'])) {
546 print
'<td class="tax_rate">'.$langs->trans(
"Rate").
': '.
vatrate($rate).
'%</td><td colspan="'.$span.
'"></td>';
549 foreach ($x_both[$rate][
'paye'][
'detail'] as $index => $fields) {
550 if (($local == 1 && $fields[
'localtax1'] != 0) || ($local == 2 && $fields[
'localtax2'] != 0)) {
552 $type = ($fields[
'dtype'] ? $fields[
'dtype'] : $fields[
'ptype']);
555 if (!empty($fields[
'ddate_start'])) {
558 if (!empty($fields[
'ddate_end'])) {
563 print
'<tr class="oddeven">';
566 print
'<td class="nowrap left">'.$fields[
'link'].
'</td>';
569 print
'<td class="left">';
570 if ($fields[
'pid']) {
571 $product_static->id = $fields[
'pid'];
572 $product_static->ref = $fields[
'pref'];
573 $product_static->type = $fields[
'ptype'];
574 print $product_static->getNomUrl(1);
580 $text =
img_object($langs->trans(
'Service'),
'service');
582 $text =
img_object($langs->trans(
'Product'),
'product');
593 print
'<td class="nowrap right">';
594 print
price($fields[
'totalht']);
597 $ratiolineinvoice = ((float) $fields[
'dtotal_ttc'] / (
float) $fields[
'ftotal_ttc']);
604 $ratiopaymentinvoice = 1;
606 print
'<td class="nowrap right">';
607 if (isset($fields[
'payment_amount']) && $fields[
'ftotal_ttc']) {
608 $ratiopaymentinvoice = ($fields[
'payment_amount'] / (float) $fields[
'ftotal_ttc']);
610 if ($fields[
'payment_amount'] && $fields[
'ftotal_ttc']) {
611 $paymentfourn_static->id = $fields[
'payment_id'];
612 print $paymentfourn_static->getNomUrl(2);
615 print $langs->trans(
"NA");
618 if (isset($fields[
'payment_amount'])) {
619 print
' ('.round($ratiopaymentinvoice * 100, 2).
'%)';
626 print
'<td class="nowrap right">';
627 $temp_ht = (float) $fields[
'totalht'] * $ratiopaymentinvoice;
632 print
'<td class="nowrap right">';
633 $temp_vat = ($local == 1 ? $fields[
'localtax1'] : $fields[
'localtax2']) * $ratiopaymentinvoice;
639 $subtot_paye_total_ht += $temp_ht;
640 $subtot_paye_vat += $temp_vat;
641 $x_paye_sum += $temp_vat;
647 print
'<tr class="liste_total">';
648 print
'<td> </td>';
649 print
'<td class="right">'.$langs->trans(
"Total").
':</td>';
651 print
'<td class="nowrap right"> </td>';
652 print
'<td class="right"> </td>';
654 print
'<td class="right"><span class="amount">'.price(
price2num($subtot_paye_total_ht,
'MT')).
'</span></td>';
655 print
'<td class="nowrap right"><span class="amount">'.price(
price2num($subtot_paye_vat,
'MT')).
'</span></td>';
659 if (count($x_paye) == 0) {
660 print
'<tr class="liste_total">';
661 print
'<td> </td>';
662 print
'<td class="right">'.$langs->trans(
"Total").
':</td>';
664 print
'<td class="nowrap right"> </td>';
665 print
'<td class="right"> </td>';
667 print
'<td class="right"><span class="amount">'.price(
price2num(0,
'MT')).
'</span></td>';
668 print
'<td class="nowrap right"><span class="amount">'.price(
price2num(0,
'MT')).
'</span></td>';
673 $diff = $x_coll_sum - $x_paye_sum;
674 print
'<tr class="liste_total">';
675 print
'<td class="liste_total" colspan="'.$span.
'">'.$langs->trans(
"TotalToPay").($q ?
', '.$langs->trans(
"Quadri").
' '.$q :
'').
'</td>';
676 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...)
dol_get_first_day($year, $month=1, $gm=false)
Return GMT time for first day of a month or year.
dol_time_plus_duree($time, $duration_value, $duration_unit, $ruleforendofmonth=0)
Add a delay to a date.
dol_get_last_day($year, $month=12, $gm=false)
Return GMT time for last day of a month or year.
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed information (by default a local PHP server timestamp) Rep...
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
vatrate($rate, $addpercent=false, $info_bits=0, $usestarfornpr=0, $html=0)
Return a string with VAT rate label formatted for view output Used into pdf and HTML pages.
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.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
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.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.
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...