From f814f45e36ab04d11375de1064b99ad3001c2f36 Mon Sep 17 00:00:00 2001 From: Sander Dorigo Date: Wed, 5 Nov 2014 21:37:24 +0100 Subject: [PATCH] Test fix for budgeting. --- app/controllers/BudgetController.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/app/controllers/BudgetController.php b/app/controllers/BudgetController.php index a564f1b7fa..5c587842e3 100644 --- a/app/controllers/BudgetController.php +++ b/app/controllers/BudgetController.php @@ -52,9 +52,13 @@ class BudgetController extends BaseController Event::fire('limits.store', [$limit]); } else { - $limit->amount = $amount; - $limit->save(); - Event::fire('limits.update', [$limit]); + if ($amount > 0) { + $limit->amount = $amount; + $limit->save(); + Event::fire('limits.update', [$limit]); + } else { + $limit->delete(); + } } // try to find the limit repetition for this limit: $repetition = $limit->limitrepetitions()->first();