diff --git a/ChangeLog b/ChangeLog index a5dcdbed28bc9341ff353e58603661341578b91a..778855c4fe0ba09e6be0f80dfd41f8383ce905f9 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 e03f381ba2291936a2e95a42c82f7a6b6d8b40be..5c359b718642ba91ddf878d23ec09b0b6c717919 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 [] = '<div class="error">' . $object->error . '</div>'; + 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 [] = '<div class="error">' . $object->error . '</div>'; + setEventMessage($object->error, 'errors'); + $action=''; } } @@ -195,7 +196,7 @@ else if ($action == 'confirm_deleteline' && $confirm == 'yes' && $user->rights-> exit(); } } else { - $mesgs [] = '<div clas="error">' . $object->error . '</div>'; + 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 fb92a3b69e1637da23b87f08e5fbdb5ad6560dcd..096fee84d6ab2a48c0fe0eb3628bd4cdf9eab234 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 93f5f017c446e38f81ad67e864409c53b11d35c8..0eea10bf510afa451cd3423185595a6d8348552c 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 e3257e2bda864c7b3b0c8d1241346cb546dd68f1..093d3800a90607744d6d9d097238e3cff3f95fa3 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); }