mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-12 15:35:15 +00:00
First code for #159 popups
This commit is contained in:
@@ -372,6 +372,30 @@ class BudgetRepository extends ComponentRepository implements BudgetRepositoryIn
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns all expenses for the given budget and the given accounts, in the given period.
|
||||
*
|
||||
* @param Budget $budget
|
||||
* @param Collection $accounts
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
*
|
||||
* @return Collection
|
||||
*/
|
||||
public function getExpenses(Budget $budget, Collection $accounts, Carbon $start, Carbon $end):Collection
|
||||
{
|
||||
$ids = $accounts->pluck('id')->toArray();
|
||||
$set = $budget->transactionjournals()
|
||||
->before($end)
|
||||
->after($start)
|
||||
->expanded()
|
||||
->where('transaction_types.type', 'Withdrawal')
|
||||
->whereIn('source_account.id', $ids)
|
||||
->get(TransactionJournal::QUERYFIELDS);
|
||||
|
||||
return $set;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the expenses for this budget grouped per day, with the date
|
||||
* in "date" (a string, not a Carbon) and the amount in "dailyAmount".
|
||||
|
Reference in New Issue
Block a user