Code clean up.

This commit is contained in:
James Cole
2017-11-15 11:33:07 +01:00
parent ef837f20dd
commit 57dcdfa0c4
60 changed files with 398 additions and 347 deletions

View File

@@ -89,7 +89,7 @@ class MonthReportGenerator extends Support implements ReportGeneratorInterface
return view(
'reports.tag.month',
compact(
'accountIds',
'accountIds',
'tagTags',
'reportType',
'accountSummary',
@@ -97,8 +97,8 @@ class MonthReportGenerator extends Support implements ReportGeneratorInterface
'averageExpenses',
'averageIncome',
'topIncome',
'topExpenses'
)
'topExpenses'
)
)->with('start', $this->start)->with('end', $this->end)->with('tags', $this->tags)->with('accounts', $this->accounts)->render();
}

View File

@@ -785,8 +785,8 @@ class JournalCollector implements JournalCollectorInterface
'transactions as opposing',
function (JoinClause $join) {
$join->on('opposing.transaction_journal_id', '=', 'transactions.transaction_journal_id')
->where('opposing.identifier', '=', DB::raw('transactions.identifier'))
->where('opposing.amount', '=', DB::raw('transactions.amount * -1'));
->where('opposing.identifier', '=', DB::raw('transactions.identifier'))
->where('opposing.amount', '=', DB::raw('transactions.amount * -1'));
}
);
$this->query->leftJoin('accounts as opposing_accounts', 'opposing.account_id', '=', 'opposing_accounts.id');

View File

@@ -132,7 +132,7 @@ class ReconcileController extends Controller
return view(
'accounts.reconcile.index',
compact(
'account',
'account',
'currency',
'subTitleIcon',
'start',
@@ -141,11 +141,11 @@ class ReconcileController extends Controller
'startBalance',
'endBalance',
'transactionsUri',
'selectionStart',
'selectionStart',
'selectionEnd',
'overviewUri',
'indexUri'
)
)
);
}

View File

@@ -209,7 +209,7 @@ class AccountController extends Controller
return view(
'accounts.edit',
compact(
'allCurrencies',
'allCurrencies',
'currencySelectList',
'account',
'currency',
@@ -218,7 +218,7 @@ class AccountController extends Controller
'what',
'roles',
'preFilled'
)
)
);
}

View File

@@ -85,14 +85,18 @@ class LoginController extends Controller
$hasTable = Schema::hasTable('users');
if (!$hasTable) {
$message = 'Firefly III could not find the "users" table. This is a strong indication your database credentials are wrong or the database has not been initialized. Did you follow the installation instructions correctly?';
$message
= 'Firefly III could not find the "users" table. This is a strong indication your database credentials are wrong or the database has not been initialized. Did you follow the installation instructions correctly?';
return view('error', compact('message'));
}
// check for presence of currency:
$currency = TransactionCurrency::where('code', 'EUR')->first();
if (is_null($currency)) {
$message = 'Firefly III could not find the EURO currency. This is a strong indication the database has not been initialized correctly. Did you follow the installation instructions?';
$message
= 'Firefly III could not find the EURO currency. This is a strong indication the database has not been initialized correctly. Did you follow the installation instructions?';
return view('error', compact('message'));
}

View File

@@ -160,9 +160,9 @@ class RegisterController extends Controller
return Validator::make(
$data,
[
'email' => 'required|string|email|max:255|unique:users',
'password' => 'required|string|secure_password|confirmed',
]
'email' => 'required|string|email|max:255|unique:users',
'password' => 'required|string|secure_password|confirmed',
]
);
}
}

View File

@@ -455,10 +455,10 @@ class BudgetController extends Controller
$subTitle = trans(
'firefly.budget_in_period',
[
'name' => $budget->name,
'start' => $budgetLimit->start_date->formatLocalized($this->monthAndDayFormat),
'end' => $budgetLimit->end_date->formatLocalized($this->monthAndDayFormat),
]
'name' => $budget->name,
'start' => $budgetLimit->start_date->formatLocalized($this->monthAndDayFormat),
'end' => $budgetLimit->end_date->formatLocalized($this->monthAndDayFormat),
]
);
// collector:

View File

@@ -123,7 +123,7 @@ class HomeController extends Controller
return view(
'debug',
compact(
'phpVersion',
'phpVersion',
'extensions',
'carbon',
'now',
@@ -136,7 +136,7 @@ class HomeController extends Controller
'isDocker',
'isSandstorm',
'trustedProxies'
)
)
);
}

View File

@@ -291,11 +291,11 @@ class PiggyBankController extends Controller
Session::flash(
'success',
strval(
trans(
'firefly.added_amount_to_piggy',
['amount' => app('amount')->formatAnything($currency, $amount, false), 'name' => $piggyBank->name]
)
)
trans(
'firefly.added_amount_to_piggy',
['amount' => app('amount')->formatAnything($currency, $amount, false), 'name' => $piggyBank->name]
)
)
);
Preferences::mark();
@@ -306,11 +306,11 @@ class PiggyBankController extends Controller
Session::flash(
'error',
strval(
trans(
'firefly.cannot_add_amount_piggy',
['amount' => app('amount')->formatAnything($currency, $amount, false), 'name' => $piggyBank->name]
)
)
trans(
'firefly.cannot_add_amount_piggy',
['amount' => app('amount')->formatAnything($currency, $amount, false), 'name' => $piggyBank->name]
)
)
);
return redirect(route('piggy-banks.index'));
@@ -348,11 +348,11 @@ class PiggyBankController extends Controller
Session::flash(
'error',
strval(
trans(
'firefly.cannot_remove_from_piggy',
['amount' => app('amount')->formatAnything($currency, $amount, false), 'name' => $piggyBank->name]
)
)
trans(
'firefly.cannot_remove_from_piggy',
['amount' => app('amount')->formatAnything($currency, $amount, false), 'name' => $piggyBank->name]
)
)
);
return redirect(route('piggy-banks.index'));

View File

@@ -90,12 +90,12 @@ class ReportController extends Controller
View::share(
'subTitle',
trans(
'firefly.report_audit',
[
'start' => $start->formatLocalized($this->monthFormat),
'end' => $end->formatLocalized($this->monthFormat),
]
)
'firefly.report_audit',
[
'start' => $start->formatLocalized($this->monthFormat),
'end' => $end->formatLocalized($this->monthFormat),
]
)
);
@@ -126,12 +126,12 @@ class ReportController extends Controller
View::share(
'subTitle',
trans(
'firefly.report_budget',
[
'start' => $start->formatLocalized($this->monthFormat),
'end' => $end->formatLocalized($this->monthFormat),
]
)
'firefly.report_budget',
[
'start' => $start->formatLocalized($this->monthFormat),
'end' => $end->formatLocalized($this->monthFormat),
]
)
);
$generator = ReportGeneratorFactory::reportGenerator('Budget', $start, $end);
@@ -162,12 +162,12 @@ class ReportController extends Controller
View::share(
'subTitle',
trans(
'firefly.report_category',
[
'start' => $start->formatLocalized($this->monthFormat),
'end' => $end->formatLocalized($this->monthFormat),
]
)
'firefly.report_category',
[
'start' => $start->formatLocalized($this->monthFormat),
'end' => $end->formatLocalized($this->monthFormat),
]
)
);
$generator = ReportGeneratorFactory::reportGenerator('Category', $start, $end);
@@ -198,12 +198,12 @@ class ReportController extends Controller
View::share(
'subTitle',
trans(
'firefly.report_default',
[
'start' => $start->formatLocalized($this->monthFormat),
'end' => $end->formatLocalized($this->monthFormat),
]
)
'firefly.report_default',
[
'start' => $start->formatLocalized($this->monthFormat),
'end' => $end->formatLocalized($this->monthFormat),
]
)
);
$generator = ReportGeneratorFactory::reportGenerator('Standard', $start, $end);
@@ -344,12 +344,12 @@ class ReportController extends Controller
View::share(
'subTitle',
trans(
'firefly.report_tag',
[
'start' => $start->formatLocalized($this->monthFormat),
'end' => $end->formatLocalized($this->monthFormat),
]
)
'firefly.report_tag',
[
'start' => $start->formatLocalized($this->monthFormat),
'end' => $end->formatLocalized($this->monthFormat),
]
)
);
$generator = ReportGeneratorFactory::reportGenerator('Tag', $start, $end);

View File

@@ -213,15 +213,15 @@ class RuleController extends Controller
return view(
'rules.rule.edit',
compact(
'rule',
'rule',
'subTitle',
'primaryTrigger',
'primaryTrigger',
'oldTriggers',
'oldActions',
'triggerCount',
'actionCount',
'ruleGroups'
)
)
);
}

View File

@@ -94,10 +94,10 @@ Breadcrumbs::register(
// when is specific period or when empty:
if ($moment !== 'all' && $moment !== '(nothing)') {
$title = trans(
'firefly.between_dates_breadcrumb',
['start' => $start->formatLocalized(strval(trans('config.month_and_day'))),
'end' => $end->formatLocalized(strval(trans('config.month_and_day')))]
);
'firefly.between_dates_breadcrumb',
['start' => $start->formatLocalized(strval(trans('config.month_and_day'))),
'end' => $end->formatLocalized(strval(trans('config.month_and_day')))]
);
$breadcrumbs->push($title, route('accounts.show', [$account->id, $moment, $start, $end]));
}
}
@@ -344,10 +344,10 @@ Breadcrumbs::register(
// when is specific period or when empty:
if ($moment !== 'all' && $moment !== '(nothing)') {
$title = trans(
'firefly.between_dates_breadcrumb',
['start' => $start->formatLocalized(strval(trans('config.month_and_day'))),
'end' => $end->formatLocalized(strval(trans('config.month_and_day')))]
);
'firefly.between_dates_breadcrumb',
['start' => $start->formatLocalized(strval(trans('config.month_and_day'))),
'end' => $end->formatLocalized(strval(trans('config.month_and_day')))]
);
$breadcrumbs->push($title, route('budgets.no-budget', [$moment]));
}
}
@@ -369,15 +369,15 @@ Breadcrumbs::register(
$breadcrumbs->push(e($budget->name), route('budgets.show', [$budget->id]));
$title = trans(
'firefly.between_dates_breadcrumb',
['start' => $budgetLimit->start_date->formatLocalized(strval(trans('config.month_and_day'))),
'end' => $budgetLimit->end_date->formatLocalized(strval(trans('config.month_and_day'))),]
);
'firefly.between_dates_breadcrumb',
['start' => $budgetLimit->start_date->formatLocalized(strval(trans('config.month_and_day'))),
'end' => $budgetLimit->end_date->formatLocalized(strval(trans('config.month_and_day'))),]
);
$breadcrumbs->push(
$title,
route('budgets.show.limit', [$budget->id, $budgetLimit->id])
);
$title,
route('budgets.show.limit', [$budget->id, $budgetLimit->id])
);
}
);
@@ -427,10 +427,10 @@ Breadcrumbs::register(
// when is specific period or when empty:
if ($moment !== 'all' && $moment !== '(nothing)') {
$title = trans(
'firefly.between_dates_breadcrumb',
['start' => $start->formatLocalized(strval(trans('config.month_and_day'))),
'end' => $end->formatLocalized(strval(trans('config.month_and_day')))]
);
'firefly.between_dates_breadcrumb',
['start' => $start->formatLocalized(strval(trans('config.month_and_day'))),
'end' => $end->formatLocalized(strval(trans('config.month_and_day')))]
);
$breadcrumbs->push($title, route('categories.show', [$category->id, $moment]));
}
}
@@ -450,10 +450,10 @@ Breadcrumbs::register(
// when is specific period or when empty:
if ($moment !== 'all' && $moment !== '(nothing)') {
$title = trans(
'firefly.between_dates_breadcrumb',
['start' => $start->formatLocalized(strval(trans('config.month_and_day'))),
'end' => $end->formatLocalized(strval(trans('config.month_and_day')))]
);
'firefly.between_dates_breadcrumb',
['start' => $start->formatLocalized(strval(trans('config.month_and_day'))),
'end' => $end->formatLocalized(strval(trans('config.month_and_day')))]
);
$breadcrumbs->push($title, route('categories.no-category', [$moment]));
}
}
@@ -559,9 +559,9 @@ Breadcrumbs::register(
function (BreadCrumbGenerator $breadcrumbs, PiggyBank $piggyBank) {
$breadcrumbs->parent('piggy-banks.show', $piggyBank);
$breadcrumbs->push(
trans('firefly.remove_money_from_piggy_title', ['name' => $piggyBank->name]),
route('piggy-banks.remove-money-mobile', [$piggyBank->id])
);
trans('firefly.remove_money_from_piggy_title', ['name' => $piggyBank->name]),
route('piggy-banks.remove-money-mobile', [$piggyBank->id])
);
}
);
@@ -795,7 +795,9 @@ Breadcrumbs::register(
'rule-groups.select-transactions',
function (BreadCrumbGenerator $breadcrumbs, RuleGroup $ruleGroup) {
$breadcrumbs->parent('rules.index');
$breadcrumbs->push(trans('firefly.rule_group_select_transactions', ['title' => $ruleGroup->title]), route('rule-groups.select-transactions', [$ruleGroup]));
$breadcrumbs->push(
trans('firefly.rule_group_select_transactions', ['title' => $ruleGroup->title]), route('rule-groups.select-transactions', [$ruleGroup])
);
}
);
@@ -804,9 +806,9 @@ Breadcrumbs::register(
function (BreadCrumbGenerator $breadcrumbs, RuleGroup $ruleGroup) {
$breadcrumbs->parent('rules.index');
$breadcrumbs->push(
trans('firefly.execute_group_on_existing_transactions', ['title' => $ruleGroup->title]),
route('rule-groups.select_transactions', [$ruleGroup])
);
trans('firefly.execute_group_on_existing_transactions', ['title' => $ruleGroup->title]),
route('rule-groups.select_transactions', [$ruleGroup])
);
}
);
@@ -870,10 +872,10 @@ Breadcrumbs::register(
// when is specific period or when empty:
if ($moment !== 'all' && $moment !== '(nothing)') {
$title = trans(
'firefly.between_dates_breadcrumb',
['start' => $start->formatLocalized(strval(trans('config.month_and_day'))),
'end' => $end->formatLocalized(strval(trans('config.month_and_day')))]
);
'firefly.between_dates_breadcrumb',
['start' => $start->formatLocalized(strval(trans('config.month_and_day'))),
'end' => $end->formatLocalized(strval(trans('config.month_and_day')))]
);
$breadcrumbs->push($title, route('tags.show', [$tag->id, $moment]));
}
}
@@ -894,10 +896,10 @@ Breadcrumbs::register(
// when is specific period or when empty:
if ($moment !== 'all' && $moment !== '(nothing)') {
$title = trans(
'firefly.between_dates_breadcrumb',
['start' => $start->formatLocalized(strval(trans('config.month_and_day'))),
'end' => $end->formatLocalized(strval(trans('config.month_and_day')))]
);
'firefly.between_dates_breadcrumb',
['start' => $start->formatLocalized(strval(trans('config.month_and_day'))),
'end' => $end->formatLocalized(strval(trans('config.month_and_day')))]
);
$breadcrumbs->push($title, route('transactions.index', [$what, $moment]));
}
}
@@ -940,9 +942,9 @@ Breadcrumbs::register(
function (BreadCrumbGenerator $breadcrumbs, TransactionType $destinationType, TransactionJournal $journal) {
$breadcrumbs->parent('transactions.show', $journal);
$breadcrumbs->push(
trans('firefly.convert_to_' . $destinationType->type, ['description' => $journal->description]),
route('transactions.convert.index', [strtolower($destinationType->type), $journal->id])
);
trans('firefly.convert_to_' . $destinationType->type, ['description' => $journal->description]),
route('transactions.convert.index', [strtolower($destinationType->type), $journal->id])
);
}
);

View File

@@ -140,6 +140,7 @@ class ImportRoutine
if ($this->journals->count() < 1) {
Log::info(sprintf('Will not create tag, %d journals imported.', $this->journals->count()));
return new Tag;
}

View File

@@ -277,10 +277,10 @@ trait ImportSupport
'transactions AS destination',
function (JoinClause $join) {
$join->on('transaction_journals.id', '=', 'destination.transaction_journal_id')->where(
'destination.amount',
'>',
0
);
'destination.amount',
'>',
0
);
}
)
->leftJoin('accounts as source_accounts', 'source.account_id', '=', 'source_accounts.id')

View File

@@ -89,10 +89,10 @@ class JournalTasker implements JournalTaskerInterface
'transactions as destination',
function (JoinClause $join) {
$join
->on('transactions.transaction_journal_id', '=', 'destination.transaction_journal_id')
->where('transactions.amount', '=', DB::raw('destination.amount * -1'))
->where('transactions.identifier', '=', DB::raw('destination.identifier'))
->whereNull('destination.deleted_at');
->on('transactions.transaction_journal_id', '=', 'destination.transaction_journal_id')
->where('transactions.amount', '=', DB::raw('destination.amount * -1'))
->where('transactions.identifier', '=', DB::raw('destination.identifier'))
->whereNull('destination.deleted_at');
}
)
->with(['budgets', 'categories'])

View File

@@ -176,7 +176,7 @@ class AmountFormat extends Twig_Extension
'formatDestinationAfter',
function (array $transaction): string {
// build fake currency for main amount.
// build fake currency for main amount.
$format = new TransactionCurrency;
$format->decimal_places = $transaction['transaction_currency_dp'];
$format->symbol = $transaction['transaction_currency_symbol'];
@@ -207,7 +207,7 @@ class AmountFormat extends Twig_Extension
'formatDestinationBefore',
function (array $transaction): string {
// build fake currency for main amount.
// build fake currency for main amount.
$format = new TransactionCurrency;
$format->decimal_places = $transaction['transaction_currency_dp'];
$format->symbol = $transaction['transaction_currency_symbol'];
@@ -227,7 +227,7 @@ class AmountFormat extends Twig_Extension
'formatSourceAfter',
function (array $transaction): string {
// build fake currency for main amount.
// build fake currency for main amount.
$format = new TransactionCurrency;
$format->decimal_places = $transaction['transaction_currency_dp'];
$format->symbol = $transaction['transaction_currency_symbol'];
@@ -258,7 +258,7 @@ class AmountFormat extends Twig_Extension
'formatSourceBefore',
function (array $transaction): string {
// build fake currency for main amount.
// build fake currency for main amount.
$format = new TransactionCurrency;
$format->decimal_places = $transaction['transaction_currency_dp'];
$format->symbol = $transaction['transaction_currency_symbol'];

View File

@@ -310,7 +310,7 @@ class Transaction extends Twig_Extension
$other = TransactionModel::where('transaction_journal_id', $journalId)->where('transactions.id', '!=', $transaction->id)
->where('amount', '=', bcmul($transaction->transaction_amount, '-1'))->where(
'identifier',
$transaction->identifier
$transaction->identifier
)
->leftJoin('accounts', 'accounts.id', '=', 'transactions.account_id')
->leftJoin('account_types', 'account_types.id', '=', 'accounts.account_type_id')
@@ -489,7 +489,7 @@ class Transaction extends Twig_Extension
$other = TransactionModel::where('transaction_journal_id', $journalId)->where('transactions.id', '!=', $transaction->id)
->where('amount', '=', bcmul($transaction->transaction_amount, '-1'))->where(
'identifier',
$transaction->identifier
$transaction->identifier
)
->leftJoin('accounts', 'accounts.id', '=', 'transactions.account_id')
->leftJoin('account_types', 'account_types.id', '=', 'accounts.account_type_id')

View File

@@ -118,8 +118,8 @@ class General extends Twig_Extension
function ($context): string {
$args = func_get_args();
$route = $args[1]; // name of the route.
$what = $args[2]; // name of the route.
$activeWhat = $context['what'] ?? false;
$what = $args[2]; // name of the route.
$activeWhat = $context['what'] ?? false;
if ($what === $activeWhat && !(strpos(Route::getCurrentRoute()->getName(), $route) === false)) {
return 'active';
@@ -194,7 +194,7 @@ class General extends Twig_Extension
'filesize',
function (int $size): string {
// less than one GB, more than one MB
// less than one GB, more than one MB
if ($size < (1024 * 1024 * 2014) && $size >= (1024 * 1024)) {
return round($size / (1024 * 1024), 2) . ' MB';
}
@@ -245,14 +245,14 @@ class General extends Twig_Extension
'mimeIcon',
function (string $string): string {
switch ($string) {
default:
return 'fa-file-o';
case 'application/pdf':
return 'fa-file-pdf-o';
case 'image/png':
case 'image/jpeg':
return 'fa-file-image-o';
}
default:
return 'fa-file-o';
case 'application/pdf':
return 'fa-file-pdf-o';
case 'image/png':
case 'image/jpeg':
return 'fa-file-image-o';
}
},
['is_safe' => ['html']]
);

View File

@@ -207,11 +207,11 @@ class Journal extends Twig_Extension
}
if (count($categories) === 0) {
$set = Category::distinct()->leftJoin('category_transaction', 'categories.id', '=', 'category_transaction.category_id')
->leftJoin('transactions', 'category_transaction.transaction_id', '=', 'transactions.id')
->leftJoin('transaction_journals', 'transactions.transaction_journal_id', '=', 'transaction_journals.id')
->where('categories.user_id', $journal->user_id)
->where('transaction_journals.id', $journal->id)
->get(['categories.*']);
->leftJoin('transactions', 'category_transaction.transaction_id', '=', 'transactions.id')
->leftJoin('transaction_journals', 'transactions.transaction_journal_id', '=', 'transaction_journals.id')
->where('categories.user_id', $journal->user_id)
->where('transaction_journals.id', $journal->id)
->get(['categories.*']);
/** @var Category $category */
foreach ($set as $category) {
$categories[] = sprintf('<a title="%1$s" href="%2$s">%1$s</a>', e($category->name), route('categories.show', $category->id));

View File

@@ -66,9 +66,9 @@ class Rule extends Twig_Extension
'allJournalTriggers',
function () {
return [
'store-journal' => trans('firefly.rule_trigger_store_journal'),
'update-journal' => trans('firefly.rule_trigger_update_journal'),
];
'store-journal' => trans('firefly.rule_trigger_store_journal'),
'update-journal' => trans('firefly.rule_trigger_update_journal'),
];
}
);
}

View File

@@ -60,9 +60,9 @@ class SetBudget implements ActionInterface
/** @var BudgetRepositoryInterface $repository */
$repository = app(BudgetRepositoryInterface::class);
$repository->setUser($journal->user);
$search = $this->action->action_value;
$search = $this->action->action_value;
$budgets = $repository->getActiveBudgets();
$budget = $budgets->filter(
$budget = $budgets->filter(
function (Budget $current) use ($search) {
return $current->name === $search;
}