fix relative times in budget calculation in export (#3216)
This commit is contained in:
@@ -163,6 +163,8 @@ trait RendererTrait
|
||||
'money' => $project->getBudget(),
|
||||
'time_left' => null,
|
||||
'money_left' => null,
|
||||
'time_left_total' => null,
|
||||
'money_left_total' => null,
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -175,10 +177,12 @@ trait RendererTrait
|
||||
$project = $statisticModel->getProject();
|
||||
$id = $project->getCustomer()->getId() . '_' . $projectId;
|
||||
if ($statisticModel->hasTimeBudget()) {
|
||||
$summary[$id]['time_left'] = $statisticModel->getTimeBudgetOpen();
|
||||
$summary[$id]['time_left'] = $statisticModel->getTimeBudgetOpenRelative();
|
||||
$summary[$id]['time_left_total'] = $statisticModel->getTimeBudgetOpen();
|
||||
}
|
||||
if ($statisticModel->hasBudget()) {
|
||||
$summary[$id]['money_left'] = $statisticModel->getBudgetOpen();
|
||||
$summary[$id]['money_left'] = $statisticModel->getBudgetOpenRelative();
|
||||
$summary[$id]['money_left_total'] = $statisticModel->getBudgetOpen();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -108,14 +108,14 @@ class BudgetStatisticModel implements BudgetStatisticModelInterface
|
||||
{
|
||||
$value = $this->getTimeBudget() - $this->getDurationBillable();
|
||||
|
||||
return $value > 0 ? $value : 0;
|
||||
return max($value, 0);
|
||||
}
|
||||
|
||||
public function getTimeBudgetOpenRelative(): int
|
||||
{
|
||||
$value = $this->getTimeBudget() - $this->getDurationBillableRelative();
|
||||
|
||||
return $value > 0 ? $value : 0;
|
||||
return max($value, 0);
|
||||
}
|
||||
|
||||
public function getTimeBudgetSpent(): int
|
||||
@@ -137,14 +137,14 @@ class BudgetStatisticModel implements BudgetStatisticModelInterface
|
||||
{
|
||||
$value = $this->getBudget() - $this->getRateBillable();
|
||||
|
||||
return $value > 0 ? $value : 0;
|
||||
return max($value, 0);
|
||||
}
|
||||
|
||||
public function getBudgetOpenRelative(): float
|
||||
{
|
||||
$value = $this->getBudget() - $this->getRateBillableRelative();
|
||||
|
||||
return $value > 0 ? $value : 0;
|
||||
return max($value, 0);
|
||||
}
|
||||
|
||||
public function getBudgetSpent(): float
|
||||
|
||||
Reference in New Issue
Block a user