Rearrange code [skip ci]

This commit is contained in:
James Cole
2016-12-14 18:59:12 +01:00
parent f19b99194c
commit 848cfabcba
45 changed files with 321 additions and 319 deletions

View File

@@ -200,7 +200,7 @@ class TransactionJournalSupport extends Model
*
* @return bool
*/
public static function isJoined(Builder $query, string $table):bool
public static function isJoined(Builder $query, string $table): bool
{
$joins = $query->getQuery()->joins;
if (is_null($joins)) {

View File

@@ -59,8 +59,8 @@ class Preferences
}
/**
* @param \FireflyIII\User $user
* @param array $list
* @param \FireflyIII\User $user
* @param array $list
*
* @return array
*/

View File

@@ -84,7 +84,7 @@ class General extends Twig_Extension
protected function activeRoutePartial(): Twig_SimpleFunction
{
return new Twig_SimpleFunction(
'activeRoutePartial', function () : string {
'activeRoutePartial', function (): string {
$args = func_get_args();
$route = $args[0]; // name of the route.
$name = Route::getCurrentRoute()->getName() ?? '';
@@ -106,7 +106,7 @@ class General extends Twig_Extension
protected function activeRoutePartialWhat(): Twig_SimpleFunction
{
return new Twig_SimpleFunction(
'activeRoutePartialWhat', function ($context) : string {
'activeRoutePartialWhat', function ($context): string {
$args = func_get_args();
$route = $args[1]; // name of the route.
$what = $args[2]; // name of the route.
@@ -130,7 +130,7 @@ class General extends Twig_Extension
protected function activeRouteStrict(): Twig_SimpleFunction
{
return new Twig_SimpleFunction(
'activeRouteStrict', function () : string {
'activeRouteStrict', function (): string {
$args = func_get_args();
$route = $args[0]; // name of the route.
@@ -149,7 +149,7 @@ class General extends Twig_Extension
protected function balance(): Twig_SimpleFilter
{
return new Twig_SimpleFilter(
'balance', function (Account $account = null) : string {
'balance', function (Account $account = null): string {
if (is_null($account)) {
return 'NULL';
}
@@ -166,7 +166,7 @@ class General extends Twig_Extension
protected function env(): Twig_SimpleFunction
{
return new Twig_SimpleFunction(
'env', function (string $name, string $default) : string {
'env', function (string $name, string $default): string {
return env($name, $default);
}
);
@@ -179,7 +179,7 @@ class General extends Twig_Extension
protected function formatAmount(): Twig_SimpleFilter
{
return new Twig_SimpleFilter(
'formatAmount', function (string $string) : string {
'formatAmount', function (string $string): string {
return app('amount')->format($string);
}, ['is_safe' => ['html']]
@@ -192,7 +192,7 @@ class General extends Twig_Extension
protected function formatAmountPlain(): Twig_SimpleFilter
{
return new Twig_SimpleFilter(
'formatAmountPlain', function (string $string) : string {
'formatAmountPlain', function (string $string): string {
return app('amount')->format($string, false);
}, ['is_safe' => ['html']]
@@ -205,7 +205,7 @@ class General extends Twig_Extension
protected function formatFilesize(): Twig_SimpleFilter
{
return new Twig_SimpleFilter(
'filesize', function (int $size) : string {
'filesize', function (int $size): string {
// less than one GB, more than one MB
if ($size < (1024 * 1024 * 2014) && $size >= (1024 * 1024)) {
@@ -228,7 +228,7 @@ class General extends Twig_Extension
protected function formatJournal(): Twig_SimpleFilter
{
return new Twig_SimpleFilter(
'formatJournal', function (TransactionJournal $journal) : string {
'formatJournal', function (TransactionJournal $journal): string {
return app('amount')->formatJournal($journal);
}, ['is_safe' => ['html']]
);
@@ -240,7 +240,7 @@ class General extends Twig_Extension
protected function getAccountRole(): Twig_SimpleFilter
{
return new Twig_SimpleFilter(
'getAccountRole', function (string $name) : string {
'getAccountRole', function (string $name): string {
return Config::get('firefly.accountRoles.' . $name);
}
);
@@ -252,7 +252,7 @@ class General extends Twig_Extension
protected function getCurrencyCode(): Twig_SimpleFunction
{
return new Twig_SimpleFunction(
'getCurrencyCode', function () : string {
'getCurrencyCode', function (): string {
return app('amount')->getCurrencyCode();
}
);
@@ -264,7 +264,7 @@ class General extends Twig_Extension
protected function getCurrencySymbol(): Twig_SimpleFunction
{
return new Twig_SimpleFunction(
'getCurrencySymbol', function () : string {
'getCurrencySymbol', function (): string {
return app('amount')->getCurrencySymbol();
}
);
@@ -276,7 +276,7 @@ class General extends Twig_Extension
protected function mimeIcon(): Twig_SimpleFilter
{
return new Twig_SimpleFilter(
'mimeIcon', function (string $string) : string {
'mimeIcon', function (string $string): string {
switch ($string) {
default:
return 'fa-file-o';
@@ -296,7 +296,7 @@ class General extends Twig_Extension
protected function phpdate()
{
return new Twig_SimpleFunction(
'phpdate', function (string $str) : string {
'phpdate', function (string $str): string {
return date($str);
}
);
@@ -308,7 +308,7 @@ class General extends Twig_Extension
private function getAmountFromJournal()
{
return new Twig_SimpleFunction(
'getAmount', function (TransactionJournal $journal) : string {
'getAmount', function (TransactionJournal $journal): string {
return TransactionJournal::amount($journal);
}
);

View File

@@ -110,9 +110,9 @@ class Transaction extends Twig_Extension
$amount = strval(
TransactionModel::where('transaction_journal_id', $journalId)
->whereNull('deleted_at')
->where('amount', '<', 0)
->sum('amount')
->whereNull('deleted_at')
->where('amount', '<', 0)
->sum('amount')
);
if ($type === TransactionType::DEPOSIT || $type === TransactionType::TRANSFER) {
@@ -203,10 +203,10 @@ class Transaction extends Twig_Extension
$journalId = $transaction->journal_id;
/** @var TransactionModel $other */
$other = TransactionModel::where('transaction_journal_id', $journalId)->where('transactions.id', '!=', $transaction->id)
->where('amount', '=', bcmul($transaction->transaction_amount, '-1'))->where('identifier', $transaction->identifier)
->leftJoin('accounts', 'accounts.id', '=', 'transactions.account_id')
->leftJoin('account_types', 'account_types.id', '=', 'accounts.account_type_id')
->first(['transactions.account_id', 'accounts.encrypted', 'accounts.name', 'account_types.type']);
->where('amount', '=', bcmul($transaction->transaction_amount, '-1'))->where('identifier', $transaction->identifier)
->leftJoin('accounts', 'accounts.id', '=', 'transactions.account_id')
->leftJoin('account_types', 'account_types.id', '=', 'accounts.account_type_id')
->first(['transactions.account_id', 'accounts.encrypted', 'accounts.name', 'account_types.type']);
$name = intval($other->encrypted) === 1 ? Crypt::decrypt($other->name) : $other->name;
$id = $other->account_id;
$type = $other->type;
@@ -275,10 +275,10 @@ class Transaction extends Twig_Extension
$journalId = $transaction->journal_id;
/** @var TransactionModel $other */
$other = TransactionModel::where('transaction_journal_id', $journalId)->where('transactions.id', '!=', $transaction->id)
->where('amount', '=', bcmul($transaction->transaction_amount, '-1'))->where('identifier', $transaction->identifier)
->leftJoin('accounts', 'accounts.id', '=', 'transactions.account_id')
->leftJoin('account_types', 'account_types.id', '=', 'accounts.account_type_id')
->first(['transactions.account_id', 'accounts.encrypted', 'accounts.name', 'account_types.type']);
->where('amount', '=', bcmul($transaction->transaction_amount, '-1'))->where('identifier', $transaction->identifier)
->leftJoin('accounts', 'accounts.id', '=', 'transactions.account_id')
->leftJoin('account_types', 'account_types.id', '=', 'accounts.account_type_id')
->first(['transactions.account_id', 'accounts.encrypted', 'accounts.name', 'account_types.type']);
$name = intval($other->encrypted) === 1 ? Crypt::decrypt($other->name) : $other->name;
$id = $other->account_id;
$type = $other->type;