32require
'../../main.inc.php';
41require_once DOL_DOCUMENT_ROOT.
'/core/lib/report.lib.php';
42require_once DOL_DOCUMENT_ROOT.
'/core/lib/tax.lib.php';
43require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
44require_once DOL_DOCUMENT_ROOT.
'/compta/tva/class/tva.class.php';
45require_once DOL_DOCUMENT_ROOT.
'/compta/localtax/class/localtax.class.php';
46require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
47require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
48require_once DOL_DOCUMENT_ROOT.
'/compta/paiement/class/paiement.class.php';
49require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.facture.class.php';
50require_once DOL_DOCUMENT_ROOT.
'/fourn/class/paiementfourn.class.php';
51require_once DOL_DOCUMENT_ROOT.
'/expensereport/class/expensereport.class.php';
52require_once DOL_DOCUMENT_ROOT.
'/expensereport/class/paymentexpensereport.class.php';
55$langs->loadLangs(array(
"other",
"compta",
"banks",
"bills",
"companies",
"product",
"trips",
"admin"));
59include DOL_DOCUMENT_ROOT.
'/compta/tva/initdatesforvat.inc.php';
72@phan-var-force int $date_start
73@phan-var-force int $date_end
74@phan-var-force int $date_start_month
75@phan-var-force int $date_start_year
76@phan-var-force int $date_start_day
77@phan-var-force int $date_end_month
78@phan-var-force int $date_end_year
79@phan-var-force int $date_end_day
80@phan-var-force int $year_current
93if (GETPOSTISSET(
"modetax")) {
103 $socid = $user->socid;
117$form =
new Form($db);
118$company_static =
new Societe($db);
119$invoice_customer =
new Facture($db);
122$product_static =
new Product($db);
127$morequerystring =
'';
128$listofparams = array(
'date_startmonth',
'date_startyear',
'date_startday',
'date_endmonth',
'date_endyear',
'date_endday');
129foreach ($listofparams as $param) {
131 $morequerystring .= ($morequerystring ?
'&' :
'').$param.
'='.
GETPOSTINT($param);
135llxHeader(
'', $langs->trans(
"LocalTaxReport"),
'',
'', 0, 0,
'',
'', $morequerystring);
137$fsearch =
'<!-- hidden fields for form -->';
138$fsearch .=
'<input type="hidden" name="token" value="'.newToken().
'">';
139$fsearch .=
'<input type="hidden" name="modetax" value="'.$modetax.
'">';
140$fsearch .=
'<input type="hidden" name="localTaxType" value="'.$local.
'">';
142$name = $langs->transcountry($local == 1 ?
"LT1ReportByQuarters" :
"LT2ReportByQuarters",
$mysoc->country_code);
145 $calcmode = $langs->trans(
'OptionVATDefault');
148 $calcmode = $langs->trans(
'OptionVATDebitOption');
151 $calcmode = $langs->trans(
'OptionPaymentForProductAndServices');
153$calcmode .=
' <span class="opacitymedium">('.$langs->trans(
"TaxModuleSetupToModifyRules", DOL_URL_ROOT.
'/admin/taxes.php').
')</span>';
155$period = $form->selectDate($date_start,
'date_start', 0, 0, 0,
'', 1, 0).
' - '.$form->selectDate($date_end,
'date_end', 0, 0, 0,
'', 1, 0);
157$description = $fsearch;
172 $description .= $langs->trans(
"ThisIsAnEstimatedValue");
176$elementcust = $langs->trans(
"CustomersInvoices");
177$productcust = $langs->trans(
"ProductOrService");
178$amountcust = $langs->trans(
"AmountHT");
179$vatcust = $langs->trans(
"VATReceived");
180$namecust = $langs->trans(
"Name");
182 $vatcust .=
' ('.$langs->trans(
"StatusToPay").
')';
186$elementsup = $langs->trans(
"SuppliersInvoices");
187$productsup = $productcust;
188$amountsup = $amountcust;
189$vatsup = $langs->trans(
"VATPaid");
192 $vatsup .=
' ('.$langs->trans(
"ToGetBack").
')';
198report_header($name,
'', $period, $periodlink, $description, $builddate, $exportlink, array(), $calcmode);
201 $vatcust = $langs->transcountry(
"LT1",
$mysoc->country_code);
202 $vatsup = $langs->transcountry(
"LT1",
$mysoc->country_code);
203 $vatexpensereport = $langs->transcountry(
"LT1",
$mysoc->country_code);
205 $vatcust = $langs->transcountry(
"LT2",
$mysoc->country_code);
206 $vatsup = $langs->transcountry(
"LT2",
$mysoc->country_code);
207 $vatexpensereport = $langs->transcountry(
"LT2",
$mysoc->country_code);
211print
'<div class="div-table-responsive">';
212echo
'<table class="noborder centpercent">';
220$x_coll =
tax_by_rate(
'localtax'.$local, $db, 0, 0, $date_start, $date_end, $modetax,
'sell');
221$x_paye =
tax_by_rate(
'localtax'.$local, $db, 0, 0, $date_start, $date_end, $modetax,
'buy');
223if (!is_array($x_coll) || !is_array($x_paye)) {
224 $langs->load(
"errors");
226 print
'<tr><td colspan="'.$columns.
'">'.$langs->trans(
"ErrorNoAccountancyModuleLoaded").
'</td></tr>';
227 } elseif ($x_coll == -2) {
228 print
'<tr><td colspan="'.$columns.
'">'.$langs->trans(
"FeatureNotYetAvailable").
'</td></tr>';
230 print
'<tr><td colspan="'.$columns.
'">'.$langs->trans(
"Error").
'</td></tr>';
236 foreach (array_keys($x_coll) as $my_coll_rate) {
237 $x_both[$my_coll_rate][
'coll'][
'totalht'] = $x_coll[$my_coll_rate][
'totalht'];
238 $x_both[$my_coll_rate][
'coll'][
'localtax'.$local] = $x_coll[$my_coll_rate][
'localtax'.$local];
239 $x_both[$my_coll_rate][
'paye'][
'totalht'] = 0;
240 $x_both[$my_coll_rate][
'paye'][
'localtax'.$local] = 0;
241 $x_both[$my_coll_rate][
'coll'][
'links'] =
'';
242 $x_both[$my_coll_rate][
'coll'][
'detail'] = array();
243 foreach ($x_coll[$my_coll_rate][
'facid'] as
$id => $dummy) {
244 $invoice_customer->id = $x_coll[$my_coll_rate][
'facid'][
$id];
245 $invoice_customer->ref = $x_coll[$my_coll_rate][
'facnum'][
$id];
246 $invoice_customer->type = $x_coll[$my_coll_rate][
'type'][
$id];
247 $company_static->fetch($x_coll[$my_coll_rate][
'company_id'][
$id]);
248 $x_both[$my_coll_rate][
'coll'][
'detail'][] = array(
249 'id' => $x_coll[$my_coll_rate][
'facid'][
$id],
250 'descr' => $x_coll[$my_coll_rate][
'descr'][
$id],
251 'pid' => $x_coll[$my_coll_rate][
'pid'][
$id],
252 'pref' => $x_coll[$my_coll_rate][
'pref'][
$id],
253 'ptype' => $x_coll[$my_coll_rate][
'ptype'][
$id],
254 'payment_id' => $x_coll[$my_coll_rate][
'payment_id'][
$id],
255 'payment_amount' => $x_coll[$my_coll_rate][
'payment_amount'][
$id],
256 'ftotal_ttc' => $x_coll[$my_coll_rate][
'ftotal_ttc'][
$id],
257 'dtotal_ttc' => $x_coll[$my_coll_rate][
'dtotal_ttc'][
$id],
258 'dtype' => $x_coll[$my_coll_rate][
'dtype'][
$id],
259 'datef' => $x_coll[$my_coll_rate][
'datef'][
$id],
260 'datep' => $x_coll[$my_coll_rate][
'datep'][
$id],
261 'company_link' => $company_static->getNomUrl(1,
'', 20),
262 'ddate_start' => $x_coll[$my_coll_rate][
'ddate_start'][
$id],
263 'ddate_end' => $x_coll[$my_coll_rate][
'ddate_end'][
$id],
264 'totalht' => $x_coll[$my_coll_rate][
'totalht_list'][
$id],
265 'localtax1' => $x_coll[$my_coll_rate][
'localtax1_list'][
$id],
266 'localtax2' => $x_coll[$my_coll_rate][
'localtax2_list'][
$id],
267 'vat' => $x_coll[$my_coll_rate][
'vat_list'][
$id],
268 'link' => $invoice_customer->getNomUrl(1,
'', 12)
273 foreach (array_keys($x_paye) as $my_paye_rate) {
274 $x_both[$my_paye_rate][
'paye'][
'totalht'] = $x_paye[$my_paye_rate][
'totalht'];
275 $x_both[$my_paye_rate][
'paye'][
'vat'] = $x_paye[$my_paye_rate][
'vat'];
276 if (!isset($x_both[$my_paye_rate][
'coll'][
'totalht'])) {
277 $x_both[$my_paye_rate][
'coll'][
'totalht'] = 0;
278 $x_both[$my_paye_rate][
'coll'][
'vat'] = 0;
280 $x_both[$my_paye_rate][
'paye'][
'links'] =
'';
281 $x_both[$my_paye_rate][
'paye'][
'detail'] = array();
283 foreach ($x_paye[$my_paye_rate][
'facid'] as
$id => $dummy) {
284 $invoice_supplier->id = $x_paye[$my_paye_rate][
'facid'][
$id];
285 $invoice_supplier->ref = $x_paye[$my_paye_rate][
'facnum'][
$id];
286 $invoice_supplier->type = $x_paye[$my_paye_rate][
'type'][
$id];
287 $x_both[$my_paye_rate][
'paye'][
'detail'][] = array(
288 'id' => $x_paye[$my_paye_rate][
'facid'][
$id],
289 'descr' => $x_paye[$my_paye_rate][
'descr'][
$id],
290 'pid' => $x_paye[$my_paye_rate][
'pid'][
$id],
291 'pref' => $x_paye[$my_paye_rate][
'pref'][
$id],
292 'ptype' => $x_paye[$my_paye_rate][
'ptype'][
$id],
293 'payment_id' => $x_paye[$my_paye_rate][
'payment_id'][
$id],
294 'payment_amount' => $x_paye[$my_paye_rate][
'payment_amount'][
$id],
295 'ftotal_ttc' =>
price2num($x_paye[$my_paye_rate][
'ftotal_ttc'][
$id]),
296 'dtotal_ttc' =>
price2num($x_paye[$my_paye_rate][
'dtotal_ttc'][
$id]),
297 'dtype' => $x_paye[$my_paye_rate][
'dtype'][
$id],
298 'datef' => $x_paye[$my_paye_rate][
'datef'][
$id],
299 'datep' => $x_paye[$my_paye_rate][
'datep'][
$id],
300 'company_link' => $company_static->getNomUrl(1,
'', 20),
301 'ddate_start' => $x_paye[$my_paye_rate][
'ddate_start'][
$id],
302 'ddate_end' => $x_paye[$my_paye_rate][
'ddate_end'][
$id],
303 'totalht' =>
price2num($x_paye[$my_paye_rate][
'totalht_list'][
$id]),
304 'localtax1' => $x_paye[$my_paye_rate][
'localtax1_list'][
$id],
305 'localtax2' => $x_paye[$my_paye_rate][
'localtax2_list'][
$id],
306 'vat' => $x_paye[$my_paye_rate][
'vat_list'][
$id],
307 'link' => $invoice_supplier->getNomUrl(1,
'', 12)
320 $span = $columns - 1;
329 print
'<tr class="liste_titre">';
330 print
'<td class="left">'.$elementcust.
'</td>';
331 print
'<td class="left">'.$productcust.
'</td>';
333 print
'<td class="right">'.$amountcust.
'</td>';
336 print
'<td class="right">'.$langs->trans(
"Payment").
' ('.$langs->trans(
"PercentOfInvoice").
')</td>';
338 print
'<td class="right">'.$langs->trans(
"BI").
'</td>';
339 print
'<td class="right">'.$vatcust.
'</td>';
345 foreach (array_keys($x_coll) as $rate) {
346 $subtot_coll_total_ht = 0;
347 $subtot_coll_vat = 0;
349 if (is_array($x_both[$rate][
'coll'][
'detail'])) {
353 print
'<td class="tax_rate">'.$langs->trans(
"Rate").
': '.
vatrate($rate).
'%</td><td colspan="'.$span.
'"></td>';
356 foreach ($x_both[$rate][
'coll'][
'detail'] as $index => $fields) {
357 if (($local == 1 && $fields[
'localtax1'] != 0) || ($local == 2 && $fields[
'localtax2'] != 0)) {
359 $type = ($fields[
'dtype'] ? $fields[
'dtype'] : $fields[
'ptype']);
361 if (!empty($fields[
'ddate_start'])) {
364 if (!empty($fields[
'ddate_end'])) {
369 print
'<tr class="oddeven">';
372 print
'<td class="nowrap left">'.$fields[
'link'].
'</td>';
375 print
'<td class="left">';
376 if ($fields[
'pid']) {
377 $product_static->id = $fields[
'pid'];
378 $product_static->ref = $fields[
'pref'];
379 $product_static->type = $fields[
'ptype'];
380 print $product_static->getNomUrl(1);
386 $text =
img_object($langs->trans(
'Service'),
'service');
388 $text =
img_object($langs->trans(
'Product'),
'product');
390 if (preg_match(
'/^\((.*)\)$/', $fields[
'descr'], $reg)) {
391 if ($reg[1] ==
'DEPOSIT') {
392 $fields[
'descr'] = $langs->transnoentitiesnoconv(
'Deposit');
393 } elseif ($reg[1] ==
'CREDIT_NOTE') {
394 $fields[
'descr'] = $langs->transnoentitiesnoconv(
'CreditNote');
396 $fields[
'descr'] = $langs->transnoentitiesnoconv($reg[1]);
408 print
'<td class="nowrap right">';
409 print
price($fields[
'totalht']);
411 $ratiolineinvoice = ($fields[
'dtotal_ttc'] / $fields[
'ftotal_ttc']);
417 $ratiopaymentinvoice = 1;
419 if (isset($fields[
'payment_amount']) && $fields[
'ftotal_ttc']) {
420 $ratiopaymentinvoice = ($fields[
'payment_amount'] / $fields[
'ftotal_ttc']);
422 print
'<td class="nowrap right">';
423 if ($fields[
'payment_amount'] && $fields[
'ftotal_ttc']) {
424 $payment_static->id = $fields[
'payment_id'];
425 print $payment_static->getNomUrl(2);
428 print $langs->trans(
"NotUsedForGoods");
430 print
price($fields[
'payment_amount']);
431 if (isset($fields[
'payment_amount'])) {
432 print
' ('.round($ratiopaymentinvoice * 100, 2).
'%)';
439 print
'<td class="nowrap right">';
440 $temp_ht = $fields[
'totalht'];
442 $temp_ht = (float) $fields[
'totalht'] * $ratiopaymentinvoice;
448 print
'<td class="nowrap right">';
449 $temp_vat = $local == 1 ? $fields[
'localtax1'] : $fields[
'localtax2'];
455 $subtot_coll_total_ht += $temp_ht;
456 $subtot_coll_vat += $temp_vat;
457 $x_coll_sum += $temp_vat;
463 print
'<tr class="liste_total">';
465 print
'<td class="right">'.$langs->trans(
"Total").
':</td>';
467 print
'<td class="nowrap right"> </td>';
468 print
'<td class="right"> </td>';
470 print
'<td class="right"><span class="amount">'.price(
price2num($subtot_coll_total_ht,
'MT')).
'</span></td>';
471 print
'<td class="nowrap right"><span class="amount">'.price(
price2num($subtot_coll_vat,
'MT')).
'</span></td>';
475 if (count($x_coll) == 0) {
476 print
'<tr class="liste_total">';
477 print
'<td> </td>';
478 print
'<td class="right">'.$langs->trans(
"Total").
':</td>';
480 print
'<td class="nowrap right"> </td>';
481 print
'<td class="right"> </td>';
483 print
'<td class="right"><span class="amount">'.price(
price2num(0,
'MT')).
'</span></td>';
484 print
'<td class="nowrap right"><span class="amount">'.price(
price2num(0,
'MT')).
'</span></td>';
489 print
'<tr><td colspan="'.($span + 1).
'"> </td></tr>';
495 print
'<tr class="liste_titre">';
496 print
'<td class="left">'.$elementsup.
'</td>';
497 print
'<td class="left">'.$productsup.
'</td>';
499 print
'<td class="right">'.$amountsup.
'</td>';
500 print
'<td class="right">'.$langs->trans(
"Payment").
' ('.$langs->trans(
"PercentOfInvoice").
')</td>';
502 print
'<td class="right">'.$langs->trans(
"BI").
'</td>';
503 print
'<td class="right">'.$vatsup.
'</td>';
506 foreach (array_keys($x_paye) as $rate) {
507 $subtot_paye_total_ht = 0;
508 $subtot_paye_vat = 0;
510 if (is_array($x_both[$rate][
'paye'][
'detail'])) {
513 print
'<td class="tax_rate">'.$langs->trans(
"Rate").
': '.
vatrate($rate).
'%</td><td colspan="'.$span.
'"></td>';
516 foreach ($x_both[$rate][
'paye'][
'detail'] as $index => $fields) {
517 if (($local == 1 && $fields[
'localtax1'] != 0) || ($local == 2 && $fields[
'localtax2'] != 0)) {
519 $type = ($fields[
'dtype'] ? $fields[
'dtype'] : $fields[
'ptype']);
521 if (!empty($fields[
'ddate_start'])) {
524 if (!empty($fields[
'ddate_end'])) {
529 print
'<tr class="oddeven">';
532 print
'<td class="nowrap left">'.$fields[
'link'].
'</td>';
535 print
'<td class="left">';
536 if ($fields[
'pid']) {
537 $product_static->id = $fields[
'pid'];
538 $product_static->ref = $fields[
'pref'];
539 $product_static->type = $fields[
'ptype'];
540 print $product_static->getNomUrl(1);
546 $text =
img_object($langs->trans(
'Service'),
'service');
548 $text =
img_object($langs->trans(
'Product'),
'product');
559 print
'<td class="nowrap right">';
560 print
price($fields[
'totalht']);
563 $ratiolineinvoice = ((float) $fields[
'dtotal_ttc'] / (
float) $fields[
'ftotal_ttc']);
570 $ratiopaymentinvoice = 1;
572 print
'<td class="nowrap right">';
573 if (isset($fields[
'payment_amount']) && $fields[
'ftotal_ttc']) {
574 $ratiopaymentinvoice = ($fields[
'payment_amount'] / (float) $fields[
'ftotal_ttc']);
576 if ($fields[
'payment_amount'] && $fields[
'ftotal_ttc']) {
577 $paymentfourn_static->id = $fields[
'payment_id'];
578 print $paymentfourn_static->getNomUrl(2);
581 print $langs->trans(
"NA");
584 if (isset($fields[
'payment_amount'])) {
585 print
' ('.round($ratiopaymentinvoice * 100, 2).
'%)';
592 print
'<td class="nowrap right">';
593 $temp_ht = (float) $fields[
'totalht'] * $ratiopaymentinvoice;
598 print
'<td class="nowrap right">';
599 $temp_vat = ($local == 1 ? $fields[
'localtax1'] : $fields[
'localtax2']) * $ratiopaymentinvoice;
605 $subtot_paye_total_ht += $temp_ht;
606 $subtot_paye_vat += $temp_vat;
607 $x_paye_sum += $temp_vat;
613 print
'<tr class="liste_total">';
614 print
'<td> </td>';
615 print
'<td class="right">'.$langs->trans(
"Total").
':</td>';
617 print
'<td class="nowrap right"> </td>';
618 print
'<td class="right"> </td>';
620 print
'<td class="right"><span class="amount">'.price(
price2num($subtot_paye_total_ht,
'MT')).
'</span></td>';
621 print
'<td class="nowrap right"><span class="amount">'.price(
price2num($subtot_paye_vat,
'MT')).
'</span></td>';
625 if (count($x_paye) == 0) {
626 print
'<tr class="liste_total">';
627 print
'<td> </td>';
628 print
'<td class="right">'.$langs->trans(
"Total").
':</td>';
630 print
'<td class="nowrap right"> </td>';
631 print
'<td class="right"> </td>';
633 print
'<td class="right"><span class="amount">'.price(
price2num(0,
'MT')).
'</span></td>';
634 print
'<td class="nowrap right"><span class="amount">'.price(
price2num(0,
'MT')).
'</span></td>';
639 $diff = $x_coll_sum - $x_paye_sum;
640 print
'<tr class="liste_total">';
641 print
'<td class="liste_total" colspan="'.$span.
'">'.$langs->trans(
"TotalToPay").
'</td>';
642 print
'<td class="liste_total nowrap right"><b>'.price(
price2num($diff,
'MT')).
"</b></td>\n";
$id
Support class for third parties, contacts, members, users or resources.
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
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_now($mode='gmt')
Return date for now.
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 '.
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $allowothertags=array())
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.
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 a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
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...