From e4922f38abf16c0c44c0772ba58cd505cf6f2843 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 25 Jun 2020 14:01:38 +0200 Subject: [PATCH] Add missing extrafield and trigger in template invoice creation --- .../facture/class/facture-rec.class.php | 24 +++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/htdocs/compta/facture/class/facture-rec.class.php b/htdocs/compta/facture/class/facture-rec.class.php index 581e63be08a..242b885375a 100644 --- a/htdocs/compta/facture/class/facture-rec.class.php +++ b/htdocs/compta/facture/class/facture-rec.class.php @@ -199,9 +199,10 @@ class FactureRec extends CommonInvoice * * @param User $user User object * @param int $facid Id of source invoice + * @param int $notrigger No trigger * @return int <0 if KO, id of invoice created if OK */ - public function create($user, $facid) + public function create($user, $facid, $notrigger = 0) { global $conf; @@ -221,7 +222,6 @@ class FactureRec extends CommonInvoice $this->date_when = null; } - $this->frequency = abs($this->frequency); $this->nb_gen_done = 0; $this->nb_gen_max = empty($this->nb_gen_max) ? 0 : $this->nb_gen_max; @@ -389,6 +389,26 @@ class FactureRec extends CommonInvoice } } + if (!$error) { + $result = $this->insertExtraFields(); + if ($result < 0) + { + $error++; + } + } + + if (!$error && !$notrigger) + { + // Call trigger + $result = $this->call_trigger('BILLREC_CREATE', $user); + if ($result < 0) + { + $this->db->rollback(); + return -2; + } + // End call triggers + } + if ($error) { $this->db->rollback();