Skip to content

Firefly III: a personal finances manager

Lots of code cleanup.

James Cole6832f2ebd047
diff --git a/app/controllers/CategoryController.php b/app/controllers/CategoryController.php
index cb9aa2c649..ec05e23798 100644
--- a/app/controllers/CategoryController.php
+++ b/app/controllers/CategoryController.php
@@ -93,19 +93,43 @@ class CategoryController extends BaseController
*/
public function store()
{
- $category = $this->_repository->store(Input::all());
- if ($category->validate()) {
- Session::flash('success', 'Category "' . $category->name . '" created!');
+ $data = Input::all();
+ /** @var \FireflyIII\Database\Category $repos */
+ $repos = App::make('FireflyIII\Database\Category');
- if (Input::get('create') == '1') {
- return Redirect::route('categories.create');
- }
+ switch ($data['post_submit_action']) {
+ default:
+ throw new FireflyException('Cannot handle post_submit_action "' . e($data['post_submit_action']) . '"');
+ break;
+ case 'create_another':
+ case 'store':
+ $messages = $repos->validate($data);
+ /** @var MessageBag $messages ['errors'] */
+ if ($messages['errors']->count() > 0) {
+ Session::flash('warnings', $messages['warnings']);
+ Session::flash('successes', $messages['successes']);
+ Session::flash('error', 'Could not save category: ' . $messages['errors']->first());
- return Redirect::route('categories.index');
- } else {
- Session::flash('error', 'Could not save the new category!');
+ return Redirect::route('categories.create')->withInput()->withErrors($messages['errors']);
+ }
+ // store!
+ $repos->store($data);
+ Session::flash('success', 'New category stored!');
- return Redirect::route('categories.create')->withInput();
+ if ($data['post_submit_action'] == 'create_another') {
+ return Redirect::route('categories.create')->withInput();
+ } else {
+ return Redirect::route('categories.index');
+ }
+ break;
+ case 'validate_only':
+ $messageBags = $repos->validate($data);
+ Session::flash('warnings', $messageBags['warnings']);
+ Session::flash('successes', $messageBags['successes']);
+ Session::flash('errors', $messageBags['errors']);
+
+ return Redirect::route('categories.create')->withInput();
+ break;
}
}
diff --git a/app/controllers/RecurringController.php b/app/controllers/RecurringController.php
index 8a6f66ba75..a4027bcb00 100644
--- a/app/controllers/RecurringController.php
+++ b/app/controllers/RecurringController.php
@@ -1,4 +1,5 @@
<?php
+use Carbon\Carbon;
use FireflyIII\Exception\FireflyException;
use Illuminate\Support\MessageBag;
@@ -84,7 +85,8 @@ class RecurringController extends BaseController
$repos = App::make('FireflyIII\Database\Recurring');
$recurring = $repos->get();
- return View::make('recurring.index',compact('recurring'));
+
+ return View::make('recurring.index', compact('recurring'));
}
/**
@@ -116,9 +118,13 @@ class RecurringController extends BaseController
*/
public function show(RecurringTransaction $recurringTransaction)
{
- $journals = $recurringTransaction->transactionjournals()->withRelevantData()->orderBy('date','DESC')->get();
+ $journals = $recurringTransaction->transactionjournals()->withRelevantData()->orderBy('date', 'DESC')->get();
$hideRecurring = true;
- return View::make('recurring.show',compact('journals','hideRecurring'))->with('recurring', $recurringTransaction)->with('subTitle', $recurringTransaction->name);
+
+
+ return View::make('recurring.show', compact('journals', 'hideRecurring','finalDate'))->with('recurring', $recurringTransaction)->with(
+ 'subTitle', $recurringTransaction->name
+ );
}
public function store()
diff --git a/app/lib/FireflyIII/Database/Category.php b/app/lib/FireflyIII/Database/Category.php
index 253dd3ab99..7056754dd8 100644
--- a/app/lib/FireflyIII/Database/Category.php
+++ b/app/lib/FireflyIII/Database/Category.php
@@ -46,8 +46,16 @@ class Category implements CUD, CommonDatabaseCalls, CategoryInterface
*/
public function store(array $data)
{
- // TODO: Implement store() method.
- throw new NotImplementedException;
+ $category = new \Category;
+ $category->name = $data['name'];
+ $category->class = 'Category';
+ $category->user()->associate($this->getUser());
+ if(!$category->validate()) {
+ var_dump($category->errors());
+ exit();
+ }
+ $category->save();
+ return $category;
}
/**
diff --git a/app/lib/FireflyIII/Shared/Toolkit/Date.php b/app/lib/FireflyIII/Shared/Toolkit/Date.php
index 352685dfca..194305a829 100644
--- a/app/lib/FireflyIII/Shared/Toolkit/Date.php
+++ b/app/lib/FireflyIII/Shared/Toolkit/Date.php
@@ -83,6 +83,7 @@ class Date
$currentEnd->addYear()->subDay();
break;
}
+ return $currentEnd;
}
/**
@@ -124,4 +125,43 @@ class Date
return $date;
}
+
+ /**
+ * @param Carbon $date
+ * @param $repeatFreq
+ * @param int $substract
+ *
+ * @return Carbon
+ * @throws FireflyException
+ */
+ public function substractPeriod(Carbon $date, $repeatFreq, $substract = 1)
+ {
+ switch ($repeatFreq) {
+ default:
+ throw new FireflyException('Cannot do addPeriod for $repeat_freq ' . $repeatFreq);
+ break;
+ case 'daily':
+ $date->subDays($substract);
+ break;
+ case 'weekly':
+ $date->subWeeks($substract);
+ break;
+ case 'monthly':
+ $date->subMonths($substract);
+ break;
+ case 'quarterly':
+ $months = $substract * 3;
+ $date->subMonths($months);
+ break;
+ case 'half-year':
+ $months = $substract * 6;
+ $date->subMonths($months);
+ break;
+ case 'yearly':
+ $date->subYears($substract);
+ break;
+ }
+
+ return $date;
+ }
}
\ No newline at end of file
diff --git a/app/models/Piggybank.php b/app/models/Piggybank.php
index 03ec278c47..890e1ea270 100644
--- a/app/models/Piggybank.php
+++ b/app/models/Piggybank.php
@@ -90,7 +90,15 @@ class Piggybank extends Ardent
*/
public function currentRelevantRep()
{
- $query = $this->piggybankrepetitions()->where(
+ if($this->currentRep) {
+ return $this->currentRep;
+ }
+ if ($this->repeats == 0) {
+ $rep = $this->piggybankrepetitions()->first();
+ $this->currentRep = $rep;
+ return $rep;
+ } else {
+ $query = $this->piggybankrepetitions()->where(
function ($q) {
$q->where(
@@ -100,12 +108,12 @@ class Piggybank extends Ardent
$q->orWhere('startdate', '<=', $today->format('Y-m-d'));
}
)->where(
- function ($q) {
- $today = new Carbon;
- $q->whereNull('targetdate');
- $q->orWhere('targetdate', '>=', $today->format('Y-m-d'));
- }
- );
+ function ($q) {
+ $today = new Carbon;
+ $q->whereNull('targetdate');
+ $q->orWhere('targetdate', '>=', $today->format('Y-m-d'));
+ }
+ );
}
)->orWhere(
function ($q) {
@@ -114,9 +122,11 @@ class Piggybank extends Ardent
$q->where('targetdate', '>=', $today->format('Y-m-d'));
}
)->orderBy('startdate', 'ASC');
- $result = $query->first();
+ $result = $query->first();
+ $this->currentRep = $result;
- return $result;
+ return $result;
+ }
}
@@ -155,26 +165,26 @@ class Piggybank extends Ardent
public function repetitionForDate(Carbon $date)
{
$query = $this->piggybankrepetitions()->where(
- function ($q) use ($date) {
-
- $q->where(
- function ($q) use ($date) {
- $q->whereNull('startdate');
- $q->orWhere('startdate', '<=', $date->format('Y-m-d'));
- }
- )->where(
- function ($q) use ($date) {
- $q->whereNull('targetdate');
- $q->orWhere('targetdate', '>=', $date->format('Y-m-d'));
- }
- );
- }
- )->orWhere(
- function ($q) use ($date) {
- $q->where('startdate', '>=', $date->format('Y-m-d'));
- $q->where('targetdate', '>=', $date->format('Y-m-d'));
- }
- )->orderBy('startdate', 'ASC');
+ function ($q) use ($date) {
+
+ $q->where(
+ function ($q) use ($date) {
+ $q->whereNull('startdate');
+ $q->orWhere('startdate', '<=', $date->format('Y-m-d'));
+ }
+ )->where(
+ function ($q) use ($date) {
+ $q->whereNull('targetdate');
+ $q->orWhere('targetdate', '>=', $date->format('Y-m-d'));
+ }
+ );
+ }
+ )->orWhere(
+ function ($q) use ($date) {
+ $q->where('startdate', '>=', $date->format('Y-m-d'));
+ $q->where('targetdate', '>=', $date->format('Y-m-d'));
+ }
+ )->orderBy('startdate', 'ASC');
$result = $query->first();
return $result;
diff --git a/app/models/RecurringTransaction.php b/app/models/RecurringTransaction.php
index 556535baec..56cd8d81c8 100644
--- a/app/models/RecurringTransaction.php
+++ b/app/models/RecurringTransaction.php
@@ -51,44 +51,66 @@ class RecurringTransaction extends Ardent
return ['created_at', 'updated_at', 'date'];
}
+ public function lastFoundMatch() {
+ $last = $this->transactionjournals()->orderBy('date','DESC')->first();
+ if($last) {
+ return $last->date;
+ }
+ return null;
+ }
/**
- * @return Carbon
+ * Find the next expected match based on the set journals and the date stuff from the recurring
+ * transaction.
*/
- public function next()
+ public function nextExpectedMatch()
{
- $today = new Carbon;
- $start = clone $this->date;
- $skip = $this->skip == 0 ? 1 : $this->skip;
- if ($today < $start) {
- return $start;
- }
- while ($start <= $this->date) {
- switch ($this->repeat_freq) {
- case 'daily':
- $start->addDays($skip);
- break;
- case 'weekly':
- $start->addWeeks($skip);
- break;
- case 'monthly':
- $start->addMonths($skip);
- break;
- case 'quarterly':
- $start->addMonths($skip * 3);
- break;
- case 'half-year':
- $start->addMonths($skip * 6);
- break;
- case 'yearly':
- $start->addYears($skip);
- break;
+ /** @var \FireflyIII\Shared\Toolkit\Date $dateKit */
+ $dateKit = App::make('FireflyIII\Shared\Toolkit\Date');
+
+ /*
+ * The date Firefly tries to find. If this stays null, it's "unknown".
+ */
+ $finalDate = null;
+
+ /*
+ * $today is the start of the next period, to make sure FF3 won't miss anything
+ * when the current period has a transaction journal.
+ */
+ $today = $dateKit->addPeriod(new Carbon, $this->repeat_freq, 0);
+
+ /*
+ * FF3 loops from the $start of the recurring transaction, and to make sure
+ * $skip works, it adds one (for modulo).
+ */
+ $skip = $this->skip + 1;
+ $start = $dateKit->startOfPeriod(new Carbon, $this->repeat_freq);
+ /*
+ * go back exactly one month/week/etc because FF3 does not care about 'next'
+ * recurring transactions if they're too far into the past.
+ */
+ // echo 'Repeat freq is: ' . $recurringTransaction->repeat_freq . '<br />';
+ // echo 'Start: ' . $start . ' <br />';
+
+ $counter = 0;
+ while ($start <= $today) {
+ if (($counter % $skip) == 0) {
+ // do something.
+ $end = $dateKit->endOfPeriod(clone $start, $this->repeat_freq);
+ $journalCount = $this->transactionjournals()->before($end)->after($start)->count();
+ if ($journalCount == 0) {
+ $finalDate = clone $start;
+ break;
+ }
}
- }
- return $start;
+ // add period for next round!
+ $start = $dateKit->addPeriod($start, $this->repeat_freq, 0);
+ $counter++;
+ }
+ return $finalDate;
}
/**
diff --git a/app/models/Transaction.php b/app/models/Transaction.php
index a60d5535eb..6a85e97864 100644
--- a/app/models/Transaction.php
+++ b/app/models/Transaction.php
@@ -78,29 +78,6 @@ class Transaction extends Ardent
return $this->belongsToMany('Component');
}
- /**
- * @param Piggybank $piggybank
- *
- * @return bool
- */
- public function connectPiggybank(\Piggybank $piggybank = null)
- {
- // TODO connect a piggy bank to a transaction.
- throw new NotImplementedException;
- // if (is_null($piggybank)) {
- // return true;
- // }
- // /** @var \Firefly\Storage\Piggybank\PiggybankRepositoryInterface $piggyRepository */
- // $piggyRepository = \App::make('Firefly\Storage\Piggybank\PiggybankRepositoryInterface');
- // if ($this->account_id == $piggybank->account_id) {
- // $this->piggybank()->associate($piggybank);
- // $this->save();
- // \Event::fire('piggybanks.createRelatedTransfer', [$piggybank, $this->transactionJournal, $this]);
- // return true;
- // }
- // return false;
- }
-
/**
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/
diff --git a/app/views/categories/create.blade.php b/app/views/categories/create.blade.php
index bf8c855596..77868e12f4 100644
--- a/app/views/categories/create.blade.php
+++ b/app/views/categories/create.blade.php
@@ -1,57 +1,37 @@
@extends('layouts.default')
@section('content')
-<div class="row">
- <div class="col-lg-12 col-md-12 col-sm-12">
- <p class="lead">Use categories to group your expenses</p>
- <p class="text-info">
- Use categories to group expenses by hobby, for certain types of groceries or what bills are for.
- Expenses grouped in categories do not have to reoccur every month or every week, like budgets.
- </p>
- </div>
-</div><!-- TODO cleanup to match new theme & form -->
{{Form::open(['class' => 'form-horizontal','url' => route('categories.store')])}}
<div class="row">
- <div class="col-lg-6 col-md-12 col-sm-6">
- <h4>Mandatory fields</h4>
-
- <div class="form-group">
- <label for="name" class="col-sm-4 control-label">Name</label>
- <div class="col-sm-8">
- <input type="text" name="name" class="form-control" id="name" value="{{Input::old('name')}}" placeholder="Name">
- @if($errors->has('name'))
- <p class="text-danger">{{$errors->first('name')}}</p>
- @else
- <span class="help-block">For example: bike, utilities, daily groceries</span>
- @endif
+ <div class="col-lg-6 col-md-6 col-sm-12">
+ <div class="panel panel-primary">
+ <div class="panel-heading">
+ <i class="fa fa-exclamation"></i> Mandatory fields
+ </div>
+ <div class="panel-body">
+ {{Form::ffText('name')}}
</div>
</div>
-
+ <p>
+ <button type="submit" class="btn btn-lg btn-success">
+ <i class="fa fa-plus-circle"></i> Store new category
+ </button>
+ </p>
</div>
-</div>
-<div class="row">
- <div class="col-lg-6 col-md-12 col-sm-6">
-
- <!-- add another after this one? -->
- <div class="form-group">
- <label for="create" class="col-sm-4 control-label">&nbsp;</label>
- <div class="col-sm-8">
- <div class="checkbox">
- <label>
- {{Form::checkbox('create',1,Input::old('create') == '1')}}
- Create another (return to this form)
- </label>
- </div>
- </div>
- </div>
+ <div class="col-lg-6 col-md-6 col-sm-12">
- <div class="form-group">
- <div class="col-sm-offset-4 col-sm-8">
- <button type="submit" class="btn btn-default btn-success">Create the category</button>
+ <!-- panel for options -->
+ <div class="panel panel-default">
+ <div class="panel-heading">
+ <i class="fa fa-bolt"></i> Options
+ </div>
+ <div class="panel-body">
+ {{Form::ffOptionsList('create','category')}}
</div>
</div>
+
</div>
</div>
diff --git a/app/views/charts/info.blade.php b/app/views/charts/info.blade.php
deleted file mode 100644
index 00e590e129..0000000000
--- a/app/views/charts/info.blade.php
+++ /dev/null
@@ -1,12 +0,0 @@
-<table class="table table-condensed">
- <tr>
- <th>Total</th>
- <th>{{mf($sum*-1)}}</th>
- </tr>
- @foreach($rows as $name => $entry)
- <tr>
- <td><a href="{{route('accounts.show',$entry['id'])}}">{{{$name}}}</a></td>
- <td>{{mf($entry['amount']*-1)}}</td>
- </tr>
- @endforeach
-</table><!-- TODO remove me -->
\ No newline at end of file
diff --git a/app/views/emails/auth/reminder.blade.php b/app/views/emails/auth/reminder.blade.php
deleted file mode 100644
index 276f8c59f2..0000000000
--- a/app/views/emails/auth/reminder.blade.php
+++ /dev/null
@@ -1,15 +0,0 @@
-<!DOCTYPE html>
-<html lang="en-US">
- <head>
- <meta charset="utf-8">
- </head>
- <body>
- <h2>Password Reset</h2>
-
- <div>
- To reset your password, complete this form: {{ URL::to('password/reset', array($token)) }}.<br/>
- This link will expire in {{ Config::get('auth.reminder.expire', 60) }} minutes.
- </div>
- </body>
-</html>
-<!-- TODO remove me -->
\ No newline at end of file
diff --git a/app/views/layouts/guest.blade.php b/app/views/layouts/guest.blade.php
index df2a721548..8485ddaccb 100644
--- a/app/views/layouts/guest.blade.php
+++ b/app/views/layouts/guest.blade.php
@@ -5,7 +5,7 @@
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<base href="{{URL::route('index')}}/">
- <title>Firefly</title>
+ <title>Firefly III</title>
{{HTML::style('assets/stylesheets/bootstrap/bootstrap.min.css')}}
{{HTML::style('assets/stylesheets/metisMenu/metisMenu.min.css')}}
@@ -25,4 +25,4 @@
@yield('content')
</div>
</body>
-</html><!-- TODO main update title and title-tag -->
\ No newline at end of file
+</html>
\ No newline at end of file
diff --git a/app/views/limits/create.blade.php b/app/views/limits/create.blade.php
deleted file mode 100644
index a3a13c4dcf..0000000000
--- a/app/views/limits/create.blade.php
+++ /dev/null
@@ -1,98 +0,0 @@
-@extends('layouts.default')
-@section('content')
-<div class="row">
- <div class="col-lg-12 col-md-12 col-sm-12">
- <p class="text-info">
- Firefly uses an "<a href="http://en.wikipedia.org/wiki/Envelope_System" class="text-success">envelope
- system</a>" for your budgets, which means that for each period of time (for example a month) a virtual
- "envelope" can be created containing a certain amount of money. Money spent within a budget is removed from
- the envelope.
- </p>
-
- <p class="text-info">
- Firefly gives you the opportunity to create such an envelope when you create a budget. However, you can
- always add more of them.
- </p>
- </div>
-</div><!-- TODO cleanup and use new forms -->
-
-{{Form::open(['class' => 'form-horizontal','url' => route('budgets.limits.store',$prefilled['budget_id'])])}}
-{{Form::hidden('from',e(Input::get('from')))}}
-
-
-<div class="row">
- <div class="col-lg-6 col-md-12 col-sm-6">
- <h4>Mandatory fields</h4>
-
- <div class="form-group">
- {{ Form::label('budget_id', 'Budget', ['class' => 'col-sm-4 control-label'])}}
- <div class="col-sm-8">
- {{Form::select('budget_id',$budgets,Input::old('budget_id') ?: $prefilled['budget_id'], ['class' =>
- 'form-control'])}}
- @if($errors->has('budget_id'))
- <p class="text-danger">{{$errors->first('name')}}</p>
- @else
- <span class="help-block">Select one of your existing budgets.</span>
- @endif
- </div>
- </div>
-
- <div class="form-group">
- {{ Form::label('startdate', 'Start date', ['class' => 'col-sm-4 control-label'])}}
- <div class="col-sm-8">
- <input type="date" name="startdate" value="{{Input::old('startdate') ?: $prefilled['startdate']}}"
- class="form-control"/>
- <span class="help-block">This date indicates when the envelope "starts". The date you select
- here will correct itself to the nearest [period] you select below.</span>
- </div>
- </div>
-
- <div class="form-group">
- <label for="period" class="col-sm-4 control-label">Spending period</label>
-
- <div class="col-sm-8">
- {{Form::select('period',$periods,Input::old('period') ?: $prefilled['repeat_freq'],['class' => 'form-control'])}}
- <span class="help-block">How long will the envelope last? A week, a month, or even longer?</span>
- </div>
- </div>
- <div class="form-group">
- <label for="period" class="col-sm-4 control-label">Repeat</label>
-
- <div class="col-sm-8">
- <div class="checkbox">
- <label>
- <input type="checkbox" value="1" name="repeats" @if(intval(Input::old('repeats')) == 1) checked @endif>
- Repeat
- </label>
- </div>
- <span class="help-block">If you want, Firefly can automatically recreate the "envelope" and fill it again
- when the timespan above has expired. Be careful with this option though. It makes it easier
- to <a href="http://en.wikipedia.org/wiki/Personal_budget#Concepts">fall back to old habits</a>.
- Instead, you should recreate the envelope yourself each [period].</span>
- </div>
- </div>
-
-
- <div class="form-group">
- {{ Form::label('amount', 'Amount', ['class' => 'col-sm-4 control-label'])}}
- <div class="col-sm-8">
- <input type="number" value="{{Input::old('amount')}}" name="amount" min="0.01" step="any" class="form-control"/>
- <span class="help-block">Of course, there needs to be money in the envelope.</span>
- </div>
- </div>
-
- <div class="form-group">
- {{ Form::label('submit', '&nbsp;', ['class' => 'col-sm-4 control-label'])}}
- <div class="col-sm-8">
- <input type="submit" name="submit" value="Save new envelope" class="btn btn-success"/>
-
- </div>
- </div>
-
- </div>
-</div>
-
-{{Form::close()}}
-
-
-@stop
\ No newline at end of file
diff --git a/app/views/limits/delete.blade.php b/app/views/limits/delete.blade.php
deleted file mode 100644
index 4c3bd9b8b7..0000000000
--- a/app/views/limits/delete.blade.php
+++ /dev/null
@@ -1,62 +0,0 @@
-@extends('layouts.default')
-@section('content')
-<div class="row">
- <div class="col-lg-12 col-md-12 col-sm-12">
- <p class="lead">Remember that deleting something is permanent.</p>
-
- </div>
-
-</div><!-- TODO cleanup and use new forms -->
-
-{{Form::open(['class' => 'form-horizontal','url' => route('budgets.limits.destroy',$limit->id)])}}
-
-<div class="row">
- <div class="col-lg-6">
- <h4>&nbsp;</h4>
- <p class="text-info">
- This form allows you to delete the envelope for budget {{{$limit->budget->name}}}, with a content of
- {{mf($limit->amount,false)}}
- @if($limit->repeats == 0)
- in {{$limit->limitrepetitions[0]->startdate->format('M Y')}} ({{$limit->repeat_freq}}).
- @endif
- </p>
- <p class="text-info">
- Destroying an envelope does not remove any transactions from the budget.
- </p>
- <p class="text-danger">
- Are you sure?
- </p>
-
- <div class="form-group">
- <div class="col-sm-8">
- <input type="submit" name="submit" value="Remove envelope" class="btn btn-danger" />
- @if(Input::get('from') == 'date')
- <a href="{{route('budgets.index')}}" class="btn-default btn">Cancel</a>
- @else
- <a href="{{route('budgets.index')}}" class="btn-default btn">Cancel</a>
- @endif
- </div>
- </div>
- </div>
- @if($limit->repeats == 1)
- <div class="col-lg-6 col-md-6 col-sm-12">
- <h4>Auto repeating</h4>
- <p class="text-info">
- This envelope is set to repeat itself; creating a new period whenever the previous period
- has passed. If you change this envelope, you'll also change the following (automatically created)
- envelopes.
- {{$limit->limitrepetitions()->count() }}
- </p>
- <ul>
- @foreach($limit->limitrepetitions()->orderBy('startdate','DESC')->get() as $rep)
- <li>Evenlope for {{$rep->periodShow()}}, {{mf($rep->amount,false)}}</li>
- @endforeach
- </ul>
- </div>
- @endif
-</div>
-
-
-{{Form::close()}}
-
-@stop
diff --git a/app/views/limits/edit.blade.php b/app/views/limits/edit.blade.php
deleted file mode 100644
index 7ba95b132b..0000000000
--- a/app/views/limits/edit.blade.php
+++ /dev/null
@@ -1,115 +0,0 @@
-@extends('layouts.default')
-@section('content')
-<div class="row">
- <div class="col-lg-12 col-md-12 col-sm-12">
- <p class="text-info">
- Firefly uses an "<a href="http://en.wikipedia.org/wiki/Envelope_System" class="text-success">envelope
- system</a>" for your budgets, which means that for each period of time (for example a month) a virtual
- "envelope" can be created containing a certain amount of money. Money spent within a budget is removed from
- the envelope.
- </p>
-
- <p class="text-info">
- This form allows you to edit the envelope for budget {{{$limit->budget->name}}}, with a content of
- {{mf($limit->amount,false)}}
- @if($limit->repeats == 0)
- in {{$limit->limitrepetitions[0]->startdate->format('M Y')}} ({{$limit->repeat_freq}}).
- @endif
- </p>
- </div>
-</div><!-- TODO cleanup and use new forms -->
-
-{{Form::open(['class' => 'form-horizontal','url' => route('budgets.limits.update',$limit->id)])}}
-{{Form::hidden('from',e(Input::get('from')))}}
-<div class="row">
- <div class="col-lg-6 col-md-12 col-sm-6">
- <h4>Mandatory fields</h4>
-
- <div class="form-group">
- {{ Form::label('budget_id', 'Budget', ['class' => 'col-sm-4 control-label'])}}
- <div class="col-sm-8">
- {{Form::select('budget_id',$budgets,Input::old('budget_id') ?: $limit->component_id, ['class' =>
- 'form-control'])}}
- @if($errors->has('budget_id'))
- <p class="text-danger">{{$errors->first('name')}}</p>
- @else
- <span class="help-block">Select one of your existing budgets.</span>
- @endif
- </div>
- </div>
-
- <div class="form-group">
- {{ Form::label('startdate', 'Start date', ['class' => 'col-sm-4 control-label'])}}
- <div class="col-sm-8">
- <input type="date" name="startdate" value="{{Input::old('startdate') ?: $limit->startdate->format('Y-m-d')}}"
- class="form-control"/>
- <span class="help-block">This date indicates when the envelope "starts". The date you select
- here will correct itself to the nearest [period] you select below.</span>
- </div>
- </div>
-
- <div class="form-group">
- <label for="period" class="col-sm-4 control-label">Spending period</label>
-
- <div class="col-sm-8">
- {{Form::select('period',$periods,Input::old('period') ?: $limit->repeat_freq,['class' => 'form-control'])}}
- <span class="help-block">How long will the envelope last? A week, a month, or even longer?</span>
- </div>
- </div>
- <div class="form-group">
- <label for="period" class="col-sm-4 control-label">Repeat</label>
-
- <div class="col-sm-8">
- <div class="checkbox">
- <label>
- <input type="checkbox" value="1" name="repeats" @if(intval(Input::old('repeats')) == 1 || intval($limit->repeats) == 1) checked @endif>
- Repeat
- </label>
- </div>
- <span class="help-block">If you want, Firefly can automatically recreate the "envelope" and fill it again
- when the timespan above has expired. Be careful with this option though. It makes it easier
- to <a href="http://en.wikipedia.org/wiki/Personal_budget#Concepts">fall back to old habits</a>.
- Instead, you should recreate the envelope yourself each [period].</span>
- </div>
- </div>
-
-
- <div class="form-group">
- {{ Form::label('amount', 'Amount', ['class' => 'col-sm-4 control-label'])}}
- <div class="col-sm-8">
- <input type="number" value="{{ is_null(Input::old('amount')) || Input::old('amount') == '' ? $limit->amount : Input::old('amount')}}" name="amount" min="0.01" step="any" class="form-control"/>
- <span class="help-block">Of course, there needs to be money in the envelope.</span>
- </div>
- </div>
-
- <div class="form-group">
- {{ Form::label('submit', '&nbsp;', ['class' => 'col-sm-4 control-label'])}}
- <div class="col-sm-8">
- <input type="submit" name="submit" value="Update envelope" class="btn btn-success"/>
-
- </div>
- </div>
-
- </div>
- @if($limit->repeats == 1)
- <div class="col-lg-6 col-md-6 col-sm-12">
- <h4>Auto repeating</h4>
- <p class="text-info">
- This envelope is set to repeat itself; creating a new period whenever the previous period
- has passed. If you change this envelope, you'll also change the following (automatically created)
- envelopes.
- {{$limit->limitrepetitions()->count() }}
- </p>
- <ul>
- @foreach($limit->limitrepetitions()->orderBy('startdate','DESC')->get() as $rep)
- <li>Evenlope for {{$rep->periodShow()}}, {{mf($rep->amount,false)}}</li>
- @endforeach
- </ul>
- </div>
- @endif
-</div>
-
-{{Form::close()}}
-
-
-@stop
diff --git a/app/views/list/recurring.blade.php b/app/views/list/recurring.blade.php
index 7edf6d4e46..624914c97f 100644
--- a/app/views/list/recurring.blade.php
+++ b/app/views/list/recurring.blade.php
@@ -32,10 +32,20 @@
{{mf($entry->amount_max)}}
</td>
<td>
- <!-- TODO -->
+ <?php $lastMatch = $entry->lastFoundMatch();?>
+ @if($lastMatch)
+ {{$lastMatch->format('j F Y')}}
+ @else
+ <em>Unknown</em>
+ @endif
</td>
<td>
- <!-- TODO -->
+ <?php $nextExpectedMatch = $entry->nextExpectedMatch();?>
+ @if($nextExpectedMatch)
+ {{$nextExpectedMatch->format('j F Y')}}
+ @else
+ <em>Unknown</em>
+ @endif
</td>
<td>
@if($entry->active)
diff --git a/app/views/lists.old/journals-large.old.blade.php b/app/views/lists.old/journals-large.old.blade.php
deleted file mode 100644
index 8ff26bcad0..0000000000
--- a/app/views/lists.old/journals-large.old.blade.php
+++ /dev/null
@@ -1,63 +0,0 @@
-<table class="table">
- <tr>
- <th></th>
- </tr>
- @foreach($journals as $journal)
- <tr>
- <td>
- @if($journal->transactiontype->type == 'Withdrawal')
- <span class="glyphicon glyphicon-arrow-left" title="Withdrawal"></span>
- @endif
- @if($journal->transactiontype->type == 'Deposit')
- <span class="glyphicon glyphicon-arrow-right" title="Deposit"></span>
- @endif
- @if($journal->transactiontype->type == 'Transfer')
- <span class="glyphicon glyphicon-resize-full" title="Transfer"></span>
- @endif
- @if($journal->transactiontype->type == 'Opening balance')
- <span class="glyphicon glyphicon-ban-circle" title="Opening balance"></span>
- @endif
- </td>
- <td>
- bud / cat
- </td>
- <td><a href="#" title="{{{$journal->description}}}">{{{$journal->description}}}</a></td>
- <td>
- @if($journal->transactiontype->type == 'Withdrawal')
- <span class="text-danger">{{mf($journal->transactions[1]->amount,false)}}</span>
- @endif
- @if($journal->transactiontype->type == 'Deposit')
- <span class="text-success">{{mf($journal->transactions[1]->amount,false)}}</span>
- @endif
- @if($journal->transactiontype->type == 'Transfer')
- <span class="text-info">{{mf($journal->transactions[1]->amount,false)}}</span>
- @endif
- </td>
- <td>
- @if($journal->transactions[0]->account->accounttype->description == 'Cash account')
- <span class="text-success">(cash)</span>
- @else
- <a href="#">{{{$journal->transactions[0]->account->name}}}</a>
- @endif
- </td>
- <td>
- @if($journal->transactions[1]->account->accounttype->description == 'Cash account')
- <span class="text-success">(cash)</span>
- @else
- <a href="#">{{{$journal->transactions[1]->account->name}}}</a>
- @endif
- </td>
- <td>
- <div class="btn-group btn-group-xs">
- <a href="{{route('transactions.edit',$journal->id)}}" class="btn btn-default">
- <span class="glyphicon glyphicon-pencil"></span>
- <a href="{{route('transactions.delete',$journal->id)}}" class="btn btn-danger">
- <span class="glyphicon glyphicon-trash"></span>
- </a>
- </div>
- </td>
- </tr>
- @endforeach
-</table>
-
-{{$journals->links()}}
\ No newline at end of file
diff --git a/app/views/lists.old/journals-small-index.old.blade.php b/app/views/lists.old/journals-small-index.old.blade.php
deleted file mode 100644
index e8e5be5a4f..0000000000
--- a/app/views/lists.old/journals-small-index.old.blade.php
+++ /dev/null
@@ -1,27 +0,0 @@
-<div class="list-group">
-@foreach($transactions as $journal)
-<a class="list-group-item" title="{{$journal->date->format('jS M Y')}}" href="{{route('transactions.show',$journal->id)}}">
-
- @if($journal->transactiontype->type == 'Withdrawal')
- <i class="fa fa-long-arrow-left fa-fw" title="Withdrawal"></i>
- @endif
- @if($journal->transactiontype->type == 'Deposit')
- <i class="fa fa-long-arrow-right fa-fw" title="Deposit"></i>
- @endif
- @if($journal->transactiontype->type == 'Transfer')
- <i class="fa fa-arrows-h fa-fw" title="Transfer"></i>
- @endif
-
- {{{$journal->description}}}
-
-<span class="pull-right small">
- @foreach($journal->transactions as $t)
- @if($t->account_id == $account->id)
- {{mf($t->amount)}}
- @endif
- @endforeach
-</span>
-
-</a>
-@endforeach
-</div>
\ No newline at end of file
diff --git a/app/views/lists.old/journals-small-noaccount.old.blade.php b/app/views/lists.old/journals-small-noaccount.old.blade.php
deleted file mode 100644
index 0cb8c04855..0000000000
--- a/app/views/lists.old/journals-small-noaccount.old.blade.php
+++ /dev/null
@@ -1,33 +0,0 @@
-<div class="list-group">
-@foreach($transactions as $journal)
-<a class="list-group-item" title="{{$journal->date->format('jS M Y')}}" href="{{route('transactions.show',$journal->id)}}">
-
- @if($journal->transactiontype->type == 'Withdrawal')
- <i class="fa fa-long-arrow-left fa-fw" title="Withdrawal"></i>
- @endif
- @if($journal->transactiontype->type == 'Deposit')
- <i class="fa fa-long-arrow-right fa-fw" title="Deposit"></i>
- @endif
- @if($journal->transactiontype->type == 'Transfer')
- <i class="fa fa-arrows-h fa-fw" title="Transfer"></i>
- @endif
-
- {{{$journal->description}}}
-
-<span class="pull-right small">
- @foreach($journal->transactions as $t)
- @if($journal->transactiontype->type == 'Withdrawal' && $t->amount < 0)
- {{mf($t->amount)}}
- @endif
- @if($journal->transactiontype->type == 'Deposit' && $t->amount > 0)
- {{mf($t->amount)}}
- @endif
- @if($journal->transactiontype->type == 'Transfer' && $t->amount > 0)
- {{mf($t->amount)}}
- @endif
- @endforeach
-</span>
-
-</a>
-@endforeach
-</div>
\ No newline at end of file
diff --git a/app/views/lists.old/transactions.old.blade.php b/app/views/lists.old/transactions.old.blade.php
deleted file mode 100644
index ceb0f54757..0000000000
--- a/app/views/lists.old/transactions.old.blade.php
+++ /dev/null
@@ -1,120 +0,0 @@
-<table class="table table-striped table-condensed" id="transactionTable">
-<thead>
- <tr>
- <th colspan="2" id="empty1">A</th>
- <th>Date</th><!-- TODO remove me-->
- <th>Description</th>
- <th>Amount (&euro;)</th>
- <th>From</th>
- <th>To</th>
- <th id="empty2">B</th>
- </tr>
- </thead>
- <?php $expenses = 0;$incomes = 0;$transfers = 0; ?>
- @foreach($journals as $journal)
- @if(isset($journal->transactions[0]) && isset($journal->transactions[1]))
- <tr
- @if(isset($highlight) && $highlight == $journal->id)
- class="success"
- @endif
- >
- <td>
- @if($journal->transactiontype->type == 'Withdrawal')
- <span class="glyphicon glyphicon-arrow-left" title="Withdrawal"></span>
- @endif
- @if($journal->transactiontype->type == 'Deposit')
- <span class="glyphicon glyphicon-arrow-right" title="Deposit"></span>
- @endif
- @if($journal->transactiontype->type == 'Transfer')
- <span class="glyphicon glyphicon-resize-full" title="Transfer"></span>
- @endif
- @if($journal->transactiontype->type == 'Opening balance')
- <span class="glyphicon glyphicon-ban-circle" title="Opening balance"></span>
- @endif
- </td>
- <td>
- @foreach($journal->components as $component)
- @if($component->class == 'Budget')
- <a href="{{route('budgets.show',$component->id)}}?highlight={{$journal->id}}"><span class="glyphicon glyphicon-tasks" title="Budget: {{{$component->name}}}"></span></a>
- @endif
- @if($component->class == 'Category')
- <a href="{{route('categories.show',$component->id)}}?highlight={{$journal->id}}"><span class="glyphicon glyphicon-tag" title="Category: {{{$component->name}}}"></span></a>
- @endif
- @endforeach
- <!-- recurring transaction -->
- @if(!is_null($journal->recurringTransaction))
- <a href="{{route('recurring.show',$journal->recurring_transaction_id)}}" title="{{{$journal->recurringTransaction->name}}}"><span title="{{{$journal->recurringTransaction->name}}}" class="glyphicon glyphicon-refresh"></span></a>
- @endif
- </td>
- <td>
- {{$journal->date->format('d F Y')}}
- </td>
- <td><a href="{{route('transactions.show',$journal->id)}}" title="{{{$journal->description}}}">{{{$journal->description}}}</a></td>
- <td>
- @if($journal->transactiontype->type == 'Withdrawal')
- <span class="text-danger">{{mf($journal->transactions[1]->amount,false)}}</span>
- <?php $expenses -= $journal->transactions[1]->amount;?>
- @endif
- @if($journal->transactiontype->type == 'Deposit')
- <span class="text-success">{{mf($journal->transactions[1]->amount,false)}}</span>
- <?php $incomes += $journal->transactions[1]->amount;?>
- @endif
- @if($journal->transactiontype->type == 'Transfer')
- <span class="text-info">{{mf($journal->transactions[1]->amount,false)}}</span>
- <?php $transfers += $journal->transactions[1]->amount;?>
- @endif
- </td>
- <td>
- <a href="{{route('accounts.show',$journal->transactions[0]->account_id)}}">{{{$journal->transactions[0]->account->name}}}</a>
- </td>
- <td>
- <a href="{{route('accounts.show',$journal->transactions[1]->account_id)}}">{{{$journal->transactions[1]->account->name}}}</a>
- </td>
- <td>
- @if($journal->transactiontype->type != 'Opening balance')
- <div class="btn-group btn-group-xs">
- <a href="{{route('transactions.edit',$journal->id)}}" class="btn btn-default">
- <span class="glyphicon glyphicon-pencil"></span>
- <a href="{{route('transactions.delete',$journal->id)}}" class="btn btn-danger">
- <span class="glyphicon glyphicon-trash"></span>
- </a>
- </div>
- @endif
- </td>
- </tr>
- @else
- <!--
- <tr class="danger">
- <td colspan="7">Invalid data found. Please delete this transaction and recreate it.</td>
- <td>
- <a href="{{route('transactions.delete',$journal->id)}}" class="btn btn-danger btn-xs">
- <span class="glyphicon glyphicon-trash"></span>
- </a>
- </td>
- </tr>
- -->
- @endif
- @endforeach
- @if(isset($sum) && $sum == true)
- @if($expenses != 0)
- <tr>
- <td colspan="4">Expenses:</td>
- <td colspan="4">{{mf($expenses)}}</td>
- </tr>
- @endif
- @if($incomes != 0)
- <tr>
- <td colspan="4">Incomes:</td>
- <td colspan="4">{{mf($incomes)}}</td>
- </tr>
- @endif
- @if($transfers != 0)
- <tr>
- <td colspan="4">Transfers:</td>
- <td colspan="4" class="text-info">{{mf($transfers,false)}}</td>
- </tr>
- @endif
- @endif
-
-
-</table>
\ No newline at end of file
diff --git a/app/views/paginated/transactions.blade.php b/app/views/paginated/transactions.blade.php
deleted file mode 100644
index 223541781e..0000000000
--- a/app/views/paginated/transactions.blade.php
+++ /dev/null
@@ -1,3 +0,0 @@
-{{$journals->links()}}
-@include('lists.transactions')
-{{$journals->links()}} <!-- TODO is this even used? -->
\ No newline at end of file
diff --git a/app/views/piggybanks/show.blade.php b/app/views/piggybanks/show.blade.php
index 4a6df0a352..813f8ed5db 100644
--- a/app/views/piggybanks/show.blade.php
+++ b/app/views/piggybanks/show.blade.php
@@ -8,7 +8,7 @@
<i class="fa fa-fw fa-clock-o"></i> Events
</div>
<div class="panel-body">
- <div id="piggybank-history"></div> <!-- TODO -->
+ <div id="piggybank-history"></div> <!-- TODO piggy bank events -->
</div>
</div>
@@ -30,11 +30,11 @@
</tr>
<tr>
<td>Saved so far</td>
- <td>{{mf(0)}}</td> <!-- TODO -->
+ <td>{{mf($piggybank->currentRelevantRep()->currentamount)}}</td>
</tr>
<tr>
<td>Left to save</td>
- <td>{{mf(0)}}</td> <!-- TODO -->
+ <td>{{mf($piggybank->targetamount-$piggybank->currentRelevantRep()->currentamount)}}</td>
</tr>
<tr>
<td>Start date</td>
@@ -72,11 +72,11 @@
</tr>
<tr>
<td>Reminders left</td>
- <td>12</td> <!-- TODO -->
+ <td>12</td> <!-- TODO piggy bank reminders-->
</tr>
<tr>
<td>Expected amount per reminder</td>
- <td>{{mf(0)}}</td> <!-- TODO -->
+ <td>{{mf(0)}}</td> <!-- TODO piggy bank reminder -->
</tr>
</table>
</div>
@@ -84,129 +84,6 @@
</div>
</div>
-
-{{--
-<div class="row">
- <div class="col-lg-12 col-md-12 col-sm-12">
- <div class="btn-group">
- <a href="{{route('piggybanks.edit',$piggybank->id)}}" class="btn btn-default"><span class="glyphicon glyphicon-pencil"></span> Edit</a>
- <a href="{{route('piggybanks.delete',$piggybank->id)}}" class="btn btn-danger"><span class="glyphicon glyphicon-trash"></span> Delete</a>
-
- @if(min(max($balance,$leftOnAccount),$piggybank->targetamount) > 0)
- <a data-toggle="modal" href="{{route('piggybanks.amount.add',$piggybank->id)}}" data-target="#modal" class="btn btn-default"><span class="glyphicon glyphicon-plus-sign"></span> Add money</a>
- @endif
-
- @if($piggybank->currentRelevantRep()->currentamount > 0)
- <a data-toggle="modal" href="{{route('piggybanks.amount.remove',$piggybank->id)}}" data-target="#modal" class="btn btn-default"><span class="glyphicon glyphicon-minus-sign"></span> Remove money</a>
- @endif
- </div>
- </div>
-</div><!-- TODO cleanup for new forms and layout. -->
-<div class="row">
- <div class="col-lg-6 col-md-6 col-sm-12">
- <h3>General information</h3>
- <table class="table table-bordered table-striped">
- <tr>
- <th>Field</th>
- <th>Value</th>
- </tr>
- <tr>
- <td>Account</td>
- <td><a href="{{route('accounts.show',$piggybank->account_id)}}">{{{$piggybank->account->name}}}</a></td>
- </tr>
- <tr>
- <td>Target amount</td>
- <td>{{mf($piggybank->targetamount)}}</td>
- </tr>
- <tr>
- <td>Start date</td>
- <td>
- @if(is_null($piggybank->startdate))
- <em>No start date</em>
- @else
- {{$piggybank->startdate->format('jS F Y')}}
- @endif
- </td>
- </tr>
- <tr>
- <td>Target date</td>
- <td>
- @if(is_null($piggybank->targetdate))
- <em>No target date</em>
- @else
- {{$piggybank->targetdate->format('jS F Y')}}
- @endif
- </td>
- </tr>
-
- <tr>
- <td>Repeats every</td>
- <td>
- @if(!is_null($piggybank->rep_length))
- Every {{$piggybank->rep_every}} {{$piggybank->rep_length}}(s)
- @if(!is_null($piggybank->rep_times))
- ({{$piggybank->rep_times}} times)
- @else
- (indefinitely)
- @endif
- @else
- <em>Does not repeat</em>
- @endif
- </td>
- </tr>
- <tr>
- <td>Reminder</td>
- <td>
- @if(is_null($piggybank->reminder))
- <em>(no reminder)</em>
- @else
- Every {{$piggybank->reminder_skip}} {{$piggybank->reminder}}(s)
- @endif
- </td>
- </tr>
- </table>
- </div>
- <div class="col-lg-6 col-md-6 col-sm-12">
- <h3>Piggy bank instances info</h3>
- @foreach($piggybank->piggybankrepetitions()->orderBy('startdate')->get() as $rep)
- <table class="table table-bordered table-striped">
- <tr>
- <th style="width:50%;">Field</th>
- <th>Value</th>
- </tr>
- <tr>
- <td>ID</td>
- <td>#{{$rep->id}}</td>
- </tr>
- <tr>
- <td>Current amount</td>
- <td>{{mf($rep->currentamount)}} of {{mf($piggybank->targetamount)}}</td>
- </tr>
- <tr>
- <td>Start date</td>
- <td>
- @if(is_null($rep->startdate))
- <em>No start date</em>
- @else
- {{$rep->startdate->format('jS F Y')}}
- @endif
- </td>
- </tr>
- <tr>
- <td>Target date</td>
- <td>
- @if(is_null($rep->targetdate))
- <em>No target date</em>
- @else
- {{$rep->targetdate->format('jS F Y')}}
- @endif
- </td>
- </tr>
- </table>
- @endforeach
- </div>
-</div>
---}}
@stop
@section('scripts')
diff --git a/app/views/recurring/show.blade.php b/app/views/recurring/show.blade.php
index 910aa69dea..a1f229b27d 100644
--- a/app/views/recurring/show.blade.php
+++ b/app/views/recurring/show.blade.php
@@ -46,8 +46,15 @@
</tr>
<tr>
- <td>Next reminder</td>
- <td>some date <!-- TODO --></td>
+ <td>Next expected match</td>
+ <td>
+ <?php $nextExpectedMatch = $recurring->nextExpectedMatch();?>
+ @if($nextExpectedMatch)
+ {{$nextExpectedMatch->format('j F Y')}}
+ @else
+ <em>Unknown</em>
+ @endif
+ </td>
</tr>
</table>
</div>
@@ -67,6 +74,19 @@
</div>
</div>
+<div class="row">
+ <div class="col-lg-12 col-sm-12 col-md-12">
+ <div class="panel panel-default">
+ <div class="panel-heading">
+ Chart
+ </div>
+ <div class="panel-body">
+ <!-- TODO chart with hits, grouped by repeat_freq and two lines with max/min amount -->
+ </div>
+ </div>
+ </div>
+</div>
+
<div class="row">
<div class="col-lg-12 col-sm-12 col-md-12">
<div class="panel panel-default">
diff --git a/app/views/search/index.blade.php b/app/views/search/index.blade.php
index c20ec700b7..c02339ef15 100644
--- a/app/views/search/index.blade.php
+++ b/app/views/search/index.blade.php
@@ -1,7 +1,7 @@
@extends('layouts.default')
@section('content')
@if(!is_null($query))
-<div class="row"><!-- TODO cleanup for new forms and layout and see if it actually still works. -->
+<div class="row">
@if(isset($result['transactions']) && $result['transactions']->count() > 0)
<div class="col-lg-6 col-md-12 col-sm-12">
<div class="panel panel-default">