diff --git a/htdocs/compta/facture/class/facture-rec.class.php b/htdocs/compta/facture/class/facture-rec.class.php index 3fefc83c6b7..09ee7806eed 100644 --- a/htdocs/compta/facture/class/facture-rec.class.php +++ b/htdocs/compta/facture/class/facture-rec.class.php @@ -1391,16 +1391,6 @@ class FactureRec extends CommonInvoice $error++; } } - if (!$error && !$notrigger) { - // Call trigger - $result = $facturerec->call_trigger('BILLREC_CREATEBILL', $user); - if ($result < 0) { - $this->errors = $facturerec->errors; - $this->error = $facturerec->error; - $error++; - } - // End call triggers - } } else { $error++; $this->error = "Failed to load invoice template with id=".$line->rowid.", entity=".$conf->entity."\n"; diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 71480ff988b..7b8b534eed8 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -1090,9 +1090,18 @@ class Facture extends CommonInvoice if ($result < 0) { $error++; } + + //special case for recurring invoices, moved from facture-rec.class.php + if (!$error && $this->fac_rec > 0) { + $result = $this->call_trigger('BILLREC_CREATEBILL', $user); + if ($result < 0) { + $error++; + } + } // End call triggers } + if (!$error) { $this->db->commit(); return $this->id;