mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Fixed two crashes.
This commit is contained in:
parent
9b69a6addd
commit
2e7703bc97
@ -16,6 +16,7 @@ use FireflyIII\Models\Preference;
|
||||
use FireflyIII\Models\Transaction;
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
use FireflyIII\Models\TransactionType;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Pagination\LengthAwarePaginator;
|
||||
use Illuminate\Support\Collection;
|
||||
@ -211,15 +212,19 @@ class AccountRepository implements AccountRepositoryInterface
|
||||
$offset = ($page - 1) * 50;
|
||||
$query = Auth::user()
|
||||
->transactionJournals()
|
||||
->withRelevantData() // TODO firefly will crash here.
|
||||
->leftJoin('transactions', 'transactions.transaction_journal_id', '=', 'transaction_journals.id')
|
||||
->where('transactions.account_id', $account->id)
|
||||
->expanded()// TODO firefly will crash here.
|
||||
->where(
|
||||
function (Builder $q) use ($account) {
|
||||
$q->where('destination.account_id', $account->id);
|
||||
$q->orWhere('source.account_id', $account->id);
|
||||
}
|
||||
)
|
||||
->orderBy('transaction_journals.date', 'DESC')
|
||||
->orderBy('transaction_journals.order', 'ASC')
|
||||
->orderBy('transaction_journals.id', 'DESC');
|
||||
|
||||
$count = $query->count();
|
||||
$set = $query->take(50)->offset($offset)->get(['transaction_journals.*']);
|
||||
$set = $query->take(50)->offset($offset)->get(TransactionJournal::QUERYFIELDS);
|
||||
$paginator = new LengthAwarePaginator($set, $count, 50, $page);
|
||||
|
||||
return $paginator;
|
||||
@ -345,7 +350,6 @@ class AccountRepository implements AccountRepositoryInterface
|
||||
::orderBy('transaction_journals.date', 'ASC')
|
||||
->leftJoin('transactions', 'transactions.transaction_journal_id', '=', 'transaction_journals.id')
|
||||
->where('transactions.account_id', $account->id)
|
||||
|
||||
->transactionTypes([TransactionType::OPENING_BALANCE])
|
||||
->orderBy('created_at', 'ASC')
|
||||
->first(['transaction_journals.*']);
|
||||
|
@ -9,6 +9,7 @@ use DB;
|
||||
use FireflyIII\Models\Budget;
|
||||
use FireflyIII\Models\BudgetLimit;
|
||||
use FireflyIII\Models\LimitRepetition;
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
use FireflyIII\Models\TransactionType;
|
||||
use FireflyIII\Repositories\Shared\ComponentRepository;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
@ -414,7 +415,8 @@ class BudgetRepository extends ComponentRepository implements BudgetRepositoryIn
|
||||
public function getJournals(Budget $budget, LimitRepetition $repetition = null, int $take = 50)
|
||||
{
|
||||
$offset = intval(Input::get('page')) > 0 ? intval(Input::get('page')) * $take : 0;
|
||||
$setQuery = $budget->transactionjournals()->withRelevantData()->take($take)->offset($offset) // TODO firefly will crash here.
|
||||
$setQuery = $budget->transactionjournals()->expanded()
|
||||
->take($take)->offset($offset)// TODO firefly will crash here.
|
||||
->orderBy('transaction_journals.date', 'DESC')
|
||||
->orderBy('transaction_journals.order', 'ASC')
|
||||
->orderBy('transaction_journals.id', 'DESC');
|
||||
@ -427,7 +429,7 @@ class BudgetRepository extends ComponentRepository implements BudgetRepositoryIn
|
||||
}
|
||||
|
||||
|
||||
$set = $setQuery->get(['transaction_journals.*']);
|
||||
$set = $setQuery->get(TransactionJournal::QUERYFIELDS);
|
||||
$count = $countQuery->count();
|
||||
|
||||
|
||||
@ -581,13 +583,13 @@ class BudgetRepository extends ComponentRepository implements BudgetRepositoryIn
|
||||
->before($end)
|
||||
->groupBy('t_from.account_id')
|
||||
->groupBy('budget_transaction_journal.budget_id')
|
||||
->transactionTypes([TransactionType::WITHDRAWAL, TransactionType::TRANSFER]) // opening balance is not an expense.
|
||||
->transactionTypes([TransactionType::WITHDRAWAL, TransactionType::TRANSFER])// opening balance is not an expense.
|
||||
->get(
|
||||
[
|
||||
't_from.account_id', 'budget_transaction_journal.budget_id',
|
||||
DB::raw('SUM(`t_from`.`amount`) AS `spent`'),
|
||||
]
|
||||
);
|
||||
[
|
||||
't_from.account_id', 'budget_transaction_journal.budget_id',
|
||||
DB::raw('SUM(`t_from`.`amount`) AS `spent`'),
|
||||
]
|
||||
);
|
||||
|
||||
return $set;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user