Fixed some display bugs for split journals.

This commit is contained in:
James Cole 2016-11-20 14:17:16 +01:00
parent bd8a285d6d
commit 78f297e18f
No known key found for this signature in database
GPG Key ID: C16961E655E74B5E
5 changed files with 5 additions and 31 deletions

View File

@ -298,7 +298,7 @@ class JournalExportCollector extends BasicCollector implements CollectorInterfac
'transactions AS opposing', function (JoinClause $join) {
$join->on('opposing.transaction_journal_id', '=', 'transactions.transaction_journal_id')
->where('opposing.amount', '=', DB::raw('transactions.amount * -1'))
->where('transactions.identifier', '=', 'opposing.identifier');
->where('transactions.identifier', '=', DB::raw('opposing.identifier'));
}
)
->leftJoin('accounts', 'transactions.account_id', '=', 'accounts.id')

View File

@ -541,12 +541,13 @@ class JournalCollector implements JournalCollectorInterface
$this->query->leftJoin(
'transactions as opposing', function (JoinClause $join) {
$join->on('opposing.transaction_journal_id', '=', 'transactions.transaction_journal_id')
->where('opposing.identifier', '=', 'transactions.identifier')
->where('opposing.identifier', '=', DB::raw('transactions.identifier'))
->where('opposing.amount', '=', DB::raw('transactions.amount * -1'));
}
);
$this->query->leftJoin('accounts as opposing_accounts', 'opposing.account_id', '=', 'opposing_accounts.id');
$this->query->leftJoin('account_types as opposing_account_types', 'opposing_accounts.account_type_id', '=', 'opposing_account_types.id');
$this->query->whereNull('opposing.deleted_at');
$this->fields[] = 'opposing.account_id as opposing_account_id';
$this->fields[] = 'opposing_accounts.name as opposing_account_name';

View File

@ -15,6 +15,7 @@ namespace FireflyIII\Models;
use Carbon\Carbon;
use Crypt;
use DB;
use FireflyIII\Exceptions\FireflyException;
use Illuminate\Contracts\Encryption\DecryptException;
use Illuminate\Database\Eloquent\Builder as EloquentBuilder;

View File

@ -334,7 +334,7 @@ class BudgetRepository implements BudgetRepositoryInterface
->leftJoin('transaction_types', 'transaction_types.id', '=', 'transaction_journals.transaction_type_id')
->leftJoin(
'transactions', function (JoinClause $join) {
$join->on('transactions.transaction_journal_id', '=', 'transaction_journals.id')->where('transactions.amount', '<', '0');
$join->on('transactions.transaction_journal_id', '=', 'transaction_journals.id')->where('transactions.amount', '<', 0);
}
)
->where('transaction_journals.date', '>=', $start->format('Y-m-d'))

View File

@ -74,34 +74,6 @@ class JournalTasker implements JournalTaskerInterface
public function getTransactionsOverview(TransactionJournal $journal): array
{
// get all transaction data + the opposite site in one list.
/**
* select
*
* source.id,
* source.account_id,
* source_accounts.name as account_name,
* source_accounts.encrypted as account_encrypted,
* source.amount,
* source.description,
*
* destination.id as destination_id,
* destination.account_id as destination_account_id,
* destination_accounts.name as destination_account_name,
* destination_accounts.encrypted as destination_account_encrypted
*
*
* from transactions as source
*
* left join transactions as destination ON source.transaction_journal_id =
* destination.transaction_journal_id AND source.amount = destination.amount * -1 AND source.identifier = destination.identifier
* -- left join source account name:
* left join accounts as source_accounts ON source.account_id = source_accounts.id
* left join accounts as destination_accounts ON destination.account_id = destination_accounts.id
*
* where source.transaction_journal_id = 6600
* and source.amount < 0
* and source.deleted_at is null
*/
$set = $journal
->transactions()// "source"
->leftJoin(