Dolibarr / dolibarr

Dolibarr ERP CRM is a modern software package to manage your company or foundation's activity (contacts, suppliers, invoices, orders, stocks, agenda, accounting, ...). it's an open source Web application (written in PHP) designed for businesses of any sizes, foundations and freelancers.
https://www.dolibarr.org
GNU General Public License v3.0
5.47k stars 2.8k forks source link

getNextNumRef($soc) not working correctly on external module #31669

Open milenmk opened 2 weeks ago

milenmk commented 2 weeks ago

Bug

On Dolibarr v19.0.3 installation, in a third-party module file, I have the following code:

require_once DOL_DOCUMENT_ROOT . '/comm/propal/class/propal.class.php';
require_once DOL_DOCUMENT_ROOT . '/commande/class/commande.class.php';
require_once DOL_DOCUMENT_ROOT . '/compta/facture/class/facture.class.php';

$soc = new Societe($db);
$propale = new Propal($db);
$commande = new Commande($db);
$facture = new Facture($db);
...
$refPropal = $propale->getNextNumRef($soc);
$refCommande = $commande->getNextNumRef($soc);
$refFacture = $facture->getNextNumRef($soc);

The ref numbers for the proposal and the invoice are generated correctly. However, for the order (commande) I get SO-0001 i.e. the month and the date are not added. For example, the correct value should be SO-2411-0001

The same happens when generating vendor purchase orders.

On Dolibarr v20.0.1, the same problem occurs for the commercial invoice and vendor invoices.

On Dolibarr v17.0.4 and v18.0.6 I have no issues

Is something generally changed in the code or can I think of an incomplete/fault installation?

Dolibarr Version

19.0, 20.0

Environment PHP

8.1.10

Environment Database

My SQL 8.2.0

Steps to reproduce the behavior and expected behavior

No response

Attached files

log.txt

marc-dll commented 14 hours ago

Hello.

Did you set the date of the object ($object->date = dol_now();) before calling the getNextNumRef() method ? . If no, can you please provide more of your code ?

Greetings.