mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2026-01-10 12:24:50 +00:00
Code for new release
This commit is contained in:
@@ -49,6 +49,7 @@ class RemoteUserGuard implements Guard
|
||||
*
|
||||
* @param UserProvider $provider
|
||||
* @param Application $app
|
||||
*
|
||||
* @throws ContainerExceptionInterface
|
||||
* @throws NotFoundExceptionInterface
|
||||
*/
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
/*
|
||||
* Calculator.php
|
||||
* Copyright (c) 2023 Antonio Spinelli https://github.com/tonicospinelli
|
||||
*
|
||||
* This file is part of Firefly III (https://github.com/firefly-iii).
|
||||
@@ -21,10 +21,13 @@ declare(strict_types=1);
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Support\Calendar;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use FireflyIII\Support\Calendar\Exceptions\IntervalException;
|
||||
use SplObjectStorage;
|
||||
|
||||
/**
|
||||
* Class Calculator
|
||||
@@ -32,62 +35,18 @@ use FireflyIII\Support\Calendar\Exceptions\IntervalException;
|
||||
class Calculator
|
||||
{
|
||||
public const DEFAULT_INTERVAL = 1;
|
||||
private static array $intervals = [];
|
||||
private static ?\SplObjectStorage $intervalMap = null;
|
||||
|
||||
/**
|
||||
* @return \SplObjectStorage
|
||||
*/
|
||||
private static function loadIntervalMap(): \SplObjectStorage
|
||||
{
|
||||
if (self::$intervalMap != null) {
|
||||
return self::$intervalMap;
|
||||
}
|
||||
self::$intervalMap = new \SplObjectStorage();
|
||||
foreach (Periodicity::cases() as $interval) {
|
||||
$periodicityClass = __NAMESPACE__ . "\\Periodicity\\{$interval->name}";
|
||||
self::$intervals[] = $interval->name;
|
||||
self::$intervalMap->attach($interval, new $periodicityClass());
|
||||
}
|
||||
return self::$intervalMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Periodicity $periodicity
|
||||
* @return bool
|
||||
*/
|
||||
private static function containsInterval(Periodicity $periodicity): bool
|
||||
{
|
||||
return self::loadIntervalMap()->contains($periodicity);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Periodicity $periodicity
|
||||
* @return bool
|
||||
*/
|
||||
public function isAvailablePeriodicity(Periodicity $periodicity): bool
|
||||
{
|
||||
return self::containsInterval($periodicity);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $skip
|
||||
* @return int
|
||||
*/
|
||||
private function skipInterval(int $skip): int
|
||||
{
|
||||
return self::DEFAULT_INTERVAL + $skip;
|
||||
}
|
||||
private static ?SplObjectStorage $intervalMap = null;
|
||||
private static array $intervals = [];
|
||||
|
||||
/**
|
||||
* @param Carbon $epoch
|
||||
* @param Periodicity $periodicity
|
||||
* @param int $skipInterval
|
||||
*
|
||||
* @return Carbon
|
||||
* @throws IntervalException
|
||||
*/
|
||||
public function nextDateByInterval(Carbon $epoch, Periodicity $periodicity, int $skipInterval = 0): Carbon
|
||||
{
|
||||
public function nextDateByInterval(Carbon $epoch, Periodicity $periodicity, int $skipInterval = 0): Carbon {
|
||||
if (!self::isAvailablePeriodicity($periodicity)) {
|
||||
throw IntervalException::unavailable($periodicity, self::$intervals);
|
||||
}
|
||||
@@ -98,4 +57,47 @@ class Calculator
|
||||
return $periodicity->nextDate($epoch->clone(), $interval);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Periodicity $periodicity
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isAvailablePeriodicity(Periodicity $periodicity): bool {
|
||||
return self::containsInterval($periodicity);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Periodicity $periodicity
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
private static function containsInterval(Periodicity $periodicity): bool {
|
||||
return self::loadIntervalMap()->contains($periodicity);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return SplObjectStorage
|
||||
*/
|
||||
private static function loadIntervalMap(): SplObjectStorage {
|
||||
if (self::$intervalMap != null) {
|
||||
return self::$intervalMap;
|
||||
}
|
||||
self::$intervalMap = new SplObjectStorage();
|
||||
foreach (Periodicity::cases() as $interval) {
|
||||
$periodicityClass = __NAMESPACE__ . "\\Periodicity\\{$interval->name}";
|
||||
self::$intervals[] = $interval->name;
|
||||
self::$intervalMap->attach($interval, new $periodicityClass());
|
||||
}
|
||||
return self::$intervalMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $skip
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
private function skipInterval(int $skip): int {
|
||||
return self::DEFAULT_INTERVAL + $skip;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
/*
|
||||
* IntervalException.php
|
||||
* Copyright (c) 2023 Antonio Spinelli https://github.com/tonicospinelli
|
||||
*
|
||||
* This file is part of Firefly III (https://github.com/firefly-iii).
|
||||
@@ -21,32 +21,36 @@ declare(strict_types=1);
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Support\Calendar\Exceptions;
|
||||
|
||||
use Exception;
|
||||
use FireflyIII\Support\Calendar\Periodicity;
|
||||
use Throwable;
|
||||
|
||||
/**
|
||||
* Class IntervalException
|
||||
*/
|
||||
final class IntervalException extends \Exception
|
||||
final class IntervalException extends Exception
|
||||
{
|
||||
protected $message = 'The periodicity %s is unknown. Choose one of available periodicity: %s';
|
||||
|
||||
public readonly array $availableIntervals;
|
||||
public readonly Periodicity $periodicity;
|
||||
public readonly array $availableIntervals;
|
||||
protected $message = 'The periodicity %s is unknown. Choose one of available periodicity: %s';
|
||||
|
||||
/**
|
||||
* @param Periodicity $periodicity
|
||||
* @param array $intervals
|
||||
* @param int $code
|
||||
* @param \Throwable|null $previous
|
||||
* @param Periodicity $periodicity
|
||||
* @param array $intervals
|
||||
* @param int $code
|
||||
* @param Throwable|null $previous
|
||||
*
|
||||
* @return IntervalException
|
||||
*/
|
||||
public static function unavailable(
|
||||
Periodicity $periodicity,
|
||||
array $intervals,
|
||||
int $code = 0,
|
||||
?\Throwable $previous = null
|
||||
?Throwable $previous = null
|
||||
): IntervalException {
|
||||
$message = sprintf(
|
||||
'The periodicity %s is unknown. Choose one of available periodicity: %s',
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
/*
|
||||
* Periodicity.php
|
||||
* Copyright (c) 2023 Antonio Spinelli <https://github.com/tonicospinelli>
|
||||
*
|
||||
* This file is part of Firefly III (https://github.com/firefly-iii).
|
||||
@@ -21,6 +21,8 @@ declare(strict_types=1);
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Support\Calendar;
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
/*
|
||||
* Bimonthly.php
|
||||
* Copyright (c) 2023 Antonio Spinelli <https://github.com/tonicospinelli>
|
||||
*
|
||||
* This file is part of Firefly III (https://github.com/firefly-iii).
|
||||
@@ -21,6 +21,8 @@ declare(strict_types=1);
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Support\Calendar\Periodicity;
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
/*
|
||||
* Daily.php
|
||||
* Copyright (c) 2023 Antonio Spinelli <https://github.com/tonicospinelli>
|
||||
*
|
||||
* This file is part of Firefly III (https://github.com/firefly-iii).
|
||||
@@ -21,6 +21,8 @@ declare(strict_types=1);
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Support\Calendar\Periodicity;
|
||||
|
||||
use Carbon\Carbon;
|
||||
@@ -32,11 +34,11 @@ final class Daily extends Interval
|
||||
{
|
||||
/**
|
||||
* @param Carbon $date
|
||||
* @param int $interval
|
||||
* @param int $interval
|
||||
*
|
||||
* @return Carbon
|
||||
*/
|
||||
public function nextDate(Carbon $date, int $interval = 1): Carbon
|
||||
{
|
||||
public function nextDate(Carbon $date, int $interval = 1): Carbon {
|
||||
return ($date->clone())->addDays($this->skip($interval));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
/*
|
||||
* Fortnightly.php
|
||||
* Copyright (c) 2023 Antonio Spinelli <https://github.com/tonicospinelli>
|
||||
*
|
||||
* This file is part of Firefly III (https://github.com/firefly-iii).
|
||||
@@ -21,6 +21,8 @@ declare(strict_types=1);
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Support\Calendar\Periodicity;
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
/*
|
||||
* HalfYearly.php
|
||||
* Copyright (c) 2023 Antonio Spinelli <https://github.com/tonicospinelli>
|
||||
*
|
||||
* This file is part of Firefly III (https://github.com/firefly-iii).
|
||||
@@ -21,6 +21,8 @@ declare(strict_types=1);
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Support\Calendar\Periodicity;
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
/*
|
||||
* Interspacable.php
|
||||
* Copyright (c) 2023 Antonio Spinelli <https://github.com/tonicospinelli>
|
||||
*
|
||||
* This file is part of Firefly III (https://github.com/firefly-iii).
|
||||
@@ -21,6 +21,8 @@ declare(strict_types=1);
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Support\Calendar\Periodicity;
|
||||
|
||||
use Carbon\Carbon;
|
||||
@@ -32,7 +34,8 @@ interface Interspacable
|
||||
{
|
||||
/**
|
||||
* @param Carbon $date
|
||||
* @param int $interval
|
||||
* @param int $interval
|
||||
*
|
||||
* @return Carbon
|
||||
*/
|
||||
public function nextDate(Carbon $date, int $interval = 1): Carbon;
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
/*
|
||||
* Interval.php
|
||||
* Copyright (c) 2023 Antonio Spinelli <https://github.com/tonicospinelli>
|
||||
*
|
||||
* This file is part of Firefly III (https://github.com/firefly-iii).
|
||||
@@ -21,6 +21,8 @@ declare(strict_types=1);
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Support\Calendar\Periodicity;
|
||||
|
||||
/**
|
||||
@@ -32,10 +34,10 @@ abstract class Interval implements Interspacable
|
||||
|
||||
/**
|
||||
* @param int $skip
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function skip(int $skip): int
|
||||
{
|
||||
public function skip(int $skip): int {
|
||||
return static::INTERVAL * $skip;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
/*
|
||||
* Monthly.php
|
||||
* Copyright (c) 2023 Antonio Spinelli <https://github.com/tonicospinelli>
|
||||
*
|
||||
* This file is part of Firefly III (https://github.com/firefly-iii).
|
||||
@@ -21,6 +21,8 @@ declare(strict_types=1);
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Support\Calendar\Periodicity;
|
||||
|
||||
use Carbon\Carbon;
|
||||
@@ -32,11 +34,11 @@ class Monthly extends Interval
|
||||
{
|
||||
/**
|
||||
* @param Carbon $date
|
||||
* @param int $interval
|
||||
* @param int $interval
|
||||
*
|
||||
* @return Carbon
|
||||
*/
|
||||
public function nextDate(Carbon $date, int $interval = 1): Carbon
|
||||
{
|
||||
public function nextDate(Carbon $date, int $interval = 1): Carbon {
|
||||
return ($date->clone())->addMonthsNoOverflow($this->skip($interval));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
/*
|
||||
* Quarterly.php
|
||||
* Copyright (c) 2023 Antonio Spinelli <https://github.com/tonicospinelli>
|
||||
*
|
||||
* This file is part of Firefly III (https://github.com/firefly-iii).
|
||||
@@ -21,6 +21,8 @@ declare(strict_types=1);
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Support\Calendar\Periodicity;
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
/*
|
||||
* Weekly.php
|
||||
* Copyright (c) 2023 Antonio Spinelli <https://github.com/tonicospinelli>
|
||||
*
|
||||
* This file is part of Firefly III (https://github.com/firefly-iii).
|
||||
@@ -21,6 +21,8 @@ declare(strict_types=1);
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Support\Calendar\Periodicity;
|
||||
|
||||
use Carbon\Carbon;
|
||||
@@ -32,11 +34,11 @@ class Weekly extends Interval
|
||||
{
|
||||
/**
|
||||
* @param Carbon $date
|
||||
* @param int $interval
|
||||
* @param int $interval
|
||||
*
|
||||
* @return Carbon
|
||||
*/
|
||||
public function nextDate(Carbon $date, int $interval = 1): Carbon
|
||||
{
|
||||
public function nextDate(Carbon $date, int $interval = 1): Carbon {
|
||||
return ($date->clone())->addWeeks($this->skip($interval));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
/*
|
||||
* Yearly.php
|
||||
* Copyright (c) 2023 Antonio Spinelli <https://github.com/tonicospinelli>
|
||||
*
|
||||
* This file is part of Firefly III (https://github.com/firefly-iii).
|
||||
@@ -21,6 +21,8 @@ declare(strict_types=1);
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Support\Calendar\Periodicity;
|
||||
|
||||
use Carbon\Carbon;
|
||||
@@ -32,11 +34,11 @@ final class Yearly extends Interval
|
||||
{
|
||||
/**
|
||||
* @param Carbon $date
|
||||
* @param int $interval
|
||||
* @param int $interval
|
||||
*
|
||||
* @return Carbon
|
||||
*/
|
||||
public function nextDate(Carbon $date, int $interval = 1): Carbon
|
||||
{
|
||||
public function nextDate(Carbon $date, int $interval = 1): Carbon {
|
||||
return ($date->clone())->addYearsNoOverflow($this->skip($interval));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -66,6 +66,7 @@ class AccountForm
|
||||
/**
|
||||
* @param array $types
|
||||
* @param AccountRepositoryInterface|null $repository
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
private function getAccountsGrouped(array $types, AccountRepositoryInterface $repository = null): array
|
||||
|
||||
@@ -39,6 +39,7 @@ trait ConvertsExchangeRates
|
||||
|
||||
/**
|
||||
* @param array $set
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function cerChartSet(array $set): array
|
||||
@@ -84,6 +85,7 @@ trait ConvertsExchangeRates
|
||||
|
||||
/**
|
||||
* @param int $currencyId
|
||||
*
|
||||
* @return TransactionCurrency
|
||||
*/
|
||||
private function getCurrency(int $currencyId): TransactionCurrency
|
||||
@@ -99,6 +101,7 @@ trait ConvertsExchangeRates
|
||||
* @param TransactionCurrency $from
|
||||
* @param TransactionCurrency $to
|
||||
* @param Carbon $date
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function getRate(TransactionCurrency $from, TransactionCurrency $to, Carbon $date): string
|
||||
@@ -154,6 +157,7 @@ trait ConvertsExchangeRates
|
||||
/**
|
||||
* @param TransactionCurrency $currency
|
||||
* @param Carbon $date
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function getEuroRate(TransactionCurrency $currency, Carbon $date): string
|
||||
@@ -203,6 +207,7 @@ trait ConvertsExchangeRates
|
||||
* the user.
|
||||
*
|
||||
* @param array $entries
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function cerSum(array $entries): array
|
||||
@@ -254,10 +259,11 @@ trait ConvertsExchangeRates
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $amount
|
||||
* @param string $amount
|
||||
* @param TransactionCurrency $from
|
||||
* @param TransactionCurrency $to
|
||||
* @param Carbon|null $date
|
||||
* @param Carbon|null $date
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function convertAmount(string $amount, TransactionCurrency $from, TransactionCurrency $to, ?Carbon $date = null): string
|
||||
|
||||
@@ -32,6 +32,7 @@ use FireflyIII\Support\Calendar\Periodicity;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Psr\Container\ContainerExceptionInterface;
|
||||
use Psr\Container\NotFoundExceptionInterface;
|
||||
use Throwable;
|
||||
|
||||
/**
|
||||
* Class Navigation.
|
||||
@@ -48,30 +49,6 @@ class Navigation
|
||||
$this->calculator = ($calculator instanceof Calculator) ?: new Calculator();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Carbon $epoch
|
||||
* @param Periodicity $periodicity
|
||||
* @param int $skipInterval
|
||||
* @return Carbon
|
||||
*/
|
||||
public function nextDateByInterval(Carbon $epoch, Periodicity $periodicity, int $skipInterval = 0): Carbon
|
||||
{
|
||||
try {
|
||||
return $this->calculator->nextDateByInterval($epoch, $periodicity, $skipInterval);
|
||||
} catch (IntervalException $exception) {
|
||||
Log::warning($exception->getMessage(), ['exception' => $exception]);
|
||||
} catch (\Throwable $exception) {
|
||||
Log::error($exception->getMessage(), ['exception' => $exception]);
|
||||
}
|
||||
|
||||
Log::debug(
|
||||
"Any error occurred to calculate the next date.",
|
||||
['date' => $epoch, 'periodicity' => $periodicity->name, 'skipInterval' => $skipInterval]
|
||||
);
|
||||
|
||||
return $epoch;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Carbon $theDate
|
||||
* @param string $repeatFreq
|
||||
@@ -122,6 +99,31 @@ class Navigation
|
||||
return $this->nextDateByInterval($theDate, $functionMap[$repeatFreq], $skip);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Carbon $epoch
|
||||
* @param Periodicity $periodicity
|
||||
* @param int $skipInterval
|
||||
*
|
||||
* @return Carbon
|
||||
*/
|
||||
public function nextDateByInterval(Carbon $epoch, Periodicity $periodicity, int $skipInterval = 0): Carbon
|
||||
{
|
||||
try {
|
||||
return $this->calculator->nextDateByInterval($epoch, $periodicity, $skipInterval);
|
||||
} catch (IntervalException $exception) {
|
||||
Log::warning($exception->getMessage(), ['exception' => $exception]);
|
||||
} catch (Throwable $exception) {
|
||||
Log::error($exception->getMessage(), ['exception' => $exception]);
|
||||
}
|
||||
|
||||
Log::debug(
|
||||
'Any error occurred to calculate the next date.',
|
||||
['date' => $epoch, 'periodicity' => $periodicity->name, 'skipInterval' => $skipInterval]
|
||||
);
|
||||
|
||||
return $epoch;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
@@ -223,14 +225,14 @@ class Navigation
|
||||
}
|
||||
|
||||
$result = match ($repeatFreq) {
|
||||
'last7' => $date->subDays(7)->startOfDay(),
|
||||
'last30' => $date->subDays(30)->startOfDay(),
|
||||
'last90' => $date->subDays(90)->startOfDay(),
|
||||
'last7' => $date->subDays(7)->startOfDay(),
|
||||
'last30' => $date->subDays(30)->startOfDay(),
|
||||
'last90' => $date->subDays(90)->startOfDay(),
|
||||
'last365' => $date->subDays(365)->startOfDay(),
|
||||
'MTD' => $date->startOfMonth()->startOfDay(),
|
||||
'QTD' => $date->firstOfQuarter()->startOfDay(),
|
||||
'YTD' => $date->startOfYear()->startOfDay(),
|
||||
default => null,
|
||||
'MTD' => $date->startOfMonth()->startOfDay(),
|
||||
'QTD' => $date->firstOfQuarter()->startOfDay(),
|
||||
'YTD' => $date->startOfYear()->startOfDay(),
|
||||
default => null,
|
||||
};
|
||||
if (null !== $result) {
|
||||
return $result;
|
||||
@@ -300,14 +302,14 @@ class Navigation
|
||||
}
|
||||
|
||||
$result = match ($repeatFreq) {
|
||||
'last7' => $currentEnd->addDays(7)->startOfDay(),
|
||||
'last30' => $currentEnd->addDays(30)->startOfDay(),
|
||||
'last90' => $currentEnd->addDays(90)->startOfDay(),
|
||||
'last7' => $currentEnd->addDays(7)->startOfDay(),
|
||||
'last30' => $currentEnd->addDays(30)->startOfDay(),
|
||||
'last90' => $currentEnd->addDays(90)->startOfDay(),
|
||||
'last365' => $currentEnd->addDays(365)->startOfDay(),
|
||||
'MTD' => $currentEnd->startOfMonth()->startOfDay(),
|
||||
'QTD' => $currentEnd->firstOfQuarter()->startOfDay(),
|
||||
'YTD' => $currentEnd->startOfYear()->startOfDay(),
|
||||
default => null,
|
||||
'MTD' => $currentEnd->startOfMonth()->startOfDay(),
|
||||
'QTD' => $currentEnd->firstOfQuarter()->startOfDay(),
|
||||
'YTD' => $currentEnd->startOfYear()->startOfDay(),
|
||||
default => null,
|
||||
};
|
||||
if (null !== $result) {
|
||||
return $result;
|
||||
@@ -385,6 +387,7 @@ class Navigation
|
||||
* range to a normal range.
|
||||
*
|
||||
* @param bool $correct
|
||||
*
|
||||
* @return string
|
||||
* @throws ContainerExceptionInterface
|
||||
* @throws NotFoundExceptionInterface
|
||||
|
||||
@@ -131,17 +131,17 @@ class ParseDateString
|
||||
$today = today(config('app.timezone'))->startOfDay();
|
||||
|
||||
return match ($keyword) {
|
||||
default => $today,
|
||||
'yesterday' => $today->subDay(),
|
||||
'tomorrow' => $today->addDay(),
|
||||
'start of this week' => $today->startOfWeek(),
|
||||
'end of this week' => $today->endOfWeek(),
|
||||
'start of this month' => $today->startOfMonth(),
|
||||
'end of this month' => $today->endOfMonth(),
|
||||
default => $today,
|
||||
'yesterday' => $today->subDay(),
|
||||
'tomorrow' => $today->addDay(),
|
||||
'start of this week' => $today->startOfWeek(),
|
||||
'end of this week' => $today->endOfWeek(),
|
||||
'start of this month' => $today->startOfMonth(),
|
||||
'end of this month' => $today->endOfMonth(),
|
||||
'start of this quarter' => $today->startOfQuarter(),
|
||||
'end of this quarter' => $today->endOfQuarter(),
|
||||
'start of this year' => $today->startOfYear(),
|
||||
'end of this year' => $today->endOfYear(),
|
||||
'end of this quarter' => $today->endOfQuarter(),
|
||||
'start of this year' => $today->startOfYear(),
|
||||
'end of this year' => $today->endOfYear(),
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -363,6 +363,7 @@ class BudgetReportGenerator
|
||||
|
||||
/**
|
||||
* @param User $user
|
||||
*
|
||||
* @throws FireflyException
|
||||
* @throws JsonException
|
||||
*/
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/*
|
||||
* AdministrationTrait.php
|
||||
* Copyright (c) 2023 james@firefly-iii.org
|
||||
@@ -21,6 +21,8 @@ declare(strict_types=1);
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Support\Repositories\Administration;
|
||||
|
||||
use FireflyIII\Exceptions\FireflyException;
|
||||
@@ -41,17 +43,16 @@ trait AdministrationTrait
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getAdministrationId(): int
|
||||
{
|
||||
public function getAdministrationId(): int {
|
||||
return $this->administrationId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $administrationId
|
||||
*
|
||||
* @throws FireflyException
|
||||
*/
|
||||
public function setAdministrationId(int $administrationId): void
|
||||
{
|
||||
public function setAdministrationId(int $administrationId): void {
|
||||
$this->administrationId = $administrationId;
|
||||
$this->refreshAdministration();
|
||||
}
|
||||
@@ -60,8 +61,7 @@ trait AdministrationTrait
|
||||
* @return void
|
||||
* @throws FireflyException
|
||||
*/
|
||||
private function refreshAdministration(): void
|
||||
{
|
||||
private function refreshAdministration(): void {
|
||||
if (null !== $this->administrationId) {
|
||||
$memberships = GroupMembership::where('user_id', $this->user->id)
|
||||
->where('user_group_id', $this->administrationId)
|
||||
@@ -77,10 +77,10 @@ trait AdministrationTrait
|
||||
|
||||
/**
|
||||
* @param Authenticatable|User|null $user
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setUser(Authenticatable | User | null $user): void
|
||||
{
|
||||
public function setUser(Authenticatable | User | null $user): void {
|
||||
if (null !== $user) {
|
||||
$this->user = $user;
|
||||
}
|
||||
|
||||
@@ -51,6 +51,7 @@ trait ConvertsDataTypes
|
||||
*
|
||||
* @param string $key
|
||||
* @param mixed|null $default
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
abstract public function get(string $key, mixed $default = null): mixed;
|
||||
@@ -212,6 +213,7 @@ trait ConvertsDataTypes
|
||||
|
||||
/**
|
||||
* @param string|null $string
|
||||
*
|
||||
* @return Carbon|null
|
||||
*/
|
||||
protected function convertDateTime(?string $string): ?Carbon
|
||||
@@ -324,6 +326,7 @@ trait ConvertsDataTypes
|
||||
* trait, OR a stub needs to be added by any other class that uses this train.
|
||||
*
|
||||
* @param mixed $key
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
abstract public function has($key);
|
||||
|
||||
@@ -134,6 +134,7 @@ class AccountSearch implements GenericSearchInterface
|
||||
|
||||
/**
|
||||
* @param User|Authenticatable|null $user
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setUser(User | Authenticatable | null $user): void
|
||||
|
||||
@@ -339,6 +339,7 @@ class Steam
|
||||
*
|
||||
* @param null|string $number
|
||||
* @param int $precision
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function bcround(?string $number, int $precision = 0): string
|
||||
@@ -430,6 +431,7 @@ class Steam
|
||||
|
||||
/**
|
||||
* @param string $ipAddress
|
||||
*
|
||||
* @return string
|
||||
* @throws FireflyException
|
||||
*/
|
||||
@@ -591,6 +593,7 @@ class Steam
|
||||
* Additionally fixed a problem with PHP <= 5.2.x with big integers
|
||||
*
|
||||
* @param string $value
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function floatalize(string $value): string
|
||||
|
||||
Reference in New Issue
Block a user