diff --git a/htdocs/compta/prelevement/class/bonprelevement.class.php b/htdocs/compta/prelevement/class/bonprelevement.class.php index 9f9435a986c..7fca836a651 100644 --- a/htdocs/compta/prelevement/class/bonprelevement.class.php +++ b/htdocs/compta/prelevement/class/bonprelevement.class.php @@ -772,17 +772,18 @@ class BonPrelevement extends CommonObject * Create a withdraw * TODO delete params banque and agence when not necesary * - * @param int $banque dolibarr mysoc bank - * @param int $agence dolibarr mysoc bank office (guichet) + * @param int $banque dolibarr mysoc bank + * @param int $agence dolibarr mysoc bank office (guichet) * @param string $mode real=do action, simu=test only * @param string $format FRST, RCUR or ALL - * @param string $executiondate Date to execute the transfer + * @param string $executiondate Date to execute the transfer + * @param int $notrigger Disable triggers * @return int <0 if KO, nbre of invoice withdrawed if OK */ - public function Create($banque = 0, $agence = 0, $mode = 'real', $format = 'ALL', $executiondate = '') + public function Create($banque = 0, $agence = 0, $mode = 'real', $format = 'ALL', $executiondate = '', $notrigger = 0) { // phpcs:enable - global $conf,$langs; + global $conf, $langs, $user; dol_syslog(__METHOD__."::Bank=".$banque." Office=".$agence." mode=".$mode." format=".$format, LOG_DEBUG); @@ -1091,6 +1092,7 @@ class BonPrelevement extends CommonObject } $this->factures = $factures_prev_id; + $this->context['factures_prev'] = $factures_prev; // Generation of SEPA file $this->filename $this->generate($format, $executiondate); @@ -1114,6 +1116,14 @@ class BonPrelevement extends CommonObject dol_syslog(__METHOD__."::Error update total: ".$this->db->error(), LOG_ERR); } + if (! $error && ! $notrigger) + { + // Call trigger + $result=$this->call_trigger('DIRECT_DEBIT_ORDER_CREATE', $user); + if ($result < 0) $error++; + // End call triggers + } + if (!$error) { $this->db->commit();