diff --git a/ChangeLog b/ChangeLog
index 4a88f51c07d..4f6549f7c50 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -65,6 +65,9 @@ For users:
- Fix: Add actions events not implemented.
- Fix: Price min of composition is not supplier price min by quantity.
- Fix: [ bug #1356 ] Bank accountancy number is limited to 8 numbers.
+- Fix: [ bug #1478 ] BILL_PAYED trigger action does not intercept failure under some circumstances
+- Fix: [ bug #1479 ] Several customer invoice triggers do not intercept trigger action
+- Fix: [ bug #1477 ] Several customer invoice triggers do not show trigger error messages
TODO
- New: Predefined product and free product use same form.
diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php
index b22f1c9827e..0c658ffea15 100644
--- a/htdocs/compta/facture.php
+++ b/htdocs/compta/facture.php
@@ -124,7 +124,7 @@ if ($action == 'confirm_clone' && $confirm == 'yes' && $user->rights->facture->c
header("Location: " . $_SERVER['PHP_SELF'] . '?facid=' . $result);
exit();
} else {
- $mesgs [] = $object->error;
+ setEventMessage($object->error, 'errors');
$action = '';
}
}
@@ -140,7 +140,7 @@ else if ($action == 'reopen' && $user->rights->facture->creer) {
header('Location: ' . $_SERVER["PHP_SELF"] . '?facid=' . $id);
exit();
} else {
- $mesgs [] = '
' . $object->error . '
';
+ setEventMessage($object->error, 'errors');
}
}
}
@@ -164,7 +164,8 @@ else if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->fact
header('Location: ' . DOL_URL_ROOT . '/compta/facture/list.php');
exit();
} else {
- $mesgs [] = '' . $object->error . '
';
+ setEventMessage($object->error, 'errors');
+ $action='';
}
}
@@ -195,7 +196,7 @@ else if ($action == 'confirm_deleteline' && $confirm == 'yes' && $user->rights->
exit();
}
} else {
- $mesgs [] = '' . $object->error . '
';
+ setEventMessage($object->error, 'errors');
$action = '';
}
}
@@ -453,7 +454,8 @@ else if ($action == 'confirm_modif' && ((empty($conf->global->MAIN_USE_ADVANCED_
// On verifie si aucun paiement n'a ete effectue
if ($resteapayer == $object->total_ttc && $object->paye == 0 && $ventilExportCompta == 0) {
- $object->set_draft($user, $idwarehouse);
+ $result=$object->set_draft($user, $idwarehouse);
+ if ($result<0) setEventMessage($object->error,'errors');
// Define output language
$outputlangs = $langs;
@@ -478,6 +480,7 @@ else if ($action == 'confirm_modif' && ((empty($conf->global->MAIN_USE_ADVANCED_
else if ($action == 'confirm_paid' && $confirm == 'yes' && $user->rights->facture->paiement) {
$object->fetch($id);
$result = $object->set_paid($user);
+ if ($result<0) setEventMessage($object->error,'errors');
} // Classif "paid partialy"
else if ($action == 'confirm_paid_partially' && $confirm == 'yes' && $user->rights->facture->paiement) {
$object->fetch($id);
@@ -485,6 +488,7 @@ else if ($action == 'confirm_paid_partially' && $confirm == 'yes' && $user->righ
$close_note = $_POST["close_note"];
if ($close_code) {
$result = $object->set_paid($user, $close_code, $close_note);
+ if ($result<0) setEventMessage($object->error,'errors');
} else {
setEventMessage($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Reason")), 'errors');
}
@@ -495,6 +499,7 @@ else if ($action == 'confirm_canceled' && $confirm == 'yes') {
$close_note = $_POST["close_note"];
if ($close_code) {
$result = $object->set_canceled($user, $close_code, $close_note);
+ if ($result<0) setEventMessage($object->error,'errors');
} else {
setEventMessage($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Reason")), 'errors');
}
diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php
index fb92a3b69e1..096fee84d6a 100644
--- a/htdocs/compta/facture/class/facture.class.php
+++ b/htdocs/compta/facture/class/facture.class.php
@@ -1564,7 +1564,11 @@ class Facture extends CommonInvoice
$interface=new Interfaces($this->db);
$result=$interface->run_triggers('BILL_CANCEL',$this,$user,$langs,$conf);
if ($result < 0) {
- $error++; $this->errors=$interface->errors;
+ $error++;
+ $this->errors=$interface->errors;
+ $this->db->rollback();
+ return -1;
+
}
// Fin appel triggers
@@ -1808,7 +1812,6 @@ class Facture extends CommonInvoice
else
{
$this->db->rollback();
- $this->error=$this->db->lasterror();
return -1;
}
}
@@ -2216,6 +2219,7 @@ class Facture extends CommonInvoice
}
else
{
+ $this->error=$this->line->error;
$this->db->rollback();
return -1;
}
@@ -2286,7 +2290,7 @@ class Facture extends CommonInvoice
else
{
$this->db->rollback();
- $this->error=$this->db->lasterror();
+ $this->error=$line->error;
return -1;
}
}
@@ -3570,8 +3574,12 @@ class FactureLigne extends CommonInvoiceLine
include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
$interface=new Interfaces($this->db);
$result = $interface->run_triggers('LINEBILL_INSERT',$this,$user,$langs,$conf);
- if ($result < 0) {
- $error++; $this->errors=$interface->errors;
+ if ($result < 0)
+ {
+ $error++;
+ $this->errors=$interface->errors;
+ $this->db->rollback();
+ return -2;
}
// Fin appel triggers
}
@@ -3683,8 +3691,12 @@ class FactureLigne extends CommonInvoiceLine
include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
$interface=new Interfaces($this->db);
$result = $interface->run_triggers('LINEBILL_UPDATE',$this,$user,$langs,$conf);
- if ($result < 0) {
- $error++; $this->errors=$interface->errors;
+ if ($result < 0)
+ {
+ $error++;
+ $this->errors=$interface->errors;
+ $this->db->rollback();
+ return -2;
}
// Fin appel triggers
}
@@ -3721,8 +3733,12 @@ class FactureLigne extends CommonInvoiceLine
include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
$interface=new Interfaces($this->db);
$result = $interface->run_triggers('LINEBILL_DELETE',$this,$user,$langs,$conf);
- if ($result < 0) {
- $error++; $this->errors=$interface->errors;
+ if ($result < 0)
+ {
+ $error++;
+ $this->errors=$interface->errors;
+ $this->db->rollback();
+ return -1;
}
// Fin appel triggers
diff --git a/htdocs/compta/paiement/class/paiement.class.php b/htdocs/compta/paiement/class/paiement.class.php
index 93f5f017c44..0eea10bf510 100644
--- a/htdocs/compta/paiement/class/paiement.class.php
+++ b/htdocs/compta/paiement/class/paiement.class.php
@@ -221,7 +221,15 @@ class Paiement extends CommonObject
if (!in_array($invoice->type, $affected_types)) dol_syslog("Invoice ".$facid." is not a standard, nor replacement invoice, nor credit note, nor deposit invoice. We do nothing more.");
else if ($remaintopay) dol_syslog("Remain to pay for invoice ".$facid." not null. We do nothing more.");
else if ($mustwait) dol_syslog("There is ".$mustwait." differed payment to process, we do nothing more.");
- else $result=$invoice->set_paid($user,'','');
+ else
+ {
+ $result=$invoice->set_paid($user,'','');
+ if ($result<0)
+ {
+ $this->error=$invoice->error;
+ $error++;
+ }
+ }
}
}
else
diff --git a/htdocs/core/triggers/interface_90_all_Demo.class.php-NORUN b/htdocs/core/triggers/interface_90_all_Demo.class.php-NORUN
index e3257e2bda8..093d3800a90 100644
--- a/htdocs/core/triggers/interface_90_all_Demo.class.php-NORUN
+++ b/htdocs/core/triggers/interface_90_all_Demo.class.php-NORUN
@@ -396,6 +396,10 @@ class InterfaceDemo
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
}
elseif ($action == 'BILL_DELETE')
+ {
+ dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
+ }
+ elseif ($action == 'BILL_PAYED')
{
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
}