26 require
'../../main.inc.php';
27 require_once DOL_DOCUMENT_ROOT.
'/core/lib/report.lib.php';
28 require_once DOL_DOCUMENT_ROOT.
'/core/lib/tax.lib.php';
29 require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
30 require_once DOL_DOCUMENT_ROOT.
'/compta/tva/class/tva.class.php';
31 require_once DOL_DOCUMENT_ROOT.
'/compta/localtax/class/localtax.class.php';
34 $langs->loadLangs(array(
"other",
"compta",
"banks",
"bills",
"companies",
"product",
"trips",
"admin"));
36 $local =
GETPOST(
'localTaxType',
'int');
42 $year_current = strftime(
"%Y",
dol_now());
43 $year_start = $year_current;
45 $year_current = $year;
51 if (empty($date_start) || empty($date_end))
57 $date_start =
dol_get_first_day($year_start, empty($conf->global->SOCIETE_FISCAL_MONTH_START) ? 1 : $conf->global->SOCIETE_FISCAL_MONTH_START,
false);
58 if (empty($conf->global->MAIN_INFO_VAT_RETURN) || $conf->global->MAIN_INFO_VAT_RETURN == 2) $date_end =
dol_time_plus_duree($date_start, 3,
'm') - 1;
59 elseif ($conf->global->MAIN_INFO_VAT_RETURN == 3) $date_end =
dol_time_plus_duree($date_start, 1, 'y') - 1;
60 elseif ($conf->global->MAIN_INFO_VAT_RETURN == 1) $date_end =
dol_time_plus_duree($date_start, 1, 'm') - 1;
71 if (empty($min)) $min = 0;
75 $modetax = $conf->global->TAX_MODE;
77 if (empty($modetax)) $modetax = 0;
80 $socid =
GETPOST(
'socid',
'int');
81 if ($user->socid) $socid = $user->socid;
96 $form =
new Form($db);
97 $company_static =
new Societe($db);
99 $morequerystring =
'';
100 $listofparams = array(
'date_startmonth',
'date_startyear',
'date_startday',
'date_endmonth',
'date_endyear',
'date_endday');
101 foreach ($listofparams as $param)
103 if (
GETPOST($param) !=
'') $morequerystring .= ($morequerystring ?
'&' :
'').$param.
'='.
GETPOST($param);
106 llxHeader(
'',
'',
'',
'', 0, 0,
'',
'', $morequerystring);
109 $name = $langs->transcountry($local == 1 ?
"LT1ReportByCustomers" :
"LT2ReportByCustomers", $mysoc->country_code);
111 $fsearch =
'<!-- hidden fields for form -->';
112 $fsearch .=
'<input type="hidden" name="token" value="'.newToken().
'">';
113 $fsearch .=
'<input type="hidden" name="modetax" value="'.$modetax.
'">';
114 $fsearch .=
'<input type="hidden" name="localTaxType" value="'.$local.
'">';
115 $fsearch .= $langs->trans(
"SalesTurnoverMinimum").
': ';
116 $fsearch .=
'<input type="text" name="min" id="min" value="'.$min.
'" size="6">';
118 $calc = $conf->global->MAIN_INFO_LOCALTAX_CALC.$local;
120 if ($calc == 0 || $calc == 1)
122 $calcmode = $calc == 0 ? $langs->trans(
"CalcModeLT".$local) : $langs->trans(
"CalcModeLT".$local.
"Rec");
123 $calcmode .=
' <span class="opacitymedium">('.$langs->trans(
"TaxModuleSetupToModifyRulesLT", DOL_URL_ROOT.
'/admin/company.php').
')</span>';
124 $period = $form->selectDate($date_start,
'date_start', 0, 0, 0,
'', 1, 0).
' - '.$form->selectDate($date_end,
'date_end', 0, 0, 0,
'', 1, 0);
125 if (!empty($conf->global->MAIN_MODULE_COMPTABILITE)) $description .=
'<br>'.$langs->trans(
"WarningDepositsNotIncluded");
126 $description .= $fsearch;
127 $description .=
' <span class="opacitymedium">('.$langs->trans(
"TaxModuleSetupToModifyRulesLT", DOL_URL_ROOT.
'/admin/company.php').
')</span>';
130 $elementcust = $langs->trans(
"CustomersInvoices");
131 $productcust = $langs->trans(
"Description");
132 $amountcust = $langs->trans(
"AmountHT");
133 $elementsup = $langs->trans(
"SuppliersInvoices");
134 $productsup = $langs->trans(
"Description");
135 $amountsup = $langs->trans(
"AmountHT");
139 $calcmode = $langs->trans(
"CalcModeLT2Debt");
140 $calcmode .=
' <span class="opacitymedium">('.$langs->trans(
"TaxModuleSetupToModifyRulesLT", DOL_URL_ROOT.
'/admin/company.php').
')</span>';
141 $period = $form->selectDate($date_start,
'date_start', 0, 0, 0,
'', 1, 0).
' - '.$form->selectDate($date_end,
'date_end', 0, 0, 0,
'', 1, 0);
142 if (!empty($conf->global->MAIN_MODULE_COMPTABILITE)) $description .=
'<br>'.$langs->trans(
"WarningDepositsNotIncluded");
143 $description .= $fsearch;
144 $description .=
'<span class="opacitymedium">('.$langs->trans(
"TaxModuleSetupToModifyRulesLT", DOL_URL_ROOT.
'/admin/company.php').
')</span>';
147 $elementcust = $langs->trans(
"CustomersInvoices");
148 $productcust = $langs->trans(
"Description");
149 $amountcust = $langs->trans(
"AmountHT");
150 $elementsup = $langs->trans(
"SuppliersInvoices");
151 $productsup = $langs->trans(
"Description");
152 $amountsup = $langs->trans(
"AmountHT");
154 report_header($name,
'', $period, $periodlink, $description, $builddate, $exportlink, array(), $calcmode);
157 $vatcust = $langs->transcountry($local == 1 ?
"LT1" :
"LT2", $mysoc->country_code);
158 $vatsup = $langs->transcountry($local == 1 ?
"LT1" :
"LT2", $mysoc->country_code);
160 print '<div class="div-table-responsive">';
161 print '<table class="noborder centpercent">';
164 if ($calc == 0 || $calc == 2)
166 print '<tr class="liste_titre">';
167 print '<td class="left">'.$langs->trans(
"Num").
'</td>';
168 print '<td class="left">'.$langs->trans(
"Customer").
'</td>';
169 print '<td>'.$langs->transcountry(
"ProfId1", $mysoc->country_code).
'</td>';
170 print '<td class="right">'.$langs->trans(
"TotalHT").
'</td>';
171 print '<td class="right">'.$vatcust.
'</td>';
174 $coll_list =
tax_by_thirdparty(
'localtax'.$local, $db, 0, $date_start, $date_end, $modetax,
'sell');
176 $action =
"tvaclient";
177 $object = &$coll_list;
178 $parameters[
"mode"] = $modetax;
179 $parameters[
"start"] = $date_start;
180 $parameters[
"end"] = $date_end;
181 $parameters[
"direction"] =
'sell';
182 $parameters[
"type"] =
'localtax'.$local;
185 $hookmanager->initHooks(array(
'externalbalance'));
186 $reshook = $hookmanager->executeHooks(
'addVatLine', $parameters, $object, $action);
188 if (is_array($coll_list))
190 $total = 0; $totalamount = 0;
192 foreach ($coll_list as $coll)
194 if (($min == 0 || ($min > 0 && $coll->amount > $min)) && ($local == 1 ? $coll->localtax1 : $coll->localtax2) != 0)
196 $intra = str_replace($find, $replace, $coll->tva_intra);
199 if ($coll->assuj ==
'1')
201 $intra = $langs->trans(
'Unknown');
206 print '<tr class="oddeven">';
207 print '<td class="nowrap">'.$i.
"</td>";
208 $company_static->id = $coll->socid;
209 $company_static->name = $coll->name;
210 print '<td class="nowrap">'.$company_static->getNomUrl(1).
'</td>';
211 $find = array(
' ',
'.');
212 $replace = array(
'',
'');
213 print '<td class="nowrap">'.$intra.
'</td>';
214 print '<td class="nowrap right">'.price($coll->amount).
'</td>';
215 print '<td class="nowrap right">'.price($local == 1 ? $coll->localtax1 : $coll->localtax2).
'</td>';
216 $totalamount = $totalamount + $coll->amount;
217 $total = $total + ($local == 1 ? $coll->localtax1 : $coll->localtax2);
222 $x_coll_sum = $total;
224 print '<tr class="liste_total"><td class="right" colspan="3">'.$langs->trans(
"Total").
':</td>';
225 print '<td class="nowrap right">'.price($totalamount).
'</td>';
226 print '<td class="nowrap right">'.price($total).
'</td>';
229 $langs->load(
"errors");
230 if ($coll_list == -1)
231 print '<tr><td colspan="5">'.$langs->trans(
"ErrorNoAccountancyModuleLoaded").
'</td></tr>';
232 elseif ($coll_list == -2)
233 print '<tr><td colspan="5">'.$langs->trans("FeatureNotYetAvailable").'</td></tr>';
234 else print '<tr><td colspan="5">'.$langs->trans("Error").'</td></tr>';
239 if ($calc == 0 || $calc == 1) {
240 print '<tr class="liste_titre">';
241 print '<td class="left">'.$langs->trans(
"Num").
"</td>";
242 print '<td class="left">'.$langs->trans(
"Supplier").
"</td>";
243 print '<td>'.$langs->transcountry(
"ProfId1", $mysoc->country_code).
'</td>';
244 print '<td class="right">'.$langs->trans(
"TotalHT").
'</td>';
245 print '<td class="right">'.$vatsup.
'</td>';
248 $company_static =
new Societe($db);
250 $coll_list =
tax_by_thirdparty(
'localtax'.$local, $db, 0, $date_start, $date_end, $modetax,
'buy');
251 $parameters[
"direction"] =
'buy';
252 $parameters[
"type"] =
'localtax'.$local;
254 $reshook = $hookmanager->executeHooks(
'addVatLine', $parameters, $object, $action);
255 if (is_array($coll_list))
257 $total = 0; $totalamount = 0;
259 foreach ($coll_list as $coll)
261 if (($min == 0 || ($min > 0 && $coll->amount > $min)) && ($local == 1 ? $coll->localtax1 : $coll->localtax2) != 0)
263 $intra = str_replace($find, $replace, $coll->tva_intra);
266 if ($coll->assuj ==
'1')
268 $intra = $langs->trans(
'Unknown');
273 print '<tr class="oddeven">';
274 print '<td class="nowrap">'.$i.
"</td>";
275 $company_static->id = $coll->socid;
276 $company_static->name = $coll->name;
277 print '<td class="nowrap">'.$company_static->getNomUrl(1).
'</td>';
278 $find = array(
' ',
'.');
279 $replace = array(
'',
'');
280 print '<td class="nowrap">'.$intra.
"</td>";
281 print '<td class="nowrap right">'.price($coll->amount).
'</td>';
282 print '<td class="nowrap right">'.price($local == 1 ? $coll->localtax1 : $coll->localtax2).
'</td>';
283 $totalamount = $totalamount + $coll->amount;
284 $total = $total + ($local == 1 ? $coll->localtax1 : $coll->localtax2);
289 $x_paye_sum = $total;
291 print '<tr class="liste_total"><td class="right" colspan="3">'.$langs->trans(
"Total").
':</td>';
292 print '<td class="nowrap right">'.price($totalamount).
'</td>';
293 print '<td class="nowrap right">'.price($total).
'</td>';
296 $langs->load(
"errors");
297 if ($coll_list == -1)
298 print '<tr><td colspan="5">'.$langs->trans(
"ErrorNoAccountancyModuleLoaded").
'</td></tr>';
299 elseif ($coll_list == -2)
300 print '<tr><td colspan="5">'.$langs->trans("FeatureNotYetAvailable").'</td></tr>';
301 else print '<tr><td colspan="5">'.$langs->trans("Error").'</td></tr>';
307 print '<tr><td colspan="5"></td></tr>';
309 $diff = $x_coll_sum - $x_paye_sum;
310 print '<tr class="liste_total">';
311 print '<td class="liste_total" colspan="4">'.$langs->trans(
"TotalToPay").($q ?
', '.$langs->trans(
"Quadri").
' '.$q :
'').
'</td>';
312 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_mktime($hour, $minute, $second, $month, $day, $year, $gm= 'auto', $check=1)
Return a timestamp date built from detailed informations (by default a local PHP server timestamp) Re...
tax_by_thirdparty($type, $db, $y, $date_start, $date_end, $modetax, $direction, $m=0, $q=0)
Look for collectable VAT clients in the chosen year (and month)
dol_now($mode= 'auto')
Return date for now.
report_header($reportname, $notused, $period, $periodlink, $description, $builddate, $exportlink= '', $moreparam=array(), $calcmode= '', $varlink= '')
Show header of a report.
dol_get_first_day($year, $month=1, $gm=false)
Return GMT time for first day of a month or year.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname.
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 '...
if(!GETPOST('transkey', 'alphanohtml')&&!GETPOST('transphrase', 'alphanohtml')) else
View.
restrictedArea($user, $features, $objectid=0, $tableandshare= '', $feature2= '', $dbt_keyfield= 'fk_soc', $dbt_select= 'rowid', $isdraft=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 Calling this function terminate execution ...
dol_get_last_day($year, $month=12, $gm=false)
Return GMT time for last day of a month or year.
print
Draft customers invoices.
dol_time_plus_duree($time, $duration_value, $duration_unit)
Add a delay to a date.
if(!defined('CSRFCHECK_WITH_TOKEN')) define('CSRFCHECK_WITH_TOKEN'
Draft customers invoices.