diff --git a/htdocs/compta/localtax/clients.php b/htdocs/compta/localtax/clients.php
index 70d52c3d9d3..3dc3e2777c2 100644
--- a/htdocs/compta/localtax/clients.php
+++ b/htdocs/compta/localtax/clients.php
@@ -28,15 +28,12 @@ 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/localtax/class/localtax.class.php';
-$langs->load("bills");
-$langs->load("compta");
-$langs->load("companies");
-$langs->load("products");
+$langs->loadLangs(array("other","compta","banks","bills","companies","product","trips","admin"));
$local=GETPOST('localTaxType', 'int');
// Date range
-$year=GETPOST("year");
+$year=GETPOST("year","int");
if (empty($year))
{
$year_current = strftime("%Y",dol_now());
@@ -45,43 +42,48 @@ if (empty($year))
$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"]);
+$date_start=dol_mktime(0,0,0,GETPOST("date_startmonth"),GETPOST("date_startday"),GETPOST("date_startyear"));
+$date_end=dol_mktime(23,59,59,GETPOST("date_endmonth"),GETPOST("date_endday"),GETPOST("date_endyear"));
// Quarter
if (empty($date_start) || empty($date_end)) // We define date_start and date_end
{
$q=GETPOST("q");
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); }
+ if (GETPOST("month")) { $date_start=dol_get_first_day($year_start,GETPOST("month"),false); $date_end=dol_get_last_day($year_start,GETPOST("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;
+ $date_start=dol_get_first_day($year_start,empty($conf->global->SOCIETE_FISCAL_MONTH_START)?1:$conf->global->SOCIETE_FISCAL_MONTH_START,false);
+ if (empty($conf->global->MAIN_INFO_VAT_RETURN) || $conf->global->MAIN_INFO_VAT_RETURN == 2) $date_end=dol_time_plus_duree($date_start, 3, 'm') - 1;
+ else if ($conf->global->MAIN_INFO_VAT_RETURN == 3) $date_end=dol_time_plus_duree($date_start, 1, 'y') - 1;
+ else if ($conf->global->MAIN_INFO_VAT_RETURN == 1) $date_end=dol_time_plus_duree($date_start, 1, 'm') - 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); }
+ else
+ {
+ 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");
+$min = price2num(GETPOST("min","alpha"));
if (empty($min)) $min = 0;
// Define modetax (0 or 1)
-// 0=normal, 1=option vat for services is on debit
+// 0=normal, 1=option vat for services is on debit, 2=option on payments for products
$modetax = $conf->global->TAX_MODE;
-if (isset($_REQUEST["modetax"])) $modetax=$_REQUEST["modetax"];
+if (GETPOSTISSET("modetax")) $modetax=GETPOST("modetax",'int');
+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
*/
@@ -98,6 +100,9 @@ foreach($listofparams as $param)
llxHeader('','','','',0,0,'','',$morequerystring);
+
+$name=$langs->transcountry($local==1?"LT1ReportByCustomers":"LT2ReportByCustomers", $mysoc->country_code);
+
$fsearch.=' ';
$fsearch.=' ';
$fsearch.=' ';
@@ -108,7 +113,6 @@ $calc=$conf->global->MAIN_INFO_LOCALTAX_CALC.$local;
// Affiche en-tete du rapport
if ($calc==0 || $calc==1) // Calculate on invoice for goods and services
{
- $nom=$langs->transcountry($local==1?"LT1ReportByCustomersInInputOutputMode":"LT2ReportByCustomersInInputOutputMode",$mysoc->country_code);
$calcmode=$calc==0?$langs->trans("CalcModeLT".$local):$langs->trans("CalcModeLT".$local."Rec");
$calcmode.=' ('.$langs->trans("TaxModuleSetupToModifyRulesLT",DOL_URL_ROOT.'/admin/company.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);
@@ -126,7 +130,6 @@ if ($calc==0 || $calc==1) // Calculate on invoice for goods and services
}
if ($calc==2) // Invoice for goods, payment for services
{
- $nom=$langs->transcountry($local==1?"LT1ReportByCustomersInInputOutputMode":"LT2ReportByCustomersInInputOutputMode",$mysoc->country_code);
$calcmode=$langs->trans("CalcModeLT2Debt");
$calcmode.=' ('.$langs->trans("TaxModuleSetupToModifyRulesLT",DOL_URL_ROOT.'/admin/company.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);
diff --git a/htdocs/compta/localtax/index.php b/htdocs/compta/localtax/index.php
index cfcb117b0a8..39d8a1dfa6a 100644
--- a/htdocs/compta/localtax/index.php
+++ b/htdocs/compta/localtax/index.php
@@ -25,32 +25,58 @@
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.'/compta/tva/class/tva.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
+require_once DOL_DOCUMENT_ROOT.'/compta/tva/class/tva.class.php';
-$langs->loadLangs(array("other","compta","banks","bills","companies"));
+$langs->loadLangs(array("other","compta","banks","bills","companies","product","trips","admin"));
$localTaxType=GETPOST('localTaxType', 'int');
+// Date range
$year=GETPOST("year","int");
-if ($year == 0)
+if (empty($year))
{
- $year_current = strftime("%Y",time());
- $year_start = $year_current;
+ $year_current = strftime("%Y",dol_now());
+ $year_start = $year_current;
} else {
- $year_current = $year;
- $year_start = $year;
+ $year_current = $year;
+ $year_start = $year;
+}
+$date_start=dol_mktime(0,0,0,GETPOST("date_startmonth"),GETPOST("date_startday"),GETPOST("date_startyear"));
+$date_end=dol_mktime(23,59,59,GETPOST("date_endmonth"),GETPOST("date_endday"),GETPOST("date_endyear"));
+// Quarter
+if (empty($date_start) || empty($date_end)) // We define date_start and date_end
+{
+ $q=GETPOST("q");
+ if (empty($q))
+ {
+ if (GETPOST("month")) { $date_start=dol_get_first_day($year_start,GETPOST("month"),false); $date_end=dol_get_last_day($year_start,GETPOST("month"),false); }
+ else
+ {
+ $date_start=dol_get_first_day($year_start, $conf->global->SOCIETE_FISCAL_MONTH_START,false);
+ $date_end=dol_time_plus_duree($date_start, 1, 'y') - 1;
+ }
+ }
+ else
+ {
+ 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); }
+ }
}
+// Define modetax (0 or 1)
+// 0=normal, 1=option vat for services is on debit, 2=option on payments for products
+$modetax = $conf->global->TAX_MODE;
+if (GETPOSTISSET("modetax")) $modetax=GETPOST("modetax",'int');
+if (empty($modetax)) $modetax=0;
+
// Security check
-$socid = isset($_GET["socid"])?$_GET["socid"]:'';
+$socid = GETPOST('socid','int');
if ($user->societe_id) $socid=$user->societe_id;
$result = restrictedArea($user, 'tax', '', '', 'charges');
-// Define modetax (0 or 1)
-// 0=normal, 1=option vat for services is on debit
-$modetax = $conf->global->TAX_MODE;
-if (isset($_GET["modetax"])) $modetax=GETPOST("modetax",'alpha');
/**
* print function
@@ -103,6 +129,8 @@ function pt ($db, $sql, $date)
* View
*/
+$form=new Form($db);
+$company_static=new Societe($db);
$tva = new Tva($db);
if($localTaxType==1) {
@@ -121,34 +149,35 @@ if($localTaxType==1) {
$CalcLT= $conf->global->MAIN_INFO_LOCALTAX_CALC2;
}
+$description = '';
+// Show report header
$name = $langs->trans("ReportByMonth");
$description = $langs->trans($LT);
$calcmode = $langs->trans("LTReportBuildWithOptionDefinedInModule").' ';
$calcmode.= '('.$langs->trans("TaxModuleSetupToModifyRulesLT",DOL_URL_ROOT.'/admin/company.php').') ';
+
+//if (! empty($conf->global->MAIN_MODULE_ACCOUNTING)) $description.=' '.$langs->trans("ThisIsAnEstimatedValue");
+
+$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);
+
$builddate=dol_now();
+
llxHeader('', $name);
-$textprevyear="".img_previous()." ";
-$textnextyear=" ".img_next()." ";
-
+//$textprevyear="".img_previous()." ";
+//$textnextyear=" ".img_next()." ";
//print load_fiche_titre($langs->transcountry($LT,$mysoc->country_code),"$textprevyear ".$langs->trans("Year")." $year_start $textnextyear", 'title_accountancy.png');
-report_header($name,'',$textprevyear.$langs->trans("Year")." ".$year_start.$textnextyear,'',$description,$builddate,$exportlink,array(),$calcmode);
+report_header($name,'',$period,$periodlink,$description,$builddate,$exportlink,array(),$calcmode);
+//report_header($name,'',$textprevyear.$langs->trans("Year")." ".$year_start.$textnextyear,'',$description,$builddate,$exportlink,array(),$calcmode);
print ' ';
-//print load_fiche_titre($langs->trans("Summary"), '', '');
+print '
';
-print '
';
-print '';
print load_fiche_titre($langs->transcountry($LTSummary,$mysoc->country_code), '', '');
-print ' ';
-print load_fiche_titre($langs->transcountry($LTPaid,$mysoc->country_code), '', '');
-print ' ';
-
-print '';
print '';
print '';
@@ -163,16 +192,26 @@ if($CalcLT==1) {
if($CalcLT==2) {
print "".$langs->transcountry($LTCustomer,$mysoc->country_code)." ";
}
-
print "".$langs->trans("TotalToPay")." ";
print " \n";
print " \n";
-$y = $year_current ;
+$tmp=dol_getdate($date_start);
+$y = $tmp['year'];
+$m = $tmp['mon'];
+$tmp=dol_getdate($date_end);
+$yend = $tmp['year'];
+$mend = $tmp['mon'];
$total=0; $subtotalcoll=0; $subtotalpaye=0; $subtotal=0;
-$i=0;
-for ($m = 1 ; $m < 13 ; $m++ ) {
+$i=0; $mcursor=0;
+while ((($y < $yend) || ($y == $yend && $m < $mend)) && $mcursor < 1000) // $mcursor is to avoid too large loop
+{
+ $m = $conf->global->SOCIETE_FISCAL_MONTH_START + ($mcursor % 12);
+ if ($m == 13) $y++;
+ if ($m > 12) $m -= 12;
+ $mcursor++;
+
$coll_listsell = tax_by_date('vat', $db, $y, 0, 0, 0, $modetax, 'sell', $m);
$coll_listbuy = tax_by_date('vat', $db, $y, 0, 0, 0, $modetax, 'buy', $m);
@@ -187,20 +226,23 @@ for ($m = 1 ; $m < 13 ; $m++ ) {
$hookmanager->initHooks(array('externalbalance'));
$reshook=$hookmanager->executeHooks('addVatLine',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
- if (! is_array($coll_listbuy) && $coll_listbuy == -1) {
+ if (! is_array($coll_listbuy) && $coll_listbuy == -1)
+ {
$langs->load("errors");
print ''.$langs->trans("ErrorNoAccountancyModuleLoaded").' ';
break;
}
- if (! is_array($coll_listbuy) && $coll_listbuy == -2) {
+ if (! is_array($coll_listbuy) && $coll_listbuy == -2)
+ {
print ''.$langs->trans("FeatureNotYetAvailable").' ';
break;
}
print '';
- print ''.dol_print_date(dol_mktime(0,0,0,$m,1,$y),"%b %Y").' ';
- if($CalcLT==0) {
+ print ''.dol_print_date(dol_mktime(0,0,0,$m,1,$y),"%b %Y").' ';
+
+ if ($CalcLT==0) {
$x_coll = 0;
foreach($coll_listsell as $vatrate=>$val) {
$x_coll+=$val[$localTaxType==1?'localtax1':'localtax2'];
@@ -247,7 +289,8 @@ for ($m = 1 ; $m < 13 ; $m++ ) {
print " \n";
$i++;
- if ($i > 2) {
+ if ($i > 2)
+ {
print '';
print ''.$langs->trans("SubTotal").': ';
if($CalcLT==0) {
@@ -272,7 +315,10 @@ print ' ';
print '
';
-print ' ';
+
+print '';
+
+print load_fiche_titre($langs->transcountry($LTPaid,$mysoc->country_code), '', '');
/*
* Payed
@@ -281,18 +327,18 @@ print '
';
$sql = "SELECT SUM(amount) as mm, date_format(f.datev,'%Y-%m') as dm";
$sql.= " FROM ".MAIN_DB_PREFIX."localtax as f";
$sql.= " WHERE f.entity = ".$conf->entity;
-$sql.= " AND f.datev >= '".$db->idate(dol_get_first_day($y,1,false))."'";
-$sql.= " AND f.datev <= '".$db->idate(dol_get_last_day($y,12,false))."'";
+$sql.= " AND f.datev >= '".$db->idate($date_start)."'";
+$sql.= " AND f.datev <= '".$db->idate($date_end)."'";
$sql.= " AND localtaxtype=".$localTaxType;
$sql.= " GROUP BY dm";
$sql.= " ORDER BY dm ASC";
pt($db, $sql,$langs->trans("Year")." $y");
-print '
';
+print '
';
+
+print '
';
-print '';
-print '';
llxFooter();
$db->close();
diff --git a/htdocs/compta/localtax/list.php b/htdocs/compta/localtax/list.php
index 54183ef72b9..50bc87d4d27 100644
--- a/htdocs/compta/localtax/list.php
+++ b/htdocs/compta/localtax/list.php
@@ -16,7 +16,7 @@
*/
/**
- * \file htdocs/compta/localtax/reglement.php
+ * \file htdocs/compta/localtax/list.php
* \ingroup tax
* \brief List of IRPF payments
*/
@@ -24,15 +24,15 @@
require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/compta/localtax/class/localtax.class.php';
-$langs->load("compta");
$langs->load("compta");
// Security check
-$socid = isset($_GET["socid"])?$_GET["socid"]:'';
+$socid = GETPOST('socid','int');
if ($user->societe_id) $socid=$user->societe_id;
$result = restrictedArea($user, 'tax', '', '', 'charges');
$ltt=GETPOST("localTaxType");
+
/*
* View
*/
@@ -41,7 +41,13 @@ llxHeader();
$localtax_static = new Localtax($db);
-print load_fiche_titre($langs->transcountry($ltt==2?"LT2Payments":"LT1Payments",$mysoc->country_code));
+$newcardbutton='';
+if ($user->rights->tax->charges->creer)
+{
+ $newcardbutton=''.$langs->trans('NewVATPayment').' ';
+}
+
+print load_fiche_titre($langs->transcountry($ltt==2?"LT2Payments":"LT1Payments",$mysoc->country_code), $newcardbutton);
$sql = "SELECT rowid, amount, label, f.datev as dm";
$sql.= " FROM ".MAIN_DB_PREFIX."localtax as f ";
@@ -66,7 +72,7 @@ if ($result)
while ($i < $num)
{
$obj = $db->fetch_object($result);
-
+
print '';
$localtax_static->id=$obj->rowid;
diff --git a/htdocs/compta/localtax/quadri_detail.php b/htdocs/compta/localtax/quadri_detail.php
index 5e18c786c18..db316a1d6dc 100644
--- a/htdocs/compta/localtax/quadri_detail.php
+++ b/htdocs/compta/localtax/quadri_detail.php
@@ -38,10 +38,7 @@ 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("bills");
-$langs->load("compta");
-$langs->load("companies");
-$langs->load("products");
+$langs->loadLangs(array("other","compta","banks","bills","companies","product","trips","admin"));
$local=GETPOST('localTaxType', 'int');
// Date range
@@ -63,29 +60,31 @@ if (empty($date_start) || empty($date_end)) // We define date_start and date_end
$q=GETPOST("q");
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); }
+ if (GETPOST("month")) { $date_start=dol_get_first_day($year_start,$_REQUEST["month"],false); $date_end=dol_get_last_day($year_start,GETPOST("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;
+ $date_start=dol_get_first_day($year_start,empty($conf->global->SOCIETE_FISCAL_MONTH_START)?1:$conf->global->SOCIETE_FISCAL_MONTH_START,false);
+ if (empty($conf->global->MAIN_INFO_VAT_RETURN) || $conf->global->MAIN_INFO_VAT_RETURN == 2) $date_end=dol_time_plus_duree($date_start, 3, 'm') - 1;
+ else if ($conf->global->MAIN_INFO_VAT_RETURN == 3) $date_end=dol_time_plus_duree($date_start, 1, 'y') - 1;
+ else if ($conf->global->MAIN_INFO_VAT_RETURN == 1) $date_end=dol_time_plus_duree($date_start, 1, 'm') - 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); }
+ else
+ {
+ 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");
+$min = price2num(GETPOST("min","alpha"));
if (empty($min)) $min = 0;
// Define modetax (0 or 1)
-// 0=normal, 1=option vat for services is on debit
+// 0=normal, 1=option vat for services is on debit, 2=option on payments for products
$modetax = $conf->global->TAX_MODE;
-if (isset($_REQUEST["modetax"])) $modetax=$_REQUEST["modetax"];
+if (GETPOSTISSET("modetax")) $modetax=GETPOST("modetax",'int');
if (empty($modetax)) $modetax=0;
// Security check
@@ -118,11 +117,11 @@ $fsearch.=' ';
$fsearch.=' ';
$fsearch.=' ';
+$name=$langs->transcountry($local==1?"LT1ReportByQuarters":"LT2ReportByQuarters", $mysoc->country_code);
$calc=$conf->global->MAIN_INFO_LOCALTAX_CALC.$local;
if ($conf->global->$calc==0 || $conf->global->$calc==1) // Calculate on invoice for goods and services
{
- $nom=$langs->trans($local==1?"LT1ReportByQuartersInDueDebtMode":"LT2ReportByQuartersInDueDebtMode");
$calcmode=$calc==0?$langs->trans("CalcModeLT".$local):$langs->trans("CalcModeLT".$local."Rec");
$calcmode.=' ('.$langs->trans("TaxModuleSetupToModifyRulesLT",DOL_URL_ROOT.'/admin/company.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);
@@ -151,7 +150,6 @@ if ($conf->global->$calc==0 || $conf->global->$calc==1) // Calculate on invoice
}
if ($conf->global->$calc==2) // Invoice for goods, payment for services
{
- $nom=$langs->trans($local==1?"LT1ReportByQuartersInInputOutputMode":"LT2ReportByQuartersInInputOutputMode");
$calcmode=$calc==0?$langs->trans("CalcModeLT".$local):$langs->trans("CalcModeLT".$local."Rec");
$calcmode.=' ('.$langs->trans("TaxModuleSetupToModifyRulesLT",DOL_URL_ROOT.'/admin/company.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);
diff --git a/htdocs/compta/tva/clients.php b/htdocs/compta/tva/clients.php
index bd97101cc49..71376a566e1 100644
--- a/htdocs/compta/tva/clients.php
+++ b/htdocs/compta/tva/clients.php
@@ -1,7 +1,7 @@
* Copyright (C) 2004 Eric Seigne
- * Copyright (C) 2004-2013 Laurent Destailleur
+ * Copyright (C) 2004-2018 Laurent Destailleur
* Copyright (C) 2006 Yannick Warnier
* Copyright (C) 2014 Ferran Marcet
*
@@ -20,9 +20,9 @@
*/
/**
- * \file htdocs/compta/tva/clients.php
- * \ingroup tax
- * \brief Page des societes
+ * \file htdocs/compta/tva/clients.php
+ * \ingroup tax
+ * \brief Page of sales taxes
*/
require '../../main.inc.php';
@@ -32,71 +32,56 @@ 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.'/core/class/ccountry.class.php';
-$langs->load("bills");
-$langs->load("compta");
-$langs->load("companies");
-$langs->load("products");
-$langs->load("other");
-$langs->load("admin");
+$langs->loadLangs(array("other","compta","banks","bills","companies","product","trips","admin"));
// Date range
-$year=GETPOST("year");
-if (empty($year)) {
+$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"]);
+$date_start=dol_mktime(0,0,0,GETPOST("date_startmonth"),GETPOST("date_startday"),GETPOST("date_startyear"));
+$date_end=dol_mktime(23,59,59,GETPOST("date_endmonth"),GETPOST("date_endday"),GETPOST("date_endyear"));
// Quarter
-if (empty($date_start) || empty($date_end)) {// We define date_start and date_end
+if (empty($date_start) || empty($date_end)) // We define date_start and date_end
+{
$q=GETPOST("q");
- 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 (empty($q))
+ {
+ if (GETPOST("month")) { $date_start=dol_get_first_day($year_start,GETPOST("month"),false); $date_end=dol_get_last_day($year_start,GETPOST("month"),false); }
+ else
+ {
+ $date_start=dol_get_first_day($year_start,empty($conf->global->SOCIETE_FISCAL_MONTH_START)?1:$conf->global->SOCIETE_FISCAL_MONTH_START,false);
+ if (empty($conf->global->MAIN_INFO_VAT_RETURN) || $conf->global->MAIN_INFO_VAT_RETURN == 2) $date_end=dol_time_plus_duree($date_start, 3, 'm') - 1;
+ else if ($conf->global->MAIN_INFO_VAT_RETURN == 3) $date_end=dol_time_plus_duree($date_start, 1, 'y') - 1;
+ else if ($conf->global->MAIN_INFO_VAT_RETURN == 1) $date_end=dol_time_plus_duree($date_start, 1, 'm') - 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);
+ else
+ {
+ 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 = price2num(GETPOST("min"));
+$min = price2num(GETPOST("min","alpha"));
if (empty($min)) $min = 0;
// Define modetax (0 or 1)
-// 0=normal, 1=option vat for services is on debit
+// 0=normal, 1=option vat for services is on debit, 2=option on payments for products
$modetax = $conf->global->TAX_MODE;
-if (isset($_REQUEST["modetax"])) $modetax=$_REQUEST["modetax"];
+if (GETPOSTISSET("modetax")) $modetax=GETPOST("modetax",'int');
if (empty($modetax)) $modetax=0;
// Security check
$socid = GETPOST('socid','int');
-if ($user->societe_id) {
- $socid=$user->societe_id;
-}
+if ($user->societe_id) $socid=$user->societe_id;
$result = restrictedArea($user, 'tax', '', '', 'charges');
// Define modecompta ('CREANCES-DETTES' or 'RECETTES-DEPENSES')
@@ -135,6 +120,8 @@ $fsearch.=' ';
$description='';
+// Show report header
+$name=$langs->trans("VATReportByCustomers");
$calcmode='';
if ($modetax == 0) $calcmode=$langs->trans('OptionVATDefault');
if ($modetax == 1) $calcmode=$langs->trans('OptionVATDebitOption');
@@ -150,68 +137,32 @@ if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
}
if (! empty($conf->global->MAIN_MODULE_ACCOUNTING)) $description.=' '.$langs->trans("ThisIsAnEstimatedValue");
-// Affiche en-tete du rapport
-if ($modetax==1) { // Calculate on invoice for goods and services
- $name=$langs->trans("VATReportByCustomersInDueDebtMode");
- $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?"".img_previous()." ".img_next()." ":"");
- $description.=$fsearch;
- $description.=' '
- . ' '
- . $langs->trans('SimpleReport')
- . ''
- . ' '
- . ' '
- . $langs->trans('AddExtraReport')
- . ''
- . ' ';
- $builddate=dol_now();
- //$exportlink=$langs->trans("NotYetAvailable");
+$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?"".img_previous()." ".img_next()." ":"");
+$description.=$fsearch;
+$description.=' '
+ . ' '
+ . $langs->trans('SimpleReport')
+ . ''
+ . ' '
+ . ' '
+ . $langs->trans('AddExtraReport')
+ . ''
+ . ' ';
+$builddate=dol_now();
+//$exportlink=$langs->trans("NotYetAvailable");
- $elementcust=$langs->trans("CustomersInvoices");
- $productcust=$langs->trans("Description");
- $amountcust=$langs->trans("AmountHT");
- if ($mysoc->tva_assuj) {
- $vatcust.=' ('.$langs->trans("ToPay").')';
- }
- $elementsup=$langs->trans("SuppliersInvoices");
- $productsup=$langs->trans("Description");
- $amountsup=$langs->trans("AmountHT");
- if ($mysoc->tva_assuj) {
- $vatsup.=' ('.$langs->trans("ToGetBack").')';
- }
+$elementcust=$langs->trans("CustomersInvoices");
+$productcust=$langs->trans("Description");
+$amountcust=$langs->trans("AmountHT");
+if ($mysoc->tva_assuj) {
+ $vatcust.=' ('.$langs->trans("ToPay").')';
}
-if ($modetax==0) { // Invoice for goods, payment for services
- $name=$langs->trans("VATReportByCustomersInInputOutputMode");
- $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?"".img_previous()." ".img_next()." ":"");
- //if ($conf->global->MAIN_MODULE_COMPTABILITE || $conf->global->MAIN_MODULE_ACCOUNTING) $description.=' '.img_warning().' '.$langs->trans('OptionVatInfoModuleComptabilite');
- //if (! empty($conf->global->MAIN_MODULE_COMPTABILITE)) $description.=' '.$langs->trans("WarningDepositsNotIncluded");
- $description.=$fsearch;
- $description.=' '
- . ' '
- . $langs->trans('SimpleReport')
- . ''
- . ' '
- . ' '
- . $langs->trans('AddExtraReport')
- . ''
- . ' ';
- $builddate=dol_now();
- //$exportlink=$langs->trans("NotYetAvailable");
-
- $elementcust=$langs->trans("CustomersInvoices");
- $productcust=$langs->trans("Description");
- $amountcust=$langs->trans("AmountHT");
- if ($mysoc->tva_assuj) {
- $vatcust.=' ('.$langs->trans("ToPay").')';
- }
- $elementsup=$langs->trans("SuppliersInvoices");
- $productsup=$langs->trans("Description");
- $amountsup=$langs->trans("AmountHT");
- if ($mysoc->tva_assuj) {
- $vatsup.=' ('.$langs->trans("ToGetBack").')';
- }
+$elementsup=$langs->trans("SuppliersInvoices");
+$productsup=$langs->trans("Description");
+$amountsup=$langs->trans("AmountHT");
+if ($mysoc->tva_assuj) {
+ $vatsup.=' ('.$langs->trans("ToGetBack").')';
}
report_header($name,'',$period,$periodlink,$description,$builddate,$exportlink,array(),$calcmode);
diff --git a/htdocs/compta/tva/index.php b/htdocs/compta/tva/index.php
index 0ccd7013ba4..f6d4bdc4524 100644
--- a/htdocs/compta/tva/index.php
+++ b/htdocs/compta/tva/index.php
@@ -27,31 +27,56 @@
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.'/compta/tva/class/tva.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
+require_once DOL_DOCUMENT_ROOT.'/compta/tva/class/tva.class.php';
-$langs->loadLangs(array("other","compta","banks","bills","companies","admin"));
+$langs->loadLangs(array("other","compta","banks","bills","companies","product","trips","admin"));
+// Date range
$year=GETPOST("year","int");
-if ($year == 0)
+if (empty($year))
{
- $year_current = strftime("%Y",time());
- $year_start = $year_current;
+ $year_current = strftime("%Y",dol_now());
+ $year_start = $year_current;
} else {
- $year_current = $year;
- $year_start = $year;
+ $year_current = $year;
+ $year_start = $year;
+}
+$date_start=dol_mktime(0,0,0,GETPOST("date_startmonth"),GETPOST("date_startday"),GETPOST("date_startyear"));
+$date_end=dol_mktime(23,59,59,GETPOST("date_endmonth"),GETPOST("date_endday"),GETPOST("date_endyear"));
+// Quarter
+if (empty($date_start) || empty($date_end)) // We define date_start and date_end
+{
+ $q=GETPOST("q");
+ if (empty($q))
+ {
+ if (GETPOST("month")) { $date_start=dol_get_first_day($year_start,GETPOST("month"),false); $date_end=dol_get_last_day($year_start,GETPOST("month"),false); }
+ else
+ {
+ $date_start=dol_get_first_day($year_start, $conf->global->SOCIETE_FISCAL_MONTH_START,false);
+ $date_end=dol_time_plus_duree($date_start, 1, 'y') - 1;
+ }
+ }
+ else
+ {
+ 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); }
+ }
}
+// Define modetax (0 or 1)
+// 0=normal, 1=option vat for services is on debit, 2=option on payments for products
+$modetax = $conf->global->TAX_MODE;
+if (GETPOSTISSET("modetax")) $modetax=GETPOST("modetax",'int');
+if (empty($modetax)) $modetax=0;
+
// Security check
-$socid = isset($_GET["socid"])?$_GET["socid"]:'';
+$socid = GETPOST('socid','int');
if ($user->societe_id) $socid=$user->societe_id;
$result = restrictedArea($user, 'tax', '', '', 'charges');
-// Define modetax (0 or 1)
-// 0=normal, 1=option vat for services is on debit
-$modetax = $conf->global->TAX_MODE;
-if (isset($_GET["modetax"])) $modetax=GETPOST("modetax",'alpha');
-
/**
* print function
@@ -104,10 +129,14 @@ function pt ($db, $sql, $date)
* View
*/
+$form=new Form($db);
+$company_static=new Societe($db);
$tva = new Tva($db);
-$name = $langs->trans("ReportByMonth");
+$description = '';
+// Show report header
+$name = $langs->trans("ReportByMonth");
$calcmode='';
if ($modetax == 0) $calcmode=$langs->trans('OptionVATDefault');
if ($modetax == 1) $calcmode=$langs->trans('OptionVATDebitOption');
@@ -124,17 +153,19 @@ if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
}
if (! empty($conf->global->MAIN_MODULE_ACCOUNTING)) $description.=' '.$langs->trans("ThisIsAnEstimatedValue");
+$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);
+
$builddate=dol_now();
+
llxHeader('', $name);
-
-$textprevyear="".img_previous($langs->trans("Previous"), 'class="valignbottom"')." ";
-$textnextyear=" ".img_next($langs->trans("Next"), 'class="valignbottom"')." ";
-
+//$textprevyear="".img_previous($langs->trans("Previous"), 'class="valignbottom"')." ";
+//$textnextyear=" ".img_next($langs->trans("Next"), 'class="valignbottom"')." ";
//print load_fiche_titre($langs->transcountry("VAT", $mysoc->country_code), $textprevyear." ".$langs->trans("Year")." ".$year_start." ".$textnextyear, 'title_accountancy.png');
-report_header($name,'',$textprevyear.$langs->trans("Year")." ".$year_start.$textnextyear,'',$description,$builddate,$exportlink,array(),$calcmode);
+report_header($name,'',$period,$periodlink,$description,$builddate,$exportlink,array(),$calcmode);
+//report_header($name,'',$textprevyear.$langs->trans("Year")." ".$year_start.$textnextyear,'',$description,$builddate,$exportlink,array(),$calcmode);
print ' ';
@@ -152,14 +183,22 @@ print ''.$langs->trans("TotalToPay").' ';
print ' '."\n";
print ' '."\n";
-
-$y = $year_current ;
-
+$tmp=dol_getdate($date_start);
+$y = $tmp['year'];
+$m = $tmp['mon'];
+$tmp=dol_getdate($date_end);
+$yend = $tmp['year'];
+$mend = $tmp['mon'];
$total=0; $subtotalcoll=0; $subtotalpaye=0; $subtotal=0;
-$i=0;
-for ($m = 1 ; $m < 13 ; $m++ )
+$i=0; $mcursor=0;
+while ((($y < $yend) || ($y == $yend && $m < $mend)) && $mcursor < 1000) // $mcursor is to avoid too large loop
{
+ $m = $conf->global->SOCIETE_FISCAL_MONTH_START + ($mcursor % 12);
+ if ($m == 13) $y++;
+ if ($m > 12) $m -= 12;
+ $mcursor++;
+
$coll_listsell = tax_by_date('vat', $db, $y, 0, 0, 0, $modetax, 'sell', $m);
$coll_listbuy = tax_by_date('vat', $db, $y, 0, 0, 0, $modetax, 'buy', $m);
@@ -215,7 +254,8 @@ for ($m = 1 ; $m < 13 ; $m++ )
print "\n";
$i++;
- if ($i > 2) {
+ if ($i > 2)
+ {
print '';
print ''.$langs->trans("SubTotal").' : ';
print ''.price($subtotalcoll).' ';
@@ -245,8 +285,8 @@ print load_fiche_titre($langs->trans("VATPaid"), '', '');
$sql = "SELECT SUM(amount) as mm, date_format(f.datep,'%Y-%m') as dm";
$sql.= " FROM ".MAIN_DB_PREFIX."tva as f";
$sql.= " WHERE f.entity = ".$conf->entity;
-$sql.= " AND f.datep >= '".$db->idate(dol_get_first_day($y,1,false))."'";
-$sql.= " AND f.datep <= '".$db->idate(dol_get_last_day($y,12,false))."'";
+$sql.= " AND f.datep >= '".$db->idate($date_start)."'";
+$sql.= " AND f.datep <= '".$db->idate($date_end)."'";
$sql.= " GROUP BY dm ORDER BY dm ASC";
pt($db, $sql,$langs->trans("Year")." $y");
@@ -255,7 +295,6 @@ pt($db, $sql,$langs->trans("Year")." $y");
print ' ';
-
if (! empty($conf->global->MAIN_FEATURES_LEVEL))
{
/*
@@ -267,8 +306,8 @@ if (! empty($conf->global->MAIN_FEATURES_LEVEL))
$sql1 = "SELECT SUM(amount) as mm, date_format(f.datev,'%Y') as dm";
$sql1 .= " FROM " . MAIN_DB_PREFIX . "tva as f";
$sql1 .= " WHERE f.entity = " . $conf->entity;
- $sql1 .= " AND f.datev >= '" . $db->idate(dol_get_first_day($y, 1, false)) . "'";
- $sql1 .= " AND f.datev <= '" . $db->idate(dol_get_last_day($y, 12, false)) . "'";
+ $sql1 .= " AND f.datev >= '" . $db->idate($date_start) . "'";
+ $sql1 .= " AND f.datev <= '" . $db->idate($date_end) . "'";
$sql1 .= " GROUP BY dm ORDER BY dm ASC";
$result = $db->query($sql1);
diff --git a/htdocs/compta/tva/list.php b/htdocs/compta/tva/list.php
index 056e16b4d5b..e796ddacac7 100644
--- a/htdocs/compta/tva/list.php
+++ b/htdocs/compta/tva/list.php
@@ -35,7 +35,7 @@ $langs->load("compta");
$langs->load("bills");
// Security check
-$socid = isset($_GET["socid"])?$_GET["socid"]:'';
+$socid = GETPOST('socid','int');
if ($user->societe_id) $socid=$user->societe_id;
$result = restrictedArea($user, 'tax', '', '', 'charges');
diff --git a/htdocs/compta/tva/quadri.php b/htdocs/compta/tva/quadri.php
index 6d33c358af2..e572eb7e006 100644
--- a/htdocs/compta/tva/quadri.php
+++ b/htdocs/compta/tva/quadri.php
@@ -29,6 +29,8 @@
require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/compta/tva/class/tva.class.php';
+$langs->loadLangs(array("other","compta","banks","bills","companies","product","trips","admin"));
+
$year = GETPOST('year', 'int');
if ($year == 0 )
{
@@ -40,7 +42,7 @@ if ($year == 0 )
}
// Security check
-$socid = isset($_GET["socid"])?$_GET["socid"]:'';
+$socid = GETPOST('socid','int');
if ($user->societe_id) $socid=$user->societe_id;
$result = restrictedArea($user, 'tax', '', '', 'charges');
@@ -259,7 +261,7 @@ if ($conf->global->ACCOUNTING_MODE == "CREANCES-DETTES")
$x_paye_sum = 0;
$x_paye_ht = 0;
foreach($x_both as $rate => $both){
-
+
print ' ';
print "$rate% ";
print "".price($both['coll']['totalht'])." ";
@@ -282,7 +284,7 @@ if ($conf->global->ACCOUNTING_MODE == "CREANCES-DETTES")
$total = $total + $diff;
$subtotal = $subtotal + $diff;
-
+
print ' ';
print ' ';
print "".price($diff)." \n";
diff --git a/htdocs/compta/tva/quadri_detail.php b/htdocs/compta/tva/quadri_detail.php
index 92b67dbfd6f..f6286c32420 100644
--- a/htdocs/compta/tva/quadri_detail.php
+++ b/htdocs/compta/tva/quadri_detail.php
@@ -38,13 +38,7 @@ require_once DOL_DOCUMENT_ROOT.'/fourn/class/paiementfourn.class.php';
require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php';
require_once DOL_DOCUMENT_ROOT.'/expensereport/class/paymentexpensereport.class.php';
-$langs->load("bills");
-$langs->load("compta");
-$langs->load("companies");
-$langs->load("products");
-$langs->load("trips");
-$langs->load("other");
-$langs->load("admin");
+$langs->loadLangs(array("other","compta","banks","bills","companies","product","trips","admin"));
// Date range
$year=GETPOST("year","int");
@@ -67,26 +61,28 @@ if (empty($date_start) || empty($date_end)) // We define date_start and date_end
if (GETPOST("month")) { $date_start=dol_get_first_day($year_start,GETPOST("month"),false); $date_end=dol_get_last_day($year_start,GETPOST("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;
+ $date_start=dol_get_first_day($year_start,empty($conf->global->SOCIETE_FISCAL_MONTH_START)?1:$conf->global->SOCIETE_FISCAL_MONTH_START,false);
+ if (empty($conf->global->MAIN_INFO_VAT_RETURN) || $conf->global->MAIN_INFO_VAT_RETURN == 2) $date_end=dol_time_plus_duree($date_start, 3, 'm') - 1;
+ else if ($conf->global->MAIN_INFO_VAT_RETURN == 3) $date_end=dol_time_plus_duree($date_start, 1, 'y') - 1;
+ else if ($conf->global->MAIN_INFO_VAT_RETURN == 1) $date_end=dol_time_plus_duree($date_start, 1, 'm') - 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); }
+ else
+ {
+ 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");
+$min = price2num(GETPOST("min","alpha"));
if (empty($min)) $min = 0;
// Define modetax (0 or 1)
-// 0=normal, 1=option vat for services is on debit
+// 0=normal, 1=option vat for services is on debit, 2=option on payments for products
$modetax = $conf->global->TAX_MODE;
-if (isset($_REQUEST["modetax"])) $modetax=$_REQUEST["modetax"];
+if (GETPOSTISSET("modetax")) $modetax=GETPOST("modetax",'int');
if (empty($modetax)) $modetax=0;
// Security check
diff --git a/htdocs/core/lib/tax.lib.php b/htdocs/core/lib/tax.lib.php
index d2bc3b37183..26c31a4eee0 100644
--- a/htdocs/core/lib/tax.lib.php
+++ b/htdocs/core/lib/tax.lib.php
@@ -200,6 +200,12 @@ function tax_by_date($type, $db, $y, $q, $date_start, $date_end, $modetax, $dire
{
global $conf;
+ // If we use date_start and date_end, we must not use $y, $m, $q
+ if (($date_start || $date_end) && (! empty($y) || ! empty($m) || ! empty($q)))
+ {
+ dol_print_error('', 'Bad value of input parameter for tax_by_date');
+ }
+
$list=array();
if ($direction == 'sell')
diff --git a/htdocs/langs/en_US/compta.lang b/htdocs/langs/en_US/compta.lang
index 25e2849b949..24724088e45 100644
--- a/htdocs/langs/en_US/compta.lang
+++ b/htdocs/langs/en_US/compta.lang
@@ -165,14 +165,19 @@ RulesResultBookkeepingPersonalized=It show record in your Ledger with accounting
SeePageForSetup=See menu %s for setup
DepositsAreNotIncluded=- Down payment invoices are nor included
DepositsAreIncluded=- Down payment invoices are included
-LT2ReportByCustomersInInputOutputModeES=Report by third party IRPF
-LT1ReportByCustomersInInputOutputModeES=Report by third party RE
+LT1ReportByCustomers=Report tax 2 by third party
+LT2ReportByCustomers=Report tax 3 by third party
+LT1ReportByCustomersES=Report by third party RE
+LT2ReportByCustomersES=Report by third party IRPF
VATReport=Sale tax report
VATReportByPeriods=Sale tax report by period
+VATReportByCustomers=Sale tax report by customer
VATReportByCustomersInInputOutputMode=Report by the customer VAT collected and paid
VATReportByQuartersInInputOutputMode=Report by Sale tax rate of the tax collected and paid
-LT1ReportByQuartersInInputOutputMode=Report by RE rate
-LT2ReportByQuartersInInputOutputMode=Report by IRPF rate
+LT1ReportByQuarters=Report tax 2 by rate
+LT2ReportByQuarters=Report tax 3 by rate
+LT1ReportByQuartersES=Report by RE rate
+LT2ReportByQuartersES=Report by IRPF rate
SeeVATReportInInputOutputMode=See report %sVAT encasement%s for a standard calculation
SeeVATReportInDueDebtMode=See report %sVAT on flow%s 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.