Fix: on déduit les paiements déjà effectués des factures
This commit is contained in:
parent
eb74c83cda
commit
4acce0664c
@ -169,6 +169,7 @@ if ($_REQUEST["account"] || $_REQUEST["ref"])
|
|||||||
$i = 0;
|
$i = 0;
|
||||||
while ($i < $num)
|
while ($i < $num)
|
||||||
{
|
{
|
||||||
|
$paiement = '';
|
||||||
$var=!$var;
|
$var=!$var;
|
||||||
$obj = $db->fetch_object($result);
|
$obj = $db->fetch_object($result);
|
||||||
|
|
||||||
@ -181,6 +182,17 @@ if ($_REQUEST["account"] || $_REQUEST["ref"])
|
|||||||
$facturefournstatic->id=$obj->facid;
|
$facturefournstatic->id=$obj->facid;
|
||||||
$facturefournstatic->type=$obj->type;
|
$facturefournstatic->type=$obj->type;
|
||||||
$facture = $facturefournstatic->getNomUrl(1,'');
|
$facture = $facturefournstatic->getNomUrl(1,'');
|
||||||
|
|
||||||
|
// On recherche les paiements deja effectue pour les deduires
|
||||||
|
$sqlp = "SELECT sum(amount) as paiement";
|
||||||
|
$sqlp.= " FROM ".MAIN_DB_PREFIX.'paiementfourn_facturefourn';
|
||||||
|
$sqlp.= " WHERE fk_facturefourn = ".$obj->facid;
|
||||||
|
$resql = $db->query($sqlp);
|
||||||
|
if ($resql)
|
||||||
|
{
|
||||||
|
$objp = $db->fetch_object($resql);
|
||||||
|
if ($objp) $paiement = $objp->paiement;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -188,22 +200,39 @@ if ($_REQUEST["account"] || $_REQUEST["ref"])
|
|||||||
$facturestatic->id=$obj->facid;
|
$facturestatic->id=$obj->facid;
|
||||||
$facturestatic->type=$obj->type;
|
$facturestatic->type=$obj->type;
|
||||||
$facture = $facturestatic->getNomUrl(1,'');
|
$facture = $facturestatic->getNomUrl(1,'');
|
||||||
|
|
||||||
|
// On recherche les paiements deja effectue pour les deduires
|
||||||
|
$sqlp = "SELECT sum(amount) as paiement";
|
||||||
|
$sqlp.= " FROM ".MAIN_DB_PREFIX.'paiement_facture';
|
||||||
|
$sqlp.= " WHERE fk_facture = ".$obj->facid;
|
||||||
|
$resql = $db->query($sqlp);
|
||||||
|
if ($resql)
|
||||||
|
{
|
||||||
|
$objp = $db->fetch_object($resql);
|
||||||
|
if ($objp) $paiement = $objp->paiement;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$solde += $obj->total_ttc;
|
$total_ttc = $obj->total_ttc;
|
||||||
|
if ($paiement) $total_ttc = $obj->total_ttc - $paiement;
|
||||||
|
$solde += $total_ttc;
|
||||||
|
|
||||||
print "<tr $bc[$var]>";
|
print "<tr $bc[$var]>";
|
||||||
print "<td>".$facture."</td>";
|
print "<td>".$facture."</td>";
|
||||||
print "<td>".$societestatic->getNomUrl(0,'',16)."</td>";
|
print "<td>".$societestatic->getNomUrl(0,'',16)."</td>";
|
||||||
print "<td>".dolibarr_print_date($obj->dlr,"day")."</td>";
|
print "<td>".dolibarr_print_date($obj->dlr,"day")."</td>";
|
||||||
if ($obj->total_ttc < 0) { print "<td align=\"right\">".price($obj->total_ttc)."</td><td> </td>"; };
|
if ($obj->total_ttc < 0) { print "<td align=\"right\">".price($total_ttc)."</td><td> </td>"; };
|
||||||
if ($obj->total_ttc >= 0) { print "<td> </td><td align=\"right\">".price($obj->total_ttc)."</td>"; };
|
if ($obj->total_ttc >= 0) { print "<td> </td><td align=\"right\">".price($total_ttc)."</td>"; };
|
||||||
print "<td align=\"right\">".price($solde)."</td>";
|
print "<td align=\"right\">".price($solde)."</td>";
|
||||||
print "</tr>";
|
print "</tr>";
|
||||||
$i++;
|
$i++;
|
||||||
}
|
}
|
||||||
$db->free($result);
|
$db->free($result);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
dolibarr_print_error($db);
|
||||||
|
}
|
||||||
|
|
||||||
print "</table>";
|
print "</table>";
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user