FIX - hasDelay for retained warranty
This commit is contained in:
parent
03ee488d5f
commit
02f268ea4e
@ -4481,15 +4481,40 @@ class Facture extends CommonInvoice
|
|||||||
// Paid invoices have status STATUS_CLOSED
|
// Paid invoices have status STATUS_CLOSED
|
||||||
if ($this->statut != Facture::STATUS_VALIDATED) return false;
|
if ($this->statut != Facture::STATUS_VALIDATED) return false;
|
||||||
|
|
||||||
return $this->date_lim_reglement < ($now - $conf->facture->client->warning_delay);
|
$hasDelay = $this->date_lim_reglement < ($now - $conf->facture->client->warning_delay);
|
||||||
|
if($hasDelay && !empty($this->retained_warranty) && !empty($this->retained_warranty_date_limit))
|
||||||
|
{
|
||||||
|
$totalpaye = $this->getSommePaiement();
|
||||||
|
$totalpaye = floatval($totalpaye);
|
||||||
|
$RetainedWarrantyAmount = $this->getRetainedWarrantyAmount();
|
||||||
|
if($totalpaye >= 0 && $RetainedWarrantyAmount>= 0)
|
||||||
|
{
|
||||||
|
if( ($totalpaye < $this->total_ttc - $RetainedWarrantyAmount) && $this->date_lim_reglement < ($now - $conf->facture->client->warning_delay) )
|
||||||
|
{
|
||||||
|
$hasDelay = 1;
|
||||||
|
}
|
||||||
|
elseif($totalpaye < $this->total_ttc && $this->retained_warranty_date_limit < ($now - $conf->facture->client->warning_delay) )
|
||||||
|
{
|
||||||
|
$hasDelay = 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$hasDelay = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $hasDelay;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @param int $rounding Minimum number of decimal to show. If 0, no change, if -1, we use min($conf->global->MAIN_MAX_DECIMALS_UNIT,$conf->global->MAIN_MAX_DECIMALS_TOT)
|
||||||
* @return number or -1 if not available
|
* @return number or -1 if not available
|
||||||
*/
|
*/
|
||||||
public function getRetainedWarrantyAmount()
|
public function getRetainedWarrantyAmount($rounding = -1)
|
||||||
{
|
{
|
||||||
|
global $conf;
|
||||||
if (empty($this->retained_warranty)) {
|
if (empty($this->retained_warranty)) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -4533,6 +4558,11 @@ class Facture extends CommonInvoice
|
|||||||
$retainedWarrantyAmount = $this->total_ttc * $this->retained_warranty / 100;
|
$retainedWarrantyAmount = $this->total_ttc * $this->retained_warranty / 100;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($rounding < 0){
|
||||||
|
$rounding=min($conf->global->MAIN_MAX_DECIMALS_UNIT,$conf->global->MAIN_MAX_DECIMALS_TOT);
|
||||||
|
return round($retainedWarrantyAmount, 2);
|
||||||
|
}
|
||||||
|
|
||||||
return $retainedWarrantyAmount;
|
return $retainedWarrantyAmount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user