119 global
$conf, $bc, $langs;
121 $result = $db->query($sql);
123 $num = $db->num_rows($result);
126 print
'<table class="noborder centpercent">';
128 print
'<tr class="liste_titre">';
129 print
'<td class="nowrap">'.$date.
'</td>';
130 print
'<td class="right">'.$langs->trans(
"ClaimedForThisPeriod").
'</td>';
131 print
'<td class="right">'.$langs->trans(
"PaidDuringThisPeriod").
'</td>';
143 $obj = $db->fetch_object($result);
147 if ($obj->mode ==
'claimed' && !empty($previousmode)) {
148 print
'<tr class="oddeven">';
149 print
'<td class="nowrap">'.$previousmonth.
"</td>\n";
150 print
'<td class="nowrap right">'.price($amountclaimed).
"</td>\n";
151 print
'<td class="nowrap right">'.price($amountpaid).
"</td>\n";
158 if ($obj->mode ==
'claimed') {
159 $amountclaimed = $obj->mm;
160 $totalclaimed += $amountclaimed;
162 if ($obj->mode ==
'paid') {
163 $amountpaid = $obj->mm;
164 $totalpaid += $amountpaid;
167 if ($obj->mode ==
'paid') {
168 print
'<tr class="oddeven">';
169 print
'<td class="nowrap">'.$obj->dm.
"</td>\n";
170 print
'<td class="nowrap right">'.price($amountclaimed).
"</td>\n";
171 print
'<td class="nowrap right">'.price($amountpaid).
"</td>\n";
178 $previousmode = $obj->mode;
179 $previousmonth = $obj->dm;
185 if ($mode ==
'claimed' && !empty($previousmode)) {
186 print
'<tr class="oddeven">';
187 print
'<td class="nowrap">'.$previousmonth.
"</td>\n";
188 print
'<td class="nowrap right">'.price($amountclaimed).
"</td>\n";
189 print
'<td class="nowrap right">'.price($amountpaid).
"</td>\n";
196 print
'<tr class="liste_total">';
197 print
'<td class="right">'.$langs->trans(
"Total").
'</td>';
198 print
'<td class="nowrap right">'.price($totalclaimed).
'</td>';
199 print
'<td class="nowrap right">'.price($totalpaid).
'</td>';
209if (empty($localTaxType)) {
225$form =
new Form($db);
226$company_static =
new Societe($db);
229if ($localTaxType == 1) {
231 $LTSummary =
'LT1Summary';
233 $LTCustomer =
'LT1Customer';
234 $LTSupplier =
'LT1Supplier';
238 $LTSummary =
'LT2Summary';
240 $LTCustomer =
'LT2Customer';
241 $LTSupplier =
'LT2Supplier';
245$fsearch =
'<!-- hidden fields for form -->';
246$fsearch .=
'<input type="hidden" name="token" value="'.newToken().
'">';
247$fsearch .=
'<input type="hidden" name="localTaxType" value="'.$localTaxType.
'">';
248$fsearch .=
'<input type="hidden" name="modetax" value="'.$modetax.
'">';
250$description = $fsearch;
253$name = $langs->transcountry($localTaxType == 1 ?
"LT1ReportByMonth" :
"LT2ReportByMonth", $mysoc->country_code);
254$description .= $langs->trans($LT);
255$calcmode = $langs->trans(
"LTReportBuildWithOptionDefinedInModule").
' ';
256$calcmode .=
' <span class="opacitymedium">('.$langs->trans(
"TaxModuleSetupToModifyRulesLT", DOL_URL_ROOT.
'/admin/company.php').
')</span>';
258$period = $form->selectDate($date_start,
'date_start', 0, 0, 0,
'', 1, 0).
' - '.$form->selectDate($date_end,
'date_end', 0, 0, 0,
'', 1, 0);
272report_header($name,
'', $period, $periodlink, $description, $builddate, $exportlink, array(), $calcmode);
278print
'<div class="fichecenter"><div class="fichethirdleft">';
280print
load_fiche_titre($langs->transcountry($LTSummary, $mysoc->country_code),
'',
'');
282print
'<table class="noborder centpercent">';
283print
'<tr class="liste_titre">';
284print
'<td>'.$langs->trans(
"Year").
"</td>";
286 print
'<td class="right">'.$langs->transcountry($LTCustomer, $mysoc->country_code).
'</td>';
287 print
'<td class="right">'.$langs->transcountry($LTSupplier, $mysoc->country_code).
'</td>';
290 print
'<td class="right">'.$langs->transcountry($LTSupplier, $mysoc->country_code).
'</td><td></td>';
293 print
'<td class="right">'.$langs->transcountry($LTCustomer, $mysoc->country_code).
'</td><td></td>';
295print
'<td class="right">'.$langs->trans(
"TotalToPay").
'</td>';
296print
"<td> </td>\n";
312while ((($y < $yend) || ($y == $yend && $m <= $mend)) && $mcursor < 1000) {
323 $x_coll =
tax_by_rate(($localTaxType == 1 ?
'localtax1' :
'localtax2'), $db, $y, 0, 0, 0, $modetax,
'sell', $m);
324 $x_paye =
tax_by_rate(($localTaxType == 1 ?
'localtax1' :
'localtax2'), $db, $y, 0, 0, 0, $modetax,
'buy', $m);
328 foreach (array_keys($x_coll) as $my_coll_rate) {
329 $x_both[$my_coll_rate][
'coll'][
'totalht'] = $x_coll[$my_coll_rate][
'totalht'];
330 $x_both[$my_coll_rate][
'coll'][
'vat'] = $x_coll[$my_coll_rate][
'vat'];
331 $x_both[$my_coll_rate][
'coll'][
'localtax1'] = $x_coll[$my_coll_rate][
'localtax1'];
332 $x_both[$my_coll_rate][
'coll'][
'localtax2'] = $x_coll[$my_coll_rate][
'localtax2'];
333 $x_both[$my_coll_rate][
'paye'][
'totalht'] = 0;
334 $x_both[$my_coll_rate][
'paye'][
'vat'] = 0;
335 $x_both[$my_coll_rate][
'paye'][
'localtax1'] = 0;
336 $x_both[$my_coll_rate][
'paye'][
'localtax2'] = 0;
337 $x_both[$my_coll_rate][
'coll'][
'links'] =
'';
338 $x_both[$my_coll_rate][
'coll'][
'detail'] = array();
339 foreach ($x_coll[$my_coll_rate][
'facid'] as $id => $dummy) {
344 $x_both[$my_coll_rate][
'coll'][
'detail'][] = array(
345 'id' => $x_coll[$my_coll_rate][
'facid'][$id],
346 'descr' => $x_coll[$my_coll_rate][
'descr'][$id],
347 'pid' => $x_coll[$my_coll_rate][
'pid'][$id],
348 'pref' => $x_coll[$my_coll_rate][
'pref'][$id],
349 'ptype' => $x_coll[$my_coll_rate][
'ptype'][$id],
350 'payment_id' => $x_coll[$my_coll_rate][
'payment_id'][$id],
351 'payment_amount' => $x_coll[$my_coll_rate][
'payment_amount'][$id],
352 'ftotal_ttc' => $x_coll[$my_coll_rate][
'ftotal_ttc'][$id],
353 'dtotal_ttc' => $x_coll[$my_coll_rate][
'dtotal_ttc'][$id],
354 'dtype' => $x_coll[$my_coll_rate][
'dtype'][$id],
355 'datef' => $x_coll[$my_coll_rate][
'datef'][$id],
356 'datep' => $x_coll[$my_coll_rate][
'datep'][$id],
358 'ddate_start' => $x_coll[$my_coll_rate][
'ddate_start'][$id],
359 'ddate_end' => $x_coll[$my_coll_rate][
'ddate_end'][$id],
361 'totalht' => $x_coll[$my_coll_rate][
'totalht_list'][$id],
362 'vat' => $x_coll[$my_coll_rate][
'vat_list'][$id],
363 'localtax1' => $x_coll[$my_coll_rate][
'localtax1_list'][$id],
364 'localtax2' => $x_coll[$my_coll_rate][
'localtax2_list'][$id],
371 foreach (array_keys($x_paye) as $my_paye_rate) {
372 $x_both[$my_paye_rate][
'paye'][
'totalht'] = $x_paye[$my_paye_rate][
'totalht'];
373 $x_both[$my_paye_rate][
'paye'][
'vat'] = $x_paye[$my_paye_rate][
'vat'];
374 $x_both[$my_paye_rate][
'paye'][
'localtax1'] = $x_paye[$my_paye_rate][
'localtax1'];
375 $x_both[$my_paye_rate][
'paye'][
'localtax2'] = $x_paye[$my_paye_rate][
'localtax2'];
376 if (!isset($x_both[$my_paye_rate][
'coll'][
'totalht'])) {
377 $x_both[$my_paye_rate][
'coll'][
'totalht'] = 0;
378 $x_both[$my_paye_rate][
'coll'][
'vat'] = 0;
379 $x_both[$my_paye_rate][
'coll'][
'localtax1'] = 0;
380 $x_both[$my_paye_rate][
'coll'][
'localtax2'] = 0;
382 $x_both[$my_paye_rate][
'paye'][
'links'] =
'';
383 $x_both[$my_paye_rate][
'paye'][
'detail'] = array();
385 foreach ($x_paye[$my_paye_rate][
'facid'] as $id => $dummy) {
387 if ($x_paye[$my_paye_rate][
'ptype'][$id] ==
'ExpenseReportPayment') {
392 $x_both[$my_paye_rate][
'paye'][
'detail'][] = array(
393 'id' => $x_paye[$my_paye_rate][
'facid'][$id],
394 'descr' => $x_paye[$my_paye_rate][
'descr'][$id],
395 'pid' => $x_paye[$my_paye_rate][
'pid'][$id],
396 'pref' => $x_paye[$my_paye_rate][
'pref'][$id],
397 'ptype' => $x_paye[$my_paye_rate][
'ptype'][$id],
398 'payment_id' => $x_paye[$my_paye_rate][
'payment_id'][$id],
399 'payment_amount' => $x_paye[$my_paye_rate][
'payment_amount'][$id],
400 'ftotal_ttc' =>
price2num($x_paye[$my_paye_rate][
'ftotal_ttc'][$id]),
401 'dtotal_ttc' =>
price2num($x_paye[$my_paye_rate][
'dtotal_ttc'][$id]),
402 'dtype' => $x_paye[$my_paye_rate][
'dtype'][$id],
403 'ddate_start' => $x_paye[$my_paye_rate][
'ddate_start'][$id],
404 'ddate_end' => $x_paye[$my_paye_rate][
'ddate_end'][$id],
406 'totalht' =>
price2num($x_paye[$my_paye_rate][
'totalht_list'][$id]),
407 'vat' => $x_paye[$my_paye_rate][
'vat_list'][$id],
408 'localtax1' => $x_paye[$my_paye_rate][
'localtax1_list'][$id],
409 'localtax2' => $x_paye[$my_paye_rate][
'localtax2_list'][$id],
417 $x_both[$my_paye_rate][
'paye'][
'detail'][] = array(
418 'id' => $x_paye[$my_paye_rate][
'facid'][$id],
419 'descr' => $x_paye[$my_paye_rate][
'descr'][$id],
420 'pid' => $x_paye[$my_paye_rate][
'pid'][$id],
421 'pref' => $x_paye[$my_paye_rate][
'pref'][$id],
422 'ptype' => $x_paye[$my_paye_rate][
'ptype'][$id],
423 'payment_id' => $x_paye[$my_paye_rate][
'payment_id'][$id],
424 'payment_amount' => $x_paye[$my_paye_rate][
'payment_amount'][$id],
425 'ftotal_ttc' =>
price2num($x_paye[$my_paye_rate][
'ftotal_ttc'][$id]),
426 'dtotal_ttc' =>
price2num($x_paye[$my_paye_rate][
'dtotal_ttc'][$id]),
427 'dtype' => $x_paye[$my_paye_rate][
'dtype'][$id],
428 'datef' => $x_paye[$my_paye_rate][
'datef'][$id],
429 'datep' => $x_paye[$my_paye_rate][
'datep'][$id],
431 'ddate_start' => $x_paye[$my_paye_rate][
'ddate_start'][$id],
432 'ddate_end' => $x_paye[$my_paye_rate][
'ddate_end'][$id],
434 'totalht' =>
price2num($x_paye[$my_paye_rate][
'totalht_list'][$id]),
435 'vat' => $x_paye[$my_paye_rate][
'vat_list'][$id],
436 'localtax1' => $x_paye[$my_paye_rate][
'localtax1_list'][$id],
437 'localtax2' => $x_paye[$my_paye_rate][
'localtax2_list'][$id],
446 $object = array(&$x_coll, &$x_paye, &$x_both);
447 $parameters[
"mode"] = $modetax;
448 $parameters[
"year"] = $y;
449 $parameters[
"month"] = $m;
450 $parameters[
"type"] =
'localtax'.$localTaxType;
453 $hookmanager->initHooks(array(
'externalbalance'));
454 $reshook = $hookmanager->executeHooks(
'addVatLine', $parameters, $object, $action);
457 print
'<tr class="oddeven">';
458 print
'<td class="nowrap"><a href="'.DOL_URL_ROOT.
'/compta/localtax/quadri_detail.php?leftmenu=tax_vat&month='.$m.
'&year='.$y.
'">'.
dol_print_date(
dol_mktime(0, 0, 0, (
int) $m, 1, (
int) $y),
"%b %Y").
'</a></td>';
461 foreach (array_keys($x_coll) as $rate) {
462 $subtot_coll_total_ht = 0;
463 $subtot_coll_vat = 0;
465 foreach ($x_both[$rate][
'coll'][
'detail'] as $index => $fields) {
467 $ratiopaymentinvoice = 1;
471 $type = (isset($fields[
'dtype']) ? $fields[
'dtype'] : $fields[
'ptype']);
474 if (!empty($fields[
'ddate_start'])) {
477 if (!empty($fields[
'ddate_end'])) {
485 if (isset($fields[
'payment_amount']) &&
price2num($fields[
'ftotal_ttc'])) {
486 $ratiopaymentinvoice = ($fields[
'payment_amount'] / $fields[
'ftotal_ttc']);
491 $temp_ht = (float) $fields[
'totalht'] * $ratiopaymentinvoice;
492 $temp_vat = $fields[
'localtax'.$localTaxType] * $ratiopaymentinvoice;
493 $subtot_coll_total_ht += $temp_ht;
494 $subtot_coll_vat += $temp_vat;
495 $x_coll_sum += $temp_vat;
498 print
'<td class="nowrap right">'.price(
price2num($x_coll_sum,
'MT')).
'</td>';
501 foreach (array_keys($x_paye) as $rate) {
502 $subtot_paye_total_ht = 0;
503 $subtot_paye_vat = 0;
505 foreach ($x_both[$rate][
'paye'][
'detail'] as $index => $fields) {
507 $ratiopaymentinvoice = 1;
511 $type = (isset($fields[
'dtype']) ? $fields[
'dtype'] : $fields[
'ptype']);
514 if (!empty($fields[
'ddate_start'])) {
517 if (!empty($fields[
'ddate_end'])) {
525 if (isset($fields[
'payment_amount']) &&
price2num($fields[
'ftotal_ttc'])) {
526 $ratiopaymentinvoice = ($fields[
'payment_amount'] / (float) $fields[
'ftotal_ttc']);
531 $temp_ht = (float) $fields[
'totalht'] * $ratiopaymentinvoice;
532 $temp_vat = $fields[
'localtax'.$localTaxType] * $ratiopaymentinvoice;
533 $subtot_paye_total_ht += $temp_ht;
534 $subtot_paye_vat += $temp_vat;
535 $x_paye_sum += $temp_vat;
538 print
'<td class="nowrap right">'.price(
price2num($x_paye_sum,
'MT')).
'</td>';
540 $subtotalcoll += $x_coll_sum;
541 $subtotalpaid += $x_paye_sum;
543 $diff = $x_coll_sum - $x_paye_sum;
545 $subtotal =
price2num($subtotal + $diff,
'MT');
547 print
'<td class="nowrap right">'.price(
price2num($diff,
'MT')).
'</td>'.
"\n";
548 print
"<td> </td>\n";
554 print
'<tr class="liste_total">';
555 print
'<td class="right"><a href="quadri_detail.php?leftmenu=tax_vat&q='.round($m / 3).
'&year='.$y.
'">'.$langs->trans(
"SubTotal").
'</a>:</td>';
556 print
'<td class="nowrap right">'.price(
price2num($subtotalcoll,
'MT')).
'</td>';
557 print
'<td class="nowrap right">'.price(
price2num($subtotalpaid,
'MT')).
'</td>';
558 print
'<td class="nowrap right">'.price(
price2num($subtotal,
'MT')).
'</td>';
559 print
'<td> </td></tr>';