mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-03 20:20:37 -06:00
Code for #3309
This commit is contained in:
parent
e6e8200912
commit
dbd68cedc9
@ -97,6 +97,7 @@ class IndexController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function index(Request $request, Carbon $start = null, Carbon $end = null)
|
public function index(Request $request, Carbon $start = null, Carbon $end = null)
|
||||||
{
|
{
|
||||||
|
Log::debug('Start of IndexController::index()');
|
||||||
// collect some basic vars:
|
// collect some basic vars:
|
||||||
$range = app('preferences')->get('viewRange', '1M')->data;
|
$range = app('preferences')->get('viewRange', '1M')->data;
|
||||||
$start = $start ?? session('start', Carbon::now()->startOfMonth());
|
$start = $start ?? session('start', Carbon::now()->startOfMonth());
|
||||||
@ -104,15 +105,18 @@ class IndexController extends Controller
|
|||||||
$defaultCurrency = app('amount')->getDefaultCurrency();
|
$defaultCurrency = app('amount')->getDefaultCurrency();
|
||||||
$budgeted = '0';
|
$budgeted = '0';
|
||||||
$spent = '0';
|
$spent = '0';
|
||||||
|
Log::debug(sprintf('1) Start is "%s", end is "%s"', $start->format('Y-m-d H:i:s'), $end->format('Y-m-d H:i:s')));
|
||||||
|
|
||||||
// new period stuff:
|
// new period stuff:
|
||||||
$periodTitle = app('navigation')->periodShow($start, $range);
|
$periodTitle = app('navigation')->periodShow($start, $range);
|
||||||
$prevLoop = $this->getPreviousPeriods($start, $range);
|
$prevLoop = $this->getPreviousPeriods($start, $range);
|
||||||
$nextLoop = $this->getNextPeriods($start, $range);
|
$nextLoop = $this->getNextPeriods($start, $range);
|
||||||
|
Log::debug(sprintf('2) Start is "%s", end is "%s"', $start->format('Y-m-d H:i:s'), $end->format('Y-m-d H:i:s')));
|
||||||
|
|
||||||
// get all available budgets.
|
// get all available budgets.
|
||||||
$ab = $this->abRepository->get($start, $end);
|
$ab = $this->abRepository->get($start, $end);
|
||||||
$availableBudgets = [];
|
$availableBudgets = [];
|
||||||
|
Log::debug(sprintf('3) Start is "%s", end is "%s"', $start->format('Y-m-d H:i:s'), $end->format('Y-m-d H:i:s')));
|
||||||
// for each, complement with spent amount:
|
// for each, complement with spent amount:
|
||||||
/** @var AvailableBudget $entry */
|
/** @var AvailableBudget $entry */
|
||||||
foreach ($ab as $entry) {
|
foreach ($ab as $entry) {
|
||||||
@ -129,6 +133,7 @@ class IndexController extends Controller
|
|||||||
$array['budgeted'] = $budgeted;
|
$array['budgeted'] = $budgeted;
|
||||||
$availableBudgets[] = $array;
|
$availableBudgets[] = $array;
|
||||||
unset($spentArr);
|
unset($spentArr);
|
||||||
|
Log::debug(sprintf('4) Start is "%s", end is "%s"', $start->format('Y-m-d H:i:s'), $end->format('Y-m-d H:i:s')));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (0 === count($availableBudgets)) {
|
if (0 === count($availableBudgets)) {
|
||||||
@ -137,6 +142,7 @@ class IndexController extends Controller
|
|||||||
$spentArr = $this->opsRepository->sumExpenses($start, $end, null, null, $defaultCurrency);
|
$spentArr = $this->opsRepository->sumExpenses($start, $end, null, null, $defaultCurrency);
|
||||||
$spent = $spentArr[$defaultCurrency->id]['sum'] ?? '0';
|
$spent = $spentArr[$defaultCurrency->id]['sum'] ?? '0';
|
||||||
unset($spentArr);
|
unset($spentArr);
|
||||||
|
Log::debug(sprintf('5) Start is "%s", end is "%s"', $start->format('Y-m-d H:i:s'), $end->format('Y-m-d H:i:s')));
|
||||||
}
|
}
|
||||||
|
|
||||||
// count the number of enabled currencies. This determines if we display a "+" button.
|
// count the number of enabled currencies. This determines if we display a "+" button.
|
||||||
@ -146,11 +152,12 @@ class IndexController extends Controller
|
|||||||
// number of days for consistent budgeting.
|
// number of days for consistent budgeting.
|
||||||
$activeDaysPassed = $this->activeDaysPassed($start, $end); // see method description.
|
$activeDaysPassed = $this->activeDaysPassed($start, $end); // see method description.
|
||||||
$activeDaysLeft = $this->activeDaysLeft($start, $end); // see method description.
|
$activeDaysLeft = $this->activeDaysLeft($start, $end); // see method description.
|
||||||
Log::debug(sprintf('Start: %s, end: %s', $start->format('Y-m-d H:i:s'), $end->format('Y-m-d H:i:s')));
|
Log::debug(sprintf('6) Start is "%s", end is "%s"', $start->format('Y-m-d H:i:s'), $end->format('Y-m-d H:i:s')));
|
||||||
|
|
||||||
// get all budgets, and paginate them into $budgets.
|
// get all budgets, and paginate them into $budgets.
|
||||||
$collection = $this->repository->getActiveBudgets();
|
$collection = $this->repository->getActiveBudgets();
|
||||||
$budgets = [];
|
$budgets = [];
|
||||||
|
Log::debug(sprintf('7) Start is "%s", end is "%s"', $start->format('Y-m-d H:i:s'), $end->format('Y-m-d H:i:s')));
|
||||||
|
|
||||||
// complement budget with budget limits in range, and expenses in currency X in range.
|
// complement budget with budget limits in range, and expenses in currency X in range.
|
||||||
/** @var Budget $current */
|
/** @var Budget $current */
|
||||||
@ -161,18 +168,22 @@ class IndexController extends Controller
|
|||||||
$array['attachments'] = $this->repository->getAttachments($current);
|
$array['attachments'] = $this->repository->getAttachments($current);
|
||||||
$array['auto_budget'] = $this->repository->getAutoBudget($current);
|
$array['auto_budget'] = $this->repository->getAutoBudget($current);
|
||||||
$budgetLimits = $this->blRepository->getBudgetLimits($current, $start, $end);
|
$budgetLimits = $this->blRepository->getBudgetLimits($current, $start, $end);
|
||||||
|
Log::debug(sprintf('8) Start is "%s", end is "%s"', $start->format('Y-m-d H:i:s'), $end->format('Y-m-d H:i:s')));
|
||||||
/** @var BudgetLimit $limit */
|
/** @var BudgetLimit $limit */
|
||||||
foreach ($budgetLimits as $limit) {
|
foreach ($budgetLimits as $limit) {
|
||||||
$currency = $limit->transactionCurrency ?? $defaultCurrency;
|
$currency = $limit->transactionCurrency ?? $defaultCurrency;
|
||||||
$array['budgeted'][] = [
|
$array['budgeted'][] = [
|
||||||
'id' => $limit->id,
|
'id' => $limit->id,
|
||||||
'amount' => round($limit->amount, $currency->decimal_places),
|
'amount' => round($limit->amount, $currency->decimal_places),
|
||||||
|
'start_date' => $limit->start_date->formatLocalized($this->monthAndDayFormat),
|
||||||
|
'end_date' => $limit->end_date->formatLocalized($this->monthAndDayFormat),
|
||||||
|
'in_range' => $limit->start_date->isSameDay($start) && $limit->end_date->isSameDay($end),
|
||||||
'currency_id' => $currency->id,
|
'currency_id' => $currency->id,
|
||||||
'currency_symbol' => $currency->symbol,
|
'currency_symbol' => $currency->symbol,
|
||||||
'currency_name' => $currency->name,
|
'currency_name' => $currency->name,
|
||||||
'currency_decimal_places' => $currency->decimal_places,
|
'currency_decimal_places' => $currency->decimal_places,
|
||||||
];
|
];
|
||||||
|
Log::debug(sprintf('9) Start is "%s", end is "%s"', $start->format('Y-m-d H:i:s'), $end->format('Y-m-d H:i:s')));
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @var TransactionCurrency $currency */
|
/** @var TransactionCurrency $currency */
|
||||||
@ -183,6 +194,7 @@ class IndexController extends Controller
|
|||||||
$array['spent'][$currency->id]['currency_id'] = $currency->id;
|
$array['spent'][$currency->id]['currency_id'] = $currency->id;
|
||||||
$array['spent'][$currency->id]['currency_symbol'] = $currency->symbol;
|
$array['spent'][$currency->id]['currency_symbol'] = $currency->symbol;
|
||||||
$array['spent'][$currency->id]['currency_decimal_places'] = $currency->decimal_places;
|
$array['spent'][$currency->id]['currency_decimal_places'] = $currency->decimal_places;
|
||||||
|
Log::debug(sprintf('10) Start is "%s", end is "%s"', $start->format('Y-m-d H:i:s'), $end->format('Y-m-d H:i:s')));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$budgets[] = $array;
|
$budgets[] = $array;
|
||||||
@ -190,7 +202,7 @@ class IndexController extends Controller
|
|||||||
|
|
||||||
// get all inactive budgets, and simply list them:
|
// get all inactive budgets, and simply list them:
|
||||||
$inactive = $this->repository->getInactiveBudgets();
|
$inactive = $this->repository->getInactiveBudgets();
|
||||||
|
Log::debug(sprintf('11) Start is "%s", end is "%s"', $start->format('Y-m-d H:i:s'), $end->format('Y-m-d H:i:s')));
|
||||||
|
|
||||||
return view(
|
return view(
|
||||||
'budgets.index',
|
'budgets.index',
|
||||||
|
@ -769,6 +769,7 @@ return [
|
|||||||
'options' => 'Options',
|
'options' => 'Options',
|
||||||
|
|
||||||
// budgets:
|
// budgets:
|
||||||
|
'budget_limit_not_in_range' => 'This amount applies from :start to :end.',
|
||||||
'total_available_budget' => 'Total available budget (between :start and :end)',
|
'total_available_budget' => 'Total available budget (between :start and :end)',
|
||||||
'total_available_budget_in_currency' => 'Total available budget in :currency',
|
'total_available_budget_in_currency' => 'Total available budget in :currency',
|
||||||
'see_below' => 'see below',
|
'see_below' => 'see below',
|
||||||
|
@ -276,6 +276,11 @@
|
|||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
{% if not budgetLimit.in_range %}
|
||||||
|
<small class="text-muted">
|
||||||
|
{{ trans('firefly.budget_limit_not_in_range', {start: budgetLimit.start_date, end: budgetLimit.end_date}) }}
|
||||||
|
</small><br>
|
||||||
|
{% endif %}
|
||||||
<span class="text-danger budget_warning" data-id="{{ budget.id }}" data-budgetLimit="{{ budgetLimit.id }}"
|
<span class="text-danger budget_warning" data-id="{{ budget.id }}" data-budgetLimit="{{ budgetLimit.id }}"
|
||||||
style="display:none;"></span>
|
style="display:none;"></span>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
Loading…
Reference in New Issue
Block a user