Fixed some transaction list filter issues.

This commit is contained in:
James Cole 2017-02-15 21:55:50 +01:00
parent a5f8aa914f
commit 8f5289b7dc
No known key found for this signature in database
GPG Key ID: C16961E655E74B5E
4 changed files with 48 additions and 33 deletions

View File

@ -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);

View File

@ -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);

View File

@ -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
*/

View File

@ -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>