Suite gestion des arrondis. C'est fait sur les propales.
This commit is contained in:
parent
e2f85b6d44
commit
5cb9588518
@ -474,28 +474,6 @@ if ($_GET['action'] == 'modif' && $user->rights->propale->creer)
|
||||
}
|
||||
|
||||
|
||||
if ($_POST['action'] == "setabsolutediscount" && $user->rights->propale->creer)
|
||||
{
|
||||
if ($_POST["remise_id"])
|
||||
{
|
||||
$propal = new Propal($db);
|
||||
$propal->id=$_GET['propalid'];
|
||||
$ret=$propal->fetch($_GET['propalid']);
|
||||
if ($ret > 0)
|
||||
{
|
||||
$propal->insert_discount($_POST["remise_id"]);
|
||||
if ($result < 0)
|
||||
{
|
||||
$mesg='<div class="error">'.$propal->error.'</div>';
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
dolibarr_print_error($db,$propal->error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Ajout d'une ligne produit dans la propale
|
||||
*/
|
||||
@ -551,7 +529,8 @@ if ($_POST['action'] == "addligne" && $user->rights->propale->creer)
|
||||
$_POST['qty'],
|
||||
$tva_tx,
|
||||
$_POST['idprod'],
|
||||
$_POST['remise_percent']
|
||||
$_POST['remise_percent'],
|
||||
'HT'
|
||||
);
|
||||
|
||||
if ($_REQUEST['lang_id'])
|
||||
@ -1150,7 +1129,7 @@ if ($_GET['propalid'] > 0)
|
||||
}
|
||||
print "</td>\n";
|
||||
}
|
||||
print '<td align="right">'.$objp->tva_tx.'%</td>';
|
||||
print '<td align="right">'.vatrate($objp->tva_tx).'%</td>';
|
||||
print '<td align="right">'.price($objp->subprice)."</td>\n";
|
||||
|
||||
// Qty
|
||||
|
||||
@ -1639,7 +1639,7 @@ if ($_GET['action'] == 'create')
|
||||
}
|
||||
}
|
||||
print '</td>';
|
||||
print '<td align="right">'.$objp->tva_tx.'%</td>';
|
||||
print '<td align="right">'.vatrate($objp->tva_tx).'%</td>';
|
||||
print '<td align="right">'.price($objp->subprice).'</td>';
|
||||
print '<td align="right">';
|
||||
print (($objp->info_bits & 2) != 2) ? $objp->qty : ' ';
|
||||
@ -2193,9 +2193,10 @@ else
|
||||
/*
|
||||
* Lignes de factures
|
||||
*/
|
||||
$sql = 'SELECT l.fk_product, l.description, l.price, l.qty, l.rowid, l.tva_taux,';
|
||||
$sql = 'SELECT l.fk_product, l.description, l.qty, l.rowid, l.tva_taux,';
|
||||
$sql.= ' l.fk_remise_except,';
|
||||
$sql.= ' l.remise_percent, l.subprice, l.info_bits,';
|
||||
$sql.= ' l.total_ht, l.total_tva, l.total_ttc,';
|
||||
$sql.= ' '.$db->pdate('l.date_start').' as date_start,';
|
||||
$sql.= ' '.$db->pdate('l.date_end').' as date_end,';
|
||||
$sql.= ' p.ref, p.fk_product_type, p.label as product,';
|
||||
@ -2289,7 +2290,7 @@ else
|
||||
}
|
||||
print "</td>\n";
|
||||
}
|
||||
print '<td align="right">'.$objp->tva_taux.'%</td>';
|
||||
print '<td align="right">'.vatrate($objp->tva_taux).'%</td>';
|
||||
print '<td align="right">'.price($objp->subprice)."</td>\n";
|
||||
print '<td align="right">';
|
||||
if (($objp->info_bits & 2) != 2)
|
||||
@ -2306,7 +2307,7 @@ else
|
||||
{
|
||||
print '<td> </td>';
|
||||
}
|
||||
print '<td align="right">'.price($objp->subprice*$objp->qty*(100-$objp->remise_percent)/100)."</td>\n";
|
||||
print '<td align="right">'.price($objp->total_ht)."</td>\n";
|
||||
|
||||
// Icone d'edition et suppression
|
||||
if ($fac->statut == 0 && $user->rights->facture->creer)
|
||||
|
||||
@ -2316,7 +2316,7 @@ class Form
|
||||
{
|
||||
print ' selected="true"';
|
||||
}
|
||||
print '>'.$libtva[$i].'</option>';
|
||||
print '>'.vatrate($libtva[$i]).'</option>';
|
||||
|
||||
$this->tva_taux_value[$i] = $txtva[$i];
|
||||
$this->tva_taux_libelle[$i] = $libtva[$i];
|
||||
|
||||
@ -456,7 +456,7 @@ 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_TOT=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>)
|
||||
MAIN_MAX_DECIMALS_SHOWN=Max decimals for prices shown on screen (Add <b>...</b> after this number if you want to see <b>...<b> when number is truncated when shown on screen)
|
||||
##### Users setup #####
|
||||
UserGroupSetup=Users and groups module setup
|
||||
GeneratePassword=Suggest a generated password
|
||||
|
||||
@ -463,7 +463,7 @@ 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_TOT=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>)
|
||||
MAIN_MAX_DECIMALS_SHOWN=Nombre de décimals maximum pour les montant affichés à l'écran (Mettre <b>...</b> après ce nombre max si vous voulez voir <b>...</b> quand le nombre est tronqué à l'affichage écran)
|
||||
##### Users setup #####
|
||||
UserGroupSetup=Configuration module utilisateurs et groupes
|
||||
GeneratePassword=Proposer un mot de passe généré
|
||||
|
||||
@ -1903,17 +1903,36 @@ function print_fleche_navigation($page,$file,$options='',$nextpage)
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* \brief Fonction qui retourne un taux de tva formaté pour visualisation
|
||||
* \remarks Fonction utilisée dans les pdf et les pages html
|
||||
* \param rate Taux a formater (19.6 19,6 19.6% 19,6%...)
|
||||
* \return string Chaine avec montant formaté (19,6 ou 19,6%)
|
||||
*/
|
||||
function vatrate($rate)
|
||||
{
|
||||
$foundpercent=false;
|
||||
if (eregi('%',$rate))
|
||||
{
|
||||
$rate=eregi_replace('%','',$rate);
|
||||
$foundpercent=true;
|
||||
}
|
||||
return price($rate,0,'',0,0).($foundpercent?'%':'');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* \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 outlangs Objet langs pour formatage text
|
||||
* \param trunc 1=Tronque affichage si trop de décimales,0=Force le non troncage
|
||||
* \param nbdecimal Nbre decimals minimum.
|
||||
* \return string Chaine avec montant formaté
|
||||
* \seealso price2num Fonction inverse de price
|
||||
*/
|
||||
function price($amount, $html=0, $outlangs='', $trunc=1)
|
||||
function price($amount, $html=0, $outlangs='', $trunc=1, $nbdecimal=2)
|
||||
{
|
||||
global $langs,$conf;
|
||||
|
||||
@ -1934,17 +1953,19 @@ function price($amount, $html=0, $outlangs='', $trunc=1)
|
||||
$decpart = $datas[1];
|
||||
$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;
|
||||
$end='';
|
||||
|
||||
// On augmente au besoin si il y a plus de 2 décimales
|
||||
if (strlen($decpart) > $nbdecimal) $nbdecimal=strlen($decpart);
|
||||
// Si on depasse max
|
||||
if ($trunc && $nbdecimal > $conf->global->MAIN_MAX_DECIMALS_SHOWN)
|
||||
{
|
||||
$nbdecimal=$conf->global->MAIN_MAX_DECIMALS_SHOWN;
|
||||
$end='...';
|
||||
if (eregi('\.\.\.',$conf->global->MAIN_MAX_DECIMALS_SHOWN))
|
||||
{
|
||||
// Si un affichage est tronqué, on montre des ...
|
||||
$end='...';
|
||||
}
|
||||
}
|
||||
|
||||
// Formate nombre
|
||||
|
||||
@ -280,8 +280,8 @@ class Propal extends CommonObject
|
||||
$remise_percent=price2num($remise_percent);
|
||||
$qty=price2num($qty);
|
||||
if (! $qty) $qty=1;
|
||||
$pu = price2num($pu);
|
||||
$txtva = price2num($txtva);
|
||||
$pu = price2num($pu,'MU');
|
||||
$txtva = price2num($txtva,'MU');
|
||||
|
||||
// Calcul du total TTC et de la TVA pour la ligne a partir de
|
||||
// qty, pu, remise_percent et txtva
|
||||
@ -292,8 +292,9 @@ class Propal extends CommonObject
|
||||
$total_tva = $tabprice[1];
|
||||
$total_ttc = $tabprice[2];
|
||||
|
||||
// \TODO A virer
|
||||
// Anciens indicateurs: $price, $remise (a ne plus utiliser)
|
||||
$price = $pu;
|
||||
$price = $pu;
|
||||
if ($remise_percent > 0)
|
||||
{
|
||||
$remise = round(($pu * $remise_percent / 100), 2);
|
||||
@ -316,7 +317,7 @@ class Propal extends CommonObject
|
||||
$ligne->total_tva=$total_tva;
|
||||
$ligne->total_ttc=$total_ttc;
|
||||
|
||||
// Ne plus utiliser
|
||||
// \TODO Ne plus utiliser
|
||||
$ligne->price=$price;
|
||||
$ligne->remise=$remise;
|
||||
|
||||
@ -2236,6 +2237,9 @@ class PropaleLigne
|
||||
dolibarr_syslog("PropaleLigne.class::insert rang=".$this->rang);
|
||||
$this->db->begin();
|
||||
|
||||
// Nettoyage parameteres
|
||||
if (! $this->remise) $this->remise=0;
|
||||
|
||||
$rangtouse=$this->rang;
|
||||
if ($rangtouse == -1)
|
||||
{
|
||||
@ -2258,29 +2262,29 @@ class PropaleLigne
|
||||
|
||||
// Insertion dans base de la ligne
|
||||
$sql = 'INSERT INTO '.MAIN_DB_PREFIX.'propaldet';
|
||||
$sql.= ' (fk_propal, description, price, qty, tva_tx,';
|
||||
$sql.= ' fk_product, remise_percent, subprice, remise, fk_remise_except, ';
|
||||
$sql.= ' rang, coef,';
|
||||
$sql.= ' info_bits, total_ht, total_tva, total_ttc)';
|
||||
$sql.= ' (fk_propal, description, fk_product, fk_remise_except, qty, tva_tx,';
|
||||
$sql.= ' subprice, remise_percent, price, remise, ';
|
||||
$sql.= ' info_bits, ';
|
||||
$sql.= ' total_ht, total_tva, total_ttc, coef, rang)';
|
||||
$sql.= " VALUES (".$this->fk_propal.",";
|
||||
$sql.= " '".addslashes($this->desc)."',";
|
||||
$sql.= " '".price2num($this->price)."',";
|
||||
$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->remise)."',";
|
||||
if ($this->fk_remise_except) $sql.= $this->fk_remise_except.",";
|
||||
else $sql.= 'null,';
|
||||
$sql.= ' '.$rangtouse.',';
|
||||
$sql.= " ".price2num($this->qty).",";
|
||||
$sql.= " ".price2num($this->tva_tx).",";
|
||||
$sql.= " ".price2num($this->subprice).",";
|
||||
$sql.= " ".price2num($this->remise_percent).",";
|
||||
$sql.= " ".price2num($this->price).","; // \TODO A virer
|
||||
$sql.= " ".price2num($this->remise).","; // \TODO A virer
|
||||
$sql.= " '".$this->info_bits."',";
|
||||
$sql.= " ".price2num($this->total_ht).",";
|
||||
$sql.= " ".price2num($this->total_tva).",";
|
||||
$sql.= " ".price2num($this->total_ttc).",";
|
||||
if (isset($this->coef)) $sql.= ' '.$this->coef.',';
|
||||
else $sql.= ' null,';
|
||||
$sql.= " '".$this->info_bits."',";
|
||||
$sql.= " '".price2num($this->total_ht)."',";
|
||||
$sql.= " '".price2num($this->total_tva)."',";
|
||||
$sql.= " '".price2num($this->total_ttc)."'";
|
||||
$sql.= ' '.$rangtouse;
|
||||
$sql.= ')';
|
||||
|
||||
dolibarr_syslog("PropaleLigne.class::insert sql=$sql");
|
||||
@ -2313,20 +2317,20 @@ class PropaleLigne
|
||||
// Mise a jour ligne en base
|
||||
$sql = "UPDATE ".MAIN_DB_PREFIX."propaldet SET";
|
||||
$sql.= " description='".addslashes($this->desc)."'";
|
||||
$sql.= ",price='".price2num($this->price)."'";
|
||||
$sql.= ",subprice='".price2num($this->subprice)."'";
|
||||
$sql.= ",remise='".price2num($this->remise)."'";
|
||||
$sql.= ",remise_percent='".price2num($this->remise_percent)."'";
|
||||
if ($fk_remise_except) $sql.= ",fk_remise_except=".$this->fk_remise_except;
|
||||
else $sql.= ",fk_remise_except=null";
|
||||
$sql.= ",tva_tx='".price2num($this->tva_tx)."'";
|
||||
$sql.= ",qty='".price2num($this->qty)."'";
|
||||
$sql.= ",subprice=".price2num($this->subprice)."";
|
||||
$sql.= ",remise_percent=".price2num($this->remise_percent)."";
|
||||
$sql.= ",price=".price2num($this->price).""; // \TODO A virer
|
||||
$sql.= ",remise=".price2num($this->remise).""; // \TODO A virer
|
||||
$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.= ",rang='".$this->rang."'";
|
||||
$sql.= ",coef='".$this->coef."'";
|
||||
$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.= " WHERE rowid = ".$this->rowid;
|
||||
|
||||
dolibarr_syslog("PropaleLigne::update sql=$sql");
|
||||
@ -2347,7 +2351,7 @@ class PropaleLigne
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Mise a jour an base des champs total_xxx de ligne de propale
|
||||
* \brief Mise a jour en base des champs total_xxx de ligne de propale
|
||||
* \return int <0 si ko, >0 si ok
|
||||
*/
|
||||
function update_total()
|
||||
@ -2356,9 +2360,9 @@ class PropaleLigne
|
||||
|
||||
// Mise a jour ligne en base
|
||||
$sql = "UPDATE ".MAIN_DB_PREFIX."propaldet 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;
|
||||
|
||||
dolibarr_syslog("PropaleLigne::update_total sql=$sql");
|
||||
|
||||
@ -599,6 +599,18 @@ ALTER TABLE llx_facture_fourn_det MODIFY tva_taux double(16,8) DEFAULT
|
||||
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;
|
||||
|
||||
ALTER TABLE llx_propal ADD total_ht double(16,8) DEFAULT 0 after remise;
|
||||
|
||||
ALTER TABLE llx_propal MODIFY tva double(16,8) DEFAULT 0;
|
||||
ALTER TABLE llx_propal MODIFY total_ht double(16,8) DEFAULT 0;
|
||||
ALTER TABLE llx_propal MODIFY total double(16,8) DEFAULT 0;
|
||||
|
||||
ALTER TABLE llx_propaldet MODIFY tva_tx double(6,3) DEFAULT 0;
|
||||
ALTER TABLE llx_propaldet MODIFY total_ht double(16,8) DEFAULT 0;
|
||||
ALTER TABLE llx_propaldet MODIFY total_tva double(16,8) DEFAULT 0;
|
||||
ALTER TABLE llx_propaldet MODIFY total_ttc double(16,8) DEFAULT 0;
|
||||
ALTER TABLE llx_propaldet MODIFY subprice double(16,8) DEFAULT 0;
|
||||
|
||||
ALTER TABLE llx_societe_remise_except MODIFY amount_ht double(16,8) DEFAULT 0;
|
||||
ALTER TABLE llx_societe_remise_except MODIFY amount_tva double(16,8) DEFAULT 0;
|
||||
ALTER TABLE llx_societe_remise_except MODIFY amount_ttc double(16,8) DEFAULT 0;
|
||||
|
||||
@ -37,13 +37,13 @@ create table llx_propal
|
||||
fk_user_valid integer, -- valideur de la propale
|
||||
fk_user_cloture integer, -- cloture de la propale signee ou non signee
|
||||
fk_statut smallint DEFAULT 0 NOT NULL,
|
||||
price real DEFAULT 0,
|
||||
remise_percent real DEFAULT 0, -- remise globale relative en pourcent
|
||||
remise_absolue real DEFAULT 0, -- remise globale absolue
|
||||
remise real DEFAULT 0, -- remise calculee
|
||||
tva real DEFAULT 0, -- montant tva apres remise globale
|
||||
total_ht real DEFAULT 0, -- montant total ht apres remise globale
|
||||
total real DEFAULT 0, -- montant total ttc apres remise globale
|
||||
price real DEFAULT 0, -- (obsolete)
|
||||
remise_percent real DEFAULT 0, -- remise globale relative en pourcent (obsolete)
|
||||
remise_absolue real DEFAULT 0, -- remise globale absolue (obsolete)
|
||||
remise real DEFAULT 0, -- remise calculee (obsolete)
|
||||
total_ht double(16,8) DEFAULT 0, -- montant total ht apres remise globale
|
||||
tva double(16,8) DEFAULT 0, -- montant total tva apres remise globale
|
||||
total double(16,8) DEFAULT 0, -- montant total ttc apres remise globale
|
||||
|
||||
fk_cond_reglement integer, -- condition de reglement (30 jours, fin de mois ...)
|
||||
fk_mode_reglement integer, -- mode de reglement (Virement, Prélèvement)
|
||||
|
||||
@ -25,17 +25,17 @@ create table llx_propaldet
|
||||
fk_propal integer,
|
||||
fk_product integer,
|
||||
description text,
|
||||
tva_tx real, -- taux tva
|
||||
fk_remise_except integer NULL, -- Lien vers table des remises fixes
|
||||
tva_tx double(6,3), -- taux tva
|
||||
qty real, -- quantité
|
||||
remise_percent real DEFAULT 0, -- pourcentage de remise
|
||||
remise real DEFAULT 0, -- montant de la remise
|
||||
fk_remise_except integer NULL, -- Lien vers table des remises fixes
|
||||
subprice real, -- prix avant remise
|
||||
price real, -- prix final
|
||||
total_ht real, -- Total HT de la ligne toute quantité et incluant remise ligne et globale
|
||||
total_tva real, -- Total TVA de la ligne toute quantité et incluant remise ligne et globale
|
||||
total_ttc real, -- Total TTC de la ligne toute quantité et incluant remise ligne et globale
|
||||
info_bits integer DEFAULT 0, -- TVA NPR ou non
|
||||
remise real DEFAULT 0, -- montant de la remise (obsolete)
|
||||
price real, -- prix final (obsolete)
|
||||
subprice double(16,8), -- prix unitaire article
|
||||
total_ht double(16,8), -- Total HT de la ligne toute quantité et incluant remise ligne et globale
|
||||
total_tva double(16,8), -- Total TVA de la ligne toute quantité et incluant remise ligne et globale
|
||||
total_ttc double(16,8), -- Total TTC de la ligne toute quantité et incluant remise ligne et globale
|
||||
info_bits integer DEFAULT 0, -- TVA NPR ou non
|
||||
coef real, -- coefficient de marge
|
||||
rang integer DEFAULT 0
|
||||
rang integer DEFAULT 0 -- ordre affichage sur la propal
|
||||
)type=innodb;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user