mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-12 15:35:15 +00:00
Budget limit now has period.
This commit is contained in:
@@ -24,6 +24,9 @@ declare(strict_types=1);
|
||||
namespace FireflyIII\Transformers;
|
||||
|
||||
use FireflyIII\Models\BudgetLimit;
|
||||
use FireflyIII\Repositories\Budget\BudgetLimitRepository;
|
||||
use FireflyIII\Repositories\Budget\OperationsRepository;
|
||||
use Illuminate\Support\Collection;
|
||||
use League\Fractal\Resource\Item;
|
||||
|
||||
/**
|
||||
@@ -46,7 +49,7 @@ class BudgetLimitTransformer extends AbstractTransformer
|
||||
*/
|
||||
public function includeBudget(BudgetLimit $limit)
|
||||
{
|
||||
return $this->item($limit->budget, new BudgetTransformer,'budgets ');
|
||||
return $this->item($limit->budget, new BudgetTransformer, 'budgets');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -58,6 +61,11 @@ class BudgetLimitTransformer extends AbstractTransformer
|
||||
*/
|
||||
public function transform(BudgetLimit $budgetLimit): array
|
||||
{
|
||||
$repository = app(OperationsRepository::class);
|
||||
$repository->setUser($budgetLimit->budget->user);
|
||||
$expenses = $repository->sumExpenses($budgetLimit->start_date, $budgetLimit->end_date, null, new Collection([$budgetLimit->budget]), $budgetLimit->transactionCurrency);
|
||||
|
||||
|
||||
$currency = $budgetLimit->transactionCurrency;
|
||||
$amount = $budgetLimit->amount;
|
||||
$currencyDecimalPlaces = 2;
|
||||
@@ -88,8 +96,9 @@ class BudgetLimitTransformer extends AbstractTransformer
|
||||
'currency_decimal_places' => $currencyName,
|
||||
'currency_symbol' => $currencySymbol,
|
||||
'amount' => $amount,
|
||||
'repeat_freq' => $budgetLimit->repeat_freq,
|
||||
'period' => $budgetLimit->period,
|
||||
'auto_budget' => $budgetLimit->auto_budget,
|
||||
'spent' => $expenses[$currencyId]['sum'] ?? '0',
|
||||
'links' => [
|
||||
[
|
||||
'rel' => 'self',
|
||||
|
Reference in New Issue
Block a user