Fix: Use correct vat rate into text cases.
Qual: Next step cleaning date functions. Qual: Complete phpunit test case for dol_mktime to check dayling saving time is correctly managed.
This commit is contained in:
parent
b2f6498236
commit
73682baff0
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -69,7 +69,7 @@ function get_tz_array()
|
||||
*/
|
||||
function getServerTimeZoneString()
|
||||
{
|
||||
if (function_exists('date_default_timezone_get')) return date_default_timezone_get();
|
||||
if (function_exists('date_default_timezone_get')) return @date_default_timezone_get();
|
||||
else return '';
|
||||
}
|
||||
|
||||
@ -133,7 +133,7 @@ function getServerTimeZoneInt($refgmtdate='now')
|
||||
*
|
||||
function getParentCompanyTimeZoneString()
|
||||
{
|
||||
if (function_exists('date_default_timezone_get')) return date_default_timezone_get();
|
||||
if (function_exists('date_default_timezone_get')) return @date_default_timezone_get();
|
||||
else return '';
|
||||
}
|
||||
*/
|
||||
@ -479,7 +479,7 @@ function dol_get_next_week($day, $week, $month, $year)
|
||||
*
|
||||
* @param int $year Year
|
||||
* @param int $month Month
|
||||
* @param boolean $gm False = Return date to compare with server TZ, True to compare with GM date.
|
||||
* @param mixed $gm False or 0 or 'server' = Return date to compare with server TZ, True or 1 to compare with GM date.
|
||||
* Exemple: dol_get_first_day(1970,1,false) will return -3600 with TZ+1, after a dol_print_date will return 1970-01-01 00:00:00
|
||||
* Exemple: dol_get_first_day(1970,1,true) will return 0 whatever is TZ, after a dol_print_date will return 1970-01-01 00:00:00
|
||||
* @return timestamp Date for first day
|
||||
@ -494,7 +494,7 @@ function dol_get_first_day($year,$month=1,$gm=false)
|
||||
*
|
||||
* @param int $year Year
|
||||
* @param int $month Month
|
||||
* @param boolean $gm False = Return date to compare with server TZ, True to compare with GM date.
|
||||
* @param boolean $gm False or 0 or 'server' = Return date to compare with server TZ, True or 1 to compare with GM date.
|
||||
* @return timestamp Date for first day
|
||||
*/
|
||||
function dol_get_last_day($year,$month=12,$gm=false)
|
||||
@ -521,7 +521,7 @@ function dol_get_last_day($year,$month=12,$gm=false)
|
||||
* @param int $day Day
|
||||
* @param int $month Month
|
||||
* @param int $year Year
|
||||
* @param int $gm False = Return date to compare with server TZ, True to compare with GM date.
|
||||
* @param int $gm False or 0 or 'server' = Return date to compare with server TZ, True or 1 to compare with GM date.
|
||||
* @return array year,month, week,first_day,prev_year,prev_month,prev_day
|
||||
*/
|
||||
function dol_get_first_day_week($day,$month,$year,$gm=false)
|
||||
|
||||
@ -997,7 +997,7 @@ function dol_getdate($timestamp,$fast=false)
|
||||
* @param int $month Month (1 to 12)
|
||||
* @param int $day Day (1 to 31)
|
||||
* @param int $year Year
|
||||
* @param int $gm true or 1=Input informations are GMT values, false or 0 or 'server' = local to server TZ, 'user' = local to user TZ
|
||||
* @param mixed $gm True or 1=Input informations are GMT values, False or 0 or 'server' = local to server TZ, 'user' = local to user TZ
|
||||
* @param int $check 0=No check on parameters (Can use day 32, etc...)
|
||||
* @return int Date as a timestamp, '' if error
|
||||
* @see dol_print_date, dol_stringtotime, dol_getdate
|
||||
@ -1046,11 +1046,11 @@ function dol_mktime($hour,$minute,$second,$month,$day,$year,$gm=false,$check=1)
|
||||
$dt = new DateTime(null,$localtz);
|
||||
$dt->setDate($year,$month,$day);
|
||||
$dt->setTime((int) $hour, (int) $minute, (int) $second);
|
||||
$date=$dt->getTimestamp();
|
||||
$date=$dt->getTimestamp(); // should include daylight saving time
|
||||
}
|
||||
else
|
||||
{
|
||||
dol_print_error('','PHP version must be 5.2+');
|
||||
dol_print_error('','PHP version must be 5.3+');
|
||||
/*
|
||||
$usealternatemethod=false;
|
||||
if ($year <= 1970) $usealternatemethod=true; // <= 1970
|
||||
|
||||
@ -75,9 +75,9 @@ if (versioncompare(versionphparray(),array(4,3,10)) < 0) // Minimum to us
|
||||
print '<img src="../theme/eldy/img/error.png" alt="Error"> '.$langs->trans("ErrorPHPVersionTooLow",'4.3.10');
|
||||
$checksok=0; // 0=error, 1=warning
|
||||
}
|
||||
else if (versioncompare(versionphparray(),array(5,2,0)) < 0) // Minimum supported (error if lower)
|
||||
else if (versioncompare(versionphparray(),array(5,3,0)) < 0) // Minimum supported (error if lower)
|
||||
{
|
||||
print '<img src="../theme/eldy/img/warning.png" alt="Error"> '.$langs->trans("WarningPHPVersionTooLow",'5.2.0');
|
||||
print '<img src="../theme/eldy/img/warning.png" alt="Error"> '.$langs->trans("ErrorPHPVersionTooLow",'5.3.0');
|
||||
$checksok=0; // 0=error, 1=warning
|
||||
}
|
||||
else
|
||||
|
||||
@ -367,6 +367,8 @@ class FunctionsLibTest extends PHPUnit_Framework_TestCase
|
||||
*/
|
||||
public function testDolMkTime()
|
||||
{
|
||||
global $conf;
|
||||
|
||||
$result=dol_mktime(25,0,0,1,1,1970,1,1); // Error (25 hours)
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals('',$result);
|
||||
@ -390,7 +392,19 @@ class FunctionsLibTest extends PHPUnit_Framework_TestCase
|
||||
$result=dol_mktime(2,0,0,1,1,1970,0); // 1970-01-01 02:00:00 = 7200 in local area Europe/Paris = 3600 GMT
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$tz=getServerTimeZoneInt('winter'); // +1 in Europe/Paris at this time (this time is winter)
|
||||
$this->assertEquals(7200-($tz*3600),$result); // Should be 7200 if we are at greenwich winter
|
||||
$this->assertEquals(7200-($tz*3600),$result); // 7200 if we are at greenwich winter, 7200-($tz*3600) at local winter
|
||||
|
||||
// Check that tz for paris in winter is used
|
||||
$conf->global->MAIN_SERVER_TZ='Europe/Paris';
|
||||
$result=dol_mktime(2,0,0,1,1,1970,'server'); // 1970-01-01 02:00:00 = 7200 in local area Europe/Paris = 3600 GMT
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals(3600,$result); // 7200 if we are at greenwich winter, 3600 at Europe/Paris
|
||||
|
||||
// Check that daylight saving time is used
|
||||
$conf->global->MAIN_SERVER_TZ='Europe/Paris';
|
||||
$result=dol_mktime(2,0,0,6,1,2014,0); // 2014-06-01 02:00:00 = 1401588000-3600(location)-3600(daylight) in local area Europe/Paris = 1401588000 GMT
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals(1401588000-3600-3600,$result); // 1401588000 are at greenwich summer, 1401588000-3600(location)-3600(daylight) at Europe/Paris summer
|
||||
}
|
||||
|
||||
|
||||
@ -574,11 +588,11 @@ class FunctionsLibTest extends PHPUnit_Framework_TestCase
|
||||
|
||||
// Test RULE 2 (FR-FR)
|
||||
$vat=get_default_tva($companyfr,$companyfr,0);
|
||||
$this->assertEquals(19.6,$vat);
|
||||
$this->assertEquals(20,$vat);
|
||||
|
||||
// Test RULE 2 (FR-MC)
|
||||
$vat=get_default_tva($companyfr,$companymc,0);
|
||||
$this->assertEquals(19.6,$vat);
|
||||
$this->assertEquals(20,$vat);
|
||||
|
||||
// Test RULE 3 (FR-IT)
|
||||
$vat=get_default_tva($companyfr,$companyit,0);
|
||||
@ -586,7 +600,7 @@ class FunctionsLibTest extends PHPUnit_Framework_TestCase
|
||||
|
||||
// Test RULE 4 (FR-IT)
|
||||
$vat=get_default_tva($companyfr,$notcompanyit,0);
|
||||
$this->assertEquals(19.6,$vat);
|
||||
$this->assertEquals(20,$vat);
|
||||
|
||||
// Test RULE 5 (FR-US)
|
||||
$vat=get_default_tva($companyfr,$companyus,0);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user