Gestion des la precision decimals sur les prix unitaires des produits.

This commit is contained in:
Laurent Destailleur 2007-06-16 13:06:05 +00:00
parent b0beed7fb6
commit 357ce5bdf1
14 changed files with 294 additions and 321 deletions

View File

@ -472,11 +472,11 @@ class Conf
$this->format_date_short_java="dd/MM/yyyy";
// Format montant affichés
if (! isset($this->global->MAIN_MAX_DECIMALS_SHOWN))
{
$this->global->MAIN_MAX_DECIMALS_SHOWN=5;
}
// Limites decimales
if (! isset($this->global->MAIN_MAX_DECIMALS_UNIT)) $this->global->MAIN_MAX_DECIMALS_UNIT=5;
if (! isset($this->global->MAIN_MAX_DECIMALS_TTC)) $this->global->MAIN_MAX_DECIMALS_TTC=2;
if (! isset($this->global->MAIN_MAX_DECIMALS_SHOWN)) $this->global->MAIN_MAX_DECIMALS_SHOWN=8;
/* \todo Ajouter une option Gestion de la TVA dans le module compta qui permet de désactiver la fonction TVA
* (pour particuliers ou libéraux en franchise)

View File

@ -78,6 +78,7 @@ EnterPaymentDueToCustomer=Make payment due to customer
VAT=VAT
VATRate=VAT Rate
Amount=Amount
PriceBase=Price base
TotalTTCToYourCredit=Total TTC to your credit
BillStatus=Invoice status
BillStatusDraft=Draft (needs to be validated)

View File

@ -52,6 +52,7 @@ InformationToHelpDiagnose=This is information that can help to diagnose
MoreInformation=More information
NotePublic=Note (public)
NotePrivate=Note (private)
PrecisionUnitIsLimitedToXDecimals=Dolibarr was setup to limit precision of unit prices to <b>%s</b> decimals.
yes=yes
Yes=Yes
no=no

View File

@ -78,6 +78,7 @@ EnterPaymentDueToCustomer=R
VAT=TVA
VATRate=Taux TVA
Amount=Montant
PriceBase=Base du prix
TotalTTCToYourCredit=Total TTC à votre crédit
BillStatus=État de la facture
BillStatusDraft=Brouillon (à valider)

View File

@ -52,6 +52,7 @@ InformationToHelpDiagnose=Voici les informations qui pourront aider au diagnosti
MoreInformation=Plus d'information
NotePublic=Note (publique)
NotePrivate=Note (privée)
PrecisionUnitIsLimitedToXDecimals=Dolibarr a été configuré pour limiter la précision des prix unitaires à <b>%s</b> décimals.
yes=oui
Yes=Oui
no=non

View File

@ -1896,12 +1896,12 @@ function print_fleche_navigation($page,$file,$options='',$nextpage)
/**
* \brief Fonction qui retourne un montant monétaire formaté
* \brief Fonction qui retourne un montant monétaire formaté pour visualisation
* \remarks Fonction utilisée dans les pdf et les pages html
* \param amount Montant a formater
* \param html Formatage html ou pas (0 par defaut)
* \param outlangs Objet langs pour formatage
* \param trunc 1=Tronque affichage si trop de décimales
* \param trunc 1=Tronque affichage si trop de décimales,0=Force le non troncage
* \return string Chaine avec montant formaté
* \seealso price2num Fonction inverse de price
*/
@ -1919,12 +1919,13 @@ function price($amount, $html=0, $outlangs='', $trunc=1)
if ($outlangs->trans("SeparatorThousand")!= "SeparatorThousand") $thousand=$outlangs->trans("SeparatorThousand");
//print "dec=".$dec." thousand=".$thousand;
//print "xx".$amount."-";
//print "amount=".$amount."-";
$amount = ereg_replace(',','.',$amount);
//print $amount."-";
$datas = split("\.",$amount);
$decpart = $datas[1];
//print $datas[1]."<br>";
$decpart = eregi_replace('0+$','',$decpart); // Supprime les 0 de fin de partie décimale
//print "decpart=".$decpart."<br>";
// On pose par defaut 2 decimales
$nbdecimal = 2;
@ -1953,16 +1954,35 @@ function price($amount, $html=0, $outlangs='', $trunc=1)
}
/**
\brief Fonction qui retourne un numérique depuis un montant formaté
\remarks Fonction à appeler sur montants saisi avant un insert
\param amount montant a formater
\seealso price Fonction inverse de price2num
\brief Fonction qui retourne un numérique conforme PHP et SQL, depuis un montant au
format utilisateur.
\remarks Fonction à appeler sur montants saisis avant un insert en base
\param amount Montant a formater
\param rounding 'MU'=Round to Max unit price (MAIN_MAX_DECIMALS_UNIT)
'MT'=Round to Max with Tax (MAIN_MAX_DECIMALS_TTC)
'MS'=Round to Max Shown (MAIN_MAX_DECIMALS_SHOWN)
''=No rounding
\return string Montant au format numérique PHP et SQL (Exemple: '99.99999')
\seealso price Fonction inverse de price2num
*/
function price2num($amount)
function price2num($amount,$rounding='')
{
$amount=ereg_replace(',','.',$amount);
$amount=ereg_replace(' ','',$amount);
return $amount;
global $conf;
// Round PHP function does not allow number like '1,234.5'.
// Numbers must be '1234.5'
$amount=ereg_replace(',','.',$amount);
$amount=ereg_replace(' ','',$amount);
if ($rounding)
{
if ($rounding == 'MU') $amount = round($amount,$conf->global->MAIN_MAX_DECIMALS_UNIT);
elseif ($rounding == 'MT') $amount = round($amount,$conf->global->MAIN_MAX_DECIMALS_TTC);
elseif ($rounding == 'MS') $amount = round($amount,$conf->global->MAIN_MAX_DECIMALS_SHOWN);
else $amount='ErrorBadParameterProvidedToFunction';
$amount=ereg_replace(',','.',$amount);
$amount=ereg_replace(' ','',$amount);
}
return $amount;
}

View File

@ -23,12 +23,13 @@
/**
\file htdocs/lib/price.lib.php
\brief Librairie contenant les fonctions pour calculer un prix.
\author Rodolphe Quiedeville.
\author Rodolphe Quiedeville.
\version $Revision$
Ensemble des fonctions permettant de calculer un prix.
*/
/**
\brief Permet de calculer les parts total HT, TVA et TTC d'une ligne de
facture, propale, commande ou autre depuis:

View File

@ -130,18 +130,7 @@ class Product
return 1;
}
}
/**
* \brief Definit le prix de vente
* \return void
*/
function SetSellPrice($price, $base_type='HT')
{
$price = ereg_replace(" ","", $price);
$price = ereg_replace(",",".", $price);
$this->price = $price;
$this->price_base_type = $base_type;
}
/**
\brief Insère le produit en base
\param user Utilisateur qui effectue l'insertion
@ -574,130 +563,70 @@ class Product
/**
* \brief Ajoute un changement de prix en base dans l'historique des prix
* \param user utilisateur qui modifie le prix
*/
function _log_price($user)
{
// MultiPrix : si activé, on gère tout ici, même le prix standard
global $conf;
if($conf->global->PRODUIT_MULTIPRICES == 1)
{
$queryError = false;
for($i=2;$i<=$conf->global->PRODUIT_MULTIPRICES_LIMIT;$i++)
{
if($this->multiprices["$i"] != "")
{
if ($this->multiprices_base_type["$i"] == 'TTC')
{
$price_ttc = $this->multiprices["$i"];
$this->multiprices["$i"] = $this->multiprices["$i"] / (1 + ($this->tva_tx / 100));
}
else
{
$price_ttc = $this->multiprices["$i"] * (1 + ($this->tva_tx / 100));
}
/**
* \brief Ajoute un changement de prix en base dans l'historique des prix
* \param user Objet utilisateur qui modifie le prix
* \return int <0 si KO, >0 si OK
*/
function _log_price($user)
{
// MultiPrix : si activé, on gère tout ici, même le prix standard
global $conf;
// On supprimme ligne existante au cas ou
$sql_multiprix = "DELETE FROM ".MAIN_DB_PREFIX."product_price ";
$sql_multiprix .= "WHERE date_price = now()";
$sql_multiprix .= " and fk_product = ".$this->id;
$sql_multiprix .= " and fk_user_author = ".$user->id;
$sql_multiprix .= " and price = ".price2num($this->multiprices["$i"]);
if ($conf->global->PRODUIT_MULTIPRICES)
{
$queryError = false;
for($i=2;$i<=$conf->global->PRODUIT_MULTIPRICES_LIMIT;$i++)
{
if($this->multiprices["$i"] != "")
{
// On ajoute nouveau tarif
$sql_multiprix = "INSERT INTO ".MAIN_DB_PREFIX."product_price(date_price,fk_product,fk_user_author,price_level,price,price_ttc,price_base_type,tva_tx) ";
$sql_multiprix .= " VALUES(now(),".$this->id.",".$user->id.",".$i.",".price2num($this->multiprices["$i"]).",'".price2num($this->multiprices_ttc["$i"])."','".$this->multiprices_base_type["$i"]."',".$this->tva_tx;
$sql_multiprix .= ")";
if (! $this->db->query($sql_multiprix) )
{
$queryError = true;
}
}
}
if (strlen(trim($this->price)) > 0 )
{
// On ajoute nouveau tarif
$sql = "INSERT INTO ".MAIN_DB_PREFIX."product_price(date_price,fk_product,fk_user_author,price,price_ttc,price_base_type,envente,tva_tx) ";
$sql .= " VALUES(now(),".$this->id.",".$user->id.",".$this->price.",".$this->price_ttc.",'".$this->price_base_type."',".$this->status.",".$this->tva_tx;
$sql .= ")";
if (! $this->db->query($sql) )
$queryError = true;
}
if($queryError)
{
dolibarr_print_error($this->db);
return 0;
}
else
return 1;
}
else
{
// On ajoute nouveau tarif
$sql = "INSERT INTO ".MAIN_DB_PREFIX."product_price(date_price,fk_product,fk_user_author,price,price_ttc,price_base_type,envente,tva_tx) ";
$sql .= " VALUES(now(),".$this->id.",".$user->id.",".$this->price.",".$this->price_ttc.",'".$this->price_base_type."',".$this->status.",".$this->tva_tx;
$sql .= ")";
$this->db->query($sql_multiprix);
// On ajoute nouveau tarif
$sql_multiprix = "INSERT INTO ".MAIN_DB_PREFIX."product_price(date_price,fk_product,fk_user_author,price_level,price,price_ttc,price_base_type,tva_tx) ";
$sql_multiprix .= " VALUES(now(),".$this->id.",".$user->id.",".$i.",".price2num($this->multiprices["$i"]).",'".$price_ttc."','".$this->multiprices_base_type["$i"]."',".$this->tva_tx;
$sql_multiprix .= ")";
if (! $this->db->query($sql_multiprix) )
{
$queryError = true;
}
}
}
if (strlen(trim($this->price)) > 0 )
{
if ($this->price_base_type == 'TTC')
{
$price_ttc = $this->price;
$price = $this->price / (1 + ($this->tva_tx / 100));
}
else
{
$price = $this->price;
$price_ttc = $this->price * (1 + ($this->tva_tx / 100));
}
// On supprimme ligne existante au cas ou
$sql = "DELETE FROM ".MAIN_DB_PREFIX."product_price ";
$sql .= "WHERE date_price = now()";
$sql .= " and fk_product = ".$this->id;
$sql .= " and fk_user_author = ".$user->id;
$sql .= " and price = ".price2num($price);
$sql .= " and envente = ".$this->status;
$sql .= " and tva_tx = ".$this->tva_tx;
$this->db->query($sql);
// On ajoute nouveau tarif
$sql = "INSERT INTO ".MAIN_DB_PREFIX."product_price(date_price,fk_product,fk_user_author,price,price_ttc,price_base_type,envente,tva_tx) ";
$sql .= " VALUES(now(),".$this->id.",".$user->id.",".price2num($price).",'".$price_ttc."','".$this->price_base_type."',".$this->status.",".$this->tva_tx;
$sql .= ")";
if (! $this->db->query($sql) )
$queryError = true;
}
if($queryError)
{
dolibarr_print_error($this->db);
return 0;
}
else
return 1;
}
else
{
if ($this->price_base_type == 'TTC')
{
$price_ttc = $this->price;
$price = $this->price / (1 + ($this->tva_tx / 100));
}
else
{
$price = $this->price;
$price_ttc = $this->price * (1 + ($this->tva_tx / 100));
}
// On supprimme ligne existante au cas ou
$sql = "DELETE FROM ".MAIN_DB_PREFIX."product_price ";
$sql .= "WHERE date_price = now()";
$sql .= " and fk_product = ".$this->id;
$sql .= " and fk_user_author = ".$user->id;
$sql .= " and price = ".price2num($this->price);
$sql .= " and envente = ".$this->status;
$sql .= " and tva_tx = ".$this->tva_tx;
$this->db->query($sql);
// On ajoute nouveau tarif
$sql = "INSERT INTO ".MAIN_DB_PREFIX."product_price(date_price,fk_product,fk_user_author,price,price_ttc,price_base_type,envente,tva_tx) ";
$sql .= " VALUES(now(),".$this->id.",".$user->id.",".price2num($price).",'".$price_ttc."','".$this->price_base_type."',".$this->status.",".$this->tva_tx;
$sql .= ")";
if ($this->db->query($sql) )
{
return 1;
}
else
{
dolibarr_print_error($this->db);
return 0;
}
}
}
dolibarr_syslog("Product::_log_price sql=".$sql);
$resql=$this->db->query($sql);
if ($resql)
{
return 1;
}
else
{
dolibarr_print_error($this->db);
return -1;
}
}
}
/**
@ -869,57 +798,70 @@ class Product
}
/**
\brief Modifie le prix d'un produit/service
\param id id du produit/service à modifier
\param user utilisateur qui modifie le prix
*/
function update_price($id, $user)
{
//multiprix
global $conf;
/**
\brief Modifie le prix d'un produit/service
\param id Id du produit/service à modifier
\param newprice Nouveau prix
\param newpricebase HT ou TTC
\param user Objet utilisateur qui modifie le prix
*/
function update_price($id, $newprice, $newpricebase, $user)
{
//multiprix
global $conf,$langs;
dolibarr_syslog("Product::update_price id=".$id." newprice=".$newprice." newpricebase=".$newpricebase);
if (strlen(trim($this->price)) > 0 )
{
if ($this->price_base_type == 'TTC')
{
$price_ttc = $this->price;
$price = $this->price / (1 + ($this->tva_tx / 100));
}
else
{
$price = $this->price;
$price_ttc = $this->price * (1 + ($this->tva_tx / 100));
}
$sql = "UPDATE ".MAIN_DB_PREFIX."product ";
$sql .= " SET price = " . price2num($price);
$sql .= " , price_base_type='".$this->price_base_type."'";
$sql .= " , price_ttc='".$price_ttc."'";
$sql .= " WHERE rowid = " . $id;
if ($newprice)
{
if ($newpricebase == 'TTC')
{
$price_ttc = price2num($newprice,'MU');
$price = price2num($newprice) / (1 + ($this->tva_tx / 100));
$price = price2num($price,'MU');
}
else
{
$price = price2num($newprice,'MU');
$price_ttc = price2num($newprice) * (1 + ($this->tva_tx / 100));
$price_ttc = price2num($price_ttc,'MU');
}
// Ne pas mettre de quote sur le numériques decimaux.
// Ceci provoque des sotckage avec arrondis en base au lieu des valeurs exactes.
$sql = "UPDATE ".MAIN_DB_PREFIX."product ";
$sql .= " SET price=".$price."";
$sql .= " , price_base_type='".$newpricebase."'";
$sql .= " , price_ttc=".$price_ttc."";
$sql .= " WHERE rowid = " . $id;
if ( $this->db->query($sql) )
{
$this->_log_price($user);
return 1;
}
else
{
dolibarr_print_error($this->db);
return -1;
}
}
else if(($conf->global->PRODUIT_MULTIPRICES == 1) && (count($this->multiprices) > 0))
{
$this->_log_price($user);
return 1;
}
else
{
$this->error = "Prix saisi invalide.";
return -2;
}
}
dolibarr_syslog("Product::update_price sql=".$sql);
$resql=$this->db->query($sql);
if ($resql)
{
$this->price = $price;
$this->price_ttc = $price_ttc;
$this->price_base_type = $newpricebase;
$this->_log_price($user);
return 1;
}
else
{
dolibarr_print_error($this->db);
return -1;
}
}
else if(($conf->global->PRODUIT_MULTIPRICES) && (count($this->multiprices) > 0))
{
$this->_log_price($user);
return 1;
}
else
{
$this->error = $langs->trans("ErrorBadParameter");
return -2;
}
}
/**
@ -957,9 +899,9 @@ class Product
$this->id = $result["rowid"];
$this->ref = $result["ref"];
$this->libelle = stripslashes($result["label"]);
$this->description = stripslashes($result["description"]);
$this->note = stripslashes($result["note"]);
$this->libelle = $result["label"];
$this->description = $result["description"];
$this->note = $result["note"];
$this->price = $result["price"];
$this->price_ttc = $result["price_ttc"];
$this->price_base_type = $result["price_base_type"];
@ -987,7 +929,7 @@ class Product
if( $conf->global->MAIN_MULTILANGS) $this->getMultiLangs();
// multiprix
if($conf->global->PRODUIT_MULTIPRICES == 1)
if ($conf->global->PRODUIT_MULTIPRICES)
{
if ($ref)
{

View File

@ -42,7 +42,7 @@ $user->getrights('produit');
if (!$user->rights->produit->lire)
accessforbidden();
$html = new Form($db);
/*
* Actions
@ -51,48 +51,49 @@ $html = new Form($db);
if ($_POST["action"] == 'update_price' &&
$_POST["cancel"] <> $langs->trans("Cancel") && $user->rights->produit->creer)
{
$product = new Product($db);
$result = $product->fetch($_GET["id"]);
$product = new Product($db);
$product->SetSellprice($_POST["price"], $_POST["price_base_type"]);
$result = $product->fetch($_GET["id"]);
// MultiPrix
if($conf->global->PRODUIT_MULTIPRICES == 1)
{
for($i=2;$i<=$conf->global->PRODUIT_MULTIPRICES_LIMIT;$i++)
{
if($_POST["price_".$i])
{
$price = ereg_replace(" ","", $_POST["price_".$i]);
$price = ereg_replace(",",".", $price);
$product->multiprices["$i"] = $price;
$product->multiprices_base_type["$i"] = $_POST["multiprices_base_type_".$i];
}
else
{
$product->multiprices["$i"] = "";
}
}
}
if ( $product->update_price($product->id, $user) > 0 )
{
$_GET["action"] = '';
$mesg = 'Fiche mise à jour';
}
else
{
$_GET["action"] = 'edit_price';
$mesg = 'Fiche non mise à jour !' . "<br>" . $product->mesg_error;
}
$newprice=price2num($_POST["price"],'MU');
$newpricebase=$_POST["price_base_type"];
// MultiPrix
if($conf->global->PRODUIT_MULTIPRICES)
{
for($i=2;$i<=$conf->global->PRODUIT_MULTIPRICES_LIMIT;$i++)
{
if($_POST["price_".$i])
{
$price = ereg_replace(" ","", $_POST["price_".$i]);
$price = ereg_replace(",",".", $price);
$product->multiprices["$i"] = $price;
$product->multiprices_base_type["$i"] = $_POST["multiprices_base_type_".$i];
}
else
{
$product->multiprices["$i"] = "";
}
}
}
if ($product->update_price($product->id, $newprice, $newpricebase, $user) > 0)
{
$_GET["action"] = '';
$mesg = $langs->trans("RecordSaved");
}
else
{
$_GET["action"] = 'edit_price';
$mesg = '<div class="error">'.$product->error.'</div>';
}
}
/*
* Affiche historique prix
*/
$html = new Form($db);
$product = new Product($db);
if ($_GET["ref"]) $result = $product->fetch('',$_GET["ref"]);
@ -125,7 +126,7 @@ print '</tr>';
// MultiPrix
if($conf->global->PRODUIT_MULTIPRICES == 1)
if($conf->global->PRODUIT_MULTIPRICES)
{
print '<tr><td>'.$langs->trans("SellingPrice").' 1</td>';
@ -168,15 +169,15 @@ if($conf->global->PRODUIT_MULTIPRICES == 1)
// Prix
else
{
print '<tr><td>'.$langs->trans("SellingPrice").'</td><td colspan="2">';
if ($product->price_base_type == 'TTC')
{
print price($product->price_ttc).' '.$langs->trans($product->price_base_type).'</td></tr>';
}
else
{
print price($product->price).' '.$langs->trans($product->price_base_type).'</td></tr>';
}
print '<tr><td>'.$langs->trans("SellingPrice").'</td><td colspan="2">';
if ($product->price_base_type == 'TTC')
{
print price($product->price_ttc).' '.$langs->trans($product->price_base_type).'</td></tr>';
}
else
{
print price($product->price).' '.$langs->trans($product->price_base_type).'</td></tr>';
}
}
// Statut
@ -196,17 +197,18 @@ print "</div>\n";
/* */
/* ************************************************************************** */
print "\n<div class=\"tabsAction\">\n";
if ($_GET["action"] == '')
if (! $_GET["action"])
{
print "\n<div class=\"tabsAction\">\n";
if ($user->rights->produit->modifier || $user->rights->produit->creer)
{
print '<a class="butAction" href="'.DOL_URL_ROOT.'/product/price.php?action=edit_price&amp;id='.$product->id.'">'.$langs->trans("UpdatePrice").'</a>';
}
print "\n</div>\n";
}
print "\n</div>\n";
/*
@ -214,20 +216,16 @@ print "\n</div>\n";
*/
if ($_GET["action"] == 'edit_price' && $user->rights->produit->creer)
{
print_fiche_titre($langs->trans("NewPrice"));
print '<form action="price.php?id='.$product->id.'" method="post">';
print '<input type="hidden" name="action" value="update_price">';
print '<input type="hidden" name="id" value="'.$product->id.'">';
print '<table class="border" width="100%">';
if($conf->global->PRODUIT_MULTIPRICES == 1)
{
print '<tr><td width="15%">'.$langs->trans('SellingPrice').' 1</td>';
}
else
{
print '<tr><td width="15%">'.$langs->trans('SellingPrice').'</td>';
}
print_fiche_titre($langs->trans("NewPrice"));
print '<form action="price.php?id='.$product->id.'" method="post">';
print '<input type="hidden" name="action" value="update_price">';
print '<input type="hidden" name="id" value="'.$product->id.'">';
print '<table class="border" width="100%">';
print '<tr><td width="15%">';
$text=$langs->trans('SellingPrice');
if ($conf->global->PRODUIT_MULTIPRICES) $text.=' 1';
print $html->textwithhelp($text,$langs->trans("PrecisionUnitIsLimitedToXDecimals",$conf->global->MAIN_MAX_DECIMALS_UNIT),$direction=1,$usehelpcursor=1);
print '</td>';
if ($product->price_base_type == 'TTC')
{
@ -278,7 +276,7 @@ if ($_GET["action"] == 'edit_price' && $user->rights->produit->creer)
// Liste des evolutions du prix
$sql = "SELECT p.rowid, p.price, p.price_ttc, p.price_base_type, ";
if($conf->global->PRODUIT_MULTIPRICES == 1)
if($conf->global->PRODUIT_MULTIPRICES)
{
$sql .= "p.price_level, ";
$sql .= $db->pdate("p.date_price")." as dp, u.rowid as user_id, u.login";
@ -293,13 +291,12 @@ else
$sql .= $db->pdate("p.date_price")." as dp, u.rowid as user_id, u.login";
$sql .= " FROM ".MAIN_DB_PREFIX."product_price as p, ".MAIN_DB_PREFIX."user as u";
$sql .= " WHERE fk_product = ".$product->id;
$sql .= " AND p.fk_user_author = u.rowid ";
$sql .= " AND p.fk_user_author = u.rowid";
$sql .= " ORDER BY p.date_price DESC ";
}
$sql .= $db->plimit();
$result = $db->query($sql) ;
//$sql .= $db->plimit();
$result = $db->query($sql) ;
if ($result)
{
$num = $db->num_rows($result);
@ -325,47 +322,42 @@ if ($result)
print '<tr class="liste_titre">';
print '<td>'.$langs->trans("AppliedPricesFrom").'</td>';
if($conf->global->PRODUIT_MULTIPRICES == 1)
{
print '<td>'.$langs->trans("MultiPriceLevelsName").'</td>';
}
if($conf->global->PRODUIT_MULTIPRICES)
{
print '<td>'.$langs->trans("MultiPriceLevelsName").'</td>';
}
print '<td>'.$langs->trans("Price").'</td>';
print '<td align="right">'.$langs->trans("HT").'</td>';
print '<td align="right">'.$langs->trans("TTC").'</td>';
print '<td align="center">'.$langs->trans("PriceBase").'</td>';
print '<td>'.$langs->trans("ChangedBy").'</td>';
print '</tr>';
$var=True;
$i = 0;
while ($i < $num)
{
$objp = $db->fetch_object($result);
$var=!$var;
print "<tr $bc[$var]>";
// Date
print "<td>".dolibarr_print_date($objp->dp,"%d %b %Y %H:%M:%S")."</td>";
// catégorie de Prix
if($conf->global->PRODUIT_MULTIPRICES == 1)
{
print "<td>".$objp->price_level."</td>";
}
if ($objp->price_base_type == 'TTC')
{
print "<td>".price($objp->price_ttc);
}
else
{
print "<td>".price($objp->price);
}
print " ".$langs->trans($objp->price_base_type)."</td>";
{
$objp = $db->fetch_object($result);
$var=!$var;
print "<tr $bc[$var]>";
// Date
print "<td>".dolibarr_print_date($objp->dp,"%d %b %Y %H:%M:%S")."</td>";
// catégorie de Prix
if($conf->global->PRODUIT_MULTIPRICES)
{
print "<td>".$objp->price_level."</td>";
}
// User
print '<td><a href="'.DOL_URL_ROOT.'/user/fiche.php?id='.$objp->user_id.'">'.img_object($langs->trans("ShowUser"),'user').' '.$objp->login.'</a></td>';
print "</tr>\n";
$i++;
}
print '<td align="right">'.price($objp->price)."</td>";
print '<td align="right">'.price($objp->price_ttc)."</td>";
print '<td align="center">'.$langs->trans($objp->price_base_type)."</td>";
// User
print '<td><a href="'.DOL_URL_ROOT.'/user/fiche.php?id='.$objp->user_id.'">'.img_object($langs->trans("ShowUser"),'user').' '.$objp->login.'</a></td>';
print "</tr>\n";
$i++;
}
$db->free($result);
print "</table>";
print "<br>";

View File

@ -561,11 +561,25 @@ drop table if exists llx_ventes;
drop table if exists llx_pointmort;
drop table if exists llx_birthday_alert;
-- Pas de limite sur nb decimal dans base car definie en option
ALTER TABLE llx_product_price ADD COLUMN price_ttc float DEFAULT 0 AFTER price;
ALTER TABLE llx_product ADD COLUMN price_ttc float DEFAULT 0 AFTER price_base_type;
ALTER TABLE llx_product_price MODIFY price_ttc float DEFAULT 0;
ALTER TABLE llx_product ADD COLUMN price_ttc float DEFAULT 0;
-- Pas de limite sur nb decimal des prix dans base car definie en option
-- Tous les prix doivent etre au format float(16,8)
-- Tous les tx tva doivent etre au format float(6,3)
ALTER TABLE llx_product_price ADD COLUMN price_ttc double(16,8) DEFAULT 0 AFTER price;
ALTER TABLE llx_product ADD COLUMN price_ttc double(16,8) DEFAULT 0 AFTER price_base_type;
ALTER TABLE llx_product MODIFY price double(16,8) DEFAULT 0;
ALTER TABLE llx_product MODIFY price_ttc double(16,8) DEFAULT 0;
ALTER TABLE llx_product MODIFY tva_tx double(6,3);
ALTER TABLE llx_product_price MODIFY price double(16,8) DEFAULT 0;
ALTER TABLE llx_product_price MODIFY price_ttc double(16,8) DEFAULT 0;
ALTER TABLE llx_product_price MODIFY tva_tx double(6,3);
ALTER TABLE llx_product_fournisseur_price_log MODIFY price double(16,8);
ALTER TABLE llx_product_fournisseur_price_log MODIFY quantity double;
ALTER TABLE llx_product_fournisseur_price MODIFY price double(16,8);
ALTER TABLE llx_product_fournisseur_price MODIFY quantity double;
-- Changement de idp en rowid
-- V4 ALTER TABLE llx_propal DROP FOREIGN KEY llx_propal_ibfk1;

View File

@ -29,10 +29,10 @@ create table llx_product
label varchar(255) NOT NULL,
description text,
note text,
price double,
price_ttc float(12,4) DEFAULT 0,
price double(16,8),
price_ttc double(16,8) DEFAULT 0,
price_base_type varchar(3) DEFAULT 'HT',
tva_tx double,
tva_tx double(6,3),
fk_user_author integer,
envente tinyint DEFAULT 1,
nbvente integer DEFAULT 0,

View File

@ -27,8 +27,8 @@ create table llx_product_fournisseur_price
tms timestamp,
fk_product integer,
fk_soc integer, -- lien sur llx_societe
price real,
quantity real,
price double(16,8),
quantity double,
fk_user integer
)type=innodb;

View File

@ -26,8 +26,8 @@ create table llx_product_fournisseur_price_log
datec datetime,
fk_product integer,
fk_soc integer, -- lien sur llx_societe
price real,
quantity real,
price double(16,8),
quantity double,
fk_user integer
)type=innodb;

View File

@ -26,11 +26,11 @@ create table llx_product_price
tms timestamp,
fk_product integer NOT NULL,
date_price datetime NOT NULL,
price_level tinyint(4) NULL DEFAULT 1,
price double,
price_ttc float(12,4) DEFAULT 0,
price_level tinyint(4) NULL DEFAULT 1,
price double(16,8),
price_ttc double(16,8) DEFAULT 0,
price_base_type varchar(3) DEFAULT 'HT',
tva_tx double NOT NULL,
tva_tx double(6,3) NOT NULL,
fk_user_author integer,
envente tinyint DEFAULT 1
)type=innodb;