Update commoninvoice.class.php

This commit is contained in:
Laurent Destailleur 2019-12-31 17:06:30 +01:00 committed by GitHub
parent c341ad5e8d
commit b3373e8ba5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -336,7 +336,9 @@ abstract class CommonInvoice extends CommonObject
$retarray[]=array('amount'=>$obj->amount,'type'=>$obj->code, 'date'=>$obj->datep, 'num'=>$obj->num, 'ref'=>$obj->ref); $retarray[]=array('amount'=>$obj->amount,'type'=>$obj->code, 'date'=>$obj->datep, 'num'=>$obj->num, 'ref'=>$obj->ref);
$i++; $i++;
} }
//look for credit notes and discounts
//look for credit notes and discounts and deposits
$sql = 0;
if ($this->element == 'facture' || $this->element == 'invoice') if ($this->element == 'facture' || $this->element == 'invoice')
{ {
$sql = 'SELECT rc.amount_ttc as amount, rc.multicurrency_amount_ttc as multicurrency_amount, rc.datec as date, f.ref as ref, rc.description as type'; $sql = 'SELECT rc.amount_ttc as amount, rc.multicurrency_amount_ttc as multicurrency_amount, rc.datec as date, f.ref as ref, rc.description as type';
@ -352,6 +354,7 @@ abstract class CommonInvoice extends CommonObject
$sql.= ' AND (f.type = 2 OR f.type = 0 OR f.type = 3)'; // Find discount coming from credit note or excess received or deposits (payments from deposits are always null except if FACTURE_DEPOSITS_ARE_JUST_PAYMENTS is set) $sql.= ' AND (f.type = 2 OR f.type = 0 OR f.type = 3)'; // Find discount coming from credit note or excess received or deposits (payments from deposits are always null except if FACTURE_DEPOSITS_ARE_JUST_PAYMENTS is set)
} }
if ($sql) {
$resql=$this->db->query($sql); $resql=$this->db->query($sql);
if ($resql) if ($resql)
{ {
@ -360,12 +363,14 @@ abstract class CommonInvoice extends CommonObject
while ($i < $num) while ($i < $num)
{ {
$obj = $this->db->fetch_object($resql); $obj = $this->db->fetch_object($resql);
if ($multicurrency) { $retarray[]=array('amount'=>$obj->multicurrency_amount,'type'=>$obj->type, 'date'=>$obj->date, 'num'=>'0', 'ref'=>$obj->ref); } if ($multicurrency) {
else { $retarray[]=array('amount'=>$obj->amount,'type'=>$obj->type, 'date'=>$obj->date, 'num'=>'', 'ref'=>$obj->ref); } $retarray[]=array('amount'=>$obj->multicurrency_amount,'type'=>$obj->type, 'date'=>$obj->date, 'num'=>'0', 'ref'=>$obj->ref);
}
else {
$retarray[]=array('amount'=>$obj->amount,'type'=>$obj->type, 'date'=>$obj->date, 'num'=>'', 'ref'=>$obj->ref);
}
$i++; $i++;
} }
$this->db->free($resql);
return $retarray;
} }
else else
{ {
@ -374,6 +379,8 @@ abstract class CommonInvoice extends CommonObject
return array(); return array();
} }
$this->db->free($resql); $this->db->free($resql);
}
return $retarray; return $retarray;
} }
else else