Fix: le niveau de prix du client n'était plus récupéré

Fix: ligne produit non enregistrée si pourcentage de remise null
This commit is contained in:
Regis Houssin 2007-10-07 17:50:09 +00:00
parent 674935b14d
commit aed5136806
2 changed files with 61 additions and 60 deletions

View File

@ -487,40 +487,40 @@ if ($_POST['action'] == "addligne" && $user->rights->propale->creer)
{ {
if ($_POST['qty'] && (($_POST['np_price']!='' && $_POST['np_desc']) || $_POST['idprod'])) if ($_POST['qty'] && (($_POST['np_price']!='' && $_POST['np_desc']) || $_POST['idprod']))
{ {
$propal = new Propal($db); $propal = new Propal($db);
$ret=$propal->fetch($_POST['propalid']); $ret=$propal->fetch($_POST['propalid']);
if ($ret < 0) if ($ret < 0)
{ {
dolibarr_print_error($db,$propal->error); dolibarr_print_error($db,$propal->error);
exit; exit;
} }
$ret=$propal->fetch_client(); $ret=$propal->fetch_client();
$price_base_type = 'HT'; $price_base_type = 'HT';
// Ecrase $pu par celui du produit // Ecrase $pu par celui du produit
// Ecrase $desc par celui du produit // Ecrase $desc par celui du produit
// Ecrase $txtva par celui du produit // Ecrase $txtva par celui du produit
if ($_POST['idprod']) if ($_POST['idprod'])
{ {
$prod = new Product($db, $_POST['idprod']); $prod = new Product($db, $_POST['idprod']);
$prod->fetch($_POST['idprod']); $prod->fetch($_POST['idprod']);
$tva_tx = get_default_tva($mysoc,$propal->client,$prod->tva_tx); $tva_tx = get_default_tva($mysoc,$propal->client,$prod->tva_tx);
// On defini prix unitaire // On defini prix unitaire
if ($conf->global->PRODUIT_MULTIPRICES == 1) if ($conf->global->PRODUIT_MULTIPRICES == 1)
{ {
$pu_ht = $prod->multiprices[$fac->client->price_level]; $pu_ht = $prod->multiprices[$propal->client->price_level];
$pu_ttc = $prod->multiprices_ttc[$fac->client->price_level]; $pu_ttc = $prod->multiprices_ttc[$propal->client->price_level];
$price_base_type = $prod->multiprices_base_type[$fac->client->price_level]; $price_base_type = $prod->multiprices_base_type[$propal->client->price_level];
} }
else else
{ {
$pu_ht = $prod->price; $pu_ht = $prod->price;
$pu_ttc = $prod->price_ttc; $pu_ttc = $prod->price_ttc;
$price_base_type = $prod->price_base_type; $price_base_type = $prod->price_base_type;
} }
// On reevalue prix selon taux tva car taux tva transaction peut etre different // On reevalue prix selon taux tva car taux tva transaction peut etre different
// de ceux du produit par defaut (par exemple si pays different entre vendeur et acheteur). // de ceux du produit par defaut (par exemple si pays different entre vendeur et acheteur).

View File

@ -272,47 +272,47 @@ class Propal extends CommonObject
function addline($propalid, $desc, $pu_ht, $qty, $txtva, $fk_product=0, $remise_percent=0, $price_base_type='HT', $pu_ttc) function addline($propalid, $desc, $pu_ht, $qty, $txtva, $fk_product=0, $remise_percent=0, $price_base_type='HT', $pu_ttc)
{ {
dolibarr_syslog("Propal::Addline propalid=$propalid, desc=$desc, pu_ht=$pu_ht, qty=$qty, txtva=$txtva, fk_product=$fk_product, remise_except=$remise_percent, price_base_type=$price_base_type, pu_ttc=$pu_ttc"); dolibarr_syslog("Propal::Addline propalid=$propalid, desc=$desc, pu_ht=$pu_ht, qty=$qty, txtva=$txtva, fk_product=$fk_product, remise_except=$remise_percent, price_base_type=$price_base_type, pu_ttc=$pu_ttc");
include_once(DOL_DOCUMENT_ROOT.'/lib/price.lib.php'); include_once(DOL_DOCUMENT_ROOT.'/lib/price.lib.php');
if ($this->statut == 0) if ($this->statut == 0)
{ {
$this->db->begin(); $this->db->begin();
// Nettoyage paramètres // Nettoyage paramètres
$remise_percent=price2num($remise_percent); $remise_percent=price2num($remise_percent);
$qty=price2num($qty); $qty=price2num($qty);
if (! $qty) $qty=1; if (! $qty) $qty=1;
$pu_ht=price2num($pu_ht); $pu_ht=price2num($pu_ht);
$pu_ttc=price2num($pu_ttc); $pu_ttc=price2num($pu_ttc);
$txtva=price2num($txtva); $txtva=price2num($txtva);
if ($price_base_type=='HT') if ($price_base_type=='HT')
{ {
$pu=$pu_ht; $pu=$pu_ht;
} }
else else
{ {
$pu=$pu_ttc; $pu=$pu_ttc;
} }
// Calcul du total TTC et de la TVA pour la ligne a partir de // Calcul du total TTC et de la TVA pour la ligne a partir de
// qty, pu, remise_percent et txtva // qty, pu, remise_percent et txtva
// TRES IMPORTANT: C'est au moment de l'insertion ligne qu'on doit stocker // TRES IMPORTANT: C'est au moment de l'insertion ligne qu'on doit stocker
// la part ht, tva et ttc, et ce au niveau de la ligne qui a son propre taux tva. // la part ht, tva et ttc, et ce au niveau de la ligne qui a son propre taux tva.
$tabprice=calcul_price_total($qty, $pu, $remise_percent, $txtva, 0, $price_base_type); $tabprice=calcul_price_total($qty, $pu, $remise_percent, $txtva, 0, $price_base_type);
$total_ht = $tabprice[0]; $total_ht = $tabprice[0];
$total_tva = $tabprice[1]; $total_tva = $tabprice[1];
$total_ttc = $tabprice[2]; $total_ttc = $tabprice[2];
// \TODO A virer // \TODO A virer
// Anciens indicateurs: $price, $remise (a ne plus utiliser) // Anciens indicateurs: $price, $remise (a ne plus utiliser)
$price = $pu; $price = $pu;
$remise = 0; $remise = 0;
if ($remise_percent > 0) if ($remise_percent > 0)
{ {
$remise = round(($pu * $remise_percent / 100), 2); $remise = round(($pu * $remise_percent / 100), 2);
$price = $pu - $remise; $price = $pu - $remise;
} }
// Insertion ligne // Insertion ligne
$ligne=new PropaleLigne($this->db); $ligne=new PropaleLigne($this->db);
@ -2295,6 +2295,7 @@ class PropaleLigne
// Nettoyage parameteres // Nettoyage parameteres
if (! $this->remise) $this->remise=0; if (! $this->remise) $this->remise=0;
if (! $this->remise_percent) $this->remise_percent=0;
$rangtouse=$this->rang; $rangtouse=$this->rang;
if ($rangtouse == -1) if ($rangtouse == -1)