mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2026-02-28 14:21:07 +00:00
Compare commits
6 Commits
main
...
develop-20
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
453332eae0 | ||
|
|
4407456167 | ||
|
|
2842432204 | ||
|
|
842ec6da47 | ||
|
|
ceb5873ba7 | ||
|
|
6cfd8273fe |
@@ -25,7 +25,7 @@ declare(strict_types=1);
|
||||
namespace FireflyIII\Api\V1\Controllers\Models\Account;
|
||||
|
||||
use FireflyIII\Api\V1\Controllers\Controller;
|
||||
use FireflyIII\Api\V1\Requests\Generic\PaginationDateRangeRequest;
|
||||
use FireflyIII\Api\V1\Requests\Models\Transaction\ListRequest;
|
||||
use FireflyIII\Api\V1\Requests\PaginationRequest;
|
||||
use FireflyIII\Helpers\Collector\GroupCollectorInterface;
|
||||
use FireflyIII\Models\Account;
|
||||
@@ -126,17 +126,23 @@ class ListController extends Controller
|
||||
/**
|
||||
* Show all transaction groups related to the account.
|
||||
*/
|
||||
public function transactions(PaginationDateRangeRequest $request, Account $account): JsonResponse
|
||||
public function transactions(ListRequest $request, Account $account): JsonResponse
|
||||
{
|
||||
['limit' => $limit, 'page' => $page, 'start' => $start, 'end' => $end, 'types' => $types] = $request->attributes->all();
|
||||
$manager = $this->getManager();
|
||||
[
|
||||
'limit' => $limit,
|
||||
'page' => $page,
|
||||
'start' => $start,
|
||||
'end' => $end,
|
||||
'types' => $types,
|
||||
] = $request->attributes->all();
|
||||
$manager = $this->getManager();
|
||||
|
||||
/** @var User $admin */
|
||||
$admin = auth()->user();
|
||||
$admin = auth()->user();
|
||||
|
||||
// use new group collector:
|
||||
/** @var GroupCollectorInterface $collector */
|
||||
$collector = app(GroupCollectorInterface::class);
|
||||
$collector = app(GroupCollectorInterface::class);
|
||||
$collector->setUser($admin)->setAccounts(new Collection()->push($account))->withAPIInformation()->setLimit($limit)->setPage($page)->setTypes($types);
|
||||
if (null !== $start) {
|
||||
$collector->setStart($start);
|
||||
@@ -145,18 +151,18 @@ class ListController extends Controller
|
||||
$collector->setEnd($end);
|
||||
}
|
||||
|
||||
$paginator = $collector->getPaginatedGroups();
|
||||
$paginator = $collector->getPaginatedGroups();
|
||||
$paginator->setPath(route('api.v1.accounts.transactions', [$account->id]).$this->buildParams());
|
||||
|
||||
// enrich
|
||||
$enrichment = new TransactionGroupEnrichment();
|
||||
$enrichment = new TransactionGroupEnrichment();
|
||||
$enrichment->setUser($admin);
|
||||
$transactions = $enrichment->enrich($paginator->getCollection());
|
||||
$transactions = $enrichment->enrich($paginator->getCollection());
|
||||
|
||||
/** @var TransactionGroupTransformer $transformer */
|
||||
$transformer = app(TransactionGroupTransformer::class);
|
||||
$transformer = app(TransactionGroupTransformer::class);
|
||||
|
||||
$resource = new FractalCollection($transactions, $transformer, 'transactions');
|
||||
$resource = new FractalCollection($transactions, $transformer, 'transactions');
|
||||
$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
|
||||
|
||||
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
|
||||
|
||||
@@ -46,6 +46,9 @@ use Illuminate\Routing\Redirector;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\View\View;
|
||||
use Spatie\Period\Boundaries;
|
||||
use Spatie\Period\Period;
|
||||
use Spatie\Period\Precision;
|
||||
|
||||
/**
|
||||
* Class BudgetLimitController
|
||||
@@ -268,10 +271,16 @@ class BudgetLimitController extends Controller
|
||||
$budgetLimit->transactionCurrency
|
||||
);
|
||||
$daysLeft = $this->activeDaysLeft($limit->start_date, $limit->end_date);
|
||||
|
||||
$limitPeriod = Period::make($limit->start_date, $limit->end_date, precision: Precision::DAY(), boundaries: Boundaries::EXCLUDE_NONE());
|
||||
$inPast = $limitPeriod->startsBefore(now()) && $limitPeriod->endsBefore(now());
|
||||
|
||||
// create aray.
|
||||
$array['spent'] = $spentArr[$budgetLimit->transactionCurrency->id]['sum'] ?? '0';
|
||||
$array['left_formatted'] = Amount::formatAnything($limit->transactionCurrency, bcadd($array['spent'], (string) $array['amount']));
|
||||
$array['amount_formatted'] = Amount::formatAnything($limit->transactionCurrency, $limit['amount']);
|
||||
$array['days_left'] = (string) $daysLeft;
|
||||
$array['in_past'] = $inPast;
|
||||
$array['left_per_day'] = 0 === $daysLeft
|
||||
? bcadd((string) $array['spent'], (string) $array['amount'])
|
||||
: bcdiv(bcadd((string) $array['spent'], (string) $array['amount']), $array['days_left']);
|
||||
|
||||
@@ -47,6 +47,9 @@ use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\View\View;
|
||||
use Spatie\Period\Boundaries;
|
||||
use Spatie\Period\Period;
|
||||
use Spatie\Period\Precision;
|
||||
|
||||
/**
|
||||
* Class IndexController
|
||||
@@ -117,6 +120,10 @@ final class IndexController extends Controller
|
||||
$prevLoop = $this->getPreviousPeriods($start, $range);
|
||||
$nextLoop = $this->getNextPeriods($start, $range);
|
||||
|
||||
// number of days for consistent budgeting.
|
||||
$activeDaysPassed = $this->activeDaysPassed($start, $end); // see method description.
|
||||
$activeDaysLeft = $this->activeDaysLeft($start, $end); // see method description.
|
||||
|
||||
// get all available budgets:
|
||||
$availableBudgets = $this->getAllAvailableBudgets($start, $end);
|
||||
// get all active budgets:
|
||||
@@ -133,9 +140,6 @@ final class IndexController extends Controller
|
||||
$spent = $spentArr[$this->primaryCurrency->id]['sum'] ?? '0';
|
||||
unset($spentArr);
|
||||
}
|
||||
// number of days for consistent budgeting.
|
||||
$activeDaysPassed = $this->activeDaysPassed($start, $end); // see method description.
|
||||
$activeDaysLeft = $this->activeDaysLeft($start, $end); // see method description.
|
||||
|
||||
// get all inactive budgets, and simply list them:
|
||||
$inactive = $this->repository->getInactiveBudgets();
|
||||
@@ -221,44 +225,68 @@ final class IndexController extends Controller
|
||||
|
||||
// complement budget with budget limits in range, and expenses in currency X in range.
|
||||
/** @var Budget $current */
|
||||
foreach ($collection as $current) {
|
||||
Log::debug(sprintf('Working on budget #%d ("%s")', $current->id, $current->name));
|
||||
$array = $current->toArray();
|
||||
foreach ($collection as $budget) {
|
||||
Log::debug(sprintf('Working on budget #%d ("%s")', $budget->id, $budget->name));
|
||||
$array = $budget->toArray();
|
||||
$array['spent'] = [];
|
||||
$array['spent_total'] = [];
|
||||
$array['budgeted'] = [];
|
||||
$array['attachments'] = $this->repository->getAttachments($current);
|
||||
$array['auto_budget'] = $this->repository->getAutoBudget($current);
|
||||
$budgetLimits = $this->blRepository->getBudgetLimits($current, $start, $end);
|
||||
$array['attachments'] = $this->repository->getAttachments($budget);
|
||||
$array['auto_budget'] = $this->repository->getAutoBudget($budget);
|
||||
$budgetLimits = $this->blRepository->getBudgetLimits($budget, $start, $end);
|
||||
$spentInLimits = [];
|
||||
|
||||
/** @var BudgetLimit $limit */
|
||||
foreach ($budgetLimits as $limit) {
|
||||
Log::debug(sprintf('Working on budget limit #%d', $limit->id));
|
||||
$currency = $limit->transactionCurrency ?? $primaryCurrency;
|
||||
$amount = Steam::bcround($limit->amount, $currency->decimal_places);
|
||||
$array['budgeted'][] = [
|
||||
// number of days for consistent budgeting.
|
||||
$activeDaysPassed = $this->activeDaysPassed($limit->start_date, $limit->end_date); // see method description.
|
||||
$activeDaysLeft = $this->activeDaysLeft($limit->start_date, $limit->end_date); // see method description.
|
||||
$limitPeriod = Period::make($limit->start_date, $limit->end_date, precision: Precision::DAY(), boundaries: Boundaries::EXCLUDE_NONE());
|
||||
$inPast = $limitPeriod->startsBefore(now()) && $limitPeriod->endsBefore(now());
|
||||
$currency = $limit->transactionCurrency ?? $primaryCurrency;
|
||||
$amount = Steam::bcround($limit->amount, $currency->decimal_places);
|
||||
$spent = $this->opsRepository->sumExpenses($limit->start_date, $limit->end_date, null, new Collection()->push($budget), $currency);
|
||||
$spentAmount = $spent[$currency->id]['sum'] ?? '0';
|
||||
$array['budgeted'][] = [
|
||||
'id' => $limit->id,
|
||||
'amount' => $amount,
|
||||
'notes' => $this->blRepository->getNoteText($limit),
|
||||
'start_date' => $limit->start_date->isoFormat($this->monthAndDayFormat),
|
||||
'end_date' => $limit->end_date->isoFormat($this->monthAndDayFormat),
|
||||
'in_range' => $limit->start_date->isSameDay($start) && $limit->end_date->isSameDay($end),
|
||||
'in_past' => $inPast,
|
||||
'total_days' => $limit->start_date->diffInDays($limit->end_date) + 1,
|
||||
'currency_id' => $currency->id,
|
||||
'currency_symbol' => $currency->symbol,
|
||||
'currency_name' => $currency->name,
|
||||
'currency_decimal_places' => $currency->decimal_places,
|
||||
'spent' => $spentAmount,
|
||||
'left' => bcadd($amount, $spentAmount),
|
||||
'active_days_passed' => $activeDaysPassed,
|
||||
'active_days_left' => $activeDaysLeft,
|
||||
];
|
||||
$spentInLimits[$currency->id] = array_key_exists($currency->id, $spentInLimits)
|
||||
? bcadd($spentInLimits[$currency->id], $spentAmount)
|
||||
: $spentAmount;
|
||||
Log::debug(sprintf('The amount budgeted for budget limit #%d is %s %s', $limit->id, $currency->code, $amount));
|
||||
Log::debug(sprintf('spentInLimits[%s] is now %s', $currency->code, $spentInLimits[$currency->id]));
|
||||
}
|
||||
|
||||
// #10463
|
||||
Log::debug('Looping currencies');
|
||||
|
||||
/** @var TransactionCurrency $currency */
|
||||
foreach ($currencies as $currency) {
|
||||
$spentArr = $this->opsRepository->sumExpenses($start, $end, null, new Collection()->push($current), $currency);
|
||||
$spentInLimits[$currency->id] = array_key_exists($currency->id, $spentInLimits) ? $spentInLimits[$currency->id] : '0';
|
||||
$spentArr = $this->opsRepository->sumExpenses($start, $end, null, new Collection()->push($budget), $currency);
|
||||
|
||||
Log::debug(sprintf('Working on currency %s, spentInLimits is %s', $currency->code, $spentInLimits[$currency->id]));
|
||||
|
||||
if (array_key_exists($currency->id, $spentArr) && array_key_exists('sum', $spentArr[$currency->id])) {
|
||||
$array['spent'][$currency->id]['spent'] = $spentArr[$currency->id]['sum'];
|
||||
$array['spent'][$currency->id]['spent_outside'] = bcmul(
|
||||
bcsub($spentInLimits[$currency->id], $spentArr[$currency->id]['sum']),
|
||||
'-1'
|
||||
);
|
||||
$array['spent'][$currency->id]['currency_id'] = $currency->id;
|
||||
$array['spent'][$currency->id]['currency_symbol'] = $currency->symbol;
|
||||
$array['spent'][$currency->id]['currency_decimal_places'] = $currency->decimal_places;
|
||||
|
||||
@@ -196,6 +196,8 @@ class ExportDataGenerator
|
||||
|
||||
// @phpstan-ignore-line
|
||||
|
||||
// @phpstan-ignore-line
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->accounts = new Collection();
|
||||
|
||||
@@ -98,8 +98,10 @@ trait GetConfigurationData
|
||||
$title = sprintf('%s - %s', $start->isoFormat($this->monthAndDayFormat), $end->isoFormat($this->monthAndDayFormat));
|
||||
$isCustom = true === session('is_custom_range', false);
|
||||
$today = today(config('app.timezone'));
|
||||
$ranges = [// first range is the current range:
|
||||
$title => [$start, $end]];
|
||||
$ranges = [
|
||||
// first range is the current range:
|
||||
$title => [$start, $end],
|
||||
];
|
||||
Log::debug(sprintf('dateRange: the date range in the session is"%s" - "%s"', $start->format('Y-m-d'), $end->format('Y-m-d')));
|
||||
|
||||
// when current range is a custom range, add the current period as the next range.
|
||||
|
||||
@@ -68,12 +68,13 @@ class General extends AbstractExtension
|
||||
$this->getRootSearchOperator(),
|
||||
$this->carbonize(),
|
||||
$this->fireflyIIIConfig(),
|
||||
$this->bccomp(),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Will return "active" when a part of the route matches the argument.
|
||||
* ie. "accounts" will match "accounts.index".
|
||||
* i.e. "accounts" will match "accounts.index".
|
||||
*/
|
||||
protected function activeRoutePartial(): TwigFunction
|
||||
{
|
||||
@@ -89,6 +90,10 @@ class General extends AbstractExtension
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Will return "active" when a part of the route matches the argument.
|
||||
* ie. "accounts" will match "accounts.index".
|
||||
*/
|
||||
/**
|
||||
* This function will return "active" when the current route matches the first argument (even partly)
|
||||
* but, the variable $objectType has been set and matches the second argument.
|
||||
@@ -189,6 +194,13 @@ class General extends AbstractExtension
|
||||
});
|
||||
}
|
||||
|
||||
protected function bccomp(): TwigFunction
|
||||
{
|
||||
return new TwigFunction('bccomp', static function (string $left, string $right): int {
|
||||
return bccomp($left, $right, 12);
|
||||
});
|
||||
}
|
||||
|
||||
protected function carbonize(): TwigFunction
|
||||
{
|
||||
return new TwigFunction('carbonize', static fn (string $date): Carbon => new Carbon($date, config('app.timezone')));
|
||||
|
||||
@@ -156,8 +156,13 @@ $app = Application::configure(basePath: dirname(__DIR__))
|
||||
]);
|
||||
// This middleware is added to ensure that the user is not only logged in and
|
||||
// authenticated (with MFA and everything), but also admin.
|
||||
$middleware->appendToGroup('api-admin', [
|
||||
IsAdmin::class,
|
||||
]);
|
||||
$middleware->appendToGroup('admin', [
|
||||
IsAdmin::class,
|
||||
Range::class,
|
||||
InterestingMessage::class
|
||||
]);
|
||||
|
||||
// if the user is not logged in, this group applies.
|
||||
|
||||
@@ -78,8 +78,8 @@ return [
|
||||
'running_balance_column' => (bool)envNonEmpty('USE_RUNNING_BALANCE', true), // this is only the default value, is not used.
|
||||
// see cer.php for exchange rates feature flag.
|
||||
],
|
||||
'version' => '6.5.1',
|
||||
'build_time' => 1772225602,
|
||||
'version' => 'develop/2026-02-28',
|
||||
'build_time' => 1772260395,
|
||||
'api_version' => '2.1.0', // field is no longer used.
|
||||
'db_version' => 28, // field is no longer used.
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ tab-width = 4
|
||||
use-tabs = false
|
||||
trailing-comma = false
|
||||
method-chain-breaking-style = "same_line"
|
||||
preserve-breaking-array-like = false
|
||||
preserve-breaking-array-like = true
|
||||
align-assignment-like = true
|
||||
null-type-hint = "null_pipe"
|
||||
sort-class-methods = true
|
||||
|
||||
@@ -100,7 +100,7 @@ function updateBudgetedAmount(e) {
|
||||
input.data('limit', data.id);
|
||||
// update amount left.
|
||||
$('.left_span[data-limit="0"][data-id="' + budgetId + '"]').html(data.left_formatted);
|
||||
if (data.left_per_day > 0) {
|
||||
if (data.left_per_day > 0 && !data.in_past) {
|
||||
$('.left_span[data-limit="0"][data-id="' + budgetId + '"]').html(data.left_formatted + '(' + data.left_per_day_formatted + ')');
|
||||
}
|
||||
// update budgeted amount
|
||||
@@ -117,7 +117,7 @@ function updateBudgetedAmount(e) {
|
||||
input.prop('disabled', false);
|
||||
input.data('limit', data.id);
|
||||
$('.left_span[data-limit="' + budgetLimitId + '"]').html(data.left_formatted);
|
||||
if (data.left_per_day > 0) {
|
||||
if (data.left_per_day > 0 && !data.in_past) {
|
||||
$('.left_span[data-limit="' + budgetLimitId + '"]').html(data.left_formatted + '(' + data.left_per_day_formatted + ')');
|
||||
}
|
||||
updateTotalBudgetedAmount(data.transaction_currency_id);
|
||||
|
||||
@@ -324,89 +324,11 @@
|
||||
{% endif %}
|
||||
</td>
|
||||
<td class="hidden-sm hidden-xs spent" data-id="{{ budget.id }}" style="text-align:right;">
|
||||
|
||||
{% for spentInfo in budget.spent %}
|
||||
{{ formatAmountBySymbol(spentInfo.spent, spentInfo.currency_symbol, spentInfo.currency_decimal_places) }}
|
||||
{% if 0 == activeDaysPassed %}
|
||||
({{ formatAmountBySymbol(spentInfo.spent, spentInfo.currency_symbol, spentInfo.currency_decimal_places) }})
|
||||
{% else %}
|
||||
({{ formatAmountBySymbol(spentInfo.spent / activeDaysPassed, spentInfo.currency_symbol, spentInfo.currency_decimal_places) }})
|
||||
{% endif %}
|
||||
<br/>
|
||||
{% endfor %}
|
||||
{% for budgetLimit in budget.budgeted %}
|
||||
{% if null == budget.spent[budgetLimit.currency_id] %}
|
||||
{{ formatAmountBySymbol(0, budgetLimit.currency_symbol, budgetLimit.currency_decimal_places) }}<br/>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% include('budgets.partials.amount-spent') %}
|
||||
</td>
|
||||
{# this cell displays the amount left in the budget, per budget limit. #}
|
||||
<td class="left" data-id="{{ budget.id }}" style="text-align: right;">
|
||||
{% for spentInfo in budget.spent %}
|
||||
{% set countLimit = 0 %}
|
||||
{% for budgetLimit in budget.budgeted %}
|
||||
{# now looping a single budget limit. #}
|
||||
{% if spentInfo.currency_id == budgetLimit.currency_id and budgetLimit.in_range %}
|
||||
{# the code below is used for budget limits INSIDE the current view range. #}
|
||||
{% set countLimit = countLimit + 1 %}
|
||||
|
||||
<span class="left_span" data-currency="{{ spentInfo.currency_id }}" data-limit="{{ budgetLimit.id }}"
|
||||
data-value="{{ spentInfo.spent + budgetLimit.amount }}" class="amount_left">
|
||||
{# the amount left is automatically calculated. #}
|
||||
{{ formatAmountBySymbol(spentInfo.spent + budgetLimit.amount, spentInfo.currency_symbol, spentInfo.currency_decimal_places) }}
|
||||
{% if spentInfo.spent + budgetLimit.amount > 0 %}
|
||||
{% if 0 == activeDaysLeft %}
|
||||
({{ formatAmountBySymbol(spentInfo.spent + budgetLimit.amount, spentInfo.currency_symbol, spentInfo.currency_decimal_places) }})
|
||||
{% else %}
|
||||
({{ formatAmountBySymbol((spentInfo.spent + budgetLimit.amount) / activeDaysLeft, spentInfo.currency_symbol, spentInfo.currency_decimal_places) }})
|
||||
{% endif %}
|
||||
{% else %}
|
||||
({{ formatAmountBySymbol(0, spentInfo.currency_symbol, spentInfo.currency_decimal_places) }})
|
||||
{% endif %}
|
||||
</span>
|
||||
<br/>
|
||||
{% endif %}
|
||||
{% if spentInfo.currency_id == budgetLimit.currency_id and not budgetLimit.in_range and 0.0 == budgetLimit.total_days %}
|
||||
<span class="left_span" data-currency="{{ spentInfo.currency_id }}" data-limit="{{ budgetLimit.id }}"
|
||||
data-value="{{ spentInfo.spent + budgetLimit.amount }}" class="amount_left">
|
||||
{{ formatAmountBySymbol(spentInfo.spent + budgetLimit.amount, spentInfo.currency_symbol, spentInfo.currency_decimal_places) }}
|
||||
</span>
|
||||
<span class="text-muted">({{ 'unknown'|_ }})</span>
|
||||
{% endif %}
|
||||
{% if spentInfo.currency_id == budgetLimit.currency_id and not budgetLimit.in_range and 0.0 != budgetLimit.total_days %}
|
||||
<span class="left_span" data-currency="{{ spentInfo.currency_id }}" data-limit="{{ budgetLimit.id }}"
|
||||
data-value="{{ spentInfo.spent + budgetLimit.amount }}" class="amount_left">
|
||||
{{ formatAmountBySymbol(spentInfo.spent + budgetLimit.amount, spentInfo.currency_symbol, spentInfo.currency_decimal_places) }}
|
||||
</span>
|
||||
({{ formatAmountBySymbol((spentInfo.spent + budgetLimit.amount) / budgetLimit.total_days, spentInfo.currency_symbol, spentInfo.currency_decimal_places) }})
|
||||
{% endif %}
|
||||
|
||||
{% endfor %}
|
||||
|
||||
{% if countLimit == 0 %}
|
||||
{# display nothing #}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% for budgetLimit in budget.budgeted %}
|
||||
{% if null == budget.spent[budgetLimit.currency_id] %}
|
||||
<span class="left_span" data-currency="{{ spentInfo.currency_id }}" data-limit="{{ budgetLimit.id }}"
|
||||
data-value="{{ spentInfo.spent + budgetLimit.amount }}" class="amount_left">
|
||||
{{ formatAmountBySymbol(budgetLimit.amount, budgetLimit.currency_symbol, budgetLimit.currency_decimal_places) }}
|
||||
{% if budgetLimit.in_range %}
|
||||
{% if 0 == activeDaysLeft %}
|
||||
({{ formatAmountBySymbol(budgetLimit.amount, budgetLimit.currency_symbol, budgetLimit.currency_decimal_places) }})
|
||||
{% else %}
|
||||
({{ formatAmountBySymbol(budgetLimit.amount / activeDaysLeft, budgetLimit.currency_symbol, budgetLimit.currency_decimal_places) }})
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{% if not budgetLimit.in_range %}
|
||||
{# For issue #10441, add per day if the budget limit is out of range. #}
|
||||
({{ formatAmountBySymbol(budgetLimit.amount / budgetLimit.total_days, budgetLimit.currency_symbol, budgetLimit.currency_decimal_places) }})
|
||||
{% endif %}
|
||||
</span>
|
||||
<br/>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% include('budgets.partials.amount-left') %}
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
|
||||
87
resources/views/budgets/partials/amount-left.twig
Normal file
87
resources/views/budgets/partials/amount-left.twig
Normal file
@@ -0,0 +1,87 @@
|
||||
{# The amount left can only be shown for actual budget limits. #}
|
||||
{% for budgetLimit in budget.budgeted %}
|
||||
<span class="left_span" data-currency="{{ budgetLimit.currency_id }}" data-limit="{{ budgetLimit.id }}" data-value="{{ budgetLimit.left }}" class="amount_left">
|
||||
{{ formatAmountBySymbol(budgetLimit.left, budgetLimit.currency_symbol, budgetLimit.currency_decimal_places) }}
|
||||
{% if not budgetLimit.in_past %}
|
||||
{% if 0 == budgetLimit.active_days_left %}
|
||||
({{ formatAmountBySymbol(budgetLimit.left, budgetLimit.currency_symbol, budgetLimit.currency_decimal_places) }})
|
||||
{% else %}
|
||||
({{ formatAmountBySymbol(budgetLimit.left / budgetLimit.active_days_left, budgetLimit.currency_symbol, budgetLimit.currency_decimal_places) }})
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
</span><br />
|
||||
{% endfor %}
|
||||
|
||||
|
||||
{#
|
||||
{% for spentInfo in budget.spent %}
|
||||
{% set countLimit = 0 %}
|
||||
<!-- loop each budget limit collected for this budget in this period. -->
|
||||
{% for budgetLimit in budget.budgeted %}
|
||||
<!-- now looping a single budget limit. -->
|
||||
{% if spentInfo.currency_id == budgetLimit.currency_id and budgetLimit.in_range %}
|
||||
<!-- the code below is used for budget limits INSIDE the current view range. -->
|
||||
{% set countLimit = countLimit + 1 %}
|
||||
|
||||
<span class="left_span" data-currency="{{ spentInfo.currency_id }}" data-limit="{{ budgetLimit.id }}"
|
||||
data-value="{{ spentInfo.spent + budgetLimit.amount }}" class="amount_left">
|
||||
<!--the amount left is automatically calculated. -->
|
||||
{{ formatAmountBySymbol(spentInfo.spent + budgetLimit.amount, spentInfo.currency_symbol, spentInfo.currency_decimal_places) }}
|
||||
{% if spentInfo.spent + budgetLimit.amount > 0 %}
|
||||
{% if 0 == activeDaysLeft %}
|
||||
({{ formatAmountBySymbol(spentInfo.spent + budgetLimit.amount, spentInfo.currency_symbol, spentInfo.currency_decimal_places) }})
|
||||
{% else %}
|
||||
({{ formatAmountBySymbol((spentInfo.spent + budgetLimit.amount) / activeDaysLeft, spentInfo.currency_symbol, spentInfo.currency_decimal_places) }})
|
||||
{% endif %}
|
||||
{% else %}
|
||||
({{ formatAmountBySymbol(0, spentInfo.currency_symbol, spentInfo.currency_decimal_places) }})
|
||||
{% endif %}
|
||||
</span>
|
||||
<br/>
|
||||
{% endif %}
|
||||
|
||||
{% if spentInfo.currency_id == budgetLimit.currency_id and not budgetLimit.in_range and 0.0 == budgetLimit.total_days %}
|
||||
<span class="left_span" data-currency="{{ spentInfo.currency_id }}" data-limit="{{ budgetLimit.id }}"
|
||||
data-value="{{ spentInfo.spent + budgetLimit.amount }}" class="amount_left">
|
||||
{{ formatAmountBySymbol(spentInfo.spent + budgetLimit.amount, spentInfo.currency_symbol, spentInfo.currency_decimal_places) }}
|
||||
</span>
|
||||
<span class="text-muted">({{ 'unknown'|_ }})</span>
|
||||
{% endif %}
|
||||
{% if spentInfo.currency_id == budgetLimit.currency_id and not budgetLimit.in_range and 0.0 != budgetLimit.total_days %}
|
||||
|
||||
<span class="left_span" data-currency="{{ spentInfo.currency_id }}" data-limit="{{ budgetLimit.id }}"
|
||||
data-value="{{ spentInfo.spent + budgetLimit.amount }}" class="amount_left">
|
||||
{{ formatAmountBySymbol(spentInfo.spent + budgetLimit.amount, spentInfo.currency_symbol, spentInfo.currency_decimal_places) }}
|
||||
</span>
|
||||
({{ formatAmountBySymbol((spentInfo.spent + budgetLimit.amount) / budgetLimit.total_days, spentInfo.currency_symbol, spentInfo.currency_decimal_places) }})
|
||||
{% endif %}
|
||||
|
||||
{% endfor %}
|
||||
|
||||
{% if countLimit == 0 %}
|
||||
<!-- display nothing -->
|
||||
{% endif %}
|
||||
-->
|
||||
{% endfor %}
|
||||
{% for budgetLimit in budget.budgeted %}
|
||||
{% if null == budget.spent[budgetLimit.currency_id] %}
|
||||
<span class="left_span" data-currency="{{ spentInfo.currency_id }}" data-limit="{{ budgetLimit.id }}"
|
||||
data-value="{{ spentInfo.spent + budgetLimit.amount }}" class="amount_left">
|
||||
{{ formatAmountBySymbol(budgetLimit.amount, budgetLimit.currency_symbol, budgetLimit.currency_decimal_places) }}
|
||||
{% if budgetLimit.in_range %}
|
||||
{% if 0 == activeDaysLeft %}
|
||||
({{ formatAmountBySymbol(budgetLimit.amount, budgetLimit.currency_symbol, budgetLimit.currency_decimal_places) }})
|
||||
{% else %}
|
||||
({{ formatAmountBySymbol(budgetLimit.amount / activeDaysLeft, budgetLimit.currency_symbol, budgetLimit.currency_decimal_places) }})
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{% if not budgetLimit.in_range %}
|
||||
<!-- For issue #10441, add per day if the budget limit is out of range. -->
|
||||
({{ formatAmountBySymbol(budgetLimit.amount / budgetLimit.total_days, budgetLimit.currency_symbol, budgetLimit.currency_decimal_places) }})
|
||||
{% endif %}
|
||||
</span>
|
||||
<br/>
|
||||
{% endif %}
|
||||
|
||||
{% endfor %}
|
||||
#}
|
||||
42
resources/views/budgets/partials/amount-spent.twig
Normal file
42
resources/views/budgets/partials/amount-spent.twig
Normal file
@@ -0,0 +1,42 @@
|
||||
{# this is spent in budget limits: #}
|
||||
{% for budgetLimit in budget.budgeted %}
|
||||
{{ formatAmountBySymbol(budgetLimit.spent, budgetLimit.currency_symbol, budgetLimit.currency_decimal_places) }}
|
||||
{% if 0 == budgetLimit.active_days_passed %}
|
||||
({{ formatAmountBySymbol(budgetLimit.spent, budgetLimit.currency_symbol, budgetLimit.currency_decimal_places) }})
|
||||
{% else %}
|
||||
({{ formatAmountBySymbol(budgetLimit.spent / budgetLimit.active_days_passed, budgetLimit.currency_symbol, budgetLimit.currency_decimal_places) }})
|
||||
{% endif %}
|
||||
<br />
|
||||
{% endfor %}
|
||||
|
||||
{# this is spent NOT in budget limits: #}
|
||||
{% for spent in budget.spent %}
|
||||
{% if 0 != bccomp('0', spent.spent_outside) %}
|
||||
{{ formatAmountBySymbol(spent.spent_outside, spent.currency_symbol, spent.currency_decimal_places) }}
|
||||
{% if 0 == activeDaysPassed %}
|
||||
({{ formatAmountBySymbol(spent.spent_outside, spent.currency_symbol, spent.currency_decimal_places) }})
|
||||
{% else %}
|
||||
({{ formatAmountBySymbol(spent.spent_outside / activeDaysPassed, spent.currency_symbol, spent.currency_decimal_places) }})
|
||||
{% endif %}
|
||||
<br />
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
|
||||
{#
|
||||
|
||||
|
||||
{% for spentInfo in budget.spent %}
|
||||
{{ formatAmountBySymbol(spentInfo.spent, spentInfo.currency_symbol, spentInfo.currency_decimal_places) }}
|
||||
{% if 0 == activeDaysPassed %}
|
||||
({{ formatAmountBySymbol(spentInfo.spent, spentInfo.currency_symbol, spentInfo.currency_decimal_places) }})
|
||||
{% else %}
|
||||
({{ formatAmountBySymbol(spentInfo.spent / activeDaysPassed, spentInfo.currency_symbol, spentInfo.currency_decimal_places) }})
|
||||
{% endif %}
|
||||
<br/>
|
||||
{% endfor %}
|
||||
{% for budgetLimit in budget.budgeted %}
|
||||
{% if null == budget.spent[budgetLimit.currency_id] %}
|
||||
{{ formatAmountBySymbol(0, budgetLimit.currency_symbol, budgetLimit.currency_decimal_places) }}<br/>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
#}
|
||||
@@ -347,7 +347,7 @@ Route::group(
|
||||
'namespace' => 'FireflyIII\Api\V1\Controllers\Models\UserGroup',
|
||||
'prefix' => 'v1/user-groups',
|
||||
'as' => 'api.v1.user-groups.',
|
||||
'middleware' => ['admin'],
|
||||
'middleware' => ['api-admin'],
|
||||
],
|
||||
static function (): void {
|
||||
Route::get('', ['uses' => 'IndexController@index', 'as' => 'index']);
|
||||
@@ -724,7 +724,7 @@ Route::group(
|
||||
'namespace' => 'FireflyIII\Api\V1\Controllers\System',
|
||||
'prefix' => 'v1/configuration',
|
||||
'as' => 'api.v1.configuration.',
|
||||
'middleware' => ['admin'],
|
||||
'middleware' => ['api-admin'],
|
||||
],
|
||||
static function (): void {
|
||||
Route::get('', ['uses' => 'ConfigurationController@index', 'as' => 'index']);
|
||||
@@ -738,7 +738,7 @@ Route::group(
|
||||
'namespace' => 'FireflyIII\Api\V1\Controllers\System',
|
||||
'prefix' => 'v1/users',
|
||||
'as' => 'api.v1.users.',
|
||||
'middleware' => ['admin'],
|
||||
'middleware' => ['api-admin'],
|
||||
],
|
||||
static function (): void {
|
||||
Route::get('', ['uses' => 'UserController@index', 'as' => 'index']);
|
||||
|
||||
Reference in New Issue
Block a user