Fix: [ bug #233 ] Delete invoice problem with a discount

This commit is contained in:
Laurent Destailleur 2011-11-19 19:04:55 +01:00
parent a4570c578e
commit e08e07c493

View File

@ -1205,8 +1205,8 @@ class Facture extends CommonObject
if (sizeof($list_rowid_det)) if (sizeof($list_rowid_det))
{ {
$sql = 'UPDATE '.MAIN_DB_PREFIX.'societe_remise_except'; $sql = 'UPDATE '.MAIN_DB_PREFIX.'societe_remise_except';
$sql.= ' SET fk_facture = NULL'; $sql.= ' SET fk_facture = NULL, fk_facture_line = NULL';
$sql.= ' WHERE fk_facture IN ('.join(',',$list_rowid_det).')'; $sql.= ' WHERE fk_facture_line IN ('.join(',',$list_rowid_det).')';
dol_syslog("Facture.class::delete sql=".$sql); dol_syslog("Facture.class::delete sql=".$sql);
if (! $this->db->query($sql)) if (! $this->db->query($sql))
@ -1644,7 +1644,7 @@ class Facture extends CommonObject
if (! $error) if (! $error)
{ {
$this->oldref = ''; $this->oldref = '';
// Rename directory if dir was a temporary ref // Rename directory if dir was a temporary ref
if (preg_match('/^[\(]?PROV/i', $this->ref)) if (preg_match('/^[\(]?PROV/i', $this->ref))
{ {
@ -1661,7 +1661,7 @@ class Facture extends CommonObject
if (@rename($dirsource, $dirdest)) if (@rename($dirsource, $dirdest))
{ {
$this->oldref = $facref; $this->oldref = $facref;
dol_syslog("Rename ok"); dol_syslog("Rename ok");
// Suppression ancien fichier PDF dans nouveau rep // Suppression ancien fichier PDF dans nouveau rep
dol_delete_file($conf->facture->dir_output.'/'.$snumfa.'/'.$facref.'.*'); dol_delete_file($conf->facture->dir_output.'/'.$snumfa.'/'.$facref.'.*');
@ -1899,7 +1899,7 @@ class Facture extends CommonObject
$this->line->total_tva= (($this->type==2||$qty<0)?-abs($total_tva):$total_tva); $this->line->total_tva= (($this->type==2||$qty<0)?-abs($total_tva):$total_tva);
$this->line->total_localtax1=(($this->type==2||$qty<0)?-abs($total_localtax1):$total_localtax1); $this->line->total_localtax1=(($this->type==2||$qty<0)?-abs($total_localtax1):$total_localtax1);
$this->line->total_localtax2=(($this->type==2||$qty<0)?-abs($total_localtax2):$total_localtax2); $this->line->total_localtax2=(($this->type==2||$qty<0)?-abs($total_localtax2):$total_localtax2);
$this->line->total_ttc= (($this->type==2||$qty<0)?-abs($total_ttc):$total_ttc); $this->line->total_ttc= (($this->type==2||$qty<0)?-abs($total_ttc):$total_ttc);
$this->line->special_code=$special_code; $this->line->special_code=$special_code;
$this->line->fk_parent_line=$fk_parent_line; $this->line->fk_parent_line=$fk_parent_line;
$this->line->origin=$origin; $this->line->origin=$origin;
@ -2003,12 +2003,12 @@ class Facture extends CommonObject
// Update line into database // Update line into database
$this->line=new FactureLigne($this->db); $this->line=new FactureLigne($this->db);
// Stock previous line records // Stock previous line records
$staticline=new FactureLigne($this->db); $staticline=new FactureLigne($this->db);
$staticline->fetch($rowid); $staticline->fetch($rowid);
$this->line->oldline = $staticline; $this->line->oldline = $staticline;
$this->line->rowid = $rowid; $this->line->rowid = $rowid;
$this->line->desc = $desc; $this->line->desc = $desc;
$this->line->qty= ($this->type==2?abs($qty):$qty); // For credit note, quantity is always positive and unit price negative $this->line->qty= ($this->type==2?abs($qty):$qty); // For credit note, quantity is always positive and unit price negative
@ -2023,7 +2023,7 @@ class Facture extends CommonObject
$this->line->total_tva= (($this->type==2||$qty<0)?-abs($total_tva):$total_tva); $this->line->total_tva= (($this->type==2||$qty<0)?-abs($total_tva):$total_tva);
$this->line->total_localtax1=(($this->type==2||$qty<0)?-abs($total_localtax1):$total_localtax1); $this->line->total_localtax1=(($this->type==2||$qty<0)?-abs($total_localtax1):$total_localtax1);
$this->line->total_localtax2=(($this->type==2||$qty<0)?-abs($total_localtax2):$total_localtax2); $this->line->total_localtax2=(($this->type==2||$qty<0)?-abs($total_localtax2):$total_localtax2);
$this->line->total_ttc= (($this->type==2||$qty<0)?-abs($total_ttc):$total_ttc); $this->line->total_ttc= (($this->type==2||$qty<0)?-abs($total_ttc):$total_ttc);
$this->line->info_bits = $info_bits; $this->line->info_bits = $info_bits;
$this->line->product_type = $type; $this->line->product_type = $type;
$this->line->fk_parent_line = $fk_parent_line; $this->line->fk_parent_line = $fk_parent_line;
@ -3255,7 +3255,7 @@ class FactureLigne
{ {
var $db; var $db;
var $error; var $error;
var $oldline; var $oldline;
//! From llx_facturedet //! From llx_facturedet