diff --git a/htdocs/contrat/contrat.class.php b/htdocs/contrat/contrat.class.php
index 16165370341..fb9d0f24f61 100644
--- a/htdocs/contrat/contrat.class.php
+++ b/htdocs/contrat/contrat.class.php
@@ -1198,6 +1198,9 @@ class Contrat extends CommonObject
class ContratLigne
{
+ var $db;
+ var $error;
+
var $id;
var $desc;
var $libelle;
@@ -1216,9 +1219,16 @@ class ContratLigne
var $date_fin_prevue;
var $date_fin_reel;
- function ContratLigne()
+
+ /**
+ * \brief Constructeur d'objets ligne de contrat
+ * \param DB handler d'accès base de donnée
+ */
+ function ContratLigne($DB)
{
+ $this->db= $DB;
}
+
function is_activated()
{
@@ -1283,6 +1293,38 @@ class ContratLigne
}
}
+ /**
+ * \brief Mise a jour en base des champs total_xxx de ligne
+ * \remarks Utilisé par migration
+ * \return int <0 si ko, >0 si ok
+ */
+ function update_total()
+ {
+ $this->db->begin();
+
+ // Mise a jour ligne en base
+ $sql = "UPDATE ".MAIN_DB_PREFIX."contratdet SET";
+ $sql.= " total_ht=".price2num($this->total_ht,'MT')."";
+ $sql.= ",total_tva=".price2num($this->total_tva,'MT')."";
+ $sql.= ",total_ttc=".price2num($this->total_ttc,'MT')."";
+ $sql.= " WHERE rowid = ".$this->rowid;
+
+ dolibarr_syslog("ContratLigne::update_total sql=$sql");
+
+ $resql=$this->db->query($sql);
+ if ($resql)
+ {
+ $this->db->commit();
+ return 1;
+ }
+ else
+ {
+ $this->error=$this->db->error();
+ dolibarr_syslog("ContratLigne::update_total Error ".$this->error);
+ $this->db->rollback();
+ return -2;
+ }
+ }
}
diff --git a/htdocs/contrat/fiche.php b/htdocs/contrat/fiche.php
index caabcbd2890..7e06fadeccb 100644
--- a/htdocs/contrat/fiche.php
+++ b/htdocs/contrat/fiche.php
@@ -184,7 +184,8 @@ if ($_POST["action"] == 'addligne' && $user->rights->contrat->creer)
$_POST["p_idprod"],
$_POST["premise"],
$date_start,
- $date_end
+ $date_end,
+ 'HT'
);
}
elseif ($_POST["mode"]=='libre')
@@ -197,7 +198,8 @@ if ($_POST["action"] == 'addligne' && $user->rights->contrat->creer)
0,
$_POST["premise"],
$date_start_sl,
- $date_end_sl
+ $date_end_sl,
+ 'HT'
);
}
diff --git a/htdocs/install/upgrade2.php b/htdocs/install/upgrade2.php
index 4e98f8ba6e6..322c2557904 100644
--- a/htdocs/install/upgrade2.php
+++ b/htdocs/install/upgrade2.php
@@ -34,6 +34,7 @@ require_once($dolibarr_main_document_root . "/lib/databases/".$dolibarr_main_db_
require_once($dolibarr_main_document_root . "/conf/conf.class.php");
include_once('../facture.class.php');
include_once('../propal.class.php');
+include_once('../contrat/contrat.class.php');
include_once('../commande/commande.class.php');
include_once('../lib/price.lib.php');
@@ -158,8 +159,6 @@ if (isset($_POST['action']) && $_POST['action'] == 'upgrade')
migrate_contracts_date3($db,$langs,$conf);
- migrate_fichinter_date1($db,$langs,$conf);
-
migrate_contracts_open($db,$langs,$conf);
migrate_modeles($db,$langs,$conf);
@@ -170,6 +169,8 @@ if (isset($_POST['action']) && $_POST['action'] == 'upgrade')
migrate_price_facture($db,$langs,$conf);
+ migrate_price_contrat($db,$langs,$conf);
+
migrate_paiementfourn_facturefourn($db,$langs,$conf);
migrate_delete_old_files($db,$langs,$conf);
@@ -714,34 +715,6 @@ function migrate_contracts_date3($db,$langs,$conf)
print '';
}
-/*
- * Mise a jour des dates tms de fiche d'intervention
- */
-function migrate_fichinter_date1($db,$langs,$conf)
-{
- print '
';
-
- print ' ';
- print ''.$langs->trans('MigrationFichinterIncoherentTmsDateUpdate')." \n";
-
- $sql1="update llx_fichinter set tms=datec where tms < datec";
- $resql1 = $db->query($sql1);
- if (! $resql1) dolibarr_print_error($db);
- if ($db->affected_rows() > 0)
- print $langs->trans('MigrationFchinterIncoherentTmsDateUpdateSuccess')." \n";
- else
- print $langs->trans('MigrationFichinterIncoherentTmsDateNothingToUpdate')." \n";
- $sql2="update llx_fichinter set tms=date_valid where tms < date_valid";
- $resql2 = $db->query($sql2);
- if (! $resql2) dolibarr_print_error($db);
- if ($db->affected_rows() > 0)
- print $langs->trans('MigrationFchinterIncoherentTmsDateUpdateSuccess')." \n";
- else
- print $langs->trans('MigrationFichinterIncoherentTmsDateNothingToUpdate')." \n";
-
- print ' |
';
-}
-
/*
* Reouverture des contrats qui ont au moins une ligne non fermée
@@ -891,104 +864,101 @@ function migrate_paiementfourn_facturefourn($db,$langs,$conf)
*/
function migrate_price_facture($db,$langs,$conf)
{
- if ($conf->facture->enabled)
- {
- $db->begin();
+ $db->begin();
- dolibarr_install_syslog("upgrade2: Upgrade data for invoice");
+ dolibarr_install_syslog("upgrade2: Upgrade data for invoice");
- print '| ';
+ print ' |
';
- print ' ';
- print ''.$langs->trans('MigrationInvoice')." \n";
-
- // Liste des lignes facture non a jour
- $sql = "SELECT fd.rowid, fd.qty, fd.subprice, fd.remise_percent, fd.tva_taux, ";
- $sql.= " f.rowid as facid, f.remise_percent as remise_percent_global";
- $sql.= " FROM ".MAIN_DB_PREFIX."facturedet as fd, ".MAIN_DB_PREFIX."facture as f";
- $sql.= " WHERE fd.fk_facture = f.rowid";
- $sql.= " AND ((fd.total_ttc = 0 AND fd.remise_percent != 100) or fd.total_ttc IS NULL)";
- $resql=$db->query($sql);
- if ($resql)
- {
- $num = $db->num_rows($resql);
- $i = 0;
- if ($num)
- {
- while ($i < $num)
- {
- $obj = $db->fetch_object($resql);
-
- $rowid = $obj->rowid;
- $qty = $obj->qty;
- $pu = $obj->subprice;
- $txtva = $obj->tva_taux;
- $remise_percent = $obj->remise_percent;
- $remise_percent_global = $obj->remise_percent_global;
-
- // On met a jour les 3 nouveaux champs
- $facligne= new FactureLigne($db);
- $facligne->fetch($rowid);
-
- $result=calcul_price_total($qty,$pu,$remise_percent,$txtva,$remise_percent_global,'HT');
- $total_ht = $result[0];
- $total_tva = $result[1];
- $total_ttc = $result[2];
-
- $facligne->total_ht = $total_ht;
- $facligne->total_tva = $total_tva;
- $facligne->total_ttc = $total_ttc;
-
- dolibarr_install_syslog("upgrade2: Line $rowid: facid=$obj->facid pu=$pu qty=$qty tva_taux=$txtva remise_percent=$remise_percent remise_global=$remise_percent_global -> $total_ht, $total_tva, $total_ttc");
- print ". ";
- $facligne->update_total();
-
-
- /* On touche pas a facture mere
- $facture = new Facture($db);
- $facture->id=$obj->facid;
+ print ' ';
+ print ''.$langs->trans('MigrationInvoice')." \n";
- if ( $facture->fetch($facture->id) >= 0)
+ // Liste des lignes facture non a jour
+ $sql = "SELECT fd.rowid, fd.qty, fd.subprice, fd.remise_percent, fd.tva_taux, ";
+ $sql.= " f.rowid as facid, f.remise_percent as remise_percent_global";
+ $sql.= " FROM ".MAIN_DB_PREFIX."facturedet as fd, ".MAIN_DB_PREFIX."facture as f";
+ $sql.= " WHERE fd.fk_facture = f.rowid";
+ $sql.= " AND ((fd.total_ttc = 0 AND fd.remise_percent != 100) or fd.total_ttc IS NULL)";
+ $resql=$db->query($sql);
+ if ($resql)
+ {
+ $num = $db->num_rows($resql);
+ $i = 0;
+ if ($num)
+ {
+ while ($i < $num)
+ {
+ $obj = $db->fetch_object($resql);
+
+ $rowid = $obj->rowid;
+ $qty = $obj->qty;
+ $pu = $obj->subprice;
+ $txtva = $obj->tva_taux;
+ $remise_percent = $obj->remise_percent;
+ $remise_percent_global = $obj->remise_percent_global;
+
+ // On met a jour les 3 nouveaux champs
+ $facligne= new FactureLigne($db);
+ $facligne->fetch($rowid);
+
+ $result=calcul_price_total($qty,$pu,$remise_percent,$txtva,$remise_percent_global,'HT');
+ $total_ht = $result[0];
+ $total_tva = $result[1];
+ $total_ttc = $result[2];
+
+ $facligne->total_ht = $total_ht;
+ $facligne->total_tva = $total_tva;
+ $facligne->total_ttc = $total_ttc;
+
+ dolibarr_install_syslog("upgrade2: Line $rowid: facid=$obj->facid pu=$pu qty=$qty tva_taux=$txtva remise_percent=$remise_percent remise_global=$remise_percent_global -> $total_ht, $total_tva, $total_ttc");
+ print ". ";
+ $facligne->update_total();
+
+
+ /* On touche pas a facture mere
+ $facture = new Facture($db);
+ $facture->id=$obj->facid;
+
+ if ( $facture->fetch($facture->id) >= 0)
+ {
+ if ( $facture->update_price($facture->id) > 0 )
{
- if ( $facture->update_price($facture->id) > 0 )
- {
- print ". ";
- }
- else
- {
- print "Error id=".$facture->id;
- $err++;
- }
+ print ". ";
}
else
{
- print "Error #3";
+ print "Error id=".$facture->id;
$err++;
}
- */
- $i++;
}
+ else
+ {
+ print "Error #3";
+ $err++;
+ }
+ */
+ $i++;
}
- else
- {
- print $langs->trans("AlreadyDone");
- }
- $db->free();
-
- $db->rollback();
}
else
{
- print "Error #1 ".$db->error();
- $err++;
-
- $db->rollback();
+ print $langs->trans("AlreadyDone");
}
+ $db->free($resql);
- print '
';
-
- print ' |
';
+ $db->commit();
}
+ else
+ {
+ print "Error #1 ".$db->error();
+ $err++;
+
+ $db->rollback();
+ }
+
+ print '
';
+
+ print '';
}
@@ -997,104 +967,206 @@ function migrate_price_facture($db,$langs,$conf)
*/
function migrate_price_propal($db,$langs,$conf)
{
- if ($conf->propal->enabled)
- {
- $db->begin();
+ $db->begin();
- dolibarr_install_syslog("upgrade2: Upgrade data for propal");
+ dolibarr_install_syslog("upgrade2: Upgrade data for propal");
- print '| ';
+ print ' |
';
- print ' ';
- print ''.$langs->trans('MigrationProposal')." \n";
+ print ' ';
+ print ''.$langs->trans('MigrationProposal')." \n";
- // Liste des lignes propal non a jour
- $sql = "SELECT pd.rowid, pd.qty, pd.subprice, pd.remise_percent, pd.tva_tx as tva_taux, ";
- $sql.= " p.rowid as propalid, p.remise_percent as remise_percent_global";
- $sql.= " FROM ".MAIN_DB_PREFIX."propaldet as pd, ".MAIN_DB_PREFIX."propal as p";
- $sql.= " WHERE pd.fk_propal = p.rowid";
- $sql.= " AND ((pd.total_ttc = 0 AND pd.remise_percent != 100) or pd.total_ttc IS NULL)";
- $resql=$db->query($sql);
- if ($resql)
+ // Liste des lignes propal non a jour
+ $sql = "SELECT pd.rowid, pd.qty, pd.subprice, pd.remise_percent, pd.tva_tx as tva_taux, ";
+ $sql.= " p.rowid as propalid, p.remise_percent as remise_percent_global";
+ $sql.= " FROM ".MAIN_DB_PREFIX."propaldet as pd, ".MAIN_DB_PREFIX."propal as p";
+ $sql.= " WHERE pd.fk_propal = p.rowid";
+ $sql.= " AND ((pd.total_ttc = 0 AND pd.remise_percent != 100) or pd.total_ttc IS NULL)";
+ $resql=$db->query($sql);
+ if ($resql)
+ {
+ $num = $db->num_rows($resql);
+ $i = 0;
+ if ($num)
{
- $num = $db->num_rows($resql);
- $i = 0;
- if ($num)
+ while ($i < $num)
{
- while ($i < $num)
+ $obj = $db->fetch_object($resql);
+
+ $rowid = $obj->rowid;
+ $qty = $obj->qty;
+ $pu = $obj->subprice;
+ $txtva = $obj->tva_taux;
+ $remise_percent = $obj->remise_percent;
+ $remise_percent_global = $obj->remise_percent_global;
+
+ // On met a jour les 3 nouveaux champs
+ $propalligne= new PropaleLigne($db);
+ $propalligne->fetch($rowid);
+
+ $result=calcul_price_total($qty,$pu,$remise_percent,$txtva,$remise_percent_global,'HT');
+ $total_ht = $result[0];
+ $total_tva = $result[1];
+ $total_ttc = $result[2];
+
+ $propalligne->total_ht = $total_ht;
+ $propalligne->total_tva = $total_tva;
+ $propalligne->total_ttc = $total_ttc;
+
+ dolibarr_install_syslog("upgrade2: Line $rowid: propalid=$obj->rowid pu=$pu qty=$qty tva_taux=$txtva remise_percent=$remise_percent remise_global=$remise_percent_global -> $total_ht, $total_tva, $total_ttc");
+ print ". ";
+ $propalligne->update_total($rowid);
+
+
+ /* On touche pas a propal mere
+ $propal = new Propal($db);
+ $propal->id=$obj->rowid;
+ if ( $propal->fetch($propal->id) >= 0 )
{
- $obj = $db->fetch_object($resql);
-
- $rowid = $obj->rowid;
- $qty = $obj->qty;
- $pu = $obj->subprice;
- $txtva = $obj->tva_taux;
- $remise_percent = $obj->remise_percent;
- $remise_percent_global = $obj->remise_percent_global;
-
- // On met a jour les 3 nouveaux champs
- $propalligne= new PropaleLigne($db);
- $propalligne->fetch($rowid);
-
- $result=calcul_price_total($qty,$pu,$remise_percent,$txtva,$remise_percent_global,'HT');
- $total_ht = $result[0];
- $total_tva = $result[1];
- $total_ttc = $result[2];
-
- $propalligne->total_ht = $total_ht;
- $propalligne->total_tva = $total_tva;
- $propalligne->total_ttc = $total_ttc;
-
- dolibarr_install_syslog("upgrade2: Line $rowid: propalid=$obj->rowid pu=$pu qty=$qty tva_taux=$txtva remise_percent=$remise_percent remise_global=$remise_percent_global -> $total_ht, $total_tva, $total_ttc");
- print ". ";
- $propalligne->update_total($rowid);
-
-
- /* On touche pas a propal mere
- $propal = new Propal($db);
- $propal->id=$obj->rowid;
- if ( $propal->fetch($propal->id) >= 0 )
+ if ( $propal->update_price($propal->id) > 0 )
{
- if ( $propal->update_price($propal->id) > 0 )
- {
- print ". ";
- }
- else
- {
- print "Error id=".$propal->id;
- $err++;
- }
+ print ". ";
}
else
{
- print "Error #3";
+ print "Error id=".$propal->id;
$err++;
}
- */
- $i++;
}
+ else
+ {
+ print "Error #3";
+ $err++;
+ }
+ */
+ $i++;
}
- else
- {
- print $langs->trans("AlreadyDone");
- }
-
- $db->free();
-
- $db->rollback();
}
else
{
- print "Error #1 ".$db->error();
- $err++;
-
- $db->rollback();
+ print $langs->trans("AlreadyDone");
}
+
+ $db->free($resql);
- print ' ';
-
- print ' |
';
+ $db->commit();
}
+ else
+ {
+ print "Error #1 ".$db->error();
+ $err++;
+
+ $db->rollback();
+ }
+
+ print '
';
+
+ print '';
+}
+
+
+
+/*
+ * Mise a jour des totaux lignes de propal
+ */
+function migrate_price_contrat($db,$langs,$conf)
+{
+ $db->begin();
+
+ dolibarr_install_syslog("upgrade2: Upgrade data for contracts");
+
+ print '';
+
+ print ' ';
+ print ''.$langs->trans('MigrationContract')." \n";
+
+ // Liste des lignes contrat non a jour
+ $sql = "SELECT cd.rowid, cd.qty, cd.subprice, cd.remise_percent, cd.tva_tx as tva_taux, ";
+ $sql.= " c.rowid as contratid";
+ $sql.= " FROM ".MAIN_DB_PREFIX."contratdet as cd, ".MAIN_DB_PREFIX."contrat as c";
+ $sql.= " WHERE cd.fk_contrat = c.rowid";
+ $sql.= " AND ((cd.total_ttc = 0 AND cd.remise_percent != 100 AND cd.subprice > 0) or cd.total_ttc IS NULL)";
+ $resql=$db->query($sql);
+ if ($resql)
+ {
+ $num = $db->num_rows($resql);
+ $i = 0;
+ if ($num)
+ {
+ while ($i < $num)
+ {
+ $obj = $db->fetch_object($resql);
+
+ $rowid = $obj->rowid;
+ $qty = $obj->qty;
+ $pu = $obj->subprice;
+ $txtva = $obj->tva_taux;
+ $remise_percent = $obj->remise_percent;
+ $remise_percent_global = $obj->remise_percent_global;
+
+ // On met a jour les 3 nouveaux champs
+ $contratligne= new ContratLigne($db);
+ //$contratligne->fetch($rowid); Non requis car le update_total ne met a jour que chp redefinis
+ $contratligne->rowid=$rowid;
+
+ $result=calcul_price_total($qty,$pu,$remise_percent,$txtva,$remise_percent_global,'HT');
+ $total_ht = $result[0];
+ $total_tva = $result[1];
+ $total_ttc = $result[2];
+
+ $contratligne->total_ht = $total_ht;
+ $contratligne->total_tva = $total_tva;
+ $contratligne->total_ttc = $total_ttc;
+
+ dolibarr_install_syslog("upgrade2: Line $rowid: contratdetid=$obj->rowid pu=$pu qty=$qty tva_taux=$txtva remise_percent=$remise_percent remise_global=$remise_percent_global -> $total_ht, $total_tva, $total_ttc");
+ print ". ";
+ $contratligne->update_total($rowid);
+
+
+ /* On touche pas a contrat mere
+ $propal = new Propal($db);
+ $propal->id=$obj->rowid;
+ if ( $propal->fetch($propal->id) >= 0 )
+ {
+ if ( $propal->update_price($propal->id) > 0 )
+ {
+ print ". ";
+ }
+ else
+ {
+ print "Error id=".$propal->id;
+ $err++;
+ }
+ }
+ else
+ {
+ print "Error #3";
+ $err++;
+ }
+ */
+ $i++;
+ }
+ }
+ else
+ {
+ print $langs->trans("AlreadyDone");
+ }
+
+ $db->free($resql);
+
+ $db->commit();
+ }
+ else
+ {
+ print "Error #1 ".$db->error();
+ $err++;
+
+ $db->rollback();
+ }
+
+ print ' ';
+
+ print ' |
';
}
@@ -1103,111 +1175,108 @@ function migrate_price_propal($db,$langs,$conf)
*/
function migrate_price_commande($db,$langs,$conf)
{
- if ($conf->facture->enabled)
- {
- $db->begin();
+ $db->begin();
- dolibarr_install_syslog("upgrade2: Upgrade data for order");
+ dolibarr_install_syslog("upgrade2: Upgrade data for order");
- print '| ';
+ print ' |
';
- print ' ';
- print ''.$langs->trans('MigrationOrder')." \n";
+ print ' ';
+ print ''.$langs->trans('MigrationOrder')." \n";
- // Liste des lignes commande non a jour
- $sql = "SELECT cd.rowid, cd.qty, cd.subprice, cd.remise_percent, cd.tva_tx as tva_taux, ";
- $sql.= " c.rowid as commandeid, c.remise_percent as remise_percent_global";
- $sql.= " FROM ".MAIN_DB_PREFIX."commandedet as cd, ".MAIN_DB_PREFIX."commande as c";
- $sql.= " WHERE cd.fk_commande = c.rowid";
- $sql.= " AND ((cd.total_ttc = 0 AND cd.remise_percent != 100) or cd.total_ttc IS NULL)";
- $resql=$db->query($sql);
- if ($resql)
+ // Liste des lignes commande non a jour
+ $sql = "SELECT cd.rowid, cd.qty, cd.subprice, cd.remise_percent, cd.tva_tx as tva_taux, ";
+ $sql.= " c.rowid as commandeid, c.remise_percent as remise_percent_global";
+ $sql.= " FROM ".MAIN_DB_PREFIX."commandedet as cd, ".MAIN_DB_PREFIX."commande as c";
+ $sql.= " WHERE cd.fk_commande = c.rowid";
+ $sql.= " AND ((cd.total_ttc = 0 AND cd.remise_percent != 100) or cd.total_ttc IS NULL)";
+ $resql=$db->query($sql);
+ if ($resql)
+ {
+ $num = $db->num_rows($resql);
+ $i = 0;
+ if ($num)
{
- $num = $db->num_rows($resql);
- $i = 0;
- if ($num)
+ while ($i < $num)
{
- while ($i < $num)
+ $obj = $db->fetch_object($resql);
+
+ $rowid = $obj->rowid;
+ $qty = $obj->qty;
+ $pu = $obj->subprice;
+ $txtva = $obj->tva_taux;
+ $remise_percent = $obj->remise_percent;
+ $remise_percent_global = $obj->remise_percent_global;
+
+ // On met a jour les 3 nouveaux champs
+ $commandeligne= new CommandeLigne($db);
+ $commandeligne->fetch($rowid);
+
+ $result=calcul_price_total($qty,$pu,$remise_percent,$txtva,$remise_percent_global,'HT');
+ $total_ht = $result[0];
+ $total_tva = $result[1];
+ $total_ttc = $result[2];
+
+ $commandeligne->total_ht = $total_ht;
+ $commandeligne->total_tva = $total_tva;
+ $commandeligne->total_ttc = $total_ttc;
+
+ dolibarr_install_syslog("upgrade2: Line $rowid: commandeid=$obj->rowid pu=$pu qty=$qty tva_taux=$txtva remise_percent=$remise_percent remise_global=$remise_percent_global -> $total_ht, $total_tva, $total_ttc");
+ print ". ";
+ $commandeligne->update_total($rowid);
+
+ /* On touche pas a facture mere
+ $commande = new Commande($db);
+ $commande->id = $obj->rowid;
+ if ( $commande->fetch($commande->id) >= 0 )
{
- $obj = $db->fetch_object($resql);
-
- $rowid = $obj->rowid;
- $qty = $obj->qty;
- $pu = $obj->subprice;
- $txtva = $obj->tva_taux;
- $remise_percent = $obj->remise_percent;
- $remise_percent_global = $obj->remise_percent_global;
-
- // On met a jour les 3 nouveaux champs
- $commandeligne= new CommandeLigne($db);
- $commandeligne->fetch($rowid);
-
- $result=calcul_price_total($qty,$pu,$remise_percent,$txtva,$remise_percent_global,'HT');
- $total_ht = $result[0];
- $total_tva = $result[1];
- $total_ttc = $result[2];
-
- $commandeligne->total_ht = $total_ht;
- $commandeligne->total_tva = $total_tva;
- $commandeligne->total_ttc = $total_ttc;
-
- dolibarr_install_syslog("upgrade2: Line $rowid: commandeid=$obj->rowid pu=$pu qty=$qty tva_taux=$txtva remise_percent=$remise_percent remise_global=$remise_percent_global -> $total_ht, $total_tva, $total_ttc");
- print ". ";
- $commandeligne->update_total($rowid);
-
- /* On touche pas a facture mere
- $commande = new Commande($db);
- $commande->id = $obj->rowid;
- if ( $commande->fetch($commande->id) >= 0 )
+ if ( $commande->update_price($commande->id) > 0 )
{
- if ( $commande->update_price($commande->id) > 0 )
- {
- print ". ";
- }
- else
- {
- print "Error id=".$commande->id;
- $err++;
- }
+ print ". ";
}
else
{
- print "Error #3";
+ print "Error id=".$commande->id;
$err++;
}
- */
- $i++;
}
+ else
+ {
+ print "Error #3";
+ $err++;
+ }
+ */
+ $i++;
}
- else
- {
- print $langs->trans("AlreadyDone");
- }
-
- $db->free();
-
- $sql = "DELETE FROM ".MAIN_DB_PREFIX."commandedet";
- $sql.= " WHERE price = 0 and total_ttc = 0 and total_tva = 0 and total_ht = 0";
- $resql=$db->query($sql);
- if (! $resql)
- {
- dolibarr_print_error($db);
- }
-
- $db->rollback();
}
else
{
- print "Error #1 ".$db->error();
- $err++;
-
- $db->rollback();
+ print $langs->trans("AlreadyDone");
}
- print ' ';
+ $db->free($resql);
- print ' |
';
+ $sql = "DELETE FROM ".MAIN_DB_PREFIX."commandedet";
+ $sql.= " WHERE price = 0 and total_ttc = 0 and total_tva = 0 and total_ht = 0";
+ $resql=$db->query($sql);
+ if (! $resql)
+ {
+ dolibarr_print_error($db);
+ }
+
+ $db->commit();
}
+ else
+ {
+ print "Error #1 ".$db->error();
+ $err++;
+
+ $db->rollback();
+ }
+
+ print '
';
+
+ print '';
}
diff --git a/htdocs/propal.class.php b/htdocs/propal.class.php
index f938523a2e2..c11c48a4a25 100644
--- a/htdocs/propal.class.php
+++ b/htdocs/propal.class.php
@@ -2183,7 +2183,7 @@ class PropaleLigne
*/
function PropaleLigne($DB)
{
- $this->db= $DB ;
+ $this->db= $DB;
}
/**
@@ -2356,7 +2356,8 @@ class PropaleLigne
}
/**
- * \brief Mise a jour en base des champs total_xxx de ligne de propale
+ * \brief Mise a jour en base des champs total_xxx de ligne
+ * \remarks Utilisé par migration
* \return int <0 si ko, >0 si ok
*/
function update_total()
@@ -2365,9 +2366,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,'MT')."";
+ $sql.= ",total_tva=".price2num($this->total_tva,'MT')."";
+ $sql.= ",total_ttc=".price2num($this->total_ttc,'MT')."";
$sql.= " WHERE rowid = ".$this->rowid;
dolibarr_syslog("PropaleLigne::update_total sql=$sql");
diff --git a/mysql/migration/2.1.0-2.2.0.sql b/mysql/migration/2.1.0-2.2.0.sql
index 9df0a753c8c..02c1b527d1b 100644
--- a/mysql/migration/2.1.0-2.2.0.sql
+++ b/mysql/migration/2.1.0-2.2.0.sql
@@ -611,6 +611,12 @@ 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_contratdet MODIFY tva_tx double(6,3);
+ALTER TABLE llx_contratdet MODIFY subprice double(16,8);
+ALTER TABLE llx_contratdet MODIFY total_ht double(16,8);
+ALTER TABLE llx_contratdet MODIFY total_tva double(16,8);
+ALTER TABLE llx_contratdet MODIFY total_ttc double(16,8);
+
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;
@@ -709,3 +715,8 @@ drop table if exists `llx_accountingsystem_det`;
update llx_bank set label='(InitialBankBalance)' where fk_type='SOLD' and label in ('Balance','(Balance)','Solde','(Solde)');
+
+
+update llx_fichinter set tms=datec where tms < datec;
+update llx_fichinter set tms=date_valid where tms < date_valid;
+
diff --git a/mysql/tables/llx_contratdet.sql b/mysql/tables/llx_contratdet.sql
index 6fad904ed5e..e00112c3f23 100644
--- a/mysql/tables/llx_contratdet.sql
+++ b/mysql/tables/llx_contratdet.sql
@@ -32,6 +32,7 @@ create table llx_contratdet
label text, -- libellé du produit
description text,
+ fk_remise_except integer NULL, -- Lien vers table des remises fixes
date_commande datetime,
date_ouverture_prevue datetime,
@@ -39,17 +40,16 @@ create table llx_contratdet
date_fin_validite datetime,
date_cloture datetime,
- tva_tx real DEFAULT 19.6, -- 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_ht 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
+ tva_tx double(6,3) DEFAULT 0 NOT NULL, -- taux tva
+ qty real NOT NULL, -- quantité
+ remise_percent real DEFAULT 0, -- pourcentage de remise
+ subprice double(16,8), -- prix unitaire
+ price_ht real, -- prix final (obsolete)
+ remise real DEFAULT 0, -- montant de la remise (obsolete)
+ total_ht double(16,8) NOT NULL, -- Total HT de la ligne toute quantité et incluant remise ligne et globale
+ total_tva double(16,8) NOT NULL, -- Total TVA de la ligne toute quantité et incluant remise ligne et globale
+ total_ttc double(16,8) NOT NULL, -- Total TTC de la ligne toute quantité et incluant remise ligne et globale
+ info_bits integer DEFAULT 0, -- TVA NPR ou non
fk_user_author integer NOT NULL default 0,
fk_user_ouverture integer,