FIX credit note used on list

This commit is contained in:
atm-quentin 2019-02-18 12:28:18 +01:00
parent c0b22e86c2
commit b6deda1111
2 changed files with 27 additions and 0 deletions

View File

@ -2574,6 +2574,27 @@ class FactureFournisseur extends CommonInvoice
return ($this->statut == self::STATUS_VALIDATED) && ($this->date_echeance < ($now - $conf->facture->fournisseur->warning_delay));
}
/**
* Is credit note used
*
* @return bool
*/
public function isCreditNoteUsed()
{
global $db;
$isUsed = false;
$sql = "SELECT fk_invoice_supplier FROM ".MAIN_DB_PREFIX."societe_remise_except WHERE fk_invoice_supplier_source=".$this->id;
$resql = $db->query($sql);
if(!empty($resql)){
$obj = $db->fetch_object($resql);
if(!empty($obj->fk_invoice_supplier))$isUsed=true;
}
return $isUsed;
}
}

View File

@ -833,6 +833,7 @@ if ($resql)
$facturestatic->date_echeance = $db->jdate($obj->datelimite);
$facturestatic->statut = $obj->fk_statut;
$thirdparty->id=$obj->socid;
$thirdparty->name=$obj->name;
$thirdparty->client=$obj->client;
@ -850,6 +851,11 @@ if ($resql)
$totalpay = $paiement + $totalcreditnotes + $totaldeposits;
$remaintopay = $obj->total_ttc - $totalpay;
//If invoice has been converted and the conversion has been used, we dont have remain to pay on invoice
if($facturestatic->type == FactureFournisseur::TYPE_CREDIT_NOTE && $facturestatic->statut == FactureFournisseur::STATUS_CLOSED) {
if($facturestatic->isCreditNoteUsed())$remaintopay=0;
}
print '<tr class="oddeven">';
if (! empty($arrayfields['f.ref']['checked']))
{