Skip to content

Firefly III: a personal finances manager

Optimize again for account name [skip ci]

James Coleeecb6c6679fa
diff --git a/app/Support/Twig/Transaction.php b/app/Support/Twig/Transaction.php
index 1d9d9c73fe..37a964e959 100644
--- a/app/Support/Twig/Transaction.php
+++ b/app/Support/Twig/Transaction.php
@@ -189,9 +189,18 @@ class Transaction extends Twig_Extension
$name = intval($transaction->account_encrypted) === 1 ? Crypt::decrypt($transaction->account_name) : $transaction->account_name;
$id = intval($transaction->account_id);
$type = $transaction->account_type;
- // if the amount is positive, assume that the current account (the one in $transaction) is indeed the destination account.
- if (bccomp($transaction->transaction_amount, '0') === -1) {
+ // name is present in object, use that one:
+ if (bccomp($transaction->transaction_amount, '0') === -1 && !is_null($transaction->opposing_account_id)) {
+
+ $name = intval($transaction->opposing_account_encrypted) === 1 ? Crypt::decrypt($transaction->opposing_account_name)
+ : $transaction->opposing_account_name;
+ $id = intval($transaction->opposing_account_id);
+ $type = intval($transaction->opposing_account_type);
+ }
+
+ // Find the opposing account and use that one:
+ if (bccomp($transaction->transaction_amount, '0') === -1 && is_null($transaction->opposing_account_id)) {
// if the amount is negative, find the opposing account and use that one:
$journalId = $transaction->journal_id;
/** @var TransactionModel $other */