Firefly III: a personal finances manager
PHP accountingbudgetbudgetingbudgetscash-flowcashflowcredit-carddockerexpensesfinancefinancesfinanciallinuxmoneypaycheckpersonal-financephpphp7
Pre-filter expenses, fixes #10803
James Colee8028996081d
diff --git a/app/Support/JsonApi/Enrichments/BudgetLimitEnrichment.php b/app/Support/JsonApi/Enrichments/BudgetLimitEnrichment.phpindex 787f3c7844..41dd2a9e64 100644--- a/app/Support/JsonApi/Enrichments/BudgetLimitEnrichment.php+++ b/app/Support/JsonApi/Enrichments/BudgetLimitEnrichment.php@@ -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;+ });+ }}