Merge pull request #2638 from atm-maxime/fix_cust_outstanding
Fix cust outstanding
This commit is contained in:
commit
4201cf9f7f
@ -649,13 +649,12 @@ if ($resql)
|
||||
print '<td align="right">'.price($objp->total_ttc).'</td>';
|
||||
print '<td align="right">';
|
||||
$cn=$facturestatic->getSumCreditNotesUsed();
|
||||
if (! empty($objp->am)) print price($objp->am);
|
||||
if (! empty($objp->am) && ! empty($cn)) print '+';
|
||||
if (! empty($cn)) print price($cn);
|
||||
$dep=$facturestatic->getSumDepositsUsed();
|
||||
print price($objp->am + $cn + $dep);
|
||||
print '</td>';
|
||||
|
||||
// Remain to receive
|
||||
print '<td align="right">'.((! empty($objp->am) || ! empty($cn))?price($objp->total_ttc-$objp->am-$cn):' ').'</td>';
|
||||
print '<td align="right">'.price($objp->total_ttc-$objp->am-$cn-$dep).'</td>';
|
||||
|
||||
// Status of invoice
|
||||
print '<td align="right" class="nowrap">';
|
||||
@ -685,7 +684,7 @@ if ($resql)
|
||||
$total_ht+=$objp->total_ht;
|
||||
$total_tva+=($objp->total_tva + $tx1 + $tx2 + $revenuestamp);
|
||||
$total_ttc+=$objp->total_ttc;
|
||||
$total_paid+=$objp->am + $cn;
|
||||
$total_paid+=$objp->am + $cn + $dep;
|
||||
|
||||
$i++;
|
||||
}
|
||||
|
||||
@ -3091,7 +3091,7 @@ class Societe extends CommonObject
|
||||
$alreadypayed=price2num($paiement + $creditnotes + $deposits,'MT');
|
||||
$remaintopay=price2num($invoice->total_ttc - $paiement - $creditnotes - $deposits,'MT');
|
||||
*/
|
||||
$sql = "SELECT sum(total) as amount FROM ".MAIN_DB_PREFIX."facture as f";
|
||||
$sql = "SELECT rowid, total_ttc FROM ".MAIN_DB_PREFIX."facture as f";
|
||||
$sql .= " WHERE fk_soc = ". $this->id;
|
||||
$sql .= " AND paye = 0";
|
||||
$sql .= " AND fk_statut <> 0"; // Not a draft
|
||||
@ -3102,8 +3102,17 @@ class Societe extends CommonObject
|
||||
$resql=$this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$obj=$this->db->fetch_object($resql);
|
||||
return ($obj->amount);
|
||||
$outstandingBill = 0;
|
||||
$facturestatic=new Facture($this->db);
|
||||
while($obj=$this->db->fetch_object($resql)) {
|
||||
$facturestatic->id=$obj->rowid;
|
||||
$paiement = $facturestatic->getSommePaiement();
|
||||
$creditnotes = $facturestatic->getSumCreditNotesUsed();
|
||||
$deposits = $facturestatic->getSumDepositsUsed();
|
||||
|
||||
$outstandingBill+= $obj->total_ttc - $paiement - $creditnotes - $deposits;
|
||||
}
|
||||
return $outstandingBill;
|
||||
}
|
||||
else
|
||||
return 0;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user