2
0
forked from Wavyzz/dolibarr

gestion de la remise exceptionnelle

This commit is contained in:
Rodolphe Quiedeville
2004-11-09 15:15:58 +00:00
parent 9ded33b807
commit 2fdf46bb3d

View File

@@ -75,6 +75,7 @@ class Facture
$this->projetid = 0;
$this->id = $facid;
$this->prefixe_facture = ''; // utilis<69> dans le module de num<75>rotation saturne
$this->remise_exceptionnelle = 0;
}
/**
@@ -113,6 +114,26 @@ class Facture
$this->db->free();
}
$datelim = $this->date + ( $cdr_nbjour * 3600 * 24 );
/*
* Lecture de la remise exceptionnelle
*
*/
$sql = "SELECT rc.amount_ht";
$sql .= " FROM ".MAIN_DB_PREFIX."societe_remise_except as rc";
$sql .= " WHERE rc.fk_soc =". $this->socidp;
$sql .= " AND fk_facture IS NULL";
if ( $this->db->query($sql) )
{
$nurmx = $this->db->num_rows();
if ($nurmx > 0)
{
$row = $this->db->fetch_row();
$this->remise_exceptionnelle = $row[0];
}
$this->db->free();
}
/*
* Insertion dans la base
*/
@@ -216,6 +237,28 @@ class Facture
*
*
*/
if ($this->remise_exceptionnelle > 0)
{
$result_insert = $this->addline($this->id,
addslashes("Remise exceptionnelle"),
(0 - $this->remise_exceptionnelle),
1,
'19.6');
$sql = "UPDATE ".MAIN_DB_PREFIX."societe_remise_except";
$sql .= " SET fk_facture = $this->id WHERE fk_facture IS NULL";
$this->db->query( $sql) ;
}
/*
*
*
*
*/
$this->updateprice($this->id);
return $this->id;
}
@@ -404,10 +447,20 @@ class Facture
if ($this->db->query( $sql) )
{
$sql = "DELETE FROM ".MAIN_DB_PREFIX."facture WHERE rowid = $rowid AND fk_statut = 0;";
/*
* On repositionne la remise
*/
$sql = "UPDATE ".MAIN_DB_PREFIX."societe_remise_except";
$sql .= " SET fk_facture = NULL WHERE fk_facture = $rowid";
if ($this->db->query( $sql) )
{
$sql = "DELETE FROM ".MAIN_DB_PREFIX."facture WHERE rowid = $rowid AND fk_statut = 0;";
$this->db->query( $sql) ;
return 1;
}
else