Fix : customer outstanding was not calculated properly
This commit is contained in:
parent
e0af2feced
commit
8b307aac56
@ -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