diff --git a/htdocs/comm/fiche.php b/htdocs/comm/fiche.php
index 3447238b4d4..5e3492476a5 100644
--- a/htdocs/comm/fiche.php
+++ b/htdocs/comm/fiche.php
@@ -297,7 +297,7 @@ if ($socid > 0)
print '
';
$amount_discount=$objsoc->getcurrentDiscount();
if ($amount_discount < 0) dolibarr_print_error($db,$societe->error);
- if ($amount_discount > 0) print $amount_discount.' '.$langs->trans("Currency".$conf->monnaie);
+ if ($amount_discount > 0) print price($amount_discount).' '.$langs->trans("Currency".$conf->monnaie);
else print $langs->trans("DiscountNone");
print ' | ';
print '';
diff --git a/htdocs/comm/remx.php b/htdocs/comm/remx.php
index 5f483adc9cf..2630bacb5e2 100644
--- a/htdocs/comm/remx.php
+++ b/htdocs/comm/remx.php
@@ -232,7 +232,7 @@ if ($_socid > 0)
}
print '';
print ''.price($obj->amount_ht).' | ';
- print ''.price($obj->tva_tx).'% | ';
+ print ''.price2num($obj->tva_tx,'MU').'% | ';
print ''.price($obj->amount_ttc).' | ';
print '';
print ''.img_object($langs->trans("ShowUser"),'user').' '.$obj->login;
@@ -311,7 +311,7 @@ if ($_socid > 0)
print ' | ';
print ''.img_object($langs->trans("ShowBill"),'bill').' '.$obj->facnumber.' | ';
print ''.price($obj->amount_ht).' | ';
- print ''.price($obj->tva_tx).'% | ';
+ print ''.price2num($obj->tva_tx,'MU').'% | ';
print ''.price($obj->amount_ttc).' | ';
print '';
print ''.img_object($langs->trans("ShowUser"),'user').' '.$obj->login;
diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php
index 298e6f52cf3..dd967093876 100644
--- a/htdocs/compta/facture.php
+++ b/htdocs/compta/facture.php
@@ -1938,12 +1938,12 @@ else
{
if ($fac->statut > 0 || $fac->type == 2)
{
- print $langs->trans("CompanyHasAbsoluteDiscount",$absolute_discount,$langs->trans("Currency".$conf->monnaie));
+ print $langs->trans("CompanyHasAbsoluteDiscount",price($absolute_discount),$langs->trans("Currency".$conf->monnaie));
}
else
{
print ' ';
- print $html->form_remise_dispo($_SERVER["PHP_SELF"].'?facid='.$fac->id,0,'remise_id',$soc->id,$absolute_discount);
+ print $html->form_remise_dispo($_SERVER["PHP_SELF"].'?facid='.$fac->id,0,'remise_id',$soc->id,price($absolute_discount));
}
}
else print $langs->trans("CompanyHasNoAbsoluteDiscount").'.';
diff --git a/htdocs/compta/fiche.php b/htdocs/compta/fiche.php
index 29f3cf85711..77def9e621d 100644
--- a/htdocs/compta/fiche.php
+++ b/htdocs/compta/fiche.php
@@ -189,7 +189,7 @@ if ($socid > 0)
print ''.img_edit($langs->trans("Modify")).'';
}
print ' | ';
- print ''.($societe->remise_client?$societe->remise_client.'%':$langs->trans("DiscountNone")).' | ';
+ print ''.($societe->remise_client?price2num($societe->remise_client,'MT').'%':$langs->trans("DiscountNone")).' | ';
print '';
// Réductions (Remises-Ristournes-Rabbais)
@@ -207,7 +207,7 @@ if ($socid > 0)
print '';
$amount_discount=$societe->getCurrentDiscount();
if ($amount_discount < 0) dolibarr_print_error($db,$societe->error);
- if ($amount_discount > 0) print $amount_discount.' '.$langs->trans("Currency".$conf->monnaie);
+ if ($amount_discount > 0) print price($amount_discount).' '.$langs->trans("Currency".$conf->monnaie);
else print $langs->trans("DiscountNone");
print ' | ';
print '';
diff --git a/htdocs/facture.class.php b/htdocs/facture.class.php
index 3801007bf25..28c27a32222 100644
--- a/htdocs/facture.class.php
+++ b/htdocs/facture.class.php
@@ -702,102 +702,112 @@ class Facture extends CommonObject
}
}
- /**
- \brief Supprime la facture
- \param rowid Id de la facture à supprimer
- \return int <0 si ko, >0 si ok
- */
- function delete($rowid=0)
- {
- global $user,$langs,$conf;
+ /**
+ \brief Supprime la facture
+ \param rowid Id de la facture à supprimer
+ \return int <0 si ko, >0 si ok
+ */
+ function delete($rowid=0)
+ {
+ global $user,$langs,$conf;
- if (! $rowid) $rowid=$this->id;
+ if (! $rowid) $rowid=$this->id;
- dolibarr_syslog("Facture::Delete rowid=".$rowid, LOG_DEBUG);
+ dolibarr_syslog("Facture::delete rowid=".$rowid, LOG_DEBUG);
- $this->db->begin();
-
- $sql = 'DELETE FROM '.MAIN_DB_PREFIX.'facture_tva_sum WHERE fk_facture = '.$rowid;
- if ($this->db->query($sql))
- {
- $sql = 'DELETE FROM '.MAIN_DB_PREFIX.'fa_pr WHERE fk_facture = '.$rowid;
- if ($this->db->query($sql))
- {
- $sql = 'DELETE FROM '.MAIN_DB_PREFIX.'co_fa WHERE fk_facture = '.$rowid;
- if ($this->db->query($sql))
- {
- // On désaffecte de la facture les remises liées
- $sql = 'UPDATE '.MAIN_DB_PREFIX.'societe_remise_except as re,';
- $sql.= ' '.MAIN_DB_PREFIX.'facturedet as fd';
- $sql.= ' SET re.fk_facture = NULL';
- $sql.= ' WHERE fd.rowid=re.fk_facture AND fd.fk_facture = '.$rowid;
+ $this->db->begin();
+ $sql = 'DELETE FROM '.MAIN_DB_PREFIX.'facture_tva_sum WHERE fk_facture = '.$rowid;
if ($this->db->query($sql))
- {
- $sql = 'DELETE FROM '.MAIN_DB_PREFIX.'facturedet WHERE fk_facture = '.$rowid;
- if ($this->db->query($sql))
- {
- $sql = 'DELETE FROM '.MAIN_DB_PREFIX.'facture WHERE rowid = '.$rowid;
- $resql=$this->db->query($sql);
- if ($resql)
- {
- // Appel des triggers
- include_once(DOL_DOCUMENT_ROOT . "/interfaces.class.php");
- $interface=new Interfaces($this->db);
- $result=$interface->run_triggers('BILL_DELETE',$this,$user,$langs,$conf);
- // Fin appel triggers
-
- $this->db->commit();
- return 1;
- }
+ {
+ $sql = 'DELETE FROM '.MAIN_DB_PREFIX.'fa_pr WHERE fk_facture = '.$rowid;
+ if ($this->db->query($sql))
+ {
+ $sql = 'DELETE FROM '.MAIN_DB_PREFIX.'co_fa WHERE fk_facture = '.$rowid;
+ if ($this->db->query($sql))
+ {
+ // On met a jour le lien des remises
+ $list_rowid_det=array();
+ $sql = 'SELECT fd.rowid FROM '.MAIN_DB_PREFIX.'facturedet as fd WHERE fk_facture = '.$rowid;
+ $resql=$this->db->query($sql);
+ while ($obj = $this->db->fetch_object($resql))
+ {
+ $list_rowid_det[]=$obj->rowid;
+ }
+
+ // On désaffecte de la facture les remises liées
+ if (sizeof($list_rowid_det))
+ {
+ $sql = 'UPDATE '.MAIN_DB_PREFIX.'societe_remise_except as re';
+ $sql.= ' SET re.fk_facture = NULL';
+ $sql.= ' WHERE re.fk_facture in ('.join(',',$list_rowid_det).')';
+
+ dolibarr_syslog("Facture.class::delete sql=".$sql);
+ if (! $this->db->query($sql))
+ {
+ $this->error=$this->db->error()." sql=".$sql;
+ dolibarr_syslog("Facture.class::delete ".$this->error);
+ $this->db->rollback();
+ return -5;
+ }
+ }
+
+ $sql = 'DELETE FROM '.MAIN_DB_PREFIX.'facturedet WHERE fk_facture = '.$rowid;
+ if ($this->db->query($sql))
+ {
+ $sql = 'DELETE FROM '.MAIN_DB_PREFIX.'facture WHERE rowid = '.$rowid;
+ $resql=$this->db->query($sql);
+ if ($resql)
+ {
+ // Appel des triggers
+ include_once(DOL_DOCUMENT_ROOT . "/interfaces.class.php");
+ $interface=new Interfaces($this->db);
+ $result=$interface->run_triggers('BILL_DELETE',$this,$user,$langs,$conf);
+ // Fin appel triggers
+
+ $this->db->commit();
+ return 1;
+ }
+ else
+ {
+ $this->error=$this->db->error()." sql=".$sql;
+ dolibarr_syslog("Facture.class::delete ".$this->error);
+ $this->db->rollback();
+ return -6;
+ }
+ }
+ else
+ {
+ $this->error=$this->db->error()." sql=".$sql;
+ dolibarr_syslog("Facture.class::delete ".$this->error);
+ $this->db->rollback();
+ return -4;
+ }
+ }
+ else
+ {
+ $this->error=$this->db->error()." sql=".$sql;
+ dolibarr_syslog("Facture.class::delete ".$this->error);
+ $this->db->rollback();
+ return -3;
+ }
+ }
else
- {
- $this->error=$this->db->error()." sql=".$sql;
- dolibarr_syslog("Facture.class::delete ".$this->error);
- $this->db->rollback();
- return -6;
- }
- }
- else
- {
+ {
+ $this->error=$this->db->error()." sql=".$sql;
+ dolibarr_syslog("Facture.class::delete ".$this->error);
+ $this->db->rollback();
+ return -2;
+ }
+ }
+ else
+ {
$this->error=$this->db->error()." sql=".$sql;
dolibarr_syslog("Facture.class::delete ".$this->error);
$this->db->rollback();
- return -4;
- }
- }
- else
- {
- $this->error=$this->db->error()." sql=".$sql;
- dolibarr_syslog("Facture.class::delete ".$this->error);
- $this->db->rollback();
- return -5;
- }
- }
- else
- {
- $this->error=$this->db->error()." sql=".$sql;
- dolibarr_syslog("Facture.class::delete ".$this->error);
- $this->db->rollback();
- return -3;
- }
- }
- else
- {
- $this->error=$this->db->error()." sql=".$sql;
- dolibarr_syslog("Facture.class::delete ".$this->error);
- $this->db->rollback();
- return -2;
- }
- }
- else
- {
- $this->error=$this->db->error()." sql=".$sql;
- dolibarr_syslog("Facture.class::delete ".$this->error);
- $this->db->rollback();
- return -1;
- }
- }
+ return -1;
+ }
+ }
/**
diff --git a/htdocs/html.form.class.php b/htdocs/html.form.class.php
index 634fe6e0a86..74c9c66553f 100644
--- a/htdocs/html.form.class.php
+++ b/htdocs/html.form.class.php
@@ -706,11 +706,11 @@ class Form
if ($selected > 0 && $selected == $obj->rowid)
{
- print '';
+ print '';
}
else
{
- print '';
+ print '';
}
$i++;
}
@@ -2039,7 +2039,7 @@ class Form
print '';
print '';
print '| ';
- print $langs->trans("CompanyHasAbsoluteDiscount",$absolute_discount,$langs->trans("Currency".$conf->monnaie)).': ';
+ print $langs->trans("CompanyHasAbsoluteDiscount",price($absolute_discount),$langs->trans("Currency".$conf->monnaie)).': ';
// print $langs->trans("AvailableGlobalDiscounts").': ';
print $this->select_remises('',$htmlname,'fk_facture IS NULL',$socid);
print ' | ';
@@ -2051,7 +2051,9 @@ class Form
if ($selected)
{
print $selected;
- } else {
+ }
+ else
+ {
print "0";
}
}
diff --git a/htdocs/societe.class.php b/htdocs/societe.class.php
index e5c3e697ba3..7b06f81e641 100644
--- a/htdocs/societe.class.php
+++ b/htdocs/societe.class.php
@@ -994,10 +994,10 @@ class Societe
{
$discount = new DiscountAbsolute($this->db);
$discount->fk_soc=$this->id;
- $discount->amount_ht=$remise;
- $discount->amount_tva=($remise*$tva_tx/100);
- $discount->amount_ttc=$discount->amount_ht+$discount->amount_tva;
- $discount->tva_tx=$tva_tx;
+ $discount->amount_ht=price2num($remise,'MT');
+ $discount->amount_tva=price2num($remise*$tva_tx/100,'MT');
+ $discount->amount_ttc=price2num($discount->amount_ht+$discount->amount_tva,'MT');
+ $discount->tva_tx=price2num($tva_tx,'MT');
$discount->desc=$desc;
$result=$discount->create($user);
if ($result > 0)
diff --git a/mysql/migration/2.1.0-2.2.0.sql b/mysql/migration/2.1.0-2.2.0.sql
index e75d93ffcef..6c217096b9a 100644
--- a/mysql/migration/2.1.0-2.2.0.sql
+++ b/mysql/migration/2.1.0-2.2.0.sql
@@ -599,6 +599,11 @@ 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_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;
+ALTER TABLE llx_societe_remise_except MODIFY tva_tx double(6,3) DEFAULT 0;
+
-- Changement de idp en rowid
-- V4 ALTER TABLE llx_propal DROP FOREIGN KEY llx_propal_ibfk1;
diff --git a/mysql/tables/llx_societe_remise_except.sql b/mysql/tables/llx_societe_remise_except.sql
index dc823247d85..786a0b1128e 100644
--- a/mysql/tables/llx_societe_remise_except.sql
+++ b/mysql/tables/llx_societe_remise_except.sql
@@ -27,12 +27,12 @@ create table llx_societe_remise_except
rowid integer AUTO_INCREMENT PRIMARY KEY,
fk_soc integer NOT NULL, -- client
datec datetime,
- amount_ht real NOT NULL,
- amount_tva real DEFAULT 0 NOT NULL,
- amount_ttc real DEFAULT 0 NOT NULL,
- tva_tx real DEFAULT 0 NOT NULL,
- fk_user integer NOT NULL,
+ amount_ht double(16,8) NOT NULL,
+ amount_tva double(16,8) DEFAULT 0 NOT NULL,
+ amount_ttc double(16,8) DEFAULT 0 NOT NULL,
+ tva_tx double(6,3) DEFAULT 0 NOT NULL,
+ fk_user integer NOT NULL,
fk_facture integer,
fk_facture_source integer,
- description varchar(255) NOT NULL
+ description varchar(255) NOT NULL
)type=innodb;