mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-12 15:35:15 +00:00
Improve test coverage.
This commit is contained in:
@@ -489,36 +489,6 @@ class BudgetRepository implements BudgetRepositoryInterface
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate the average amount in the budgets available in this period.
|
||||
* Grouped by day.
|
||||
*
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getAverageAvailable(Carbon $start, Carbon $end): string
|
||||
{
|
||||
/** @var Collection $list */
|
||||
$list = $this->user->availableBudgets()
|
||||
->where('start_date', '>=', $start->format('Y-m-d 00:00:00'))
|
||||
->where('end_date', '<=', $end->format('Y-m-d 00:00:00'))
|
||||
->get();
|
||||
if (0 === $list->count()) {
|
||||
return '0';
|
||||
}
|
||||
$total = '0';
|
||||
$days = 0;
|
||||
/** @var AvailableBudget $availableBudget */
|
||||
foreach ($list as $availableBudget) {
|
||||
$total = bcadd($availableBudget->amount, $total);
|
||||
$days += $availableBudget->start_date->diffInDays($availableBudget->end_date);
|
||||
}
|
||||
|
||||
return bcdiv($total, (string)$days);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is being used to generate the budget overview in the year/multi-year report. Its used
|
||||
* in both the year/multi-year budget overview AND in the accompanying chart.
|
||||
|
@@ -172,17 +172,6 @@ interface BudgetRepositoryInterface
|
||||
*/
|
||||
public function getAvailableBudgetsByCurrency(TransactionCurrency $currency): Collection;
|
||||
|
||||
/**
|
||||
* Calculate the average amount in the budgets available in this period.
|
||||
* Grouped by day.
|
||||
*
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getAverageAvailable(Carbon $start, Carbon $end): string;
|
||||
|
||||
/**
|
||||
* @param Budget $budget
|
||||
* @param Carbon $start
|
||||
|
Reference in New Issue
Block a user