fix relative times in budget calculation in export (#3216)

This commit is contained in:
Kevin Papst
2022-03-22 21:02:29 +01:00
committed by GitHub
parent 6c1d79fe5b
commit 3c6b5c6c1e
2 changed files with 10 additions and 6 deletions

View File

@@ -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();
}
}

View File

@@ -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