mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-09-30 02:26:58 +00:00
Fix #10773 for budget limits.
This commit is contained in:
@@ -47,6 +47,7 @@ class BudgetLimitEnrichment implements EnrichmentInterface
|
|||||||
$this->collectCurrencies();
|
$this->collectCurrencies();
|
||||||
$this->collectNotes();
|
$this->collectNotes();
|
||||||
$this->collectBudgets();
|
$this->collectBudgets();
|
||||||
|
$this->stringifyIds();
|
||||||
$this->appendCollectedData();
|
$this->appendCollectedData();
|
||||||
|
|
||||||
return $this->collection;
|
return $this->collection;
|
||||||
@@ -74,8 +75,8 @@ class BudgetLimitEnrichment implements EnrichmentInterface
|
|||||||
|
|
||||||
private function collectIds(): void
|
private function collectIds(): void
|
||||||
{
|
{
|
||||||
$this->start = $this->collection->min('start_date') ?? Carbon::now()->startOfMonth();
|
$this->start = $this->collection->min('start_date') ?? Carbon::now()->startOfMonth();
|
||||||
$this->end = $this->collection->max('end_date') ?? Carbon::now()->endOfMonth();
|
$this->end = $this->collection->max('end_date') ?? Carbon::now()->endOfMonth();
|
||||||
|
|
||||||
/** @var BudgetLimit $limit */
|
/** @var BudgetLimit $limit */
|
||||||
foreach ($this->collection as $limit) {
|
foreach ($this->collection as $limit) {
|
||||||
@@ -92,10 +93,9 @@ class BudgetLimitEnrichment implements EnrichmentInterface
|
|||||||
private function collectNotes(): void
|
private function collectNotes(): void
|
||||||
{
|
{
|
||||||
$notes = Note::query()->whereIn('noteable_id', $this->ids)
|
$notes = Note::query()->whereIn('noteable_id', $this->ids)
|
||||||
->whereNotNull('notes.text')
|
->whereNotNull('notes.text')
|
||||||
->where('notes.text', '!=', '')
|
->where('notes.text', '!=', '')
|
||||||
->where('noteable_type', BudgetLimit::class)->get(['notes.noteable_id', 'notes.text'])->toArray()
|
->where('noteable_type', BudgetLimit::class)->get(['notes.noteable_id', 'notes.text'])->toArray();
|
||||||
;
|
|
||||||
foreach ($notes as $note) {
|
foreach ($notes as $note) {
|
||||||
$this->notes[(int)$note['noteable_id']] = (string)$note['text'];
|
$this->notes[(int)$note['noteable_id']] = (string)$note['text'];
|
||||||
}
|
}
|
||||||
@@ -127,9 +127,9 @@ class BudgetLimitEnrichment implements EnrichmentInterface
|
|||||||
$budgetIds = $this->collection->pluck('budget_id')->unique()->toArray();
|
$budgetIds = $this->collection->pluck('budget_id')->unique()->toArray();
|
||||||
$this->budgets = Budget::whereIn('id', $budgetIds)->get();
|
$this->budgets = Budget::whereIn('id', $budgetIds)->get();
|
||||||
|
|
||||||
$repository = app(OperationsRepository::class);
|
$repository = app(OperationsRepository::class);
|
||||||
$repository->setUser($this->user);
|
$repository->setUser($this->user);
|
||||||
$expenses = $repository->collectExpenses($this->start, $this->end, null, $this->budgets, null);
|
$expenses = $repository->collectExpenses($this->start, $this->end, null, $this->budgets, null);
|
||||||
|
|
||||||
/** @var BudgetLimit $budgetLimit */
|
/** @var BudgetLimit $budgetLimit */
|
||||||
foreach ($this->collection as $budgetLimit) {
|
foreach ($this->collection as $budgetLimit) {
|
||||||
@@ -155,4 +155,22 @@ class BudgetLimitEnrichment implements EnrichmentInterface
|
|||||||
$this->currencies[(int)$currency->id] = $currency;
|
$this->currencies[(int)$currency->id] = $currency;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function stringifyIds(): void
|
||||||
|
{
|
||||||
|
$this->expenses = array_map(function ($first) {
|
||||||
|
return array_map(function ($second) {
|
||||||
|
$second['currency_id'] = (string)($second['currency_id'] ?? 0);
|
||||||
|
return $second;
|
||||||
|
}, $first);
|
||||||
|
}, $this->expenses);
|
||||||
|
|
||||||
|
$this->pcExpenses = array_map(function ($first) {
|
||||||
|
return array_map(function ($second) {
|
||||||
|
$second['currency_id'] = (string)($second['currency_id'] ?? 0);
|
||||||
|
return $second;
|
||||||
|
}, $first);
|
||||||
|
}, $this->expenses);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user