General cleanup.

This commit is contained in:
James Cole 2015-05-03 12:58:55 +02:00
parent bb84f7a434
commit 4a51176193
34 changed files with 147 additions and 62 deletions

View File

@ -19,7 +19,8 @@ class JournalCreated extends Event
/**
* Create a new event instance.
*
* @return void
* @param TransactionJournal $journal
* @param $piggyBankId
*/
public function __construct(TransactionJournal $journal, $piggyBankId)
{

View File

@ -2,6 +2,11 @@
use Illuminate\Queue\SerializesModels;
/**
* Class JournalDeleted
*
* @package FireflyIII\Events
*/
class JournalDeleted extends Event
{
@ -10,7 +15,6 @@ class JournalDeleted extends Event
/**
* Create a new event instance.
*
* @return void
*/
public function __construct()
{

View File

@ -3,6 +3,11 @@
use FireflyIII\Models\TransactionJournal;
use Illuminate\Queue\SerializesModels;
/**
* Class JournalSaved
*
* @package FireflyIII\Events
*/
class JournalSaved extends Event
{
@ -13,7 +18,7 @@ class JournalSaved extends Event
/**
* Create a new event instance.
*
* @return void
* @param TransactionJournal $journal
*/
public function __construct(TransactionJournal $journal)
{

View File

@ -54,7 +54,9 @@ class Help implements HelpInterface
}
/**
* @return boolean
* @param $route
*
* @return bool
*/
public function hasRoute($route)
{
@ -62,10 +64,10 @@ class Help implements HelpInterface
}
/**
* @param $title
* @param $route
* @param array $content
*
* @return void
* @internal param $title
*/
public function putInCache($route, array $content)
{

View File

@ -18,16 +18,25 @@ interface HelpInterface
public function getFromCache($key);
/**
* @return boolean
* @param $route
*
* @return array
*/
public function getFromGithub($route);
/**
* @param $route
*
* @return bool
*/
public function hasRoute($route);
/**
* @param $route
*
* @return array
* @return bool
*/
public function getFromGithub($route);
public function inCache($route);
/**
* @param $route
@ -36,11 +45,4 @@ interface HelpInterface
* @return void
*/
public function putInCache($route, array $content);
/**
* @param $route
*
* @return bool
*/
public function inCache($route);
}

View File

@ -92,7 +92,7 @@ class AccountController extends Controller
*
* @return View
*/
public function edit(AccountRepositoryInterface $repository,Account $account)
public function edit(AccountRepositoryInterface $repository, Account $account)
{
$what = Config::get('firefly.shortNamesByFullName')[$account->accountType->type];

View File

@ -264,10 +264,10 @@ class BudgetController extends Controller
*/
public function updateIncome()
{
$date = Session::get('start', Carbon::now()->startOfMonth())->format('FY');
$date = Session::get('start', Carbon::now()->startOfMonth())->format('FY');
$amount = Preferences::get('budgetIncomeTotal' . $date, 1000);
return view('budgets.income',compact('amount'));
return view('budgets.income', compact('amount'));
}
}

View File

@ -97,8 +97,9 @@ class CategoryController extends Controller
}
/**
* @return $this
* @param CategoryRepositoryInterface $repository
*
* @return $this
*/
public function index(CategoryRepositoryInterface $repository)
{
@ -114,6 +115,8 @@ class CategoryController extends Controller
}
/**
* @param CategoryRepositoryInterface $repository
*
* @return \Illuminate\View\View
*/
public function noCategory(CategoryRepositoryInterface $repository)

View File

@ -133,6 +133,8 @@ class CurrencyController extends Controller
}
/**
* @param CurrencyRepositoryInterface $repository
*
* @return \Illuminate\View\View
*/
public function index(CurrencyRepositoryInterface $repository)
@ -146,6 +148,9 @@ class CurrencyController extends Controller
/**
* @SuppressWarnings("CyclomaticComplexity") // It's exactly 5. So I don't mind.
*
* @param CurrencyFormRequest $request
* @param CurrencyRepositoryInterface $repository
*
* @return $this|\Illuminate\Http\RedirectResponse
*/
public function store(CurrencyFormRequest $request, CurrencyRepositoryInterface $repository)

View File

@ -243,7 +243,10 @@ class GoogleChartController extends Controller
}
/**
* @param GChart $chart
* @param GChart $chart
*
* @param BillRepositoryInterface $repository
* @param AccountRepositoryInterface $accounts
*
* @return \Symfony\Component\HttpFoundation\Response
*/
@ -494,7 +497,7 @@ class GoogleChartController extends Controller
*
* @return \Symfony\Component\HttpFoundation\Response
*/
public function yearInExp(GChart $chart, ReportQueryInterface $query,$year)
public function yearInExp(GChart $chart, ReportQueryInterface $query, $year)
{
$start = new Carbon('01-01-' . $year);
$chart->addColumn('Month', 'date');

View File

@ -13,7 +13,8 @@ class HelpController extends Controller
{
/**
* @param $route
* @param HelpInterface $help
* @param $route
*
* @return \Illuminate\Http\JsonResponse
*/

View File

@ -28,7 +28,9 @@ class JsonController extends Controller
/**
* @param BillRepositoryInterface $repository
* @param BillRepositoryInterface $repository
*
* @param AccountRepositoryInterface $accountRepository
*
* @return \Symfony\Component\HttpFoundation\Response
*/
@ -149,6 +151,8 @@ class JsonController extends Controller
/**
* Returns a list of categories.
*
* @param CategoryRepositoryInterface $repository
*
* @return \Illuminate\Http\JsonResponse
*/
public function categories(CategoryRepositoryInterface $repository)
@ -166,6 +170,8 @@ class JsonController extends Controller
/**
* Returns a JSON list of all beneficiaries.
*
* @param AccountRepositoryInterface $accountRepository
*
* @return \Illuminate\Http\JsonResponse
*/
public function expenseAccounts(AccountRepositoryInterface $accountRepository)
@ -183,6 +189,8 @@ class JsonController extends Controller
/**
* Returns a JSON list of all beneficiaries.
*
* @param TagRepositoryInterface $tagRepository
*
* @return \Illuminate\Http\JsonResponse
*/
public function tags(TagRepositoryInterface $tagRepository)
@ -198,6 +206,8 @@ class JsonController extends Controller
}
/**
* @param AccountRepositoryInterface $accountRepository
*
* @return \Illuminate\Http\JsonResponse
*/
public function revenueAccounts(AccountRepositoryInterface $accountRepository)

View File

@ -40,7 +40,8 @@ class PiggyBankController extends Controller
/**
* Add money to piggy bank
*
* @param PiggyBank $piggyBank
* @param AccountRepositoryInterface $repository
* @param PiggyBank $piggyBank
*
* @return $this
*/
@ -55,6 +56,8 @@ class PiggyBankController extends Controller
}
/**
* @param AccountRepositoryInterface $repository
*
* @return mixed
*/
public function create(AccountRepositoryInterface $repository)
@ -337,10 +340,11 @@ class PiggyBankController extends Controller
}
/**
* @param PiggyBank $piggyBank
* @param PiggyBankRepositoryInterface $repository
* @param PiggyBankFormRequest $request
* @param PiggyBank $piggyBank
*
* @SuppressWarnings("CyclomaticComplexity") // It's exactly 5. So I don't mind.
*
* @return $this
*/
public function update(PiggyBankRepositoryInterface $repository, PiggyBankFormRequest $request, PiggyBank $piggyBank)

View File

@ -26,6 +26,8 @@ class PreferencesController extends Controller
}
/**
* @param AccountRepositoryInterface $repository
*
* @return $this|\Illuminate\View\View
*/
public function index(AccountRepositoryInterface $repository)

View File

@ -46,6 +46,8 @@ class ProfileController extends Controller
}
/**
* @param ProfileFormRequest $request
*
* @return \Illuminate\Http\RedirectResponse|\Illuminate\View\View
*/
public function postChangePassword(ProfileFormRequest $request)
@ -91,7 +93,10 @@ class ProfileController extends Controller
}
/**
* @param DeleteAccountFormRequest $request
*
* @return \Illuminate\Http\RedirectResponse
* @throws \Exception
*/
public function postDeleteAccount(DeleteAccountFormRequest $request)
{

View File

@ -1,7 +1,5 @@
<?php namespace FireflyIII\Http\Controllers;
use Auth;
use FireflyIII\Helpers\Reminders\ReminderHelperInterface;
use FireflyIII\Models\Reminder;
use FireflyIII\Repositories\Reminder\ReminderRepositoryInterface;
use Redirect;
@ -19,6 +17,8 @@ class ReminderController extends Controller
/**
* @param Reminder $reminder
*
* @return \Illuminate\Http\RedirectResponse
*/
public function act(Reminder $reminder)
{
@ -36,6 +36,8 @@ class ReminderController extends Controller
/**
* @param Reminder $reminder
*
* @return \Illuminate\Http\RedirectResponse
*/
public function dismiss(Reminder $reminder)
{
@ -48,7 +50,9 @@ class ReminderController extends Controller
}
/**
* @param ReminderRepositoryInterface $repository
*
* @return \Illuminate\View\View
*/
public function index(ReminderRepositoryInterface $repository)
{
@ -67,6 +71,8 @@ class ReminderController extends Controller
/**
* @param Reminder $reminder
*
* @return \Illuminate\View\View
*/
public function show(Reminder $reminder)
{

View File

@ -1,7 +1,6 @@
<?php namespace FireflyIII\Http\Controllers;
use Carbon\Carbon;
use Exception;
use FireflyIII\Helpers\Report\ReportHelperInterface;
use FireflyIII\Helpers\Report\ReportQueryInterface;
use FireflyIII\Models\Account;
@ -107,9 +106,9 @@ class ReportController extends Controller
}
/**
* @param ReportHelperInterface $helper
*
* @return View
* @internal param ReportHelperInterface $helper
*
*/
public function index()
{
@ -144,12 +143,13 @@ class ReportController extends Controller
}
/**
* @param Account $account
* @param string $year
* @param string $month
* @param ReportQueryInterface $query
* @param Account $account
* @param string $year
* @param string $month
*
* @return View
* @internal param ReportQueryInterface $query
*
*/
public function modalLeftUnbalanced(Account $account, $year = '2014', $month = '1')
{
@ -164,6 +164,8 @@ class ReportController extends Controller
if ($count == 0) {
return $journal;
}
return null;
}
);

View File

@ -12,6 +12,10 @@ class SearchController extends Controller
{
/**
* Results always come in the form of an array [results, count, fullCount]
*
* @param SearchInterface $searcher
*
* @return $this
*/
public function index(SearchInterface $searcher)
{

View File

@ -92,7 +92,7 @@ class TagController extends Controller
*
* @return \Illuminate\Http\RedirectResponse
*/
public function destroy(TagRepositoryInterface $repository,Tag $tag)
public function destroy(TagRepositoryInterface $repository, Tag $tag)
{
$tagName = $tag->tag;
@ -150,7 +150,7 @@ class TagController extends Controller
$count++;
}
}
if($count > 1) {
if ($count > 1) {
$allowToAdvancePayment = false;
}
@ -170,12 +170,12 @@ class TagController extends Controller
$count++;
}
}
if($count > 0) {
if ($count > 0) {
$allowToBalancingAct = false;
}
// edit tagoptions:
// edit tag options:
if ($allowToAdvancePayment === false) {
unset($tagOptions['advancePayment']);
}
@ -195,6 +195,8 @@ class TagController extends Controller
/**
* @param $state
*
* @return \Symfony\Component\HttpFoundation\Response
*/
public function hideTagHelp($state)
{
@ -234,7 +236,11 @@ class TagController extends Controller
}
/**
* @param TagFormRequest $request
* @param TagFormRequest $request
*
* @param TagRepositoryInterface $repository
*
* @return $this|\Illuminate\Http\RedirectResponse
*/
public function store(TagFormRequest $request, TagRepositoryInterface $repository)
{

View File

@ -26,7 +26,7 @@ class DeleteAccountFormRequest extends Request
public function rules()
{
return [
'password' => 'required',
'password' => 'required',
];
}
}

View File

@ -33,7 +33,7 @@ class TagFormRequest extends Request
*/
public function rules()
{
$idRule = '';
$idRule = '';
$tagRule = 'required|min:1|uniqueObjectForUser:tags,tag,TRUE';
if (Tag::find(Input::get('id'))) {
$idRule = 'belongsToUser:tags';

View File

@ -9,9 +9,10 @@ use FireflyIII\Models\Category;
use FireflyIII\Models\LimitRepetition;
use FireflyIII\Models\PiggyBank;
use FireflyIII\Models\Reminder;
use FireflyIII\Models\Tag;
use FireflyIII\Models\TransactionCurrency;
use FireflyIII\Models\TransactionJournal;
use FireflyIII\Models\Tag;
/*
* Back home.
*/
@ -176,13 +177,13 @@ Breadcrumbs::register(
Breadcrumbs::register(
'currency.edit', function (Generator $breadcrumbs, TransactionCurrency $currency) {
$breadcrumbs->parent('currency.index');
$breadcrumbs->push('Edit '.$currency->name, route('currency.edit', $currency->id));
$breadcrumbs->push('Edit ' . $currency->name, route('currency.edit', $currency->id));
}
);
Breadcrumbs::register(
'currency.delete', function (Generator $breadcrumbs, TransactionCurrency $currency) {
$breadcrumbs->parent('currency.index');
$breadcrumbs->push('Delete '.$currency->name, route('currency.delete', $currency->id));
$breadcrumbs->push('Delete ' . $currency->name, route('currency.delete', $currency->id));
}
);

View File

@ -145,8 +145,8 @@ Route::bind(
if (Auth::check()) {
/** @var \FireflyIII\Models\Reminder $object */
$object = Reminder::find($value);
if($object) {
if($object->remindersable->account->user_id == Auth::user()->id) {
if ($object) {
if ($object->remindersable->account->user_id == Auth::user()->id) {
return $object;
}
}
@ -177,7 +177,7 @@ Route::get('/register', ['uses' => 'Auth\AuthController@getRegister', 'as' => 'r
Route::controllers(
[
'auth' => 'Auth\AuthController',
'auth' => 'Auth\AuthController',
'password' => 'Auth\PasswordController',
]
);
@ -350,8 +350,13 @@ Route::group(
// pop ups for budget report:
Route::get('/reports/modal/{account}/{year}/{month}/no-budget', ['uses' => 'ReportController@modalNoBudget', 'as' => 'reports.no-budget']);
Route::get('/reports/modal/{account}/{year}/{month}/balanced-transfers', ['uses' => 'ReportController@modalBalancedTransfers', 'as' => 'reports.balanced-transfers']);
Route::get('/reports/modal/{account}/{year}/{month}/left-unbalanced', ['uses' => 'ReportController@modalLeftUnbalanced', 'as' => 'reports.left-unbalanced']);
Route::get(
'/reports/modal/{account}/{year}/{month}/balanced-transfers',
['uses' => 'ReportController@modalBalancedTransfers', 'as' => 'reports.balanced-transfers']
);
Route::get(
'/reports/modal/{account}/{year}/{month}/left-unbalanced', ['uses' => 'ReportController@modalLeftUnbalanced', 'as' => 'reports.left-unbalanced']
);
/**
* Search Controller

View File

@ -51,7 +51,7 @@ class Account extends Model
$account = Account::create($fields);
if (is_null($account->id)) {
// could not create account:
App::abort(500, 'Could not create new account with data: ' . json_encode($fields).' because ' . json_encode($account->getErrors()));
App::abort(500, 'Could not create new account with data: ' . json_encode($fields) . ' because ' . json_encode($account->getErrors()));
}

View File

@ -1,9 +1,10 @@
<?php namespace FireflyIII\Models;
use App;
use Crypt;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
use App;
/**
* Class Category
*

View File

@ -14,7 +14,7 @@ class PiggyBank extends Model
use SoftDeletes;
protected $fillable
= ['name', 'account_id','order', 'reminder_skip', 'targetamount', 'startdate', 'targetdate', 'reminder', 'remind_me'];
= ['name', 'account_id', 'order', 'reminder_skip', 'targetamount', 'startdate', 'targetdate', 'reminder', 'remind_me'];
/**
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo

View File

@ -78,6 +78,11 @@ class Reminder extends Model
return $query->where('reminders.startdate', '=', $start->format('Y-m-d 00:00:00'))->where('reminders.enddate', '=', $end->format('Y-m-d 00:00:00'));
}
/**
* @param EloquentBuilder $query
*
* @return $this
*/
public function scopeToday(EloquentBuilder $query)
{
$today = new Carbon;

View File

@ -52,9 +52,9 @@ class Tag extends Model
}
}
// create it!
$fields['tagMode'] = 'nothing';
$fields['tagMode'] = 'nothing';
$fields['description'] = isset($fields['description']) && !is_null($fields['description']) ? $fields['description'] : '';
$tag = Tag::create($fields);
$tag = Tag::create($fields);
if (is_null($tag->id)) {
// could not create account:
App::abort(500, 'Could not create new tag with data: ' . json_encode($fields) . ' because ' . json_encode($tag->getErrors()));

View File

@ -66,8 +66,13 @@ class TransactionJournal extends Model
return floatval($t->amount);
}
}
return 0;
}
/**
* @return Account|mixed
*/
public function getAssetAccountAttribute()
{
$positive = true; // the asset account is in the transaction with the positive amount.

View File

@ -173,7 +173,7 @@ class ConfigServiceProvider extends ServiceProvider
],
'Form' => [
'is_safe' => [
'input', 'select', 'checkbox', 'model', 'open','radio','textarea'
'input', 'select', 'checkbox', 'model', 'open', 'radio', 'textarea'
]
],
],

View File

@ -6,6 +6,7 @@ use FireflyIII\Models\BudgetLimit;
use FireflyIII\Models\LimitRepetition;
use FireflyIII\Models\PiggyBank;
use FireflyIII\Models\PiggyBankRepetition;
use FireflyIII\Models\Reminder;
use FireflyIII\Models\Transaction;
use FireflyIII\Models\TransactionJournal;
use FireflyIII\Support\Facades\Navigation;
@ -13,7 +14,6 @@ use Illuminate\Contracts\Events\Dispatcher as DispatcherContract;
use Illuminate\Database\QueryException;
use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;
use Log;
use FireflyIII\Models\Reminder;
/**
* Class EventServiceProvider

View File

@ -231,7 +231,7 @@ class JournalRepository implements JournalRepositoryInterface
DB::table('tag_transaction_journal')->where('transaction_journal_id', $journal->id)->whereNotIn('tag_id', $ids)->delete();
}
// if count is zero, delete them all:
if(count($ids) == 0) {
if (count($ids) == 0) {
DB::table('tag_transaction_journal')->where('transaction_journal_id', $journal->id)->delete();
}

View File

@ -1,6 +1,7 @@
<?php
namespace FireflyIII\Repositories\Tag;
use FireflyIII\Models\Tag;
use FireflyIII\Models\TransactionJournal;
use Illuminate\Support\Collection;
@ -11,7 +12,8 @@ use Illuminate\Support\Collection;
*
* @package FireflyIII\Repositories\Tag
*/
interface TagRepositoryInterface {
interface TagRepositoryInterface
{
/**
* @param array $data
@ -34,7 +36,7 @@ interface TagRepositoryInterface {
public function update(Tag $tag, array $data);
/**
* @param Tag $tag
* @param Tag $tag
*
* @return boolean
*/

View File

@ -2,9 +2,9 @@
namespace FireflyIII\Support\Twig;
use FireflyIII\Models\PiggyBank as PB;
use Twig_Extension;
use Twig_SimpleFunction;
use FireflyIII\Models\PiggyBank as PB;
/**
* Class PiggyBank
@ -26,6 +26,7 @@ class PiggyBank extends Twig_Extension
return $piggyBank->currentRelevantRep()->currentamount;
}
);
return $functions;
}