Optimize again for account name [skip ci]

This commit is contained in:
James Cole 2016-11-12 21:08:14 +01:00
parent 750b9d8038
commit eecb6c6679
No known key found for this signature in database
GPG Key ID: C16961E655E74B5E

View File

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