Gestion des la precision decimals sur les prix unitaires des produits.
This commit is contained in:
parent
4faa3937ae
commit
65f70ca87e
@ -39,7 +39,7 @@ if (isset($_POST["action"]) && $_POST["action"] == 'update')
|
||||
{
|
||||
$MAXDEC=8;
|
||||
if ($_POST["MAIN_MAX_DECIMALS_UNIT"] > $MAXDEC
|
||||
|| $_POST["MAIN_MAX_DECIMALS_TTC"] > $MAXDEC
|
||||
|| $_POST["MAIN_MAX_DECIMALS_TOT"] > $MAXDEC
|
||||
|| $_POST["MAIN_MAX_DECIMALS_SHOWN"] > $MAXDEC)
|
||||
{
|
||||
$mesg='<div class="error">'.$langs->trans("ErrorDecimalLargerThanAreForbidden",$MAXDEC).'</div>';
|
||||
@ -47,7 +47,7 @@ if (isset($_POST["action"]) && $_POST["action"] == 'update')
|
||||
else
|
||||
{
|
||||
dolibarr_set_const($db, "MAIN_MAX_DECIMALS_UNIT", $_POST["MAIN_MAX_DECIMALS_UNIT"]);
|
||||
dolibarr_set_const($db, "MAIN_MAX_DECIMALS_TTC", $_POST["MAIN_MAX_DECIMALS_TTC"]);
|
||||
dolibarr_set_const($db, "MAIN_MAX_DECIMALS_TOT", $_POST["MAIN_MAX_DECIMALS_TOT"]);
|
||||
dolibarr_set_const($db, "MAIN_MAX_DECIMALS_SHOWN", $_POST["MAIN_MAX_DECIMALS_SHOWN"]);
|
||||
|
||||
Header("Location: ".$_SERVER["PHP_SELF"]."?mainmenu=home&leftmenu=setup");
|
||||
@ -82,7 +82,7 @@ if (isset($_GET["action"]) && $_GET["action"] == 'edit')
|
||||
print '<tr '.$bc[$var].'><td>'.$langs->trans("MAIN_MAX_DECIMALS_UNIT").'</td><td><input class="flat" name="MAIN_MAX_DECIMALS_UNIT" size="3" value="' . $conf->global->MAIN_MAX_DECIMALS_UNIT . '"></td></tr>';
|
||||
|
||||
$var=!$var;
|
||||
print '<tr '.$bc[$var].'><td>'.$langs->trans("MAIN_MAX_DECIMALS_TTC").'</td><td><input class="flat" name="MAIN_MAX_DECIMALS_TTC" size="3" value="' . $conf->global->MAIN_MAX_DECIMALS_TTC . '"></td></tr>';
|
||||
print '<tr '.$bc[$var].'><td>'.$langs->trans("MAIN_MAX_DECIMALS_TOT").'</td><td><input class="flat" name="MAIN_MAX_DECIMALS_TOT" size="3" value="' . $conf->global->MAIN_MAX_DECIMALS_TOT . '"></td></tr>';
|
||||
|
||||
$var=!$var;
|
||||
print '<tr '.$bc[$var].'><td>'.$langs->trans("MAIN_MAX_DECIMALS_SHOWN").'</td><td><input class="flat" name="MAIN_MAX_DECIMALS_SHOWN" size="3" value="' . $conf->global->MAIN_MAX_DECIMALS_SHOWN . '"></td></tr>';
|
||||
@ -109,7 +109,7 @@ else
|
||||
print '<tr '.$bc[$var].'><td>'.$langs->trans("MAIN_MAX_DECIMALS_UNIT").'</td><td align="right">'.$conf->global->MAIN_MAX_DECIMALS_UNIT.'</td></tr>';
|
||||
|
||||
$var=!$var;
|
||||
print '<tr '.$bc[$var].'><td>'.$langs->trans("MAIN_MAX_DECIMALS_TTC").'</td><td align="right">'.$conf->global->MAIN_MAX_DECIMALS_TTC.'</td></tr>';
|
||||
print '<tr '.$bc[$var].'><td>'.$langs->trans("MAIN_MAX_DECIMALS_TOT").'</td><td align="right">'.$conf->global->MAIN_MAX_DECIMALS_TOT.'</td></tr>';
|
||||
|
||||
$var=!$var;
|
||||
print '<tr '.$bc[$var].'><td>'.$langs->trans("MAIN_MAX_DECIMALS_SHOWN").'</td><td align="right">'.$conf->global->MAIN_MAX_DECIMALS_SHOWN.'</td></tr>';
|
||||
|
||||
@ -474,7 +474,7 @@ class Conf
|
||||
|
||||
// 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_TOT)) $this->global->MAIN_MAX_DECIMALS_TOT=2;
|
||||
if (! isset($this->global->MAIN_MAX_DECIMALS_SHOWN)) $this->global->MAIN_MAX_DECIMALS_SHOWN=8;
|
||||
|
||||
|
||||
|
||||
@ -2841,14 +2841,14 @@ class FactureLigne
|
||||
$sql.= ' info_bits, total_ht, total_tva, total_ttc)';
|
||||
$sql.= " VALUES (".$this->fk_facture.",";
|
||||
$sql.= " '".addslashes($this->desc)."',";
|
||||
$sql.= " '".price2num($this->qty)."',";
|
||||
$sql.= " '".price2num($this->tva_tx)."',";
|
||||
$sql.= " ".price2num($this->qty).",";
|
||||
$sql.= " ".price2num($this->tva_tx).",";
|
||||
if ($this->fk_product) { $sql.= "'".$this->fk_product."',"; }
|
||||
else { $sql.='null,'; }
|
||||
$sql.= " '".price2num($this->remise_percent)."',";
|
||||
$sql.= " '".price2num($this->subprice)."',";
|
||||
$sql.= " '".price2num($this->price)."',";
|
||||
$sql.= " '".price2num($this->remise)."',";
|
||||
$sql.= " ".price2num($this->remise_percent).",";
|
||||
$sql.= " ".price2num($this->subprice).",";
|
||||
$sql.= " ".price2num($this->price).",";
|
||||
$sql.= " ".price2num($this->remise).",";
|
||||
if ($this->fk_remise_except) $sql.= $this->fk_remise_except.",";
|
||||
else $sql.= 'null,';
|
||||
if ($this->date_start) { $sql.= "'".$this->date_start."',"; }
|
||||
@ -2859,9 +2859,9 @@ class FactureLigne
|
||||
$sql.= ' '.$this->fk_export_compta.',';
|
||||
$sql.= ' '.$rangtouse.',';
|
||||
$sql.= " '".$this->info_bits."',";
|
||||
$sql.= " '".price2num($this->total_ht)."',";
|
||||
$sql.= " '".price2num($this->total_tva)."',";
|
||||
$sql.= " '".price2num($this->total_ttc)."'";
|
||||
$sql.= " ".price2num($this->total_ht);
|
||||
$sql.= " ".price2num($this->total_tva);
|
||||
$sql.= " ".price2num($this->total_ttc);
|
||||
$sql.= ')';
|
||||
|
||||
dolibarr_syslog("FactureLigne::insert sql=".$sql);
|
||||
@ -2943,23 +2943,23 @@ class FactureLigne
|
||||
// Mise a jour ligne en base
|
||||
$sql = "UPDATE ".MAIN_DB_PREFIX."facturedet SET";
|
||||
$sql.= " description='".addslashes($this->desc)."'";
|
||||
$sql.= ",subprice='".price2num($this->subprice)."'";
|
||||
$sql.= ",price='".price2num($this->price)."'";
|
||||
$sql.= ",remise='".price2num($this->remise)."'";
|
||||
$sql.= ",remise_percent='".price2num($this->remise_percent)."'";
|
||||
$sql.= ",subprice=".price2num($this->subprice)."";
|
||||
$sql.= ",price=".price2num($this->price)."";
|
||||
$sql.= ",remise=".price2num($this->remise)."";
|
||||
$sql.= ",remise_percent=".price2num($this->remise_percent)."";
|
||||
if ($this->fk_remise_except) $sql.= ",fk_remise_except=".$this->fk_remise_except;
|
||||
else $sql.= ",fk_remise_except=null";
|
||||
$sql.= ",tva_taux='".price2num($this->tva_tx)."'";
|
||||
$sql.= ",qty='".price2num($this->qty)."'";
|
||||
$sql.= ",tva_taux=".price2num($this->tva_tx)."";
|
||||
$sql.= ",qty=".price2num($this->qty)."";
|
||||
if ($this->date_start) { $sql.= ",date_start='".$this->date_start."'"; }
|
||||
else { $sql.=',date_start=null'; }
|
||||
if ($this->date_end) { $sql.= ",date_end='".$this->date_end."'"; }
|
||||
else { $sql.=',date_end=null'; }
|
||||
$sql.= ",rang='".$this->rang."'";
|
||||
$sql.= ",info_bits='".$this->info_bits."'";
|
||||
$sql.= ",total_ht='".price2num($this->total_ht)."'";
|
||||
$sql.= ",total_tva='".price2num($this->total_tva)."'";
|
||||
$sql.= ",total_ttc='".price2num($this->total_ttc)."'";
|
||||
$sql.= ",total_ht=".price2num($this->total_ht)."";
|
||||
$sql.= ",total_tva=".price2num($this->total_tva)."";
|
||||
$sql.= ",total_ttc=".price2num($this->total_ttc)."";
|
||||
$sql.= " WHERE rowid = ".$this->rowid;
|
||||
|
||||
dolibarr_syslog("FactureLigne::update sql=$sql");
|
||||
@ -2990,9 +2990,9 @@ class FactureLigne
|
||||
|
||||
// Mise a jour ligne en base
|
||||
$sql = "UPDATE ".MAIN_DB_PREFIX."facturedet SET";
|
||||
$sql.= " total_ht='".price2num($this->total_ht)."'";
|
||||
$sql.= ",total_tva='".price2num($this->total_tva)."'";
|
||||
$sql.= ",total_ttc='".price2num($this->total_ttc)."'";
|
||||
$sql.= " total_ht=".price2num($this->total_ht)."";
|
||||
$sql.= ",total_tva=".price2num($this->total_tva)."";
|
||||
$sql.= ",total_ttc=".price2num($this->total_ttc)."";
|
||||
$sql.= " WHERE rowid = ".$this->rowid;
|
||||
|
||||
|
||||
|
||||
@ -446,8 +446,8 @@ class FactureFournisseur extends Facture
|
||||
$sql = 'UPDATE '.MAIN_DB_PREFIX.'facture_fourn_det ';
|
||||
$sql.= 'SET ';
|
||||
$sql.= 'description =\''.addslashes($label).'\'';
|
||||
$sql.= ', pu_ht = ' .$puht;
|
||||
$sql.= ', qty =' .$qty;
|
||||
$sql.= ', pu_ht = ' .price2num($puht);
|
||||
$sql.= ', qty =' .price2num($qty);
|
||||
$sql.= ', total_ht=' .price2num($totalht);
|
||||
$sql.= ', tva=' .price2num($tva);
|
||||
$sql.= ', tva_taux=' .price2num($tauxtva);
|
||||
@ -456,6 +456,7 @@ class FactureFournisseur extends Facture
|
||||
else $sql.= ', fk_product=null';
|
||||
$sql.= ' WHERE rowid = '.$id;
|
||||
|
||||
dolibarr_syslog("Fournisseur.facture::updateline sql=".$sql);
|
||||
$resql=$this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
@ -524,6 +525,7 @@ class FactureFournisseur extends Facture
|
||||
$sql .= ',total_tva = '.price2num($total_tva);
|
||||
$sql .= ',total_ttc = '.price2num($total_ttc);
|
||||
$sql .= ' WHERE rowid = '.$facid.';';
|
||||
dolibarr_syslog("Fournisseur.facture::update_price sql=".$sql);
|
||||
$resql2 = $this->db->query($sql);
|
||||
if ($resql2)
|
||||
{
|
||||
|
||||
@ -454,7 +454,7 @@ MiscellanousDesc=Define here all other parameters related to security.
|
||||
LimitsSetup=Limits/Precision setup
|
||||
LimitsDesc=You can define here limits and precision used by Dolibarr
|
||||
MAIN_MAX_DECIMALS_UNIT=Max decimals for unit prices
|
||||
MAIN_MAX_DECIMALS_TTC=Max decimals for prices with taxes
|
||||
MAIN_MAX_DECIMALS_TTC=Max decimals for total prices
|
||||
MAIN_MAX_DECIMALS_SHOWN=Max decimals for prices shown on screen (Excedented decimals will be replaced by three dots <b>...</b>)
|
||||
##### Users setup #####
|
||||
UserGroupSetup=Users and groups module setup
|
||||
|
||||
@ -461,7 +461,7 @@ MiscellanousDesc=D
|
||||
LimitsSetup=Configuration des limites et precisions
|
||||
LimitsDesc=Vous pouvez définir ici les limites et précisions utilisées par Dolibarr
|
||||
MAIN_MAX_DECIMALS_UNIT=Nombre de décimals maximum pour les prix unitaires
|
||||
MAIN_MAX_DECIMALS_TTC=Nombre de décimals maximum pour les prix totaux toute taxe comprise
|
||||
MAIN_MAX_DECIMALS_TTC=Nombre de décimals maximum pour les prix totaux
|
||||
MAIN_MAX_DECIMALS_SHOWN=Nombre de décimals maximum pour les montant affichés à l'écran (Les décimals en trop sont remplacés par trois petits points: <b>...</b>)
|
||||
##### Users setup #####
|
||||
UserGroupSetup=Configuration module utilisateurs et groupes
|
||||
|
||||
@ -1959,7 +1959,7 @@ function price($amount, $html=0, $outlangs='', $trunc=1)
|
||||
\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)
|
||||
'MT'=Round to Max with Tax (MAIN_MAX_DECIMALS_TOT)
|
||||
'MS'=Round to Max Shown (MAIN_MAX_DECIMALS_SHOWN)
|
||||
''=No rounding
|
||||
\return string Montant au format numérique PHP et SQL (Exemple: '99.99999')
|
||||
@ -1976,7 +1976,7 @@ function price2num($amount,$rounding='')
|
||||
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 == 'MT') $amount = round($amount,$conf->global->MAIN_MAX_DECIMALS_TOT);
|
||||
elseif ($rounding == 'MS') $amount = round($amount,$conf->global->MAIN_MAX_DECIMALS_SHOWN);
|
||||
else $amount='ErrorBadParameterProvidedToFunction';
|
||||
$amount=ereg_replace(',','.',$amount);
|
||||
|
||||
@ -583,6 +583,22 @@ ALTER TABLE llx_product_fournisseur_price MODIFY price double(16,8);
|
||||
ALTER TABLE llx_product_fournisseur_price MODIFY quantity double;
|
||||
|
||||
|
||||
ALTER TABLE llx_facture_fourn MODIFY amount double(16,8) DEFAULT 0 NOT NULL;
|
||||
ALTER TABLE llx_facture_fourn MODIFY remise double(16,8) DEFAULT 0;
|
||||
ALTER TABLE llx_facture_fourn MODIFY tva double(16,8) DEFAULT 0;
|
||||
ALTER TABLE llx_facture_fourn MODIFY total double(16,8) DEFAULT 0;
|
||||
ALTER TABLE llx_facture_fourn MODIFY total_ht double(16,8) DEFAULT 0;
|
||||
ALTER TABLE llx_facture_fourn MODIFY total_tva double(16,8) DEFAULT 0;
|
||||
ALTER TABLE llx_facture_fourn MODIFY total_ttc double(16,8) DEFAULT 0;
|
||||
|
||||
ALTER TABLE llx_facture_fourn_det MODIFY pu_ht double(16,8) DEFAULT 0;
|
||||
ALTER TABLE llx_facture_fourn_det MODIFY qty smallint DEFAULT 1;
|
||||
ALTER TABLE llx_facture_fourn_det MODIFY total_ht double(16,8) DEFAULT 0;
|
||||
ALTER TABLE llx_facture_fourn_det MODIFY tva_taux double(16,8) DEFAULT 0;
|
||||
ALTER TABLE llx_facture_fourn_det MODIFY tva double(16,8) DEFAULT 0;
|
||||
ALTER TABLE llx_facture_fourn_det MODIFY total_ttc double(16,8) DEFAULT 0;
|
||||
|
||||
|
||||
-- Changement de idp en rowid
|
||||
-- V4 ALTER TABLE llx_propal DROP FOREIGN KEY llx_propal_ibfk1;
|
||||
-- V4 ALTER TABLE llx_socpeople DROP FOREIGN KEY fk_socpeople_fk_soc;
|
||||
|
||||
@ -30,13 +30,13 @@ create table llx_facture_fourn
|
||||
datef date, -- date de la facture
|
||||
libelle varchar(255),
|
||||
paye smallint DEFAULT 0 NOT NULL,
|
||||
amount real DEFAULT 0 NOT NULL,
|
||||
remise real DEFAULT 0,
|
||||
tva real DEFAULT 0,
|
||||
total real DEFAULT 0,
|
||||
total_ht real DEFAULT 0,
|
||||
total_tva real DEFAULT 0,
|
||||
total_ttc real DEFAULT 0,
|
||||
amount double(16,8) DEFAULT 0 NOT NULL,
|
||||
remise double(16,8) DEFAULT 0,
|
||||
tva double(16,8) DEFAULT 0,
|
||||
total double(16,8) DEFAULT 0,
|
||||
total_ht double(16,8) DEFAULT 0,
|
||||
total_tva double(16,8) DEFAULT 0,
|
||||
total_ttc double(16,8) DEFAULT 0,
|
||||
|
||||
fk_statut smallint DEFAULT 0 NOT NULL,
|
||||
|
||||
|
||||
@ -25,11 +25,11 @@ create table llx_facture_fourn_det
|
||||
fk_facture_fourn integer NOT NULL,
|
||||
fk_product integer NULL,
|
||||
description text,
|
||||
pu_ht real DEFAULT 0,
|
||||
pu_ht double(16,8) DEFAULT 0,
|
||||
qty smallint DEFAULT 1,
|
||||
total_ht real DEFAULT 0,
|
||||
tva_taux real DEFAULT 0,
|
||||
tva real DEFAULT 0,
|
||||
total_ttc real DEFAULT 0
|
||||
total_ht double(16,8) DEFAULT 0,
|
||||
tva_taux double(16,8) DEFAULT 0,
|
||||
tva double(16,8) DEFAULT 0,
|
||||
total_ttc double(16,8) DEFAULT 0
|
||||
|
||||
)type=innodb;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user