diff --git a/app/controllers/PiggybankController.php b/app/controllers/PiggybankController.php index 8dc335bc31..2c3d7940b4 100644 --- a/app/controllers/PiggybankController.php +++ b/app/controllers/PiggybankController.php @@ -35,9 +35,10 @@ class PiggybankController extends BaseController public function createRepeated() { + $periods = Config::get('firefly.piggybank_periods'); $accounts = $this->_accounts->getActiveDefaultAsSelectList(); - return View::make('piggybanks.create')->with('accounts', $accounts); + return View::make('piggybanks.create-repeated')->with('accounts', $accounts)->with('periods',$periods); } diff --git a/app/lib/Firefly/Storage/Piggybank/EloquentPiggybankRepository.php b/app/lib/Firefly/Storage/Piggybank/EloquentPiggybankRepository.php index 144b3fab8b..49d927f0ea 100644 --- a/app/lib/Firefly/Storage/Piggybank/EloquentPiggybankRepository.php +++ b/app/lib/Firefly/Storage/Piggybank/EloquentPiggybankRepository.php @@ -69,7 +69,6 @@ class EloquentPiggybankRepository implements PiggybankRepositoryInterface */ public function store($data) { - var_dump($data); if ($data['targetdate'] == '') { unset($data['targetdate']); } @@ -83,15 +82,14 @@ class EloquentPiggybankRepository implements PiggybankRepositoryInterface $piggyBank = new \Piggybank($data); - $piggyBank->account()->associate($account); + if (!is_null($account)) { + $piggyBank->account()->associate($account); + } $today = new Carbon; if ($piggyBank->validate()) { - echo 'Valid, but some more checking!'; - if (!is_null($piggyBank->targetdate) && $piggyBank->targetdate < $today) { $piggyBank->errors()->add('targetdate', 'Target date cannot be in the past.'); - return $piggyBank; } @@ -100,7 +98,7 @@ class EloquentPiggybankRepository implements PiggybankRepositoryInterface // just flash a warning $reminderSkip = $piggyBank->reminder_skip < 1 ? 1 : intval($piggyBank->reminder_skip); $firstReminder = new Carbon; - switch($piggyBank->reminder) { + switch ($piggyBank->reminder) { case 'day': $firstReminder->addDays($reminderSkip); break; @@ -117,18 +115,12 @@ class EloquentPiggybankRepository implements PiggybankRepositoryInterface throw new FireflyException('Invalid reminder period'); break; } - if($firstReminder > $piggyBank->targetdate) { - $piggyBank->errors()->add('reminder','Something reminder bla.'); + if ($firstReminder > $piggyBank->targetdate) { + $piggyBank->errors()->add('reminder', 'The reminder has been set to remind you after the piggy bank will expire.'); return $piggyBank; } } - $piggyBank->save(); - } else { - echo 'Does not validate'; - - print_r($piggyBank->errors()->all()); - exit; } return $piggyBank; diff --git a/app/views/piggybanks/create-piggybank.blade.php b/app/views/piggybanks/create-piggybank.blade.php index 80e2bb86a6..3342e1135d 100644 --- a/app/views/piggybanks/create-piggybank.blade.php +++ b/app/views/piggybanks/create-piggybank.blade.php @@ -66,7 +66,11 @@
{{$errors->first('startdate')}}
+ @else This date indicates when you start(ed) saving money for this piggy bank. This field defaults to today and you should keep it on today. + @endif{{$errors->first('targetdate')}}
+ @else If this piggy bank has a dead line, enter it here. + @endif{{$errors->first('reminder')}}
+ @else Enter a number and a period and Firefly will remind you to add money to this piggy bank every now and then. + @endifCreate piggy banks to make saving money easier
-- Saving money is hard. Piggy banks allow you to group money - from an account together. If you also set a target (and a target date) you - can save towards your goals. -
+Create repeated expenses to keep track of long-term planned expenses
{{$errors->first('target')}}
+ @if($errors->has('targetamount')) +{{$errors->first('targetamount')}}
@else How much money do you need to save? @endif