FIX #12674
This commit is contained in:
parent
2d97c0bb79
commit
fe44d3a4fa
@ -60,10 +60,10 @@ if (empty($year))
|
|||||||
}
|
}
|
||||||
$date_start = dol_mktime(0, 0, 0, GETPOST("date_startmonth"), GETPOST("date_startday"), GETPOST("date_startyear"));
|
$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"));
|
$date_end = dol_mktime(23, 59, 59, GETPOST("date_endmonth"), GETPOST("date_endday"), GETPOST("date_endyear"));
|
||||||
// Quarter
|
// Set default period if not defined
|
||||||
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");
|
$q = GETPOST("q", "int");
|
||||||
if (empty($q))
|
if (empty($q))
|
||||||
{
|
{
|
||||||
if (GETPOST("month", 'int')) { $date_start = dol_get_first_day($year_start, GETPOST("month", 'int'), false); $date_end = dol_get_last_day($year_start, GETPOST("month", 'int'), false); }
|
if (GETPOST("month", 'int')) { $date_start = dol_get_first_day($year_start, GETPOST("month", 'int'), false); $date_end = dol_get_last_day($year_start, GETPOST("month", 'int'), false); }
|
||||||
|
|||||||
@ -35,12 +35,15 @@ require_once DOL_DOCUMENT_ROOT.'/compta/localtax/class/localtax.class.php';
|
|||||||
// Load translation files required by the page
|
// Load translation files required by the page
|
||||||
$langs->loadLangs(array("other", "compta", "banks", "bills", "companies", "product", "trips", "admin"));
|
$langs->loadLangs(array("other", "compta", "banks", "bills", "companies", "product", "trips", "admin"));
|
||||||
|
|
||||||
|
$now = dol_now();
|
||||||
|
$current_date = dol_getdate($now);
|
||||||
|
if (empty($conf->global->SOCIETE_FISCAL_MONTH_START)) $conf->global->SOCIETE_FISCAL_MONTH_START = 1;
|
||||||
|
|
||||||
// Date range
|
// Date range
|
||||||
$year = GETPOST("year", "int");
|
$year = GETPOST("year", "int");
|
||||||
if (empty($year))
|
if (empty($year))
|
||||||
{
|
{
|
||||||
$year_current = strftime("%Y", dol_now());
|
$year_current = $current_date['year'];
|
||||||
if ($conf->global->SOCIETE_FISCAL_MONTH_START > date('m')) $year_current--;
|
|
||||||
$year_start = $year_current;
|
$year_start = $year_current;
|
||||||
} else {
|
} else {
|
||||||
$year_current = $year;
|
$year_current = $year;
|
||||||
@ -48,6 +51,7 @@ if (empty($year))
|
|||||||
}
|
}
|
||||||
$date_start = dol_mktime(0, 0, 0, GETPOST("date_startmonth"), GETPOST("date_startday"), GETPOST("date_startyear"));
|
$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"));
|
$date_end = dol_mktime(23, 59, 59, GETPOST("date_endmonth"), GETPOST("date_endday"), GETPOST("date_endyear"));
|
||||||
|
// Set default period if not defined
|
||||||
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", "int");
|
$q = GETPOST("q", "int");
|
||||||
@ -56,9 +60,28 @@ if (empty($date_start) || empty($date_end)) // We define date_start and date_end
|
|||||||
if (GETPOST("month", "int")) { $date_start = dol_get_first_day($year_start, GETPOST("month", "int"), false); $date_end = dol_get_last_day($year_start, GETPOST("month", "int"), false); }
|
if (GETPOST("month", "int")) { $date_start = dol_get_first_day($year_start, GETPOST("month", "int"), false); $date_end = dol_get_last_day($year_start, GETPOST("month", "int"), false); }
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
if (empty($conf->global->MAIN_INFO_VAT_RETURN) || $conf->global->MAIN_INFO_VAT_RETURN == 2) { // quaterly vat, we take last past complete quarter
|
||||||
|
$date_start = dol_time_plus_duree(dol_get_first_day($year_start, $current_date['mon'], false), -3 - (($current_date['mon'] - $conf->global->SOCIETE_FISCAL_MONTH_START) % 3), 'm');
|
||||||
|
$date_end = dol_time_plus_duree($date_start, 3, 'm') - 1;
|
||||||
|
}
|
||||||
|
elseif ($conf->global->MAIN_INFO_VAT_RETURN == 3) { // yearly vat
|
||||||
|
if ($current_date['mon'] < $conf->global->SOCIETE_FISCAL_MONTH_START) {
|
||||||
|
if (($conf->global->SOCIETE_FISCAL_MONTH_START - $current_date['mon']) > 6) { // If period started from less than 6 years, we show past year
|
||||||
|
$year_start--;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (($current_date['mon'] - $conf->global->SOCIETE_FISCAL_MONTH_START) < 6) { // If perdio started from less than 6 years, we show past year
|
||||||
|
$year_start--;
|
||||||
|
}
|
||||||
|
}
|
||||||
$date_start = dol_get_first_day($year_start, $conf->global->SOCIETE_FISCAL_MONTH_START, false);
|
$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;
|
$date_end = dol_time_plus_duree($date_start, 1, 'y') - 1;
|
||||||
}
|
}
|
||||||
|
elseif ($conf->global->MAIN_INFO_VAT_RETURN == 1) { // monthly vat, we take last past complete month
|
||||||
|
$date_start = dol_time_plus_duree(dol_get_first_day($year_start, $current_date['mon'], false), -1, 'm');
|
||||||
|
$date_end = dol_time_plus_duree($date_start, 1, 'm') - 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@ -44,11 +44,15 @@ require_once DOL_DOCUMENT_ROOT.'/expensereport/class/paymentexpensereport.class.
|
|||||||
// Load translation files required by the page
|
// Load translation files required by the page
|
||||||
$langs->loadLangs(array("other", "compta", "banks", "bills", "companies", "product", "trips", "admin"));
|
$langs->loadLangs(array("other", "compta", "banks", "bills", "companies", "product", "trips", "admin"));
|
||||||
|
|
||||||
|
$now = dol_now();
|
||||||
|
$current_date = dol_getdate($now);
|
||||||
|
if (empty($conf->global->SOCIETE_FISCAL_MONTH_START)) $conf->global->SOCIETE_FISCAL_MONTH_START = 1;
|
||||||
|
|
||||||
// Date range
|
// Date range
|
||||||
$year = GETPOST("year", "int");
|
$year = GETPOST("year", "int");
|
||||||
if (empty($year))
|
if (empty($year))
|
||||||
{
|
{
|
||||||
$year_current = strftime("%Y", dol_now());
|
$year_current = $current_date['year'];
|
||||||
$year_start = $year_current;
|
$year_start = $year_current;
|
||||||
} else {
|
} else {
|
||||||
$year_current = $year;
|
$year_current = $year;
|
||||||
@ -56,7 +60,7 @@ if (empty($year))
|
|||||||
}
|
}
|
||||||
$date_start = dol_mktime(0, 0, 0, GETPOST("date_startmonth"), GETPOST("date_startday"), GETPOST("date_startyear"));
|
$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"));
|
$date_end = dol_mktime(23, 59, 59, GETPOST("date_endmonth"), GETPOST("date_endday"), GETPOST("date_endyear"));
|
||||||
// Quarter
|
// Set default period if not defined
|
||||||
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", "int");
|
$q = GETPOST("q", "int");
|
||||||
@ -65,10 +69,27 @@ if (empty($date_start) || empty($date_end)) // We define date_start and date_end
|
|||||||
if (GETPOST("month", "int")) { $date_start = dol_get_first_day($year_start, GETPOST("month", "int"), false); $date_end = dol_get_last_day($year_start, GETPOST("month", "int"), false); }
|
if (GETPOST("month", "int")) { $date_start = dol_get_first_day($year_start, GETPOST("month", "int"), false); $date_end = dol_get_last_day($year_start, GETPOST("month", "int"), false); }
|
||||||
else
|
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) { // quaterly vat, we take last past complete quarter
|
||||||
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;
|
$date_start = dol_time_plus_duree(dol_get_first_day($year_start, $current_date['mon'], false), -3 - (($current_date['mon'] - $conf->global->SOCIETE_FISCAL_MONTH_START) % 3), 'm');
|
||||||
elseif ($conf->global->MAIN_INFO_VAT_RETURN == 3) $date_end = dol_time_plus_duree($date_start, 1, 'y') - 1;
|
$date_end = dol_time_plus_duree($date_start, 3, 'm') - 1;
|
||||||
elseif ($conf->global->MAIN_INFO_VAT_RETURN == 1) $date_end = dol_time_plus_duree($date_start, 1, 'm') - 1;
|
}
|
||||||
|
elseif ($conf->global->MAIN_INFO_VAT_RETURN == 3) { // yearly vat
|
||||||
|
if ($current_date['mon'] < $conf->global->SOCIETE_FISCAL_MONTH_START) {
|
||||||
|
if (($conf->global->SOCIETE_FISCAL_MONTH_START - $current_date['mon']) > 6) { // If period started from less than 6 years, we show past year
|
||||||
|
$year_start--;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (($current_date['mon'] - $conf->global->SOCIETE_FISCAL_MONTH_START) < 6) { // If perdio started from less than 6 years, we show past year
|
||||||
|
$year_start--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$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;
|
||||||
|
}
|
||||||
|
elseif ($conf->global->MAIN_INFO_VAT_RETURN == 1) { // monthly vat, we take last past complete month
|
||||||
|
$date_start = dol_time_plus_duree(dol_get_first_day($year_start, $current_date['mon'], false), -1, 'm');
|
||||||
|
$date_end = dol_time_plus_duree($date_start, 1, 'm') - 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user