mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-12 15:35:15 +00:00
Pre-filter expenses, fixes #10803
This commit is contained in:
@@ -135,6 +135,7 @@ class BudgetLimitEnrichment implements EnrichmentInterface
|
||||
/** @var BudgetLimit $budgetLimit */
|
||||
foreach ($this->collection as $budgetLimit) {
|
||||
$id = (int)$budgetLimit->id;
|
||||
$filteredExpenses = $this->filterToBudget($expenses, $budgetLimit->budget_id);
|
||||
$filteredExpenses = $repository->sumCollectedExpenses($expenses, $budgetLimit->start_date, $budgetLimit->end_date, $budgetLimit->transactionCurrency, false);
|
||||
$this->expenses[$id] = array_values($filteredExpenses);
|
||||
|
||||
@@ -175,4 +176,11 @@ class BudgetLimitEnrichment implements EnrichmentInterface
|
||||
}, $first);
|
||||
}, $this->expenses);
|
||||
}
|
||||
|
||||
private function filterToBudget(array $expenses, int $budget): array
|
||||
{
|
||||
return array_filter($expenses, function (array $item) use ($budget) {
|
||||
return (int)$item['budget_id'] === $budget;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user