mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2025-02-20 13:46:52 +01:00
Qual: Include is_erasable() into test
This commit is contained in:
parent
4fe49b6736
commit
5b110ebae9
|
|
@ -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}';
|
||||
|
|
@ -233,7 +257,7 @@ class NumberingModulesTest extends PHPUnit_Framework_TestCase
|
|||
|
||||
$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
|
||||
$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";
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user