mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2024-12-27 17:31:09 -06:00
Fix list for no budget #159
This commit is contained in:
parent
144a6130f2
commit
3fbedf323f
@ -66,11 +66,12 @@ class ReportController extends Controller
|
||||
$repository = app('FireflyIII\Repositories\Budget\BudgetRepositoryInterface');
|
||||
$budget = $repository->find(intval($attributes['budgetId']));
|
||||
if (is_null($budget->id)) {
|
||||
throw new FireflyException('Could not find a budget for value "' . e($attributes['budgetId']) . '".');
|
||||
$journals = $repository->getWithoutBudgetForAccounts($attributes['accounts'], $attributes['startDate'], $attributes['endDate']);
|
||||
} else {
|
||||
// get all expenses in budget in period:
|
||||
$journals = $repository->getExpenses($budget, $attributes['accounts'], $attributes['startDate'], $attributes['endDate']);
|
||||
}
|
||||
|
||||
// get all expenses in budget in period:
|
||||
$journals = $repository->getExpenses($budget, $attributes['accounts'], $attributes['startDate'], $attributes['endDate']);
|
||||
|
||||
$view = view('popup.report.budget-spent-amount', compact('journals'))->render();
|
||||
|
||||
|
@ -382,7 +382,8 @@ class TransactionJournal extends TransactionJournalSupport
|
||||
// join destination account
|
||||
$query->leftJoin('accounts as source_account', 'source_account.id', '=', 'source.account_id');
|
||||
// join destination account type
|
||||
$query->leftJoin('account_types as source_acct_type', 'source_account.account_type_id', '=', 'source_acct_type.id');
|
||||
$query->leftJoin('account_types as source_acct_type', 'source_account.account_type_id', '=', 'source_acct_type.id')
|
||||
->orderBy('transaction_journals.date', 'DESC')->orderBy('transaction_journals.order', 'ASC')->orderBy('transaction_journals.id', 'DESC');
|
||||
|
||||
$query->with(['categories', 'budgets', 'attachments', 'bill']);
|
||||
|
||||
|
@ -389,7 +389,7 @@ class BudgetRepository extends ComponentRepository implements BudgetRepositoryIn
|
||||
->before($end)
|
||||
->after($start)
|
||||
->expanded()
|
||||
->where('transaction_types.type', 'Withdrawal')
|
||||
->where('transaction_types.type', TransactionType::WITHDRAWAL)
|
||||
->whereIn('source_account.id', $ids)
|
||||
->get(TransactionJournal::QUERYFIELDS);
|
||||
|
||||
@ -501,15 +501,36 @@ class BudgetRepository extends ComponentRepository implements BudgetRepositoryIn
|
||||
{
|
||||
return $this->user
|
||||
->transactionjournals()
|
||||
->transactionTypes([TransactionType::WITHDRAWAL])
|
||||
->expanded()
|
||||
->where('transaction_types.type', TransactionType::WITHDRAWAL)
|
||||
->leftJoin('budget_transaction_journal', 'budget_transaction_journal.transaction_journal_id', '=', 'transaction_journals.id')
|
||||
->whereNull('budget_transaction_journal.id')
|
||||
->before($end)
|
||||
->after($start)
|
||||
->orderBy('transaction_journals.date', 'DESC')
|
||||
->orderBy('transaction_journals.order', 'ASC')
|
||||
->orderBy('transaction_journals.id', 'DESC')
|
||||
->get(['transaction_journals.*']);
|
||||
->get(TransactionJournal::QUERYFIELDS);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Collection $accounts
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
*
|
||||
* @return Collection
|
||||
*/
|
||||
public function getWithoutBudgetForAccounts(Collection $accounts, Carbon $start, Carbon $end)
|
||||
{
|
||||
$ids = $accounts->pluck('id')->toArray();
|
||||
|
||||
return $this->user
|
||||
->transactionjournals()
|
||||
->expanded()
|
||||
->whereIn('source_account.id', $ids)
|
||||
->where('transaction_types.type', TransactionType::WITHDRAWAL)
|
||||
->leftJoin('budget_transaction_journal', 'budget_transaction_journal.transaction_journal_id', '=', 'transaction_journals.id')
|
||||
->whereNull('budget_transaction_journal.id')
|
||||
->before($end)
|
||||
->after($start)
|
||||
->get(TransactionJournal::QUERYFIELDS);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -187,6 +187,15 @@ interface BudgetRepositoryInterface
|
||||
*/
|
||||
public function getWithoutBudget(Carbon $start, Carbon $end);
|
||||
|
||||
/**
|
||||
* @param Collection $accounts
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
*
|
||||
* @return Collection
|
||||
*/
|
||||
public function getWithoutBudgetForAccounts(Collection $accounts, Carbon $start, Carbon $end);
|
||||
|
||||
/**
|
||||
* @param Collection $accounts
|
||||
* @param Carbon $start
|
||||
|
@ -26,11 +26,6 @@
|
||||
</td>
|
||||
<td>
|
||||
<a href="{{ route('transactions.show',journal.id) }}" title="{{ journal.description }}">{{ journal.description }}</a>
|
||||
{% if journal.attachments|length > 0 %}
|
||||
<i class="fa fa-paperclip pull-right"
|
||||
title="{{ Lang.choice('firefly.nr_of_attachments', journal.attachments|length, {count: journal.attachments|length}) }}"></i>
|
||||
{% endif %}
|
||||
|
||||
</td>
|
||||
<td>
|
||||
{{ journal|formatJournal }}
|
||||
|
Loading…
Reference in New Issue
Block a user