mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-12 15:35:15 +00:00
Fix various code.
This commit is contained in:
@@ -215,7 +215,6 @@ class AccountBalanceGrouped
|
||||
|
||||
private function getDataKey(array $journal): string
|
||||
{
|
||||
$key = 'spent';
|
||||
// deposit = incoming
|
||||
// transfer or reconcile or opening balance, and these accounts are the destination.
|
||||
if (
|
||||
@@ -230,10 +229,10 @@ class AccountBalanceGrouped
|
||||
&& in_array($journal['destination_account_id'], $this->accountIds, true)
|
||||
)
|
||||
) {
|
||||
$key = 'earned';
|
||||
return 'earned';
|
||||
}
|
||||
|
||||
return $key;
|
||||
return 'spent';
|
||||
}
|
||||
|
||||
private function getRate(TransactionCurrency $currency, Carbon $date): string
|
||||
|
@@ -33,6 +33,8 @@ use Illuminate\Support\Facades\Log;
|
||||
use Laravel\Passport\Passport;
|
||||
use phpseclib3\Crypt\RSA;
|
||||
|
||||
use function Safe\file_put_contents;
|
||||
|
||||
/**
|
||||
* Trait CreateStuff
|
||||
*/
|
||||
@@ -106,8 +108,8 @@ trait CreateStuff
|
||||
|
||||
Log::alert('NO OAuth keys were found. They have been created.');
|
||||
|
||||
\Safe\file_put_contents($publicKey, (string) $key->getPublicKey());
|
||||
\Safe\file_put_contents($privateKey, $key->toString('PKCS1'));
|
||||
file_put_contents($publicKey, (string) $key->getPublicKey());
|
||||
file_put_contents($privateKey, $key->toString('PKCS1'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -77,7 +77,7 @@ trait DateCalculation
|
||||
$step = '1M';
|
||||
}
|
||||
if ($months > 100) {
|
||||
$step = '1Y';
|
||||
return '1Y';
|
||||
}
|
||||
|
||||
return $step;
|
||||
|
@@ -207,7 +207,7 @@ trait GetConfigurationData
|
||||
{
|
||||
$config = app('fireflyconfig')->get('last_rt_job', 0);
|
||||
$lastTime = (int) $config?->data;
|
||||
$now = time();
|
||||
$now = Carbon::now()->getTimestamp();
|
||||
app('log')->debug(sprintf('verifyRecurringCronJob: last time is %d ("%s"), now is %d', $lastTime, $config?->data, $now));
|
||||
if (0 === $lastTime) {
|
||||
request()->session()->flash('info', trans('firefly.recurring_never_cron'));
|
||||
|
@@ -36,6 +36,8 @@ use Illuminate\Support\Facades\Validator;
|
||||
use Illuminate\Support\Facades\Route as RouteFacade;
|
||||
use Hash;
|
||||
|
||||
use function Safe\parse_url;
|
||||
|
||||
/**
|
||||
* Trait RequestInformation
|
||||
*/
|
||||
@@ -47,7 +49,7 @@ trait RequestInformation
|
||||
final protected function getDomain(): string // get request info
|
||||
{
|
||||
$url = url()->to('/');
|
||||
$parts = \Safe\parse_url($url);
|
||||
$parts = parse_url($url);
|
||||
|
||||
return $parts['host'] ?? '';
|
||||
}
|
||||
@@ -95,7 +97,7 @@ trait RequestInformation
|
||||
$shownDemo = app('preferences')->get($key, false)->data;
|
||||
}
|
||||
if (!is_bool($shownDemo)) {
|
||||
$shownDemo = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
return $shownDemo;
|
||||
@@ -123,20 +125,19 @@ trait RequestInformation
|
||||
final protected function notInSessionRange(Carbon $date): bool // Validate a preference
|
||||
{
|
||||
/** @var Carbon $start */
|
||||
$start = session('start', today(config('app.timezone'))->startOfMonth());
|
||||
$start = session('start', today(config('app.timezone'))->startOfMonth());
|
||||
|
||||
/** @var Carbon $end */
|
||||
$end = session('end', today(config('app.timezone'))->endOfMonth());
|
||||
$result = false;
|
||||
$end = session('end', today(config('app.timezone'))->endOfMonth());
|
||||
if ($start->greaterThanOrEqualTo($date) && $end->greaterThanOrEqualTo($date)) {
|
||||
$result = true;
|
||||
return true;
|
||||
}
|
||||
// start and end in the past? use $end
|
||||
if ($start->lessThanOrEqualTo($date) && $end->lessThanOrEqualTo($date)) {
|
||||
$result = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
return $result;
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -147,14 +148,14 @@ trait RequestInformation
|
||||
$attributes['location'] ??= '';
|
||||
$attributes['accounts'] = AccountList::routeBinder($attributes['accounts'] ?? '', new Route('get', '', []));
|
||||
$date = Carbon::createFromFormat('Ymd', $attributes['startDate']);
|
||||
if (null === $date) {
|
||||
if (!$date instanceof Carbon) {
|
||||
$date = today(config('app.timezone'));
|
||||
}
|
||||
$date->startOfMonth();
|
||||
$attributes['startDate'] = $date;
|
||||
|
||||
$date2 = Carbon::createFromFormat('Ymd', $attributes['endDate']);
|
||||
if (null === $date2) {
|
||||
if (!$date2 instanceof Carbon) {
|
||||
$date2 = today(config('app.timezone'));
|
||||
}
|
||||
$date2->endOfDay();
|
||||
|
Reference in New Issue
Block a user