mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Fix #2606
This commit is contained in:
parent
f976bc21af
commit
a1ae85660d
@ -26,6 +26,7 @@ namespace FireflyIII\Transformers;
|
|||||||
|
|
||||||
use FireflyIII\Models\Budget;
|
use FireflyIII\Models\Budget;
|
||||||
use FireflyIII\Repositories\Budget\BudgetRepositoryInterface;
|
use FireflyIII\Repositories\Budget\BudgetRepositoryInterface;
|
||||||
|
use FireflyIII\Repositories\Budget\OperationsRepositoryInterface;
|
||||||
use Illuminate\Support\Collection;
|
use Illuminate\Support\Collection;
|
||||||
use Log;
|
use Log;
|
||||||
|
|
||||||
@ -34,7 +35,8 @@ use Log;
|
|||||||
*/
|
*/
|
||||||
class BudgetTransformer extends AbstractTransformer
|
class BudgetTransformer extends AbstractTransformer
|
||||||
{
|
{
|
||||||
private $repository;
|
/** @var OperationsRepositoryInterface */
|
||||||
|
private $opsRepository;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* BudgetTransformer constructor.
|
* BudgetTransformer constructor.
|
||||||
@ -43,7 +45,7 @@ class BudgetTransformer extends AbstractTransformer
|
|||||||
*/
|
*/
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
$this->repository = app(BudgetRepositoryInterface::class);
|
$this->opsRepository = app(OperationsRepositoryInterface::class);
|
||||||
if ('testing' === config('app.env')) {
|
if ('testing' === config('app.env')) {
|
||||||
Log::warning(sprintf('%s should not be instantiated in the TEST environment!', get_class($this)));
|
Log::warning(sprintf('%s should not be instantiated in the TEST environment!', get_class($this)));
|
||||||
}
|
}
|
||||||
@ -58,12 +60,12 @@ class BudgetTransformer extends AbstractTransformer
|
|||||||
*/
|
*/
|
||||||
public function transform(Budget $budget): array
|
public function transform(Budget $budget): array
|
||||||
{
|
{
|
||||||
$this->repository->setUser($budget->user);
|
$this->opsRepository->setUser($budget->user);
|
||||||
$start = $this->parameters->get('start');
|
$start = $this->parameters->get('start');
|
||||||
$end = $this->parameters->get('end');
|
$end = $this->parameters->get('end');
|
||||||
$spent = [];
|
$spent = [];
|
||||||
if (null !== $start && null !== $end) {
|
if (null !== $start && null !== $end) {
|
||||||
$spent = $this->repository->spentInPeriodMc(new Collection([$budget]), new Collection, $start, $end);
|
$spent = array_values($this->opsRepository->sumExpenses($start, $end, null, new Collection([$budget])));
|
||||||
}
|
}
|
||||||
|
|
||||||
$data = [
|
$data = [
|
||||||
|
Loading…
Reference in New Issue
Block a user