Suite gestion des arrondis sur les montants.
Fix: Pb du update sur vieilles version mysql
This commit is contained in:
parent
7ae57dda4e
commit
adf61a88c9
@ -297,7 +297,7 @@ if ($socid > 0)
|
||||
print '<td colspan="3">';
|
||||
$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 '</td>';
|
||||
print '</tr>';
|
||||
|
||||
@ -232,7 +232,7 @@ if ($_socid > 0)
|
||||
}
|
||||
print '</td>';
|
||||
print '<td align="right">'.price($obj->amount_ht).'</td>';
|
||||
print '<td align="right">'.price($obj->tva_tx).'%</td>';
|
||||
print '<td align="right">'.price2num($obj->tva_tx,'MU').'%</td>';
|
||||
print '<td align="right">'.price($obj->amount_ttc).'</td>';
|
||||
print '<td align="center">';
|
||||
print '<a href="'.DOL_URL_ROOT.'/user/fiche.php?id='.$obj->user_id.'">'.img_object($langs->trans("ShowUser"),'user').' '.$obj->login;
|
||||
@ -311,7 +311,7 @@ if ($_socid > 0)
|
||||
print '</td>';
|
||||
print '<td align="left"><a href="'.DOL_URL_ROOT.'/compta/facture.php?facid='.$obj->rowid.'">'.img_object($langs->trans("ShowBill"),'bill').' '.$obj->facnumber.'</a></td>';
|
||||
print '<td align="right">'.price($obj->amount_ht).'</td>';
|
||||
print '<td align="right">'.price($obj->tva_tx).'%</td>';
|
||||
print '<td align="right">'.price2num($obj->tva_tx,'MU').'%</td>';
|
||||
print '<td align="right">'.price($obj->amount_ttc).'</td>';
|
||||
print '<td align="center">';
|
||||
print '<a href="'.DOL_URL_ROOT.'/user/fiche.php?id='.$obj->user_id.'">'.img_object($langs->trans("ShowUser"),'user').' '.$obj->login;
|
||||
|
||||
@ -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 '<br>';
|
||||
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").'.';
|
||||
|
||||
@ -189,7 +189,7 @@ if ($socid > 0)
|
||||
print '<a href="'.DOL_URL_ROOT.'/comm/remise.php?id='.$societe->id.'">'.img_edit($langs->trans("Modify")).'</a>';
|
||||
}
|
||||
print '</td></tr></table>';
|
||||
print '</td><td colspan="3">'.($societe->remise_client?$societe->remise_client.'%':$langs->trans("DiscountNone")).'</td>';
|
||||
print '</td><td colspan="3">'.($societe->remise_client?price2num($societe->remise_client,'MT').'%':$langs->trans("DiscountNone")).'</td>';
|
||||
print '</tr>';
|
||||
|
||||
// Réductions (Remises-Ristournes-Rabbais)
|
||||
@ -207,7 +207,7 @@ if ($socid > 0)
|
||||
print '<td colspan="3">';
|
||||
$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 '</td>';
|
||||
print '</tr>';
|
||||
|
||||
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@ -706,11 +706,11 @@ class Form
|
||||
|
||||
if ($selected > 0 && $selected == $obj->rowid)
|
||||
{
|
||||
print '<option value="'.$obj->rowid.'" selected="true">'.$desc.' ('.$obj->amount_ht.' '.$langs->trans("Currency".$conf->monnaie).')'.'</option>';
|
||||
print '<option value="'.$obj->rowid.'" selected="true">'.$desc.' ('.price($obj->amount_ht).' '.$langs->trans("HT").' - '.price($obj->amount_ttc).' '.$langs->trans("TTC").')</option>';
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<option value="'.$obj->rowid.'">'.$desc.' ('.$obj->amount_ht.' '.$langs->trans("Currency".$conf->monnaie).')'.'</option>';
|
||||
print '<option value="'.$obj->rowid.'">'.$desc.' ('.price($obj->amount_ht).' '.$langs->trans("HT").' - '.price($obj->amount_ttc).' '.$langs->trans("TTC").')</option>';
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
@ -2039,7 +2039,7 @@ class Form
|
||||
print '<input type="hidden" name="action" value="setabsolutediscount">';
|
||||
print '<table class="nobordernopadding" cellpadding="0" cellspacing="0">';
|
||||
print '<tr><td>';
|
||||
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 '</td>';
|
||||
@ -2051,7 +2051,9 @@ class Form
|
||||
if ($selected)
|
||||
{
|
||||
print $selected;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
print "0";
|
||||
}
|
||||
}
|
||||
|
||||
@ -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)
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user