Work on vat reports
This commit is contained in:
parent
26e2d3c4f0
commit
b44e791c0a
@ -37,6 +37,7 @@ $langs->load("compta");
|
|||||||
$langs->load("companies");
|
$langs->load("companies");
|
||||||
$langs->load("products");
|
$langs->load("products");
|
||||||
$langs->load("other");
|
$langs->load("other");
|
||||||
|
$langs->load("admin");
|
||||||
|
|
||||||
// Date range
|
// Date range
|
||||||
$year=GETPOST("year");
|
$year=GETPOST("year");
|
||||||
@ -132,24 +133,28 @@ $fsearch.=' <input type="hidden" name="modetax" value="'.$modetax.'">';
|
|||||||
$fsearch.=' '.$langs->trans("SalesTurnoverMinimum").': ';
|
$fsearch.=' '.$langs->trans("SalesTurnoverMinimum").': ';
|
||||||
$fsearch.=' <input type="text" name="min" id="min" value="'.$min.'" size="6">';
|
$fsearch.=' <input type="text" name="min" id="min" value="'.$min.'" size="6">';
|
||||||
|
|
||||||
|
$description='';
|
||||||
|
|
||||||
|
$calcmode='';
|
||||||
|
if ($modetax == 0) $calcmode=$langs->trans('OptionVATDefault');
|
||||||
|
if ($modetax == 1) $calcmode=$langs->trans('OptionVATDebitOption');
|
||||||
|
if ($modetax == 2) $calcmode=$langs->trans('OptionPaymentForProductAndServices');
|
||||||
|
$calcmode.='<br>('.$langs->trans("TaxModuleSetupToModifyRules",DOL_URL_ROOT.'/admin/taxes.php').')';
|
||||||
|
|
||||||
|
if ($conf->global->TAX_MODE_SELL_PRODUCT == 'invoice') $description.=$langs->trans("RulesVATDueProducts");
|
||||||
|
if ($conf->global->TAX_MODE_SELL_PRODUCT == 'payment') $description.=$langs->trans("RulesVATInProducts");
|
||||||
|
if ($conf->global->TAX_MODE_SELL_SERVICE == 'invoice') $description.='<br>'.$langs->trans("RulesVATDueServices");
|
||||||
|
if ($conf->global->TAX_MODE_SELL_SERVICE == 'payment') $description.='<br>'.$langs->trans("RulesVATInServices");
|
||||||
|
if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
|
||||||
|
$description.='<br>'.$langs->trans("DepositsAreNotIncluded");
|
||||||
|
}
|
||||||
|
if (! empty($conf->global->MAIN_MODULE_ACCOUNTING)) $description.='<br>'.$langs->trans("ThisIsAnEstimatedValue");
|
||||||
|
|
||||||
// Affiche en-tete du rapport
|
// Affiche en-tete du rapport
|
||||||
if ($modetax==1) { // Calculate on invoice for goods and services
|
if ($modetax==1) { // Calculate on invoice for goods and services
|
||||||
$name=$langs->trans("VATReportByCustomersInDueDebtMode");
|
$name=$langs->trans("VATReportByCustomersInDueDebtMode");
|
||||||
$calcmode=$langs->trans("CalcModeVATDebt");
|
|
||||||
$calcmode.='<br>('.$langs->trans("TaxModuleSetupToModifyRules",DOL_URL_ROOT.'/admin/taxes.php').')';
|
|
||||||
//$name.='<br>('.$langs->trans("SeeVATReportInInputOutputMode",'<a href="'.$_SERVER["PHP_SELF"].'?year='.$year_start.'&modetax=0">','</a>').')';
|
|
||||||
$period=$form->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$form->select_date($date_end,'date_end',0,0,0,'',1,0,1);
|
$period=$form->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$form->select_date($date_end,'date_end',0,0,0,'',1,0,1);
|
||||||
//$periodlink=($year_start?"<a href='".$_SERVER["PHP_SELF"]."?year=".($year_start-1)."&modetax=".$modetax."'>".img_previous()."</a> <a href='".$_SERVER["PHP_SELF"]."?year=".($year_start+1)."&modetax=".$modetax."'>".img_next()."</a>":"");
|
//$periodlink=($year_start?"<a href='".$_SERVER["PHP_SELF"]."?year=".($year_start-1)."&modetax=".$modetax."'>".img_previous()."</a> <a href='".$_SERVER["PHP_SELF"]."?year=".($year_start+1)."&modetax=".$modetax."'>".img_next()."</a>":"");
|
||||||
$description=$langs->trans("RulesVATDueServices");
|
|
||||||
$description.='<br>';
|
|
||||||
$description.=$langs->trans("RulesVATDueProducts");
|
|
||||||
//if ($conf->global->MAIN_MODULE_COMPTABILITE || $conf->global->MAIN_MODULE_ACCOUNTING) $description.='<br>'.img_warning().' '.$langs->trans('OptionVatInfoModuleComptabilite');
|
|
||||||
//if (! empty($conf->global->MAIN_MODULE_COMPTABILITE)) $description.='<br>'.$langs->trans("WarningDepositsNotIncluded");
|
|
||||||
if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
|
|
||||||
$description.='<br>'.$langs->trans("DepositsAreNotIncluded");
|
|
||||||
} else {
|
|
||||||
$description.='<br>'.$langs->trans("DepositsAreIncluded");
|
|
||||||
}
|
|
||||||
$description.=$fsearch;
|
$description.=$fsearch;
|
||||||
$description.='<br>'
|
$description.='<br>'
|
||||||
. '<input type="radio" name="extra_report" value="0" '.($special_report?'':'checked="checked"').'> '
|
. '<input type="radio" name="extra_report" value="0" '.($special_report?'':'checked="checked"').'> '
|
||||||
@ -178,20 +183,8 @@ if ($modetax==1) { // Calculate on invoice for goods and services
|
|||||||
}
|
}
|
||||||
if ($modetax==0) { // Invoice for goods, payment for services
|
if ($modetax==0) { // Invoice for goods, payment for services
|
||||||
$name=$langs->trans("VATReportByCustomersInInputOutputMode");
|
$name=$langs->trans("VATReportByCustomersInInputOutputMode");
|
||||||
$calcmode=$langs->trans("CalcModeVATEngagement");
|
|
||||||
$calcmode.='<br>('.$langs->trans("TaxModuleSetupToModifyRules",DOL_URL_ROOT.'/admin/taxes.php').')';
|
|
||||||
//$name.='<br>('.$langs->trans("SeeVATReportInDueDebtMode",'<a href="'.$_SERVER["PHP_SELF"].'?year='.$year_start.'&modetax=1">','</a>').')';
|
|
||||||
$period=$form->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$form->select_date($date_end,'date_end',0,0,0,'',1,0,1);
|
$period=$form->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$form->select_date($date_end,'date_end',0,0,0,'',1,0,1);
|
||||||
//$periodlink=($year_start?"<a href='".$_SERVER["PHP_SELF"]."?year=".($year_start-1)."&modetax=".$modetax."'>".img_previous()."</a> <a href='".$_SERVER["PHP_SELF"]."?year=".($year_start+1)."&modetax=".$modetax."'>".img_next()."</a>":"");
|
//$periodlink=($year_start?"<a href='".$_SERVER["PHP_SELF"]."?year=".($year_start-1)."&modetax=".$modetax."'>".img_previous()."</a> <a href='".$_SERVER["PHP_SELF"]."?year=".($year_start+1)."&modetax=".$modetax."'>".img_next()."</a>":"");
|
||||||
$description=$langs->trans("RulesVATInServices");
|
|
||||||
$description.=' '.$langs->trans("DepositsAreIncluded");
|
|
||||||
$description.='<br>';
|
|
||||||
$description.=$langs->trans("RulesVATInProducts");
|
|
||||||
if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
|
|
||||||
$description .= ' ' . $langs->trans("DepositsAreNotIncluded");
|
|
||||||
} else {
|
|
||||||
$description .= ' ' . $langs->trans("DepositsAreIncluded");
|
|
||||||
}
|
|
||||||
//if ($conf->global->MAIN_MODULE_COMPTABILITE || $conf->global->MAIN_MODULE_ACCOUNTING) $description.='<br>'.img_warning().' '.$langs->trans('OptionVatInfoModuleComptabilite');
|
//if ($conf->global->MAIN_MODULE_COMPTABILITE || $conf->global->MAIN_MODULE_ACCOUNTING) $description.='<br>'.img_warning().' '.$langs->trans('OptionVatInfoModuleComptabilite');
|
||||||
//if (! empty($conf->global->MAIN_MODULE_COMPTABILITE)) $description.='<br>'.$langs->trans("WarningDepositsNotIncluded");
|
//if (! empty($conf->global->MAIN_MODULE_COMPTABILITE)) $description.='<br>'.$langs->trans("WarningDepositsNotIncluded");
|
||||||
$description.=$fsearch;
|
$description.=$fsearch;
|
||||||
|
|||||||
@ -30,7 +30,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/tax.lib.php';
|
|||||||
require_once DOL_DOCUMENT_ROOT.'/compta/tva/class/tva.class.php';
|
require_once DOL_DOCUMENT_ROOT.'/compta/tva/class/tva.class.php';
|
||||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
|
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
|
||||||
|
|
||||||
$langs->loadLangs(array("other","compta","banks","bills","companies"));
|
$langs->loadLangs(array("other","compta","banks","bills","companies","admin"));
|
||||||
|
|
||||||
$year=GETPOST("year","int");
|
$year=GETPOST("year","int");
|
||||||
if ($year == 0)
|
if ($year == 0)
|
||||||
@ -107,9 +107,23 @@ function pt ($db, $sql, $date)
|
|||||||
$tva = new Tva($db);
|
$tva = new Tva($db);
|
||||||
|
|
||||||
$name = $langs->trans("ReportByMonth");
|
$name = $langs->trans("ReportByMonth");
|
||||||
$description = $langs->trans("VATSummary");
|
|
||||||
$calcmode = $langs->trans("VATReportBuildWithOptionDefinedInModule").' ';
|
$calcmode='';
|
||||||
$calcmode.= '('.$langs->trans("TaxModuleSetupToModifyRules",DOL_URL_ROOT.'/admin/taxes.php').')';
|
if ($modetax == 0) $calcmode=$langs->trans('OptionVATDefault');
|
||||||
|
if ($modetax == 1) $calcmode=$langs->trans('OptionVATDebitOption');
|
||||||
|
if ($modetax == 2) $calcmode=$langs->trans('OptionPaymentForProductAndServices');
|
||||||
|
$calcmode.='<br>('.$langs->trans("TaxModuleSetupToModifyRules",DOL_URL_ROOT.'/admin/taxes.php').')';
|
||||||
|
|
||||||
|
$description = $langs->trans("VATSummary").'<br>';
|
||||||
|
if ($conf->global->TAX_MODE_SELL_PRODUCT == 'invoice') $description.=$langs->trans("RulesVATDueProducts");
|
||||||
|
if ($conf->global->TAX_MODE_SELL_PRODUCT == 'payment') $description.=$langs->trans("RulesVATInProducts");
|
||||||
|
if ($conf->global->TAX_MODE_SELL_SERVICE == 'invoice') $description.='<br>'.$langs->trans("RulesVATDueServices");
|
||||||
|
if ($conf->global->TAX_MODE_SELL_SERVICE == 'payment') $description.='<br>'.$langs->trans("RulesVATInServices");
|
||||||
|
if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
|
||||||
|
$description.='<br>'.$langs->trans("DepositsAreNotIncluded");
|
||||||
|
}
|
||||||
|
if (! empty($conf->global->MAIN_MODULE_ACCOUNTING)) $description.='<br>'.$langs->trans("ThisIsAnEstimatedValue");
|
||||||
|
|
||||||
$builddate=dol_now();
|
$builddate=dol_now();
|
||||||
|
|
||||||
llxHeader('', $name);
|
llxHeader('', $name);
|
||||||
|
|||||||
@ -2,9 +2,8 @@
|
|||||||
/* Copyright (C) 2001-2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
/* Copyright (C) 2001-2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||||
* Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com>
|
* Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com>
|
||||||
* Copyright (C) 2004-2013 Laurent Destailleur <eldy@users.sourceforge.net>
|
* Copyright (C) 2004-2013 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||||
* Copyright (C) 2006-2007 Yannick Warnier <ywarnier@beeznest.org>
|
* Copyright (C) 2006-2007, 2015 Yannick Warnier <ywarnier@beeznest.org>
|
||||||
* Copyright (C) 2014 Ferran Marcet <fmarcet@2byte.es>
|
* Copyright (C) 2014 Ferran Marcet <fmarcet@2byte.es>
|
||||||
* Copyright (C) 2016 Alexandre Spangaro <aspangaro@zendsi.com>
|
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -24,7 +23,6 @@
|
|||||||
* \file htdocs/compta/tva/quadri_detail.php
|
* \file htdocs/compta/tva/quadri_detail.php
|
||||||
* \ingroup tax
|
* \ingroup tax
|
||||||
* \brief Trimestrial page - detailed version
|
* \brief Trimestrial page - detailed version
|
||||||
* TODO Deal with recurrent invoices as well
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
require '../../main.inc.php';
|
require '../../main.inc.php';
|
||||||
@ -46,6 +44,7 @@ $langs->load("companies");
|
|||||||
$langs->load("products");
|
$langs->load("products");
|
||||||
$langs->load("trips");
|
$langs->load("trips");
|
||||||
$langs->load("other");
|
$langs->load("other");
|
||||||
|
$langs->load("admin");
|
||||||
|
|
||||||
// Date range
|
// Date range
|
||||||
$year=GETPOST("year","int");
|
$year=GETPOST("year","int");
|
||||||
@ -103,7 +102,7 @@ $result = restrictedArea($user, 'tax', '', '', 'charges');
|
|||||||
|
|
||||||
$morequerystring='';
|
$morequerystring='';
|
||||||
$listofparams=array('date_startmonth','date_startyear','date_startday','date_endmonth','date_endyear','date_endday');
|
$listofparams=array('date_startmonth','date_startyear','date_startday','date_endmonth','date_endyear','date_endday');
|
||||||
foreach($listofparams as $param)
|
foreach ($listofparams as $param)
|
||||||
{
|
{
|
||||||
if (GETPOST($param)!='') $morequerystring.=($morequerystring?'&':'').$param.'='.GETPOST($param);
|
if (GETPOST($param)!='') $morequerystring.=($morequerystring?'&':'').$param.'='.GETPOST($param);
|
||||||
}
|
}
|
||||||
@ -130,86 +129,60 @@ $fsearch.=' <input type="hidden" name="modetax" value="'.$modetax.'">';
|
|||||||
//$fsearch.=' <input type="text" name="min" value="'.$min.'">';
|
//$fsearch.=' <input type="text" name="min" value="'.$min.'">';
|
||||||
|
|
||||||
|
|
||||||
// Affiche en-tete du rapport
|
// Show report header
|
||||||
if ($modetax==1) // Calculate on invoice for goods and services
|
$name=$langs->trans("VATReportByPeriods");
|
||||||
{
|
$calcmode='';
|
||||||
$name=$langs->trans("VATReportByQuartersInDueDebtMode");
|
if ($modetax == 0) $calcmode=$langs->trans('OptionVATDefault');
|
||||||
$calcmode=$langs->trans("CalcModeVATDebt");
|
if ($modetax == 1) $calcmode=$langs->trans('OptionVATDebitOption');
|
||||||
$calcmode.='<br>('.$langs->trans("TaxModuleSetupToModifyRules",DOL_URL_ROOT.'/admin/taxes.php').')';
|
if ($modetax == 2) $calcmode=$langs->trans('OptionPaymentForProductAndServices');
|
||||||
$period=$form->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$form->select_date($date_end,'date_end',0,0,0,'',1,0,1);
|
$calcmode.='<br>('.$langs->trans("TaxModuleSetupToModifyRules",DOL_URL_ROOT.'/admin/taxes.php').')';
|
||||||
$prevyear=$year_start; $prevquarter=$q;
|
// Set period
|
||||||
if ($prevquarter > 1) $prevquarter--;
|
$period=$form->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$form->select_date($date_end,'date_end',0,0,0,'',1,0,1);
|
||||||
else { $prevquarter=4; $prevyear--; }
|
$prevyear=$year_start; $prevquarter=$q;
|
||||||
$nextyear=$year_start; $nextquarter=$q;
|
if ($prevquarter > 1) {
|
||||||
if ($nextquarter < 4) $nextquarter++;
|
$prevquarter--;
|
||||||
else { $nextquarter=1; $nextyear++; }
|
} else {
|
||||||
//$periodlink=($prevyear?"<a href='".$_SERVER["PHP_SELF"]."?year=".$prevyear."&q=".$prevquarter."&modetax=".$modetax."'>".img_previous()."</a> <a href='".$_SERVER["PHP_SELF"]."?year=".$nextyear."&q=".$nextquarter."&modetax=".$modetax."'>".img_next()."</a>":"");
|
$prevquarter=4; $prevyear--;
|
||||||
$description=$langs->trans("RulesVATDueServices");
|
|
||||||
$description.='<br>';
|
|
||||||
$description.=$langs->trans("RulesVATDueProducts");
|
|
||||||
//if ($conf->global->MAIN_MODULE_COMPTABILITE || $conf->global->MAIN_MODULE_ACCOUNTING) $description.='<br>'.img_warning().' '.$langs->trans('OptionVatInfoModuleComptabilite');
|
|
||||||
//if (! empty($conf->global->MAIN_MODULE_COMPTABILITE)) $description.='<br>'.$langs->trans("WarningDepositsNotIncluded");
|
|
||||||
if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $description.='<br>'.$langs->trans("DepositsAreNotIncluded");
|
|
||||||
else $description.='<br>'.$langs->trans("DepositsAreIncluded");
|
|
||||||
$description.=$fsearch;
|
|
||||||
$builddate=dol_now();
|
|
||||||
//$exportlink=$langs->trans("NotYetAvailable");
|
|
||||||
|
|
||||||
// Customers invoices
|
|
||||||
$elementcust=$langs->trans("CustomersInvoices");
|
|
||||||
$productcust=$langs->trans("ProductOrService");
|
|
||||||
$amountcust=$langs->trans("AmountHT");
|
|
||||||
$vatcust=$langs->trans("VATReceived");
|
|
||||||
if ($mysoc->tva_assuj) $vatcust.=' ('.$langs->trans("ToPay").')';
|
|
||||||
|
|
||||||
// Suppliers invoices
|
|
||||||
$elementsup=$langs->trans("SuppliersInvoices");
|
|
||||||
$productsup=$langs->trans("ProductOrService");
|
|
||||||
$amountsup=$langs->trans("AmountHT");
|
|
||||||
$vatsup=$langs->trans("VATPaid");
|
|
||||||
if ($mysoc->tva_assuj) $vatsup.=' ('.$langs->trans("ToGetBack").')';
|
|
||||||
|
|
||||||
}
|
}
|
||||||
if ($modetax==0) // Invoice for goods, payment for services
|
$nextyear=$year_start; $nextquarter=$q;
|
||||||
{
|
if ($nextquarter < 4) {
|
||||||
$name=$langs->trans("VATReportByQuartersInInputOutputMode");
|
$nextquarter++;
|
||||||
$calcmode=$langs->trans("CalcModeVATEngagement");
|
} else {
|
||||||
$calcmode.='<br>('.$langs->trans("TaxModuleSetupToModifyRules",DOL_URL_ROOT.'/admin/taxes.php').')';
|
$nextquarter=1; $nextyear++;
|
||||||
$period=$form->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$form->select_date($date_end,'date_end',0,0,0,'',1,0,1);
|
|
||||||
$prevyear=$year_start; $prevquarter=$q;
|
|
||||||
if ($prevquarter > 1) $prevquarter--;
|
|
||||||
else { $prevquarter=4; $prevyear--; }
|
|
||||||
$nextyear=$year_start; $nextquarter=$q;
|
|
||||||
if ($nextquarter < 4) $nextquarter++;
|
|
||||||
else { $nextquarter=1; $nextyear++; }
|
|
||||||
//$periodlink=($prevyear?"<a href='".$_SERVER["PHP_SELF"]."?year=".$prevyear."&q=".$prevquarter."&modetax=".$modetax."'>".img_previous()."</a> <a href='".$_SERVER["PHP_SELF"]."?year=".$nextyear."&q=".$nextquarter."&modetax=".$modetax."'>".img_next()."</a>":"");
|
|
||||||
$description=$langs->trans("RulesVATInServices");
|
|
||||||
$description.=' '.$langs->trans("DepositsAreIncluded");
|
|
||||||
$description.='<br>';
|
|
||||||
$description.=$langs->trans("RulesVATInProducts");
|
|
||||||
if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $description.=' '.$langs->trans("DepositsAreNotIncluded");
|
|
||||||
else $description.=' '.$langs->trans("DepositsAreIncluded");
|
|
||||||
//if ($conf->global->MAIN_MODULE_COMPTABILITE || $conf->global->MAIN_MODULE_ACCOUNTING) $description.='<br>'.img_warning().' '.$langs->trans('OptionVatInfoModuleComptabilite');
|
|
||||||
//if (! empty($conf->global->MAIN_MODULE_COMPTABILITE)) $description.='<br>'.$langs->trans("WarningDepositsNotIncluded");
|
|
||||||
$description.=$fsearch;
|
|
||||||
$builddate=dol_now();
|
|
||||||
//$exportlink=$langs->trans("NotYetAvailable");
|
|
||||||
|
|
||||||
// Customers invoices
|
|
||||||
$elementcust=$langs->trans("CustomersInvoices");
|
|
||||||
$productcust=$langs->trans("ProductOrService");
|
|
||||||
$amountcust=$langs->trans("AmountHT");
|
|
||||||
$vatcust=$langs->trans("VATReceived");
|
|
||||||
if ($mysoc->tva_assuj) $vatcust.=' ('.$langs->trans("ToPay").')';
|
|
||||||
|
|
||||||
// Suppliers invoices
|
|
||||||
$elementsup=$langs->trans("SuppliersInvoices");
|
|
||||||
$productsup=$langs->trans("ProductOrService");
|
|
||||||
$amountsup=$langs->trans("AmountHT");
|
|
||||||
$vatsup=$langs->trans("VATPaid");
|
|
||||||
if ($mysoc->tva_assuj) $vatsup.=' ('.$langs->trans("ToGetBack").')';
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
$description.=$fsearch;
|
||||||
|
$builddate=dol_now();
|
||||||
|
|
||||||
|
if ($conf->global->TAX_MODE_SELL_PRODUCT == 'invoice') $description.=$langs->trans("RulesVATDueProducts");
|
||||||
|
if ($conf->global->TAX_MODE_SELL_PRODUCT == 'payment') $description.=$langs->trans("RulesVATInProducts");
|
||||||
|
if ($conf->global->TAX_MODE_SELL_SERVICE == 'invoice') $description.='<br>'.$langs->trans("RulesVATDueServices");
|
||||||
|
if ($conf->global->TAX_MODE_SELL_SERVICE == 'payment') $description.='<br>'.$langs->trans("RulesVATInServices");
|
||||||
|
if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
|
||||||
|
$description.='<br>'.$langs->trans("DepositsAreNotIncluded");
|
||||||
|
}
|
||||||
|
if (! empty($conf->global->MAIN_MODULE_ACCOUNTING)) $description.='<br>'.$langs->trans("ThisIsAnEstimatedValue");
|
||||||
|
|
||||||
|
// Customers invoices
|
||||||
|
$elementcust=$langs->trans("CustomersInvoices");
|
||||||
|
$productcust=$langs->trans("ProductOrService");
|
||||||
|
$amountcust=$langs->trans("AmountHT");
|
||||||
|
$vatcust=$langs->trans("VATReceived");
|
||||||
|
$namecust=$langs->trans("Name");
|
||||||
|
if ($mysoc->tva_assuj) {
|
||||||
|
$vatcust.=' ('.$langs->trans("ToPay").')';
|
||||||
|
}
|
||||||
|
|
||||||
|
// Suppliers invoices
|
||||||
|
$elementsup=$langs->trans("SuppliersInvoices");
|
||||||
|
$productsup=$productcust;
|
||||||
|
$amountsup=$amountcust;
|
||||||
|
$vatsup=$langs->trans("VATPaid");
|
||||||
|
$namesup=$namecust;
|
||||||
|
if ($mysoc->tva_assuj) {
|
||||||
|
$vatsup.=' ('.$langs->trans("ToGetBack").')';
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
report_header($name,'',$period,$periodlink,$description,$builddate,$exportlink,array(),$calcmode);
|
report_header($name,'',$period,$periodlink,$description,$builddate,$exportlink,array(),$calcmode);
|
||||||
|
|
||||||
$vatcust=$langs->trans("VATReceived");
|
$vatcust=$langs->trans("VATReceived");
|
||||||
@ -222,6 +195,7 @@ print '<table class="noborder" width="100%">';
|
|||||||
$y = $year_current;
|
$y = $year_current;
|
||||||
$total = 0;
|
$total = 0;
|
||||||
$i=0;
|
$i=0;
|
||||||
|
$columns = 5;
|
||||||
|
|
||||||
// Load arrays of datas
|
// Load arrays of datas
|
||||||
$x_coll = vat_by_date($db, 0, 0, $date_start, $date_end, $modetax, 'sell');
|
$x_coll = vat_by_date($db, 0, 0, $date_start, $date_end, $modetax, 'sell');
|
||||||
@ -230,15 +204,14 @@ $x_paye = vat_by_date($db, 0, 0, $date_start, $date_end, $modetax, 'buy');
|
|||||||
if (! is_array($x_coll) || ! is_array($x_paye))
|
if (! is_array($x_coll) || ! is_array($x_paye))
|
||||||
{
|
{
|
||||||
$langs->load("errors");
|
$langs->load("errors");
|
||||||
if ($x_coll == -1)
|
if ($x_coll == -1) {
|
||||||
print '<tr><td colspan="5">'.$langs->trans("ErrorNoAccountancyModuleLoaded").'</td></tr>';
|
print '<tr><td colspan="' . $columns . '">' . $langs->trans("ErrorNoAccountancyModuleLoaded") . '</td></tr>';
|
||||||
else if ($x_coll == -2)
|
} else if ($x_coll == -2) {
|
||||||
print '<tr><td colspan="5">'.$langs->trans("FeatureNotYetAvailable").'</td></tr>';
|
print '<tr><td colspan="' . $columns . '">' . $langs->trans("FeatureNotYetAvailable") . '</td></tr>';
|
||||||
else
|
} else {
|
||||||
print '<tr><td colspan="5">'.$langs->trans("Error").'</td></tr>';
|
print '<tr><td colspan="' . $columns . '">' . $langs->trans("Error") . '</td></tr>';
|
||||||
}
|
}
|
||||||
else
|
} else {
|
||||||
{
|
|
||||||
$x_both = array();
|
$x_both = array();
|
||||||
//now, from these two arrays, get another array with one rate per line
|
//now, from these two arrays, get another array with one rate per line
|
||||||
foreach(array_keys($x_coll) as $my_coll_rate)
|
foreach(array_keys($x_coll) as $my_coll_rate)
|
||||||
@ -249,41 +222,45 @@ else
|
|||||||
$x_both[$my_coll_rate]['paye']['vat'] = 0;
|
$x_both[$my_coll_rate]['paye']['vat'] = 0;
|
||||||
$x_both[$my_coll_rate]['coll']['links'] = '';
|
$x_both[$my_coll_rate]['coll']['links'] = '';
|
||||||
$x_both[$my_coll_rate]['coll']['detail'] = array();
|
$x_both[$my_coll_rate]['coll']['detail'] = array();
|
||||||
foreach($x_coll[$my_coll_rate]['facid'] as $id=>$dummy)
|
foreach($x_coll[$my_coll_rate]['facid'] as $id=>$dummy) {
|
||||||
{
|
|
||||||
$invoice_customer->id=$x_coll[$my_coll_rate]['facid'][$id];
|
$invoice_customer->id=$x_coll[$my_coll_rate]['facid'][$id];
|
||||||
$invoice_customer->ref=$x_coll[$my_coll_rate]['facnum'][$id];
|
$invoice_customer->ref=$x_coll[$my_coll_rate]['facnum'][$id];
|
||||||
$invoice_customer->type=$x_coll[$my_coll_rate]['type'][$id];
|
$invoice_customer->type=$x_coll[$my_coll_rate]['type'][$id];
|
||||||
|
$company_static->fetch($x_coll[$my_coll_rate]['company_id'][$id]);
|
||||||
$x_both[$my_coll_rate]['coll']['detail'][] = array(
|
$x_both[$my_coll_rate]['coll']['detail'][] = array(
|
||||||
'id' =>$x_coll[$my_coll_rate]['facid'][$id],
|
'id' =>$x_coll[$my_coll_rate]['facid'][$id],
|
||||||
'descr' =>$x_coll[$my_coll_rate]['descr'][$id],
|
'descr' =>$x_coll[$my_coll_rate]['descr'][$id],
|
||||||
'pid' =>$x_coll[$my_coll_rate]['pid'][$id],
|
'pid' =>$x_coll[$my_coll_rate]['pid'][$id],
|
||||||
'pref' =>$x_coll[$my_coll_rate]['pref'][$id],
|
'pref' =>$x_coll[$my_coll_rate]['pref'][$id],
|
||||||
'ptype' =>$x_coll[$my_coll_rate]['ptype'][$id],
|
'ptype' =>$x_coll[$my_coll_rate]['ptype'][$id],
|
||||||
'payment_id' =>$x_coll[$my_coll_rate]['payment_id'][$id],
|
'payment_id'=>$x_coll[$my_coll_rate]['payment_id'][$id],
|
||||||
'payment_amount' =>$x_coll[$my_coll_rate]['payment_amount'][$id],
|
'payment_amount'=>$x_coll[$my_coll_rate]['payment_amount'][$id],
|
||||||
'ftotal_ttc' =>$x_coll[$my_coll_rate]['ftotal_ttc'][$id],
|
'ftotal_ttc'=>$x_coll[$my_coll_rate]['ftotal_ttc'][$id],
|
||||||
'dtotal_ttc' =>$x_coll[$my_coll_rate]['dtotal_ttc'][$id],
|
'dtotal_ttc'=>$x_coll[$my_coll_rate]['dtotal_ttc'][$id],
|
||||||
'dtype' =>$x_coll[$my_coll_rate]['dtype'][$id],
|
'dtype' =>$x_coll[$my_coll_rate]['dtype'][$id],
|
||||||
'ddate_start' =>$x_coll[$my_coll_rate]['ddate_start'][$id],
|
'datef' =>$x_coll[$my_coll_rate]['datef'][$id],
|
||||||
|
'datep' =>$x_coll[$my_coll_rate]['datep'][$id],
|
||||||
|
'company_link'=>$company_static->getNomUrl(1,'',20),
|
||||||
|
'ddate_start'=>$x_coll[$my_coll_rate]['ddate_start'][$id],
|
||||||
'ddate_end' =>$x_coll[$my_coll_rate]['ddate_end'][$id],
|
'ddate_end' =>$x_coll[$my_coll_rate]['ddate_end'][$id],
|
||||||
'totalht' =>$x_coll[$my_coll_rate]['totalht_list'][$id],
|
'totalht' =>$x_coll[$my_coll_rate]['totalht_list'][$id],
|
||||||
'vat' =>$x_coll[$my_coll_rate]['vat_list'][$id],
|
'vat' =>$x_coll[$my_coll_rate]['vat_list'][$id],
|
||||||
'link' =>$invoice_customer->getNomUrl(1,'',12));
|
'link' =>$invoice_customer->getNomUrl(1,'',12)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// tva paid
|
// tva paid
|
||||||
foreach(array_keys($x_paye) as $my_paye_rate){
|
foreach (array_keys($x_paye) as $my_paye_rate) {
|
||||||
$x_both[$my_paye_rate]['paye']['totalht'] = $x_paye[$my_paye_rate]['totalht'];
|
$x_both[$my_paye_rate]['paye']['totalht'] = $x_paye[$my_paye_rate]['totalht'];
|
||||||
$x_both[$my_paye_rate]['paye']['vat'] = $x_paye[$my_paye_rate]['vat'];
|
$x_both[$my_paye_rate]['paye']['vat'] = $x_paye[$my_paye_rate]['vat'];
|
||||||
if(!isset($x_both[$my_paye_rate]['coll']['totalht'])){
|
if (!isset($x_both[$my_paye_rate]['coll']['totalht'])) {
|
||||||
$x_both[$my_paye_rate]['coll']['totalht'] = 0;
|
$x_both[$my_paye_rate]['coll']['totalht'] = 0;
|
||||||
$x_both[$my_paye_rate]['coll']['vat'] = 0;
|
$x_both[$my_paye_rate]['coll']['vat'] = 0;
|
||||||
}
|
}
|
||||||
$x_both[$my_paye_rate]['paye']['links'] = '';
|
$x_both[$my_paye_rate]['paye']['links'] = '';
|
||||||
$x_both[$my_paye_rate]['paye']['detail'] = array();
|
$x_both[$my_paye_rate]['paye']['detail'] = array();
|
||||||
|
|
||||||
foreach($x_paye[$my_paye_rate]['facid'] as $id=>$dummy)
|
foreach ($x_paye[$my_paye_rate]['facid'] as $id=>$dummy)
|
||||||
{
|
{
|
||||||
// ExpenseReport
|
// ExpenseReport
|
||||||
if ($x_paye[$my_paye_rate]['ptype'][$id] == 'ExpenseReportPayment')
|
if ($x_paye[$my_paye_rate]['ptype'][$id] == 'ExpenseReportPayment')
|
||||||
@ -315,18 +292,22 @@ else
|
|||||||
$invoice_supplier->id=$x_paye[$my_paye_rate]['facid'][$id];
|
$invoice_supplier->id=$x_paye[$my_paye_rate]['facid'][$id];
|
||||||
$invoice_supplier->ref=$x_paye[$my_paye_rate]['facnum'][$id];
|
$invoice_supplier->ref=$x_paye[$my_paye_rate]['facnum'][$id];
|
||||||
$invoice_supplier->type=$x_paye[$my_paye_rate]['type'][$id];
|
$invoice_supplier->type=$x_paye[$my_paye_rate]['type'][$id];
|
||||||
|
$company_static->fetch($x_paye[$my_paye_rate]['company_id'][$id]);
|
||||||
$x_both[$my_paye_rate]['paye']['detail'][] = array(
|
$x_both[$my_paye_rate]['paye']['detail'][] = array(
|
||||||
'id' =>$x_paye[$my_paye_rate]['facid'][$id],
|
'id' =>$x_paye[$my_paye_rate]['facid'][$id],
|
||||||
'descr' =>$x_paye[$my_paye_rate]['descr'][$id],
|
'descr' =>$x_paye[$my_paye_rate]['descr'][$id],
|
||||||
'pid' =>$x_paye[$my_paye_rate]['pid'][$id],
|
'pid' =>$x_paye[$my_paye_rate]['pid'][$id],
|
||||||
'pref' =>$x_paye[$my_paye_rate]['pref'][$id],
|
'pref' =>$x_paye[$my_paye_rate]['pref'][$id],
|
||||||
'ptype' =>$x_paye[$my_paye_rate]['ptype'][$id],
|
'ptype' =>$x_paye[$my_paye_rate]['ptype'][$id],
|
||||||
'payment_id' =>$x_paye[$my_paye_rate]['payment_id'][$id],
|
'payment_id'=>$x_paye[$my_paye_rate]['payment_id'][$id],
|
||||||
'payment_amount' =>$x_paye[$my_paye_rate]['payment_amount'][$id],
|
'payment_amount'=>$x_paye[$my_paye_rate]['payment_amount'][$id],
|
||||||
'ftotal_ttc' =>price2num($x_paye[$my_paye_rate]['ftotal_ttc'][$id]),
|
'ftotal_ttc'=>price2num($x_paye[$my_paye_rate]['ftotal_ttc'][$id]),
|
||||||
'dtotal_ttc' =>price2num($x_paye[$my_paye_rate]['dtotal_ttc'][$id]),
|
'dtotal_ttc'=>price2num($x_paye[$my_paye_rate]['dtotal_ttc'][$id]),
|
||||||
'dtype' =>$x_paye[$my_paye_rate]['dtype'][$id],
|
'dtype' =>$x_paye[$my_paye_rate]['dtype'][$id],
|
||||||
'ddate_start' =>$x_paye[$my_paye_rate]['ddate_start'][$id],
|
'datef' =>$x_paye[$my_paye_rate]['datef'][$id],
|
||||||
|
'datep' =>$x_paye[$my_paye_rate]['datep'][$id],
|
||||||
|
'company_link'=>$company_static->getNomUrl(1,'',20),
|
||||||
|
'ddate_start'=>$x_paye[$my_paye_rate]['ddate_start'][$id],
|
||||||
'ddate_end' =>$x_paye[$my_paye_rate]['ddate_end'][$id],
|
'ddate_end' =>$x_paye[$my_paye_rate]['ddate_end'][$id],
|
||||||
'totalht' =>price2num($x_paye[$my_paye_rate]['totalht_list'][$id]),
|
'totalht' =>price2num($x_paye[$my_paye_rate]['totalht_list'][$id]),
|
||||||
'vat' =>$x_paye[$my_paye_rate]['vat_list'][$id],
|
'vat' =>$x_paye[$my_paye_rate]['vat_list'][$id],
|
||||||
@ -345,16 +326,20 @@ else
|
|||||||
$x_paye_sum = 0;
|
$x_paye_sum = 0;
|
||||||
$x_paye_ht = 0;
|
$x_paye_ht = 0;
|
||||||
|
|
||||||
$span=3;
|
$span=$columns;
|
||||||
if ($modetax == 0) $span+=2;
|
if ($modetax != 1) $span+=2;
|
||||||
|
|
||||||
//print '<tr><td colspan="'.($span+1).'">'..')</td></tr>';
|
//print '<tr><td colspan="'.($span+1).'">'..')</td></tr>';
|
||||||
|
|
||||||
// Customers invoices
|
// Customers invoices
|
||||||
print '<tr class="liste_titre">';
|
print '<tr class="liste_titre">';
|
||||||
print '<td align="left">'.$elementcust.'</td>';
|
print '<td align="left">'.$elementcust.'</td>';
|
||||||
|
print '<td align="left">'.$langs->trans("DateInvoice").'</td>';
|
||||||
|
if ($conf->global->TAX_MODE_SELL_PRODUCT == 'payment' || $conf->global->TAX_MODE_SELL_SERVICE == 'payment') print '<td align="left">'.$langs->trans("DatePayment").'</td>';
|
||||||
|
else print '<td></td>';
|
||||||
|
print '<td align="left">'.$namecust.'</td>';
|
||||||
print '<td align="left">'.$productcust.'</td>';
|
print '<td align="left">'.$productcust.'</td>';
|
||||||
if ($modetax == 0)
|
if ($modetax != 1)
|
||||||
{
|
{
|
||||||
print '<td align="right">'.$amountcust.'</td>';
|
print '<td align="right">'.$amountcust.'</td>';
|
||||||
print '<td align="right">'.$langs->trans("Payment").' ('.$langs->trans("PercentOfInvoice").')</td>';
|
print '<td align="right">'.$langs->trans("Payment").' ('.$langs->trans("PercentOfInvoice").')</td>';
|
||||||
@ -374,8 +359,7 @@ else
|
|||||||
$hookmanager->initHooks(array('externalbalance'));
|
$hookmanager->initHooks(array('externalbalance'));
|
||||||
$reshook=$hookmanager->executeHooks('addVatLine',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
|
$reshook=$hookmanager->executeHooks('addVatLine',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
|
||||||
|
|
||||||
foreach(array_keys($x_coll) as $rate)
|
foreach (array_keys($x_coll) as $rate) {
|
||||||
{
|
|
||||||
$subtot_coll_total_ht = 0;
|
$subtot_coll_total_ht = 0;
|
||||||
$subtot_coll_vat = 0;
|
$subtot_coll_vat = 0;
|
||||||
|
|
||||||
@ -384,17 +368,20 @@ else
|
|||||||
// VAT Rate
|
// VAT Rate
|
||||||
$var=true;
|
$var=true;
|
||||||
print "<tr>";
|
print "<tr>";
|
||||||
print '<td class="tax_rate">'.$langs->trans("Rate").': '.vatrate($rate).'%</td><td colspan="'.$span.'"></td>';
|
print '<td class="tax_rate">'.$langs->trans("Rate").': '.vatrate($rate).'%</td><td colspan="'.($span+1).'"></td>';
|
||||||
print '</tr>'."\n";
|
print '</tr>'."\n";
|
||||||
|
|
||||||
foreach($x_both[$rate]['coll']['detail'] as $index => $fields)
|
foreach ($x_both[$rate]['coll']['detail'] as $index => $fields) {
|
||||||
{
|
|
||||||
// Define type
|
// Define type
|
||||||
$type=($fields['dtype']?$fields['dtype']:$fields['ptype']);
|
$type=($fields['dtype']?$fields['dtype']:$fields['ptype']);
|
||||||
// Try to enhance type detection using date_start and date_end for free lines where type
|
// Try to enhance type detection using date_start and date_end for free lines where type
|
||||||
// was not saved.
|
// was not saved.
|
||||||
if (! empty($fields['ddate_start'])) $type=1;
|
if (!empty($fields['ddate_start'])) {
|
||||||
if (! empty($fields['ddate_end'])) $type=1;
|
$type=1;
|
||||||
|
}
|
||||||
|
if (!empty($fields['ddate_end'])) {
|
||||||
|
$type=1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
print '<tr class="oddeven">';
|
print '<tr class="oddeven">';
|
||||||
@ -402,6 +389,16 @@ else
|
|||||||
// Ref
|
// Ref
|
||||||
print '<td class="nowrap" align="left">'.$fields['link'].'</td>';
|
print '<td class="nowrap" align="left">'.$fields['link'].'</td>';
|
||||||
|
|
||||||
|
// Invoice date
|
||||||
|
print '<td align="left">' . dol_print_date($fields['datef'], 'day') . '</td>';
|
||||||
|
|
||||||
|
// Payment date
|
||||||
|
if ($conf->global->TAX_MODE_SELL_PRODUCT == 'payment' || $conf->global->TAX_MODE_SELL_SERVICE == 'payment') print '<td align="left">' . dol_print_date($fields['datep'], 'day') . '</td>';
|
||||||
|
else print '<td></td>';
|
||||||
|
|
||||||
|
// Company name
|
||||||
|
print '<td align="left">' . $fields['company_link'] . '</td>';
|
||||||
|
|
||||||
// Description
|
// Description
|
||||||
print '<td align="left">';
|
print '<td align="left">';
|
||||||
if ($fields['pid'])
|
if ($fields['pid'])
|
||||||
@ -410,17 +407,25 @@ else
|
|||||||
$product_static->ref=$fields['pref'];
|
$product_static->ref=$fields['pref'];
|
||||||
$product_static->type=$fields['ptype'];
|
$product_static->type=$fields['ptype'];
|
||||||
print $product_static->getNomUrl(1);
|
print $product_static->getNomUrl(1);
|
||||||
if (dol_string_nohtmltag($fields['descr'])) print ' - '.dol_trunc(dol_string_nohtmltag($fields['descr']),16);
|
if (dol_string_nohtmltag($fields['descr'])) {
|
||||||
|
print ' - '.dol_trunc(dol_string_nohtmltag($fields['descr']),16);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if ($type) $text = img_object($langs->trans('Service'),'service');
|
if ($type) {
|
||||||
else $text = img_object($langs->trans('Product'),'product');
|
$text = img_object($langs->trans('Service'),'service');
|
||||||
if (preg_match('/^\((.*)\)$/',$fields['descr'],$reg))
|
} else {
|
||||||
{
|
$text = img_object($langs->trans('Product'),'product');
|
||||||
if ($reg[1]=='DEPOSIT') $fields['descr']=$langs->transnoentitiesnoconv('Deposit');
|
}
|
||||||
elseif ($reg[1]=='CREDIT_NOTE') $fields['descr']=$langs->transnoentitiesnoconv('CreditNote');
|
if (preg_match('/^\((.*)\)$/',$fields['descr'],$reg)) {
|
||||||
else $fields['descr']=$langs->transnoentitiesnoconv($reg[1]);
|
if ($reg[1]=='DEPOSIT') {
|
||||||
|
$fields['descr']=$langs->transnoentitiesnoconv('Deposit');
|
||||||
|
} elseif ($reg[1]=='CREDIT_NOTE') {
|
||||||
|
$fields['descr']=$langs->transnoentitiesnoconv('CreditNote');
|
||||||
|
} else {
|
||||||
|
$fields['descr']=$langs->transnoentitiesnoconv($reg[1]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
print $text.' '.dol_trunc(dol_string_nohtmltag($fields['descr']),16);
|
print $text.' '.dol_trunc(dol_string_nohtmltag($fields['descr']),16);
|
||||||
|
|
||||||
@ -430,7 +435,7 @@ else
|
|||||||
print '</td>';
|
print '</td>';
|
||||||
|
|
||||||
// Total HT
|
// Total HT
|
||||||
if ($modetax == 0)
|
if ($modetax != 1)
|
||||||
{
|
{
|
||||||
print '<td class="nowrap" align="right">';
|
print '<td class="nowrap" align="right">';
|
||||||
print price($fields['totalht']);
|
print price($fields['totalht']);
|
||||||
@ -445,9 +450,8 @@ else
|
|||||||
|
|
||||||
// Payment
|
// Payment
|
||||||
$ratiopaymentinvoice=1;
|
$ratiopaymentinvoice=1;
|
||||||
if ($modetax == 0)
|
if ($modetax != 1)
|
||||||
{
|
{
|
||||||
if (isset($fields['payment_amount']) && price2num($fields['ftotal_ttc'])) $ratiopaymentinvoice=($fields['payment_amount']/$fields['ftotal_ttc']);
|
|
||||||
print '<td class="nowrap" align="right">';
|
print '<td class="nowrap" align="right">';
|
||||||
//print $fields['totalht']."-".$fields['payment_amount']."-".$fields['ftotal_ttc'];
|
//print $fields['totalht']."-".$fields['payment_amount']."-".$fields['ftotal_ttc'];
|
||||||
if ($fields['payment_amount'] && $fields['ftotal_ttc'])
|
if ($fields['payment_amount'] && $fields['ftotal_ttc'])
|
||||||
@ -455,28 +459,31 @@ else
|
|||||||
$payment_static->id=$fields['payment_id'];
|
$payment_static->id=$fields['payment_id'];
|
||||||
print $payment_static->getNomUrl(2);
|
print $payment_static->getNomUrl(2);
|
||||||
}
|
}
|
||||||
if ($type == 0)
|
if (($type == 0 && $conf->global->TAX_MODE_SELL_PRODUCT == 'invoice')
|
||||||
|
|| ($type == 1 && $conf->global->TAX_MODE_SELL_SERVICE == 'invoice'))
|
||||||
{
|
{
|
||||||
print $langs->trans("NotUsedForGoods");
|
print $langs->trans("NA");
|
||||||
|
} else {
|
||||||
|
if (isset($fields['payment_amount']) && price2num($fields['ftotal_ttc'])) {
|
||||||
|
$ratiopaymentinvoice=($fields['payment_amount']/$fields['ftotal_ttc']);
|
||||||
|
}
|
||||||
|
print price(price2num($fields['payment_amount'],'MT'));
|
||||||
|
if (isset($fields['payment_amount'])) {
|
||||||
|
print ' ('.round($ratiopaymentinvoice*100,2).'%)';
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
print price($fields['payment_amount']);
|
|
||||||
if (isset($fields['payment_amount'])) print ' ('.round($ratiopaymentinvoice*100,2).'%)';
|
|
||||||
}
|
}
|
||||||
print '</td>';
|
print '</td>';
|
||||||
}
|
}
|
||||||
|
|
||||||
// Total collected
|
// Total collected
|
||||||
print '<td class="nowrap" align="right">';
|
print '<td class="nowrap" align="right">';
|
||||||
$temp_ht=$fields['totalht'];
|
$temp_ht=$fields['totalht']*$ratiopaymentinvoice;
|
||||||
if ($type == 1) $temp_ht=$fields['totalht']*$ratiopaymentinvoice;
|
|
||||||
print price(price2num($temp_ht,'MT'),1);
|
print price(price2num($temp_ht,'MT'),1);
|
||||||
print '</td>';
|
print '</td>';
|
||||||
|
|
||||||
// VAT
|
// VAT
|
||||||
print '<td class="nowrap" align="right">';
|
print '<td class="nowrap" align="right">';
|
||||||
$temp_vat=$fields['vat'];
|
$temp_vat=$fields['vat']*$ratiopaymentinvoice;
|
||||||
if ($type == 1) $temp_vat=$fields['vat']*$ratiopaymentinvoice;
|
|
||||||
print price(price2num($temp_vat,'MT'),1);
|
print price(price2num($temp_vat,'MT'),1);
|
||||||
//print price($fields['vat']);
|
//print price($fields['vat']);
|
||||||
print '</td>';
|
print '</td>';
|
||||||
@ -489,10 +496,9 @@ else
|
|||||||
}
|
}
|
||||||
// Total customers for this vat rate
|
// Total customers for this vat rate
|
||||||
print '<tr class="liste_total">';
|
print '<tr class="liste_total">';
|
||||||
print '<td></td>';
|
print '<td colspan="4"></td>';
|
||||||
print '<td align="right">'.$langs->trans("Total").':</td>';
|
print '<td align="right">'.$langs->trans("Total").':</td>';
|
||||||
if ($modetax == 0)
|
if ($modetax != 1) {
|
||||||
{
|
|
||||||
print '<td class="nowrap" align="right"> </td>';
|
print '<td class="nowrap" align="right"> </td>';
|
||||||
print '<td align="right"> </td>';
|
print '<td align="right"> </td>';
|
||||||
}
|
}
|
||||||
@ -504,10 +510,9 @@ else
|
|||||||
if (count($x_coll) == 0) // Show a total ine if nothing shown
|
if (count($x_coll) == 0) // Show a total ine if nothing shown
|
||||||
{
|
{
|
||||||
print '<tr class="liste_total">';
|
print '<tr class="liste_total">';
|
||||||
print '<td> </td>';
|
print '<td colspan="4"></td>';
|
||||||
print '<td align="right">'.$langs->trans("Total").':</td>';
|
print '<td align="right">'.$langs->trans("Total").':</td>';
|
||||||
if ($modetax == 0)
|
if ($modetax != 1) {
|
||||||
{
|
|
||||||
print '<td class="nowrap" align="right"> </td>';
|
print '<td class="nowrap" align="right"> </td>';
|
||||||
print '<td align="right"> </td>';
|
print '<td align="right"> </td>';
|
||||||
}
|
}
|
||||||
@ -519,13 +524,15 @@ else
|
|||||||
// Blank line
|
// Blank line
|
||||||
print '<tr><td colspan="'.($span+1).'"> </td></tr>';
|
print '<tr><td colspan="'.($span+1).'"> </td></tr>';
|
||||||
|
|
||||||
//print table headers for this quadri - expenses now
|
// Print table headers for this quadri - expenses now
|
||||||
//imprime les en-tete de tables pour ce quadri - maintenant les d<>penses
|
|
||||||
print '<tr class="liste_titre liste_titre_topborder">';
|
print '<tr class="liste_titre liste_titre_topborder">';
|
||||||
print '<td align="left">'.$elementsup.'</td>';
|
print '<td align="left">'.$elementsup.'</td>';
|
||||||
|
print '<td align="left">'.$langs->trans("Date").'</td>';
|
||||||
|
if ($conf->global->TAX_MODE_BUY_PRODUCT == 'payment' || $conf->global->TAX_MODE_BUY_SERVICE == 'payment') print '<td align="left">'.$langs->trans("DatePayment").'</td>';
|
||||||
|
else print '<td></td>';
|
||||||
|
print '<td align="left">'.$namesup.'</td>';
|
||||||
print '<td align="left">'.$productsup.'</td>';
|
print '<td align="left">'.$productsup.'</td>';
|
||||||
if ($modetax == 0)
|
if ($modetax != 1) {
|
||||||
{
|
|
||||||
print '<td align="right">'.$amountsup.'</td>';
|
print '<td align="right">'.$amountsup.'</td>';
|
||||||
print '<td align="right">'.$langs->trans("Payment").' ('.$langs->trans("PercentOfInvoice").')</td>';
|
print '<td align="right">'.$langs->trans("Payment").' ('.$langs->trans("PercentOfInvoice").')</td>';
|
||||||
}
|
}
|
||||||
@ -533,25 +540,29 @@ else
|
|||||||
print '<td align="right">'.$vatsup.'</td>';
|
print '<td align="right">'.$vatsup.'</td>';
|
||||||
print '</tr>'."\n";
|
print '</tr>'."\n";
|
||||||
|
|
||||||
foreach(array_keys($x_paye) as $rate)
|
foreach (array_keys($x_paye) as $rate)
|
||||||
{
|
{
|
||||||
$subtot_paye_total_ht = 0;
|
$subtot_paye_total_ht = 0;
|
||||||
$subtot_paye_vat = 0;
|
$subtot_paye_vat = 0;
|
||||||
|
|
||||||
if(is_array($x_both[$rate]['paye']['detail']))
|
if (is_array($x_both[$rate]['paye']['detail']))
|
||||||
{
|
{
|
||||||
$var=true;
|
$var=true;
|
||||||
print "<tr>";
|
print "<tr>";
|
||||||
print '<td class="tax_rate">'.$langs->trans("Rate").': '.vatrate($rate).'%</td><td colspan="'.$span.'"></td>';
|
print '<td class="tax_rate">'.$langs->trans("Rate").': '.vatrate($rate).'%</td><td colspan="'.($span+1).'"></td>';
|
||||||
print '</tr>'."\n";
|
print '</tr>'."\n";
|
||||||
foreach($x_both[$rate]['paye']['detail'] as $index=>$fields)
|
|
||||||
{
|
foreach ($x_both[$rate]['paye']['detail'] as $index=>$fields) {
|
||||||
// Define type
|
// Define type
|
||||||
$type=($fields['dtype']?$fields['dtype']:$fields['ptype']);
|
$type=($fields['dtype']?$fields['dtype']:$fields['ptype']);
|
||||||
// Try to enhance type detection using date_start and date_end for free lines where type
|
// Try to enhance type detection using date_start and date_end for free lines where type
|
||||||
// was not saved.
|
// was not saved.
|
||||||
if (! empty($fields['ddate_start'])) $type=1;
|
if (!empty($fields['ddate_start'])) {
|
||||||
if (! empty($fields['ddate_end'])) $type=1;
|
$type=1;
|
||||||
|
}
|
||||||
|
if (!empty($fields['ddate_end'])) {
|
||||||
|
$type=1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
print '<tr class="oddeven">';
|
print '<tr class="oddeven">';
|
||||||
@ -559,6 +570,16 @@ else
|
|||||||
// Ref
|
// Ref
|
||||||
print '<td class="nowrap" align="left">'.$fields['link'].'</td>';
|
print '<td class="nowrap" align="left">'.$fields['link'].'</td>';
|
||||||
|
|
||||||
|
// Invoice date
|
||||||
|
print '<td align="left">' . dol_print_date($fields['datef'], 'day') . '</td>';
|
||||||
|
|
||||||
|
// Payment date
|
||||||
|
if ($conf->global->TAX_MODE_BUY_PRODUCT == 'payment' || $conf->global->TAX_MODE_BUY_SERVICE == 'payment') print '<td align="left">' . dol_print_date($fields['datep'], 'day') . '</td>';
|
||||||
|
else print '<td></td>';
|
||||||
|
|
||||||
|
// Company name
|
||||||
|
print '<td align="left">' . $fields['company_link'] . '</td>';
|
||||||
|
|
||||||
// Description
|
// Description
|
||||||
print '<td align="left">';
|
print '<td align="left">';
|
||||||
if ($fields['pid'])
|
if ($fields['pid'])
|
||||||
@ -567,12 +588,17 @@ else
|
|||||||
$product_static->ref=$fields['pref'];
|
$product_static->ref=$fields['pref'];
|
||||||
$product_static->type=$fields['ptype'];
|
$product_static->type=$fields['ptype'];
|
||||||
print $product_static->getNomUrl(1);
|
print $product_static->getNomUrl(1);
|
||||||
if (dol_string_nohtmltag($fields['descr'])) print ' - '.dol_trunc(dol_string_nohtmltag($fields['descr']),16);
|
if (dol_string_nohtmltag($fields['descr'])) {
|
||||||
|
print ' - '.dol_trunc(dol_string_nohtmltag($fields['descr']),16);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if ($type) $text = img_object($langs->trans('Service'),'service');
|
if ($type) {
|
||||||
else $text = img_object($langs->trans('Product'),'product');
|
$text = img_object($langs->trans('Service'),'service');
|
||||||
|
} else {
|
||||||
|
$text = img_object($langs->trans('Product'),'product');
|
||||||
|
}
|
||||||
print $text.' '.dol_trunc(dol_string_nohtmltag($fields['descr']),16);
|
print $text.' '.dol_trunc(dol_string_nohtmltag($fields['descr']),16);
|
||||||
|
|
||||||
// Show range
|
// Show range
|
||||||
@ -581,7 +607,7 @@ else
|
|||||||
print '</td>';
|
print '</td>';
|
||||||
|
|
||||||
// Total HT
|
// Total HT
|
||||||
if ($modetax == 0)
|
if ($modetax != 1)
|
||||||
{
|
{
|
||||||
print '<td class="nowrap" align="right">';
|
print '<td class="nowrap" align="right">';
|
||||||
print price($fields['totalht']);
|
print price($fields['totalht']);
|
||||||
@ -596,38 +622,42 @@ else
|
|||||||
|
|
||||||
// Payment
|
// Payment
|
||||||
$ratiopaymentinvoice=1;
|
$ratiopaymentinvoice=1;
|
||||||
if ($modetax == 0)
|
if ($modetax != 1)
|
||||||
{
|
{
|
||||||
if (isset($fields['payment_amount']) && $fields['ftotal_ttc']) $ratiopaymentinvoice=($fields['payment_amount']/$fields['ftotal_ttc']);
|
|
||||||
print '<td class="nowrap" align="right">';
|
print '<td class="nowrap" align="right">';
|
||||||
if ($fields['payment_amount'] && $fields['ftotal_ttc'])
|
if ($fields['payment_amount'] && $fields['ftotal_ttc'])
|
||||||
{
|
{
|
||||||
$paymentfourn_static->id=$fields['payment_id'];
|
$paymentfourn_static->id=$fields['payment_id'];
|
||||||
print $paymentfourn_static->getNomUrl(2);
|
print $paymentfourn_static->getNomUrl(2);
|
||||||
}
|
}
|
||||||
if ($type == 0)
|
|
||||||
|
if (($type == 0 && $conf->global->TAX_MODE_BUY_PRODUCT == 'invoice')
|
||||||
|
|| ($type == 1 && $conf->global->TAX_MODE_BUY_SERVICE == 'invoice'))
|
||||||
{
|
{
|
||||||
print $langs->trans("NotUsedForGoods");
|
print $langs->trans("NA");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
print price($fields['payment_amount']);
|
if (isset($fields['payment_amount']) && $fields['ftotal_ttc']) {
|
||||||
if (isset($fields['payment_amount'])) print ' ('.round($ratiopaymentinvoice*100,2).'%)';
|
$ratiopaymentinvoice=($fields['payment_amount']/$fields['ftotal_ttc']);
|
||||||
|
}
|
||||||
|
print price(price2num($fields['payment_amount'],'MT'));
|
||||||
|
if (isset($fields['payment_amount'])) {
|
||||||
|
print ' ('.round($ratiopaymentinvoice*100,2).'%)';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
print '</td>';
|
print '</td>';
|
||||||
}
|
}
|
||||||
|
|
||||||
// VAT paid
|
// VAT paid
|
||||||
print '<td class="nowrap" align="right">';
|
print '<td class="nowrap" align="right">';
|
||||||
$temp_ht=$fields['totalht'];
|
$temp_ht=$fields['totalht']*$ratiopaymentinvoice;
|
||||||
if ($type == 1) $temp_ht=$fields['totalht']*$ratiopaymentinvoice;
|
|
||||||
print price(price2num($temp_ht,'MT'),1);
|
print price(price2num($temp_ht,'MT'),1);
|
||||||
print '</td>';
|
print '</td>';
|
||||||
|
|
||||||
// VAT
|
// VAT
|
||||||
print '<td class="nowrap" align="right">';
|
print '<td class="nowrap" align="right">';
|
||||||
$temp_vat=$fields['vat'];
|
$temp_vat=$fields['vat']*$ratiopaymentinvoice;
|
||||||
if ($type == 1) $temp_vat=$fields['vat']*$ratiopaymentinvoice;
|
|
||||||
print price(price2num($temp_vat,'MT'),1);
|
print price(price2num($temp_vat,'MT'),1);
|
||||||
//print price($fields['vat']);
|
//print price($fields['vat']);
|
||||||
print '</td>';
|
print '</td>';
|
||||||
@ -640,10 +670,9 @@ else
|
|||||||
}
|
}
|
||||||
// Total suppliers for this vat rate
|
// Total suppliers for this vat rate
|
||||||
print '<tr class="liste_total">';
|
print '<tr class="liste_total">';
|
||||||
print '<td> </td>';
|
print '<td colspan="4"></td>';
|
||||||
print '<td align="right">'.$langs->trans("Total").':</td>';
|
print '<td align="right">'.$langs->trans("Total").':</td>';
|
||||||
if ($modetax == 0)
|
if ($modetax != 1) {
|
||||||
{
|
|
||||||
print '<td class="nowrap" align="right"> </td>';
|
print '<td class="nowrap" align="right"> </td>';
|
||||||
print '<td align="right"> </td>';
|
print '<td align="right"> </td>';
|
||||||
}
|
}
|
||||||
@ -652,13 +681,11 @@ else
|
|||||||
print '</tr>';
|
print '</tr>';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (count($x_paye) == 0) // Show a total line if nothing shown
|
if (count($x_paye) == 0) { // Show a total line if nothing shown
|
||||||
{
|
|
||||||
print '<tr class="liste_total">';
|
print '<tr class="liste_total">';
|
||||||
print '<td> </td>';
|
print '<td colspan="4"></td>';
|
||||||
print '<td align="right">'.$langs->trans("Total").':</td>';
|
print '<td align="right">'.$langs->trans("Total").':</td>';
|
||||||
if ($modetax == 0)
|
if ($modetax != 1) {
|
||||||
{
|
|
||||||
print '<td class="nowrap" align="right"> </td>';
|
print '<td class="nowrap" align="right"> </td>';
|
||||||
print '<td align="right"> </td>';
|
print '<td align="right"> </td>';
|
||||||
}
|
}
|
||||||
@ -680,7 +707,7 @@ else
|
|||||||
|
|
||||||
$i++;
|
$i++;
|
||||||
}
|
}
|
||||||
echo '</table>';
|
print '</table>';
|
||||||
|
|
||||||
llxFooter();
|
llxFooter();
|
||||||
$db->close();
|
$db->close();
|
||||||
|
|||||||
@ -1,713 +0,0 @@
|
|||||||
<?php
|
|
||||||
/* Copyright (C) 2001-2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
|
||||||
* Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com>
|
|
||||||
* Copyright (C) 2004-2013 Laurent Destailleur <eldy@users.sourceforge.net>
|
|
||||||
* Copyright (C) 2006-2007, 2015 Yannick Warnier <ywarnier@beeznest.org>
|
|
||||||
* Copyright (C) 2014 Ferran Marcet <fmarcet@2byte.es>
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation; either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* \file htdocs/compta/tva/quadri_detail.php
|
|
||||||
* \ingroup tax
|
|
||||||
* \brief Trimestrial page - detailed version
|
|
||||||
* TODO Deal with recurrent invoices as well
|
|
||||||
*/
|
|
||||||
|
|
||||||
require '../../main.inc.php';
|
|
||||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/report.lib.php';
|
|
||||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/tax.lib.php';
|
|
||||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
|
|
||||||
require_once DOL_DOCUMENT_ROOT.'/compta/tva/class/tva.class.php';
|
|
||||||
require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
|
|
||||||
require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
|
|
||||||
require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php';
|
|
||||||
require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
|
|
||||||
require_once DOL_DOCUMENT_ROOT.'/fourn/class/paiementfourn.class.php';
|
|
||||||
|
|
||||||
$langs->load("main");
|
|
||||||
$langs->load("bills");
|
|
||||||
$langs->load("compta");
|
|
||||||
$langs->load("companies");
|
|
||||||
$langs->load("products");
|
|
||||||
$langs->load("other");
|
|
||||||
|
|
||||||
// Date range
|
|
||||||
$year=GETPOST('year', 'int');
|
|
||||||
if (empty($year)) {
|
|
||||||
$year_current = strftime("%Y",dol_now());
|
|
||||||
$year_start = $year_current;
|
|
||||||
} else {
|
|
||||||
$year_current = $year;
|
|
||||||
$year_start = $year;
|
|
||||||
}
|
|
||||||
$date_start=dol_mktime(0,0,0,$_REQUEST["date_startmonth"],$_REQUEST["date_startday"],$_REQUEST["date_startyear"]);
|
|
||||||
$date_end=dol_mktime(23,59,59,$_REQUEST["date_endmonth"],$_REQUEST["date_endday"],$_REQUEST["date_endyear"]);
|
|
||||||
// Quarter
|
|
||||||
if (empty($date_start) || empty($date_end)) { // We define date_start and date_end
|
|
||||||
$q=GETPOST('q', 'int');
|
|
||||||
if (empty($q)) {
|
|
||||||
if (isset($_REQUEST["month"])) {
|
|
||||||
$date_start=dol_get_first_day($year_start,$_REQUEST["month"],false);
|
|
||||||
$date_end=dol_get_last_day($year_start,$_REQUEST["month"],false);
|
|
||||||
} else {
|
|
||||||
$month_current = strftime("%m",dol_now());
|
|
||||||
if ($month_current >= 10) $q=4;
|
|
||||||
elseif ($month_current >= 7) $q=3;
|
|
||||||
elseif ($month_current >= 4) $q=2;
|
|
||||||
else $q=1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if ($q==1) {
|
|
||||||
$date_start=dol_get_first_day($year_start,1,false);
|
|
||||||
$date_end=dol_get_last_day($year_start,3,false);
|
|
||||||
}
|
|
||||||
if ($q==2) {
|
|
||||||
$date_start=dol_get_first_day($year_start,4,false);
|
|
||||||
$date_end=dol_get_last_day($year_start,6,false);
|
|
||||||
}
|
|
||||||
if ($q==3) {
|
|
||||||
$date_start=dol_get_first_day($year_start,7,false);
|
|
||||||
$date_end=dol_get_last_day($year_start,9,false);
|
|
||||||
}
|
|
||||||
if ($q==4) {
|
|
||||||
$date_start=dol_get_first_day($year_start,10,false);
|
|
||||||
$date_end=dol_get_last_day($year_start,12,false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$min = GETPOST("min");
|
|
||||||
if (empty($min)) {
|
|
||||||
$min = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Define modetax (0 or 1)
|
|
||||||
// 0=normal, 1=option vat for services is on debit
|
|
||||||
$modetax = $conf->global->TAX_MODE;
|
|
||||||
if (isset($_REQUEST["modetax"])) {
|
|
||||||
$modetax=$_REQUEST["modetax"];
|
|
||||||
}
|
|
||||||
if (empty($modetax)) {
|
|
||||||
$modetax=0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Security check
|
|
||||||
$socid = GETPOST('socid','int');
|
|
||||||
if ($user->societe_id) {
|
|
||||||
$socid=$user->societe_id;
|
|
||||||
}
|
|
||||||
$result = restrictedArea($user, 'tax', '', '', 'charges');
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* View
|
|
||||||
*/
|
|
||||||
|
|
||||||
$morequerystring='';
|
|
||||||
$listofparams=array('date_startmonth','date_startyear','date_startday','date_endmonth','date_endyear','date_endday');
|
|
||||||
foreach ($listofparams as $param) {
|
|
||||||
if (GETPOST($param)!='') {
|
|
||||||
$morequerystring.=($morequerystring?'&':'').$param.'='.GETPOST($param);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
llxHeader('','','','',0,0,'','',$morequerystring);
|
|
||||||
|
|
||||||
$form=new Form($db);
|
|
||||||
|
|
||||||
$company_static=new Societe($db);
|
|
||||||
$invoice_customer=new Facture($db);
|
|
||||||
$invoice_supplier=new FactureFournisseur($db);
|
|
||||||
$product_static=new Product($db);
|
|
||||||
$payment_static=new Paiement($db);
|
|
||||||
$paymentfourn_static=new PaiementFourn($db);
|
|
||||||
|
|
||||||
//print load_fiche_titre($langs->trans("VAT"),"");
|
|
||||||
|
|
||||||
//$fsearch.='<br>';
|
|
||||||
$fsearch.=' <input type="hidden" name="year" value="'.$year.'">';
|
|
||||||
$fsearch.=' <input type="hidden" name="modetax" value="'.$modetax.'">';
|
|
||||||
//$fsearch.=' '.$langs->trans("SalesTurnoverMinimum").': ';
|
|
||||||
//$fsearch.=' <input type="text" name="min" value="'.$min.'">';
|
|
||||||
|
|
||||||
|
|
||||||
// Affiche en-tete du rapport
|
|
||||||
if ($modetax==1) { // Calculate on invoice for goods and services
|
|
||||||
$name=$langs->trans("VATReportByQuartersInDueDebtMode");
|
|
||||||
$calcmode=$langs->trans("CalcModeVATDebt");
|
|
||||||
$calcmode.='<br>('.$langs->trans("TaxModuleSetupToModifyRules",DOL_URL_ROOT.'/admin/taxes.php').')';
|
|
||||||
$period=$form->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$form->select_date($date_end,'date_end',0,0,0,'',1,0,1);
|
|
||||||
$prevyear=$year_start; $prevquarter=$q;
|
|
||||||
if ($prevquarter > 1) {
|
|
||||||
$prevquarter--;
|
|
||||||
} else {
|
|
||||||
$prevquarter=4; $prevyear--;
|
|
||||||
}
|
|
||||||
$nextyear=$year_start; $nextquarter=$q;
|
|
||||||
if ($nextquarter < 4) {
|
|
||||||
$nextquarter++;
|
|
||||||
} else {
|
|
||||||
$nextquarter=1; $nextyear++;
|
|
||||||
}
|
|
||||||
//$periodlink=($prevyear?"<a href='".$_SERVER["PHP_SELF"]."?year=".$prevyear."&q=".$prevquarter."&modetax=".$modetax."'>".img_previous()."</a> <a href='".$_SERVER["PHP_SELF"]."?year=".$nextyear."&q=".$nextquarter."&modetax=".$modetax."'>".img_next()."</a>":"");
|
|
||||||
$description=$langs->trans("RulesVATDueServices");
|
|
||||||
$description.='<br>';
|
|
||||||
$description.=$langs->trans("RulesVATDueProducts");
|
|
||||||
//if ($conf->global->MAIN_MODULE_COMPTABILITE || $conf->global->MAIN_MODULE_ACCOUNTING) $description.='<br>'.img_warning().' '.$langs->trans('OptionVatInfoModuleComptabilite');
|
|
||||||
//if (! empty($conf->global->MAIN_MODULE_COMPTABILITE)) $description.='<br>'.$langs->trans("WarningDepositsNotIncluded");
|
|
||||||
if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
|
|
||||||
$description.='<br>'.$langs->trans("DepositsAreNotIncluded");
|
|
||||||
} else {
|
|
||||||
$description.='<br>'.$langs->trans("DepositsAreIncluded");
|
|
||||||
}
|
|
||||||
$description.=$fsearch;
|
|
||||||
$builddate=dol_now();
|
|
||||||
//$exportlink=$langs->trans("NotYetAvailable");
|
|
||||||
|
|
||||||
$elementcust=$langs->trans("CustomersInvoices");
|
|
||||||
$productcust=$langs->trans("ProductOrService");
|
|
||||||
$amountcust=$langs->trans("AmountHT");
|
|
||||||
$vatcust=$langs->trans("VATReceived");
|
|
||||||
$namecust=$langs->trans("Name");
|
|
||||||
if ($mysoc->tva_assuj) {
|
|
||||||
$vatcust.=' ('.$langs->trans("ToPay").')';
|
|
||||||
}
|
|
||||||
$elementsup=$langs->trans("SuppliersInvoices");
|
|
||||||
$productsup=$langs->trans("ProductOrService");
|
|
||||||
$amountsup=$langs->trans("AmountHT");
|
|
||||||
$vatsup=$langs->trans("VATPaid");
|
|
||||||
$namesup=$namecust;
|
|
||||||
if ($mysoc->tva_assuj) {
|
|
||||||
$vatsup.=' ('.$langs->trans("ToGetBack").')';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if ($modetax==0) { // Invoice for goods, payment for services
|
|
||||||
$name=$langs->trans("VATReportByQuartersInInputOutputMode");
|
|
||||||
$calcmode=$langs->trans("CalcModeVATEngagement");
|
|
||||||
$calcmode.='<br>('.$langs->trans("TaxModuleSetupToModifyRules",DOL_URL_ROOT.'/admin/taxes.php').')';
|
|
||||||
$period=$form->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$form->select_date($date_end,'date_end',0,0,0,'',1,0,1);
|
|
||||||
$prevyear=$year_start; $prevquarter=$q;
|
|
||||||
if ($prevquarter > 1) {
|
|
||||||
$prevquarter--;
|
|
||||||
} else {
|
|
||||||
$prevquarter=4; $prevyear--;
|
|
||||||
}
|
|
||||||
$nextyear=$year_start; $nextquarter=$q;
|
|
||||||
if ($nextquarter < 4) {
|
|
||||||
$nextquarter++;
|
|
||||||
} else {
|
|
||||||
$nextquarter=1; $nextyear++;
|
|
||||||
}
|
|
||||||
//$periodlink=($prevyear?"<a href='".$_SERVER["PHP_SELF"]."?year=".$prevyear."&q=".$prevquarter."&modetax=".$modetax."'>".img_previous()."</a> <a href='".$_SERVER["PHP_SELF"]."?year=".$nextyear."&q=".$nextquarter."&modetax=".$modetax."'>".img_next()."</a>":"");
|
|
||||||
$description=$langs->trans("RulesVATInServices");
|
|
||||||
$description.=' '.$langs->trans("DepositsAreIncluded");
|
|
||||||
$description.='<br>';
|
|
||||||
$description.=$langs->trans("RulesVATInProducts");
|
|
||||||
if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
|
|
||||||
$description.=' '.$langs->trans("DepositsAreNotIncluded");
|
|
||||||
} else {
|
|
||||||
$description.=' '.$langs->trans("DepositsAreIncluded");
|
|
||||||
}
|
|
||||||
//if ($conf->global->MAIN_MODULE_COMPTABILITE || $conf->global->MAIN_MODULE_ACCOUNTING) $description.='<br>'.img_warning().' '.$langs->trans('OptionVatInfoModuleComptabilite');
|
|
||||||
//if (! empty($conf->global->MAIN_MODULE_COMPTABILITE)) $description.='<br>'.$langs->trans("WarningDepositsNotIncluded");
|
|
||||||
$description.=$fsearch;
|
|
||||||
$builddate=dol_now();
|
|
||||||
//$exportlink=$langs->trans("NotYetAvailable");
|
|
||||||
|
|
||||||
$elementcust=$langs->trans("CustomersInvoices");
|
|
||||||
$productcust=$langs->trans("ProductOrService");
|
|
||||||
$amountcust=$langs->trans("AmountHT");
|
|
||||||
$vatcust=$langs->trans("VATReceived");
|
|
||||||
$namecust=$langs->trans("Name");
|
|
||||||
if ($mysoc->tva_assuj) {
|
|
||||||
$vatcust.=' ('.$langs->trans("ToPay").')';
|
|
||||||
}
|
|
||||||
$elementsup=$langs->trans("SuppliersInvoices");
|
|
||||||
$productsup=$productcust;
|
|
||||||
$amountsup=$amountcust;
|
|
||||||
$vatsup=$langs->trans("VATPaid");
|
|
||||||
$namesup=$namecust;
|
|
||||||
if ($mysoc->tva_assuj) {
|
|
||||||
$vatsup.=' ('.$langs->trans("ToGetBack").')';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
report_header($name,'',$period,$periodlink,$description,$builddate,$exportlink,array(),$calcmode);
|
|
||||||
|
|
||||||
$vatcust=$langs->trans("VATReceived");
|
|
||||||
$vatsup=$langs->trans("VATPaid");
|
|
||||||
|
|
||||||
|
|
||||||
// VAT Received and paid
|
|
||||||
|
|
||||||
print '<table class="noborder" width="100%">';
|
|
||||||
|
|
||||||
$y = $year_current;
|
|
||||||
$total = 0;
|
|
||||||
$i=0;
|
|
||||||
$columns = 6;
|
|
||||||
|
|
||||||
// Load arrays of datas
|
|
||||||
$x_coll = vat_by_date($db, 0, 0, $date_start, $date_end, $modetax, 'sell');
|
|
||||||
$x_paye = vat_by_date($db, 0, 0, $date_start, $date_end, $modetax, 'buy');
|
|
||||||
|
|
||||||
if (!is_array($x_coll) || !is_array($x_paye)) {
|
|
||||||
$langs->load("errors");
|
|
||||||
if ($x_coll == -1) {
|
|
||||||
print '<tr><td colspan="' . $columns . '">' . $langs->trans("ErrorNoAccountancyModuleLoaded") . '</td></tr>';
|
|
||||||
} else if ($x_coll == -2) {
|
|
||||||
print '<tr><td colspan="' . $columns . '">' . $langs->trans("FeatureNotYetAvailable") . '</td></tr>';
|
|
||||||
} else {
|
|
||||||
print '<tr><td colspan="' . $columns . '">' . $langs->trans("Error") . '</td></tr>';
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
$x_both = array();
|
|
||||||
//now, from these two arrays, get another array with one rate per line
|
|
||||||
foreach(array_keys($x_coll) as $my_coll_rate) {
|
|
||||||
$x_both[$my_coll_rate]['coll']['totalht'] = $x_coll[$my_coll_rate]['totalht'];
|
|
||||||
$x_both[$my_coll_rate]['coll']['vat'] = $x_coll[$my_coll_rate]['vat'];
|
|
||||||
$x_both[$my_coll_rate]['paye']['totalht'] = 0;
|
|
||||||
$x_both[$my_coll_rate]['paye']['vat'] = 0;
|
|
||||||
$x_both[$my_coll_rate]['coll']['links'] = '';
|
|
||||||
$x_both[$my_coll_rate]['coll']['detail'] = array();
|
|
||||||
foreach($x_coll[$my_coll_rate]['facid'] as $id=>$dummy) {
|
|
||||||
$invoice_customer->id=$x_coll[$my_coll_rate]['facid'][$id];
|
|
||||||
$invoice_customer->ref=$x_coll[$my_coll_rate]['facnum'][$id];
|
|
||||||
$invoice_customer->type=$x_coll[$my_coll_rate]['type'][$id];
|
|
||||||
$company_static->fetch($x_coll[$my_coll_rate]['company_id'][$id]);
|
|
||||||
$x_both[$my_coll_rate]['coll']['detail'][] = array(
|
|
||||||
'id' =>$x_coll[$my_coll_rate]['facid'][$id],
|
|
||||||
'descr' =>$x_coll[$my_coll_rate]['descr'][$id],
|
|
||||||
'pid' =>$x_coll[$my_coll_rate]['pid'][$id],
|
|
||||||
'pref' =>$x_coll[$my_coll_rate]['pref'][$id],
|
|
||||||
'ptype' =>$x_coll[$my_coll_rate]['ptype'][$id],
|
|
||||||
'payment_id'=>$x_coll[$my_coll_rate]['payment_id'][$id],
|
|
||||||
'payment_amount'=>$x_coll[$my_coll_rate]['payment_amount'][$id],
|
|
||||||
'ftotal_ttc'=>$x_coll[$my_coll_rate]['ftotal_ttc'][$id],
|
|
||||||
'dtotal_ttc'=>$x_coll[$my_coll_rate]['dtotal_ttc'][$id],
|
|
||||||
'dtype' =>$x_coll[$my_coll_rate]['dtype'][$id],
|
|
||||||
'datef' =>$x_coll[$my_coll_rate]['datef'][$id],
|
|
||||||
'company_link'=>$company_static->getNomUrl(1,'',20),
|
|
||||||
'ddate_start'=>$x_coll[$my_coll_rate]['ddate_start'][$id],
|
|
||||||
'ddate_end' =>$x_coll[$my_coll_rate]['ddate_end'][$id],
|
|
||||||
'totalht' =>$x_coll[$my_coll_rate]['totalht_list'][$id],
|
|
||||||
'vat' =>$x_coll[$my_coll_rate]['vat_list'][$id],
|
|
||||||
'link' =>$invoice_customer->getNomUrl(1,'',12)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// tva paid
|
|
||||||
foreach (array_keys($x_paye) as $my_paye_rate) {
|
|
||||||
$x_both[$my_paye_rate]['paye']['totalht'] = $x_paye[$my_paye_rate]['totalht'];
|
|
||||||
$x_both[$my_paye_rate]['paye']['vat'] = $x_paye[$my_paye_rate]['vat'];
|
|
||||||
if (!isset($x_both[$my_paye_rate]['coll']['totalht'])) {
|
|
||||||
$x_both[$my_paye_rate]['coll']['totalht'] = 0;
|
|
||||||
$x_both[$my_paye_rate]['coll']['vat'] = 0;
|
|
||||||
}
|
|
||||||
$x_both[$my_paye_rate]['paye']['links'] = '';
|
|
||||||
$x_both[$my_paye_rate]['paye']['detail'] = array();
|
|
||||||
|
|
||||||
foreach ($x_paye[$my_paye_rate]['facid'] as $id=>$dummy) {
|
|
||||||
$invoice_supplier->id=$x_paye[$my_paye_rate]['facid'][$id];
|
|
||||||
$invoice_supplier->ref=$x_paye[$my_paye_rate]['facnum'][$id];
|
|
||||||
$invoice_supplier->type=$x_paye[$my_paye_rate]['type'][$id];
|
|
||||||
$company_static->fetch($x_paye[$my_paye_rate]['company_id'][$id]);
|
|
||||||
$x_both[$my_paye_rate]['paye']['detail'][] = array(
|
|
||||||
'id' =>$x_paye[$my_paye_rate]['facid'][$id],
|
|
||||||
'descr' =>$x_paye[$my_paye_rate]['descr'][$id],
|
|
||||||
'pid' =>$x_paye[$my_paye_rate]['pid'][$id],
|
|
||||||
'pref' =>$x_paye[$my_paye_rate]['pref'][$id],
|
|
||||||
'ptype' =>$x_paye[$my_paye_rate]['ptype'][$id],
|
|
||||||
'payment_id'=>$x_paye[$my_paye_rate]['payment_id'][$id],
|
|
||||||
'payment_amount'=>$x_paye[$my_paye_rate]['payment_amount'][$id],
|
|
||||||
'ftotal_ttc'=>price2num($x_paye[$my_paye_rate]['ftotal_ttc'][$id]),
|
|
||||||
'dtotal_ttc'=>price2num($x_paye[$my_paye_rate]['dtotal_ttc'][$id]),
|
|
||||||
'dtype' =>$x_paye[$my_paye_rate]['dtype'][$id],
|
|
||||||
'datef' =>$x_paye[$my_paye_rate]['datef'][$id],
|
|
||||||
'company_link'=>$company_static->getNomUrl(1,'',20),
|
|
||||||
'ddate_start'=>$x_paye[$my_paye_rate]['ddate_start'][$id],
|
|
||||||
'ddate_end' =>$x_paye[$my_paye_rate]['ddate_end'][$id],
|
|
||||||
'totalht' =>price2num($x_paye[$my_paye_rate]['totalht_list'][$id]),
|
|
||||||
'vat' =>$x_paye[$my_paye_rate]['vat_list'][$id],
|
|
||||||
'link' =>$invoice_supplier->getNomUrl(1,'',12)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//now we have an array (x_both) indexed by rates for coll and paye
|
|
||||||
|
|
||||||
|
|
||||||
//print table headers for this quadri - incomes first
|
|
||||||
|
|
||||||
$x_coll_sum = 0;
|
|
||||||
$x_coll_ht = 0;
|
|
||||||
$x_paye_sum = 0;
|
|
||||||
$x_paye_ht = 0;
|
|
||||||
|
|
||||||
$span=$columns-3;
|
|
||||||
if ($modetax == 0) $span+=2;
|
|
||||||
|
|
||||||
//print '<tr><td colspan="'.($span+1).'">'..')</td></tr>';
|
|
||||||
|
|
||||||
// Customers invoices
|
|
||||||
print '<tr class="liste_titre">';
|
|
||||||
print '<td align="left">'.$elementcust.'</td>';
|
|
||||||
print '<td align="left">'.$langs->trans("Date").'</td>';
|
|
||||||
print '<td align="left">'.$namecust.'</td>';
|
|
||||||
print '<td align="left">'.$productcust.'</td>';
|
|
||||||
if ($modetax == 0) {
|
|
||||||
print '<td align="right">'.$amountcust.'</td>';
|
|
||||||
print '<td align="right">'.$langs->trans("Payment").' ('.$langs->trans("PercentOfInvoice").')</td>';
|
|
||||||
}
|
|
||||||
print '<td align="right">'.$langs->trans("AmountHTVATRealReceived").'</td>';
|
|
||||||
print '<td align="right">'.$vatcust.'</td>';
|
|
||||||
print '</tr>';
|
|
||||||
|
|
||||||
$action = "tvadetail";
|
|
||||||
$parameters["mode"] = $modetax;
|
|
||||||
$parameters["start"] = $date_start;
|
|
||||||
$parameters["end"] = $date_end;
|
|
||||||
$parameters["type"] = 'vat';
|
|
||||||
|
|
||||||
$object = array(&$x_coll, &$x_paye, &$x_both);
|
|
||||||
// Initialize technical object to manage hooks of expenses. Note that conf->hooks_modules contains array array
|
|
||||||
$hookmanager->initHooks(array('externalbalance'));
|
|
||||||
$reshook=$hookmanager->executeHooks('addVatLine',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
|
|
||||||
|
|
||||||
foreach (array_keys($x_coll) as $rate) {
|
|
||||||
$subtot_coll_total_ht = 0;
|
|
||||||
$subtot_coll_vat = 0;
|
|
||||||
|
|
||||||
if (is_array($x_both[$rate]['coll']['detail'])) {
|
|
||||||
// VAT Rate
|
|
||||||
$var=true;
|
|
||||||
print "<tr>";
|
|
||||||
print '<td class="tax_rate">'.$langs->trans("Rate").': '.vatrate($rate).'%</td><td colspan="'.$span.'"></td>';
|
|
||||||
print '</tr>'."\n";
|
|
||||||
|
|
||||||
foreach ($x_both[$rate]['coll']['detail'] as $index => $fields) {
|
|
||||||
// Define type
|
|
||||||
$type=($fields['dtype']?$fields['dtype']:$fields['ptype']);
|
|
||||||
// Try to enhance type detection using date_start and date_end for free lines where type
|
|
||||||
// was not saved.
|
|
||||||
if (!empty($fields['ddate_start'])) {
|
|
||||||
$type=1;
|
|
||||||
}
|
|
||||||
if (!empty($fields['ddate_end'])) {
|
|
||||||
$type=1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
print '<tr class="oddeven">';
|
|
||||||
|
|
||||||
// Ref
|
|
||||||
print '<td class="nowrap" align="left">'.$fields['link'].'</td>';
|
|
||||||
|
|
||||||
// Invoice date
|
|
||||||
print '<td align="left">' . $fields['datef'] . '</td>';
|
|
||||||
// Company name
|
|
||||||
print '<td align="left">' . $fields['company_link'] . '</td>';
|
|
||||||
|
|
||||||
// Description
|
|
||||||
print '<td align="left">';
|
|
||||||
if ($fields['pid']) {
|
|
||||||
$product_static->id=$fields['pid'];
|
|
||||||
$product_static->ref=$fields['pref'];
|
|
||||||
$product_static->type=$fields['ptype'];
|
|
||||||
print $product_static->getNomUrl(1);
|
|
||||||
if (dol_string_nohtmltag($fields['descr'])) {
|
|
||||||
print ' - '.dol_trunc(dol_string_nohtmltag($fields['descr']),16);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if ($type) {
|
|
||||||
$text = img_object($langs->trans('Service'),'service');
|
|
||||||
} else {
|
|
||||||
$text = img_object($langs->trans('Product'),'product');
|
|
||||||
}
|
|
||||||
if (preg_match('/^\((.*)\)$/',$fields['descr'],$reg)) {
|
|
||||||
if ($reg[1]=='DEPOSIT') {
|
|
||||||
$fields['descr']=$langs->transnoentitiesnoconv('Deposit');
|
|
||||||
} elseif ($reg[1]=='CREDIT_NOTE') {
|
|
||||||
$fields['descr']=$langs->transnoentitiesnoconv('CreditNote');
|
|
||||||
} else {
|
|
||||||
$fields['descr']=$langs->transnoentitiesnoconv($reg[1]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
print $text.' '.dol_trunc(dol_string_nohtmltag($fields['descr']),16);
|
|
||||||
|
|
||||||
// Show range
|
|
||||||
print_date_range($fields['ddate_start'],$fields['ddate_end']);
|
|
||||||
}
|
|
||||||
print '</td>';
|
|
||||||
|
|
||||||
// Total HT
|
|
||||||
if ($modetax == 0) {
|
|
||||||
print '<td class="nowrap" align="right">';
|
|
||||||
print price($fields['totalht']);
|
|
||||||
if (price2num($fields['ftotal_ttc'])) {
|
|
||||||
//print $fields['dtotal_ttc']."/".$fields['ftotal_ttc']." - ";
|
|
||||||
$ratiolineinvoice=($fields['dtotal_ttc']/$fields['ftotal_ttc']);
|
|
||||||
//print ' ('.round($ratiolineinvoice*100,2).'%)';
|
|
||||||
}
|
|
||||||
print '</td>';
|
|
||||||
}
|
|
||||||
|
|
||||||
// Payment
|
|
||||||
$ratiopaymentinvoice=1;
|
|
||||||
if ($modetax == 0) {
|
|
||||||
if (isset($fields['payment_amount']) && $fields['ftotal_ttc']) {
|
|
||||||
$ratiopaymentinvoice=($fields['payment_amount']/$fields['ftotal_ttc']);
|
|
||||||
}
|
|
||||||
print '<td class="nowrap" align="right">';
|
|
||||||
//print $fields['totalht']."-".$fields['payment_amount']."-".$fields['ftotal_ttc'];
|
|
||||||
if ($fields['payment_amount'] && $fields['ftotal_ttc']) {
|
|
||||||
$payment_static->id=$fields['payment_id'];
|
|
||||||
print $payment_static->getNomUrl(2);
|
|
||||||
}
|
|
||||||
if ($type == 0) {
|
|
||||||
print $langs->trans("NotUsedForGoods");
|
|
||||||
} else {
|
|
||||||
print $fields['payment_amount'];
|
|
||||||
if (isset($fields['payment_amount'])) {
|
|
||||||
print ' ('.round($ratiopaymentinvoice*100,2).'%)';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
print '</td>';
|
|
||||||
}
|
|
||||||
|
|
||||||
// Total collected
|
|
||||||
print '<td class="nowrap" align="right">';
|
|
||||||
$temp_ht=$fields['totalht'];
|
|
||||||
if ($type == 1) {
|
|
||||||
$temp_ht=$fields['totalht']*$ratiopaymentinvoice;
|
|
||||||
}
|
|
||||||
print price(price2num($temp_ht,'MT'),1);
|
|
||||||
print '</td>';
|
|
||||||
|
|
||||||
// VAT
|
|
||||||
print '<td class="nowrap" align="right">';
|
|
||||||
$temp_vat=$fields['vat'];
|
|
||||||
if ($type == 1) {
|
|
||||||
$temp_vat=$fields['vat']*$ratiopaymentinvoice;
|
|
||||||
}
|
|
||||||
print price(price2num($temp_vat,'MT'),1);
|
|
||||||
//print price($fields['vat']);
|
|
||||||
print '</td>';
|
|
||||||
print '</tr>';
|
|
||||||
|
|
||||||
$subtot_coll_total_ht += $temp_ht;
|
|
||||||
$subtot_coll_vat += $temp_vat;
|
|
||||||
$x_coll_sum += $temp_vat;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Total customers for this vat rate
|
|
||||||
print '<tr class="liste_total">';
|
|
||||||
print '<td colspan="'.$span.'"></td>';
|
|
||||||
print '<td align="right">'.$langs->trans("Total").':</td>';
|
|
||||||
if ($modetax == 0) {
|
|
||||||
print '<td class="nowrap" align="right"> </td>';
|
|
||||||
print '<td align="right"> </td>';
|
|
||||||
}
|
|
||||||
print '<td align="right">'.price(price2num($subtot_coll_total_ht,'MT')).'</td>';
|
|
||||||
print '<td class="nowrap" align="right">'.price(price2num($subtot_coll_vat,'MT')).'</td>';
|
|
||||||
print '</tr>';
|
|
||||||
}
|
|
||||||
|
|
||||||
if (count($x_coll) == 0) { // Show a total ine if nothing shown
|
|
||||||
print '<tr class="liste_total">';
|
|
||||||
print '<td colspan="'.$span.'"></td>';
|
|
||||||
print '<td align="right">'.$langs->trans("Total").':</td>';
|
|
||||||
if ($modetax == 0) {
|
|
||||||
print '<td class="nowrap" align="right"> </td>';
|
|
||||||
print '<td align="right"> </td>';
|
|
||||||
}
|
|
||||||
print '<td align="right">'.price(price2num(0,'MT')).'</td>';
|
|
||||||
print '<td class="nowrap" align="right">'.price(price2num(0,'MT')).'</td>';
|
|
||||||
print '</tr>';
|
|
||||||
}
|
|
||||||
|
|
||||||
// Blank line
|
|
||||||
print '<tr><td colspan="'.($span+1).'"> </td></tr>';
|
|
||||||
|
|
||||||
// Print table headers for this quadri - expenses now
|
|
||||||
print '<tr class="liste_titre">';
|
|
||||||
print '<td align="left">'.$elementsup.'</td>';
|
|
||||||
print '<td align="left">'.$langs->trans("Date").'</td>';
|
|
||||||
print '<td align="left">'.$namesup.'</td>';
|
|
||||||
print '<td align="left">'.$productsup.'</td>';
|
|
||||||
if ($modetax == 0) {
|
|
||||||
print '<td align="right">'.$amountsup.'</td>';
|
|
||||||
print '<td align="right">'.$langs->trans("Payment").' ('.$langs->trans("PercentOfInvoice").')</td>';
|
|
||||||
}
|
|
||||||
print '<td align="right">'.$langs->trans("AmountHTVATRealPaid").'</td>';
|
|
||||||
print '<td align="right">'.$vatsup.'</td>';
|
|
||||||
print '</tr>'."\n";
|
|
||||||
|
|
||||||
foreach (array_keys($x_paye) as $rate) {
|
|
||||||
$subtot_paye_total_ht = 0;
|
|
||||||
$subtot_paye_vat = 0;
|
|
||||||
|
|
||||||
if (is_array($x_both[$rate]['paye']['detail'])) {
|
|
||||||
$var=true;
|
|
||||||
print "<tr>";
|
|
||||||
print '<td class="tax_rate">'.$langs->trans("Rate").': '.vatrate($rate).'%</td><td colspan="'.$span.'"></td>';
|
|
||||||
print '</tr>'."\n";
|
|
||||||
|
|
||||||
foreach ($x_both[$rate]['paye']['detail'] as $index=>$fields) {
|
|
||||||
// Define type
|
|
||||||
$type=($fields['dtype']?$fields['dtype']:$fields['ptype']);
|
|
||||||
// Try to enhance type detection using date_start and date_end for free lines where type
|
|
||||||
// was not saved.
|
|
||||||
if (!empty($fields['ddate_start'])) {
|
|
||||||
$type=1;
|
|
||||||
}
|
|
||||||
if (!empty($fields['ddate_end'])) {
|
|
||||||
$type=1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
print '<tr class="oddeven">';
|
|
||||||
|
|
||||||
// Ref
|
|
||||||
print '<td class="nowrap" align="left">'.$fields['link'].'</td>';
|
|
||||||
// Invoice date
|
|
||||||
print '<td align="left">' . $fields['datef'] . '</td>';
|
|
||||||
// Company name
|
|
||||||
print '<td align="left">' . $fields['company_link'] . '</td>';
|
|
||||||
|
|
||||||
// Description
|
|
||||||
print '<td align="left">';
|
|
||||||
if ($fields['pid']) {
|
|
||||||
$product_static->id=$fields['pid'];
|
|
||||||
$product_static->ref=$fields['pref'];
|
|
||||||
$product_static->type=$fields['ptype'];
|
|
||||||
print $product_static->getNomUrl(1);
|
|
||||||
if (dol_string_nohtmltag($fields['descr'])) {
|
|
||||||
print ' - '.dol_trunc(dol_string_nohtmltag($fields['descr']),16);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if ($type) {
|
|
||||||
$text = img_object($langs->trans('Service'),'service');
|
|
||||||
} else {
|
|
||||||
$text = img_object($langs->trans('Product'),'product');
|
|
||||||
}
|
|
||||||
print $text.' '.dol_trunc(dol_string_nohtmltag($fields['descr']),16);
|
|
||||||
|
|
||||||
// Show range
|
|
||||||
print_date_range($fields['ddate_start'],$fields['ddate_end']);
|
|
||||||
}
|
|
||||||
print '</td>';
|
|
||||||
|
|
||||||
// Total HT
|
|
||||||
if ($modetax == 0) {
|
|
||||||
print '<td class="nowrap" align="right">';
|
|
||||||
print price($fields['totalht']);
|
|
||||||
if (price2num($fields['ftotal_ttc'])) {
|
|
||||||
//print $fields['dtotal_ttc']."/".$fields['ftotal_ttc']." - ";
|
|
||||||
$ratiolineinvoice=($fields['dtotal_ttc']/$fields['ftotal_ttc']);
|
|
||||||
//print ' ('.round($ratiolineinvoice*100,2).'%)';
|
|
||||||
}
|
|
||||||
print '</td>';
|
|
||||||
}
|
|
||||||
|
|
||||||
// Payment
|
|
||||||
$ratiopaymentinvoice=1;
|
|
||||||
if ($modetax == 0) {
|
|
||||||
if (isset($fields['payment_amount']) && $fields['ftotal_ttc']) {
|
|
||||||
$ratiopaymentinvoice=($fields['payment_amount']/$fields['ftotal_ttc']);
|
|
||||||
}
|
|
||||||
print '<td class="nowrap" align="right">';
|
|
||||||
if ($fields['payment_amount'] && $fields['ftotal_ttc']) {
|
|
||||||
$paymentfourn_static->id=$fields['payment_id'];
|
|
||||||
print $paymentfourn_static->getNomUrl(2);
|
|
||||||
}
|
|
||||||
if ($type == 0) {
|
|
||||||
print $langs->trans("NotUsedForGoods");
|
|
||||||
} else {
|
|
||||||
print $fields['payment_amount'];
|
|
||||||
if (isset($fields['payment_amount'])) {
|
|
||||||
print ' ('.round($ratiopaymentinvoice*100,2).'%)';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
print '</td>';
|
|
||||||
}
|
|
||||||
|
|
||||||
// VAT paid
|
|
||||||
print '<td class="nowrap" align="right">';
|
|
||||||
$temp_ht=$fields['totalht'];
|
|
||||||
if ($type == 1) {
|
|
||||||
$temp_ht=$fields['totalht']*$ratiopaymentinvoice;
|
|
||||||
}
|
|
||||||
print price(price2num($temp_ht,'MT'),1);
|
|
||||||
print '</td>';
|
|
||||||
|
|
||||||
// VAT
|
|
||||||
print '<td class="nowrap" align="right">';
|
|
||||||
$temp_vat=$fields['vat'];
|
|
||||||
if ($type == 1) {
|
|
||||||
$temp_vat=$fields['vat']*$ratiopaymentinvoice;
|
|
||||||
}
|
|
||||||
print price(price2num($temp_vat,'MT'),1);
|
|
||||||
//print price($fields['vat']);
|
|
||||||
print '</td>';
|
|
||||||
print '</tr>';
|
|
||||||
|
|
||||||
$subtot_paye_total_ht += $temp_ht;
|
|
||||||
$subtot_paye_vat += $temp_vat;
|
|
||||||
$x_paye_sum += $temp_vat;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Total suppliers for this vat rate
|
|
||||||
print '<tr class="liste_total">';
|
|
||||||
print '<td colspan="'.$span.'"></td>';
|
|
||||||
print '<td align="right">'.$langs->trans("Total").':</td>';
|
|
||||||
if ($modetax == 0) {
|
|
||||||
print '<td class="nowrap" align="right"> </td>';
|
|
||||||
print '<td align="right"> </td>';
|
|
||||||
}
|
|
||||||
print '<td align="right">'.price(price2num($subtot_paye_total_ht,'MT')).'</td>';
|
|
||||||
print '<td class="nowrap" align="right">'.price(price2num($subtot_paye_vat,'MT')).'</td>';
|
|
||||||
print '</tr>';
|
|
||||||
}
|
|
||||||
|
|
||||||
if (count($x_paye) == 0) { // Show a total line if nothing shown
|
|
||||||
print '<tr class="liste_total">';
|
|
||||||
print '<td colspan="'.$span.'"></td>';
|
|
||||||
print '<td align="right">'.$langs->trans("Total").':</td>';
|
|
||||||
if ($modetax == 0) {
|
|
||||||
print '<td class="nowrap" align="right"> </td>';
|
|
||||||
print '<td align="right"> </td>';
|
|
||||||
}
|
|
||||||
print '<td align="right">'.price(price2num(0,'MT')).'</td>';
|
|
||||||
print '<td class="nowrap" align="right">'.price(price2num(0,'MT')).'</td>';
|
|
||||||
print '</tr>';
|
|
||||||
}
|
|
||||||
|
|
||||||
print '</table>';
|
|
||||||
|
|
||||||
// Total to pay
|
|
||||||
print '<br><br>';
|
|
||||||
print '<table class="noborder" width="100%">';
|
|
||||||
$diff = $x_coll_sum - $x_paye_sum;
|
|
||||||
print '<tr class="liste_total">';
|
|
||||||
print '<td class="liste_total" colspan="'.$span.'">'.$langs->trans("TotalToPay").($q?', '.$langs->trans("Quadri").' '.$q:'').'</td>';
|
|
||||||
print '<td class="liste_total nowrap" align="right"><b>'.price(price2num($diff,'MT'))."</b></td>\n";
|
|
||||||
print "</tr>\n";
|
|
||||||
|
|
||||||
$i++;
|
|
||||||
}
|
|
||||||
print '</table>';
|
|
||||||
|
|
||||||
llxFooter();
|
|
||||||
$db->close();
|
|
||||||
@ -237,11 +237,12 @@ function tax_by_date($type, $db, $y, $q, $date_start, $date_end, $modetax, $dire
|
|||||||
$total_localtax1='total_localtax1';
|
$total_localtax1='total_localtax1';
|
||||||
$total_localtax2='total_localtax2';
|
$total_localtax2='total_localtax2';
|
||||||
|
|
||||||
// CAS DES BIENS
|
// CAS DES BIENS/PRODUITS
|
||||||
|
|
||||||
// Define sql request
|
// Define sql request
|
||||||
$sql='';
|
$sql='';
|
||||||
if ($modetax == 1) // Option vat on delivery for goods (payment) and debit invoice for services
|
if (($direction == 'sell' && $conf->global->TAX_MODE_SELL_PRODUCT == 'invoice')
|
||||||
|
|| ($direction == 'buy' && $conf->global->TAX_MODE_BUY_PRODUCT == 'invoice'))
|
||||||
{
|
{
|
||||||
// Count on delivery date (use invoice date as delivery is unknown)
|
// Count on delivery date (use invoice date as delivery is unknown)
|
||||||
$sql = "SELECT d.rowid, d.product_type as dtype, d.".$fk_facture." as facid, d.$f_rate as rate, d.total_ht as total_ht, d.total_ttc as total_ttc, d.".$total_tva." as total_vat, d.description as descr,";
|
$sql = "SELECT d.rowid, d.product_type as dtype, d.".$fk_facture." as facid, d.$f_rate as rate, d.total_ht as total_ht, d.total_ttc as total_ttc, d.".$total_tva." as total_vat, d.description as descr,";
|
||||||
@ -273,44 +274,48 @@ function tax_by_date($type, $db, $y, $q, $date_start, $date_end, $modetax, $dire
|
|||||||
if ($q) $sql.= " AND (date_format(f.datef,'%m') > ".(($q-1)*3)." AND date_format(f.datef,'%m') <= ".($q*3).")";
|
if ($q) $sql.= " AND (date_format(f.datef,'%m') > ".(($q-1)*3)." AND date_format(f.datef,'%m') <= ".($q*3).")";
|
||||||
if ($date_start && $date_end) $sql.= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'";
|
if ($date_start && $date_end) $sql.= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'";
|
||||||
$sql.= " AND (d.product_type = 0"; // Limit to products
|
$sql.= " AND (d.product_type = 0"; // Limit to products
|
||||||
$sql.= " AND d.date_start is null AND d.date_end IS NULL)"; // enhance detection of service
|
$sql.= " AND d.date_start is null AND d.date_end IS NULL)"; // enhance detection of products
|
||||||
$sql.= " ORDER BY d.rowid, d.".$fk_facture;
|
$sql.= " ORDER BY d.rowid, d.".$fk_facture;
|
||||||
}
|
}
|
||||||
else // Option vat on delivery for goods (payments) and payments for services
|
else
|
||||||
{
|
{
|
||||||
// Count on delivery date (use invoice date as delivery is unknown)
|
// Count on payments date
|
||||||
$sql = "SELECT d.rowid, d.product_type as dtype, d.".$fk_facture." as facid, d.$f_rate as rate, d.total_ht as total_ht, d.total_ttc as total_ttc, d.".$total_tva." as total_vat, d.description as descr,";
|
$sql = "SELECT d.rowid, d.product_type as dtype, d.".$fk_facture." as facid, d.$f_rate as rate, d.total_ht as total_ht, d.total_ttc as total_ttc, d.".$total_tva." as total_vat, d.description as descr,";
|
||||||
$sql .=" d.".$total_localtax1." as total_localtax1, d.".$total_localtax2." as total_localtax2, ";
|
$sql .=" d.".$total_localtax1." as total_localtax1, d.".$total_localtax2." as total_localtax2, ";
|
||||||
$sql.= " d.date_start as date_start, d.date_end as date_end,";
|
$sql.= " d.date_start as date_start, d.date_end as date_end,";
|
||||||
$sql.= " f.".$invoicefieldref." as facnum, f.type, f.total_ttc as ftotal_ttc, f.datef as date_f, s.nom as company_name, s.rowid as company_id,";
|
$sql.= " f.".$invoicefieldref." as facnum, f.type, f.total_ttc as ftotal_ttc, f.datef, s.nom as company_name, s.rowid as company_id,";
|
||||||
$sql.= " p.rowid as pid, p.ref as pref, p.fk_product_type as ptype,";
|
$sql.= " p.rowid as pid, p.ref as pref, p.fk_product_type as ptype,";
|
||||||
$sql.= " 0 as payment_id, 0 as payment_amount";
|
$sql.= " pf.".$fk_payment." as payment_id, pf.amount as payment_amount,";
|
||||||
|
$sql.= " pa.datep as datep";
|
||||||
$sql.= " FROM ".MAIN_DB_PREFIX.$invoicetable." as f,";
|
$sql.= " FROM ".MAIN_DB_PREFIX.$invoicetable." as f,";
|
||||||
|
$sql.= " ".MAIN_DB_PREFIX.$paymentfacturetable." as pf,";
|
||||||
|
$sql.= " ".MAIN_DB_PREFIX.$paymenttable." as pa,";
|
||||||
$sql.= " ".MAIN_DB_PREFIX."societe as s,";
|
$sql.= " ".MAIN_DB_PREFIX."societe as s,";
|
||||||
$sql.= " ".MAIN_DB_PREFIX.$invoicedettable." as d" ;
|
$sql.= " ".MAIN_DB_PREFIX.$invoicedettable." as d";
|
||||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p on d.fk_product = p.rowid";
|
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p on d.fk_product = p.rowid";
|
||||||
$sql.= " WHERE f.entity = " . $conf->entity;
|
$sql.= " WHERE f.entity = " . $conf->entity;
|
||||||
$sql.= " AND f.fk_statut in (1,2)"; // Validated or paid (partially or completely)
|
$sql.= " AND f.fk_statut in (1,2)"; // Paid (partially or completely)
|
||||||
if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $sql.= " AND f.type IN (0,1,2,5)";
|
if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $sql.= " AND f.type IN (0,1,2,5)";
|
||||||
else $sql.= " AND f.type IN (0,1,2,3,5)";
|
else $sql.= " AND f.type IN (0,1,2,3,5)";
|
||||||
$sql.= " AND f.rowid = d.".$fk_facture;
|
$sql.= " AND f.rowid = d.".$fk_facture;
|
||||||
$sql.= " AND s.rowid = f.fk_soc";
|
$sql.= " AND s.rowid = f.fk_soc";
|
||||||
|
$sql.= " AND pf.".$fk_facture2." = f.rowid";
|
||||||
|
$sql.= " AND pa.rowid = pf.".$fk_payment;
|
||||||
if ($y && $m)
|
if ($y && $m)
|
||||||
{
|
{
|
||||||
$sql.= " AND f.datef >= '".$db->idate(dol_get_first_day($y,$m,false))."'";
|
$sql.= " AND pa.datep >= '".$db->idate(dol_get_first_day($y,$m,false))."'";
|
||||||
$sql.= " AND f.datef <= '".$db->idate(dol_get_last_day($y,$m,false))."'";
|
$sql.= " AND pa.datep <= '".$db->idate(dol_get_last_day($y,$m,false))."'";
|
||||||
}
|
}
|
||||||
else if ($y)
|
else if ($y)
|
||||||
{
|
{
|
||||||
$sql.= " AND f.datef >= '".$db->idate(dol_get_first_day($y,1,false))."'";
|
$sql.= " AND pa.datep >= '".$db->idate(dol_get_first_day($y,1,false))."'";
|
||||||
$sql.= " AND f.datef <= '".$db->idate(dol_get_last_day($y,12,false))."'";
|
$sql.= " AND pa.datep <= '".$db->idate(dol_get_last_day($y,12,false))."'";
|
||||||
}
|
}
|
||||||
if ($q) $sql.= " AND (date_format(f.datef,'%m') > ".(($q-1)*3)." AND date_format(f.datef,'%m') <= ".($q*3).")";
|
if ($q) $sql.= " AND (date_format(pa.datep,'%m') > ".(($q-1)*3)." AND date_format(pa.datep,'%m') <= ".($q*3).")";
|
||||||
if ($date_start && $date_end) $sql.= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'";
|
if ($date_start && $date_end) $sql.= " AND pa.datep >= '".$db->idate($date_start)."' AND pa.datep <= '".$db->idate($date_end)."'";
|
||||||
$sql.= " AND (d.product_type = 0"; // Limit to products
|
$sql.= " AND (d.product_type = 0"; // Limit to products
|
||||||
$sql.= " AND d.date_start is null AND d.date_end IS NULL)"; // enhance detection of service
|
$sql.= " AND d.date_start is null AND d.date_end IS NULL)"; // enhance detection of products
|
||||||
$sql.= " ORDER BY d.rowid, d.".$fk_facture;
|
$sql.= " ORDER BY d.rowid, d.".$fk_facture.", pf.rowid";
|
||||||
//print $sql;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//print $sql.'<br>';
|
//print $sql.'<br>';
|
||||||
@ -342,7 +347,8 @@ function tax_by_date($type, $db, $y, $q, $date_start, $date_end, $modetax, $dire
|
|||||||
}
|
}
|
||||||
$list[$assoc['rate']]['dtotal_ttc'][] = $assoc['total_ttc'];
|
$list[$assoc['rate']]['dtotal_ttc'][] = $assoc['total_ttc'];
|
||||||
$list[$assoc['rate']]['dtype'][] = $assoc['dtype'];
|
$list[$assoc['rate']]['dtype'][] = $assoc['dtype'];
|
||||||
$list[$assoc['rate']]['datef'][] = $assoc['datef'];
|
$list[$assoc['rate']]['datef'][] = $db->jdate($assoc['datef']);
|
||||||
|
$list[$assoc['rate']]['datep'][] = $db->jdate($assoc['datep']);
|
||||||
$list[$assoc['rate']]['company_name'][] = $assoc['company_name'];
|
$list[$assoc['rate']]['company_name'][] = $assoc['company_name'];
|
||||||
$list[$assoc['rate']]['company_id'][] = $assoc['company_id'];
|
$list[$assoc['rate']]['company_id'][] = $assoc['company_id'];
|
||||||
$list[$assoc['rate']]['ddate_start'][] = $db->jdate($assoc['date_start']);
|
$list[$assoc['rate']]['ddate_start'][] = $db->jdate($assoc['date_start']);
|
||||||
@ -381,7 +387,8 @@ function tax_by_date($type, $db, $y, $q, $date_start, $date_end, $modetax, $dire
|
|||||||
|
|
||||||
// Define sql request
|
// Define sql request
|
||||||
$sql='';
|
$sql='';
|
||||||
if ($modetax == 1) // Option vat on delivery for goods (payment) and debit invoice for services
|
if (($direction == 'sell' && $conf->global->TAX_MODE_SELL_SERVICE == 'invoice')
|
||||||
|
|| ($direction == 'buy' && $conf->global->TAX_MODE_BUY_SERVICE == 'invoice'))
|
||||||
{
|
{
|
||||||
// Count on invoice date
|
// Count on invoice date
|
||||||
$sql = "SELECT d.rowid, d.product_type as dtype, d.".$fk_facture." as facid, d.$f_rate as rate, d.total_ht as total_ht, d.total_ttc as total_ttc, d.".$total_tva." as total_vat, d.description as descr,";
|
$sql = "SELECT d.rowid, d.product_type as dtype, d.".$fk_facture." as facid, d.$f_rate as rate, d.total_ht as total_ht, d.total_ttc as total_ttc, d.".$total_tva." as total_vat, d.description as descr,";
|
||||||
@ -416,7 +423,7 @@ function tax_by_date($type, $db, $y, $q, $date_start, $date_end, $modetax, $dire
|
|||||||
$sql.= " OR d.date_start is NOT null OR d.date_end IS NOT NULL)"; // enhance detection of service
|
$sql.= " OR d.date_start is NOT null OR d.date_end IS NOT NULL)"; // enhance detection of service
|
||||||
$sql.= " ORDER BY d.rowid, d.".$fk_facture;
|
$sql.= " ORDER BY d.rowid, d.".$fk_facture;
|
||||||
}
|
}
|
||||||
else // Option vat on delivery for goods (payments) and payments for services
|
else
|
||||||
{
|
{
|
||||||
// Count on payments date
|
// Count on payments date
|
||||||
$sql = "SELECT d.rowid, d.product_type as dtype, d.".$fk_facture." as facid, d.$f_rate as rate, d.total_ht as total_ht, d.total_ttc as total_ttc, d.".$total_tva." as total_vat, d.description as descr,";
|
$sql = "SELECT d.rowid, d.product_type as dtype, d.".$fk_facture." as facid, d.$f_rate as rate, d.total_ht as total_ht, d.total_ttc as total_ttc, d.".$total_tva." as total_vat, d.description as descr,";
|
||||||
@ -424,7 +431,8 @@ function tax_by_date($type, $db, $y, $q, $date_start, $date_end, $modetax, $dire
|
|||||||
$sql.= " d.date_start as date_start, d.date_end as date_end,";
|
$sql.= " d.date_start as date_start, d.date_end as date_end,";
|
||||||
$sql.= " f.".$invoicefieldref." as facnum, f.type, f.total_ttc as ftotal_ttc, f.datef, s.nom as company_name, s.rowid as company_id,";
|
$sql.= " f.".$invoicefieldref." as facnum, f.type, f.total_ttc as ftotal_ttc, f.datef, s.nom as company_name, s.rowid as company_id,";
|
||||||
$sql.= " p.rowid as pid, p.ref as pref, p.fk_product_type as ptype,";
|
$sql.= " p.rowid as pid, p.ref as pref, p.fk_product_type as ptype,";
|
||||||
$sql.= " pf.".$fk_payment." as payment_id, pf.amount as payment_amount";
|
$sql.= " pf.".$fk_payment." as payment_id, pf.amount as payment_amount,";
|
||||||
|
$sql.= " pa.datep as datep";
|
||||||
$sql.= " FROM ".MAIN_DB_PREFIX.$invoicetable." as f,";
|
$sql.= " FROM ".MAIN_DB_PREFIX.$invoicetable." as f,";
|
||||||
$sql.= " ".MAIN_DB_PREFIX.$paymentfacturetable." as pf,";
|
$sql.= " ".MAIN_DB_PREFIX.$paymentfacturetable." as pf,";
|
||||||
$sql.= " ".MAIN_DB_PREFIX.$paymenttable." as pa,";
|
$sql.= " ".MAIN_DB_PREFIX.$paymenttable." as pa,";
|
||||||
@ -487,7 +495,8 @@ function tax_by_date($type, $db, $y, $q, $date_start, $date_end, $modetax, $dire
|
|||||||
}
|
}
|
||||||
$list[$assoc['rate']]['dtotal_ttc'][] = $assoc['total_ttc'];
|
$list[$assoc['rate']]['dtotal_ttc'][] = $assoc['total_ttc'];
|
||||||
$list[$assoc['rate']]['dtype'][] = $assoc['dtype'];
|
$list[$assoc['rate']]['dtype'][] = $assoc['dtype'];
|
||||||
$list[$assoc['rate']]['datef'][] = $assoc['datef'];
|
$list[$assoc['rate']]['datef'][] = $db->jdate($assoc['datef']);
|
||||||
|
$list[$assoc['rate']]['datep'][] = $db->jdate($assoc['datep']);
|
||||||
$list[$assoc['rate']]['company_name'][] = $assoc['company_name'];
|
$list[$assoc['rate']]['company_name'][] = $assoc['company_name'];
|
||||||
$list[$assoc['rate']]['company_id'][] = $assoc['company_id'];
|
$list[$assoc['rate']]['company_id'][] = $assoc['company_id'];
|
||||||
$list[$assoc['rate']]['ddate_start'][] = $db->jdate($assoc['date_start']);
|
$list[$assoc['rate']]['ddate_start'][] = $db->jdate($assoc['date_start']);
|
||||||
|
|||||||
@ -166,22 +166,20 @@ DepositsAreNotIncluded=- Down payment invoices are nor included
|
|||||||
DepositsAreIncluded=- Down payment invoices are included
|
DepositsAreIncluded=- Down payment invoices are included
|
||||||
LT2ReportByCustomersInInputOutputModeES=Report by third party IRPF
|
LT2ReportByCustomersInInputOutputModeES=Report by third party IRPF
|
||||||
LT1ReportByCustomersInInputOutputModeES=Report by third party RE
|
LT1ReportByCustomersInInputOutputModeES=Report by third party RE
|
||||||
VATReport=VAT report
|
VATReport=Sale tax report
|
||||||
|
VATReportByPeriods=Sale tax report by period
|
||||||
VATReportByCustomersInInputOutputMode=Report by the customer VAT collected and paid
|
VATReportByCustomersInInputOutputMode=Report by the customer VAT collected and paid
|
||||||
VATReportByCustomersInDueDebtMode=Report by the customer VAT collected and paid
|
VATReportByQuartersInInputOutputMode=Report by Sale tax rate of the tax collected and paid
|
||||||
VATReportByQuartersInInputOutputMode=Report by rate of the VAT collected and paid
|
|
||||||
LT1ReportByQuartersInInputOutputMode=Report by RE rate
|
LT1ReportByQuartersInInputOutputMode=Report by RE rate
|
||||||
LT2ReportByQuartersInInputOutputMode=Report by IRPF rate
|
LT2ReportByQuartersInInputOutputMode=Report by IRPF rate
|
||||||
VATReportByQuartersInDueDebtMode=Report by rate of the VAT collected and paid
|
|
||||||
LT1ReportByQuartersInDueDebtMode=Report by RE rate
|
|
||||||
LT2ReportByQuartersInDueDebtMode=Report by IRPF rate
|
|
||||||
SeeVATReportInInputOutputMode=See report <b>%sVAT encasement%s</b> for a standard calculation
|
SeeVATReportInInputOutputMode=See report <b>%sVAT encasement%s</b> for a standard calculation
|
||||||
SeeVATReportInDueDebtMode=See report <b>%sVAT on flow%s</b> for a calculation with an option on the flow
|
SeeVATReportInDueDebtMode=See report <b>%sVAT on flow%s</b> for a calculation with an option on the flow
|
||||||
RulesVATInServices=- For services, the report includes the VAT regulations actually received or issued on the basis of the date of payment.
|
RulesVATInServices=- For services, the report includes the VAT regulations actually received or issued on the basis of the date of payment.
|
||||||
RulesVATInProducts=- For material assets, it includes the VAT invoices on the basis of the invoice date.
|
RulesVATInProducts=- For material assets, the report includes the VAT received or issued on the basis of the date of payment.
|
||||||
RulesVATDueServices=- For services, the report includes VAT invoices due, paid or not, based on the invoice date.
|
RulesVATDueServices=- For services, the report includes VAT invoices due, paid or not, based on the invoice date.
|
||||||
RulesVATDueProducts=- For material assets, it includes the VAT invoices, based on the invoice date.
|
RulesVATDueProducts=- For material assets, the report includes the VAT invoices, based on the invoice date.
|
||||||
OptionVatInfoModuleComptabilite=Note: For material assets, it should use the date of delivery to be more fair.
|
OptionVatInfoModuleComptabilite=Note: For material assets, it should use the date of delivery to be more fair.
|
||||||
|
ThisIsAnEstimatedValue=This is a preview, based on business events and not from the final ledger table, so final results may differ from this preview values
|
||||||
PercentOfInvoice=%%/invoice
|
PercentOfInvoice=%%/invoice
|
||||||
NotUsedForGoods=Not used on goods
|
NotUsedForGoods=Not used on goods
|
||||||
ProposalStats=Statistics on proposals
|
ProposalStats=Statistics on proposals
|
||||||
|
|||||||
@ -43,6 +43,7 @@ Individual=Individu privé
|
|||||||
ToCreateContactWithSameName=Crée automatiquement un contact/adresse, sous le tiers, avec la même information que le tiers. Dans la plupart des cas, même si votre tiers est une personne physique, la création d'un tiers seul suffit.
|
ToCreateContactWithSameName=Crée automatiquement un contact/adresse, sous le tiers, avec la même information que le tiers. Dans la plupart des cas, même si votre tiers est une personne physique, la création d'un tiers seul suffit.
|
||||||
ParentCompany=Maison mère
|
ParentCompany=Maison mère
|
||||||
Subsidiaries=Filiales
|
Subsidiaries=Filiales
|
||||||
|
ReportByMonth=Rapport par mois
|
||||||
ReportByCustomers=Rapport par client
|
ReportByCustomers=Rapport par client
|
||||||
ReportByQuarter=Rapport par taux
|
ReportByQuarter=Rapport par taux
|
||||||
CivilityCode=Code civilité
|
CivilityCode=Code civilité
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user