From 850ec25f23541fefd27814e2eb642782ce96dde3 Mon Sep 17 00:00:00 2001 From: Eric Seigne Date: Tue, 2 Apr 2024 21:29:21 +0200 Subject: [PATCH 1/2] move BILLREC_CREATEBILL to facture because of user can click on button "create" from ui, not only from cron --- htdocs/compta/facture/class/facture-rec.class.php | 10 ---------- htdocs/compta/facture/class/facture.class.php | 9 +++++++++ 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/htdocs/compta/facture/class/facture-rec.class.php b/htdocs/compta/facture/class/facture-rec.class.php index e8c965f5937..aa1a45e0b36 100644 --- a/htdocs/compta/facture/class/facture-rec.class.php +++ b/htdocs/compta/facture/class/facture-rec.class.php @@ -1367,16 +1367,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 b610327f7e9..9bb919de5bd 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -1092,9 +1092,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 = $facturerec->call_trigger('BILLREC_CREATEBILL', $user); + if ($result < 0) { + $error++; + } + } // End call triggers } + if (!$error) { $this->db->commit(); return $this->id; From 6bd2d78fc9d1d2b9f181cd2880b2792943afaa18 Mon Sep 17 00:00:00 2001 From: Eric Seigne Date: Tue, 2 Apr 2024 21:35:25 +0200 Subject: [PATCH 2/2] fix object call --- htdocs/compta/facture/class/facture.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 9bb919de5bd..e01d5442d03 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -1095,7 +1095,7 @@ class Facture extends CommonInvoice //special case for recurring invoices, moved from facture-rec.class.php if (!$error && $this->fac_rec > 0) { - $result = $facturerec->call_trigger('BILLREC_CREATEBILL', $user); + $result = $this->call_trigger('BILLREC_CREATEBILL', $user); if ($result < 0) { $error++; }