Skip to content
Snippets Groups Projects
Commit 3a474a22 authored by Laurent Destailleur's avatar Laurent Destailleur
Browse files

Qual: Include is_erasable() into test

Conflicts:
	test/phpunit/NumberingModulesTest.php
parent a5deb8e9
No related branches found
No related tags found
No related merge requests found
......@@ -131,6 +131,7 @@ class NumberingModulesTest extends PHPUnit_Framework_TestCase
// First we try with a simple mask, with no reset
// and we test counter is still increase second year.
$conf->global->FACTURE_ADDON='mercure';
$conf->global->FACTURE_MERCURE_MASK_CREDIT='{yyyy}-{0000}';
$conf->global->FACTURE_MERCURE_MASK_INVOICE='{yyyy}-{0000}';
......@@ -143,17 +144,29 @@ class NumberingModulesTest extends PHPUnit_Framework_TestCase
$result3=$localobject->validate($user, $result); // create invoice by forcing ref
print __METHOD__." result=".$result."\n";
$this->assertEquals('1915-0001', $result); // counter must start to 1
$localobject=new Facture($this->savdb);
$localobject->initAsSpecimen();
$localobject->date=dol_mktime(12, 0, 0, 1, 1, 1916); // we use following year for second invoice (there is no reset into mask)
$result=$localobject->is_erasable();
print __METHOD__." is_erasable=".$result."\n";
$this->assertEquals(1, $result); // Can be deleted
$localobject2=new Facture($this->savdb);
$localobject2->initAsSpecimen();
$localobject2->date=dol_mktime(12, 0, 0, 1, 1, 1916); // we use following year for second invoice (there is no reset into mask)
$numbering=new mod_facture_mercure();
$result=$numbering->getNextValue($mysoc, $localobject, 'last');
$result=$numbering->getNextValue($mysoc, $localobject2, 'last');
print __METHOD__." result=".$result."\n";
$this->assertEquals('1915-0001', $result);
$result=$numbering->getNextValue($mysoc, $localobject);
$result=$numbering->getNextValue($mysoc, $localobject2);
$result2=$localobject2->create($user,1);
$result3=$localobject2->validate($user, $result); // create invoice by forcing ref
print __METHOD__." result=".$result."\n";
$this->assertEquals('1916-0002', $result); // counter must not be reseted so be 2
$result=$localobject2->is_erasable();
print __METHOD__." is_erasable=".$result."\n";
$this->assertEquals(1, $result); // Can be deleted
$result=$localobject->is_erasable();
print __METHOD__." is_erasable=".$result."\n";
$this->assertEquals(0, $result); // Case 1 can not be deleted (case 2 is more recent)
// Now we try with a reset
$conf->global->FACTURE_MERCURE_MASK_CREDIT='{yyyy}-{0000@1}';
$conf->global->FACTURE_MERCURE_MASK_INVOICE='{yyyy}-{0000@1}';
......@@ -178,15 +191,26 @@ class NumberingModulesTest extends PHPUnit_Framework_TestCase
$result3=$localobject->validate($user, $result);
print __METHOD__." result=".$result."\n";
$this->assertEquals('192001-0001', $result); // counter must start to 1
$localobject=new Facture($this->savdb);
$localobject->initAsSpecimen();
$localobject->date=dol_mktime(12, 0, 0, 1, 1, 1921); // we use following year for second invoice (and there is a reset required)
$result=$localobject->is_erasable();
print __METHOD__." is_erasable=".$result."\n";
$this->assertEquals(1, $result); // Can be deleted
$localobject2=new Facture($this->savdb);
$localobject2->initAsSpecimen();
$localobject2->date=dol_mktime(12, 0, 0, 1, 1, 1921); // we use following year for second invoice (and there is a reset required)
$numbering=new mod_facture_mercure();
$result=$numbering->getNextValue($mysoc, $localobject);
print __METHOD__." result=".$result."\n";
$result=$numbering->getNextValue($mysoc, $localobject2);
$result2=$localobject2->create($user,1);
$result3=$localobject2->validate($user, $result);
print __METHOD__." result=".$result."\n";
$this->assertEquals('192101-0001', $result); // counter must be reseted to 1
$result=$localobject2->is_erasable();
print __METHOD__." is_erasable=".$result."\n";
$this->assertEquals(1, $result); // Can be deleted
$result=$localobject->is_erasable();
print __METHOD__." is_erasable=".$result."\n";
$this->assertEquals(1, $result); // Case 1 can be deleted (because there was a reset for case 2)
// Now we try with a different fiscal month (forced by mask)
$conf->global->FACTURE_MERCURE_MASK_CREDIT='{yyyy}{mm}-{0000@6}';
......@@ -231,12 +255,12 @@ class NumberingModulesTest extends PHPUnit_Framework_TestCase
print __METHOD__." result=".$result."\n";
$this->assertEquals('193101-0002', $result); // counter must be 2
$localobject=new Facture($this->savdb);
$localobject->initAsSpecimen();
$localobject->date=dol_mktime(12, 0, 0, 12, 1, 1931); // we use different discal year but same year
$numbering=new mod_facture_mercure();
$result=$numbering->getNextValue($mysoc, $localobject);
print __METHOD__." result=".$result."\n";
$localobject=new Facture($this->savdb);
$localobject->initAsSpecimen();
$localobject->date=dol_mktime(12, 0, 0, 12, 1, 1931); // we use different fiscal year but same year
$numbering=new mod_facture_mercure();
$result=$numbering->getNextValue($mysoc, $localobject);
print __METHOD__." result=".$result."\n";
$this->assertEquals('193112-0001', $result); // counter must be reset to 1
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment