This will be the first release!

This commit is contained in:
James Cole
2014-08-28 07:53:54 +02:00
parent c7f070a2d1
commit c4f42a604f
75 changed files with 1043 additions and 618 deletions

View File

@@ -14,7 +14,7 @@ class AccountController extends \BaseController
/**
* @param ARI $repository
* @param AI $accounts
* @param AI $accounts
*/
public function __construct(ARI $repository, AI $accounts)
{
@@ -40,7 +40,9 @@ class AccountController extends \BaseController
$accountType = $account->accountType()->first();
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);
@@ -56,7 +58,9 @@ class AccountController extends \BaseController
$accountType = $account->accountType()->first();
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);
if ($result === true) {
@@ -79,7 +83,9 @@ class AccountController extends \BaseController
$accountType = $account->accountType()->first();
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);
@@ -106,7 +112,9 @@ class AccountController extends \BaseController
{
$accountType = $account->accountType()->first();
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);
@@ -148,7 +156,9 @@ class AccountController extends \BaseController
{
$accountType = $account->accountType()->first();
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());
if ($account->validate()) {

View File

@@ -9,10 +9,12 @@ class BaseController extends Controller
/**
*
*/
public function __construct() {
public function __construct()
{
\Event::fire('limits.check');
\Event::fire('piggybanks.check');
}
/**
* Setup the layout used by the controller.
*

View File

@@ -50,7 +50,7 @@ class BudgetController extends BaseController
*/
public function destroy(Budget $budget)
{
Event::fire('budgets.destroy',[$budget]); // just before deletion.
Event::fire('budgets.destroy', [$budget]); // just before deletion.
$result = $this->_repository->destroy($budget);
if ($result === true) {
Session::flash('success', 'The budget was deleted.');
@@ -133,13 +133,13 @@ class BudgetController extends BaseController
$filters[] = 'no_envelope';
} else {
// grab all limit repetitions, order them, show them:
$repetitions = $this->_budgets->organizeRepetitions($budget,$useSessionDates);
$repetitions = $this->_budgets->organizeRepetitions($budget, $useSessionDates);
}
}
return View::make('budgets.show')->with('budget', $budget)->with('repetitions', $repetitions)->with(
'filters', $filters
)->with('highlight', Input::get('highlight'))->with('useSessionDates',$useSessionDates);
)->with('highlight', Input::get('highlight'))->with('useSessionDates', $useSessionDates);
}
/**
@@ -150,7 +150,7 @@ class BudgetController extends BaseController
$budget = $this->_repository->store(Input::all());
if ($budget->validate()) {
Event::fire('budgets.store',[$budget]);
Event::fire('budgets.store', [$budget]);
Session::flash('success', 'Budget created!');
if (Input::get('create') == '1') {
@@ -179,7 +179,7 @@ class BudgetController extends BaseController
{
$budget = $this->_repository->update($budget, Input::all());
if ($budget->validate()) {
Event::fire('budgets.update',[$budget]);
Event::fire('budgets.update', [$budget]);
Session::flash('success', 'Budget "' . $budget->name . '" updated.');
if (Input::get('from') == 'date') {

View File

@@ -2,7 +2,7 @@
use Carbon\Carbon;
use Firefly\Helper\Preferences\PreferencesHelperInterface as PHI;
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;
/**
@@ -13,20 +13,14 @@ class HomeController extends BaseController
protected $_accounts;
protected $_preferences;
protected $_journal;
protected $_budgets;
protected $_reminders;
/**
* @param ARI $accounts
* @param PHI $preferences
* @param TJRI $journal
* @param BRI $budgets
*/
public function __construct(ARI $accounts, PHI $preferences, TJRI $journal, BRI $budgets)
public function __construct(ARI $accounts, PHI $preferences, TJRI $journal, RRI $reminders)
{
$this->_accounts = $accounts;
$this->_preferences = $preferences;
$this->_journal = $journal;
$this->_budgets = $budgets;
$this->_reminders = $reminders;
}
/**
@@ -47,7 +41,7 @@ class HomeController extends BaseController
\Event::fire('limits.check');
\Event::fire('piggybanks.check');
\Event::fire('recurring.check');
// count, maybe we need some introducing text to show:
@@ -64,10 +58,9 @@ class HomeController extends BaseController
$accounts = $this->_accounts->getByIds($frontpage->data);
}
$transactions = [];
foreach ($accounts as $account) {
$set = $this->_journal->getByAccountInDateRange($account, 15, $start, $end);
$set = $this->_journal->getByAccountInDateRange($account, 10, $start, $end);
if (count($set) > 0) {
$transactions[] = [$set, $account];
}
@@ -81,7 +74,13 @@ class HomeController extends BaseController
$transactions = array_chunk($transactions, 3);
}
// get the users reminders:
$reminders = $this->_reminders->getCurrentRecurringReminders();
// 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
);
}
}

View File

@@ -1,6 +1,5 @@
<?php
use Carbon\Carbon;
use Firefly\Storage\Account\AccountRepositoryInterface as ARI;
use Firefly\Storage\Budget\BudgetRepositoryInterface as Bud;
use Firefly\Storage\Category\CategoryRepositoryInterface as Cat;

View File

@@ -60,7 +60,7 @@ class LimitController extends BaseController
*/
public function destroy(\Limit $limit)
{
Event::fire('limits.destroy',[$limit]); // before
Event::fire('limits.destroy', [$limit]); // before
$success = $this->_limits->destroy($limit);
if ($success) {
@@ -102,7 +102,7 @@ class LimitController extends BaseController
$limit = $this->_limits->store(Input::all());
if ($limit->validate()) {
Session::flash('success', 'Envelope created!');
Event::fire('limits.store',[$limit]);
Event::fire('limits.store', [$limit]);
if (Input::get('from') == 'date') {
return Redirect::route('budgets.index');
} else {
@@ -127,10 +127,10 @@ class LimitController extends BaseController
{
$limit = $this->_limits->update($limit,Input::all());
$limit = $this->_limits->update($limit, Input::all());
if ($limit->validate()) {
Event::fire('limits.update',[$limit]);
Event::fire('limits.update', [$limit]);
Session::flash('success', 'Limit saved!');
if (Input::get('from') == 'date') {
return Redirect::route('budgets.index');

View File

@@ -192,7 +192,11 @@ class PiggybankController extends BaseController
*/
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);
}
/**
@@ -212,7 +216,7 @@ class PiggybankController extends BaseController
$piggyBank = $this->_repository->store($data);
if (!is_null($piggyBank->id)) {
Session::flash('success', 'New piggy bank "' . $piggyBank->name . '" created!');
Event::fire('piggybanks.store',[$piggyBank]);
Event::fire('piggybanks.store', [$piggyBank]);
return Redirect::route('piggybanks.index');
@@ -241,7 +245,7 @@ class PiggybankController extends BaseController
$piggyBank = $this->_repository->store($data);
if ($piggyBank->id) {
Session::flash('success', 'New piggy bank "' . $piggyBank->name . '" created!');
Event::fire('piggybanks.store',[$piggyBank]);
Event::fire('piggybanks.store', [$piggyBank]);
return Redirect::route('piggybanks.index');
@@ -261,7 +265,7 @@ class PiggybankController extends BaseController
$piggyBank = $this->_repository->update($piggyBank, Input::all());
if ($piggyBank->validate()) {
Session::flash('success', 'Piggy bank "' . $piggyBank->name . '" updated.');
Event::fire('piggybanks.update',[$piggyBank]);
Event::fire('piggybanks.update', [$piggyBank]);
return Redirect::route('piggybanks.index');
} else {

View File

@@ -44,6 +44,7 @@ class RecurringController extends BaseController
*/
public function destroy(RecurringTransaction $recurringTransaction)
{
Event::fire('recurring.destroy', [$recurringTransaction]);
$result = $this->_repository->destroy($recurringTransaction);
if ($result === true) {
Session::flash('success', 'The recurring transaction was deleted.');
@@ -96,6 +97,7 @@ class RecurringController extends BaseController
$recurringTransaction = $this->_repository->store(Input::all());
if ($recurringTransaction->validate()) {
Session::flash('success', 'Recurring transaction "' . $recurringTransaction->name . '" saved!');
Event::fire('recurring.store', [$recurringTransaction]);
if (Input::get('create') == '1') {
return Redirect::route('recurring.create')->withInput();
} else {
@@ -119,6 +121,7 @@ class RecurringController extends BaseController
$recurringTransaction = $this->_repository->update($recurringTransaction, Input::all());
if ($recurringTransaction->errors()->count() == 0) {
Session::flash('success', 'The recurring transaction has been updated.');
Event::fire('recurring.update', [$recurringTransaction]);
return Redirect::route('recurring.index');
} else {

View File

@@ -189,14 +189,15 @@ class TransactionController extends BaseController
Session::flash('success', 'Transaction "' . $journal->description . '" saved!');
// if reminder present, deactivate it:
if(Input::get('reminder')) {
if (Input::get('reminder')) {
/** @var \Firefly\Storage\Reminder\ReminderRepositoryInterface $reminders */
$reminders = App::make('Firefly\Storage\Reminder\ReminderRepositoryInterface');
$reminder = $reminders->find(Input::get('reminder'));
$reminders->deactivate($reminder);
}
// trigger the creation for recurring transactions.
if (Input::get('create') == '1') {
return Redirect::route('transactions.create', [$what])->withInput();
} else {