Suite gestion des arrondis sur les montants
This commit is contained in:
parent
1de5331346
commit
b90bcdcd33
@ -146,23 +146,23 @@ class Product
|
||||
if ($this->price=='') $this->price = 0;
|
||||
if ($this->status=='') $this->status = 0;
|
||||
|
||||
if (strlen(trim($this->price)) > 0 )
|
||||
if ($this->price > 0)
|
||||
{
|
||||
if ($this->price_base_type == 'TTC')
|
||||
{
|
||||
$price_ttc = $this->price;
|
||||
$price = $this->price / (1 + ($this->tva_tx / 100));
|
||||
$price_ttc = price2num($this->price,'MU');
|
||||
$price_ht = price2num($this->price / (1 + ($this->tva_tx / 100)),'MU');
|
||||
}
|
||||
else
|
||||
{
|
||||
$price = $this->price;
|
||||
$price_ttc = $this->price * (1 + ($this->tva_tx / 100));
|
||||
$price_ht = price2num($this->price,'MU');
|
||||
$price_ttc = price2num($this->price * (1 + ($this->tva_tx / 100)),'MU');
|
||||
}
|
||||
}
|
||||
|
||||
dolibarr_syslog("Product::Create ref=".$this->ref." Categorie : ".$this->catid);
|
||||
|
||||
if (strlen($this->ref) > 0)
|
||||
if ($this->ref)
|
||||
{
|
||||
$this->db->begin();
|
||||
|
||||
@ -176,13 +176,20 @@ class Product
|
||||
if ($row[0] == 0)
|
||||
{
|
||||
// Produit non deja existant
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."product ";
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."product";
|
||||
$sql.= " (datec, ";
|
||||
if ($this->ref) $sql.= "ref, ";
|
||||
$sql.= "fk_user_author, fk_product_type, price, price_ttc, price_base_type, canvas)";
|
||||
$sql.= " VALUES (now(), ";
|
||||
if ($this->ref) $sql.= "'".$this->ref."', ";
|
||||
$sql.= $user->id.", ".$this->type.", '" . price2num($price) . "', '".$price_ttc."', '" . $this->price_base_type . "','".$this->canvas."')";
|
||||
$sql.= $user->id.",";
|
||||
$sql.= " ".$this->type.",";
|
||||
$sql.= ($price_ht?price2num($price_ht):"null").",";
|
||||
$sql.= ($price_ttc?price2num($price_ttc):"null").",";
|
||||
$sql.= "'".$this->price_base_type."',";
|
||||
$sql.= "'".$this->canvas."')";
|
||||
|
||||
dolibarr_syslog("Product::Create sql=".$sql);
|
||||
$result = $this->db->query($sql);
|
||||
if ( $result )
|
||||
{
|
||||
@ -191,7 +198,12 @@ class Product
|
||||
if ($id > 0)
|
||||
{
|
||||
$this->id = $id;
|
||||
$this->_log_price($user);
|
||||
$this->price = $price_ht;
|
||||
$this->price_ttc = $price_ttc;
|
||||
|
||||
$result = $this->_log_price($user);
|
||||
if ($result > 0)
|
||||
{
|
||||
if ( $this->update($id, $user) > 0)
|
||||
{
|
||||
if ($this->catid > 0)
|
||||
@ -206,6 +218,11 @@ class Product
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->_setErrNo("Create",264);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->_setErrNo("Create",259);
|
||||
}
|
||||
@ -287,8 +304,10 @@ class Product
|
||||
$langs->load("main");
|
||||
$langs->load("products");
|
||||
|
||||
// Verification parametres
|
||||
if (! $this->libelle) $this->libelle = 'LIBELLE MANQUANT';
|
||||
|
||||
// Nettoyage parametres
|
||||
$this->ref = trim(sanitize_string($this->ref));
|
||||
$this->libelle = trim($this->libelle);
|
||||
$this->description = trim($this->description);
|
||||
@ -302,7 +321,7 @@ class Product
|
||||
$sql = "UPDATE ".MAIN_DB_PREFIX."product ";
|
||||
$sql .= " SET label = '" . addslashes($this->libelle) ."'";
|
||||
if ($this->ref) $sql .= ",ref = '" . $this->ref ."'";
|
||||
$sql .= ",tva_tx = '" . $this->tva_tx."'";
|
||||
$sql .= ",tva_tx = " . $this->tva_tx;
|
||||
$sql .= ",envente = " . $this->status;
|
||||
$sql .= ",weight = " . ($this->new_weight!='' ? "'".$this->new_weight."'" : 'null');
|
||||
$sql .= ",weight_units = '" . $this->new_weight_units."'";
|
||||
@ -315,6 +334,7 @@ class Product
|
||||
$sql .= ",duration = '" . $this->duration_value . $this->duration_unit ."'";
|
||||
$sql .= " WHERE rowid = " . $id;
|
||||
|
||||
dolibarr_syslog("Product::update sql=".$sql);
|
||||
if ( $this->db->query($sql) )
|
||||
{
|
||||
// Multilangs
|
||||
|
||||
@ -113,7 +113,7 @@ if ($_POST["action"] == 'add' && $user->rights->produit->creer)
|
||||
// Produit spécifique
|
||||
// $_POST n'est pas utilise dans la classe Product
|
||||
// mais dans des classes qui hérite de Product
|
||||
$id = $product->Create($user, $_POST);
|
||||
$id = $product->create($user, $_POST);
|
||||
|
||||
if ($id > 0)
|
||||
{
|
||||
@ -399,10 +399,12 @@ if ($_POST["cancel"] == $langs->trans("Cancel"))
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
|
||||
$html = new Form($db);
|
||||
|
||||
/*
|
||||
* Action création du produit
|
||||
* Fiche création du produit
|
||||
*/
|
||||
if ($_GET["action"] == 'create' && $user->rights->produit->creer)
|
||||
{
|
||||
@ -737,7 +739,7 @@ if ($_GET["id"] || $_GET["ref"])
|
||||
print '</td></tr>';
|
||||
|
||||
// TVA
|
||||
print '<tr><td>'.$langs->trans("VATRate").'</td><td>'.$product->tva_tx.'%</td></tr>';
|
||||
print '<tr><td>'.$langs->trans("VATRate").'</td><td>'.price2num($product->tva_tx,'MU').'%</td></tr>';
|
||||
|
||||
// Stock
|
||||
if ($product->isproduct() && $conf->stock->enabled)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user