mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-09-29 18:20:01 +00:00
Code cleanup [skip ci]
This commit is contained in:
@@ -1,8 +1,6 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
//use Symfony\Component\Console\Input\InputArgument;
|
||||
//use Symfony\Component\Console\Input\InputOption;
|
||||
|
||||
/**
|
||||
* Class Cleanup
|
||||
|
@@ -187,7 +187,7 @@ class AccountController extends BaseController
|
||||
return Redirect::route('accounts.create', e($data['what']))->withInput();
|
||||
}
|
||||
|
||||
// store:
|
||||
// store
|
||||
$this->_repository->store($data);
|
||||
Session::flash('success', 'Account "' . e($data['name']) . '" stored.');
|
||||
if ($data['post_submit_action'] == 'store') {
|
||||
|
@@ -149,7 +149,7 @@ class BillController extends BaseController
|
||||
return Redirect::route('bills.create')->withInput();
|
||||
}
|
||||
|
||||
// store:
|
||||
// store
|
||||
$this->_repository->store($data);
|
||||
Session::flash('success', 'Bill "' . e($data['name']) . '" stored.');
|
||||
if ($data['post_submit_action'] == 'store') {
|
||||
|
@@ -179,7 +179,7 @@ class BudgetController extends BaseController
|
||||
return Redirect::route('budgets.create')->withInput();
|
||||
}
|
||||
|
||||
// store:
|
||||
// store
|
||||
$this->_repository->store($data);
|
||||
Session::flash('success', 'Budget "' . e($data['name']) . '" stored.');
|
||||
if ($data['post_submit_action'] == 'store') {
|
||||
|
@@ -116,7 +116,7 @@ class CategoryController extends BaseController
|
||||
return Redirect::route('categories.create')->withInput();
|
||||
}
|
||||
|
||||
// store:
|
||||
// store
|
||||
$this->_repository->store($data);
|
||||
Session::flash('success', 'Category "' . e($data['name']) . '" stored.');
|
||||
if ($data['post_submit_action'] == 'store') {
|
||||
|
@@ -145,7 +145,7 @@ class CurrencyController extends BaseController
|
||||
return Redirect::route('currency.create')->withInput();
|
||||
}
|
||||
|
||||
// store:
|
||||
// store
|
||||
$this->_repository->store($data);
|
||||
Session::flash('success', 'Currency "' . e($data['name']) . '" stored.');
|
||||
if ($data['post_submit_action'] == 'store') {
|
||||
|
@@ -297,7 +297,7 @@ class PiggyBankController extends BaseController
|
||||
return Redirect::route('piggy_banks.create')->withInput();
|
||||
}
|
||||
|
||||
// store:
|
||||
// store
|
||||
$piggyBank = $this->_repository->store($data);
|
||||
Event::fire('piggy_bank.store', [$piggyBank]); // new and used.
|
||||
Session::flash('success', 'Piggy bank "' . e($data['name']) . '" stored.');
|
||||
|
@@ -168,7 +168,7 @@ class RepeatedExpenseController extends BaseController
|
||||
return Redirect::route('repeated.create')->withInput();
|
||||
}
|
||||
|
||||
// store:
|
||||
// store
|
||||
$piggyBank = $this->_repository->store($data);
|
||||
Event::fire('piggy_bank.store', [$piggyBank]); // new and used.
|
||||
Session::flash('success', 'Piggy bank "' . e($data['name']) . '" stored.');
|
||||
|
@@ -94,7 +94,6 @@ class ReportController extends BaseController
|
||||
$budgets = $this->_repository->getBudgetsForMonth($date);
|
||||
$categories = $this->_repository->getCategoriesForMonth($date, 10);
|
||||
$accounts = $this->_repository->getAccountsForMonth($date);
|
||||
//$piggyBanks = $this->_repository->getPiggyBanksForMonth($date);
|
||||
|
||||
return View::make(
|
||||
'reports.month',
|
||||
|
@@ -382,7 +382,7 @@ class TransactionController extends BaseController
|
||||
return Redirect::route('transactions.create', $data['what'])->withInput();
|
||||
}
|
||||
|
||||
// store:
|
||||
// store
|
||||
$journal = $this->_repository->store($data);
|
||||
Event::fire('transactionJournal.store', [$journal, Input::get('piggy_bank_id')]); // new and used.
|
||||
/*
|
||||
|
@@ -76,8 +76,6 @@ class UserController extends BaseController
|
||||
|
||||
$user = $repository->register(Input::all());
|
||||
|
||||
|
||||
//$user = $this->user->register(Input::all());
|
||||
if ($user) {
|
||||
$email->sendVerificationMail($user);
|
||||
|
||||
|
@@ -1,6 +1,7 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
|
||||
/**
|
||||
* Class CreateSessionTable
|
||||
@@ -27,11 +28,11 @@ class CreateSessionTable extends Migration
|
||||
public function up()
|
||||
{
|
||||
Schema::create(
|
||||
'sessions', function ($t) {
|
||||
$t->string('id')->unique();
|
||||
$t->text('payload');
|
||||
$t->integer('last_activity');
|
||||
}
|
||||
'sessions', function (Blueprint $table) {
|
||||
$table->string('id')->unique();
|
||||
$table->text('payload');
|
||||
$table->integer('last_activity');
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
|
@@ -272,19 +272,6 @@ class ChangesForV321 extends Migration
|
||||
$this->dropComponentIdFromBudgetLimits(); // 16.
|
||||
$this->expandCurrencyTable(); // 17.
|
||||
|
||||
|
||||
// $this->doRenameInLimitRepetitions();
|
||||
// $this->doBudgetLimits();
|
||||
// $this->doPiggyBankEvents();
|
||||
// $this->doCreateCategoryTables();
|
||||
// $this->doUpdateTransactionTable();
|
||||
// $this->doDropCompRecurTable();
|
||||
// $this->doDropCompTransTable();
|
||||
// $this->doMoveBudgets();
|
||||
// $this->doMoveCategories();
|
||||
// $this->doMoveLimitReferences();
|
||||
|
||||
|
||||
}
|
||||
|
||||
public function createBudgetTable()
|
||||
|
@@ -1,7 +1,6 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\QueryException;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
|
||||
/**
|
||||
@@ -96,23 +95,6 @@ class ChangesForV322 extends Migration
|
||||
Schema::rename('piggybank_repetitions', 'piggy_bank_repetitions');
|
||||
Schema::rename('piggybanks', 'piggy_banks');
|
||||
|
||||
// drop an invalid index (how, in sqlite?).
|
||||
Schema::table(
|
||||
'budget_limits', function (Blueprint $table) {
|
||||
|
||||
// try {
|
||||
// //$table->dropUnique('unique_ci_combi');
|
||||
// } catch (QueryException $e) {
|
||||
// echo 'Could not delete unique_ci_combi';
|
||||
//
|
||||
// } catch (PDOException $e) {
|
||||
// echo 'Could not delete unique_ci_combi';
|
||||
// } catch (Exception $e) {
|
||||
// echo 'Could not delete unique_ci_combi';
|
||||
// }
|
||||
|
||||
}
|
||||
);
|
||||
// recreate it the correct way:
|
||||
Schema::table(
|
||||
'budget_limits', function (Blueprint $table) {
|
||||
|
@@ -268,10 +268,10 @@ class TestContentSeeder extends Seeder
|
||||
*/
|
||||
public function createPiggyBanks(User $user)
|
||||
{
|
||||
// account:
|
||||
// account
|
||||
$savings = Account::whereName('Savings account')->orderBy('id', 'DESC')->first();
|
||||
|
||||
// some dates:
|
||||
// some dates
|
||||
$endDate = clone $this->_startOfMonth;
|
||||
$nextYear = clone $this->_startOfMonth;
|
||||
|
||||
@@ -374,7 +374,7 @@ class TestContentSeeder extends Seeder
|
||||
*/
|
||||
public function createRecurringTransactions(User $user)
|
||||
{
|
||||
// account:
|
||||
// account
|
||||
$savings = Account::whereName('Savings account')->orderBy('id', 'DESC')->first();
|
||||
|
||||
$recurring = PiggyBank::create(
|
||||
|
@@ -7,6 +7,7 @@ use FireflyIII\Database\CommonDatabaseCalls;
|
||||
use FireflyIII\Database\CUD;
|
||||
use FireflyIII\Database\SwitchUser;
|
||||
use FireflyIII\Exception\NotImplementedException;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Model as Eloquent;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\MessageBag;
|
||||
@@ -224,18 +225,18 @@ class Account implements CUD, CommonDatabaseCalls, AccountInterface
|
||||
|
||||
// delete journals:
|
||||
$journals = \TransactionJournal::whereIn(
|
||||
'id', function ($query) use ($model) {
|
||||
'id', function (Builder $query) use ($model) {
|
||||
$query->select('transaction_journal_id')
|
||||
->from('transactions')->whereIn(
|
||||
'account_id', function ($query) use ($model) {
|
||||
'account_id', function (Builder $query) use ($model) {
|
||||
$query
|
||||
->select('id')
|
||||
->from('accounts')
|
||||
->where(
|
||||
function ($q) use ($model) {
|
||||
function (Builder $q) use ($model) {
|
||||
$q->where('id', $model->id);
|
||||
$q->orWhere(
|
||||
function ($q) use ($model) {
|
||||
function (Builder $q) use ($model) {
|
||||
$q->where('accounts.name', 'LIKE', '%' . $model->name . '%');
|
||||
// TODO magic number!
|
||||
$q->where('accounts.account_type_id', 3);
|
||||
@@ -273,10 +274,10 @@ class Account implements CUD, CommonDatabaseCalls, AccountInterface
|
||||
|
||||
// delete accounts:
|
||||
\Account::where(
|
||||
function ($q) use ($model) {
|
||||
function (Builder $q) use ($model) {
|
||||
$q->where('id', $model->id);
|
||||
$q->orWhere(
|
||||
function ($q) use ($model) {
|
||||
function (Builder $q) use ($model) {
|
||||
$q->where('accounts.name', 'LIKE', '%' . $model->name . '%');
|
||||
// TODO magic number!
|
||||
$q->where('accounts.account_type_id', 3);
|
||||
|
@@ -10,6 +10,7 @@ use FireflyIII\Exception\NotImplementedException;
|
||||
use Illuminate\Database\Eloquent\Model as Eloquent;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\MessageBag;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
|
||||
/**
|
||||
* Class Budget
|
||||
@@ -265,7 +266,7 @@ class Budget implements CUD, CommonDatabaseCalls, BudgetInterface
|
||||
return $this->getUser()
|
||||
->transactionjournals()
|
||||
->whereNotIn(
|
||||
'transaction_journals.id', function ($query) use ($start, $end) {
|
||||
'transaction_journals.id', function (Builder $query) use ($start, $end) {
|
||||
$query
|
||||
->select('transaction_journals.id')
|
||||
->from('transaction_journals')
|
||||
|
@@ -158,7 +158,7 @@ class TransactionJournal implements TransactionJournalInterface, CUD, CommonData
|
||||
$errors->add('description', 'Internal error: need to know type of transaction!');
|
||||
}
|
||||
/*
|
||||
* Amount:
|
||||
* Amount
|
||||
*/
|
||||
if (isset($model['amount']) && floatval($model['amount']) < 0.01) {
|
||||
$errors->add('amount', 'Amount must be > 0.01');
|
||||
@@ -171,7 +171,7 @@ class TransactionJournal implements TransactionJournalInterface, CUD, CommonData
|
||||
}
|
||||
|
||||
/*
|
||||
* Budget:
|
||||
* Budget
|
||||
*/
|
||||
if (isset($model['budget_id']) && !ctype_digit($model['budget_id'])) {
|
||||
$errors->add('budget_id', 'Invalid budget');
|
||||
|
@@ -43,8 +43,6 @@ class FF3ServiceProvider extends ServiceProvider
|
||||
*/
|
||||
public function register()
|
||||
{
|
||||
// FORMAT:
|
||||
#$this->app->bind('Interface', 'Class');
|
||||
$this->registerFacades();
|
||||
$this->registerInterfaces();
|
||||
$this->registerAliases();
|
||||
@@ -88,10 +86,10 @@ class FF3ServiceProvider extends ServiceProvider
|
||||
|
||||
public function registerInterfaces()
|
||||
{
|
||||
// preferences:
|
||||
// preferences
|
||||
$this->app->bind('FireflyIII\Shared\Preferences\PreferencesInterface', 'FireflyIII\Shared\Preferences\Preferences');
|
||||
|
||||
// registration and user mail:
|
||||
// registration and user mail
|
||||
$this->app->bind('FireflyIII\Shared\Mail\RegistrationInterface', 'FireflyIII\Shared\Mail\Registration');
|
||||
|
||||
// reports
|
||||
|
@@ -365,24 +365,24 @@ class Report implements ReportInterface
|
||||
{
|
||||
return \TransactionJournal::
|
||||
leftJoin(
|
||||
'transactions as t_from', function ($join) {
|
||||
'transactions as t_from', function (JoinClause $join) {
|
||||
$join->on('t_from.transaction_journal_id', '=', 'transaction_journals.id')->where('t_from.amount', '<', 0);
|
||||
}
|
||||
)
|
||||
->leftJoin('accounts as ac_from', 't_from.account_id', '=', 'ac_from.id')
|
||||
->leftJoin(
|
||||
'account_meta as acm_from', function ($join) {
|
||||
'account_meta as acm_from', function (JoinClause $join) {
|
||||
$join->on('ac_from.id', '=', 'acm_from.account_id')->where('acm_from.name', '=', 'accountRole');
|
||||
}
|
||||
)
|
||||
->leftJoin(
|
||||
'transactions as t_to', function ($join) {
|
||||
'transactions as t_to', function (JoinClause $join) {
|
||||
$join->on('t_to.transaction_journal_id', '=', 'transaction_journals.id')->where('t_to.amount', '>', 0);
|
||||
}
|
||||
)
|
||||
->leftJoin('accounts as ac_to', 't_to.account_id', '=', 'ac_to.id')
|
||||
->leftJoin(
|
||||
'account_meta as acm_to', function ($join) {
|
||||
'account_meta as acm_to', function (JoinClause $join) {
|
||||
$join->on('ac_to.id', '=', 'acm_to.account_id')->where('acm_to.name', '=', 'accountRole');
|
||||
}
|
||||
)
|
||||
|
@@ -287,24 +287,24 @@ class ReportQuery implements ReportQueryInterface
|
||||
{
|
||||
return \TransactionJournal::
|
||||
leftJoin(
|
||||
'transactions as t_from', function ($join) {
|
||||
'transactions as t_from', function (JoinClause $join) {
|
||||
$join->on('t_from.transaction_journal_id', '=', 'transaction_journals.id')->where('t_from.amount', '<', 0);
|
||||
}
|
||||
)
|
||||
->leftJoin('accounts as ac_from', 't_from.account_id', '=', 'ac_from.id')
|
||||
->leftJoin(
|
||||
'account_meta as acm_from', function ($join) {
|
||||
'account_meta as acm_from', function (JoinClause $join) {
|
||||
$join->on('ac_from.id', '=', 'acm_from.account_id')->where('acm_from.name', '=', 'accountRole');
|
||||
}
|
||||
)
|
||||
->leftJoin(
|
||||
'transactions as t_to', function ($join) {
|
||||
'transactions as t_to', function (JoinClause $join) {
|
||||
$join->on('t_to.transaction_journal_id', '=', 'transaction_journals.id')->where('t_to.amount', '>', 0);
|
||||
}
|
||||
)
|
||||
->leftJoin('accounts as ac_to', 't_to.account_id', '=', 'ac_to.id')
|
||||
->leftJoin(
|
||||
'account_meta as acm_to', function ($join) {
|
||||
'account_meta as acm_to', function (JoinClause $join) {
|
||||
$join->on('ac_to.id', '=', 'acm_to.account_id')->where('acm_to.name', '=', 'accountRole');
|
||||
}
|
||||
)
|
||||
|
@@ -4,6 +4,7 @@ namespace FireflyIII\Search;
|
||||
|
||||
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
|
||||
/**
|
||||
* Class Search
|
||||
@@ -20,7 +21,7 @@ class Search
|
||||
public function searchAccounts(array $words)
|
||||
{
|
||||
return \Auth::user()->accounts()->with('accounttype')->where(
|
||||
function ($q) use ($words) {
|
||||
function (Builder $q) use ($words) {
|
||||
foreach ($words as $word) {
|
||||
$q->orWhere('name', 'LIKE', '%' . e($word) . '%');
|
||||
}
|
||||
@@ -96,7 +97,7 @@ class Search
|
||||
public function searchTransactions(array $words)
|
||||
{
|
||||
return \Auth::user()->transactionjournals()->withRelevantData()->where(
|
||||
function ($q) use ($words) {
|
||||
function (Builder $q) use ($words) {
|
||||
foreach ($words as $word) {
|
||||
$q->orWhere('description', 'LIKE', '%' . e($word) . '%');
|
||||
}
|
||||
|
@@ -16,6 +16,8 @@ class Steam
|
||||
{
|
||||
|
||||
/**
|
||||
* TODO find a way to reliably remove cache entries for accounts.
|
||||
*
|
||||
* @param \Account $account
|
||||
* @param Carbon $date
|
||||
*
|
||||
@@ -23,24 +25,12 @@ class Steam
|
||||
*/
|
||||
public function balance(\Account $account, Carbon $date = null)
|
||||
{
|
||||
\Log::debug('Now in Steam::balance() for account #' . $account->id . ' (' . $account->name . ')');
|
||||
if (is_null($date)) {
|
||||
$key = 'account.' . $account->id . '.latestBalance';
|
||||
} else {
|
||||
$key = 'account.' . $account->id . '.balanceOn' . $date->format('dmy');
|
||||
}
|
||||
if (\Cache::has($key)) {
|
||||
// TODO find a way to reliably remove cache entries for accounts.
|
||||
#return \Cache::get($key);
|
||||
}
|
||||
$date = is_null($date) ? Carbon::now() : $date;
|
||||
\Log::debug('Now reached the moment we fire the query.');
|
||||
$balance = floatval(
|
||||
$account->transactions()->leftJoin(
|
||||
'transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id'
|
||||
)->where('transaction_journals.date', '<=', $date->format('Y-m-d'))->sum('transactions.amount')
|
||||
);
|
||||
\Cache::put($key, $balance, 20160);
|
||||
|
||||
return $balance;
|
||||
}
|
||||
|
@@ -3,6 +3,7 @@ use Carbon\Carbon;
|
||||
use Illuminate\Database\Eloquent\Model as Eloquent;
|
||||
use Illuminate\Database\Eloquent\SoftDeletingTrait;
|
||||
use Watson\Validating\ValidatingTrait;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
|
||||
/**
|
||||
* Class PiggyBank
|
||||
@@ -77,19 +78,19 @@ class PiggyBank extends Eloquent
|
||||
return $rep;
|
||||
} else {
|
||||
$query = $this->piggyBankRepetitions()->where(
|
||||
function ($q) {
|
||||
function (Builder $q) {
|
||||
|
||||
$q->where(
|
||||
function ($q) {
|
||||
function (Builder $q) {
|
||||
|
||||
$q->where(
|
||||
function ($q) {
|
||||
function (Builder $q) {
|
||||
$today = new Carbon;
|
||||
$q->whereNull('startdate');
|
||||
$q->orWhere('startdate', '<=', $today->format('Y-m-d 00:00:00'));
|
||||
}
|
||||
)->where(
|
||||
function ($q) {
|
||||
function (Builder $q) {
|
||||
$today = new Carbon;
|
||||
$q->whereNull('targetdate');
|
||||
$q->orWhere('targetdate', '>=', $today->format('Y-m-d 00:00:00'));
|
||||
@@ -97,7 +98,7 @@ class PiggyBank extends Eloquent
|
||||
);
|
||||
}
|
||||
)->orWhere(
|
||||
function ($q) {
|
||||
function (Builder $q) {
|
||||
$today = new Carbon;
|
||||
$q->where('startdate', '>=', $today->format('Y-m-d 00:00:00'));
|
||||
$q->where('targetdate', '>=', $today->format('Y-m-d 00:00:00'));
|
||||
|
@@ -192,7 +192,7 @@ class TransactionJournal extends Eloquent
|
||||
public function scopeWithRelevantData(Builder $query)
|
||||
{
|
||||
$query->with(
|
||||
['transactions' => function ($q) {
|
||||
['transactions' => function (Builder $q) {
|
||||
$q->orderBy('amount', 'ASC');
|
||||
}, 'transactiontype', 'budgets','categories', 'transactions.account.accounttype', 'bill', 'budgets', 'categories']
|
||||
);
|
||||
|
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
// models:
|
||||
// models
|
||||
Route::bind(
|
||||
'account',
|
||||
function ($value, $route) {
|
||||
@@ -167,7 +167,6 @@ Route::group(
|
||||
|
||||
// some date routes used for (well duh) date-based navigation.
|
||||
Route::get('/prev', ['uses' => 'HomeController@sessionPrev', 'as' => 'sessionPrev']);
|
||||
//Route::get('/repair', ['uses' => 'HomeController@repair']);
|
||||
Route::get('/next', ['uses' => 'HomeController@sessionNext', 'as' => 'sessionNext']);
|
||||
Route::get('/jump/{range}', ['uses' => 'HomeController@rangeJump', 'as' => 'rangeJump']);
|
||||
|
||||
@@ -268,7 +267,6 @@ Route::group(
|
||||
Route::get('/reports/{year}', ['uses' => 'ReportController@year', 'as' => 'reports.year']);
|
||||
Route::get('/reports/{year}/{month}', ['uses' => 'ReportController@month', 'as' => 'reports.month']);
|
||||
Route::get('/reports/budget/{year}/{month}', ['uses' => 'ReportController@budget', 'as' => 'reports.budget']);
|
||||
#Route::get('/reports/unbalanced/{year}/{month}', ['uses' => 'ReportController@unbalanced', 'as' => 'reports.unbalanced']);
|
||||
|
||||
// reminder controller
|
||||
Route::get('/reminders/{reminder}', ['uses' => 'ReminderController@show', 'as' => 'reminders.show']);
|
||||
|
@@ -68,7 +68,7 @@ App::down(
|
||||
}
|
||||
);
|
||||
|
||||
// forms:
|
||||
// forms
|
||||
\Form::macro(
|
||||
'ffText', function ($name, $value = null, array $options = []) {
|
||||
return \FireflyIII\Form\Form::ffText($name, $value, $options);
|
||||
|
Reference in New Issue
Block a user