Fix: récupération de l'avoir de propale vers commande

This commit is contained in:
Regis Houssin 2007-04-04 10:18:38 +00:00
parent b677f9e714
commit c96d42bc7c
3 changed files with 59 additions and 52 deletions

View File

@ -63,9 +63,11 @@ class Commande extends CommonObject
var $adresse; var $adresse;
var $date; // Date commande var $date; // Date commande
var $date_livraison; // Date livraison souhaitée var $date_livraison; // Date livraison souhaitée
var $fk_remise_except;
var $remise_percent; var $remise_percent;
var $remise_absolue; var $remise_absolue;
var $modelpdf; var $modelpdf;
var $info_bits;
var $lines = array(); var $lines = array();
@ -114,16 +116,18 @@ class Commande extends CommonObject
$this->source = 0; $this->source = 0;
for ($i = 0 ; $i < sizeof($propal->lignes) ; $i++) for ($i = 0 ; $i < sizeof($propal->lignes) ; $i++)
{ {
$CommLigne = new CommandeLigne($this->db); $CommLigne = new CommandeLigne($this->db);
$CommLigne->libelle = $propal->lignes[$i]->libelle; $CommLigne->libelle = $propal->lignes[$i]->libelle;
$CommLigne->desc = $propal->lignes[$i]->desc; $CommLigne->desc = $propal->lignes[$i]->desc;
$CommLigne->price = $propal->lignes[$i]->price; $CommLigne->price = $propal->lignes[$i]->price;
$CommLigne->subprice = $propal->lignes[$i]->subprice; $CommLigne->subprice = $propal->lignes[$i]->subprice;
$CommLigne->tva_tx = $propal->lignes[$i]->tva_tx; $CommLigne->tva_tx = $propal->lignes[$i]->tva_tx;
$CommLigne->qty = $propal->lignes[$i]->qty; $CommLigne->qty = $propal->lignes[$i]->qty;
$CommLigne->remise_percent = $propal->lignes[$i]->remise_percent; $CommLigne->fk_remise_except = $propal->lignes[$i]->fk_remise_except;
$CommLigne->fk_product = $propal->lignes[$i]->fk_product; $CommLigne->remise_percent = $propal->lignes[$i]->remise_percent;
$this->lines[$i] = $CommLigne; $CommLigne->fk_product = $propal->lignes[$i]->fk_product;
$CommLigne->info_bits = $propal->lignes[$i]->info_bits;
$this->lines[$i] = $CommLigne;
} }
$this->socid = $propal->socid; $this->socid = $propal->socid;
@ -477,22 +481,22 @@ class Commande extends CommonObject
// Vérification paramètres // Vérification paramètres
if ($this->source < 0) if ($this->source < 0)
{ {
$this->error=$langs->trans("ErrorFieldRequired",$langs->trans("Source")); $this->error=$langs->trans("ErrorFieldRequired",$langs->trans("Source"));
dolibarr_syslog("Commande.class.php::create ".$this->error, LOG_ERR); dolibarr_syslog("Commande.class.php::create ".$this->error, LOG_ERR);
return -1; return -1;
} }
if (! $remise) $remise=0; if (! $remise) $remise=0;
if (! $this->projetid) $this->projetid = 0; if (! $this->projetid) $this->projetid = 0;
$soc = new Societe($this->db); $soc = new Societe($this->db);
$result=$soc->fetch($this->socid); $result=$soc->fetch($this->socid);
if ($result < 0) if ($result < 0)
{ {
$this->error="Failed to fetch company"; $this->error="Failed to fetch company";
dolibarr_syslog("Commande.class.php::create ".$this->error, LOG_ERR); dolibarr_syslog("Commande.class.php::create ".$this->error, LOG_ERR);
return -2; return -2;
} }
$this->db->begin(); $this->db->begin();
@ -525,14 +529,16 @@ class Commande extends CommonObject
*/ */
for ($i = 0 ; $i < sizeof($this->lines) ; $i++) for ($i = 0 ; $i < sizeof($this->lines) ; $i++)
{ {
$resql = $this->addline( $resql = $this->addline(
$this->id, $this->id,
$this->lines[$i]->desc, $this->lines[$i]->desc,
$this->lines[$i]->subprice, $this->lines[$i]->subprice,
$this->lines[$i]->qty, $this->lines[$i]->qty,
$this->lines[$i]->tva_tx, $this->lines[$i]->tva_tx,
$this->lines[$i]->fk_product, $this->lines[$i]->fk_product,
$this->lines[$i]->remise_percent $this->lines[$i]->remise_percent,
$this->lines[$i]->fk_remise_except,
$this->lines[$i]->info_bits
); );
if ($resql < 0) if ($resql < 0)
@ -615,7 +621,7 @@ class Commande extends CommonObject
* par l'appelant par la methode get_default_tva(societe_vendeuse,societe_acheteuse,taux_produit) * par l'appelant par la methode get_default_tva(societe_vendeuse,societe_acheteuse,taux_produit)
* et le desc doit deja avoir la bonne valeur (a l'appelant de gerer le multilangue) * et le desc doit deja avoir la bonne valeur (a l'appelant de gerer le multilangue)
*/ */
function addline($commandeid, $desc, $pu, $qty, $txtva, $fk_product=0, $remise_percent=0) function addline($commandeid, $desc, $pu, $qty, $txtva, $fk_product=0, $remise_percent=0, $fk_remise_except=0, $info_bits=0)
{ {
dolibarr_syslog("Commande.class.php::addline this->id=$this->id, $commandeid, $desc, $pu, $qty, $txtva, $fk_product, $remise_percent"); dolibarr_syslog("Commande.class.php::addline this->id=$this->id, $commandeid, $desc, $pu, $qty, $txtva, $fk_product, $remise_percent");
include_once(DOL_DOCUMENT_ROOT.'/lib/price.lib.php'); include_once(DOL_DOCUMENT_ROOT.'/lib/price.lib.php');
@ -656,6 +662,7 @@ class Commande extends CommonObject
$ligne->qty=$qty; $ligne->qty=$qty;
$ligne->tva_tx=$txtva; $ligne->tva_tx=$txtva;
$ligne->fk_product=$fk_product; $ligne->fk_product=$fk_product;
$ligne->fk_remise_except=$fk_remise_except;
$ligne->remise_percent=$remise_percent; $ligne->remise_percent=$remise_percent;
$ligne->subprice=$pu; $ligne->subprice=$pu;
$ligne->rang=-1; $ligne->rang=-1;
@ -671,7 +678,7 @@ class Commande extends CommonObject
$result=$ligne->insert(); $result=$ligne->insert();
if ($result > 0) if ($result > 0)
{ {
// Mise a jour informations denormalisees au niveau de la facture meme // Mise a jour informations denormalisees au niveau de la commande meme
$result=$this->update_price($this->id); $result=$this->update_price($this->id);
if ($result > 0) if ($result > 0)

View File

@ -1332,7 +1332,7 @@ else
{ {
$discount=new DiscountAbsolute($db); $discount=new DiscountAbsolute($db);
$discount->fetch($objp->fk_remise_except); $discount->fetch($objp->fk_remise_except);
print ' - '.$langs->transnoentities("DiscountFromCreditNote",$discount->getNomUrl()); print ' - '.$langs->transnoentities("DiscountFromCreditNote",$discount->getNomUrl(0));
} }
else else
{ {

View File

@ -786,8 +786,8 @@ class Propal extends CommonObject
$sql.= ", p.fk_mode_reglement, cp.code as mode_reglement_code"; $sql.= ", p.fk_mode_reglement, cp.code as mode_reglement_code";
$sql.= ", c.label as statut_label"; $sql.= ", c.label as statut_label";
$sql.= " FROM ".MAIN_DB_PREFIX."c_propalst as c, ".MAIN_DB_PREFIX."propal as p"; $sql.= " FROM ".MAIN_DB_PREFIX."c_propalst as c, ".MAIN_DB_PREFIX."propal as p";
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as cp ON p.fk_mode_reglement = cp.id'; $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as cp ON p.fk_mode_reglement = cp.id';
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'cond_reglement as cr ON p.fk_cond_reglement = cr.rowid'; $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'cond_reglement as cr ON p.fk_cond_reglement = cr.rowid';
$sql.= " WHERE p.fk_statut = c.id"; $sql.= " WHERE p.fk_statut = c.id";
$sql.= " AND p.rowid='".$rowid."'"; $sql.= " AND p.rowid='".$rowid."'";
@ -822,12 +822,12 @@ class Propal extends CommonObject
$this->note_public = $obj->note_public; $this->note_public = $obj->note_public;
$this->statut = $obj->fk_statut; $this->statut = $obj->fk_statut;
$this->statut_libelle = $obj->statut_label; $this->statut_libelle = $obj->statut_label;
$this->mode_reglement_id = $obj->fk_mode_reglement; $this->mode_reglement_id = $obj->fk_mode_reglement;
$this->mode_reglement_code = $obj->mode_reglement_code; $this->mode_reglement_code = $obj->mode_reglement_code;
$this->cond_reglement_id = $obj->fk_cond_reglement; $this->cond_reglement_id = $obj->fk_cond_reglement;
$this->cond_reglement_code = $obj->cond_reglement_code; $this->cond_reglement_code = $obj->cond_reglement_code;
$this->date_livraison = $obj->date_livraison; $this->date_livraison = $obj->date_livraison;
$this->adresse_livraison_id = $obj->fk_adresse_livraison; $this->adresse_livraison_id = $obj->fk_adresse_livraison;
$this->user_author_id = $obj->fk_user_author; $this->user_author_id = $obj->fk_user_author;
@ -876,32 +876,32 @@ class Propal extends CommonObject
while ($i < $num) while ($i < $num)
{ {
$objp = $this->db->fetch_object($result); $objp = $this->db->fetch_object($result);
$ligne = new PropaleLigne($this->db); $ligne = new PropaleLigne($this->db);
$ligne->desc = $objp->description; // Description ligne $ligne->desc = $objp->description; // Description ligne
$ligne->qty = $objp->qty; $ligne->qty = $objp->qty;
$ligne->tva_tx = $objp->tva_tx; $ligne->tva_tx = $objp->tva_tx;
$ligne->subprice = $objp->subprice; $ligne->subprice = $objp->subprice;
$ligne->fk_remise_except = $objp->fk_remise_except; $ligne->fk_remise_except = $objp->fk_remise_except;
$ligne->remise_percent = $objp->remise_percent; $ligne->remise_percent = $objp->remise_percent;
$ligne->price = $objp->price; $ligne->price = $objp->price;
$ligne->info_bits = $objp->info_bits; $ligne->info_bits = $objp->info_bits;
$ligne->total_ht = $objp->total_ht; $ligne->total_ht = $objp->total_ht;
$ligne->total_tva = $objp->total_tva; $ligne->total_tva = $objp->total_tva;
$ligne->total_ttc = $objp->total_ttc; $ligne->total_ttc = $objp->total_ttc;
$ligne->coef = $objp->coef; $ligne->coef = $objp->coef;
$ligne->rang = $objp->rang; $ligne->rang = $objp->rang;
$ligne->fk_product = $objp->fk_product; $ligne->fk_product = $objp->fk_product;
$ligne->libelle = $objp->label; // Label produit $ligne->libelle = $objp->label; // Label produit
$ligne->product_desc = $objp->product_desc; // Description produit $ligne->product_desc = $objp->product_desc; // Description produit
$ligne->ref = $objp->ref; $ligne->ref = $objp->ref;
$this->lignes[$i] = $ligne; $this->lignes[$i] = $ligne;
//dolibarr_syslog("1 ".$ligne->fk_product); //dolibarr_syslog("1 ".$ligne->fk_product);
//print "xx $i ".$this->lignes[$i]->fk_product; //print "xx $i ".$this->lignes[$i]->fk_product;
$i++; $i++;