mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-12-19 04:49:30 +00:00
Fix #10768
This commit is contained in:
@@ -57,8 +57,8 @@ class AvailableBudgetEnrichment implements EnrichmentInterface
|
|||||||
private readonly BudgetRepositoryInterface $repository;
|
private readonly BudgetRepositoryInterface $repository;
|
||||||
|
|
||||||
|
|
||||||
private ?Carbon $start = null;
|
private ?Carbon $start = null;
|
||||||
private ?Carbon $end = null;
|
private ?Carbon $end = null;
|
||||||
|
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
@@ -73,10 +73,12 @@ class AvailableBudgetEnrichment implements EnrichmentInterface
|
|||||||
public function enrich(Collection $collection): Collection
|
public function enrich(Collection $collection): Collection
|
||||||
{
|
{
|
||||||
$this->collection = $collection;
|
$this->collection = $collection;
|
||||||
$this->collectIds();
|
if ($this->collection->count() > 0) {
|
||||||
$this->collectCurrencies();
|
$this->collectIds();
|
||||||
$this->collectSpentInfo();
|
$this->collectCurrencies();
|
||||||
$this->appendCollectedData();
|
$this->collectSpentInfo();
|
||||||
|
$this->appendCollectedData();
|
||||||
|
}
|
||||||
|
|
||||||
return $this->collection;
|
return $this->collection;
|
||||||
}
|
}
|
||||||
@@ -85,7 +87,7 @@ class AvailableBudgetEnrichment implements EnrichmentInterface
|
|||||||
public function enrichSingle(array|Model $model): array|Model
|
public function enrichSingle(array|Model $model): array|Model
|
||||||
{
|
{
|
||||||
Log::debug(__METHOD__);
|
Log::debug(__METHOD__);
|
||||||
$collection = new Collection([$model]);
|
$collection = new Collection()->push($model);
|
||||||
$collection = $this->enrich($collection);
|
$collection = $this->enrich($collection);
|
||||||
|
|
||||||
return $collection->first();
|
return $collection->first();
|
||||||
@@ -119,8 +121,8 @@ class AvailableBudgetEnrichment implements EnrichmentInterface
|
|||||||
|
|
||||||
private function collectSpentInfo(): void
|
private function collectSpentInfo(): void
|
||||||
{
|
{
|
||||||
$start = $this->collection->min('start_date');
|
$start = $this->collection->min('start_date') ?? Carbon::now()->startOfMonth();
|
||||||
$end = $this->collection->max('end_date');
|
$end = $this->collection->max('end_date') ?? Carbon::now()->endOfMonth();
|
||||||
$allActive = $this->repository->getActiveBudgets();
|
$allActive = $this->repository->getActiveBudgets();
|
||||||
$spentInBudgets = $this->opsRepository->collectExpenses($start, $end, null, $allActive, null);
|
$spentInBudgets = $this->opsRepository->collectExpenses($start, $end, null, $allActive, null);
|
||||||
$spentOutsideBudgets = $this->noBudgetRepository->collectExpenses($start, $end, null, null, null);
|
$spentOutsideBudgets = $this->noBudgetRepository->collectExpenses($start, $end, null, null, null);
|
||||||
@@ -139,14 +141,7 @@ class AvailableBudgetEnrichment implements EnrichmentInterface
|
|||||||
$this->pcSpentInBudgets[$id] = array_values($pcFilteredSpentInBudgets);
|
$this->pcSpentInBudgets[$id] = array_values($pcFilteredSpentInBudgets);
|
||||||
$this->pcSpentOutsideBudgets[$id] = array_values($pcFilteredSpentOutsideBudgets);
|
$this->pcSpentOutsideBudgets[$id] = array_values($pcFilteredSpentOutsideBudgets);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// filter arrays on date.
|
|
||||||
// send them to sumCollection thing.
|
|
||||||
// save.
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// first collect, then filter and append.
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private function appendCollectedData(): void
|
private function appendCollectedData(): void
|
||||||
|
|||||||
Reference in New Issue
Block a user