mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-12 15:35:15 +00:00
Various code cleanup.
This commit is contained in:
@@ -136,12 +136,12 @@ class Transaction extends Twig_Extension
|
||||
}
|
||||
|
||||
// transaction has a budget
|
||||
if (null !== $transaction->transaction_budget_id && $txt === '') {
|
||||
if (null !== $transaction->transaction_budget_id && '' === $txt) {
|
||||
$name = app('steam')->tryDecrypt($transaction->transaction_budget_name);
|
||||
$txt = sprintf('<a href="%s" title="%s">%s</a>', route('budgets.show', [$transaction->transaction_budget_id]), $name, $name);
|
||||
}
|
||||
|
||||
if ($txt === '') {
|
||||
if ('' === $txt) {
|
||||
// see if the transaction has a budget:
|
||||
$budgets = $transaction->budgets()->get();
|
||||
if (0 === $budgets->count()) {
|
||||
@@ -174,12 +174,12 @@ class Transaction extends Twig_Extension
|
||||
}
|
||||
|
||||
// transaction has a category:
|
||||
if (null !== $transaction->transaction_category_id && $txt === '') {
|
||||
if (null !== $transaction->transaction_category_id && '' === $txt) {
|
||||
$name = app('steam')->tryDecrypt($transaction->transaction_category_name);
|
||||
$txt = sprintf('<a href="%s" title="%s">%s</a>', route('categories.show', [$transaction->transaction_category_id]), $name, $name);
|
||||
}
|
||||
|
||||
if ($txt === '') {
|
||||
if ('' === $txt) {
|
||||
// see if the transaction has a category:
|
||||
$categories = $transaction->categories()->get();
|
||||
if (0 === $categories->count()) {
|
||||
@@ -229,14 +229,14 @@ class Transaction extends Twig_Extension
|
||||
$type = $transaction->account_type;
|
||||
|
||||
// name is present in object, use that one:
|
||||
if (bccomp($transaction->transaction_amount, '0') === -1 && null !== $transaction->opposing_account_id) {
|
||||
if (null !== $transaction->opposing_account_id && bccomp($transaction->transaction_amount, '0') === -1) {
|
||||
$name = $transaction->opposing_account_name;
|
||||
$transactionId = (int)$transaction->opposing_account_id;
|
||||
$type = $transaction->opposing_account_type;
|
||||
}
|
||||
|
||||
// Find the opposing account and use that one:
|
||||
if (bccomp($transaction->transaction_amount, '0') === -1 && null === $transaction->opposing_account_id) {
|
||||
if (null === $transaction->opposing_account_id && bccomp($transaction->transaction_amount, '0') === -1) {
|
||||
// if the amount is negative, find the opposing account and use that one:
|
||||
$journalId = $transaction->journal_id;
|
||||
/** @var TransactionModel $other */
|
||||
@@ -259,7 +259,7 @@ class Transaction extends Twig_Extension
|
||||
}
|
||||
|
||||
if (AccountType::CASH === $type) {
|
||||
$txt = '<span class="text-success">(' . (string)trans('firefly.cash') . ')</span>';
|
||||
$txt = '<span class="text-success">(' . trans('firefly.cash') . ')</span>';
|
||||
|
||||
return $txt;
|
||||
}
|
||||
@@ -285,7 +285,7 @@ class Transaction extends Twig_Extension
|
||||
)
|
||||
);
|
||||
}
|
||||
if ($transaction->attachmentCount === null) {
|
||||
if (null === $transaction->attachmentCount) {
|
||||
$journalId = (int)$transaction->journal_id;
|
||||
$count = Attachment::whereNull('deleted_at')
|
||||
->where('attachable_type', TransactionJournal::class)
|
||||
@@ -355,11 +355,11 @@ class Transaction extends Twig_Extension
|
||||
public function isSplit(TransactionModel $transaction): string
|
||||
{
|
||||
$res = '';
|
||||
if ($transaction->is_split === true) {
|
||||
if (true === $transaction->is_split) {
|
||||
$res = '<i class="fa fa-fw fa-share-alt" aria-hidden="true"></i>';
|
||||
}
|
||||
|
||||
if ($transaction->is_split === null) {
|
||||
if (null === $transaction->is_split) {
|
||||
$journalId = (int)$transaction->journal_id;
|
||||
$count = TransactionModel::where('transaction_journal_id', $journalId)->whereNull('deleted_at')->count();
|
||||
if ($count > 2) {
|
||||
@@ -387,13 +387,13 @@ class Transaction extends Twig_Extension
|
||||
$type = $transaction->account_type;
|
||||
|
||||
// name is present in object, use that one:
|
||||
if (1 === bccomp($transaction->transaction_amount, '0') && null !== $transaction->opposing_account_id) {
|
||||
if (null !== $transaction->opposing_account_id && 1 === bccomp($transaction->transaction_amount, '0')) {
|
||||
$name = $transaction->opposing_account_name;
|
||||
$transactionId = (int)$transaction->opposing_account_id;
|
||||
$type = $transaction->opposing_account_type;
|
||||
}
|
||||
// Find the opposing account and use that one:
|
||||
if (1 === bccomp($transaction->transaction_amount, '0') && null === $transaction->opposing_account_id) {
|
||||
if (null === $transaction->opposing_account_id && 1 === bccomp($transaction->transaction_amount, '0')) {
|
||||
$journalId = $transaction->journal_id;
|
||||
/** @var TransactionModel $other */
|
||||
$other = TransactionModel::where('transaction_journal_id', $journalId)->where('transactions.id', '!=', $transaction->id)
|
||||
@@ -410,7 +410,7 @@ class Transaction extends Twig_Extension
|
||||
}
|
||||
|
||||
if (AccountType::CASH === $type) {
|
||||
$txt = '<span class="text-success">(' . (string)trans('firefly.cash') . ')</span>';
|
||||
$txt = '<span class="text-success">(' . trans('firefly.cash') . ')</span>';
|
||||
|
||||
return $txt;
|
||||
}
|
||||
|
Reference in New Issue
Block a user