diff --git a/test/phpunit/NumberingModulesTest.php b/test/phpunit/NumberingModulesTest.php index a6c96d2da11..6e482fe75b0 100644 --- a/test/phpunit/NumberingModulesTest.php +++ b/test/phpunit/NumberingModulesTest.php @@ -167,8 +167,11 @@ class NumberingModulesTest extends PHPUnit\Framework\TestCase $result=$localobject->is_erasable(); print __METHOD__." is_erasable=".$result."\n"; $this->assertGreaterThanOrEqual(1, $result, 'Test for is_erasable, 1st invoice'); // Can be deleted + $localobject2=new Facture($this->savdb); $localobject2->initAsSpecimen(); + $localobject2->fetch_thirdparty(); + $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, $localobject2, 'last'); @@ -195,6 +198,8 @@ class NumberingModulesTest extends PHPUnit\Framework\TestCase $localobject=new Facture($this->savdb); $localobject->initAsSpecimen(); + $localobject->fetch_thirdparty(); + $localobject->date=dol_mktime(12, 0, 0, 1, 1, 1910); // we use year 1910 to be sure to not have existing invoice for this year $numbering=new mod_facture_mercure(); $result=$numbering->getNextValue($mysoc, $localobject); @@ -202,15 +207,21 @@ class NumberingModulesTest extends PHPUnit\Framework\TestCase $result3=$localobject->validate($user, $result); print __METHOD__." result=".$result."\n"; $this->assertEquals('1910-0001', $result, 'Test for {yyyy}-{0000@1} 1st invoice'); // counter must start to 1 + $localobject2=new Facture($this->savdb); $localobject2->initAsSpecimen(); + $localobject2->fetch_thirdparty(); + $localobject2->date=dol_mktime(12, 0, 0, 1, 1, 1910); // we use same year for second invoice (and there is a reset required) $numbering=new mod_facture_mercure(); $result=$numbering->getNextValue($mysoc, $localobject2); print __METHOD__." result=".$result."\n"; $this->assertEquals('1910-0002', $result, 'Test for {yyyy}-{0000@1} 2nd invoice, same day'); // counter must be now 2 + $localobject3=new Facture($this->savdb); $localobject3->initAsSpecimen(); + $localobject3->fetch_thirdparty(); + $localobject3->date=dol_mktime(12, 0, 0, 1, 1, 1911); // we use next year for third invoice (and there is a reset required) $numbering=new mod_facture_mercure(); $result=$numbering->getNextValue($mysoc, $localobject3); @@ -220,8 +231,11 @@ class NumberingModulesTest extends PHPUnit\Framework\TestCase // Same but we add month after year $conf->global->FACTURE_MERCURE_MASK_CREDIT='{yyyy}{mm}-{0000@1}'; $conf->global->FACTURE_MERCURE_MASK_INVOICE='{yyyy}{mm}-{0000@1}'; + $localobject=new Facture($this->savdb); $localobject->initAsSpecimen(); + $localobject->fetch_thirdparty(); + $localobject->date=dol_mktime(12, 0, 0, 1, 1, 1920); // we use year 1920 to be sure to not have existing invoice for this year $numbering=new mod_facture_mercure(); $result=$numbering->getNextValue($mysoc, $localobject); @@ -232,8 +246,11 @@ class NumberingModulesTest extends PHPUnit\Framework\TestCase $result=$localobject->is_erasable(); print __METHOD__." is_erasable=".$result."\n"; $this->assertGreaterThanOrEqual(1, $result); // Can be deleted + $localobject2=new Facture($this->savdb); $localobject2->initAsSpecimen(); + $localobject2->fetch_thirdparty(); + $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, $localobject2); @@ -253,6 +270,7 @@ class NumberingModulesTest extends PHPUnit\Framework\TestCase $conf->global->FACTURE_MERCURE_MASK_INVOICE='{mm}{yy}-{0000@1}'; $localobject=new Facture($this->savdb); $localobject->initAsSpecimen(); + $localobject->fetch_thirdparty(); $localobject->date=dol_mktime(12, 0, 0, 1, 1, 1925); // we use year 1925 to be sure to not have existing invoice for this year $numbering=new mod_facture_mercure(); $result=$numbering->getNextValue($mysoc, $localobject); @@ -263,8 +281,10 @@ class NumberingModulesTest extends PHPUnit\Framework\TestCase $result=$localobject->is_erasable(); // This call get getNextNumRef with param 'last' print __METHOD__." is_erasable=".$result."\n"; $this->assertGreaterThanOrEqual(1, $result); // Can be deleted + $localobject2=new Facture($this->savdb); $localobject2->initAsSpecimen(); + $localobject2->fetch_thirdparty(); $localobject2->date=dol_mktime(12, 0, 0, 1, 1, 1925); // we use same year 1925 for second invoice (and there is a reset required) $numbering=new mod_facture_mercure(); $result=$numbering->getNextValue($mysoc, $localobject2); @@ -278,8 +298,10 @@ class NumberingModulesTest extends PHPUnit\Framework\TestCase $result=$localobject->is_erasable(); print __METHOD__." is_erasable=".$result."\n"; $this->assertLessThanOrEqual(0, $result); // Case 1 can not be deleted (because there is an invoice 2) + $localobject3=new Facture($this->savdb); $localobject3->initAsSpecimen(); + $localobject3->fetch_thirdparty(); $localobject3->date=dol_mktime(12, 0, 0, 1, 1, 1926); // we use following year for third invoice (and there is a reset required) $numbering=new mod_facture_mercure(); $result=$numbering->getNextValue($mysoc, $localobject3); @@ -297,6 +319,8 @@ class NumberingModulesTest extends PHPUnit\Framework\TestCase $localobject=new Facture($this->savdb); $localobject->initAsSpecimen(); + $localobject->fetch_thirdparty(); + $localobject->date=dol_mktime(12, 0, 0, 1, 1, 1930); // we use year 1930 to be sure to not have existing invoice for this year $numbering=new mod_facture_mercure(); $result=$numbering->getNextValue($mysoc, $localobject, 'last'); @@ -313,6 +337,8 @@ class NumberingModulesTest extends PHPUnit\Framework\TestCase $localobject=new Facture($this->savdb); $localobject->initAsSpecimen(); + $localobject->fetch_thirdparty(); + $localobject->date=dol_mktime(12, 0, 0, 12, 1, 1930); // we use same year but fiscal month after $numbering=new mod_facture_mercure(); $result=$numbering->getNextValue($mysoc, $localobject, 'last'); @@ -326,6 +352,8 @@ class NumberingModulesTest extends PHPUnit\Framework\TestCase $localobject=new Facture($this->savdb); $localobject->initAsSpecimen(); + $localobject->fetch_thirdparty(); + $localobject->date=dol_mktime(12, 0, 0, 1, 1, 1931); // we use same fiscal year but different year $numbering=new mod_facture_mercure(); $result=$numbering->getNextValue($mysoc, $localobject); @@ -336,6 +364,8 @@ class NumberingModulesTest extends PHPUnit\Framework\TestCase $localobject=new Facture($this->savdb); $localobject->initAsSpecimen(); + $localobject->fetch_thirdparty(); + $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); @@ -350,6 +380,8 @@ class NumberingModulesTest extends PHPUnit\Framework\TestCase $localobject=new Facture($this->savdb); $localobject->initAsSpecimen(); + $localobject->fetch_thirdparty(); + $localobject->date=dol_mktime(12, 0, 0, 1, 1, 1940); // we use year 1940 to be sure to not have existing invoice for this year $numbering=new mod_facture_mercure(); $result=$numbering->getNextValue($mysoc, $localobject); @@ -360,6 +392,8 @@ class NumberingModulesTest extends PHPUnit\Framework\TestCase $localobject=new Facture($this->savdb); $localobject->initAsSpecimen(); + $localobject->fetch_thirdparty(); + $localobject->date=dol_mktime(12, 0, 0, 12, 1, 1940); // we use same year but fiscal month after $numbering=new mod_facture_mercure(); $result=$numbering->getNextValue($mysoc, $localobject); @@ -380,6 +414,8 @@ class NumberingModulesTest extends PHPUnit\Framework\TestCase $localobject=new Facture($this->savdb); $localobject->initAsSpecimen(); + $localobject->fetch_thirdparty(); + $localobject->date=dol_mktime(12, 0, 0, 12, 1, 1941); // we use different discal year but same year $numbering=new mod_facture_mercure(); $result=$numbering->getNextValue($mysoc, $localobject); @@ -394,6 +430,8 @@ class NumberingModulesTest extends PHPUnit\Framework\TestCase $localobject=new Facture($this->savdb); $localobject->initAsSpecimen(); + $localobject->fetch_thirdparty(); + $localobject->date=dol_mktime(12, 0, 0, 1, 1, 1950); // we use year 1950 to be sure to not have existing invoice for this year $numbering=new mod_facture_mercure(); $result=$numbering->getNextValue($mysoc, $localobject); @@ -404,6 +442,8 @@ class NumberingModulesTest extends PHPUnit\Framework\TestCase $localobject=new Facture($this->savdb); $localobject->initAsSpecimen(); + $localobject->fetch_thirdparty(); + $localobject->date=dol_mktime(12, 0, 0, 12, 1, 1950); // we use same year but fiscal month after $numbering=new mod_facture_mercure(); $result=$numbering->getNextValue($mysoc, $localobject); @@ -414,6 +454,8 @@ class NumberingModulesTest extends PHPUnit\Framework\TestCase $localobject=new Facture($this->savdb); $localobject->initAsSpecimen(); + $localobject->fetch_thirdparty(); + $localobject->date=dol_mktime(12, 0, 0, 1, 1, 1951); // we use same fiscal year but different year $numbering=new mod_facture_mercure(); $result=$numbering->getNextValue($mysoc, $localobject); @@ -424,6 +466,8 @@ class NumberingModulesTest extends PHPUnit\Framework\TestCase $localobject=new Facture($this->savdb); $localobject->initAsSpecimen(); + $localobject->fetch_thirdparty(); + $localobject->date=dol_mktime(12, 0, 0, 12, 1, 1951); // we use different discal year but same year $numbering=new mod_facture_mercure(); $result=$numbering->getNextValue($mysoc, $localobject); @@ -438,6 +482,8 @@ class NumberingModulesTest extends PHPUnit\Framework\TestCase $localobject=new Facture($this->savdb); $localobject->initAsSpecimen(); + $localobject->fetch_thirdparty(); + $localobject->date=dol_mktime(12, 0, 0, 1, 1, 1960); // we use year 1960 to be sure to not have existing invoice for this year $numbering=new mod_facture_mercure(); $result=$numbering->getNextValue($mysoc, $localobject); @@ -448,6 +494,8 @@ class NumberingModulesTest extends PHPUnit\Framework\TestCase $localobject=new Facture($this->savdb); $localobject->initAsSpecimen(); + $localobject->fetch_thirdparty(); + $localobject->date=dol_mktime(12, 0, 0, 12, 1, 1960); // we use same year but fiscal month after $numbering=new mod_facture_mercure(); $result=$numbering->getNextValue($mysoc, $localobject); @@ -458,6 +506,8 @@ class NumberingModulesTest extends PHPUnit\Framework\TestCase $localobject=new Facture($this->savdb); $localobject->initAsSpecimen(); + $localobject->fetch_thirdparty(); + $localobject->date=dol_mktime(12, 0, 0, 1, 1, 1961); // we use same fiscal year but different year $numbering=new mod_facture_mercure(); $result=$numbering->getNextValue($mysoc, $localobject); @@ -468,6 +518,8 @@ class NumberingModulesTest extends PHPUnit\Framework\TestCase $localobject=new Facture($this->savdb); $localobject->initAsSpecimen(); + $localobject->fetch_thirdparty(); + $localobject->date=dol_mktime(12, 0, 0, 12, 1, 1961); // we use different discal year but same year $numbering=new mod_facture_mercure(); $result=$numbering->getNextValue($mysoc, $localobject); @@ -482,6 +534,8 @@ class NumberingModulesTest extends PHPUnit\Framework\TestCase $localobject=new Facture($this->savdb); $localobject->initAsSpecimen(); + $localobject->fetch_thirdparty(); + $localobject->date=dol_mktime(12, 0, 0, 1, 1, 1970); // we use year 1970 to be sure to not have existing invoice for this year $numbering=new mod_facture_mercure(); $result=$numbering->getNextValue($mysoc, $localobject); @@ -492,6 +546,8 @@ class NumberingModulesTest extends PHPUnit\Framework\TestCase $localobject=new Facture($this->savdb); $localobject->initAsSpecimen(); + $localobject->fetch_thirdparty(); + $localobject->date=dol_mktime(12, 0, 0, 12, 1, 1970); // we use same year but fiscal month after $numbering=new mod_facture_mercure(); $result=$numbering->getNextValue($mysoc, $localobject); @@ -502,6 +558,8 @@ class NumberingModulesTest extends PHPUnit\Framework\TestCase $localobject=new Facture($this->savdb); $localobject->initAsSpecimen(); + $localobject->fetch_thirdparty(); + $localobject->date=dol_mktime(12, 0, 0, 1, 1, 1971); // we use same fiscal year but different year $numbering=new mod_facture_mercure(); $result=$numbering->getNextValue($mysoc, $localobject); @@ -512,6 +570,8 @@ class NumberingModulesTest extends PHPUnit\Framework\TestCase $localobject=new Facture($this->savdb); $localobject->initAsSpecimen(); + $localobject->fetch_thirdparty(); + $localobject->date=dol_mktime(12, 0, 0, 12, 1, 1971); // we use different fiscal year but same year $numbering=new mod_facture_mercure(); $result=$numbering->getNextValue($mysoc, $localobject); @@ -555,6 +615,8 @@ class NumberingModulesTest extends PHPUnit\Framework\TestCase $localobject=new Facture($this->savdb); $localobject->initAsSpecimen(); + $localobject->fetch_thirdparty(); + $localobject->date=dol_mktime(12, 0, 0, 1, 1, 1981); // we use year 1981 to be sure to not have existing invoice for this year $numbering=new mod_facture_mercure(); $result=$numbering->getNextValue($mysoc, $localobject); @@ -574,6 +636,8 @@ class NumberingModulesTest extends PHPUnit\Framework\TestCase $localobject=new Facture($this->savdb); $localobject->initAsSpecimen(); + $localobject->fetch_thirdparty(); + $localobject->date=dol_mktime(12, 0, 0, 1, 1, 1982); // we use year 1982 to be sure to not have existing invoice for this year $numbering=new mod_facture_mercure(); $result=$numbering->getNextValue($tmpthirdparty, $localobject);