mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-22 20:16:22 +00:00
Expand API.
This commit is contained in:
@@ -29,16 +29,15 @@ use FireflyIII\Models\Budget;
|
||||
use FireflyIII\Repositories\Budget\BudgetRepositoryInterface;
|
||||
use FireflyIII\Repositories\Budget\OperationsRepositoryInterface;
|
||||
use Illuminate\Support\Collection;
|
||||
use Symfony\Component\HttpFoundation\ParameterBag;
|
||||
|
||||
/**
|
||||
* Class BudgetTransformer
|
||||
*/
|
||||
class BudgetTransformer extends AbstractTransformer
|
||||
{
|
||||
/** @var OperationsRepositoryInterface */
|
||||
private $opsRepository;
|
||||
/** @var BudgetRepositoryInterface */
|
||||
private $repository;
|
||||
private OperationsRepositoryInterface $opsRepository;
|
||||
private BudgetRepositoryInterface $repository;
|
||||
|
||||
/**
|
||||
* BudgetTransformer constructor.
|
||||
@@ -49,6 +48,7 @@ class BudgetTransformer extends AbstractTransformer
|
||||
{
|
||||
$this->opsRepository = app(OperationsRepositoryInterface::class);
|
||||
$this->repository = app(BudgetRepositoryInterface::class);
|
||||
$this->parameters = new ParameterBag();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -66,7 +66,7 @@ class BudgetTransformer extends AbstractTransformer
|
||||
$autoBudget = $this->repository->getAutoBudget($budget);
|
||||
$spent = [];
|
||||
if (null !== $start && null !== $end) {
|
||||
$spent = $this->beautify($this->opsRepository->sumExpenses($start, $end, null, new Collection([$budget])));
|
||||
$spent = $this->beautify($this->opsRepository->sumExpenses($start, $end, null, new Collection([$budget])));
|
||||
}
|
||||
|
||||
$abCurrencyId = null;
|
||||
@@ -81,10 +81,10 @@ class BudgetTransformer extends AbstractTransformer
|
||||
];
|
||||
|
||||
if (null !== $autoBudget) {
|
||||
$abCurrencyId = (int) $autoBudget->transactionCurrency->id;
|
||||
$abCurrencyId = (int)$autoBudget->transactionCurrency->id;
|
||||
$abCurrencyCode = $autoBudget->transactionCurrency->code;
|
||||
$abType = $types[$autoBudget->auto_budget_type];
|
||||
$abAmount = number_format((float) $autoBudget->amount, $autoBudget->transactionCurrency->decimal_places, '.', '');
|
||||
$abAmount = number_format((float)$autoBudget->amount, $autoBudget->transactionCurrency->decimal_places, '.', '');
|
||||
$abPeriod = $autoBudget->period;
|
||||
}
|
||||
|
||||
@@ -118,7 +118,7 @@ class BudgetTransformer extends AbstractTransformer
|
||||
{
|
||||
$return = [];
|
||||
foreach ($array as $data) {
|
||||
$data['sum'] = number_format((float) $data['sum'], (int) $data['currency_decimal_places'], '.', '');
|
||||
$data['sum'] = number_format((float)$data['sum'], (int)$data['currency_decimal_places'], '.', '');
|
||||
$return[] = $data;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user