diff --git a/htdocs/core/modules/expedition/mod_expedition_safor.php b/htdocs/core/modules/expedition/mod_expedition_safor.php index c01da143297..29c9299fb73 100644 --- a/htdocs/core/modules/expedition/mod_expedition_safor.php +++ b/htdocs/core/modules/expedition/mod_expedition_safor.php @@ -144,7 +144,7 @@ class mod_expedition_safor extends ModelNumRefExpedition return -1; } - $date = time(); + $date = $shipment->date_creation; $yymm = strftime("%y%m", $date); if ($max >= (pow(10, 4) - 1)) { diff --git a/htdocs/core/modules/expedition/modules_expedition.php b/htdocs/core/modules/expedition/modules_expedition.php index 75c5e6bfeee..249a2bc46e3 100644 --- a/htdocs/core/modules/expedition/modules_expedition.php +++ b/htdocs/core/modules/expedition/modules_expedition.php @@ -31,7 +31,7 @@ */ require_once DOL_DOCUMENT_ROOT.'/core/class/commondocgenerator.class.php'; -require_once DOL_DOCUMENT_ROOT.'/core/class/commondocgenerator.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/commonnumrefgenerator.class.php'; /** diff --git a/test/phpunit/NumberingModulesTest.php b/test/phpunit/NumberingModulesTest.php index 67852e81ccf..3c4a2720ba8 100644 --- a/test/phpunit/NumberingModulesTest.php +++ b/test/phpunit/NumberingModulesTest.php @@ -657,7 +657,35 @@ class NumberingModulesTest extends PHPUnit\Framework\TestCase $this->assertEquals('A198201-0001', $result); // counter must start to 1 - return $result; } + + + /** + * testShipmentSafor + * + * @return int + */ + public function testShipmentSafor() + { + global $conf,$user,$langs,$db,$mysoc; + $conf=$this->savconf; + $user=$this->savuser; + $langs=$this->savlangs; + $db=$this->savdb; + + require_once dirname(__FILE__).'/../../htdocs/expedition/class/expedition.class.php'; + require_once dirname(__FILE__).'/../../htdocs/core/modules/expedition/mod_expedition_safor.php'; + + $localobject=new Expedition($db); + $localobject->initAsSpecimen(); + $localobject->fetch_thirdparty(); + + $localobject->date_creation = dol_mktime(12, 0, 0, 1, 1, 1980); // we use year 1915 to be sure to not have existing invoice for this year (usefull only if numbering is {0000@1} + $numbering=new mod_expedition_safor(); + $result=$numbering->getNextValue($mysoc, $localobject); + + print __METHOD__." result=".$result."\n"; + $this->assertEquals('SH8001-0001', $result); // counter must start to 1 + } }