Improve test coverage.

This commit is contained in:
James Cole
2019-07-31 16:53:09 +02:00
parent 5524941c90
commit 9b574ce7ad
155 changed files with 1890 additions and 2263 deletions

View File

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

View File

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