Fix: If multiprice is enabled and level is not defined for customer, we always use the level 1. We can't use the denormalized price stored in product table as this price is the last price saved (it might be any level) and should never bee seen by user when multiprice is activated.
So we force the level to 1 if not defined.
This commit is contained in:
parent
127ab8911d
commit
2be9a2fdb4
@ -281,7 +281,7 @@ if ($_GET["action"] == 'create')
|
|||||||
{
|
{
|
||||||
print '<tr><td>';
|
print '<tr><td>';
|
||||||
// multiprix
|
// multiprix
|
||||||
if($conf->global->PRODUIT_MULTIPRICES)
|
if($conf->global->PRODUIT_MULTIPRICES && $soc->price_level)
|
||||||
$html->select_produits('',"idprod".$i,'',$conf->produit->limit_size,$soc->price_level);
|
$html->select_produits('',"idprod".$i,'',$conf->produit->limit_size,$soc->price_level);
|
||||||
else
|
else
|
||||||
$html->select_produits('',"idprod".$i,'',$conf->produit->limit_size);
|
$html->select_produits('',"idprod".$i,'',$conf->produit->limit_size);
|
||||||
|
|||||||
@ -642,7 +642,7 @@ if ($_POST['action'] == "addline" && $user->rights->propale->creer)
|
|||||||
$tva_npr = get_default_npr($mysoc,$propal->client,$prod->tva_tx);
|
$tva_npr = get_default_npr($mysoc,$propal->client,$prod->tva_tx);
|
||||||
|
|
||||||
// On defini prix unitaire
|
// On defini prix unitaire
|
||||||
if ($conf->global->PRODUIT_MULTIPRICES && isset($prod->multiprices_base_type[$propal->client->price_level]))
|
if ($conf->global->PRODUIT_MULTIPRICES && $propal->client->price_level)
|
||||||
{
|
{
|
||||||
$pu_ht = $prod->multiprices[$propal->client->price_level];
|
$pu_ht = $prod->multiprices[$propal->client->price_level];
|
||||||
$pu_ttc = $prod->multiprices_ttc[$propal->client->price_level];
|
$pu_ttc = $prod->multiprices_ttc[$propal->client->price_level];
|
||||||
|
|||||||
@ -853,7 +853,7 @@ class Commande extends CommonObject
|
|||||||
|
|
||||||
$tva_tx = get_default_tva($mysoc,$this->client,$prod->tva_tx);
|
$tva_tx = get_default_tva($mysoc,$this->client,$prod->tva_tx);
|
||||||
// multiprix
|
// multiprix
|
||||||
if($conf->global->PRODUIT_MULTIPRICES)
|
if($conf->global->PRODUIT_MULTIPRICES && $this->client->price_level)
|
||||||
$price = $prod->multiprices[$this->client->price_level];
|
$price = $prod->multiprices[$this->client->price_level];
|
||||||
else
|
else
|
||||||
$price = $prod->price;
|
$price = $prod->price;
|
||||||
|
|||||||
@ -354,7 +354,7 @@ if ($_POST['action'] == 'addline' && $user->rights->commande->creer)
|
|||||||
$tva_tx = get_default_tva($mysoc,$commande->client,$prod->tva_tx);
|
$tva_tx = get_default_tva($mysoc,$commande->client,$prod->tva_tx);
|
||||||
|
|
||||||
// multiprix
|
// multiprix
|
||||||
if ($conf->global->PRODUIT_MULTIPRICES)
|
if ($conf->global->PRODUIT_MULTIPRICES && $commande->client->price_level)
|
||||||
{
|
{
|
||||||
$pu_ht = $prod->multiprices[$commande->client->price_level];
|
$pu_ht = $prod->multiprices[$commande->client->price_level];
|
||||||
$pu_ttc = $prod->multiprices_ttc[$commande->client->price_level];
|
$pu_ttc = $prod->multiprices_ttc[$commande->client->price_level];
|
||||||
|
|||||||
@ -18,21 +18,20 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
\file htdocs/commonobject.class.php
|
* \file htdocs/commonobject.class.php
|
||||||
\ingroup core
|
* \ingroup core
|
||||||
\brief Fichier de la classe mere des classes metiers (facture, contrat, propal, commande, etc...)
|
* \brief Fichier de la classe mere des classes metiers (facture, contrat, propal, commande, etc...)
|
||||||
\version $Id$
|
* \version $Id$
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
\class CommonObject
|
* \class CommonObject
|
||||||
\brief Classe mere pour heritage des classes metiers
|
* \brief Classe mere pour heritage des classes metiers
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class CommonObject
|
class CommonObject
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Ajoute un contact associe au l'entite definie dans $this->element
|
* \brief Ajoute un contact associe au l'entite definie dans $this->element
|
||||||
* \param fk_socpeople Id du contact a ajouter
|
* \param fk_socpeople Id du contact a ajouter
|
||||||
@ -352,9 +351,15 @@ class CommonObject
|
|||||||
*/
|
*/
|
||||||
function fetch_client()
|
function fetch_client()
|
||||||
{
|
{
|
||||||
|
global $conf;
|
||||||
|
|
||||||
$client = new Societe($this->db);
|
$client = new Societe($this->db);
|
||||||
$result=$client->fetch($this->socid);
|
$result=$client->fetch($this->socid);
|
||||||
$this->client = $client;
|
$this->client = $client;
|
||||||
|
|
||||||
|
// Use first price level if level not defined for third party
|
||||||
|
if ($conf->global->PRODUIT_MULTIPRICES && empty($this->client->price_level)) $this->client->price_level=1;
|
||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -885,7 +885,7 @@ if (($_POST['action'] == 'addline' || $_POST['action'] == 'addline_predef') && $
|
|||||||
$tva_npr = get_default_npr($mysoc,$fac->client,$prod->tva_tx);
|
$tva_npr = get_default_npr($mysoc,$fac->client,$prod->tva_tx);
|
||||||
|
|
||||||
// We define price for product
|
// We define price for product
|
||||||
if ($conf->global->PRODUIT_MULTIPRICES)
|
if ($conf->global->PRODUIT_MULTIPRICES && $fac->client->price_level)
|
||||||
{
|
{
|
||||||
$pu_ht = $prod->multiprices[$fac->client->price_level];
|
$pu_ht = $prod->multiprices[$fac->client->price_level];
|
||||||
$pu_ttc = $prod->multiprices_ttc[$fac->client->price_level];
|
$pu_ttc = $prod->multiprices_ttc[$fac->client->price_level];
|
||||||
|
|||||||
@ -226,7 +226,7 @@ if ($_POST["action"] == 'addligne' && $user->rights->contrat->creer)
|
|||||||
$tva_npr = get_default_npr($mysoc,$contrat->client,$prod->tva_npr);
|
$tva_npr = get_default_npr($mysoc,$contrat->client,$prod->tva_npr);
|
||||||
|
|
||||||
// On defini prix unitaire
|
// On defini prix unitaire
|
||||||
if ($conf->global->PRODUIT_MULTIPRICES)
|
if ($conf->global->PRODUIT_MULTIPRICES && $contrat->client->price_level)
|
||||||
{
|
{
|
||||||
$pu_ht = $prod->multiprices[$contrat->client->price_level];
|
$pu_ht = $prod->multiprices[$contrat->client->price_level];
|
||||||
$pu_ttc = $prod->multiprices_ttc[$contrat->client->price_level];
|
$pu_ttc = $prod->multiprices_ttc[$contrat->client->price_level];
|
||||||
|
|||||||
@ -870,8 +870,12 @@ class Form
|
|||||||
$opt.= '>'.$objp->ref.' - ';
|
$opt.= '>'.$objp->ref.' - ';
|
||||||
$opt.= dol_trunc($objp->label,32).' - ';
|
$opt.= dol_trunc($objp->label,32).' - ';
|
||||||
|
|
||||||
|
$found=0;
|
||||||
|
$currencytext=$langs->trans("Currency".$conf->monnaie);
|
||||||
|
if (strlen($currencytext) > 10) $currencytext=$conf->monnaie; // If text is too long, we use the short code
|
||||||
|
|
||||||
// Multiprice
|
// Multiprice
|
||||||
if ($price_level > 1)
|
if ($price_level >= 1) // If we need a particular price level (from 1 to 6)
|
||||||
{
|
{
|
||||||
$sql= "SELECT price, price_ttc, price_base_type ";
|
$sql= "SELECT price, price_ttc, price_base_type ";
|
||||||
$sql.= "FROM ".MAIN_DB_PREFIX."product_price ";
|
$sql.= "FROM ".MAIN_DB_PREFIX."product_price ";
|
||||||
@ -887,10 +891,11 @@ class Form
|
|||||||
$objp2 = $this->db->fetch_object($result2);
|
$objp2 = $this->db->fetch_object($result2);
|
||||||
if ($objp2)
|
if ($objp2)
|
||||||
{
|
{
|
||||||
|
$found=1;
|
||||||
if ($objp2->price_base_type == 'HT')
|
if ($objp2->price_base_type == 'HT')
|
||||||
$opt.= price($objp2->price,1).' '.$langs->trans("Currency".$conf->monnaie).' '.$langs->trans("HT");
|
$opt.= price($objp2->price,1).' '.$currencytext.' '.$langs->trans("HT");
|
||||||
else
|
else
|
||||||
$opt.= price($objp2->price_ttc,1).' '.$langs->trans("Currency".$conf->monnaie).' '.$langs->trans("TTC");
|
$opt.= price($objp2->price_ttc,1).' '.$currencytext.' '.$langs->trans("TTC");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -898,13 +903,14 @@ class Form
|
|||||||
dol_print_error($this->db);
|
dol_print_error($this->db);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//si il n'y a pas de prix multiple on prend le prix de base du produit/service
|
|
||||||
else
|
// If level no defined or multiprice not found, we used the default price
|
||||||
|
if (! $found)
|
||||||
{
|
{
|
||||||
if ($objp->price_base_type == 'HT')
|
if ($objp->price_base_type == 'HT')
|
||||||
$opt.= price($objp->price,1).' '.$langs->trans("Currency".$conf->monnaie).' '.$langs->trans("HT");
|
$opt.= price($objp->price,1).' '.$currencytext.' '.$langs->trans("HT");
|
||||||
else
|
else
|
||||||
$opt.= price($objp->price_ttc,1).' '.$langs->trans("Currency".$conf->monnaie).' '.$langs->trans("TTC");
|
$opt.= price($objp->price_ttc,1).' '.$currencytext.' '.$langs->trans("TTC");
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($conf->stock->enabled && isset($objp->stock) && $objp->fk_product_type == 0)
|
if ($conf->stock->enabled && isset($objp->stock) && $objp->fk_product_type == 0)
|
||||||
|
|||||||
@ -338,7 +338,7 @@ if ($_POST["action"] == 'addinpropal')
|
|||||||
$price_base_type = 'HT';
|
$price_base_type = 'HT';
|
||||||
|
|
||||||
// multiprix
|
// multiprix
|
||||||
if ($conf->global->PRODUIT_MULTIPRICES)
|
if ($conf->global->PRODUIT_MULTIPRICES && $soc->price_level)
|
||||||
{
|
{
|
||||||
$pu_ht = $prod->multiprices[$soc->price_level];
|
$pu_ht = $prod->multiprices[$soc->price_level];
|
||||||
$pu_ttc = $prod->multiprices_ttc[$soc->price_level];
|
$pu_ttc = $prod->multiprices_ttc[$soc->price_level];
|
||||||
@ -417,7 +417,7 @@ if ($_POST["action"] == 'addincommande')
|
|||||||
$tva_tx = get_default_tva($mysoc,$soc,$prod->tva_tx);
|
$tva_tx = get_default_tva($mysoc,$soc,$prod->tva_tx);
|
||||||
|
|
||||||
// multiprix
|
// multiprix
|
||||||
if ($conf->global->PRODUIT_MULTIPRICES)
|
if ($conf->global->PRODUIT_MULTIPRICES && $soc->price_level)
|
||||||
{
|
{
|
||||||
$pu_ht = $prod->multiprices[$soc->price_level];
|
$pu_ht = $prod->multiprices[$soc->price_level];
|
||||||
$pu_ttc = $prod->multiprices_ttc[$soc->price_level];
|
$pu_ttc = $prod->multiprices_ttc[$soc->price_level];
|
||||||
@ -497,7 +497,7 @@ if ($_POST["action"] == 'addinfacture' && $user->rights->facture->creer)
|
|||||||
$tva_tx = get_default_tva($mysoc,$soc,$prod->tva_tx);
|
$tva_tx = get_default_tva($mysoc,$soc,$prod->tva_tx);
|
||||||
|
|
||||||
// multiprix
|
// multiprix
|
||||||
if ($conf->global->PRODUIT_MULTIPRICES)
|
if ($conf->global->PRODUIT_MULTIPRICES && $soc->price_level)
|
||||||
{
|
{
|
||||||
$pu_ht = $prod->multiprices[$soc->price_level];
|
$pu_ht = $prod->multiprices[$soc->price_level];
|
||||||
$pu_ttc = $prod->multiprices_ttc[$soc->price_level];
|
$pu_ttc = $prod->multiprices_ttc[$soc->price_level];
|
||||||
|
|||||||
@ -155,7 +155,7 @@ class Propal extends CommonObject
|
|||||||
|
|
||||||
$tva_tx = get_default_tva($mysoc,$this->client,$prod->tva_tx);
|
$tva_tx = get_default_tva($mysoc,$this->client,$prod->tva_tx);
|
||||||
// multiprix
|
// multiprix
|
||||||
if($conf->global->PRODUIT_MULTIPRICES)
|
if($conf->global->PRODUIT_MULTIPRICES && $this->client->price_level)
|
||||||
{
|
{
|
||||||
$price = $prod->multiprices[$this->client->price_level];
|
$price = $prod->multiprices[$this->client->price_level];
|
||||||
}
|
}
|
||||||
|
|||||||
@ -633,6 +633,9 @@ class Societe extends CommonObject
|
|||||||
$result = -3;
|
$result = -3;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Use first price level if level not defined for third party
|
||||||
|
if ($conf->global->PRODUIT_MULTIPRICES && empty($this->price_level)) $this->price_level=1;
|
||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user