Skip to content

Commit

Permalink
Merge pull request #1685 from KreizIT/3.6
Browse files Browse the repository at this point in the history
FIX : #1477, #1478, #1479
  • Loading branch information
eldy committed Jun 26, 2014
2 parents 2b93380 + ee91f4a commit fc44932
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 15 deletions.
3 changes: 3 additions & 0 deletions ChangeLog
Expand Up @@ -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.
Expand Down
15 changes: 10 additions & 5 deletions htdocs/compta/facture.php
Expand Up @@ -124,7 +124,7 @@
header("Location: " . $_SERVER['PHP_SELF'] . '?facid=' . $result);
exit();
} else {
$mesgs [] = $object->error;
setEventMessage($object->error, 'errors');
$action = '';
}
}
Expand All @@ -140,7 +140,7 @@
header('Location: ' . $_SERVER["PHP_SELF"] . '?facid=' . $id);
exit();
} else {
$mesgs [] = '<div class="error">' . $object->error . '</div>';
setEventMessage($object->error, 'errors');
}
}
}
Expand All @@ -164,7 +164,8 @@
header('Location: ' . DOL_URL_ROOT . '/compta/facture/list.php');
exit();
} else {
$mesgs [] = '<div class="error">' . $object->error . '</div>';
setEventMessage($object->error, 'errors');
$action='';
}
}

Expand Down Expand Up @@ -195,7 +196,7 @@
exit();
}
} else {
$mesgs [] = '<div clas="error">' . $object->error . '</div>';
setEventMessage($object->error, 'errors');
$action = '';
}
}
Expand Down Expand Up @@ -453,7 +454,8 @@

// 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;
Expand All @@ -478,13 +480,15 @@
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);
$close_code = $_POST["close_code"];
$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');
}
Expand All @@ -495,6 +499,7 @@
$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');
}
Expand Down
34 changes: 25 additions & 9 deletions htdocs/compta/facture/class/facture.class.php
Expand Up @@ -1564,7 +1564,11 @@ function set_canceled($user,$close_code='',$close_note='')
$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

Expand Down Expand Up @@ -1808,7 +1812,6 @@ function validate($user, $force_number='', $idwarehouse=0)
else
{
$this->db->rollback();
$this->error=$this->db->lasterror();
return -1;
}
}
Expand Down Expand Up @@ -2216,6 +2219,7 @@ function updateline($rowid, $desc, $pu, $qty, $remise_percent, $date_start, $dat
}
else
{
$this->error=$this->line->error;
$this->db->rollback();
return -1;
}
Expand Down Expand Up @@ -2286,7 +2290,7 @@ function deleteline($rowid)
else
{
$this->db->rollback();
$this->error=$this->db->lasterror();
$this->error=$line->error;
return -1;
}
}
Expand Down Expand Up @@ -3570,8 +3574,12 @@ function insert($notrigger=0)
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
}
Expand Down Expand Up @@ -3683,8 +3691,12 @@ function update($user='',$notrigger=0)
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
}
Expand Down Expand Up @@ -3721,8 +3733,12 @@ function delete()
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

Expand Down
10 changes: 9 additions & 1 deletion htdocs/compta/paiement/class/paiement.class.php
Expand Up @@ -221,7 +221,15 @@ function create($user,$closepaidinvoices=0)
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
Expand Down
4 changes: 4 additions & 0 deletions htdocs/core/triggers/interface_90_all_Demo.class.php-NORUN
Expand Up @@ -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);
}
Expand Down

0 comments on commit fc44932

Please sign in to comment.