Skip to content

Firefly III: a personal finances manager

Form for issue #6 is complete, final checks about to be written. Mebbe tomorrow. [skip ci]

James Cole2b42cb8ef301
diff --git a/app/controllers/PiggybankController.php b/app/controllers/PiggybankController.php
index b105dfd4a0..6e35f8fe2b 100644
--- a/app/controllers/PiggybankController.php
+++ b/app/controllers/PiggybankController.php
@@ -27,9 +27,10 @@ class PiggybankController extends BaseController
*/
public function createPiggybank()
{
+ $periods = Config::get('firefly.piggybank_periods');
$accounts = $this->_accounts->getActiveDefaultAsSelectList();
- return View::make('piggybanks.create-piggybank')->with('accounts', $accounts);
+ return View::make('piggybanks.create-piggybank')->with('accounts', $accounts)->with('periods',$periods);
}
public function createRepeated()
diff --git a/app/database/migrations/2014_07_05_100651_create_piggybanks_table.php b/app/database/migrations/2014_07_05_100651_create_piggybanks_table.php
index 1f2b5d1828..c7b3da8e09 100644
--- a/app/database/migrations/2014_07_05_100651_create_piggybanks_table.php
+++ b/app/database/migrations/2014_07_05_100651_create_piggybanks_table.php
@@ -31,6 +31,7 @@ class CreatePiggybanksTable extends Migration
$table->enum('rep_length', ['day', 'week', 'month', 'year'])->nullable();
$table->smallInteger('rep_times')->unsigned();
$table->enum('reminder', ['day', 'week', 'month', 'year'])->nullable();
+ $table->smallInteger('reminder_skip')->unsigned();
$table->integer('order')->unsigned();
// connect account to piggybank.
diff --git a/app/lib/Firefly/Storage/Piggybank/EloquentPiggybankRepository.php b/app/lib/Firefly/Storage/Piggybank/EloquentPiggybankRepository.php
index 6e3b58ad93..ecb724221b 100644
--- a/app/lib/Firefly/Storage/Piggybank/EloquentPiggybankRepository.php
+++ b/app/lib/Firefly/Storage/Piggybank/EloquentPiggybankRepository.php
@@ -1,6 +1,7 @@
<?php
namespace Firefly\Storage\Piggybank;
+use Carbon\Carbon;
/**
@@ -74,7 +75,19 @@ class EloquentPiggybankRepository implements PiggybankRepositoryInterface
$piggyBank = new \Piggybank($data);
$piggyBank->account()->associate($account);
+ $today = new Carbon;
if ($piggyBank->validate()) {
+ echo 'Valid, but some more checking!';
+ if($piggyBank->targetdate < $today) {
+ $piggyBank->errors()->add('targetdate','Target date cannot be in the past.');
+ echo 'errrrrrr on target date';
+ return $piggyBank;
+ }
+
+ // first period for reminder is AFTER target date.
+ // just flash a warning
+ die('Here be a check. Sorry for the kill-switch. Will continue tomorrow.');
+
$piggyBank->save();
}
diff --git a/app/views/piggybanks/create-piggybank.blade.php b/app/views/piggybanks/create-piggybank.blade.php
index 68147e1686..ae06586553 100644
--- a/app/views/piggybanks/create-piggybank.blade.php
+++ b/app/views/piggybanks/create-piggybank.blade.php
@@ -75,7 +75,23 @@
<div class="col-sm-8">
<input type="date" name="targetdate" value="{{Input::old('targetdate') ?: ''}}"
class="form-control"/>
- <span class="help-block">This field indicates when you want to have saved the indicated amount.</span>
+ <span class="help-block">If this piggy bank has a dead line, enter it here.</span>
+ </div>
+ </div>
+
+ <div class="form-group">
+ {{ Form::label('reminder', 'Remind you every', ['class' => 'col-sm-4 control-label'])}}
+ <div class="col-sm-8">
+ <input type="number" step="1" min="1" value="1" style="width:50px;display:inline;" max="100" name="reminder_skip" class="form-control" />
+
+ <select class="form-control" style="width:150px;display: inline">
+ <option value="none" label="do not remind me">do not remind me</option>
+ @foreach($periods as $period)
+ <option value="{{$period}}" label="{{$period}}">{{$period}}</option>
+ @endforeach
+ </select>
+ <span class="help-block">Enter a number and a period and Firefly will remind you to add money
+ to this piggy bank every now and then.</span>
</div>
</div>
diff --git a/app/views/piggybanks/index.blade.php b/app/views/piggybanks/index.blade.php
index 72fbc0d5b7..88cf559e11 100644
--- a/app/views/piggybanks/index.blade.php
+++ b/app/views/piggybanks/index.blade.php
@@ -12,7 +12,7 @@
<p class="lead">Save money for large expenses</p>
<p class="text-info">
Saving money is <em>hard</em>. Firefly's piggy banks can help you to save money. Simply set the amount
- of money you want to save, set an optional target and whether or not Firefly should remind you to add money
+ of money you want to save, set an optional target date and whether or not Firefly should remind you to add money
to the piggy bank.
</p>
<p>