Skip to content

Firefly III: a personal finances manager

Fixed some transaction list filter issues.

James Cole8f5289b7dc5d
diff --git a/app/Helpers/Collector/JournalCollector.php b/app/Helpers/Collector/JournalCollector.php
index f1de985b9e..945f604f6c 100644
--- a/app/Helpers/Collector/JournalCollector.php
+++ b/app/Helpers/Collector/JournalCollector.php
@@ -506,6 +506,7 @@ class JournalCollector implements JournalCollectorInterface
{
$this->joinOpposingTables();
+ /**
$accountIds = $this->accountIds;
$this->query->where(
function (EloquentBuilder $q1) use ($accountIds) {
@@ -535,6 +536,7 @@ class JournalCollector implements JournalCollectorInterface
);
}
);
+ * **/
return $this;
}
@@ -637,12 +639,12 @@ class JournalCollector implements JournalCollectorInterface
continue;
}
// make property string:
- $journalId = $transaction->transaction_journal_id;
- $amount = Steam::positive($transaction->transaction_amount);
- $source = $transaction->account_id;
- $dest = $transaction->opposing_account_id;
- $key = $journalId . $source . $dest . $amount;
-
+ $journalId = $transaction->transaction_journal_id;
+ $amount = Steam::positive($transaction->transaction_amount);
+ $accountIds = [intval($transaction->account_id), intval($transaction->opposing_account_id)];
+ sort($accountIds);
+ $key = $journalId . '-' . join(',', $accountIds) . '-' . $amount;
+ Log::debug(sprintf('Key is %s', $key));
if (!isset($count[$key])) {
// not yet counted? add to new set and count it:
$new->push($transaction);
diff --git a/app/Http/Controllers/TransactionController.php b/app/Http/Controllers/TransactionController.php
index 3557144c94..b0ef6013ab 100644
--- a/app/Http/Controllers/TransactionController.php
+++ b/app/Http/Controllers/TransactionController.php
@@ -73,15 +73,10 @@ class TransactionController extends Controller
/** @var JournalCollectorInterface $collector */
$collector = app(JournalCollectorInterface::class);
- $collector->setTypes($types)->setLimit($pageSize)->setPage($page)->setAllAssetAccounts();
- $collector->setRange($start, $end)->withBudgetInformation()->withCategoryInformation();
-
- // do not filter transfers if $what = transfer.
- if (!in_array($what, ['transfer', 'transfers'])) {
- Log::debug('Also get opposing account info.');
- $collector->withOpposingAccount();
- }
-
+ $collector->setTypes($types)->setLimit($pageSize)->setPage($page)->setAllAssetAccounts()->setRange($start, $end)->withBudgetInformation()
+ ->withCategoryInformation();
+ $collector->withOpposingAccount();
+ $collector->disableInternalFilter();
$journals = $collector->getPaginatedJournals();
$journals->setPath('transactions/' . $what);
@@ -122,14 +117,11 @@ class TransactionController extends Controller
$subTitle = sprintf('%s (%s)', trans('firefly.title_' . $what), strtolower(trans('firefly.everything')));
$page = intval($request->get('page')) === 0 ? 1 : intval($request->get('page'));
+ /** @var JournalCollectorInterface $collector */
$collector = app(JournalCollectorInterface::class);
$collector->setTypes($types)->setLimit($pageSize)->setPage($page)->setAllAssetAccounts()->withBudgetInformation()->withCategoryInformation();
-
- // do not filter transfers if $what = transfer.
- if (!in_array($what, ['transfer', 'transfers'])) {
- Log::debug('Also get opposing account info.');
- $collector->withOpposingAccount();
- }
+ $collector->withOpposingAccount();
+ $collector->disableInternalFilter();
$journals = $collector->getPaginatedJournals();
$journals->setPath('transactions/' . $what . '/all');
@@ -165,13 +157,8 @@ class TransactionController extends Controller
$collector->setUser(auth()->user());
$collector->setTypes($types)->setLimit($pageSize)->setPage($page)->setAllAssetAccounts();
$collector->setRange($start, $end)->withBudgetInformation()->withCategoryInformation();
-
- // do not filter transfers if $what = transfer.
- if (!in_array($what, ['transfer', 'transfers'])) {
- Log::debug('Also get opposing account info.');
- $collector->withOpposingAccount();
- }
-
+ $collector->withOpposingAccount();
+ $collector->disableInternalFilter();
$journals = $collector->getPaginatedJournals();
$journals->setPath('transactions/' . $what . '/' . $date);
diff --git a/app/Support/Twig/General.php b/app/Support/Twig/General.php
index cfd98fcafc..5d339960fa 100644
--- a/app/Support/Twig/General.php
+++ b/app/Support/Twig/General.php
@@ -17,6 +17,7 @@ use Carbon\Carbon;
use FireflyIII\Models\Account;
use FireflyIII\Models\TransactionJournal;
use Route;
+use Steam;
use Twig_Extension;
use Twig_SimpleFilter;
use Twig_SimpleFunction;
@@ -43,6 +44,7 @@ class General extends Twig_Extension
$this->balance(),
$this->formatFilesize(),
$this->mimeIcon(),
+
];
}
@@ -59,6 +61,7 @@ class General extends Twig_Extension
$this->env(),
$this->getAmountFromJournal(),
$this->activeRouteStrict(),
+ $this->steamPositive(),
$this->activeRoutePartial(),
$this->activeRoutePartialWhat(),
];
@@ -288,6 +291,18 @@ class General extends Twig_Extension
);
}
+ /**
+ * @return Twig_SimpleFunction
+ */
+ protected function steamPositive()
+ {
+ return new Twig_SimpleFunction(
+ 'steam_positive', function (string $str): string {
+ return Steam::positive($str);
+ }
+ );
+ }
+
/**
* @return Twig_SimpleFunction
*/
diff --git a/resources/views/list/journals-tasker.twig b/resources/views/list/journals-tasker.twig
index 184ab9431f..7502719e27 100644
--- a/resources/views/list/journals-tasker.twig
+++ b/resources/views/list/journals-tasker.twig
@@ -33,7 +33,11 @@
<div class="select_single" style="display:none;">
<input name="select_all_single[]" class="select_all_single" value="{{ transaction.journal_id }}" type="checkbox"/>
</div>
- <div class="btn-group btn-group-xs edit_buttons edit_tr_buttons">{% if sorting %}<a href="#" class="handle btn btn-default btn-xs"><i class="fa fa-fw fa-arrows-v"></i></a>{% endif %}<a href="{{ route('transactions.edit',transaction.journal_id) }}" class="btn btn-xs btn-default"><i class="fa fa-fw fa-pencil"></i></a><a href="{{ route('transactions.delete',transaction.journal_id) }}" class="btn btn-xs btn-danger"><i class="fa fa-fw fa-trash-o"></i></a></div>
+ <div class="btn-group btn-group-xs edit_buttons edit_tr_buttons">{% if sorting %}<a href="#" class="handle btn btn-default btn-xs"><i
+ class="fa fa-fw fa-arrows-v"></i></a>{% endif %}<a href="{{ route('transactions.edit',transaction.journal_id) }}"
+ class="btn btn-xs btn-default"><i class="fa fa-fw fa-pencil"></i></a><a
+ href="{{ route('transactions.delete',transaction.journal_id) }}" class="btn btn-xs btn-danger"><i
+ class="fa fa-fw fa-trash-o"></i></a></div>
</td>
<td class="hidden-xs">
@@ -58,10 +62,17 @@
</td>
<td style="text-align: right;">
<span style="margin-right:5px;">
- <!-- format amount of transaction -->
- {{ formatByCode(transaction.transaction_currency_code, transaction.transaction_amount) }}
- <!-- and then amount of journal itself. -->
- {{ optionalJournalAmount(transaction.journal_id, transaction.transaction_amount, transaction.transaction_currency_code, transaction.transaction_type_type) }}
+ {% if transaction.transaction_type_type == 'Transfer' %}
+ <!-- format amount of transaction -->
+ {{ formatByCode(transaction.transaction_currency_code, steam_positive(transaction.transaction_amount)) }}
+ <!-- and then amount of journal itself. -->
+ {{ optionalJournalAmount(transaction.journal_id, transaction.transaction_amount, transaction.transaction_currency_code, transaction.transaction_type_type) }}
+ {% else %}
+ <!-- format amount of transaction -->
+ {{ formatByCode(transaction.transaction_currency_code, transaction.transaction_amount) }}
+ <!-- and then amount of journal itself. -->
+ {{ optionalJournalAmount(transaction.journal_id, transaction.transaction_amount, transaction.transaction_currency_code, transaction.transaction_type_type) }}
+ {% endif %}
</span>
</td>