mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-09-20 03:08:11 +00:00
This will be the first release!
This commit is contained in:
@@ -40,7 +40,9 @@ class AccountController extends \BaseController
|
|||||||
$accountType = $account->accountType()->first();
|
$accountType = $account->accountType()->first();
|
||||||
|
|
||||||
if ($accountType->description == 'Initial balance account' || $accountType->description == 'Cash account') {
|
if ($accountType->description == 'Initial balance account' || $accountType->description == 'Cash account') {
|
||||||
return \View::make('error')->with('message', 'Cannot edit this account type (' . $accountType->description . ').');
|
return \View::make('error')->with(
|
||||||
|
'message', 'Cannot edit this account type (' . $accountType->description . ').'
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return View::make('accounts.delete')->with('account', $account);
|
return View::make('accounts.delete')->with('account', $account);
|
||||||
@@ -56,7 +58,9 @@ class AccountController extends \BaseController
|
|||||||
$accountType = $account->accountType()->first();
|
$accountType = $account->accountType()->first();
|
||||||
|
|
||||||
if ($accountType->description == 'Initial balance account' || $accountType->description == 'Cash account') {
|
if ($accountType->description == 'Initial balance account' || $accountType->description == 'Cash account') {
|
||||||
return View::make('error')->with('message', 'Cannot edit this account type (' . $accountType->description . ').');
|
return View::make('error')->with(
|
||||||
|
'message', 'Cannot edit this account type (' . $accountType->description . ').'
|
||||||
|
);
|
||||||
}
|
}
|
||||||
$result = $this->_repository->destroy($account);
|
$result = $this->_repository->destroy($account);
|
||||||
if ($result === true) {
|
if ($result === true) {
|
||||||
@@ -79,7 +83,9 @@ class AccountController extends \BaseController
|
|||||||
$accountType = $account->accountType()->first();
|
$accountType = $account->accountType()->first();
|
||||||
|
|
||||||
if ($accountType->description == 'Initial balance account' || $accountType->description == 'Cash account') {
|
if ($accountType->description == 'Initial balance account' || $accountType->description == 'Cash account') {
|
||||||
return View::make('error')->with('message', 'Cannot edit this account type (' . $accountType->description . ').');
|
return View::make('error')->with(
|
||||||
|
'message', 'Cannot edit this account type (' . $accountType->description . ').'
|
||||||
|
);
|
||||||
}
|
}
|
||||||
$openingBalance = $this->_accounts->openingBalanceTransaction($account);
|
$openingBalance = $this->_accounts->openingBalanceTransaction($account);
|
||||||
|
|
||||||
@@ -106,7 +112,9 @@ class AccountController extends \BaseController
|
|||||||
{
|
{
|
||||||
$accountType = $account->accountType()->first();
|
$accountType = $account->accountType()->first();
|
||||||
if ($accountType->description == 'Initial balance account' || $accountType->description == 'Cash account') {
|
if ($accountType->description == 'Initial balance account' || $accountType->description == 'Cash account') {
|
||||||
return View::make('error')->with('message', 'Cannot show this account type (' . $accountType->description . ').');
|
return View::make('error')->with(
|
||||||
|
'message', 'Cannot show this account type (' . $accountType->description . ').'
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
$show = $this->_accounts->show($account, 40);
|
$show = $this->_accounts->show($account, 40);
|
||||||
@@ -148,7 +156,9 @@ class AccountController extends \BaseController
|
|||||||
{
|
{
|
||||||
$accountType = $account->accountType()->first();
|
$accountType = $account->accountType()->first();
|
||||||
if ($accountType->description == 'Initial balance account' || $accountType->description == 'Cash account') {
|
if ($accountType->description == 'Initial balance account' || $accountType->description == 'Cash account') {
|
||||||
return View::make('error')->with('message', 'Cannot show this account type (' . $accountType->description . ').');
|
return View::make('error')->with(
|
||||||
|
'message', 'Cannot show this account type (' . $accountType->description . ').'
|
||||||
|
);
|
||||||
}
|
}
|
||||||
$account = $this->_repository->update($account, Input::all());
|
$account = $this->_repository->update($account, Input::all());
|
||||||
if ($account->validate()) {
|
if ($account->validate()) {
|
||||||
|
@@ -9,10 +9,12 @@ class BaseController extends Controller
|
|||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public function __construct() {
|
public function __construct()
|
||||||
|
{
|
||||||
\Event::fire('limits.check');
|
\Event::fire('limits.check');
|
||||||
\Event::fire('piggybanks.check');
|
\Event::fire('piggybanks.check');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Setup the layout used by the controller.
|
* Setup the layout used by the controller.
|
||||||
*
|
*
|
||||||
|
@@ -2,7 +2,7 @@
|
|||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use Firefly\Helper\Preferences\PreferencesHelperInterface as PHI;
|
use Firefly\Helper\Preferences\PreferencesHelperInterface as PHI;
|
||||||
use Firefly\Storage\Account\AccountRepositoryInterface as ARI;
|
use Firefly\Storage\Account\AccountRepositoryInterface as ARI;
|
||||||
use Firefly\Storage\Budget\BudgetRepositoryInterface as BRI;
|
use Firefly\Storage\Reminder\ReminderRepositoryInterface as RRI;
|
||||||
use Firefly\Storage\TransactionJournal\TransactionJournalRepositoryInterface as TJRI;
|
use Firefly\Storage\TransactionJournal\TransactionJournalRepositoryInterface as TJRI;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -13,20 +13,14 @@ class HomeController extends BaseController
|
|||||||
protected $_accounts;
|
protected $_accounts;
|
||||||
protected $_preferences;
|
protected $_preferences;
|
||||||
protected $_journal;
|
protected $_journal;
|
||||||
protected $_budgets;
|
protected $_reminders;
|
||||||
|
|
||||||
/**
|
public function __construct(ARI $accounts, PHI $preferences, TJRI $journal, RRI $reminders)
|
||||||
* @param ARI $accounts
|
|
||||||
* @param PHI $preferences
|
|
||||||
* @param TJRI $journal
|
|
||||||
* @param BRI $budgets
|
|
||||||
*/
|
|
||||||
public function __construct(ARI $accounts, PHI $preferences, TJRI $journal, BRI $budgets)
|
|
||||||
{
|
{
|
||||||
$this->_accounts = $accounts;
|
$this->_accounts = $accounts;
|
||||||
$this->_preferences = $preferences;
|
$this->_preferences = $preferences;
|
||||||
$this->_journal = $journal;
|
$this->_journal = $journal;
|
||||||
$this->_budgets = $budgets;
|
$this->_reminders = $reminders;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -47,7 +41,7 @@ class HomeController extends BaseController
|
|||||||
|
|
||||||
\Event::fire('limits.check');
|
\Event::fire('limits.check');
|
||||||
\Event::fire('piggybanks.check');
|
\Event::fire('piggybanks.check');
|
||||||
|
\Event::fire('recurring.check');
|
||||||
|
|
||||||
|
|
||||||
// count, maybe we need some introducing text to show:
|
// count, maybe we need some introducing text to show:
|
||||||
@@ -64,10 +58,9 @@ class HomeController extends BaseController
|
|||||||
$accounts = $this->_accounts->getByIds($frontpage->data);
|
$accounts = $this->_accounts->getByIds($frontpage->data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$transactions = [];
|
$transactions = [];
|
||||||
foreach ($accounts as $account) {
|
foreach ($accounts as $account) {
|
||||||
$set = $this->_journal->getByAccountInDateRange($account, 15, $start, $end);
|
$set = $this->_journal->getByAccountInDateRange($account, 10, $start, $end);
|
||||||
if (count($set) > 0) {
|
if (count($set) > 0) {
|
||||||
$transactions[] = [$set, $account];
|
$transactions[] = [$set, $account];
|
||||||
}
|
}
|
||||||
@@ -81,7 +74,13 @@ class HomeController extends BaseController
|
|||||||
$transactions = array_chunk($transactions, 3);
|
$transactions = array_chunk($transactions, 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// get the users reminders:
|
||||||
|
|
||||||
|
$reminders = $this->_reminders->getCurrentRecurringReminders();
|
||||||
|
|
||||||
// build the home screen:
|
// build the home screen:
|
||||||
return View::make('index')->with('count', $count)->with('transactions', $transactions);
|
return View::make('index')->with('count', $count)->with('transactions', $transactions)->with(
|
||||||
|
'reminders', $reminders
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -1,6 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
use Carbon\Carbon;
|
|
||||||
use Firefly\Storage\Account\AccountRepositoryInterface as ARI;
|
use Firefly\Storage\Account\AccountRepositoryInterface as ARI;
|
||||||
use Firefly\Storage\Budget\BudgetRepositoryInterface as Bud;
|
use Firefly\Storage\Budget\BudgetRepositoryInterface as Bud;
|
||||||
use Firefly\Storage\Category\CategoryRepositoryInterface as Cat;
|
use Firefly\Storage\Category\CategoryRepositoryInterface as Cat;
|
||||||
|
@@ -192,7 +192,11 @@ class PiggybankController extends BaseController
|
|||||||
*/
|
*/
|
||||||
public function show(Piggybank $piggyBank)
|
public function show(Piggybank $piggyBank)
|
||||||
{
|
{
|
||||||
return View::make('piggybanks.show')->with('piggyBank', $piggyBank);
|
$leftOnAccount = $this->_repository->leftOnAccount($piggyBank->account);
|
||||||
|
$balance = $piggyBank->account->balance();
|
||||||
|
|
||||||
|
return View::make('piggybanks.show')->with('piggyBank', $piggyBank)->with('leftOnAccount', $leftOnAccount)
|
||||||
|
->with('balance', $balance);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -44,6 +44,7 @@ class RecurringController extends BaseController
|
|||||||
*/
|
*/
|
||||||
public function destroy(RecurringTransaction $recurringTransaction)
|
public function destroy(RecurringTransaction $recurringTransaction)
|
||||||
{
|
{
|
||||||
|
Event::fire('recurring.destroy', [$recurringTransaction]);
|
||||||
$result = $this->_repository->destroy($recurringTransaction);
|
$result = $this->_repository->destroy($recurringTransaction);
|
||||||
if ($result === true) {
|
if ($result === true) {
|
||||||
Session::flash('success', 'The recurring transaction was deleted.');
|
Session::flash('success', 'The recurring transaction was deleted.');
|
||||||
@@ -96,6 +97,7 @@ class RecurringController extends BaseController
|
|||||||
$recurringTransaction = $this->_repository->store(Input::all());
|
$recurringTransaction = $this->_repository->store(Input::all());
|
||||||
if ($recurringTransaction->validate()) {
|
if ($recurringTransaction->validate()) {
|
||||||
Session::flash('success', 'Recurring transaction "' . $recurringTransaction->name . '" saved!');
|
Session::flash('success', 'Recurring transaction "' . $recurringTransaction->name . '" saved!');
|
||||||
|
Event::fire('recurring.store', [$recurringTransaction]);
|
||||||
if (Input::get('create') == '1') {
|
if (Input::get('create') == '1') {
|
||||||
return Redirect::route('recurring.create')->withInput();
|
return Redirect::route('recurring.create')->withInput();
|
||||||
} else {
|
} else {
|
||||||
@@ -119,6 +121,7 @@ class RecurringController extends BaseController
|
|||||||
$recurringTransaction = $this->_repository->update($recurringTransaction, Input::all());
|
$recurringTransaction = $this->_repository->update($recurringTransaction, Input::all());
|
||||||
if ($recurringTransaction->errors()->count() == 0) {
|
if ($recurringTransaction->errors()->count() == 0) {
|
||||||
Session::flash('success', 'The recurring transaction has been updated.');
|
Session::flash('success', 'The recurring transaction has been updated.');
|
||||||
|
Event::fire('recurring.update', [$recurringTransaction]);
|
||||||
|
|
||||||
return Redirect::route('recurring.index');
|
return Redirect::route('recurring.index');
|
||||||
} else {
|
} else {
|
||||||
|
@@ -194,9 +194,10 @@ class TransactionController extends BaseController
|
|||||||
$reminders = App::make('Firefly\Storage\Reminder\ReminderRepositoryInterface');
|
$reminders = App::make('Firefly\Storage\Reminder\ReminderRepositoryInterface');
|
||||||
$reminder = $reminders->find(Input::get('reminder'));
|
$reminder = $reminders->find(Input::get('reminder'));
|
||||||
$reminders->deactivate($reminder);
|
$reminders->deactivate($reminder);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// trigger the creation for recurring transactions.
|
||||||
|
|
||||||
if (Input::get('create') == '1') {
|
if (Input::get('create') == '1') {
|
||||||
return Redirect::route('transactions.create', [$what])->withInput();
|
return Redirect::route('transactions.create', [$what])->withInput();
|
||||||
} else {
|
} else {
|
||||||
|
@@ -1,9 +1,10 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
use Illuminate\Database\Schema\Blueprint;
|
|
||||||
use Illuminate\Database\Migrations\Migration;
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
|
||||||
class CreatePiggyEvents extends Migration {
|
class CreatePiggyEvents extends Migration
|
||||||
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Run the migrations.
|
* Run the migrations.
|
||||||
@@ -12,8 +13,8 @@ class CreatePiggyEvents extends Migration {
|
|||||||
*/
|
*/
|
||||||
public function up()
|
public function up()
|
||||||
{
|
{
|
||||||
Schema::create('piggybank_events', function(Blueprint $table)
|
Schema::create(
|
||||||
{
|
'piggybank_events', function (Blueprint $table) {
|
||||||
$table->increments('id');
|
$table->increments('id');
|
||||||
$table->timestamps();
|
$table->timestamps();
|
||||||
$table->integer('piggybank_id')->unsigned();
|
$table->integer('piggybank_id')->unsigned();
|
||||||
@@ -24,7 +25,8 @@ class CreatePiggyEvents extends Migration {
|
|||||||
$table->foreign('piggybank_id')
|
$table->foreign('piggybank_id')
|
||||||
->references('id')->on('piggybanks')
|
->references('id')->on('piggybanks')
|
||||||
->onDelete('cascade');
|
->onDelete('cascade');
|
||||||
});
|
}
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -1,9 +1,20 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
use Illuminate\Database\Schema\Blueprint;
|
|
||||||
use Illuminate\Database\Migrations\Migration;
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
|
||||||
class CreateRemindersTable extends Migration {
|
class CreateRemindersTable extends Migration
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::drop('reminders');
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Run the migrations.
|
* Run the migrations.
|
||||||
@@ -16,8 +27,9 @@ class CreateRemindersTable extends Migration {
|
|||||||
'reminders', function (Blueprint $table) {
|
'reminders', function (Blueprint $table) {
|
||||||
$table->increments('id');
|
$table->increments('id');
|
||||||
$table->timestamps();
|
$table->timestamps();
|
||||||
$table->string('class', 30);
|
$table->string('class', 40);
|
||||||
$table->integer('piggybank_id')->unsigned()->nullable();
|
$table->integer('piggybank_id')->unsigned()->nullable();
|
||||||
|
$table->integer('recurring_transaction_id')->unsigned()->nullable();
|
||||||
$table->integer('user_id')->unsigned();
|
$table->integer('user_id')->unsigned();
|
||||||
$table->date('startdate');
|
$table->date('startdate');
|
||||||
$table->date('enddate');
|
$table->date('enddate');
|
||||||
@@ -29,6 +41,12 @@ class CreateRemindersTable extends Migration {
|
|||||||
->references('id')->on('piggybanks')
|
->references('id')->on('piggybanks')
|
||||||
->onDelete('set null');
|
->onDelete('set null');
|
||||||
|
|
||||||
|
// connect reminders to recurring transactions.
|
||||||
|
$table->foreign('recurring_transaction_id')
|
||||||
|
->references('id')->on('recurring_transactions')
|
||||||
|
->onDelete('set null');
|
||||||
|
|
||||||
|
|
||||||
// connect reminders to users
|
// connect reminders to users
|
||||||
$table->foreign('user_id')
|
$table->foreign('user_id')
|
||||||
->references('id')->on('users')
|
->references('id')->on('users')
|
||||||
@@ -37,14 +55,4 @@ class CreateRemindersTable extends Migration {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Reverse the migrations.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function down()
|
|
||||||
{
|
|
||||||
Schema::drop('reminders');
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -29,6 +29,7 @@ interface BudgetInterface
|
|||||||
/**
|
/**
|
||||||
* @param \Budget $budget
|
* @param \Budget $budget
|
||||||
* @param bool $useSessionDates
|
* @param bool $useSessionDates
|
||||||
|
*
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
public function organizeRepetitions(\Budget $budget, $useSessionDates = false);
|
public function organizeRepetitions(\Budget $budget, $useSessionDates = false);
|
||||||
|
@@ -169,8 +169,8 @@ class Chart implements ChartInterface
|
|||||||
$amount = floatval($rep->amount);
|
$amount = floatval($rep->amount);
|
||||||
$spent = $rep->spent;
|
$spent = $rep->spent;
|
||||||
$color = $spent > $amount ? '#FF0000' : null;
|
$color = $spent > $amount ? '#FF0000' : null;
|
||||||
$data['series'][0]['data'][] = ['y' => $amount, 'id' => 'def'];
|
$data['series'][0]['data'][] = ['y' => $amount, 'id' => 'amount-' . $rep->id];
|
||||||
$data['series'][1]['data'][] = ['y' => $rep->spent, 'color' => $color, 'id' => 'abc'];
|
$data['series'][1]['data'][] = ['y' => $rep->spent, 'color' => $color, 'id' => 'spent-' . $rep->id];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -64,6 +64,29 @@ class Toolkit implements ToolkitInterface
|
|||||||
return [\Session::get('start'), \Session::get('end')];
|
return [\Session::get('start'), \Session::get('end')];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function getReminders()
|
||||||
|
{
|
||||||
|
// get reminders, for menu, mumble mumble:
|
||||||
|
$today = new Carbon;
|
||||||
|
$reminders = \Auth::user()->reminders()->where('class', 'PiggybankReminder')->validOn($today)->get();
|
||||||
|
|
||||||
|
/** @var \Reminder $reminder */
|
||||||
|
foreach ($reminders as $index => $reminder) {
|
||||||
|
if (\Session::has('dismissal-' . $reminder->id)) {
|
||||||
|
$time = \Session::get('dismissal-' . $reminder->id);
|
||||||
|
if ($time >= $today) {
|
||||||
|
unset($reminders[$index]);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
\Session::put('reminderCount', count($reminders));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
@@ -302,26 +325,4 @@ class Toolkit implements ToolkitInterface
|
|||||||
return $end;
|
return $end;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return mixed
|
|
||||||
*/
|
|
||||||
public function getReminders() {
|
|
||||||
// get reminders, for menu, mumble mumble:
|
|
||||||
$today = new Carbon;
|
|
||||||
$reminders = \Auth::user()->reminders()->validOn($today)->get();
|
|
||||||
|
|
||||||
/** @var \Reminder $reminder */
|
|
||||||
foreach($reminders as $index => $reminder) {
|
|
||||||
if(\Session::has('dismissal-' . $reminder->id)) {
|
|
||||||
$time = \Session::get('dismissal-' . $reminder->id);
|
|
||||||
if($time >= $today) {
|
|
||||||
unset($reminders[$index]);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
\Session::put('reminderCount',count($reminders));
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
@@ -29,6 +29,7 @@ class EloquentLimitRepository implements LimitRepositoryInterface
|
|||||||
/**
|
/**
|
||||||
* @param \Limit $limit
|
* @param \Limit $limit
|
||||||
* @param $data
|
* @param $data
|
||||||
|
*
|
||||||
* @return mixed|void
|
* @return mixed|void
|
||||||
*/
|
*/
|
||||||
public function update(\Limit $limit, $data)
|
public function update(\Limit $limit, $data)
|
||||||
@@ -39,6 +40,7 @@ class EloquentLimitRepository implements LimitRepositoryInterface
|
|||||||
$limit->amount = floatval($data['amount']);
|
$limit->amount = floatval($data['amount']);
|
||||||
|
|
||||||
$limit->save();
|
$limit->save();
|
||||||
|
|
||||||
return $limit;
|
return $limit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -22,6 +22,7 @@ interface LimitRepositoryInterface
|
|||||||
/**
|
/**
|
||||||
* @param \Limit $limit
|
* @param \Limit $limit
|
||||||
* @param $data
|
* @param $data
|
||||||
|
*
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
public function update(\Limit $limit, $data);
|
public function update(\Limit $limit, $data);
|
||||||
|
@@ -225,7 +225,6 @@ class EloquentPiggybankRepository implements PiggybankRepositoryInterface
|
|||||||
= isset($data['startdate']) && strlen($data['startdate']) > 0 ? new Carbon($data['startdate']) : null;
|
= isset($data['startdate']) && strlen($data['startdate']) > 0 ? new Carbon($data['startdate']) : null;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
foreach ($piggy->piggybankrepetitions()->get() as $rep) {
|
foreach ($piggy->piggybankrepetitions()->get() as $rep) {
|
||||||
$rep->delete();
|
$rep->delete();
|
||||||
}
|
}
|
||||||
|
@@ -69,9 +69,11 @@ class EloquentRecurringTransactionRepository implements RecurringTransactionRepo
|
|||||||
/**
|
/**
|
||||||
* @param \RecurringTransaction $recurringTransaction
|
* @param \RecurringTransaction $recurringTransaction
|
||||||
* @param $data
|
* @param $data
|
||||||
|
*
|
||||||
* @return mixed|void
|
* @return mixed|void
|
||||||
*/
|
*/
|
||||||
public function update(\RecurringTransaction $recurringTransaction, $data) {
|
public function update(\RecurringTransaction $recurringTransaction, $data)
|
||||||
|
{
|
||||||
$recurringTransaction->name = $data['name'];
|
$recurringTransaction->name = $data['name'];
|
||||||
$recurringTransaction->match = join(' ', explode(',', $data['match']));
|
$recurringTransaction->match = join(' ', explode(',', $data['match']));
|
||||||
$recurringTransaction->amount_max = floatval($data['amount_max']);
|
$recurringTransaction->amount_max = floatval($data['amount_max']);
|
||||||
|
@@ -33,6 +33,7 @@ interface RecurringTransactionRepositoryInterface
|
|||||||
/**
|
/**
|
||||||
* @param \RecurringTransaction $recurringTransaction
|
* @param \RecurringTransaction $recurringTransaction
|
||||||
* @param $data
|
* @param $data
|
||||||
|
*
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
public function update(\RecurringTransaction $recurringTransaction, $data);
|
public function update(\RecurringTransaction $recurringTransaction, $data);
|
||||||
|
@@ -45,4 +45,17 @@ class EloquentReminderRepository implements ReminderRepositoryInterface
|
|||||||
return \Auth::user()->reminders()->validOn($today)->get();
|
return \Auth::user()->reminders()->validOn($today)->get();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public function getCurrentRecurringReminders()
|
||||||
|
{
|
||||||
|
$today = new Carbon;
|
||||||
|
|
||||||
|
return \Auth::user()->reminders()->with('recurringtransaction')->validOn($today)->where(
|
||||||
|
'class', 'RecurringTransactionReminder'
|
||||||
|
)->get();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
@@ -14,7 +14,8 @@ namespace Firefly\Storage\Reminder;
|
|||||||
*
|
*
|
||||||
* @package Firefly\Storage\Reminder
|
* @package Firefly\Storage\Reminder
|
||||||
*/
|
*/
|
||||||
interface ReminderRepositoryInterface {
|
interface ReminderRepositoryInterface
|
||||||
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param \Reminder $reminder
|
* @param \Reminder $reminder
|
||||||
@@ -35,4 +36,7 @@ interface ReminderRepositoryInterface {
|
|||||||
*/
|
*/
|
||||||
public function find($id);
|
public function find($id);
|
||||||
|
|
||||||
|
|
||||||
|
public function getCurrentRecurringReminders();
|
||||||
|
|
||||||
}
|
}
|
127
app/lib/Firefly/Trigger/Recurring/EloquentRecurringTrigger.php
Normal file
127
app/lib/Firefly/Trigger/Recurring/EloquentRecurringTrigger.php
Normal file
@@ -0,0 +1,127 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Firefly\Trigger\Recurring;
|
||||||
|
|
||||||
|
use Carbon\Carbon;
|
||||||
|
use Illuminate\Events\Dispatcher;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class EloquentRecurringTrigger
|
||||||
|
*
|
||||||
|
* @package Firefly\Trigger\Recurring
|
||||||
|
*/
|
||||||
|
class EloquentRecurringTrigger
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param \RecurringTransaction $recurring
|
||||||
|
*/
|
||||||
|
public function destroy(\RecurringTransaction $recurring)
|
||||||
|
{
|
||||||
|
$reminders = $recurring->recurringtransactionreminders()->get();
|
||||||
|
/** @var \RecurringTransactionReminder $reminder */
|
||||||
|
foreach ($reminders as $reminder) {
|
||||||
|
$reminder->delete();
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param \RecurringTransaction $recurring
|
||||||
|
*/
|
||||||
|
public function store(\RecurringTransaction $recurring)
|
||||||
|
{
|
||||||
|
$this->createReminders();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function createReminders()
|
||||||
|
{
|
||||||
|
$entries = \Auth::user()->recurringtransactions()->where('active', 1)->get();
|
||||||
|
|
||||||
|
// for each entry, check for existing reminders during their period:
|
||||||
|
/** @var \RecurringTransaction $entry */
|
||||||
|
foreach ($entries as $entry) {
|
||||||
|
|
||||||
|
$start = clone $entry->date;
|
||||||
|
$end = clone $entry->date;
|
||||||
|
switch ($entry->repeat_freq) {
|
||||||
|
case 'weekly':
|
||||||
|
$start->startOfWeek();
|
||||||
|
$end->endOfWeek();
|
||||||
|
break;
|
||||||
|
case 'monthly':
|
||||||
|
$start->startOfMonth();
|
||||||
|
$end->endOfMonth();
|
||||||
|
break;
|
||||||
|
case 'quarterly':
|
||||||
|
$start->firstOfQuarter();
|
||||||
|
$end->lastOfQuarter();
|
||||||
|
break;
|
||||||
|
case 'half-year':
|
||||||
|
// start of half-year:
|
||||||
|
if (intval($start->format('m')) >= 7) {
|
||||||
|
$start->startOfYear();
|
||||||
|
$start->addMonths(6);
|
||||||
|
} else {
|
||||||
|
$start->startOfYear();
|
||||||
|
}
|
||||||
|
$end = clone $start;
|
||||||
|
$end->addMonths(6);
|
||||||
|
break;
|
||||||
|
case 'yearly':
|
||||||
|
$start->startOfYear();
|
||||||
|
$end->endOfYear();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
// check if exists.
|
||||||
|
$count = $entry->reminders()->where('startdate', $start->format('Y-m-d'))->where(
|
||||||
|
'enddate', $end->format('Y-m-d')
|
||||||
|
)->count();
|
||||||
|
if ($count == 0) {
|
||||||
|
// create reminder:
|
||||||
|
$reminder = new \RecurringTransactionReminder;
|
||||||
|
$reminder->recurringtransaction()->associate($entry);
|
||||||
|
$reminder->startdate = $start;
|
||||||
|
$reminder->enddate = $end;
|
||||||
|
$reminder->active = 1;
|
||||||
|
$reminder->user()->associate(\Auth::user());
|
||||||
|
$reminder->save();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Trigger!
|
||||||
|
*
|
||||||
|
* @param Dispatcher $events
|
||||||
|
*/
|
||||||
|
public function subscribe(Dispatcher $events)
|
||||||
|
{
|
||||||
|
$events->listen('recurring.destroy', 'Firefly\Trigger\Recurring\EloquentRecurringTrigger@destroy');
|
||||||
|
$events->listen('recurring.store', 'Firefly\Trigger\Recurring\EloquentRecurringTrigger@store');
|
||||||
|
$events->listen('recurring.update', 'Firefly\Trigger\Recurring\EloquentRecurringTrigger@update');
|
||||||
|
$events->listen('recurring.check', 'Firefly\Trigger\Recurring\EloquentRecurringTrigger@createReminders');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param \RecurringTransaction $recurring
|
||||||
|
*/
|
||||||
|
public function update(\RecurringTransaction $recurring)
|
||||||
|
{
|
||||||
|
// remove old active reminders
|
||||||
|
$reminders = $recurring->reminders()->validOnOrAfter(new Carbon)->get();
|
||||||
|
foreach ($reminders as $r) {
|
||||||
|
$r->delete();
|
||||||
|
}
|
||||||
|
$this->createReminders();
|
||||||
|
// create new reminder for the current period.
|
||||||
|
|
||||||
|
// and now create new one(s)!
|
||||||
|
}
|
||||||
|
}
|
@@ -39,6 +39,7 @@ use LaravelBook\Ardent\Ardent as Ardent;
|
|||||||
* @method static \Illuminate\Database\Query\Builder|\Piggybank whereReminder($value)
|
* @method static \Illuminate\Database\Query\Builder|\Piggybank whereReminder($value)
|
||||||
* @method static \Illuminate\Database\Query\Builder|\Piggybank whereReminderSkip($value)
|
* @method static \Illuminate\Database\Query\Builder|\Piggybank whereReminderSkip($value)
|
||||||
* @method static \Illuminate\Database\Query\Builder|\Piggybank whereOrder($value)
|
* @method static \Illuminate\Database\Query\Builder|\Piggybank whereOrder($value)
|
||||||
|
* @property-read \Illuminate\Database\Eloquent\Collection|\PiggybankReminder[] $piggybankreminders
|
||||||
*/
|
*/
|
||||||
class Piggybank extends Ardent
|
class Piggybank extends Ardent
|
||||||
{
|
{
|
||||||
|
@@ -3,6 +3,32 @@ use Carbon\Carbon;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Class PiggybankReminder
|
* Class PiggybankReminder
|
||||||
|
*
|
||||||
|
* @property integer $id
|
||||||
|
* @property \Carbon\Carbon $created_at
|
||||||
|
* @property \Carbon\Carbon $updated_at
|
||||||
|
* @property string $class
|
||||||
|
* @property integer $piggybank_id
|
||||||
|
* @property integer $recurring_transaction_id
|
||||||
|
* @property integer $user_id
|
||||||
|
* @property \Carbon\Carbon $startdate
|
||||||
|
* @property \Carbon\Carbon $enddate
|
||||||
|
* @property boolean $active
|
||||||
|
* @property-read \Piggybank $piggybank
|
||||||
|
* @property-read \RecurringTransaction $recurringTransaction
|
||||||
|
* @property-read \User $user
|
||||||
|
* @method static \Illuminate\Database\Query\Builder|\PiggybankReminder whereId($value)
|
||||||
|
* @method static \Illuminate\Database\Query\Builder|\PiggybankReminder whereCreatedAt($value)
|
||||||
|
* @method static \Illuminate\Database\Query\Builder|\PiggybankReminder whereUpdatedAt($value)
|
||||||
|
* @method static \Illuminate\Database\Query\Builder|\PiggybankReminder whereClass($value)
|
||||||
|
* @method static \Illuminate\Database\Query\Builder|\PiggybankReminder wherePiggybankId($value)
|
||||||
|
* @method static \Illuminate\Database\Query\Builder|\PiggybankReminder whereRecurringTransactionId($value)
|
||||||
|
* @method static \Illuminate\Database\Query\Builder|\PiggybankReminder whereUserId($value)
|
||||||
|
* @method static \Illuminate\Database\Query\Builder|\PiggybankReminder whereStartdate($value)
|
||||||
|
* @method static \Illuminate\Database\Query\Builder|\PiggybankReminder whereEnddate($value)
|
||||||
|
* @method static \Illuminate\Database\Query\Builder|\PiggybankReminder whereActive($value)
|
||||||
|
* @method static \Reminder validOn($date)
|
||||||
|
* @method static \Reminder validOnOrAfter($date)
|
||||||
*/
|
*/
|
||||||
class PiggybankReminder extends Reminder
|
class PiggybankReminder extends Reminder
|
||||||
{
|
{
|
||||||
|
@@ -32,6 +32,7 @@ use LaravelBook\Ardent\Ardent;
|
|||||||
* @method static \Illuminate\Database\Query\Builder|\RecurringTransaction whereAutomatch($value)
|
* @method static \Illuminate\Database\Query\Builder|\RecurringTransaction whereAutomatch($value)
|
||||||
* @method static \Illuminate\Database\Query\Builder|\RecurringTransaction whereRepeatFreq($value)
|
* @method static \Illuminate\Database\Query\Builder|\RecurringTransaction whereRepeatFreq($value)
|
||||||
* @method static \Illuminate\Database\Query\Builder|\RecurringTransaction whereSkip($value)
|
* @method static \Illuminate\Database\Query\Builder|\RecurringTransaction whereSkip($value)
|
||||||
|
* @property-read \Illuminate\Database\Eloquent\Collection|\RecurringTransactionReminder[] $reminders
|
||||||
*/
|
*/
|
||||||
class RecurringTransaction extends Ardent
|
class RecurringTransaction extends Ardent
|
||||||
{
|
{
|
||||||
@@ -59,13 +60,27 @@ class RecurringTransaction extends Ardent
|
|||||||
return ['created_at', 'updated_at', 'date'];
|
return ['created_at', 'updated_at', 'date'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return \Illuminate\Database\Eloquent\Relations\HasMany
|
||||||
|
*/
|
||||||
|
public function reminders()
|
||||||
|
{
|
||||||
|
return $this->hasMany('RecurringTransactionReminder');
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Carbon
|
* @return Carbon
|
||||||
*/
|
*/
|
||||||
public function next()
|
public function next()
|
||||||
{
|
{
|
||||||
|
$today = new Carbon;
|
||||||
$start = clone $this->date;
|
$start = clone $this->date;
|
||||||
$skip = $this->skip == 0 ? 1 : $this->skip;
|
$skip = $this->skip == 0 ? 1 : $this->skip;
|
||||||
|
if ($today < $start) {
|
||||||
|
return $start;
|
||||||
|
}
|
||||||
|
|
||||||
while ($start <= $this->date) {
|
while ($start <= $this->date) {
|
||||||
switch ($this->repeat_freq) {
|
switch ($this->repeat_freq) {
|
||||||
|
37
app/models/RecurringTransactionReminder.php
Normal file
37
app/models/RecurringTransactionReminder.php
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class RecurringTransactionReminder
|
||||||
|
*
|
||||||
|
* @property integer $id
|
||||||
|
* @property \Carbon\Carbon $created_at
|
||||||
|
* @property \Carbon\Carbon $updated_at
|
||||||
|
* @property string $class
|
||||||
|
* @property integer $piggybank_id
|
||||||
|
* @property integer $recurring_transaction_id
|
||||||
|
* @property integer $user_id
|
||||||
|
* @property \Carbon\Carbon $startdate
|
||||||
|
* @property \Carbon\Carbon $enddate
|
||||||
|
* @property boolean $active
|
||||||
|
* @property-read \Piggybank $piggybank
|
||||||
|
* @property-read \RecurringTransaction $recurringTransaction
|
||||||
|
* @property-read \User $user
|
||||||
|
* @method static \Illuminate\Database\Query\Builder|\RecurringTransactionReminder whereId($value)
|
||||||
|
* @method static \Illuminate\Database\Query\Builder|\RecurringTransactionReminder whereCreatedAt($value)
|
||||||
|
* @method static \Illuminate\Database\Query\Builder|\RecurringTransactionReminder whereUpdatedAt($value)
|
||||||
|
* @method static \Illuminate\Database\Query\Builder|\RecurringTransactionReminder whereClass($value)
|
||||||
|
* @method static \Illuminate\Database\Query\Builder|\RecurringTransactionReminder wherePiggybankId($value)
|
||||||
|
* @method static \Illuminate\Database\Query\Builder|\RecurringTransactionReminder whereRecurringTransactionId($value)
|
||||||
|
* @method static \Illuminate\Database\Query\Builder|\RecurringTransactionReminder whereUserId($value)
|
||||||
|
* @method static \Illuminate\Database\Query\Builder|\RecurringTransactionReminder whereStartdate($value)
|
||||||
|
* @method static \Illuminate\Database\Query\Builder|\RecurringTransactionReminder whereEnddate($value)
|
||||||
|
* @method static \Illuminate\Database\Query\Builder|\RecurringTransactionReminder whereActive($value)
|
||||||
|
* @method static \Reminder validOn($date)
|
||||||
|
* @method static \Reminder validOnOrAfter($date)
|
||||||
|
*/
|
||||||
|
class RecurringTransactionReminder extends Reminder
|
||||||
|
{
|
||||||
|
protected $isSubclass = true;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@@ -7,6 +7,32 @@ use Firefly\Database\SingleTableInheritanceEntity;
|
|||||||
/**
|
/**
|
||||||
* Class Reminder
|
* Class Reminder
|
||||||
* // reminder for: recurring, piggybank.
|
* // reminder for: recurring, piggybank.
|
||||||
|
*
|
||||||
|
* @property integer $id
|
||||||
|
* @property \Carbon\Carbon $created_at
|
||||||
|
* @property \Carbon\Carbon $updated_at
|
||||||
|
* @property string $class
|
||||||
|
* @property integer $piggybank_id
|
||||||
|
* @property integer $recurring_transaction_id
|
||||||
|
* @property integer $user_id
|
||||||
|
* @property \Carbon\Carbon $startdate
|
||||||
|
* @property \Carbon\Carbon $enddate
|
||||||
|
* @property boolean $active
|
||||||
|
* @property-read \Piggybank $piggybank
|
||||||
|
* @property-read \RecurringTransaction $recurringTransaction
|
||||||
|
* @property-read \User $user
|
||||||
|
* @method static \Illuminate\Database\Query\Builder|\Reminder whereId($value)
|
||||||
|
* @method static \Illuminate\Database\Query\Builder|\Reminder whereCreatedAt($value)
|
||||||
|
* @method static \Illuminate\Database\Query\Builder|\Reminder whereUpdatedAt($value)
|
||||||
|
* @method static \Illuminate\Database\Query\Builder|\Reminder whereClass($value)
|
||||||
|
* @method static \Illuminate\Database\Query\Builder|\Reminder wherePiggybankId($value)
|
||||||
|
* @method static \Illuminate\Database\Query\Builder|\Reminder whereRecurringTransactionId($value)
|
||||||
|
* @method static \Illuminate\Database\Query\Builder|\Reminder whereUserId($value)
|
||||||
|
* @method static \Illuminate\Database\Query\Builder|\Reminder whereStartdate($value)
|
||||||
|
* @method static \Illuminate\Database\Query\Builder|\Reminder whereEnddate($value)
|
||||||
|
* @method static \Illuminate\Database\Query\Builder|\Reminder whereActive($value)
|
||||||
|
* @method static \Reminder validOn($date)
|
||||||
|
* @method static \Reminder validOnOrAfter($date)
|
||||||
*/
|
*/
|
||||||
class Reminder extends SingleTableInheritanceEntity
|
class Reminder extends SingleTableInheritanceEntity
|
||||||
{
|
{
|
||||||
@@ -31,9 +57,14 @@ class Reminder extends SingleTableInheritanceEntity
|
|||||||
return $this->belongsTo('Piggybank');
|
return $this->belongsTo('Piggybank');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function render() {
|
public function recurringTransaction()
|
||||||
return '';
|
{
|
||||||
|
return $this->belongsTo('RecurringTransaction');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function render()
|
||||||
|
{
|
||||||
|
return '';
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -44,6 +75,23 @@ class Reminder extends SingleTableInheritanceEntity
|
|||||||
->where('active', 1);
|
->where('active', 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function scopeValidOnOrAfter($query, Carbon $date)
|
||||||
|
{
|
||||||
|
return $query->where(
|
||||||
|
function ($q) use ($date) {
|
||||||
|
$q->where('startdate', '<=', $date->format('Y-m-d'))->where(
|
||||||
|
'enddate', '>=', $date->format('Y-m-d')
|
||||||
|
);
|
||||||
|
$q->orWhere(
|
||||||
|
function ($q) use ($date) {
|
||||||
|
$q->where('startdate', '>=', $date);
|
||||||
|
$q->where('enddate', '>=', $date);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
)->where('active', 1);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* User
|
* User
|
||||||
*
|
*
|
||||||
|
@@ -36,6 +36,11 @@ use LaravelBook\Ardent\Ardent;
|
|||||||
* @method static \Illuminate\Database\Query\Builder|\TransactionJournal whereDate($value)
|
* @method static \Illuminate\Database\Query\Builder|\TransactionJournal whereDate($value)
|
||||||
* @method static \TransactionJournal after($date)
|
* @method static \TransactionJournal after($date)
|
||||||
* @method static \TransactionJournal before($date)
|
* @method static \TransactionJournal before($date)
|
||||||
|
* @property-read \Illuminate\Database\Eloquent\Collection|\
|
||||||
|
* 'Budget[] $budgets
|
||||||
|
* @property-read \Illuminate\Database\Eloquent\Collection|\
|
||||||
|
* 'Category[] $categories
|
||||||
|
* @method static \TransactionJournal onDate($date)
|
||||||
*/
|
*/
|
||||||
class TransactionJournal extends Ardent
|
class TransactionJournal extends Ardent
|
||||||
{
|
{
|
||||||
|
@@ -33,6 +33,8 @@ use LaravelBook\Ardent\Ardent;
|
|||||||
* @method static \Illuminate\Database\Query\Builder|\User whereReset($value)
|
* @method static \Illuminate\Database\Query\Builder|\User whereReset($value)
|
||||||
* @method static \Illuminate\Database\Query\Builder|\User whereRememberToken($value)
|
* @method static \Illuminate\Database\Query\Builder|\User whereRememberToken($value)
|
||||||
* @method static \Illuminate\Database\Query\Builder|\User whereMigrated($value)
|
* @method static \Illuminate\Database\Query\Builder|\User whereMigrated($value)
|
||||||
|
* @property-read \Illuminate\Database\Eloquent\Collection|\Reminder[] $reminders
|
||||||
|
* @property-read \Illuminate\Database\Eloquent\Collection|\PiggybankReminder[] $piggybankreminders
|
||||||
*/
|
*/
|
||||||
class User extends Ardent implements UserInterface, RemindableInterface
|
class User extends Ardent implements UserInterface, RemindableInterface
|
||||||
{
|
{
|
||||||
|
@@ -11,14 +11,16 @@
|
|||||||
|
|
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
ClassLoader::addDirectories(array(
|
ClassLoader::addDirectories(
|
||||||
|
array(
|
||||||
|
|
||||||
app_path() . '/commands',
|
app_path() . '/commands',
|
||||||
app_path() . '/controllers',
|
app_path() . '/controllers',
|
||||||
app_path() . '/models',
|
app_path() . '/models',
|
||||||
app_path() . '/database/seeds',
|
app_path() . '/database/seeds',
|
||||||
|
|
||||||
));
|
)
|
||||||
|
);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
@@ -46,10 +48,11 @@ Log::useFiles(storage_path().'/logs/laravel.log');
|
|||||||
|
|
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
App::error(function(Exception $exception, $code)
|
App::error(
|
||||||
{
|
function (Exception $exception, $code) {
|
||||||
Log::error($exception);
|
Log::error($exception);
|
||||||
});
|
}
|
||||||
|
);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
@@ -62,10 +65,11 @@ App::error(function(Exception $exception, $code)
|
|||||||
|
|
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
App::down(function()
|
App::down(
|
||||||
{
|
function () {
|
||||||
return Response::make("Be right back!", 503);
|
return Response::make("Be right back!", 503);
|
||||||
});
|
}
|
||||||
|
);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
|
@@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use Illuminate\Database\Eloquent\Collection;
|
use Illuminate\Database\Eloquent\Collection;
|
||||||
use Mockery as m;
|
|
||||||
use League\FactoryMuffin\Facade as f;
|
use League\FactoryMuffin\Facade as f;
|
||||||
|
use Mockery as m;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class BudgetControllerTest
|
* Class BudgetControllerTest
|
||||||
|
@@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use Illuminate\Database\Eloquent\Collection;
|
use Illuminate\Database\Eloquent\Collection;
|
||||||
use Mockery as m;
|
|
||||||
use League\FactoryMuffin\Facade as f;
|
use League\FactoryMuffin\Facade as f;
|
||||||
|
use Mockery as m;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class CategoryControllerTest
|
* Class CategoryControllerTest
|
||||||
|
@@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use Illuminate\Database\Eloquent\Collection;
|
use Illuminate\Database\Eloquent\Collection;
|
||||||
use Mockery as m;
|
|
||||||
use League\FactoryMuffin\Facade as f;
|
use League\FactoryMuffin\Facade as f;
|
||||||
|
use Mockery as m;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
use Carbon\Carbon as Carbon;
|
use Carbon\Carbon as Carbon;
|
||||||
use Mockery as m;
|
|
||||||
use League\FactoryMuffin\Facade as f;
|
use League\FactoryMuffin\Facade as f;
|
||||||
|
use Mockery as m;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class HomeControllerTest
|
* Class HomeControllerTest
|
||||||
@@ -15,6 +15,7 @@ class HomeControllerTest extends TestCase
|
|||||||
protected $_repository;
|
protected $_repository;
|
||||||
protected $_preferences;
|
protected $_preferences;
|
||||||
protected $_journals;
|
protected $_journals;
|
||||||
|
protected $_reminders;
|
||||||
|
|
||||||
public function setUp()
|
public function setUp()
|
||||||
{
|
{
|
||||||
@@ -25,6 +26,7 @@ class HomeControllerTest extends TestCase
|
|||||||
$this->_repository = $this->mock('Firefly\Storage\Account\AccountRepositoryInterface');
|
$this->_repository = $this->mock('Firefly\Storage\Account\AccountRepositoryInterface');
|
||||||
$this->_preferences = $this->mock('Firefly\Helper\Preferences\PreferencesHelperInterface');
|
$this->_preferences = $this->mock('Firefly\Helper\Preferences\PreferencesHelperInterface');
|
||||||
$this->_journals = $this->mock('Firefly\Storage\TransactionJournal\TransactionJournalRepositoryInterface');
|
$this->_journals = $this->mock('Firefly\Storage\TransactionJournal\TransactionJournalRepositoryInterface');
|
||||||
|
$this->_reminders = $this->mock('Firefly\Storage\Reminder\ReminderRepositoryInterface');
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -47,6 +49,11 @@ class HomeControllerTest extends TestCase
|
|||||||
$preference = $this->mock('Preference');
|
$preference = $this->mock('Preference');
|
||||||
$preference->shouldReceive('getAttribute')->with('data')->andReturn([]);
|
$preference->shouldReceive('getAttribute')->with('data')->andReturn([]);
|
||||||
|
|
||||||
|
Event::shouldReceive('fire')->with('limits.check');
|
||||||
|
Event::shouldReceive('fire')->with('piggybanks.check');
|
||||||
|
Event::shouldReceive('fire')->with('recurring.check');
|
||||||
|
|
||||||
|
$this->_reminders->shouldReceive('getCurrentRecurringReminders')->once()->andReturn([]);
|
||||||
|
|
||||||
// mock accounts:
|
// mock accounts:
|
||||||
$this->_repository->shouldReceive('count')->once()->andReturn(0);
|
$this->_repository->shouldReceive('count')->once()->andReturn(0);
|
||||||
@@ -71,6 +78,12 @@ class HomeControllerTest extends TestCase
|
|||||||
$preference = $this->mock('Preference');
|
$preference = $this->mock('Preference');
|
||||||
$preference->shouldReceive('getAttribute')->with('data')->andReturn([$account->id]);
|
$preference->shouldReceive('getAttribute')->with('data')->andReturn([$account->id]);
|
||||||
|
|
||||||
|
Event::shouldReceive('fire')->with('limits.check');
|
||||||
|
Event::shouldReceive('fire')->with('piggybanks.check');
|
||||||
|
Event::shouldReceive('fire')->with('recurring.check');
|
||||||
|
|
||||||
|
$this->_reminders->shouldReceive('getCurrentRecurringReminders')->once()->andReturn([]);
|
||||||
|
|
||||||
|
|
||||||
// mock accounts:
|
// mock accounts:
|
||||||
$this->_repository->shouldReceive('count')->once()->andReturn(0);
|
$this->_repository->shouldReceive('count')->once()->andReturn(0);
|
||||||
@@ -80,7 +93,7 @@ class HomeControllerTest extends TestCase
|
|||||||
$this->_preferences->shouldReceive('get')->with('frontpageAccounts', [])->andReturn($preference);
|
$this->_preferences->shouldReceive('get')->with('frontpageAccounts', [])->andReturn($preference);
|
||||||
|
|
||||||
// mock journals:
|
// mock journals:
|
||||||
$this->_journals->shouldReceive('getByAccountInDateRange')->once()->with($account, 15, $start, $end)->andReturn(
|
$this->_journals->shouldReceive('getByAccountInDateRange')->once()->with($account, 10, $start, $end)->andReturn(
|
||||||
[1, 2]
|
[1, 2]
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -104,6 +117,12 @@ class HomeControllerTest extends TestCase
|
|||||||
$preference = $this->mock('Preference');
|
$preference = $this->mock('Preference');
|
||||||
$preference->shouldReceive('getAttribute')->with('data')->andReturn($ids);
|
$preference->shouldReceive('getAttribute')->with('data')->andReturn($ids);
|
||||||
|
|
||||||
|
Event::shouldReceive('fire')->with('limits.check');
|
||||||
|
Event::shouldReceive('fire')->with('piggybanks.check');
|
||||||
|
Event::shouldReceive('fire')->with('recurring.check');
|
||||||
|
|
||||||
|
$this->_reminders->shouldReceive('getCurrentRecurringReminders')->once()->andReturn([]);
|
||||||
|
|
||||||
|
|
||||||
// mock accounts:
|
// mock accounts:
|
||||||
$this->_repository->shouldReceive('count')->once()->andReturn(0);
|
$this->_repository->shouldReceive('count')->once()->andReturn(0);
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
use Mockery as m;
|
|
||||||
use League\FactoryMuffin\Facade as f;
|
use League\FactoryMuffin\Facade as f;
|
||||||
|
use Mockery as m;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class LimitControllerTest
|
* Class LimitControllerTest
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
use Mockery as m;
|
|
||||||
use League\FactoryMuffin\Facade as f;
|
use League\FactoryMuffin\Facade as f;
|
||||||
|
use Mockery as m;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -308,48 +308,6 @@ class PiggybankControllerTest extends TestCase
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function teststorePiggybank()
|
|
||||||
{
|
|
||||||
$piggy = f::create('Piggybank');
|
|
||||||
$piggy->repeats = 0;
|
|
||||||
$piggy->save();
|
|
||||||
Event::shouldReceive('fire')->with('piggybanks.store',[$piggy])->once();
|
|
||||||
|
|
||||||
|
|
||||||
$this->_piggybanks->shouldReceive('store')->once()->andReturn($piggy);
|
|
||||||
$this->action('POST', 'PiggybankController@storePiggybank');
|
|
||||||
$this->assertResponseStatus(302);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testStoreRepeated()
|
|
||||||
{
|
|
||||||
$piggy = f::create('Piggybank');
|
|
||||||
$piggy->repeats = 1;
|
|
||||||
$piggy->save();
|
|
||||||
Event::shouldReceive('fire')->with('piggybanks.store',[$piggy])->once();
|
|
||||||
$this->_piggybanks->shouldReceive('store')->once()->andReturn($piggy);
|
|
||||||
$this->action('POST', 'PiggybankController@storeRepeated');
|
|
||||||
$this->assertResponseStatus(302);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function teststorePiggybankFails()
|
|
||||||
{
|
|
||||||
$piggy = f::create('Piggybank');
|
|
||||||
unset($piggy->id);
|
|
||||||
$this->_piggybanks->shouldReceive('store')->once()->andReturn($piggy);
|
|
||||||
$this->action('POST', 'PiggybankController@storePiggybank');
|
|
||||||
$this->assertResponseStatus(302);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testStoreRepeatedFails()
|
|
||||||
{
|
|
||||||
$piggy = f::create('Piggybank');
|
|
||||||
unset($piggy->id);
|
|
||||||
$this->_piggybanks->shouldReceive('store')->once()->andReturn($piggy);
|
|
||||||
$this->action('POST', 'PiggybankController@storeRepeated');
|
|
||||||
$this->assertResponseStatus(302);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testRemoveMoneyGET()
|
public function testRemoveMoneyGET()
|
||||||
{
|
{
|
||||||
$pig = $this->mock('Piggybank');
|
$pig = $this->mock('Piggybank');
|
||||||
@@ -375,19 +333,48 @@ class PiggybankControllerTest extends TestCase
|
|||||||
|
|
||||||
public function testShow()
|
public function testShow()
|
||||||
{
|
{
|
||||||
$piggyBank = f::create('Piggybank');
|
$pig = $this->mock('Piggybank');
|
||||||
// for binding
|
$piggybank = f::create('Piggybank');
|
||||||
|
$rep = f::create('PiggybankRepetition');
|
||||||
|
$rep->piggybank_id = $piggybank->id;
|
||||||
|
$rep->save();
|
||||||
|
|
||||||
Auth::shouldReceive('user')->andReturn($this->_user);
|
Auth::shouldReceive('user')->andReturn($this->_user);
|
||||||
Auth::shouldReceive('check')->andReturn(true);
|
Auth::shouldReceive('check')->andReturn(true);
|
||||||
$this->_user->shouldReceive('getAttribute')->with('id')->once()->andReturn(
|
$this->_user->shouldReceive('getAttribute')->with('id')->once()->andReturn(
|
||||||
$piggyBank->account()->first()->user_id
|
$piggybank->account()->first()->user_id
|
||||||
);
|
);
|
||||||
$this->_user->shouldReceive('getAttribute')->andReturn('some@email');
|
$this->_user->shouldReceive('getAttribute')->andReturn('some@email');
|
||||||
|
|
||||||
$this->action('GET', 'PiggybankController@show', $piggyBank->id);
|
$pig->shouldReceive('currentRelevantRep')->andReturn($rep);
|
||||||
|
|
||||||
|
// repos:
|
||||||
|
$this->_piggybanks->shouldReceive('leftOnAccount');
|
||||||
|
|
||||||
|
$this->action('GET', 'PiggybankController@show', $piggybank->id);
|
||||||
$this->assertResponseOk();
|
$this->assertResponseOk();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testStoreRepeated()
|
||||||
|
{
|
||||||
|
$piggy = f::create('Piggybank');
|
||||||
|
$piggy->repeats = 1;
|
||||||
|
$piggy->save();
|
||||||
|
Event::shouldReceive('fire')->with('piggybanks.store', [$piggy])->once();
|
||||||
|
$this->_piggybanks->shouldReceive('store')->once()->andReturn($piggy);
|
||||||
|
$this->action('POST', 'PiggybankController@storeRepeated');
|
||||||
|
$this->assertResponseStatus(302);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testStoreRepeatedFails()
|
||||||
|
{
|
||||||
|
$piggy = f::create('Piggybank');
|
||||||
|
unset($piggy->id);
|
||||||
|
$this->_piggybanks->shouldReceive('store')->once()->andReturn($piggy);
|
||||||
|
$this->action('POST', 'PiggybankController@storeRepeated');
|
||||||
|
$this->assertResponseStatus(302);
|
||||||
|
}
|
||||||
|
|
||||||
public function testUpdate()
|
public function testUpdate()
|
||||||
{
|
{
|
||||||
$piggyBank = f::create('Piggybank');
|
$piggyBank = f::create('Piggybank');
|
||||||
@@ -427,5 +414,27 @@ class PiggybankControllerTest extends TestCase
|
|||||||
$this->assertResponseStatus(302);
|
$this->assertResponseStatus(302);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function teststorePiggybank()
|
||||||
|
{
|
||||||
|
$piggy = f::create('Piggybank');
|
||||||
|
$piggy->repeats = 0;
|
||||||
|
$piggy->save();
|
||||||
|
Event::shouldReceive('fire')->with('piggybanks.store', [$piggy])->once();
|
||||||
|
|
||||||
|
|
||||||
|
$this->_piggybanks->shouldReceive('store')->once()->andReturn($piggy);
|
||||||
|
$this->action('POST', 'PiggybankController@storePiggybank');
|
||||||
|
$this->assertResponseStatus(302);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function teststorePiggybankFails()
|
||||||
|
{
|
||||||
|
$piggy = f::create('Piggybank');
|
||||||
|
unset($piggy->id);
|
||||||
|
$this->_piggybanks->shouldReceive('store')->once()->andReturn($piggy);
|
||||||
|
$this->action('POST', 'PiggybankController@storePiggybank');
|
||||||
|
$this->assertResponseStatus(302);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
@@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
use Mockery as m;
|
|
||||||
use League\FactoryMuffin\Facade as f;
|
use League\FactoryMuffin\Facade as f;
|
||||||
|
use Mockery as m;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class ProfileControllerTest
|
* Class ProfileControllerTest
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
use Mockery as m;
|
|
||||||
use League\FactoryMuffin\Facade as f;
|
use League\FactoryMuffin\Facade as f;
|
||||||
|
use Mockery as m;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class RecurringControllerTest
|
* Class RecurringControllerTest
|
||||||
@@ -40,6 +40,8 @@ class RecurringControllerTest extends TestCase
|
|||||||
{
|
{
|
||||||
$recurringTransaction = f::create('RecurringTransaction');
|
$recurringTransaction = f::create('RecurringTransaction');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// for binding
|
// for binding
|
||||||
Auth::shouldReceive('user')->andReturn($this->_user);
|
Auth::shouldReceive('user')->andReturn($this->_user);
|
||||||
Auth::shouldReceive('check')->andReturn(true);
|
Auth::shouldReceive('check')->andReturn(true);
|
||||||
@@ -55,6 +57,8 @@ class RecurringControllerTest extends TestCase
|
|||||||
{
|
{
|
||||||
$recurringTransaction = f::create('RecurringTransaction');
|
$recurringTransaction = f::create('RecurringTransaction');
|
||||||
|
|
||||||
|
Event::shouldReceive('fire')->with('recurring.destroy',m::any());
|
||||||
|
|
||||||
// for binding
|
// for binding
|
||||||
Auth::shouldReceive('user')->andReturn($this->_user);
|
Auth::shouldReceive('user')->andReturn($this->_user);
|
||||||
Auth::shouldReceive('check')->andReturn(true);
|
Auth::shouldReceive('check')->andReturn(true);
|
||||||
@@ -73,6 +77,7 @@ class RecurringControllerTest extends TestCase
|
|||||||
// for binding
|
// for binding
|
||||||
Auth::shouldReceive('user')->andReturn($this->_user);
|
Auth::shouldReceive('user')->andReturn($this->_user);
|
||||||
Auth::shouldReceive('check')->andReturn(true);
|
Auth::shouldReceive('check')->andReturn(true);
|
||||||
|
Event::shouldReceive('fire')->with('recurring.destroy',m::any());
|
||||||
$this->_user->shouldReceive('getAttribute')->with('id')->once()->andReturn($recurringTransaction->user_id);
|
$this->_user->shouldReceive('getAttribute')->with('id')->once()->andReturn($recurringTransaction->user_id);
|
||||||
$this->_user->shouldReceive('getAttribute')->with('email')->andReturn('some@email');
|
$this->_user->shouldReceive('getAttribute')->with('email')->andReturn('some@email');
|
||||||
$this->_repository->shouldReceive('destroy')->andReturn(false);
|
$this->_repository->shouldReceive('destroy')->andReturn(false);
|
||||||
@@ -123,6 +128,8 @@ class RecurringControllerTest extends TestCase
|
|||||||
{
|
{
|
||||||
$recurringTransaction = f::create('RecurringTransaction');
|
$recurringTransaction = f::create('RecurringTransaction');
|
||||||
|
|
||||||
|
Event::shouldReceive('fire')->with('recurring.store',m::any());
|
||||||
|
|
||||||
$this->_repository->shouldReceive('store')->andReturn($recurringTransaction);
|
$this->_repository->shouldReceive('store')->andReturn($recurringTransaction);
|
||||||
$this->action('POST', 'RecurringController@store');
|
$this->action('POST', 'RecurringController@store');
|
||||||
$this->assertResponseStatus(302);
|
$this->assertResponseStatus(302);
|
||||||
@@ -132,6 +139,8 @@ class RecurringControllerTest extends TestCase
|
|||||||
{
|
{
|
||||||
$recurringTransaction = f::create('RecurringTransaction');
|
$recurringTransaction = f::create('RecurringTransaction');
|
||||||
|
|
||||||
|
Event::shouldReceive('fire')->with('recurring.store',m::any());
|
||||||
|
|
||||||
$this->_repository->shouldReceive('store')->andReturn($recurringTransaction);
|
$this->_repository->shouldReceive('store')->andReturn($recurringTransaction);
|
||||||
$this->action('POST', 'RecurringController@store', ['create' => '1']);
|
$this->action('POST', 'RecurringController@store', ['create' => '1']);
|
||||||
$this->assertResponseStatus(302);
|
$this->assertResponseStatus(302);
|
||||||
@@ -158,6 +167,8 @@ class RecurringControllerTest extends TestCase
|
|||||||
$this->_user->shouldReceive('getAttribute')->with('id')->andReturn($recurringTransaction->user_id);
|
$this->_user->shouldReceive('getAttribute')->with('id')->andReturn($recurringTransaction->user_id);
|
||||||
$this->_user->shouldReceive('getAttribute')->with('email')->andReturn('some@email');
|
$this->_user->shouldReceive('getAttribute')->with('email')->andReturn('some@email');
|
||||||
|
|
||||||
|
Event::shouldReceive('fire')->with('recurring.update',m::any());
|
||||||
|
|
||||||
$this->_repository->shouldReceive('update')->andReturn($recurringTransaction);
|
$this->_repository->shouldReceive('update')->andReturn($recurringTransaction);
|
||||||
|
|
||||||
|
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
use Mockery as m;
|
|
||||||
use League\FactoryMuffin\Facade as f;
|
use League\FactoryMuffin\Facade as f;
|
||||||
|
use Mockery as m;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class TransactionControllerTest
|
* Class TransactionControllerTest
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
use Mockery as m;
|
|
||||||
use League\FactoryMuffin\Facade as f;
|
use League\FactoryMuffin\Facade as f;
|
||||||
|
use Mockery as m;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -11,6 +11,7 @@ Facade::define(
|
|||||||
'Initial balance account',
|
'Initial balance account',
|
||||||
'Beneficiary account'
|
'Beneficiary account'
|
||||||
];
|
];
|
||||||
|
|
||||||
return $types[rand(0, 3)];
|
return $types[rand(0, 3)];
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
@@ -10,12 +10,14 @@ Facade::define(
|
|||||||
'startdate' => function () {
|
'startdate' => function () {
|
||||||
$start = new Carbon;
|
$start = new Carbon;
|
||||||
$start->startOfMonth();
|
$start->startOfMonth();
|
||||||
|
|
||||||
return $start;
|
return $start;
|
||||||
},
|
},
|
||||||
'amount' => 100,
|
'amount' => 100,
|
||||||
'repeats' => 'boolean',
|
'repeats' => 'boolean',
|
||||||
'repeat_freq' => function () {
|
'repeat_freq' => function () {
|
||||||
$frequencies = ['daily', 'weekly', 'monthly', 'quarterly', 'half-year', 'yearly'];
|
$frequencies = ['daily', 'weekly', 'monthly', 'quarterly', 'half-year', 'yearly'];
|
||||||
|
|
||||||
return $frequencies[rand(0, 5)];
|
return $frequencies[rand(0, 5)];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -10,12 +10,14 @@ Facade::define(
|
|||||||
'startdate' => function () {
|
'startdate' => function () {
|
||||||
$start = new Carbon;
|
$start = new Carbon;
|
||||||
$start->startOfMonth();
|
$start->startOfMonth();
|
||||||
|
|
||||||
return $start;
|
return $start;
|
||||||
|
|
||||||
},
|
},
|
||||||
'enddate' => function () {
|
'enddate' => function () {
|
||||||
$end = new Carbon;
|
$end = new Carbon;
|
||||||
$end->endOfMonth();
|
$end->endOfMonth();
|
||||||
|
|
||||||
return $end;
|
return $end;
|
||||||
|
|
||||||
},
|
},
|
||||||
|
@@ -12,11 +12,13 @@ Facade::define(
|
|||||||
'startdate' => function () {
|
'startdate' => function () {
|
||||||
$start = new Carbon;
|
$start = new Carbon;
|
||||||
$start->startOfMonth();
|
$start->startOfMonth();
|
||||||
|
|
||||||
return $start;
|
return $start;
|
||||||
},
|
},
|
||||||
'targetdate' => function () {
|
'targetdate' => function () {
|
||||||
$end = new Carbon;
|
$end = new Carbon;
|
||||||
$end->endOfMonth();
|
$end->endOfMonth();
|
||||||
|
|
||||||
return $end;
|
return $end;
|
||||||
},
|
},
|
||||||
'repeats' => 0,
|
'repeats' => 0,
|
||||||
|
@@ -11,11 +11,13 @@ Facade::define(
|
|||||||
'startdate' => function () {
|
'startdate' => function () {
|
||||||
$start = new Carbon;
|
$start = new Carbon;
|
||||||
$start->startOfMonth();
|
$start->startOfMonth();
|
||||||
|
|
||||||
return $start;
|
return $start;
|
||||||
},
|
},
|
||||||
'targetdate' => function () {
|
'targetdate' => function () {
|
||||||
$end = new Carbon;
|
$end = new Carbon;
|
||||||
$end->endOfMonth();
|
$end->endOfMonth();
|
||||||
|
|
||||||
return $end;
|
return $end;
|
||||||
},
|
},
|
||||||
'currentamount' => 200
|
'currentamount' => 200
|
||||||
|
@@ -1,5 +1,4 @@
|
|||||||
<?php
|
<?php
|
||||||
use Carbon\Carbon;
|
|
||||||
use League\FactoryMuffin\Facade;
|
use League\FactoryMuffin\Facade;
|
||||||
|
|
||||||
Facade::define(
|
Facade::define(
|
||||||
|
@@ -1,7 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
|
||||||
use Carbon\Carbon;
|
|
||||||
use League\FactoryMuffin\Facade;
|
use League\FactoryMuffin\Facade;
|
||||||
|
|
||||||
Facade::define(
|
Facade::define(
|
||||||
|
@@ -1,7 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
|
||||||
use Carbon\Carbon;
|
|
||||||
use League\FactoryMuffin\Facade;
|
use League\FactoryMuffin\Facade;
|
||||||
|
|
||||||
Facade::define(
|
Facade::define(
|
||||||
|
@@ -1,7 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
|
||||||
use Carbon\Carbon;
|
|
||||||
use League\FactoryMuffin\Facade;
|
use League\FactoryMuffin\Facade;
|
||||||
|
|
||||||
Facade::define(
|
Facade::define(
|
||||||
@@ -9,6 +8,7 @@ Facade::define(
|
|||||||
[
|
[
|
||||||
'type' => function () {
|
'type' => function () {
|
||||||
$types = ['Withdrawal', 'Deposit', 'Transfer', 'Opening balance'];
|
$types = ['Withdrawal', 'Deposit', 'Transfer', 'Opening balance'];
|
||||||
|
|
||||||
return $types[rand(0, 3)];
|
return $types[rand(0, 3)];
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
@@ -71,11 +71,68 @@
|
|||||||
@endforeach
|
@endforeach
|
||||||
@endif
|
@endif
|
||||||
|
|
||||||
|
@if(count($reminders) > 0)
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-lg-12 col-md-12 col-sm-12">
|
||||||
|
<h4>Recurring transactions</h4>
|
||||||
|
<p class="text-info">These transactions are set to be expected between
|
||||||
|
{{Session::get('start')->format('j F Y')}} and {{Session::get('end')->format('j F Y')}}.</p>
|
||||||
|
<table class="table">
|
||||||
|
<tr>
|
||||||
|
<th>Name</th>
|
||||||
|
<th>Tags</th>
|
||||||
|
<th colspan="2">Amount</th>
|
||||||
|
<th>Repeats</th>
|
||||||
|
</tr>
|
||||||
|
<?php $max =0;$min = 0;?>
|
||||||
|
@foreach($reminders as $reminder)
|
||||||
|
<?php
|
||||||
|
$max += $reminder->recurringtransaction->amount_max;
|
||||||
|
$min += $reminder->recurringtransaction->amount_min;
|
||||||
|
?>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<a href="{{route('recurring.show',$reminder->recurringtransaction->id)}}">
|
||||||
|
{{{$reminder->recurringtransaction->name}}}
|
||||||
|
</a>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
@foreach(explode(' ',$reminder->recurringtransaction->match) as $word)
|
||||||
|
<span class="label label-info">{{{$word}}}</span>
|
||||||
|
@endforeach
|
||||||
|
</td>
|
||||||
|
|
||||||
|
<td>
|
||||||
|
{{mf($reminder->recurringtransaction->amount_min)}}
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
{{mf($reminder->recurringtransaction->amount_max)}}
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
{{$reminder->recurringtransaction->repeat_freq}}
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<div class="btn-group btn-group-xs">
|
||||||
|
<a href="#" class="btn btn-default">postpone</a>
|
||||||
|
<a href="#" class="btn btn-default">dismiss</a>
|
||||||
|
<a href="#" class="btn btn-default">done!</a>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
@endforeach
|
||||||
|
<tr>
|
||||||
|
<td colspan="2">Sum</td>
|
||||||
|
<td>{{mf($max)}}</td>
|
||||||
|
<td colspan="3">{{mf($min)}}</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
|
|
||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-lg-12 col-md-12 col-sm-12">
|
<div class="col-lg-12 col-md-12 col-sm-12">
|
||||||
<h4>Budgets</h4>
|
|
||||||
|
|
||||||
<div id="budgets"></div>
|
<div id="budgets"></div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@@ -7,9 +7,21 @@
|
|||||||
</h1>
|
</h1>
|
||||||
<p>
|
<p>
|
||||||
<a href="{{route('accounts.show',$piggyBank->account_id)}}">{{{$piggyBank->account->name}}}</a> has
|
<a href="{{route('accounts.show',$piggyBank->account_id)}}">{{{$piggyBank->account->name}}}</a> has
|
||||||
a balance of {{mf($piggyBank->account->balance())}}.
|
a balance of {{mf($balance)}}.
|
||||||
Of that {{mf($piggyBank->account->balance())}}, you have {{mf(0)}} not yet locked up in other piggy banks.
|
Of that {{mf($balance)}}, you have {{mf($leftOnAccount)}} not yet locked up in other piggy banks.
|
||||||
You can add {{mf(max(0,1))}} to this piggy bank.
|
You can add {{mf(min(max($balance,$leftOnAccount),$piggyBank->targetamount))}} to this piggy bank.
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
<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
|
||||||
|
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -105,7 +117,7 @@
|
|||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>Current amount</td>
|
<td>Current amount</td>
|
||||||
<td>{{mf($rep->currentamount)}}</td>
|
<td>{{mf($rep->currentamount)}} of {{mf($piggyBank->targetamount)}}</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>Start date</td>
|
<td>Start date</td>
|
||||||
|
@@ -27,8 +27,7 @@ require __DIR__.'/../vendor/autoload.php';
|
|||||||
|
|
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (file_exists($compiled = __DIR__.'/compiled.php'))
|
if (file_exists($compiled = __DIR__ . '/compiled.php')) {
|
||||||
{
|
|
||||||
require $compiled;
|
require $compiled;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -69,7 +68,6 @@ Illuminate\Support\ClassLoader::register();
|
|||||||
|
|
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (is_dir($workbench = __DIR__.'/../workbench'))
|
if (is_dir($workbench = __DIR__ . '/../workbench')) {
|
||||||
{
|
|
||||||
Illuminate\Workbench\Starter::start($workbench);
|
Illuminate\Workbench\Starter::start($workbench);
|
||||||
}
|
}
|
||||||
|
@@ -1,8 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
use Carbon\Carbon;
|
|
||||||
use Firefly\Exception\FireflyException;
|
|
||||||
|
|
||||||
if (!function_exists('mf')) {
|
if (!function_exists('mf')) {
|
||||||
function mf($n, $coloured = true)
|
function mf($n, $coloured = true)
|
||||||
{
|
{
|
||||||
@@ -94,6 +91,7 @@ Event::subscribe('Firefly\Helper\Form\FormTrigger');
|
|||||||
Event::subscribe('Firefly\Trigger\Limits\EloquentLimitTrigger');
|
Event::subscribe('Firefly\Trigger\Limits\EloquentLimitTrigger');
|
||||||
Event::subscribe('Firefly\Trigger\Piggybanks\EloquentPiggybankTrigger');
|
Event::subscribe('Firefly\Trigger\Piggybanks\EloquentPiggybankTrigger');
|
||||||
Event::subscribe('Firefly\Trigger\Budgets\EloquentBudgetTrigger');
|
Event::subscribe('Firefly\Trigger\Budgets\EloquentBudgetTrigger');
|
||||||
|
Event::subscribe('Firefly\Trigger\Recurring\EloquentRecurringTrigger');
|
||||||
|
|
||||||
//App::booted(
|
//App::booted(
|
||||||
// function () {
|
// function () {
|
||||||
@@ -103,6 +101,4 @@ Event::subscribe('Firefly\Trigger\Budgets\EloquentBudgetTrigger');
|
|||||||
//);
|
//);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return $app;
|
return $app;
|
||||||
|
Reference in New Issue
Block a user