Fix multicompany compatibility for recurring invoice generation
This commit is contained in:
parent
14ed19265c
commit
f1ad3912e7
@ -973,6 +973,7 @@ class FactureRec extends CommonInvoice
|
|||||||
$sql.= " AND (date_when IS NULL OR date_when <= '".$db->idate($today)."')";
|
$sql.= " AND (date_when IS NULL OR date_when <= '".$db->idate($today)."')";
|
||||||
$sql.= ' AND (nb_gen_done < nb_gen_max OR nb_gen_max = 0)';
|
$sql.= ' AND (nb_gen_done < nb_gen_max OR nb_gen_max = 0)';
|
||||||
$sql.= ' AND suspended = 0';
|
$sql.= ' AND suspended = 0';
|
||||||
|
$sql.= ' AND entity = '.$conf->entity; // MUST STAY = $conf->entity here
|
||||||
$sql.= $db->order('entity', 'ASC');
|
$sql.= $db->order('entity', 'ASC');
|
||||||
//print $sql;exit;
|
//print $sql;exit;
|
||||||
|
|
||||||
@ -987,7 +988,7 @@ class FactureRec extends CommonInvoice
|
|||||||
|
|
||||||
$saventity = $conf->entity;
|
$saventity = $conf->entity;
|
||||||
|
|
||||||
while ($i < $num) // Loop on each template invoice
|
while ($i < $num) // Loop on each template invoice. If $num = 0, test is false at first pass.
|
||||||
{
|
{
|
||||||
$line = $db->fetch_object($resql);
|
$line = $db->fetch_object($resql);
|
||||||
|
|
||||||
@ -996,6 +997,8 @@ class FactureRec extends CommonInvoice
|
|||||||
$facturerec = new FactureRec($db);
|
$facturerec = new FactureRec($db);
|
||||||
$facturerec->fetch($line->rowid);
|
$facturerec->fetch($line->rowid);
|
||||||
|
|
||||||
|
if ($facturerec->id > 0)
|
||||||
|
{
|
||||||
// Set entity context
|
// Set entity context
|
||||||
$conf->entity = $facturerec->entity;
|
$conf->entity = $facturerec->entity;
|
||||||
|
|
||||||
@ -1039,6 +1042,14 @@ class FactureRec extends CommonInvoice
|
|||||||
$error++;
|
$error++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$error++;
|
||||||
|
$this->error="Failed to load invoice template with id=".$line->rowid.", entity=".$conf->entity."\n";
|
||||||
|
$this->errors[]="Failed to load invoice template with id=".$line->rowid.", entity=".$conf->entity;
|
||||||
|
dol_syslog("createRecurringInvoices Failed to load invoice template with id=".$line->rowid.", entity=".$conf->entity);
|
||||||
|
}
|
||||||
|
|
||||||
if (! $error && $invoiceidgenerated >= 0)
|
if (! $error && $invoiceidgenerated >= 0)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -1044,8 +1044,9 @@ class Cronjob extends CommonObject
|
|||||||
{
|
{
|
||||||
dol_syslog(get_class($this)."::run_jobs START ".$this->objectname."->".$this->methodename."(".$this->params.");", LOG_DEBUG);
|
dol_syslog(get_class($this)."::run_jobs START ".$this->objectname."->".$this->methodename."(".$this->params.");", LOG_DEBUG);
|
||||||
|
|
||||||
// Create Object for the call module
|
// Create Object for the called module
|
||||||
$object = new $this->objectname($this->db);
|
$object = new $this->objectname($this->db);
|
||||||
|
if ($this->entity > 0) $object->entity = $this->entity; // We work on a dedicated entity
|
||||||
|
|
||||||
$params_arr = array_map('trim', explode(",",$this->params));
|
$params_arr = array_map('trim', explode(",",$this->params));
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user