29 require
'../../main.inc.php';
30 require_once DOL_DOCUMENT_ROOT.
'/core/lib/report.lib.php';
31 require_once DOL_DOCUMENT_ROOT.
'/core/lib/tax.lib.php';
32 require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
33 require_once DOL_DOCUMENT_ROOT.
'/compta/tva/class/tva.class.php';
34 require_once DOL_DOCUMENT_ROOT.
'/compta/localtax/class/localtax.class.php';
35 require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
36 require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
37 require_once DOL_DOCUMENT_ROOT.
'/compta/paiement/class/paiement.class.php';
38 require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.facture.class.php';
39 require_once DOL_DOCUMENT_ROOT.
'/fourn/class/paiementfourn.class.php';
40 require_once DOL_DOCUMENT_ROOT.
'/expensereport/class/expensereport.class.php';
41 require_once DOL_DOCUMENT_ROOT.
'/expensereport/class/paymentexpensereport.class.php';
44 $langs->loadLangs(array(
"other",
"compta",
"banks",
"bills",
"companies",
"product",
"trips",
"admin"));
46 include DOL_DOCUMENT_ROOT.
'/compta/tva/initdatesforvat.inc.php';
55 $modetax = (empty($conf->global->TAX_MODE) ? 0 : $conf->global->TAX_MODE);
59 if (empty($modetax)) {
66 $socid = $user->socid;
77 $company_static =
new Societe($db);
78 $invoice_customer =
new Facture($db);
81 $product_static =
new Product($db);
85 $user_static =
new User($db);
87 $morequerystring =
'';
88 $listofparams = array(
'date_startmonth',
'date_startyear',
'date_startday',
'date_endmonth',
'date_endyear',
'date_endday');
89 foreach ($listofparams as $param) {
91 $morequerystring .= ($morequerystring ?
'&' :
'').$param.
'='.
GETPOST($param);
95 $special_report =
false;
96 if (isset($_REQUEST[
'extra_report']) && $_REQUEST[
'extra_report'] == 1) {
97 $special_report =
true;
100 llxHeader(
'', $langs->trans(
"VATReport"),
'',
'', 0, 0,
'',
'', $morequerystring);
102 $fsearch =
'<!-- hidden fields for form -->';
103 $fsearch .=
'<input type="hidden" name="token" value="'.newToken().
'">';
104 $fsearch .=
'<input type="hidden" name="modetax" value="'.$modetax.
'">';
105 $fsearch .= $langs->trans(
"SalesTurnoverMinimum").
': ';
106 $fsearch .=
'<input type="text" name="min" id="min" value="'.$min.
'" size="6">';
109 $name = $langs->trans(
"VATReportByThirdParties");
112 $calcmode = $langs->trans(
'OptionVATDefault');
115 $calcmode = $langs->trans(
'OptionVATDebitOption');
118 $calcmode = $langs->trans(
'OptionPaymentForProductAndServices');
120 $calcmode .=
' <span class="opacitymedium">('.$langs->trans(
"TaxModuleSetupToModifyRules", DOL_URL_ROOT.
'/admin/taxes.php').
')</span>';
122 $period =
$form->selectDate($date_start,
'date_start', 0, 0, 0,
'', 1, 0).
' - '.
$form->selectDate($date_end,
'date_end', 0, 0, 0,
'', 1, 0);
123 $prevyear = $date_start_year;
125 if ($prevquarter > 1) {
131 $nextyear = $date_start_year;
133 if ($nextquarter < 4) {
141 if ($conf->global->TAX_MODE_SELL_PRODUCT ==
'invoice') {
142 $description .= $langs->trans(
"RulesVATDueProducts");
144 if ($conf->global->TAX_MODE_SELL_PRODUCT ==
'payment') {
145 $description .= $langs->trans(
"RulesVATInProducts");
147 if ($conf->global->TAX_MODE_SELL_SERVICE ==
'invoice') {
148 $description .=
'<br>'.$langs->trans(
"RulesVATDueServices");
150 if ($conf->global->TAX_MODE_SELL_SERVICE ==
'payment') {
151 $description .=
'<br>'.$langs->trans(
"RulesVATInServices");
153 if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
154 $description .=
'<br>'.$langs->trans(
"DepositsAreNotIncluded");
156 if (!empty($conf->global->MAIN_MODULE_ACCOUNTING)) {
157 $description .=
'<br>'.$langs->trans(
"ThisIsAnEstimatedValue");
161 $description .= ($description ?
'<br>' :
'').$fsearch;
162 if (!empty($conf->global->TAX_REPORT_EXTRA_REPORT)) {
163 $description .=
'<br>';
164 $description .=
'<input type="radio" name="extra_report" value="0" '.($special_report ?
'' :
'checked="checked"').
'> ';
165 $description .= $langs->trans(
'SimpleReport');
166 $description .=
'</input>';
167 $description .=
'<br>';
168 $description .=
'<input type="radio" name="extra_report" value="1" '.($special_report ?
'checked="checked"' :
'').
'> ';
169 $description .= $langs->trans(
'AddExtraReport');
170 $description .=
'</input>';
171 $description .=
'<br>';
174 $elementcust = $langs->trans(
"CustomersInvoices");
175 $productcust = $langs->trans(
"Description");
176 $namerate = $langs->trans(
"VATRate");
177 $amountcust = $langs->trans(
"AmountHT");
178 if ($mysoc->tva_assuj) {
179 $vatcust .=
' ('.$langs->trans(
"StatusToPay").
')';
181 $elementsup = $langs->trans(
"SuppliersInvoices");
182 $productsup = $langs->trans(
"Description");
183 $amountsup = $langs->trans(
"AmountHT");
184 if ($mysoc->tva_assuj) {
185 $vatsup .=
' ('.$langs->trans(
"ToGetBack").
')';
187 report_header($name,
'', $period, $periodlink, $description, $builddate, $exportlink, array(), $calcmode);
189 $vatcust = $langs->trans(
"VATReceived");
190 $vatsup = $langs->trans(
"VATPaid");
194 print
'<div class="div-table-responsive">';
195 print
"<table class=\"noborder\" width=\"100%\">";
207 $x_coll =
tax_by_thirdparty(
'vat', $db, 0, $date_start, $date_end, $modetax,
'sell');
208 $x_paye =
tax_by_thirdparty(
'vat', $db, 0, $date_start, $date_end, $modetax,
'buy');
210 if (!is_array($x_coll) || !is_array($x_paye)) {
211 $langs->load(
"errors");
213 print
'<tr><td colspan="'.$columns.
'">'.$langs->trans(
"ErrorNoAccountancyModuleLoaded").
'</td></tr>';
214 } elseif ($x_coll == -2) {
215 print
'<tr><td colspan="'.$columns.
'">'.$langs->trans(
"FeatureNotYetAvailable").
'</td></tr>';
217 print
'<tr><td colspan="'.$columns.
'">'.$langs->trans(
"Error").
'</td></tr>';
222 foreach (array_keys($x_coll) as $my_coll_thirdpartyid) {
223 $x_both[$my_coll_thirdpartyid][
'coll'][
'totalht'] = $x_coll[$my_coll_thirdpartyid][
'totalht'];
224 $x_both[$my_coll_thirdpartyid][
'coll'][
'vat'] = $x_coll[$my_coll_thirdpartyid][
'vat'];
225 $x_both[$my_coll_thirdpartyid][
'paye'][
'totalht'] = 0;
226 $x_both[$my_coll_thirdpartyid][
'paye'][
'vat'] = 0;
227 $x_both[$my_coll_thirdpartyid][
'coll'][
'links'] =
'';
228 $x_both[$my_coll_thirdpartyid][
'coll'][
'detail'] = array();
229 foreach ($x_coll[$my_coll_thirdpartyid][
'facid'] as $id => $dummy) {
230 $invoice_customer->id = $x_coll[$my_coll_thirdpartyid][
'facid'][$id];
231 $invoice_customer->ref = $x_coll[$my_coll_thirdpartyid][
'facnum'][$id];
232 $invoice_customer->type = $x_coll[$my_coll_thirdpartyid][
'type'][$id];
235 $company_static->id = $x_coll[$my_coll_thirdpartyid][
'company_id'][$id];
236 $company_static->name = $x_coll[$my_coll_thirdpartyid][
'company_name'][$id];
237 $company_static->name_alias = $x_coll[$my_coll_thirdpartyid][
'company_alias'][$id];
238 $company_static->email = $x_coll[$my_coll_thirdpartyid][
'company_email'][$id];
239 $company_static->tva_intra = $x_coll[$my_coll_thirdpartyid][
'tva_intra'][$id];
240 $company_static->client = $x_coll[$my_coll_thirdpartyid][
'company_client'][$id];
241 $company_static->fournisseur = $x_coll[$my_coll_thirdpartyid][
'company_fournisseur'][$id];
242 $company_static->status = $x_coll[$my_coll_thirdpartyid][
'company_status'][$id];
243 $company_static->code_client = $x_coll[$my_coll_thirdpartyid][
'company_customer_code'][$id];
244 $company_static->code_compta_client = $x_coll[$my_coll_thirdpartyid][
'company_customer_accounting_code'][$id];
245 $company_static->code_fournisseur = $x_coll[$my_coll_thirdpartyid][
'company_supplier_code'][$id];
246 $company_static->code_compta_fournisseur = $x_coll[$my_coll_thirdpartyid][
'company_supplier_accounting_code'][$id];
248 $x_both[$my_coll_thirdpartyid][
'coll'][
'detail'][] = array(
249 'id' =>$x_coll[$my_coll_thirdpartyid][
'facid'][$id],
250 'descr' =>$x_coll[$my_coll_thirdpartyid][
'descr'][$id],
252 'pid' =>$x_coll[$my_coll_thirdpartyid][
'pid'][$id],
253 'pref' =>$x_coll[$my_coll_thirdpartyid][
'pref'][$id],
254 'ptype' =>$x_coll[$my_coll_thirdpartyid][
'ptype'][$id],
255 'pstatus' =>$x_paye[$my_coll_thirdpartyid][
'pstatus'][$id],
256 'pstatusbuy'=>$x_paye[$my_coll_thirdpartyid][
'pstatusbuy'][$id],
258 'payment_id'=>$x_coll[$my_coll_thirdpartyid][
'payment_id'][$id],
259 'payment_ref'=>$x_coll[$my_coll_thirdpartyid][
'payment_ref'][$id],
260 'payment_amount'=>$x_coll[$my_coll_thirdpartyid][
'payment_amount'][$id],
261 'ftotal_ttc'=>$x_coll[$my_coll_thirdpartyid][
'ftotal_ttc'][$id],
262 'dtotal_ttc'=>$x_coll[$my_coll_thirdpartyid][
'dtotal_ttc'][$id],
263 'dtype' =>$x_coll[$my_coll_thirdpartyid][
'dtype'][$id],
264 'drate' =>$x_coll[$my_coll_thirdpartyid][
'drate'][$id],
265 'datef' =>$x_coll[$my_coll_thirdpartyid][
'datef'][$id],
266 'datep' =>$x_coll[$my_coll_thirdpartyid][
'datep'][$id],
268 'company_link'=>$company_static->getNomUrl(1,
'', 20),
270 'ddate_start'=>$x_coll[$my_coll_thirdpartyid][
'ddate_start'][$id],
271 'ddate_end' =>$x_coll[$my_coll_thirdpartyid][
'ddate_end'][$id],
272 'totalht' =>$x_coll[$my_coll_thirdpartyid][
'totalht_list'][$id],
273 'vat' =>$x_coll[$my_coll_thirdpartyid][
'vat_list'][$id],
274 'link' =>$invoice_customer->getNomUrl(1,
'', 12)
279 foreach (array_keys($x_paye) as $my_paye_thirdpartyid) {
280 $x_both[$my_paye_thirdpartyid][
'paye'][
'totalht'] = $x_paye[$my_paye_thirdpartyid][
'totalht'];
281 $x_both[$my_paye_thirdpartyid][
'paye'][
'vat'] = $x_paye[$my_paye_thirdpartyid][
'vat'];
282 if (!isset($x_both[$my_paye_thirdpartyid][
'coll'][
'totalht'])) {
283 $x_both[$my_paye_thirdpartyid][
'coll'][
'totalht'] = 0;
284 $x_both[$my_paye_thirdpartyid][
'coll'][
'vat'] = 0;
286 $x_both[$my_paye_thirdpartyid][
'paye'][
'links'] =
'';
287 $x_both[$my_paye_thirdpartyid][
'paye'][
'detail'] = array();
289 foreach ($x_paye[$my_paye_thirdpartyid][
'facid'] as $id => $dummy) {
291 if ($x_paye[$my_paye_thirdpartyid][
'ptype'][$id] ==
'ExpenseReportPayment') {
292 $expensereport->id = $x_paye[$my_paye_thirdpartyid][
'facid'][$id];
293 $expensereport->ref = $x_paye[$my_paye_thirdpartyid][
'facnum'][$id];
294 $expensereport->type = $x_paye[$my_paye_thirdpartyid][
'type'][$id];
296 $x_both[$my_paye_thirdpartyid][
'paye'][
'detail'][] = array(
297 'id' =>$x_paye[$my_paye_thirdpartyid][
'facid'][$id],
298 'descr' =>$x_paye[$my_paye_thirdpartyid][
'descr'][$id],
300 'pid' =>$x_paye[$my_paye_thirdpartyid][
'pid'][$id],
301 'pref' =>$x_paye[$my_paye_thirdpartyid][
'pref'][$id],
302 'ptype' =>$x_paye[$my_paye_thirdpartyid][
'ptype'][$id],
303 'pstatus' =>$x_paye[$my_paye_thirdpartyid][
'pstatus'][$id],
304 'pstatusbuy' =>$x_paye[$my_paye_thirdpartyid][
'pstatusbuy'][$id],
306 'payment_id' =>$x_paye[$my_paye_thirdpartyid][
'payment_id'][$id],
307 'payment_ref' =>$x_paye[$my_paye_thirdpartyid][
'payment_ref'][$id],
308 'payment_amount' =>$x_paye[$my_paye_thirdpartyid][
'payment_amount'][$id],
309 'ftotal_ttc' =>
price2num($x_paye[$my_paye_thirdpartyid][
'ftotal_ttc'][$id]),
310 'dtotal_ttc' =>
price2num($x_paye[$my_paye_thirdpartyid][
'dtotal_ttc'][$id]),
311 'dtype' =>$x_paye[$my_paye_thirdpartyid][
'dtype'][$id],
312 'drate' =>$x_paye[$my_coll_thirdpartyid][
'drate'][$id],
313 'ddate_start' =>$x_paye[$my_paye_thirdpartyid][
'ddate_start'][$id],
314 'ddate_end' =>$x_paye[$my_paye_thirdpartyid][
'ddate_end'][$id],
315 'totalht' =>
price2num($x_paye[$my_paye_thirdpartyid][
'totalht_list'][$id]),
316 'vat' =>$x_paye[$my_paye_thirdpartyid][
'vat_list'][$id],
317 'link' =>$expensereport->getNomUrl(1)
320 $invoice_supplier->id = $x_paye[$my_paye_thirdpartyid][
'facid'][$id];
321 $invoice_supplier->ref = $x_paye[$my_paye_thirdpartyid][
'facnum'][$id];
322 $invoice_supplier->type = $x_paye[$my_paye_thirdpartyid][
'type'][$id];
325 $company_static->id = $x_paye[$my_paye_thirdpartyid][
'company_id'][$id];
326 $company_static->name = $x_paye[$my_paye_thirdpartyid][
'company_name'][$id];
327 $company_static->name_alias = $x_paye[$my_paye_thirdpartyid][
'company_alias'][$id];
328 $company_static->email = $x_paye[$my_paye_thirdpartyid][
'company_email'][$id];
329 $company_static->tva_intra = $x_paye[$my_paye_thirdpartyid][
'tva_intra'][$id];
330 $company_static->client = $x_paye[$my_paye_thirdpartyid][
'company_client'][$id];
331 $company_static->fournisseur = $x_paye[$my_paye_thirdpartyid][
'company_fournisseur'][$id];
332 $company_static->status = $x_paye[$my_paye_thirdpartyid][
'company_status'][$id];
333 $company_static->code_client = $x_paye[$my_paye_thirdpartyid][
'company_customer_code'][$id];
334 $company_static->code_compta_client = $x_paye[$my_paye_thirdpartyid][
'company_customer_accounting_code'][$id];
335 $company_static->code_fournisseur = $x_paye[$my_paye_thirdpartyid][
'company_supplier_code'][$id];
336 $company_static->code_compta_fournisseur = $x_paye[$my_paye_thirdpartyid][
'company_supplier_accounting_code'][$id];
338 $x_both[$my_paye_thirdpartyid][
'paye'][
'detail'][] = array(
339 'id' =>$x_paye[$my_paye_thirdpartyid][
'facid'][$id],
340 'descr' =>$x_paye[$my_paye_thirdpartyid][
'descr'][$id],
342 'pid' =>$x_paye[$my_paye_thirdpartyid][
'pid'][$id],
343 'pref' =>$x_paye[$my_paye_thirdpartyid][
'pref'][$id],
344 'ptype' =>$x_paye[$my_paye_thirdpartyid][
'ptype'][$id],
345 'pstatus' =>$x_paye[$my_paye_thirdpartyid][
'pstatus'][$id],
346 'pstatusbuy'=>$x_paye[$my_paye_thirdpartyid][
'pstatusbuy'][$id],
348 'payment_id'=>$x_paye[$my_paye_thirdpartyid][
'payment_id'][$id],
349 'payment_ref'=>$x_paye[$my_paye_thirdpartyid][
'payment_ref'][$id],
350 'payment_amount'=>$x_paye[$my_paye_thirdpartyid][
'payment_amount'][$id],
351 'ftotal_ttc'=>
price2num($x_paye[$my_paye_thirdpartyid][
'ftotal_ttc'][$id]),
352 'dtotal_ttc'=>
price2num($x_paye[$my_paye_thirdpartyid][
'dtotal_ttc'][$id]),
353 'dtype' =>$x_paye[$my_paye_thirdpartyid][
'dtype'][$id],
354 'drate' =>$x_paye[$my_coll_thirdpartyid][
'drate'][$id],
355 'datef' =>$x_paye[$my_paye_thirdpartyid][
'datef'][$id],
356 'datep' =>$x_paye[$my_paye_thirdpartyid][
'datep'][$id],
358 'company_link'=>$company_static->getNomUrl(1,
'', 20),
360 'ddate_start'=>$x_paye[$my_paye_thirdpartyid][
'ddate_start'][$id],
361 'ddate_end' =>$x_paye[$my_paye_thirdpartyid][
'ddate_end'][$id],
362 'totalht' =>
price2num($x_paye[$my_paye_thirdpartyid][
'totalht_list'][$id]),
363 'vat' =>$x_paye[$my_paye_thirdpartyid][
'vat_list'][$id],
364 'link' =>$invoice_supplier->getNomUrl(1,
'', 12)
382 print
'<tr class="liste_titre">';
383 print
'<td class="left">'.$elementcust.
'</td>';
384 print
'<td class="left">'.$langs->trans(
"DateInvoice").
'</td>';
385 if ($conf->global->TAX_MODE_SELL_PRODUCT ==
'payment' || $conf->global->TAX_MODE_SELL_SERVICE ==
'payment') {
386 print
'<td class="left">'.$langs->trans(
"DatePayment").
'</td>';
390 print
'<td class="right">'.$namerate.
'</td>';
391 print
'<td class="left">'.$productcust.
'</td>';
393 print
'<td class="right">'.$amountcust.
'</td>';
394 print
'<td class="right">'.$langs->trans(
"Payment").
' ('.$langs->trans(
"PercentOfInvoice").
')</td>';
396 print
'<td class="right">'.$langs->trans(
"AmountHTVATRealReceived").
'</td>';
397 print
'<td class="right">'.$vatcust.
'</td>';
400 $action =
"tvadetail";
401 $parameters[
"mode"] = $modetax;
402 $parameters[
"start"] = $date_start;
403 $parameters[
"end"] = $date_end;
404 $parameters[
"type"] =
'vat';
406 $object = array(&$x_coll, &$x_paye, &$x_both);
408 $hookmanager->initHooks(array(
'externalbalance'));
409 $reshook = $hookmanager->executeHooks(
'addVatLine', $parameters, $object, $action);
411 foreach (array_keys($x_coll) as $thirdparty_id) {
412 $subtot_coll_total_ht = 0;
413 $subtot_coll_vat = 0;
415 if ($min == 0 || ($min > 0 && $x_both[$thirdparty_id][
'coll'][
'totalht'] > $min)) {
416 if (is_array($x_both[$thirdparty_id][
'coll'][
'detail'])) {
419 print
'<td class="tax_rate">';
420 if (is_numeric($thirdparty_id)) {
421 $company_static->fetch($thirdparty_id);
422 print $langs->trans(
"ThirdParty").
': '.$company_static->getNomUrl(1);
424 $tmpid = preg_replace(
'/userid_/',
'', $thirdparty_id);
425 $user_static->fetch($tmpid);
426 print $langs->trans(
"User").
': '.$user_static->getNomUrl(1);
428 print
'</td><td colspan="'.($span + 1).
'"></td>';
431 foreach ($x_both[$thirdparty_id][
'coll'][
'detail'] as $index => $fields) {
434 $type = (isset($fields[
'dtype']) ? $fields[
'dtype'] : $fields[
'ptype']);
437 if (!empty($fields[
'ddate_start'])) {
440 if (!empty($fields[
'ddate_end'])) {
444 print
'<tr class="oddeven">';
447 print
'<td class="nowrap left">'.$fields[
'link'].
'</td>';
450 print
'<td class="left">'.dol_print_date($fields[
'datef'],
'day').
'</td>';
453 if ($conf->global->TAX_MODE_SELL_PRODUCT ==
'payment' || $conf->global->TAX_MODE_SELL_SERVICE ==
'payment') {
454 print
'<td class="left">'.dol_print_date($fields[
'datep'],
'day').
'</td>';
460 print
'<td class="right">'.$fields[
'drate'].
'</td>';
463 print
'<td class="left">';
464 if ($fields[
'pid']) {
465 $product_static->id = $fields[
'pid'];
466 $product_static->ref = $fields[
'pref'];
467 $product_static->type = $fields[
'dtype'];
468 $product_static->status = $fields[
'pstatus'];
469 $product_static->status_buy = $fields[
'pstatusbuy'];
471 print $product_static->getNomUrl(1);
477 $text =
img_object($langs->trans(
'Service'),
'service');
479 $text =
img_object($langs->trans(
'Product'),
'product');
481 if (preg_match(
'/^\((.*)\)$/', $fields[
'descr'], $reg)) {
482 if ($reg[1] ==
'DEPOSIT') {
483 $fields[
'descr'] = $langs->transnoentitiesnoconv(
'Deposit');
484 } elseif ($reg[1] ==
'CREDIT_NOTE') {
485 $fields[
'descr'] = $langs->transnoentitiesnoconv(
'CreditNote');
487 $fields[
'descr'] = $langs->transnoentitiesnoconv($reg[1]);
499 print
'<td class="nowrap right"><span class="amount">';
500 print
price($fields[
'totalht']);
503 $ratiolineinvoice = ($fields[
'dtotal_ttc'] / $fields[
'ftotal_ttc']);
506 print
'</span></td>';
510 $ratiopaymentinvoice = 1;
512 print
'<td class="nowrap right">';
514 if ($fields[
'payment_amount'] && $fields[
'ftotal_ttc']) {
515 $payment_static->id = $fields[
'payment_id'];
516 $payment_static->ref = $fields[
'payment_ref'];
517 print $payment_static->getNomUrl(2,
'',
'', 0).
' ';
519 if (($type == 0 && $conf->global->TAX_MODE_SELL_PRODUCT ==
'invoice')
520 || ($type == 1 && $conf->global->TAX_MODE_SELL_SERVICE ==
'invoice')) {
521 print $langs->trans(
"NA");
523 if (isset($fields[
'payment_amount']) &&
price2num($fields[
'ftotal_ttc'])) {
524 $ratiopaymentinvoice = ($fields[
'payment_amount'] / $fields[
'ftotal_ttc']);
526 print
'<span class="amount">'.price(
price2num($fields[
'payment_amount'],
'MT')).
'</span>';
527 if (isset($fields[
'payment_amount'])) {
528 print
' ('.round($ratiopaymentinvoice * 100, 2).
'%)';
535 print
'<td class="nowrap right"><span class="amount">';
536 $temp_ht = $fields[
'totalht'] * $ratiopaymentinvoice;
538 print
'</span></td>';
541 print
'<td class="nowrap right"><span class="amount">';
542 $temp_vat = $fields[
'vat'] * $ratiopaymentinvoice;
545 print
'</span></td>';
548 $subtot_coll_total_ht += $temp_ht;
549 $subtot_coll_vat += $temp_vat;
550 $x_coll_sum += $temp_vat;
555 print
'<tr class="liste_total">';
556 print
'<td colspan="4"></td>';
557 print
'<td class="right">'.$langs->trans(
"Total").
':</td>';
559 print
'<td class="nowrap right"> </td>';
560 print
'<td class="right"> </td>';
562 print
'<td class="right"><span class="amount">'.price(
price2num($subtot_coll_total_ht,
'MT')).
'</span></td>';
563 print
'<td class="nowrap right"><span class="amount">'.price(
price2num($subtot_coll_vat,
'MT')).
'</span></td>';
568 if (count($x_coll) == 0) {
569 print
'<tr class="liste_total">';
570 print
'<td colspan="4"></td>';
571 print
'<td class="right">'.$langs->trans(
"Total").
':</td>';
573 print
'<td class="nowrap right"> </td>';
574 print
'<td class="right"> </td>';
576 print
'<td class="right">'.price(
price2num(0,
'MT')).
'</td>';
577 print
'<td class="nowrap right">'.price(
price2num(0,
'MT')).
'</td>';
582 print
'<tr><td colspan="'.($span + 1).
'"> </td></tr>';
585 print
'<tr class="liste_titre liste_titre_topborder">';
586 print
'<td class="left">'.$elementsup.
'</td>';
587 print
'<td class="left">'.$langs->trans(
"DateInvoice").
'</td>';
588 if ($conf->global->TAX_MODE_BUY_PRODUCT ==
'payment' || $conf->global->TAX_MODE_BUY_SERVICE ==
'payment') {
589 print
'<td class="left">'.$langs->trans(
"DatePayment").
'</td>';
593 print
'<td class="left">'.$namesup.
'</td>';
594 print
'<td class="left">'.$productsup.
'</td>';
596 print
'<td class="right">'.$amountsup.
'</td>';
597 print
'<td class="right">'.$langs->trans(
"Payment").
' ('.$langs->trans(
"PercentOfInvoice").
')</td>';
599 print
'<td class="right">'.$langs->trans(
"AmountHTVATRealPaid").
'</td>';
600 print
'<td class="right">'.$vatsup.
'</td>';
603 foreach (array_keys($x_paye) as $thirdparty_id) {
604 $subtot_paye_total_ht = 0;
605 $subtot_paye_vat = 0;
607 if ($min == 0 || ($min > 0 && $x_both[$thirdparty_id][
'paye'][
'totalht'] > $min)) {
608 if (is_array($x_both[$thirdparty_id][
'paye'][
'detail'])) {
610 print
'<td class="tax_rate">';
611 if (is_numeric($thirdparty_id)) {
612 $company_static->fetch($thirdparty_id);
613 print $langs->trans(
"ThirdParty").
': '.$company_static->getNomUrl(1);
615 $tmpid = preg_replace(
'/userid_/',
'', $thirdparty_id);
616 $user_static->fetch($tmpid);
617 print $langs->trans(
"User").
': '.$user_static->getNomUrl(1);
619 print
'<td colspan="'.($span + 1).
'"></td>';
622 foreach ($x_both[$thirdparty_id][
'paye'][
'detail'] as $index => $fields) {
625 $type = (isset($fields[
'dtype']) ? $fields[
'dtype'] : $fields[
'ptype']);
628 if (!empty($fields[
'ddate_start'])) {
631 if (!empty($fields[
'ddate_end'])) {
636 print
'<tr class="oddeven">';
639 print
'<td class="nowrap left">'.$fields[
'link'].
'</td>';
642 print
'<td class="left">'.dol_print_date($fields[
'datef'],
'day').
'</td>';
645 if ($conf->global->TAX_MODE_BUY_PRODUCT ==
'payment' || $conf->global->TAX_MODE_BUY_SERVICE ==
'payment') {
646 print
'<td class="left">'.dol_print_date($fields[
'datep'],
'day').
'</td>';
652 print
'<td class="tdmaxoverflow150">';
653 print $fields[
'company_link'];
657 print
'<td class="left">';
658 if ($fields[
'pid']) {
659 $product_static->id = $fields[
'pid'];
660 $product_static->ref = $fields[
'pref'];
661 $product_static->type = $fields[
'dtype'];
662 print $product_static->getNomUrl(1);
668 $text =
img_object($langs->trans(
'Service'),
'service');
670 $text =
img_object($langs->trans(
'Product'),
'product');
672 if (preg_match(
'/^\((.*)\)$/', $fields[
'descr'], $reg)) {
673 if ($reg[1] ==
'DEPOSIT') {
674 $fields[
'descr'] = $langs->transnoentitiesnoconv(
'Deposit');
675 } elseif ($reg[1] ==
'CREDIT_NOTE') {
676 $fields[
'descr'] = $langs->transnoentitiesnoconv(
'CreditNote');
678 $fields[
'descr'] = $langs->transnoentitiesnoconv($reg[1]);
690 print
'<td class="nowrap right"><span class="amount">';
691 print
price($fields[
'totalht']);
694 $ratiolineinvoice = ($fields[
'dtotal_ttc'] / $fields[
'ftotal_ttc']);
697 print
'</span></td>';
701 $ratiopaymentinvoice = 1;
703 print
'<td class="nowrap right">';
704 if ($fields[
'payment_amount'] && $fields[
'ftotal_ttc']) {
705 $paymentfourn_static->id = $fields[
'payment_id'];
706 $paymentfourn_static->ref = $fields[
'payment_ref'];
707 print $paymentfourn_static->getNomUrl(2,
'',
'', 0);
710 if (($type == 0 && $conf->global->TAX_MODE_BUY_PRODUCT ==
'invoice')
711 || ($type == 1 && $conf->global->TAX_MODE_BUY_SERVICE ==
'invoice')) {
712 print $langs->trans(
"NA");
714 if (isset($fields[
'payment_amount']) && $fields[
'ftotal_ttc']) {
715 $ratiopaymentinvoice = ($fields[
'payment_amount'] / $fields[
'ftotal_ttc']);
717 print
'<span class="amount">'.price(
price2num($fields[
'payment_amount'],
'MT')).
'</span>';
718 if (isset($fields[
'payment_amount'])) {
719 print
' ('.round($ratiopaymentinvoice * 100, 2).
'%)';
726 print
'<td class="nowrap right"><span class="amount">';
727 $temp_ht = $fields[
'totalht'] * $ratiopaymentinvoice;
729 print
'</span></td>';
732 print
'<td class="nowrap right"><span class="amount">';
733 $temp_vat = $fields[
'vat'] * $ratiopaymentinvoice;
736 print
'</span></td>';
739 $subtot_paye_total_ht += $temp_ht;
740 $subtot_paye_vat += $temp_vat;
741 $x_paye_sum += $temp_vat;
745 print
'<tr class="liste_total">';
746 print
'<td colspan="4"></td>';
747 print
'<td class="right">'.$langs->trans(
"Total").
':</td>';
749 print
'<td class="nowrap right"> </td>';
750 print
'<td class="right"> </td>';
752 print
'<td class="right"><span class="amount">'.price(
price2num($subtot_paye_total_ht,
'MT')).
'</span></td>';
753 print
'<td class="nowrap right"><span class="amount">'.price(
price2num($subtot_paye_vat,
'MT')).
'</span></td>';
758 if (count($x_paye) == 0) {
759 print
'<tr class="liste_total">';
760 print
'<td colspan="4"></td>';
761 print
'<td class="right">'.$langs->trans(
"Total").
':</td>';
763 print
'<td class="nowrap right"> </td>';
764 print
'<td class="right"> </td>';
766 print
'<td class="right">'.price(
price2num(0,
'MT')).
'</td>';
767 print
'<td class="nowrap right">'.price(
price2num(0,
'MT')).
'</td>';
772 print
'<tr><td colspan="'.($span + 2).
'"></td></tr>';
774 $diff = $x_coll_sum - $x_paye_sum;
775 print
'<tr class="liste_total">';
776 print
'<td class="liste_total" colspan="'.($span + 1).
'">'.$langs->trans(
"TotalToPay").($q ?
', '.$langs->trans(
"Quadri").
' '.$q :
'').
'</td>';
777 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.
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)
Class to manage products or services.
dol_now($mode= 'auto')
Return date for now.
Class to manage Dolibarr users.
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.
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...
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 '...
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.
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.