Fix numbering of shipments

This commit is contained in:
Laurent Destailleur 2023-08-11 12:14:28 +02:00
parent 0ab376887c
commit df4761e42a
3 changed files with 31 additions and 3 deletions

View File

@ -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)) {

View File

@ -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';
/**

View File

@ -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
}
}