Skip to content

Firefly III: a personal finances manager

Implemented #264

James Colec619b8730b5d
diff --git a/app/Http/Controllers/BudgetController.php b/app/Http/Controllers/BudgetController.php
index a858e82252..e6f517c9a8 100644
--- a/app/Http/Controllers/BudgetController.php
+++ b/app/Http/Controllers/BudgetController.php
@@ -164,6 +164,8 @@ class BudgetController extends Controller
*/
public function index(BudgetRepositoryInterface $repository, AccountCrudInterface $crud)
{
+ $repository->cleanupBudgets();
+
$budgets = $repository->getActiveBudgets();
$inactive = $repository->getInactiveBudgets();
$spent = '0';
diff --git a/app/Repositories/Budget/BudgetRepository.php b/app/Repositories/Budget/BudgetRepository.php
index 04d63893a5..b104c8f292 100644
--- a/app/Repositories/Budget/BudgetRepository.php
+++ b/app/Repositories/Budget/BudgetRepository.php
@@ -156,6 +156,18 @@ class BudgetRepository implements BudgetRepositoryInterface
return $set;
}
+ /**
+ * @return bool
+ */
+ public function cleanupBudgets(): bool
+ {
+ // delete limits with amount 0:
+ BudgetLimit::where('amount', 0)->delete();
+
+ return true;
+
+ }
+
/**
* @return Collection
*/
diff --git a/app/Repositories/Budget/BudgetRepositoryInterface.php b/app/Repositories/Budget/BudgetRepositoryInterface.php
index 6feeb5336c..31bf8d4ed2 100644
--- a/app/Repositories/Budget/BudgetRepositoryInterface.php
+++ b/app/Repositories/Budget/BudgetRepositoryInterface.php
@@ -111,6 +111,11 @@ interface BudgetRepositoryInterface
*/
public function spentInPeriod(Collection $budgets, Collection $accounts, Carbon $start, Carbon $end) : string;
+ /**
+ * @return bool
+ */
+ public function cleanupBudgets(): bool;
+
/**
* @param array $data
*