mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-12-18 12:28:46 +00:00
Fix #11310
This commit is contained in:
@@ -24,7 +24,6 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Api\V1\Controllers\Chart;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use FireflyIII\Api\V1\Controllers\Controller;
|
||||
use FireflyIII\Api\V1\Requests\Chart\ChartRequest;
|
||||
use FireflyIII\Enums\UserRoleEnum;
|
||||
@@ -32,11 +31,13 @@ use FireflyIII\Exceptions\FireflyException;
|
||||
use FireflyIII\Models\Account;
|
||||
use FireflyIII\Models\TransactionCurrency;
|
||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||
use FireflyIII\Support\Facades\Navigation;
|
||||
use FireflyIII\Support\Facades\Steam;
|
||||
use FireflyIII\Support\Http\Api\ApiSupport;
|
||||
use FireflyIII\Support\Http\Api\CleansChartData;
|
||||
use FireflyIII\Support\Http\Api\CollectsAccountsFromFilter;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
/**
|
||||
@@ -48,9 +49,9 @@ class AccountController extends Controller
|
||||
use CleansChartData;
|
||||
use CollectsAccountsFromFilter;
|
||||
|
||||
protected array $acceptedRoles = [UserRoleEnum::READ_ONLY];
|
||||
protected array $acceptedRoles = [UserRoleEnum::READ_ONLY];
|
||||
|
||||
private array $chartData = [];
|
||||
private array $chartData = [];
|
||||
private AccountRepositoryInterface $repository;
|
||||
|
||||
/**
|
||||
@@ -100,17 +101,17 @@ class AccountController extends Controller
|
||||
private function renderAccountData(array $params, Account $account): void
|
||||
{
|
||||
Log::debug(sprintf('Now in %s(array, #%d)', __METHOD__, $account->id));
|
||||
$currency = $this->repository->getAccountCurrency($account);
|
||||
$currentStart = clone $params['start'];
|
||||
$range = Steam::finalAccountBalanceInRange($account, $params['start'], clone $params['end'], $this->convertToPrimary);
|
||||
$currency = $this->repository->getAccountCurrency($account);
|
||||
$currentStart = clone $params['start'];
|
||||
$range = Steam::finalAccountBalanceInRange($account, $params['start'], clone $params['end'], $this->convertToPrimary);
|
||||
$period = $params['period'] ?? '1D';
|
||||
|
||||
|
||||
$previous = array_values($range)[0]['balance'];
|
||||
$pcPrevious = null;
|
||||
$previous = array_values($range)[0]['balance'];
|
||||
$pcPrevious = null;
|
||||
if (!$currency instanceof TransactionCurrency) {
|
||||
$currency = $this->primaryCurrency;
|
||||
}
|
||||
$currentSet = [
|
||||
$currentSet = [
|
||||
'label' => $account->name,
|
||||
|
||||
// the currency that belongs to the account.
|
||||
@@ -129,7 +130,7 @@ class AccountController extends Controller
|
||||
'end_date' => $params['end']->toAtomString(),
|
||||
'type' => 'line',
|
||||
'yAxisID' => 0,
|
||||
'period' => '1D',
|
||||
'period' => $period,
|
||||
'entries' => [],
|
||||
'pc_entries' => [],
|
||||
];
|
||||
@@ -141,7 +142,7 @@ class AccountController extends Controller
|
||||
$currentSet['primary_currency_decimal_places'] = $this->primaryCurrency->decimal_places;
|
||||
$pcPrevious = array_values($range)[0]['pc_balance'];
|
||||
}
|
||||
|
||||
// create array of values to collect.
|
||||
|
||||
while ($currentStart <= $params['end']) {
|
||||
$format = $currentStart->format('Y-m-d');
|
||||
@@ -152,14 +153,14 @@ class AccountController extends Controller
|
||||
|
||||
|
||||
// do the same for the primary currency balance, if relevant:
|
||||
$pcBalance = null;
|
||||
$pcBalance = null;
|
||||
if ($this->convertToPrimary) {
|
||||
$pcBalance = array_key_exists($format, $range) ? $range[$format]['pc_balance'] : $pcPrevious;
|
||||
$pcPrevious = $pcBalance;
|
||||
$currentSet['pc_entries'][$label] = $pcBalance;
|
||||
}
|
||||
|
||||
$currentStart->addDay();
|
||||
$currentStart = Navigation::addPeriod($currentStart, $period);
|
||||
// $currentStart->addDay();
|
||||
}
|
||||
$this->chartData[] = $currentSet;
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@ use Illuminate\View\View;
|
||||
*/
|
||||
class ExecutionController extends Controller
|
||||
{
|
||||
private AccountRepositoryInterface $repository;
|
||||
private readonly AccountRepositoryInterface $repository;
|
||||
|
||||
/**
|
||||
* ExecutionController constructor.
|
||||
|
||||
@@ -27,7 +27,6 @@ namespace Tests\unit\Support\Calendar\Periodicity;
|
||||
use FireflyIII\Support\Calendar\Periodicity\Bimonthly;
|
||||
use Carbon\Carbon;
|
||||
use FireflyIII\Support\Calendar\Periodicity;
|
||||
use FireflyIII\Support\Calendar\Periodicity\Interval;
|
||||
|
||||
/**
|
||||
* @group unit-test
|
||||
@@ -41,7 +40,7 @@ use FireflyIII\Support\Calendar\Periodicity\Interval;
|
||||
*/
|
||||
final class BimonthlyTest extends IntervalTestCase
|
||||
{
|
||||
public static function factory(): Interval
|
||||
public static function factory(): Bimonthly
|
||||
{
|
||||
return new Bimonthly();
|
||||
}
|
||||
|
||||
@@ -27,7 +27,6 @@ namespace Tests\unit\Support\Calendar\Periodicity;
|
||||
use FireflyIII\Support\Calendar\Periodicity\Daily;
|
||||
use Carbon\Carbon;
|
||||
use FireflyIII\Support\Calendar\Periodicity;
|
||||
use FireflyIII\Support\Calendar\Periodicity\Interval;
|
||||
|
||||
/**
|
||||
* @group unit-test
|
||||
@@ -41,7 +40,7 @@ use FireflyIII\Support\Calendar\Periodicity\Interval;
|
||||
*/
|
||||
final class DailyTest extends IntervalTestCase
|
||||
{
|
||||
public static function factory(): Interval
|
||||
public static function factory(): Daily
|
||||
{
|
||||
return new Daily();
|
||||
}
|
||||
|
||||
@@ -27,7 +27,6 @@ namespace Tests\unit\Support\Calendar\Periodicity;
|
||||
use FireflyIII\Support\Calendar\Periodicity\Fortnightly;
|
||||
use Carbon\Carbon;
|
||||
use FireflyIII\Support\Calendar\Periodicity;
|
||||
use FireflyIII\Support\Calendar\Periodicity\Interval;
|
||||
|
||||
/**
|
||||
* @group unit-test
|
||||
@@ -41,7 +40,7 @@ use FireflyIII\Support\Calendar\Periodicity\Interval;
|
||||
*/
|
||||
final class FortnightlyTest extends IntervalTestCase
|
||||
{
|
||||
public static function factory(): Interval
|
||||
public static function factory(): Fortnightly
|
||||
{
|
||||
return new Fortnightly();
|
||||
}
|
||||
|
||||
@@ -27,7 +27,6 @@ namespace Tests\unit\Support\Calendar\Periodicity;
|
||||
use FireflyIII\Support\Calendar\Periodicity\HalfYearly;
|
||||
use Carbon\Carbon;
|
||||
use FireflyIII\Support\Calendar\Periodicity;
|
||||
use FireflyIII\Support\Calendar\Periodicity\Interval;
|
||||
|
||||
/**
|
||||
* @group unit-test
|
||||
@@ -41,7 +40,7 @@ use FireflyIII\Support\Calendar\Periodicity\Interval;
|
||||
*/
|
||||
final class HalfYearlyTest extends IntervalTestCase
|
||||
{
|
||||
public static function factory(): Interval
|
||||
public static function factory(): HalfYearly
|
||||
{
|
||||
return new HalfYearly();
|
||||
}
|
||||
|
||||
@@ -27,7 +27,6 @@ namespace Tests\unit\Support\Calendar\Periodicity;
|
||||
use FireflyIII\Support\Calendar\Periodicity\Monthly;
|
||||
use Carbon\Carbon;
|
||||
use FireflyIII\Support\Calendar\Periodicity;
|
||||
use FireflyIII\Support\Calendar\Periodicity\Interval;
|
||||
|
||||
/**
|
||||
* @group unit-test
|
||||
@@ -41,7 +40,7 @@ use FireflyIII\Support\Calendar\Periodicity\Interval;
|
||||
*/
|
||||
final class MonthlyTest extends IntervalTestCase
|
||||
{
|
||||
public static function factory(): Interval
|
||||
public static function factory(): Monthly
|
||||
{
|
||||
return new Monthly();
|
||||
}
|
||||
|
||||
@@ -27,7 +27,6 @@ namespace Tests\unit\Support\Calendar\Periodicity;
|
||||
use FireflyIII\Support\Calendar\Periodicity\Quarterly;
|
||||
use Carbon\Carbon;
|
||||
use FireflyIII\Support\Calendar\Periodicity;
|
||||
use FireflyIII\Support\Calendar\Periodicity\Interval;
|
||||
|
||||
/**
|
||||
* @group unit-test
|
||||
@@ -41,7 +40,7 @@ use FireflyIII\Support\Calendar\Periodicity\Interval;
|
||||
*/
|
||||
final class QuarterlyTest extends IntervalTestCase
|
||||
{
|
||||
public static function factory(): Interval
|
||||
public static function factory(): Quarterly
|
||||
{
|
||||
return new Quarterly();
|
||||
}
|
||||
|
||||
@@ -27,7 +27,6 @@ namespace Tests\unit\Support\Calendar\Periodicity;
|
||||
use FireflyIII\Support\Calendar\Periodicity\Weekly;
|
||||
use Carbon\Carbon;
|
||||
use FireflyIII\Support\Calendar\Periodicity;
|
||||
use FireflyIII\Support\Calendar\Periodicity\Interval;
|
||||
|
||||
/**
|
||||
* @group unit-test
|
||||
@@ -41,7 +40,7 @@ use FireflyIII\Support\Calendar\Periodicity\Interval;
|
||||
*/
|
||||
final class WeeklyTest extends IntervalTestCase
|
||||
{
|
||||
public static function factory(): Interval
|
||||
public static function factory(): Weekly
|
||||
{
|
||||
return new Weekly();
|
||||
}
|
||||
|
||||
@@ -27,7 +27,6 @@ namespace Tests\unit\Support\Calendar\Periodicity;
|
||||
use FireflyIII\Support\Calendar\Periodicity\Yearly;
|
||||
use Carbon\Carbon;
|
||||
use FireflyIII\Support\Calendar\Periodicity;
|
||||
use FireflyIII\Support\Calendar\Periodicity\Interval;
|
||||
|
||||
/**
|
||||
* @group unit-test
|
||||
@@ -41,7 +40,7 @@ use FireflyIII\Support\Calendar\Periodicity\Interval;
|
||||
*/
|
||||
final class YearlyTest extends IntervalTestCase
|
||||
{
|
||||
public static function factory(): Interval
|
||||
public static function factory(): Yearly
|
||||
{
|
||||
return new Yearly();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user