Merge pull request #11775 from atm-ph/fix_9.0_withdraw_trigger_create_missing

NEW Add trigger DIRECT_DEBIT_ORDER_CREATE on widthdraw is missing
This commit is contained in:
Laurent Destailleur 2019-09-30 18:47:35 +02:00 committed by GitHub
commit 7d3e5288a6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -772,17 +772,18 @@ class BonPrelevement extends CommonObject
* Create a withdraw * Create a withdraw
* TODO delete params banque and agence when not necesary * TODO delete params banque and agence when not necesary
* *
* @param int $banque dolibarr mysoc bank * @param int $banque dolibarr mysoc bank
* @param int $agence dolibarr mysoc bank office (guichet) * @param int $agence dolibarr mysoc bank office (guichet)
* @param string $mode real=do action, simu=test only * @param string $mode real=do action, simu=test only
* @param string $format FRST, RCUR or ALL * @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 * @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 // phpcs:enable
global $conf,$langs; global $conf, $langs, $user;
dol_syslog(__METHOD__."::Bank=".$banque." Office=".$agence." mode=".$mode." format=".$format, LOG_DEBUG); 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->factures = $factures_prev_id;
$this->context['factures_prev'] = $factures_prev;
// Generation of SEPA file $this->filename // Generation of SEPA file $this->filename
$this->generate($format, $executiondate); $this->generate($format, $executiondate);
@ -1114,6 +1116,14 @@ class BonPrelevement extends CommonObject
dol_syslog(__METHOD__."::Error update total: ".$this->db->error(), LOG_ERR); 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) if (!$error)
{ {
$this->db->commit(); $this->db->commit();