Fix: Corrige quelques problmes avec factures de remplacement
This commit is contained in:
parent
74608799f7
commit
c533227062
@ -242,9 +242,10 @@ if ($socid > 0)
|
||||
|
||||
print '<table class="noborder" width="100%">';
|
||||
|
||||
$sql = "SELECT s.nom, s.idp, f.rowid as facid, f.facnumber, f.amount, f.total, f.total_ttc,";
|
||||
$sql.= " ".$db->pdate("f.datef")." as df, f.paye as paye, f.fk_statut as statut";
|
||||
$sql.= ' ,sum(pf.amount) as am';
|
||||
$sql = 'SELECT f.rowid as facid, f.facnumber, f.type, f.amount, f.total, f.total_ttc,';
|
||||
$sql.= ' '.$db->pdate("f.datef").' as df, f.paye as paye, f.fk_statut as statut,';
|
||||
$sql.= ' s.nom, s.idp,';
|
||||
$sql.= ' sum(pf.amount) as am';
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture as f";
|
||||
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'paiement_facture as pf ON f.rowid=pf.fk_facture';
|
||||
$sql.= " WHERE f.fk_soc = s.idp AND s.idp = ".$societe->id;
|
||||
@ -270,7 +271,12 @@ if ($socid > 0)
|
||||
$objp = $db->fetch_object($resql);
|
||||
$var=!$var;
|
||||
print "<tr $bc[$var]>";
|
||||
print "<td><a href=\"../compta/facture.php?facid=$objp->facid\">".img_object($langs->trans("ShowBill"),"bill")." ".$objp->facnumber."</a></td>\n";
|
||||
print '<td>';
|
||||
$facturestatic->id=$objp->facid;
|
||||
$facturestatic->ref=$objp->facnumber;
|
||||
$facturestatic->type=$objp->type;
|
||||
print $facturestatic->getNomUrl(1);
|
||||
print '</td>';
|
||||
if ($objp->df > 0)
|
||||
{
|
||||
print "<td align=\"right\">".dolibarr_print_date($objp->df)."</td>\n";
|
||||
|
||||
@ -1012,7 +1012,7 @@ class Facture extends CommonObject
|
||||
}
|
||||
|
||||
// Controle que facture source non deja remplacee par une autre
|
||||
$idreplacement=$facreplaced->getIdReplacingInvoice();
|
||||
$idreplacement=$facreplaced->getIdReplacingInvoice('validated');
|
||||
if ($idreplacement && $idreplacement != $rowid)
|
||||
{
|
||||
$facreplacement=new Facture($this->db);
|
||||
@ -1791,14 +1791,20 @@ class Facture extends CommonObject
|
||||
|
||||
/**
|
||||
* \brief Renvoie l'id de la facture qui la remplace
|
||||
* \return int <0 si ko, 0 si aucune facture ne remplace, id facture sinon
|
||||
* \param option filtre sur statut ('', 'validated', ...)
|
||||
* \return int <0 si ko, 0 si aucune facture ne remplace, id facture sinon
|
||||
*/
|
||||
function getIdReplacingInvoice()
|
||||
function getIdReplacingInvoice($option='')
|
||||
{
|
||||
$sql = 'SELECT rowid';
|
||||
$sql.= ' FROM '.MAIN_DB_PREFIX.'facture';
|
||||
$sql.= ' WHERE fk_facture_source = '.$this->id;
|
||||
$sql.= ' AND type < 2';
|
||||
if ($option == 'validated') $sql.= ' AND fk_statut = 1';
|
||||
$sql.= ' ORDER BY fk_statut DESC'; // Au cas ou base corrompu et qu'il y a une
|
||||
// facture de remplacement validee et une autre non
|
||||
// on donne priorité à la validée. Ne devrait pas arriver
|
||||
|
||||
$resql=$this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
|
||||
Loading…
Reference in New Issue
Block a user