Merge pull request #24105 from FHenry/dev_fix_delete_info_time_spent_invoice_correctly
fix: remove invoice line id and invoice on time spend when delete line
This commit is contained in:
commit
f8edbc5708
@ -4230,19 +4230,6 @@ class Facture extends CommonInvoice
|
|||||||
|
|
||||||
$this->db->begin();
|
$this->db->begin();
|
||||||
|
|
||||||
// Free discount linked to invoice line
|
|
||||||
$sql = 'UPDATE '.MAIN_DB_PREFIX.'societe_remise_except';
|
|
||||||
$sql .= ' SET fk_facture_line = NULL';
|
|
||||||
$sql .= ' WHERE fk_facture_line = '.((int) $rowid);
|
|
||||||
|
|
||||||
dol_syslog(get_class($this)."::deleteline", LOG_DEBUG);
|
|
||||||
$result = $this->db->query($sql);
|
|
||||||
if (!$result) {
|
|
||||||
$this->error = $this->db->error();
|
|
||||||
$this->db->rollback();
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Memorize previous line for triggers
|
// Memorize previous line for triggers
|
||||||
$staticline = clone $line;
|
$staticline = clone $line;
|
||||||
$line->oldline = $staticline;
|
$line->oldline = $staticline;
|
||||||
@ -6444,13 +6431,38 @@ class FactureLigne extends CommonInvoiceLine
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."facturedet WHERE rowid = ".((int) $this->rowid);
|
// Free discount linked to invoice line
|
||||||
|
$sql = 'UPDATE '.MAIN_DB_PREFIX.'societe_remise_except';
|
||||||
|
$sql .= ' SET fk_facture_line = NULL';
|
||||||
|
$sql .= ' WHERE fk_facture_line = '.((int) $this->id);
|
||||||
|
|
||||||
|
dol_syslog(get_class($this)."::deleteline", LOG_DEBUG);
|
||||||
|
$result = $this->db->query($sql);
|
||||||
|
if (!$result) {
|
||||||
|
$this->error = $this->db->error();
|
||||||
|
$this->errors[] = $this->error;
|
||||||
|
$this->db->rollback();
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
$sql = 'UPDATE '.MAIN_DB_PREFIX.'projet_task_time';
|
||||||
|
$sql .= ' SET invoice_id = NULL, invoice_line_id = NULL';
|
||||||
|
$sql .= ' WHERE invoice_line_id = '.((int) $this->id);
|
||||||
|
if (!$this->db->query($sql)) {
|
||||||
|
$this->error = $this->db->error()." sql=".$sql;
|
||||||
|
$this->errors[] = $this->error;
|
||||||
|
$this->db->rollback();
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
$sql = "DELETE FROM ".MAIN_DB_PREFIX."facturedet WHERE rowid = ".((int) $this->id);
|
||||||
|
|
||||||
if ($this->db->query($sql)) {
|
if ($this->db->query($sql)) {
|
||||||
$this->db->commit();
|
$this->db->commit();
|
||||||
return 1;
|
return 1;
|
||||||
} else {
|
} else {
|
||||||
$this->error = $this->db->error()." sql=".$sql;
|
$this->error = $this->db->error()." sql=".$sql;
|
||||||
|
$this->errors[] = $this->error;
|
||||||
$this->db->rollback();
|
$this->db->rollback();
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user