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">'.price($objp->total_ttc).'</td>';
|
||||||
print '<td align="right">';
|
print '<td align="right">';
|
||||||
$cn=$facturestatic->getSumCreditNotesUsed();
|
$cn=$facturestatic->getSumCreditNotesUsed();
|
||||||
if (! empty($objp->am)) print price($objp->am);
|
$dep=$facturestatic->getSumDepositsUsed();
|
||||||
if (! empty($objp->am) && ! empty($cn)) print '+';
|
print price($objp->am + $cn + $dep);
|
||||||
if (! empty($cn)) print price($cn);
|
|
||||||
print '</td>';
|
print '</td>';
|
||||||
|
|
||||||
// Remain to receive
|
// 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
|
// Status of invoice
|
||||||
print '<td align="right" class="nowrap">';
|
print '<td align="right" class="nowrap">';
|
||||||
@ -685,7 +684,7 @@ if ($resql)
|
|||||||
$total_ht+=$objp->total_ht;
|
$total_ht+=$objp->total_ht;
|
||||||
$total_tva+=($objp->total_tva + $tx1 + $tx2 + $revenuestamp);
|
$total_tva+=($objp->total_tva + $tx1 + $tx2 + $revenuestamp);
|
||||||
$total_ttc+=$objp->total_ttc;
|
$total_ttc+=$objp->total_ttc;
|
||||||
$total_paid+=$objp->am + $cn;
|
$total_paid+=$objp->am + $cn + $dep;
|
||||||
|
|
||||||
$i++;
|
$i++;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -3091,7 +3091,7 @@ class Societe extends CommonObject
|
|||||||
$alreadypayed=price2num($paiement + $creditnotes + $deposits,'MT');
|
$alreadypayed=price2num($paiement + $creditnotes + $deposits,'MT');
|
||||||
$remaintopay=price2num($invoice->total_ttc - $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 .= " WHERE fk_soc = ". $this->id;
|
||||||
$sql .= " AND paye = 0";
|
$sql .= " AND paye = 0";
|
||||||
$sql .= " AND fk_statut <> 0"; // Not a draft
|
$sql .= " AND fk_statut <> 0"; // Not a draft
|
||||||
@ -3102,8 +3102,17 @@ class Societe extends CommonObject
|
|||||||
$resql=$this->db->query($sql);
|
$resql=$this->db->query($sql);
|
||||||
if ($resql)
|
if ($resql)
|
||||||
{
|
{
|
||||||
$obj=$this->db->fetch_object($resql);
|
$outstandingBill = 0;
|
||||||
return ($obj->amount);
|
$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
|
else
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user