New budget repository tests.

This commit is contained in:
James Cole
2015-05-09 09:05:37 +02:00
parent befdc05084
commit 49a65ebff4
2 changed files with 102 additions and 63 deletions

View File

@@ -25,21 +25,6 @@ class BudgetRepository implements BudgetRepositoryInterface
*/
public function cleanupBudgets()
{
$limits = BudgetLimit::leftJoin('budgets', 'budgets.id', '=', 'budget_limits.budget_id')->get(['budget_limits.*']);
// loop budget limits:
$found = [];
/** @var BudgetLimit $limit */
foreach ($limits as $limit) {
$key = $limit->budget_id . '-' . $limit->startdate;
if (isset($found[$key])) {
$limit->delete();
} else {
$found[$key] = true;
}
unset($key);
}
// delete limits with amount 0:
BudgetLimit::where('amount', 0)->delete();