mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2026-01-06 06:01:21 +00:00
Move collecting journals to the collector.
This commit is contained in:
@@ -116,41 +116,6 @@ class BillRepository implements BillRepositoryInterface
|
||||
return $set;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns all journals connected to these bills in the given range. Amount paid
|
||||
* is stored in "journalAmount" as a negative number.
|
||||
*
|
||||
* @param Collection $bills
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
*
|
||||
* @return Collection
|
||||
*/
|
||||
public function getAllJournalsInRange(Collection $bills, Carbon $start, Carbon $end): Collection
|
||||
{
|
||||
$ids = $bills->pluck('id')->toArray();
|
||||
|
||||
$set = $this->user->transactionJournals()
|
||||
->leftJoin(
|
||||
'transactions', function (JoinClause $join) {
|
||||
$join->on('transactions.transaction_journal_id', '=', 'transaction_journals.id')->where('transactions.amount', '<', 0);
|
||||
}
|
||||
)
|
||||
->whereIn('bill_id', $ids)
|
||||
->before($end)
|
||||
->after($start)
|
||||
->groupBy(['transaction_journals.bill_id', 'transaction_journals.id'])
|
||||
->get(
|
||||
[
|
||||
'transaction_journals.bill_id',
|
||||
'transaction_journals.id',
|
||||
DB::raw('SUM(transactions.amount) AS journalAmount'),
|
||||
]
|
||||
);
|
||||
|
||||
return $set;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user