Various nestor-related fixes.

This commit is contained in:
James Cole
2025-05-24 05:40:20 +02:00
parent b7ec7625c0
commit c40229e9fa
63 changed files with 222 additions and 156 deletions

View File

@@ -23,6 +23,7 @@ declare(strict_types=1);
namespace FireflyIII\Http\Controllers\Chart;
use function Safe\json_encode;
use Carbon\Carbon;
use FireflyIII\Enums\AccountTypeEnum;
use FireflyIII\Enums\TransactionTypeEnum;
@@ -468,14 +469,14 @@ class AccountController extends Controller
Log::debug('Balances exist at:');
foreach ($range as $key => $value) {
$newRange[] = ['date' => $key, 'info' => $value];
Log::debug(sprintf('%d - %s (%s)', count($newRange) - 1, $key, \Safe\json_encode($value)));
Log::debug(sprintf('%d - %s (%s)', count($newRange) - 1, $key, json_encode($value)));
}
$carbon = Carbon::createFromFormat('Y-m-d', $newRange[0]['date'])->endOfDay();
Log::debug(sprintf('Start of loop, $carbon is %s', $carbon->format('Y-m-d H:i:s')));
while ($end->gte($current)) {
$momentBalance = $previous;
// $theDate = $current->format('Y-m-d');
Log::debug(sprintf('Now at %s, with momentBalance %s', $current->format('Y-m-d H:i:s'), \Safe\json_encode($momentBalance)));
Log::debug(sprintf('Now at %s, with momentBalance %s', $current->format('Y-m-d H:i:s'), json_encode($momentBalance)));
// loop over the array with balances, find one that is earlier or on the same day.
while ($carbon->lte($current) && array_key_exists($expectedIndex, $newRange)) {
@@ -490,7 +491,7 @@ class AccountController extends Controller
$carbon = Carbon::createFromFormat('Y-m-d', $newRange[$expectedIndex]['date'])->endOfDay();
}
}
Log::debug(sprintf('momentBalance is now %s', \Safe\json_encode($momentBalance)));
Log::debug(sprintf('momentBalance is now %s', json_encode($momentBalance)));
$return = $this->updateChartKeys($return, $momentBalance);
$previous = $momentBalance;

View File

@@ -202,7 +202,7 @@ class BudgetController extends Controller
{
/** @var GroupCollectorInterface $collector */
$collector = app(GroupCollectorInterface::class);
$budgetLimitId = null === $budgetLimit ? 0 : $budgetLimit->id;
$budgetLimitId = $budgetLimit instanceof BudgetLimit ? $budgetLimit->id : 0;
$cache = new CacheProperties();
$cache->addProperty($budget->id);
$cache->addProperty($this->convertToNative);
@@ -211,7 +211,7 @@ class BudgetController extends Controller
$start = session('first', today(config('app.timezone'))->startOfYear());
$end = today();
if (null !== $budgetLimit) {
if ($budgetLimit instanceof BudgetLimit) {
$start = $budgetLimit->start_date;
$end = $budgetLimit->end_date;
$collector->setRange($budgetLimit->start_date, $budgetLimit->end_date)->setNormalCurrency($budgetLimit->transactionCurrency);
@@ -285,7 +285,7 @@ class BudgetController extends Controller
{
/** @var GroupCollectorInterface $collector */
$collector = app(GroupCollectorInterface::class);
$budgetLimitId = null === $budgetLimit ? 0 : $budgetLimit->id;
$budgetLimitId = $budgetLimit instanceof BudgetLimit ? $budgetLimit->id : 0;
$cache = new CacheProperties();
$cache->addProperty($budget->id);
$cache->addProperty($this->convertToNative);
@@ -293,7 +293,7 @@ class BudgetController extends Controller
$cache->addProperty('chart.budget.expense-category');
$start = session('first', today(config('app.timezone'))->startOfYear());
$end = today();
if (null !== $budgetLimit) {
if ($budgetLimit instanceof BudgetLimit) {
$start = $budgetLimit->start_date;
$end = $budgetLimit->end_date;
$collector->setNormalCurrency($budgetLimit->transactionCurrency);
@@ -367,7 +367,7 @@ class BudgetController extends Controller
{
/** @var GroupCollectorInterface $collector */
$collector = app(GroupCollectorInterface::class);
$budgetLimitId = null === $budgetLimit ? 0 : $budgetLimit->id;
$budgetLimitId = $budgetLimit instanceof BudgetLimit ? $budgetLimit->id : 0;
$cache = new CacheProperties();
$cache->addProperty($budget->id);
$cache->addProperty($budgetLimitId);
@@ -375,7 +375,7 @@ class BudgetController extends Controller
$cache->addProperty('chart.budget.expense-expense');
$start = session('first', today(config('app.timezone'))->startOfYear());
$end = today();
if (null !== $budgetLimit) {
if ($budgetLimit instanceof BudgetLimit) {
$start = $budgetLimit->start_date;
$end = $budgetLimit->end_date;
$collector->setRange($budgetLimit->start_date, $budgetLimit->end_date)->setNormalCurrency($budgetLimit->transactionCurrency);
@@ -529,7 +529,7 @@ class BudgetController extends Controller
// get budget limit in this period for this currency.
$limit = $this->blRepository->find($budget, $currency, $currentStart, $currentEnd);
if (null !== $limit) {
if ($limit instanceof BudgetLimit) {
$chartData[1]['entries'][$title] = app('steam')->bcround($limit->amount, $currency->decimal_places);
}

View File

@@ -159,7 +159,7 @@ class CategoryController extends Controller
$income = [];
$expenses = [];
$categoryId = 0;
if (null === $category) {
if (!$category instanceof Category) {
/** @var NoCategoryRepositoryInterface $noCatRepository */
$noCatRepository = app(NoCategoryRepositoryInterface::class);
@@ -168,7 +168,7 @@ class CategoryController extends Controller
$income = $noCatRepository->listIncome($start, $end, $accounts);
}
if (null !== $category) {
if ($category instanceof Category) {
/** @var OperationsRepositoryInterface $opsRepository */
$opsRepository = app(OperationsRepositoryInterface::class);
$categoryId = $category->id;