mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-01-15 19:22:08 -06:00
Started work on recurring transactions controller. [skip ci]
This commit is contained in:
parent
5e809633e3
commit
23d69c0dd9
@ -1,7 +1,15 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use Firefly\Storage\RecurringTransaction\RecurringTransactionRepositoryInterface as RTR;
|
||||||
|
|
||||||
class RecurringController extends BaseController
|
class RecurringController extends BaseController
|
||||||
{
|
{
|
||||||
|
protected $_repository;
|
||||||
|
public function __construct(RTR $repository)
|
||||||
|
{
|
||||||
|
$this->_repository = $repository;
|
||||||
|
View::share('menu', 'home');
|
||||||
|
}
|
||||||
public function create()
|
public function create()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@ -20,6 +28,8 @@ class RecurringController extends BaseController
|
|||||||
|
|
||||||
public function index()
|
public function index()
|
||||||
{
|
{
|
||||||
|
$list = $this->_repository->get();
|
||||||
|
return View::make('recurring.index');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function show()
|
public function show()
|
||||||
|
@ -18,10 +18,15 @@ class CreateRecurringTransactionsTable extends Migration {
|
|||||||
$table->timestamps();
|
$table->timestamps();
|
||||||
$table->integer('user_id')->unsigned();
|
$table->integer('user_id')->unsigned();
|
||||||
$table->string('name',50);
|
$table->string('name',50);
|
||||||
|
$table->string('match',255);
|
||||||
$table->decimal('amount_max',10,2);
|
$table->decimal('amount_max',10,2);
|
||||||
$table->decimal('amount_min',10,2);
|
$table->decimal('amount_min',10,2);
|
||||||
|
$table->date('date');
|
||||||
$table->boolean('active');
|
$table->boolean('active');
|
||||||
|
|
||||||
|
$table->boolean('automatch');
|
||||||
$table->enum('repeat_freq', ['daily', 'weekly','monthly','quarterly','half-year','yearly']);
|
$table->enum('repeat_freq', ['daily', 'weekly','monthly','quarterly','half-year','yearly']);
|
||||||
|
$table->smallInteger('skip')->unsigned();
|
||||||
|
|
||||||
$table->unique(['user_id','name']);
|
$table->unique(['user_id','name']);
|
||||||
|
|
||||||
|
@ -17,6 +17,7 @@ class RecurringTransactionsToComponents extends Migration {
|
|||||||
$table->increments('id');
|
$table->increments('id');
|
||||||
$table->integer('component_id')->unsigned();
|
$table->integer('component_id')->unsigned();
|
||||||
$table->integer('recurring_transaction_id')->unsigned();
|
$table->integer('recurring_transaction_id')->unsigned();
|
||||||
|
$table->boolean('optional');
|
||||||
|
|
||||||
// link components with component_id
|
// link components with component_id
|
||||||
$table->foreign('component_id')
|
$table->foreign('component_id')
|
||||||
|
@ -0,0 +1,15 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
|
||||||
|
namespace Firefly\Storage\RecurringTransaction;
|
||||||
|
|
||||||
|
use Carbon\Carbon;
|
||||||
|
|
||||||
|
class EloquentRecurringTransactionRepository implements RecurringTransactionRepositoryInterface
|
||||||
|
{
|
||||||
|
|
||||||
|
public function get() {
|
||||||
|
return \Auth::user()->recurringtransactions()->get();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,13 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
|
||||||
|
namespace Firefly\Storage\RecurringTransaction;
|
||||||
|
|
||||||
|
|
||||||
|
interface RecurringTransactionRepositoryInterface
|
||||||
|
{
|
||||||
|
|
||||||
|
public function get();
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -31,6 +31,11 @@ class StorageServiceProvider extends ServiceProvider
|
|||||||
'Firefly\Storage\Piggybank\EloquentPiggybankRepository'
|
'Firefly\Storage\Piggybank\EloquentPiggybankRepository'
|
||||||
);
|
);
|
||||||
|
|
||||||
|
$this->app->bind(
|
||||||
|
'Firefly\Storage\RecurringTransaction\RecurringTransactionRepositoryInterface',
|
||||||
|
'Firefly\Storage\RecurringTransaction\EloquentRecurringTransactionRepository'
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
$this->app->bind(
|
$this->app->bind(
|
||||||
'Firefly\Storage\Account\AccountRepositoryInterface',
|
'Firefly\Storage\Account\AccountRepositoryInterface',
|
||||||
|
33
app/models/RecurringTransaction.php
Normal file
33
app/models/RecurringTransaction.php
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
<?php
|
||||||
|
use LaravelBook\Ardent\Ardent;
|
||||||
|
|
||||||
|
class RecurringTransaction extends Ardent
|
||||||
|
{
|
||||||
|
|
||||||
|
public static $rules
|
||||||
|
= [
|
||||||
|
'user_id' => 'required|exists:users,id',
|
||||||
|
'name' => 'required|between:1,255',
|
||||||
|
'match' => 'required',
|
||||||
|
'amount_max' => 'required|between:0,65536',
|
||||||
|
'amount_min' => 'required|between:0,65536',
|
||||||
|
'date' => 'required|date',
|
||||||
|
'active' => 'required|between:0,1',
|
||||||
|
'automatch' => 'required|between:0,1',
|
||||||
|
'repeat_freq' => 'required|in:daily,weekly,monthly,quarterly,half-year,yearly',
|
||||||
|
'skip' => 'required|between:0,31',
|
||||||
|
];
|
||||||
|
|
||||||
|
public static $factory
|
||||||
|
= [
|
||||||
|
'user_id' => 'factory|User',
|
||||||
|
'name' => 'string',
|
||||||
|
'data' => 'string'
|
||||||
|
];
|
||||||
|
|
||||||
|
public function user()
|
||||||
|
{
|
||||||
|
return $this->belongsTo('User');
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -73,6 +73,11 @@ class User extends Ardent implements UserInterface, RemindableInterface
|
|||||||
return $this->hasMany('Account');
|
return $this->hasMany('Account');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function recurringtransactions()
|
||||||
|
{
|
||||||
|
return $this->hasMany('RecurringTransaction');
|
||||||
|
}
|
||||||
|
|
||||||
public function piggybanks()
|
public function piggybanks()
|
||||||
{
|
{
|
||||||
return $this->hasMany('Piggybank');
|
return $this->hasMany('Piggybank');
|
||||||
|
@ -110,10 +110,14 @@ Route::group(['before' => 'auth'], function () {
|
|||||||
Route::get('/', ['uses' => 'HomeController@index', 'as' => 'index']);
|
Route::get('/', ['uses' => 'HomeController@index', 'as' => 'index']);
|
||||||
Route::get('/flush', ['uses' => 'HomeController@flush', 'as' => 'flush']);
|
Route::get('/flush', ['uses' => 'HomeController@flush', 'as' => 'flush']);
|
||||||
|
|
||||||
|
// JSON controller:
|
||||||
|
Route::get('/json/beneficiaries', ['uses' => 'JsonController@beneficiaries', 'as' => 'json.beneficiaries']);
|
||||||
|
Route::get('/json/categories', ['uses' => 'JsonController@categories', 'as' => 'json.categories']);
|
||||||
|
|
||||||
|
// limit controller:
|
||||||
// Categories controller:
|
Route::get('/budgets/limits/create/{budget?}',['uses' => 'LimitController@create','as' => 'budgets.limits.create']);
|
||||||
|
Route::get('/budgets/limits/delete/{limit}',['uses' => 'LimitController@delete','as' => 'budgets.limits.delete']);
|
||||||
|
Route::get('/budgets/limits/edit/{limit}',['uses' => 'LimitController@edit','as' => 'budgets.limits.edit']);
|
||||||
|
|
||||||
// piggy bank controller
|
// piggy bank controller
|
||||||
Route::get('/piggybanks',['uses' => 'PiggybankController@index','as' => 'piggybanks.index']);
|
Route::get('/piggybanks',['uses' => 'PiggybankController@index','as' => 'piggybanks.index']);
|
||||||
@ -126,26 +130,12 @@ Route::group(['before' => 'auth'], function () {
|
|||||||
// preferences controller
|
// preferences controller
|
||||||
Route::get('/preferences', ['uses' => 'PreferencesController@index', 'as' => 'preferences']);
|
Route::get('/preferences', ['uses' => 'PreferencesController@index', 'as' => 'preferences']);
|
||||||
|
|
||||||
// user controller
|
|
||||||
Route::get('/logout', ['uses' => 'UserController@logout', 'as' => 'logout']);
|
|
||||||
|
|
||||||
//profile controller
|
//profile controller
|
||||||
Route::get('/profile', ['uses' => 'ProfileController@index', 'as' => 'profile']);
|
Route::get('/profile', ['uses' => 'ProfileController@index', 'as' => 'profile']);
|
||||||
Route::get('/profile/change-password',['uses' => 'ProfileController@changePassword', 'as' => 'change-password']);
|
Route::get('/profile/change-password',['uses' => 'ProfileController@changePassword', 'as' => 'change-password']);
|
||||||
|
|
||||||
|
// recurring transactions controller
|
||||||
|
Route::get('/recurring',['uses' => 'RecurringController@index', 'as' => 'recurring.index']);
|
||||||
|
|
||||||
|
|
||||||
// limit controller:
|
|
||||||
Route::get('/budgets/limits/create/{budget?}',['uses' => 'LimitController@create','as' => 'budgets.limits.create']);
|
|
||||||
Route::get('/budgets/limits/delete/{limit}',['uses' => 'LimitController@delete','as' => 'budgets.limits.delete']);
|
|
||||||
Route::get('/budgets/limits/edit/{limit}',['uses' => 'LimitController@edit','as' => 'budgets.limits.edit']);
|
|
||||||
|
|
||||||
// JSON controller:
|
|
||||||
Route::get('/json/beneficiaries', ['uses' => 'JsonController@beneficiaries', 'as' => 'json.beneficiaries']);
|
|
||||||
Route::get('/json/categories', ['uses' => 'JsonController@categories', 'as' => 'json.categories']);
|
|
||||||
|
|
||||||
|
|
||||||
// transaction controller:
|
// transaction controller:
|
||||||
Route::get('/transactions/create/{what}', ['uses' => 'TransactionController@create', 'as' => 'transactions.create'])->where(['what' => 'withdrawal|deposit|transfer']);
|
Route::get('/transactions/create/{what}', ['uses' => 'TransactionController@create', 'as' => 'transactions.create'])->where(['what' => 'withdrawal|deposit|transfer']);
|
||||||
@ -154,6 +144,9 @@ Route::group(['before' => 'auth'], function () {
|
|||||||
Route::get('/transaction/delete/{tj}',['uses' => 'TransactionController@delete','as' => 'transactions.delete']);
|
Route::get('/transaction/delete/{tj}',['uses' => 'TransactionController@delete','as' => 'transactions.delete']);
|
||||||
Route::get('/transactions/index',['uses' => 'TransactionController@index','as' => 'transactions.index']);
|
Route::get('/transactions/index',['uses' => 'TransactionController@index','as' => 'transactions.index']);
|
||||||
|
|
||||||
|
// user controller
|
||||||
|
Route::get('/logout', ['uses' => 'UserController@logout', 'as' => 'logout']);
|
||||||
|
|
||||||
// migration controller
|
// migration controller
|
||||||
Route::get('/migrate', ['uses' => 'MigrationController@index', 'as' => 'migrate']);
|
Route::get('/migrate', ['uses' => 'MigrationController@index', 'as' => 'migrate']);
|
||||||
|
|
||||||
@ -177,43 +170,39 @@ Route::group(['before' => 'csrf|auth'], function () {
|
|||||||
Route::post('/categories/update/{category}', ['uses' => 'CategoryController@update', 'as' => 'categories.update']);
|
Route::post('/categories/update/{category}', ['uses' => 'CategoryController@update', 'as' => 'categories.update']);
|
||||||
Route::post('/categories/destroy/{category}', ['uses' => 'CategoryController@destroy', 'as' => 'categories.destroy']);
|
Route::post('/categories/destroy/{category}', ['uses' => 'CategoryController@destroy', 'as' => 'categories.destroy']);
|
||||||
|
|
||||||
// profile controller
|
// limit controller:
|
||||||
Route::post('/profile/change-password', ['uses' => 'ProfileController@postChangePassword']);
|
Route::post('/budgets/limits/store/{budget?}', ['uses' => 'LimitController@store', 'as' => 'budgets.limits.store']);
|
||||||
|
Route::post('/budgets/limits/destroy/{id?}',['uses' => 'LimitController@destroy','as' => 'budgets.limits.destroy']);
|
||||||
|
Route::post('/budgets/limits/update/{id?}',['uses' => 'LimitController@update','as' => 'budgets.limits.update']);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// migration controller
|
|
||||||
Route::post('/migrate', ['uses' => 'MigrationController@postIndex']);
|
|
||||||
|
|
||||||
// piggy bank controller
|
// piggy bank controller
|
||||||
Route::post('/piggybanks/store',['uses' => 'PiggybankController@store','as' => 'piggybanks.store']);
|
Route::post('/piggybanks/store',['uses' => 'PiggybankController@store','as' => 'piggybanks.store']);
|
||||||
Route::post('/piggybanks/update', ['uses' => 'PiggybankController@update','as' => 'piggybanks.update']);
|
Route::post('/piggybanks/update', ['uses' => 'PiggybankController@update','as' => 'piggybanks.update']);
|
||||||
Route::post('/piggybanks/destroy/{piggybank}', ['uses' => 'PiggybankController@destroy','as' => 'piggybanks.destroy']);
|
Route::post('/piggybanks/destroy/{piggybank}', ['uses' => 'PiggybankController@destroy','as' => 'piggybanks.destroy']);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// preferences controller
|
// preferences controller
|
||||||
Route::post('/preferences', ['uses' => 'PreferencesController@postIndex']);
|
Route::post('/preferences', ['uses' => 'PreferencesController@postIndex']);
|
||||||
|
|
||||||
|
// profile controller
|
||||||
// limit controller:
|
Route::post('/profile/change-password', ['uses' => 'ProfileController@postChangePassword']);
|
||||||
Route::post('/budgets/limits/store/{budget?}', ['uses' => 'LimitController@store', 'as' => 'budgets.limits.store']);
|
|
||||||
Route::post('/budgets/limits/destroy/{id?}',['uses' => 'LimitController@destroy','as' => 'budgets.limits.destroy']);
|
|
||||||
Route::post('/budgets/limits/update/{id?}',['uses' => 'LimitController@update','as' => 'budgets.limits.update']);
|
|
||||||
|
|
||||||
// transaction controller:
|
// transaction controller:
|
||||||
Route::post('/transactions/store/{what}', ['uses' => 'TransactionController@store', 'as' => 'transactions.store'])
|
Route::post('/transactions/store/{what}', ['uses' => 'TransactionController@store', 'as' => 'transactions.store'])->where(['what' => 'withdrawal|deposit|transfer']);
|
||||||
->where(['what' => 'withdrawal|deposit|transfer']);
|
|
||||||
Route::post('/transaction/update/{tj}',['uses' => 'TransactionController@update','as' => 'transactions.update']);
|
Route::post('/transaction/update/{tj}',['uses' => 'TransactionController@update','as' => 'transactions.update']);
|
||||||
Route::post('/transaction/destroy/{tj}',['uses' => 'TransactionController@destroy','as' => 'transactions.destroy']);
|
Route::post('/transaction/destroy/{tj}',['uses' => 'TransactionController@destroy','as' => 'transactions.destroy']);
|
||||||
|
|
||||||
|
// migration controller
|
||||||
|
Route::post('/migrate', ['uses' => 'MigrationController@postIndex']);
|
||||||
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
// guest routes:
|
// guest routes:
|
||||||
Route::group(['before' => 'guest'], function () {
|
Route::group(['before' => 'guest'], function () {
|
||||||
|
// dev import route:
|
||||||
|
Route::get('/dev',['uses' => 'MigrationController@dev']);
|
||||||
|
|
||||||
// user controller
|
// user controller
|
||||||
Route::get('/login', ['uses' => 'UserController@login', 'as' => 'login']);
|
Route::get('/login', ['uses' => 'UserController@login', 'as' => 'login']);
|
||||||
Route::get('/register', ['uses' => 'UserController@register', 'as' => 'register']);
|
Route::get('/register', ['uses' => 'UserController@register', 'as' => 'register']);
|
||||||
@ -221,9 +210,7 @@ Route::group(['before' => 'guest'], function () {
|
|||||||
Route::get('/reset/{reset}', ['uses' => 'UserController@reset', 'as' => 'reset']);
|
Route::get('/reset/{reset}', ['uses' => 'UserController@reset', 'as' => 'reset']);
|
||||||
Route::get('/remindme', ['uses' => 'UserController@remindme', 'as' => 'remindme']);
|
Route::get('/remindme', ['uses' => 'UserController@remindme', 'as' => 'remindme']);
|
||||||
|
|
||||||
// dev import route:
|
|
||||||
Route::get('/dev',['uses' => 'MigrationController@dev']);
|
|
||||||
Route::get('/limit',['uses' => 'MigrationController@limit']);
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -27,6 +27,7 @@ $r = Route::current()->getName();
|
|||||||
|
|
||||||
<li class="divider"></li>
|
<li class="divider"></li>
|
||||||
<li><a href="{{route('transactions.index')}}"><span class="glyphicon glyphicon-list-alt"></span> Transactions</a></li>
|
<li><a href="{{route('transactions.index')}}"><span class="glyphicon glyphicon-list-alt"></span> Transactions</a></li>
|
||||||
|
<li><a href="{{route('recurring.index')}}"><span class="glyphicon glyphicon-refresh"></span> Recurring transactions</a></li>
|
||||||
|
|
||||||
<li class="divider"></li>
|
<li class="divider"></li>
|
||||||
<li><a href="{{route('piggybanks.index')}}"><span class="glyphicon glyphicon-save"></span> Piggy banks</a></li>
|
<li><a href="{{route('piggybanks.index')}}"><span class="glyphicon glyphicon-save"></span> Piggy banks</a></li>
|
||||||
|
31
app/views/recurring/index.blade.php
Normal file
31
app/views/recurring/index.blade.php
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
@extends('layouts.default')
|
||||||
|
@section('content')
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-lg-12 col-md-12 col-sm-12">
|
||||||
|
<h1>Firefly
|
||||||
|
<small>Recurring transactions</small>
|
||||||
|
</h1>
|
||||||
|
<p class="text-info">We all have bills to pay. Firefly can help you organize those bills into recurring transactions,
|
||||||
|
which are exactly what the name suggests. Firefly can match new (and existing) transactions to such a recurring transaction
|
||||||
|
and help you organize these expenses into manageable groups. The front page of Firefly will show you which recurring
|
||||||
|
transactions you have missed, which are yet to come and which have been paid.</p>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-lg-12 col-sm-12 col-md-12">
|
||||||
|
<table class="table table-striped">
|
||||||
|
<tr>
|
||||||
|
<th>Name</th>
|
||||||
|
<th>Matches on</th>
|
||||||
|
<th>Amount between</th>
|
||||||
|
<th>Expected every</th>
|
||||||
|
<th>Next expected match</th>
|
||||||
|
<th>Automatch</th>
|
||||||
|
<th>Active</th>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
@stop
|
@ -1,3 +1,4 @@
|
|||||||
|
REM composer self-update
|
||||||
composer update
|
composer update
|
||||||
php artisan clear-compiled --env=local
|
php artisan clear-compiled --env=local
|
||||||
php artisan ide-helper:generate --env=local
|
php artisan ide-helper:generate --env=local
|
||||||
|
Loading…
Reference in New Issue
Block a user