Compare commits

...

27 Commits

Author SHA1 Message Date
github-actions
86b4965458 Auto commit for release 'develop' on 2024-04-03 2024-04-03 05:19:06 +02:00
James Cole
d2dc0c2bf0 Merge branch 'main' into develop 2024-04-03 05:12:51 +02:00
James Cole
9f4894bbb5 Fix https://github.com/firefly-iii/firefly-iii/issues/8748 2024-04-03 05:12:28 +02:00
James Cole
76a8675a34 make sure boxes are empty 2024-04-02 18:04:42 +02:00
James Cole
6988301da1 Merge pull request #8746 from imlonghao/patch-1
Set date to now when cloning journal
2024-04-02 18:03:52 +02:00
imlonghao
109cd37211 Set date to now when cloning journal
Signed-off-by: imlonghao <git@imlonghao.com>
2024-04-02 23:44:45 +08:00
James Cole
284ff4d1b0 Merge branch 'main' into develop 2024-04-02 16:53:31 +02:00
James Cole
bc0ab7af99 Spelling error in nightly release instructions 2024-04-02 16:53:18 +02:00
James Cole
a17bc7258f Fix phpstan error courtesy of the laravel 11 upgrade (changed signatures and return types) 2024-04-02 15:40:33 +02:00
James Cole
87911c2438 Catch empty preference, just in case. 2024-04-02 12:38:31 +02:00
github-actions
746f1fd300 Auto commit for release 'develop' on 2024-04-02 2024-04-02 07:47:24 +02:00
James Cole
9e5faf919f Add space 2024-04-02 07:40:40 +02:00
James Cole
cc6cbe6605 Add something to changelog before I forget. 2024-04-02 07:01:13 +02:00
James Cole
dc6d708897 Replace frontpageAccounts variable name. 2024-04-02 06:59:40 +02:00
James Cole
6189d24b98 Replace variable names. 2024-04-01 20:26:02 +02:00
James Cole
f6e28dc88f Fine tune preferences to handle multi-administration options. 2024-04-01 19:59:21 +02:00
James Cole
75ea035630 Preferences can be administration specific. Not yet really working. 2024-04-01 18:18:48 +02:00
James Cole
4cdb14301d Add administration specific thing to preferences. 2024-04-01 18:03:43 +02:00
James Cole
9f95221ba3 Various code cleanup. 2024-04-01 17:43:31 +02:00
James Cole
e3a67be412 Clear user groups when loading 2024-04-01 16:07:14 +02:00
James Cole
5749b642ce Wrong response code. 2024-04-01 16:07:03 +02:00
James Cole
baff7c67f9 Expand user group views and translations 2024-04-01 15:41:16 +02:00
James Cole
ccc005942f Expand user group pages. 2024-04-01 15:40:53 +02:00
James Cole
5b83c33039 Turns out it's pointless to add "default_administration", you can force that already through the owner role (which is already in place). 2024-04-01 14:15:35 +02:00
James Cole
cc32578c5f Add new strings. 2024-04-01 14:04:36 +02:00
James Cole
80f410835b Expand models, user groups need more properties. 2024-04-01 14:04:22 +02:00
James Cole
b537a3145d Expand financial administrations views. 2024-04-01 14:01:52 +02:00
192 changed files with 1488 additions and 499 deletions

View File

@@ -1,5 +1,5 @@
{
"require": {
"friendsofphp/php-cs-fixer": "^3.12"
}
"require": {
"friendsofphp/php-cs-fixer": "^3.12"
}
}

View File

@@ -9,16 +9,16 @@
"packages-dev": [
{
"name": "composer/pcre",
"version": "3.1.2",
"version": "3.1.3",
"source": {
"type": "git",
"url": "https://github.com/composer/pcre.git",
"reference": "4775f35b2d70865807c89d32c8e7385b86eb0ace"
"reference": "5b16e25a5355f1f3afdfc2f954a0a80aec4826a8"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/composer/pcre/zipball/4775f35b2d70865807c89d32c8e7385b86eb0ace",
"reference": "4775f35b2d70865807c89d32c8e7385b86eb0ace",
"url": "https://api.github.com/repos/composer/pcre/zipball/5b16e25a5355f1f3afdfc2f954a0a80aec4826a8",
"reference": "5b16e25a5355f1f3afdfc2f954a0a80aec4826a8",
"shasum": ""
},
"require": {
@@ -60,7 +60,7 @@
],
"support": {
"issues": "https://github.com/composer/pcre/issues",
"source": "https://github.com/composer/pcre/tree/3.1.2"
"source": "https://github.com/composer/pcre/tree/3.1.3"
},
"funding": [
{
@@ -76,20 +76,20 @@
"type": "tidelift"
}
],
"time": "2024-03-07T15:38:35+00:00"
"time": "2024-03-19T10:26:25+00:00"
},
{
"name": "composer/xdebug-handler",
"version": "3.0.3",
"version": "3.0.4",
"source": {
"type": "git",
"url": "https://github.com/composer/xdebug-handler.git",
"reference": "ced299686f41dce890debac69273b47ffe98a40c"
"reference": "4f988f8fdf580d53bdb2d1278fe93d1ed5462255"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/composer/xdebug-handler/zipball/ced299686f41dce890debac69273b47ffe98a40c",
"reference": "ced299686f41dce890debac69273b47ffe98a40c",
"url": "https://api.github.com/repos/composer/xdebug-handler/zipball/4f988f8fdf580d53bdb2d1278fe93d1ed5462255",
"reference": "4f988f8fdf580d53bdb2d1278fe93d1ed5462255",
"shasum": ""
},
"require": {
@@ -100,7 +100,7 @@
"require-dev": {
"phpstan/phpstan": "^1.0",
"phpstan/phpstan-strict-rules": "^1.1",
"symfony/phpunit-bridge": "^6.0"
"phpunit/phpunit": "^8.5 || ^9.6 || ^10.5"
},
"type": "library",
"autoload": {
@@ -124,9 +124,9 @@
"performance"
],
"support": {
"irc": "irc://irc.freenode.org/composer",
"irc": "ircs://irc.libera.chat:6697/composer",
"issues": "https://github.com/composer/xdebug-handler/issues",
"source": "https://github.com/composer/xdebug-handler/tree/3.0.3"
"source": "https://github.com/composer/xdebug-handler/tree/3.0.4"
},
"funding": [
{
@@ -142,7 +142,7 @@
"type": "tidelift"
}
],
"time": "2022-02-25T21:32:43+00:00"
"time": "2024-03-26T18:29:49+00:00"
},
{
"name": "pdepend/pdepend",

View File

@@ -19,9 +19,9 @@
~ along with this program. If not, see <https://www.gnu.org/licenses/>.
-->
<ruleset name="pcsg-generated-ruleset"
<ruleset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
name="pcsg-generated-ruleset"
xmlns="http://pmd.sf.net/ruleset/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://pmd.sf.net/ruleset/1.0.0 http://pmd.sf.net/ruleset_xml_schema.xsd"
xsi:noNamespaceSchemaLocation="http://pmd.sf.net/ruleset_xml_schema.xsd">
<description>Firefly III ruleset.</description>

View File

@@ -3,7 +3,7 @@ name: "Issues - Command to close duplicate issues"
# the workflow to execute on is comments that are newly created
on:
issue_comment:
types: [created]
types: [ created ]
permissions:
issues: write

View File

@@ -3,9 +3,9 @@ name: 'Issues - Respond to hidden commands'
# the workflow to execute on is comments that are newly created
on:
issues:
types: [opened, edited]
types: [ opened, edited ]
issue_comment:
types: [created]
types: [ created ]
# permissions needed for reacting to IssueOps commands on issues and PRs
permissions:

View File

@@ -2,11 +2,11 @@ name: 'Issues - Reply to specific labels'
on:
issues:
types: [labeled, unlabeled]
types: [ labeled, unlabeled ]
pull_request_target:
types: [labeled, unlabeled]
types: [ labeled, unlabeled ]
discussion:
types: [labeled, unlabeled]
types: [ labeled, unlabeled ]
permissions:
contents: read

View File

@@ -8,7 +8,7 @@ on:
required: true
default: 'develop'
schedule:
- cron: '0 3 * * MON,THU'
- cron: '0 3 * * MON,THU'
jobs:
build:
@@ -192,7 +192,7 @@ jobs:
echo 'Zip and tar...'
zip -rq $zipName . -x "*.git*" "*.ci*" "*.github*" "*node_modules*" "*output.txt*"
touch $tarName
tar --exclude=$tarName --exclude='./.git' --exclude='./.ci' --exclude='./.github' --exclude='./node_modules' --exclude='./output.txt' -czf $tarName .
tar --exclude=$tarName --exclude=$zipName --exclude='./.git' --exclude='./.ci' --exclude='./.github' --exclude='./node_modules' --exclude='./output.txt' -czf $tarName .
# add sha256 sum
echo 'Sha sum ...'
@@ -211,7 +211,7 @@ jobs:
echo "* Please read the installation instructions for [Docker](https://docs.firefly-iii.org/how-to/firefly-iii/installation/docker/), [Portainer](https://docs.firefly-iii.org/how-to/firefly-iii/installation/portainer/), [Kubernetes](https://docs.firefly-iii.org/how-to/firefly-iii/installation/kubernetes/) or [self-managed servers](https://docs.firefly-iii.org/how-to/firefly-iii/installation/self-managed/)" >> output.txt
echo "* Or read the upgrade instructions for [Docker](https://docs.firefly-iii.org/how-to/firefly-iii/upgrade/docker/), [Kubernetes](https://docs.firefly-iii.org/how-to/firefly-iii/upgrade/kubernetes/) or [self-managed servers](https://docs.firefly-iii.org/how-to/firefly-iii/upgrade/self-managed/)" >> output.txt
echo "" >> output.txt
echo ":warning: Please be careful with this pre-release, as is may not work as expected." >> output.txt
echo ":warning: Please be careful with this pre-release, as it may not work as expected." >> output.txt
# create the release:
echo "Create nightly release."

View File

@@ -83,17 +83,17 @@ class AccountController extends Controller
// user's preferences
$defaultSet = $this->repository->getAccountsByType([AccountType::ASSET])->pluck('id')->toArray();
/** @var Preference $frontPage */
$frontPage = app('preferences')->get('frontPageAccounts', $defaultSet);
/** @var Preference $frontpage */
$frontpage = app('preferences')->get('frontpageAccounts', $defaultSet);
$default = app('amount')->getDefaultCurrency();
if (!(is_array($frontPage->data) && count($frontPage->data) > 0)) {
$frontPage->data = $defaultSet;
$frontPage->save();
if (!(is_array($frontpage->data) && count($frontpage->data) > 0)) {
$frontpage->data = $defaultSet;
$frontpage->save();
}
// get accounts:
$accounts = $this->repository->getAccountsById($frontPage->data);
$accounts = $this->repository->getAccountsById($frontpage->data);
$chartData = [];
/** @var Account $account */

View File

@@ -54,17 +54,13 @@ class TestRequest extends FormRequest
private function getDate(string $field): ?Carbon
{
$value = $this->query($field);
$value = $this->query($field);
if (is_array($value)) {
return null;
}
$value = (string)$value;
$result = null === $this->query($field) ? null : Carbon::createFromFormat('Y-m-d', substr($value, 0, 10));
if (false === $result) {
return null;
}
$value = (string)$value;
return $result;
return null === $this->query($field) ? null : Carbon::createFromFormat('Y-m-d', substr($value, 0, 10));
}
private function getAccounts(): array

View File

@@ -48,17 +48,13 @@ class TriggerRequest extends FormRequest
private function getDate(string $field): ?Carbon
{
$value = $this->query($field);
$value = $this->query($field);
if (is_array($value)) {
return null;
}
$value = (string)$value;
$result = null === $this->query($field) ? null : Carbon::createFromFormat('Y-m-d', substr($value, 0, 10));
if (false === $result) {
return null;
}
$value = (string)$value;
return $result;
return null === $this->query($field) ? null : Carbon::createFromFormat('Y-m-d', substr($value, 0, 10));
}
private function getAccounts(): array

View File

@@ -48,17 +48,13 @@ class TestRequest extends FormRequest
private function getDate(string $field): ?Carbon
{
$value = $this->query($field);
$value = $this->query($field);
if (is_array($value)) {
return null;
}
$value = (string)$value;
$result = null === $this->query($field) ? null : Carbon::createFromFormat('Y-m-d', substr($value, 0, 10));
if (false === $result) {
return null;
}
$value = (string)$value;
return $result;
return null === $this->query($field) ? null : Carbon::createFromFormat('Y-m-d', substr($value, 0, 10));
}
private function getAccounts(): array

View File

@@ -48,17 +48,13 @@ class TriggerRequest extends FormRequest
private function getDate(string $field): ?Carbon
{
$value = $this->query($field);
$value = $this->query($field);
if (is_array($value)) {
return null;
}
$value = (string)$value;
$result = null === $this->query($field) ? null : Carbon::createFromFormat('Y-m-d', substr($value, 0, 10));
if (false === $result) {
return null;
}
$value = (string)$value;
return $result;
return null === $this->query($field) ? null : Carbon::createFromFormat('Y-m-d', substr($value, 0, 10));
}
private function getAccounts(): array

View File

@@ -98,14 +98,14 @@ class AccountController extends Controller
// user's preferences
if (0 === $accounts->count()) {
$defaultSet = $this->repository->getAccountsByType([AccountType::ASSET, AccountType::DEFAULT])->pluck('id')->toArray();
$frontPage = app('preferences')->get('frontPageAccounts', $defaultSet);
$frontpage = app('preferences')->get('frontpageAccounts', $defaultSet);
if (!(is_array($frontPage->data) && count($frontPage->data) > 0)) {
$frontPage->data = $defaultSet;
$frontPage->save();
if (!(is_array($frontpage->data) && count($frontpage->data) > 0)) {
$frontpage->data = $defaultSet;
$frontpage->save();
}
$accounts = $this->repository->getAccountsById($frontPage->data);
$accounts = $this->repository->getAccountsById($frontpage->data);
}
// both options are overruled by "preselected"

View File

@@ -298,7 +298,7 @@ class BasicController extends Controller
app('log')->debug(sprintf('Amount left is %s', $left));
// how much left per day?
$days = (int) $today->diffInDays($end, true) + 1;
$days = (int)$today->diffInDays($end, true) + 1;
$perDay = '0';
$perDayNative = '0';
if (0 !== $days && bccomp($left, '0') > -1) {

View File

@@ -79,4 +79,12 @@ class UpdateController extends Controller
->header('Content-Type', self::CONTENT_TYPE)
;
}
public function useUserGroup(UserGroup $userGroup): JsonResponse
{
// group validation is already in place, so can just update the user.
$this->repository->useUserGroup($userGroup);
return response()->json([], 204);
}
}

View File

@@ -26,6 +26,7 @@ namespace FireflyIII\Api\V2\Request\UserGroup;
use FireflyIII\Enums\UserRoleEnum;
use FireflyIII\Models\UserGroup;
use FireflyIII\Rules\IsDefaultUserGroupName;
use FireflyIII\Support\Request\ChecksLogin;
use FireflyIII\Support\Request\ConvertsDataTypes;
use Illuminate\Foundation\Http\FormRequest;
@@ -53,7 +54,7 @@ class UpdateRequest extends FormRequest
$userGroup = $this->route()->parameter('userGroup');
return [
'title' => sprintf('required|min:1|max:255|unique:user_groups,title,%d', $userGroup->id),
'title' => ['required', 'min:1', 'max:255', sprintf('unique:user_groups,title,%d', $userGroup->id), new IsDefaultUserGroupName($userGroup)],
];
}
}

View File

@@ -73,6 +73,7 @@ class CorrectDatabase extends Command
// new!
'firefly-iii:unify-group-accounts',
'firefly-iii:trigger-credit-recalculation',
'firefly-iii:migrate-preferences',
];
foreach ($commands as $command) {
$this->friendlyLine(sprintf('Now executing command "%s"', $command));

View File

@@ -50,7 +50,7 @@ class FixFrontpageAccounts extends Command
/** @var User $user */
foreach ($users as $user) {
$preference = app('preferences')->getForUser($user, 'frontPageAccounts');
$preference = app('preferences')->getForUser($user, 'frontpageAccounts');
if (null !== $preference) {
$this->fixPreference($preference);
}
@@ -83,6 +83,6 @@ class FixFrontpageAccounts extends Command
}
}
}
app('preferences')->setForUser($preference->user, 'frontPageAccounts', $fixed);
app('preferences')->setForUser($preference->user, 'frontpageAccounts', $fixed);
}
}

View File

@@ -0,0 +1,66 @@
<?php
declare(strict_types=1);
/*
* MigratePreferences.php
* Copyright (c) 2024 james@firefly-iii.org.
*
* This file is part of Firefly III (https://github.com/firefly-iii).
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see https://www.gnu.org/licenses/.
*/
namespace FireflyIII\Console\Commands\Correction;
use FireflyIII\Models\Preference;
use FireflyIII\User;
use Illuminate\Console\Command;
use Symfony\Component\Console\Command\Command as CommandAlias;
class MigratePreferences extends Command
{
protected $description = 'Give Firefly III preferences a user group ID so they can be made administration specific.';
protected $signature = 'firefly-iii:migrate-preferences';
/**
* Execute the console command.
*/
public function handle(): int
{
$items = config('firefly.admin_specific_prefs');
$users = User::get();
/** @var User $user */
foreach ($users as $user) {
$count = 0;
foreach ($items as $item) {
$preference = Preference::where('name', $item)->where('user_id', $user->id)->first();
if (null === $preference) {
continue;
}
if (null !== $preference->user_group_id) {
$preference->user_group_id = $user->user_group_id;
$preference->save();
++$count;
}
}
if ($count > 0) {
$this->info(sprintf('Migrated %d preference(s) for user #%d ("%s").', $count, $user->id, $user->email));
}
}
return CommandAlias::SUCCESS;
}
}

View File

@@ -191,7 +191,7 @@ class ExportData extends Command
$this->friendlyError(sprintf('%s date "%s" must be formatted YYYY-MM-DD. Field will be ignored.', $field, $this->option('start')));
$error = true;
}
if (false === $date) {
if (null === $date) {
$this->friendlyError(sprintf('%s date "%s" must be formatted YYYY-MM-DD.', $field, $this->option('start')));
throw new FireflyException(sprintf('%s date "%s" must be formatted YYYY-MM-DD.', $field, $this->option('start')));

View File

@@ -80,7 +80,7 @@ class CreateGroupMemberships extends Command
// check if membership exists
$userGroup = UserGroup::where('title', $user->email)->first();
if (null === $userGroup) {
$userGroup = UserGroup::create(['title' => $user->email]);
$userGroup = UserGroup::create(['title' => $user->email, 'default_administration' => true]);
}
$userRole = UserRole::where('title', UserRoleEnum::OWNER->value)->first();

View File

@@ -32,24 +32,13 @@ class LaravelPassportKeys extends Command
{
use ShowsFriendlyMessages;
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'firefly-iii:laravel-passport-keys';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Calls the Laravel "passport:keys" but doesn\'t exit 1.';
protected $signature = 'firefly-iii:laravel-passport-keys';
/**
* Execute the console command.
*/
public function handle()
public function handle(): int
{
Artisan::call('passport:keys --no-interaction', []);
$result = Artisan::output();

View File

@@ -285,7 +285,7 @@ class ApplyRules extends Command
if (null !== $endString && '' !== $endString) {
$inputEnd = Carbon::createFromFormat('Y-m-d', $endString);
}
if (false === $inputEnd || false === $inputStart) {
if (null === $inputEnd || null === $inputStart) {
Log::error('Could not parse start or end date in verifyInputDate().');
return;

View File

@@ -69,6 +69,7 @@ class UpgradeDatabase extends Command
'firefly-iii:create-group-memberships',
'firefly-iii:upgrade-group-information',
'firefly-iii:upgrade-currency-preferences',
'firefly-iii:correct-database',
];
$args = [];
if ($this->option('force')) {

View File

@@ -405,7 +405,7 @@ class UserEventHandler
}
// clean up old entries (6 months)
$carbon = Carbon::createFromFormat('Y-m-d H:i:s', $preference[$index]['time']);
if (false !== $carbon && $carbon->diffInMonths(today(), true) > 6) {
if (null !== $carbon && $carbon->diffInMonths(today(), true) > 6) {
app('log')->debug(sprintf('Entry for %s is very old, remove it.', $row['ip']));
unset($preference[$index]);
}

View File

@@ -145,13 +145,13 @@ class CreateController extends Controller
Log::channel('audit')->info('Stored new account.', $data);
// update preferences if necessary:
$frontPage = app('preferences')->get('frontPageAccounts', [])->data;
if (!is_array($frontPage)) {
$frontPage = [];
$frontpage = app('preferences')->get('frontpageAccounts', [])->data;
if (!is_array($frontpage)) {
$frontpage = [];
}
if (AccountType::ASSET === $account->accountType->type) {
$frontPage[] = $account->id;
app('preferences')->set('frontPageAccounts', $frontPage);
$frontpage[] = $account->id;
app('preferences')->set('frontpageAccounts', $frontpage);
}
// store attachment(s):

View File

@@ -128,7 +128,7 @@ class BudgetLimitController extends Controller
$start = Carbon::createFromFormat('Y-m-d', $request->get('start'));
$end = Carbon::createFromFormat('Y-m-d', $request->get('end'));
if (false === $start || false === $end) {
if (null === $start || null === $end) {
return response()->json([]);
}

View File

@@ -301,14 +301,14 @@ class AccountController extends Controller
$end = clone session('end', today(config('app.timezone'))->endOfMonth());
$defaultSet = $repository->getAccountsByType([AccountType::DEFAULT, AccountType::ASSET])->pluck('id')->toArray();
app('log')->debug('Default set is ', $defaultSet);
$frontPage = app('preferences')->get('frontPageAccounts', $defaultSet);
$frontPageArray = !is_array($frontPage->data) ? [] : $frontPage->data;
app('log')->debug('Frontpage preference set is ', $frontPageArray);
if (0 === count($frontPageArray)) {
app('preferences')->set('frontPageAccounts', $defaultSet);
$frontpage = app('preferences')->get('frontpageAccounts', $defaultSet);
$frontpageArray = !is_array($frontpage->data) ? [] : $frontpage->data;
app('log')->debug('Frontpage preference set is ', $frontpageArray);
if (0 === count($frontpageArray)) {
app('preferences')->set('frontpageAccounts', $defaultSet);
app('log')->debug('frontpage set is empty!');
}
$accounts = $repository->getAccountsById($frontPageArray);
$accounts = $repository->getAccountsById($frontpageArray);
return response()->json($this->accountBalanceChart($accounts, $start, $end));
}

View File

@@ -116,8 +116,8 @@ class CategoryController extends Controller
return response()->json($cache->get());
}
$frontPageGenerator = new FrontpageChartGenerator($start, $end);
$chartData = $frontPageGenerator->generate();
$frontpageGenerator = new FrontpageChartGenerator($start, $end);
$chartData = $frontpageGenerator->generate();
$data = $this->generator->multiSet($chartData);
$cache->store($data);

View File

@@ -79,10 +79,10 @@ class HomeController extends Controller
app('log')->error(sprintf('End could not parse date string "%s" so ignore it.', $stringEnd));
$end = Carbon::now()->endOfMonth();
}
if (false === $start) {
if (null === $start) {
$start = Carbon::now()->startOfMonth();
}
if (false === $end) {
if (null === $end) {
$end = Carbon::now()->endOfMonth();
}
@@ -129,10 +129,10 @@ class HomeController extends Controller
}
$subTitle = (string)trans('firefly.welcome_back');
$transactions = [];
$frontPage = app('preferences')->getFresh('frontPageAccounts', $repository->getAccountsByType([AccountType::ASSET])->pluck('id')->toArray());
$frontPageArray = $frontPage->data;
if (!is_array($frontPageArray)) {
$frontPageArray = [];
$frontpage = app('preferences')->getFresh('frontpageAccounts', $repository->getAccountsByType([AccountType::ASSET])->pluck('id')->toArray());
$frontpageArray = $frontpage->data;
if (!is_array($frontpageArray)) {
$frontpageArray = [];
}
/** @var Carbon $start */
@@ -140,13 +140,13 @@ class HomeController extends Controller
/** @var Carbon $end */
$end = session('end', today(config('app.timezone'))->endOfMonth());
$accounts = $repository->getAccountsById($frontPageArray);
$accounts = $repository->getAccountsById($frontpageArray);
$today = today(config('app.timezone'));
// sort frontpage accounts by order
$accounts = $accounts->sortBy('order');
app('log')->debug('Frontpage accounts are ', $frontPageArray);
app('log')->debug('Frontpage accounts are ', $frontpageArray);
/** @var BillRepositoryInterface $billRepository */
$billRepository = app(BillRepositoryInterface::class);

View File

@@ -130,7 +130,7 @@ class BoxController extends Controller
$boxTitle = (string)trans('firefly.left_to_spend');
$activeDaysLeft = $this->activeDaysLeft($start, $end); // see method description.
$display = 1; // not overspent
$leftPerDayAmount = 0 === (int) $activeDaysLeft ? $leftToSpendAmount : bcdiv($leftToSpendAmount, (string)$activeDaysLeft);
$leftPerDayAmount = 0 === $activeDaysLeft ? $leftToSpendAmount : bcdiv($leftToSpendAmount, (string)$activeDaysLeft);
app('log')->debug(sprintf('Left to spend per day is %s', $leftPerDayAmount));
}
}

View File

@@ -81,7 +81,7 @@ class RecurrenceController extends Controller
$skip = $skip < 0 || $skip > 31 ? 0 : $skip;
$weekend = $weekend < 1 || $weekend > 4 ? 1 : $weekend;
if (false === $start || false === $end || false === $firstDate || false === $endDate) {
if (null === $start || null === $end || null === $firstDate || null === $endDate) {
return response()->json();
}
@@ -112,7 +112,7 @@ class RecurrenceController extends Controller
$actualEnd = clone $end;
if ('until_date' === $endsAt) {
$actualEnd = $endDate ?? clone $end;
$actualEnd = $endDate;
$occurrences = $this->recurring->getOccurrencesInRange($repetition, $actualStart, $actualEnd);
}
if ('times' === $endsAt) {
@@ -155,7 +155,7 @@ class RecurrenceController extends Controller
} catch (InvalidFormatException $e) {
$date = Carbon::today(config('app.timezone'));
}
if (false === $date) {
if (null === $date) {
return response()->json();
}
$date->startOfDay();

View File

@@ -115,7 +115,7 @@ class NewUserController extends Controller
// store frontpage preferences:
$accounts = $this->repository->getAccountsByType([AccountType::ASSET])->pluck('id')->toArray();
app('preferences')->set('frontPageAccounts', $accounts);
app('preferences')->set('frontpageAccounts', $accounts);
// mark.
app('preferences')->mark();

View File

@@ -89,10 +89,10 @@ class PreferencesController extends Controller
/** @var array<int, int> $accountIds */
$accountIds = $accounts->pluck('id')->toArray();
$viewRange = app('navigation')->getViewRange(false);
$frontPageAccountsPref = app('preferences')->get('frontPageAccounts', $accountIds);
$frontPageAccounts = $frontPageAccountsPref->data;
if (!is_array($frontPageAccounts)) {
$frontPageAccounts = $accountIds;
$frontpageAccountsPref = app('preferences')->get('frontpageAccounts', $accountIds);
$frontpageAccounts = $frontpageAccountsPref->data;
if (!is_array($frontpageAccounts)) {
$frontpageAccounts = $accountIds;
}
$language = app('steam')->getLanguage();
$languages = config('firefly.languages');
@@ -128,8 +128,8 @@ class PreferencesController extends Controller
$locales = ['equal' => (string)trans('firefly.equal_to_language')] + $locales;
// an important fallback is that the frontPageAccount array gets refilled automatically
// when it turns up empty.
if (0 === count($frontPageAccounts)) {
$frontPageAccounts = $accountIds;
if (0 === count($frontpageAccounts)) {
$frontpageAccounts = $accountIds;
}
// for the demo user, the slackUrl is automatically emptied.
@@ -139,7 +139,7 @@ class PreferencesController extends Controller
$slackUrl = '';
}
return view('preferences.index', compact('language', 'groupedAccounts', 'isDocker', 'frontPageAccounts', 'languages', 'darkMode', 'availableDarkModes', 'notifications', 'slackUrl', 'locales', 'locale', 'tjOptionalFields', 'viewRange', 'customFiscalYear', 'listPageSize', 'fiscalYearStart'));
return view('preferences.index', compact('language', 'groupedAccounts', 'isDocker', 'frontpageAccounts', 'languages', 'darkMode', 'availableDarkModes', 'notifications', 'slackUrl', 'locales', 'locale', 'tjOptionalFields', 'viewRange', 'customFiscalYear', 'listPageSize', 'fiscalYearStart'));
}
/**
@@ -155,12 +155,12 @@ class PreferencesController extends Controller
public function postIndex(Request $request)
{
// front page accounts
$frontPageAccounts = [];
if (is_array($request->get('frontPageAccounts')) && count($request->get('frontPageAccounts')) > 0) {
foreach ($request->get('frontPageAccounts') as $id) {
$frontPageAccounts[] = (int)$id;
$frontpageAccounts = [];
if (is_array($request->get('frontpageAccounts')) && count($request->get('frontpageAccounts')) > 0) {
foreach ($request->get('frontpageAccounts') as $id) {
$frontpageAccounts[] = (int)$id;
}
app('preferences')->set('frontPageAccounts', $frontPageAccounts);
app('preferences')->set('frontpageAccounts', $frontpageAccounts);
}
// extract notifications:
@@ -223,8 +223,8 @@ class PreferencesController extends Controller
// same for locale:
if (!auth()->user()->hasRole('demo')) {
/** @var Preference $locale */
$locale = $request->get('locale');
$locale = (string) $request->get('locale');
$locale = '' === $locale ? null : $locale;
app('preferences')->set('locale', $locale);
}

View File

@@ -23,7 +23,6 @@ declare(strict_types=1);
namespace FireflyIII\Http\Controllers;
use Auth;
use FireflyIII\Events\UserChangedEmail;
use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Exceptions\ValidationException;
@@ -467,9 +466,7 @@ class ProfileController extends Controller
if (is_array($secret)) {
$secret = null;
}
if (is_int($secret)) {
$secret = (string)$secret;
}
$secret = (string)$secret;
$repository->setMFACode($user, $secret);

View File

@@ -36,7 +36,7 @@ class CreateController extends Controller
public function create()
{
$title = (string)trans('firefly.administrations_page_title');
$subTitle = (string)trans('firefly.administrations_page_sub_title');
$subTitle = (string)trans('firefly.administrations_page_create_sub_title');
$mainTitleIcon = 'fa-book';
app('log')->debug(sprintf('Now at %s', __METHOD__));

View File

@@ -0,0 +1,46 @@
<?php
/*
* CreateController.php
* Copyright (c) 2024 james@firefly-iii.org.
*
* This file is part of Firefly III (https://github.com/firefly-iii).
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see https://www.gnu.org/licenses/.
*/
declare(strict_types=1);
namespace FireflyIII\Http\Controllers\UserGroup;
use FireflyIII\Http\Controllers\Controller;
use FireflyIII\Models\UserGroup;
use Illuminate\Contracts\View\Factory;
use Illuminate\Contracts\View\View;
use Illuminate\Foundation\Application;
class EditController extends Controller
{
/**
* @return Application|Factory|\Illuminate\Contracts\Foundation\Application|View
*/
public function edit(UserGroup $userGroup)
{
$title = (string)trans('firefly.administrations_page_title');
$subTitle = (string)trans('firefly.administrations_page_edit_sub_title', ['title' => $userGroup->title]);
$mainTitleIcon = 'fa-book';
app('log')->debug(sprintf('Now at %s', __METHOD__));
return view('administrations.edit')->with(compact('title', 'subTitle', 'mainTitleIcon'));
}
}

View File

@@ -119,7 +119,7 @@ class DownloadExchangeRates implements ShouldQueue
return;
}
$date = Carbon::createFromFormat('Y-m-d', $json['date'], config('app.timezone'));
if (false === $date) {
if (null === $date) {
return;
}
$this->saveRates($currency, $date, $json['rates']);

View File

@@ -128,7 +128,7 @@ class WarnAboutBills implements ShouldQueue
$today = clone $this->date;
$carbon = clone $bill->{$field};
return (int) $today->diffInDays($carbon);
return (int)$today->diffInDays($carbon);
}
private function sendWarning(Bill $bill, string $field): void

View File

@@ -110,6 +110,7 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
* @method static EloquentBuilder|Account whereUserGroupId($value)
*
* @property null|UserGroup $userGroup
* @property mixed $account_id
*
* @mixin Eloquent
*/

View File

@@ -61,6 +61,8 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
* @method static Builder|InvitedUser whereUpdatedAt($value)
* @method static Builder|InvitedUser whereUserId($value)
*
* @property mixed $user_group_id
*
* @mixin Eloquent
*/
class InvitedUser extends Model

View File

@@ -36,13 +36,13 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
/**
* FireflyIII\Models\Preference
*
* @property int $id
* @property null|Carbon $created_at
* @property null|Carbon $updated_at
* @property int $user_id
* @property string $name
* @property null|array|int|string $data
* @property User $user
* @property int $id
* @property null|Carbon $created_at
* @property null|Carbon $updated_at
* @property int $user_id
* @property string $name
* @property null|array|bool|int|string $data
* @property User $user
*
* @method static Builder|Preference newModelQuery()
* @method static Builder|Preference newQuery()
@@ -54,6 +54,8 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
* @method static Builder|Preference whereUpdatedAt($value)
* @method static Builder|Preference whereUserId($value)
*
* @property mixed $user_group_id
*
* @mixin Eloquent
*/
class Preference extends Model
@@ -79,22 +81,39 @@ class Preference extends Model
{
if (auth()->check()) {
/** @var User $user */
$user = auth()->user();
$user = auth()->user();
// some preferences do not have an administration ID.
// some need it, to make sure the correct one is selected.
$userGroupId = (int)$user->user_group_id;
$userGroupId = 0 === $userGroupId ? null : $userGroupId;
/** @var null|Preference $preference */
$preference = $user->preferences()->where('name', $value)->first();
$preference = null;
$items = config('firefly.admin_specific_prefs');
if (null !== $userGroupId && in_array($value, $items, true)) {
// find a preference with a specific user_group_id
$preference = $user->preferences()->where('user_group_id', $userGroupId)->where('name', $value)->first();
}
if (!in_array($value, $items, true)) {
// find any one.
$preference = $user->preferences()->where('name', $value)->first();
}
// try again with ID, but this time don't care about the preferred user_group_id
if (null === $preference) {
$preference = $user->preferences()->where('id', (int)$value)->first();
}
if (null !== $preference) {
return $preference;
}
$default = config('firefly.default_preferences');
$default = config('firefly.default_preferences');
if (array_key_exists($value, $default)) {
$preference = new self();
$preference->name = $value;
$preference->data = $default[$value];
$preference->user_id = (int)$user->id;
$preference = new self();
$preference->name = $value;
$preference->data = $default[$value];
$preference->user_id = (int)$user->id;
$preference->user_group_id = in_array($value, $items, true) ? $userGroupId : null;
$preference->save();
return $preference;

View File

@@ -81,6 +81,7 @@ use Illuminate\Database\Query\Builder;
* @method static \Illuminate\Database\Eloquent\Builder|RecurrenceTransaction whereTransactionTypeId($value)
*
* @property null|TransactionType $transactionType
* @property mixed $user_id
*
* @mixin Eloquent
*/

View File

@@ -98,7 +98,7 @@ class UserGroup extends Model
{
use ReturnsIntegerIdTrait;
protected $fillable = ['title'];
protected $fillable = ['title', 'default_administration'];
/**
* Route binder. Converts the key in the URL to the specified object (or throw 404).

View File

@@ -69,7 +69,10 @@ class AppServiceProvider extends ServiceProvider
if ('' === $firstParam && str_contains($name, $route)) {
return true;
}
$params = Route::getCurrentRoute()->parameters() ?? [];
/** @var null|array $params */
$params = Route::getCurrentRoute()->parameters();
$params ??= [];
$objectType = $params['objectType'] ?? '';
if ($objectType === $firstParam && str_contains($name, $route)) {
return true;

View File

@@ -183,21 +183,21 @@ class BudgetRepository implements BudgetRepositoryInterface
// |-----------|
// |----------------|
if ($start->gte($limit->start_date) && $end->lte($limit->end_date)) {
return (int) $start->diffInDays($end, true) + 1; // add one day
return (int)$start->diffInDays($end, true) + 1; // add one day
}
// limit starts earlier and limit ends first:
// |-----------|
// |-------|
if ($limit->start_date->lte($start) && $limit->end_date->lte($end)) {
// return days in the range $start-$limit_end
return (int) $start->diffInDays($limit->end_date, true) + 1; // add one day, the day itself
return (int)$start->diffInDays($limit->end_date, true) + 1; // add one day, the day itself
}
// limit starts later and limit ends earlier
// |-----------|
// |-------|
if ($limit->start_date->gte($start) && $limit->end_date->gte($end)) {
// return days in the range $limit_start - $end
return (int) $limit->start_date->diffInDays($end, true) + 1; // add one day, the day itself
return (int)$limit->start_date->diffInDays($end, true) + 1; // add one day, the day itself
}
return 0;

View File

@@ -51,7 +51,7 @@ class OperationsRepository implements OperationsRepositoryInterface
$total = '0';
$count = 0;
foreach ($budget->budgetlimits as $limit) {
$diff = (int) $limit->start_date->diffInDays($limit->end_date, true);
$diff = (int)$limit->start_date->diffInDays($limit->end_date, true);
$diff = 0 === $diff ? 1 : $diff;
$amount = $limit->amount;
$perDay = bcdiv($amount, (string)$diff);

View File

@@ -301,7 +301,7 @@ class PiggyBankRepository implements PiggyBankRepositoryInterface
if (null !== $piggyBank->targetdate && $repetition->currentamount < $piggyBank->targetamount) {
$now = today(config('app.timezone'));
$startDate = null !== $piggyBank->startdate && $piggyBank->startdate->gte($now) ? $piggyBank->startdate : $now;
$diffInMonths = (int) $startDate->diffInMonths($piggyBank->targetdate);
$diffInMonths = (int)$startDate->diffInMonths($piggyBank->targetdate);
$remainingAmount = bcsub($piggyBank->targetamount, $repetition->currentamount);
// more than 1 month to go and still need money to save:

View File

@@ -473,10 +473,10 @@ class RecurringRepository implements RecurringRepositoryInterface
if ('yearly' === $repetition->repetition_type) {
$today = today(config('app.timezone'))->endOfYear();
$repDate = Carbon::createFromFormat('Y-m-d', $repetition->repetition_moment);
if (false === $repDate) {
if (null === $repDate) {
$repDate = clone $today;
}
$diffInYears = (int) $today->diffInYears($repDate, true);
$diffInYears = (int)$today->diffInYears($repDate, true);
$repDate->addYears($diffInYears); // technically not necessary.
$string = $repDate->isoFormat((string)trans('config.month_and_day_no_year_js'));

View File

@@ -242,6 +242,30 @@ class UserRepository implements UserRepositoryInterface
return false;
}
#[\Override]
public function getUserGroups(User $user): Collection
{
$memberships = $user->groupMemberships()->get();
$set = [];
$collection = new Collection();
/** @var GroupMembership $membership */
foreach ($memberships as $membership) {
/** @var null|UserGroup $group */
$group = $membership->userGroup()->first();
if (null !== $group) {
$groupId = $group->id;
if (in_array($groupId, array_keys($set), true)) {
continue;
}
$set[$groupId] = $group;
}
}
$collection->push(...$set);
return $collection;
}
public function inviteUser(null|Authenticatable|User $user, string $email): InvitedUser
{
$now = today(config('app.timezone'));

View File

@@ -94,6 +94,8 @@ interface UserRepositoryInterface
*/
public function getUserData(User $user): array;
public function getUserGroups(User $user): Collection;
public function hasRole(null|Authenticatable|User $user, string $role): bool;
public function inviteUser(null|Authenticatable|User $user, string $email): InvitedUser;

View File

@@ -106,8 +106,8 @@ class UserGroupRepository implements UserGroupRepositoryInterface
/** @var null|UserGroup $group */
$group = $membership->userGroup()->first();
if (null !== $group) {
$groupId = (int)$group->id;
if (in_array($groupId, $set, true)) {
$groupId = $group->id;
if (in_array($groupId, array_keys($set), true)) {
continue;
}
$set[$groupId] = $group;
@@ -288,4 +288,11 @@ class UserGroupRepository implements UserGroupRepositoryInterface
return $roles;
}
#[\Override]
public function useUserGroup(UserGroup $userGroup): void
{
$this->user->user_group_id = $userGroup->id;
$this->user->save();
}
}

View File

@@ -47,4 +47,6 @@ interface UserGroupRepositoryInterface
public function update(UserGroup $userGroup, array $data): UserGroup;
public function updateMembership(UserGroup $userGroup, array $data): UserGroup;
public function useUserGroup(UserGroup $userGroup): void;
}

View File

@@ -63,6 +63,8 @@ interface AccountRepositoryInterface
*/
public function getMetaValue(Account $account, string $field): ?string;
public function getUserGroup(): UserGroup;
/**
* Reset order types of the mentioned accounts.
*/

View File

@@ -0,0 +1,63 @@
<?php
/**
* IsTransferAccount.php
* Copyright (c) 2020 james@firefly-iii.org
*
* This file is part of Firefly III (https://github.com/firefly-iii).
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
declare(strict_types=1);
namespace FireflyIII\Rules;
use FireflyIII\Models\UserGroup;
use FireflyIII\Repositories\User\UserRepositoryInterface;
use FireflyIII\User;
use Illuminate\Contracts\Validation\ValidationRule;
/**
* Class IsDefaultUserGroupName
*/
class IsDefaultUserGroupName implements ValidationRule
{
private UserGroup $userGroup;
public function __construct(UserGroup $userGroup)
{
$this->userGroup = $userGroup;
}
/**
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function validate(string $attribute, mixed $value, \Closure $fail): void
{
app('log')->debug(sprintf('Now in %s(%s)', __METHOD__, $value));
// are you owner of this group and the name is the same? fail.
/** @var User $user */
$user = auth()->user();
/** @var UserRepositoryInterface $userRepos */
$userRepos = app(UserRepositoryInterface::class);
$roles = $userRepos->getRolesInGroup($user, $this->userGroup->id);
if ($this->userGroup->title === $user->email && in_array('owner', $roles, true)) {
$fail('validation.administration_owner_rename')->translate();
}
}
}

View File

@@ -117,7 +117,7 @@ class UpdateRequest implements UpdateRequestInterface
// parse response a bit. No message yet.
$response = $json['firefly_iii'][$channel];
$date = Carbon::createFromFormat('Y-m-d', $response['date']);
if (false === $date) {
if (null === $date) {
$date = today(config('app.timezone'));
}
$return['version'] = $response['version'];

View File

@@ -54,7 +54,7 @@ class GroupCloneService
{
$newJournal = $journal->replicate();
$newJournal->transaction_group_id = $newGroup->id;
$newJournal->date = today(config('app.timezone'));
$newJournal->date = now();
$newJournal->save();
foreach ($journal->transactions as $transaction) {

View File

@@ -146,7 +146,7 @@ class RemoteUserGuard implements Guard
return $this->user?->id;
}
public function setUser(null|Authenticatable|User $user): void
public function setUser(null|Authenticatable|User $user): void // @phpstan-ignore-line
{
app('log')->debug(sprintf('Now at %s', __METHOD__));
if ($user instanceof User) {

View File

@@ -36,6 +36,14 @@ use Illuminate\Contracts\Auth\UserProvider;
*/
class RemoteUserProvider implements UserProvider
{
#[\Override]
public function rehashPasswordIfRequired(Authenticatable $user, array $credentials, bool $force = false): void
{
app('log')->debug(sprintf('Now at %s', __METHOD__));
throw new FireflyException(sprintf('Did not implement %s', __METHOD__));
}
/**
* @throws FireflyException
*
@@ -120,12 +128,4 @@ class RemoteUserProvider implements UserProvider
throw new FireflyException(sprintf('C) Did not implement %s', __METHOD__));
}
#[\Override]
public function rehashPasswordIfRequired(Authenticatable $user, array $credentials, bool $force = false): void
{
app('log')->debug(sprintf('Now at %s', __METHOD__));
throw new FireflyException(sprintf('Did not implement %s', __METHOD__));
}
}

View File

@@ -46,7 +46,7 @@ trait DateCalculation
$difference = $today->diffInDays($end);
}
return (int) (0 === $difference ? 1 : $difference);
return (int)(0 === $difference ? 1 : $difference);
}
/**
@@ -63,7 +63,7 @@ trait DateCalculation
$difference = $start->diffInDays($today, true) + 1;
}
return (int) $difference;
return (int)$difference;
}
protected function calculateStep(Carbon $start, Carbon $end): string

View File

@@ -145,14 +145,14 @@ trait RequestInformation
$attributes['location'] ??= '';
$attributes['accounts'] = AccountList::routeBinder($attributes['accounts'] ?? '', new Route('get', '', []));
$date = Carbon::createFromFormat('Ymd', $attributes['startDate']);
if (false === $date) {
if (null === $date) {
$date = today(config('app.timezone'));
}
$date->startOfMonth();
$attributes['startDate'] = $date;
$date2 = Carbon::createFromFormat('Ymd', $attributes['endDate']);
if (false === $date2) {
if (null === $date2) {
$date2 = today(config('app.timezone'));
}
$date2->endOfDay();

View File

@@ -188,7 +188,7 @@ class Navigation
Log::debug(sprintf('Function is ->%s()', $function));
if (array_key_exists($function, $parameterMap)) {
Log::debug(sprintf('Parameter map, function becomes ->%s(%s)', $function, implode(', ', $parameterMap[$function])));
$date->{$function}($parameterMap[$function][0]);
$date->{$function}($parameterMap[$function][0]); // @phpstan-ignore-line
Log::debug(sprintf('Result is "%s"', $date->toIso8601String()));
return $date;
@@ -274,7 +274,7 @@ class Navigation
/** @var Carbon $tEnd */
$tEnd = session('end', today(config('app.timezone'))->endOfMonth());
$diffInDays = (int) $tStart->diffInDays($tEnd, true);
$diffInDays = (int)$tStart->diffInDays($tEnd, true);
}
Log::debug(sprintf('Diff in days is %d', $diffInDays));
$currentEnd->addDays($diffInDays);
@@ -327,7 +327,7 @@ class Navigation
{
$endOfMonth = $date->copy()->endOfMonth();
return (int) $date->diffInDays($endOfMonth, true);
return (int)$date->diffInDays($endOfMonth, true);
}
public function diffInPeriods(string $period, int $skip, Carbon $beginning, Carbon $end): int
@@ -677,7 +677,7 @@ class Navigation
/** @var Carbon $tEnd */
$tEnd = session('end', today(config('app.timezone'))->endOfMonth());
$diffInDays = (int) $tStart->diffInDays($tEnd, true);
$diffInDays = (int)$tStart->diffInDays($tEnd, true);
$date->subDays($diffInDays * $subtract);
return $date;

View File

@@ -25,6 +25,7 @@ declare(strict_types=1);
namespace FireflyIII\Support;
use Carbon\Carbon;
use Carbon\CarbonInterface;
use Carbon\Exceptions\InvalidFormatException;
use FireflyIII\Exceptions\FireflyException;
use Illuminate\Support\Facades\Log;
@@ -122,12 +123,12 @@ class ParseDateString
{
$today = today(config('app.timezone'))->startOfDay();
return match ($keyword) {
return match ($keyword) { // @phpstan-ignore-line
default => $today,
'yesterday' => $today->subDay(),
'tomorrow' => $today->addDay(),
'start of this week' => $today->startOfWeek(Carbon::MONDAY),
'end of this week' => $today->endOfWeek(Carbon::SUNDAY),
'start of this week' => $today->startOfWeek(CarbonInterface::MONDAY),
'end of this week' => $today->endOfWeek(CarbonInterface::SUNDAY),
'start of this month' => $today->startOfMonth(),
'end of this month' => $today->endOfMonth(),
'start of this quarter' => $today->startOfQuarter(),

View File

@@ -26,7 +26,10 @@ namespace FireflyIII\Support;
use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Models\Preference;
use FireflyIII\User;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Support\Collection;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\Session;
/**
* Class Preferences.
@@ -40,20 +43,17 @@ class Preferences
return new Collection();
}
return Preference::where('user_id', $user->id)->get();
return Preference::where('user_id', $user->id)
->where(function (Builder $q) use ($user): void {
$q->whereNull('user_group_id');
$q->orWhere('user_group_id', $user->user_group_id);
})
->get()
;
}
/**
* @param mixed $default
*
* @throws FireflyException
*/
public function get(string $name, $default = null): ?Preference
public function get(string $name, null|array|bool|int|string $default = null): ?Preference
{
if ('currencyPreference' === $name) {
throw new FireflyException('No longer supports "currencyPreference", please refactor me.');
}
/** @var null|User $user */
$user = auth()->user();
if (null === $user) {
@@ -66,15 +66,12 @@ class Preferences
return $this->getForUser($user, $name, $default);
}
/**
* @throws FireflyException
*/
public function getForUser(User $user, string $name, null|array|bool|int|string $default = null): ?Preference
{
if ('currencyPreference' === $name) {
throw new FireflyException('No longer supports "currencyPreference", please refactor me.');
}
$preference = Preference::where('user_id', $user->id)->where('name', $name)->first(['id', 'user_id', 'name', 'data', 'updated_at', 'created_at']);
// don't care about user group ID, except for some specific preferences.
$userGroupId = $this->getUserGroupId($user, $name);
$preference = Preference::where('user_group_id', $userGroupId)->where('user_id', $user->id)->where('name', $name)->first(['id', 'user_id', 'name', 'data', 'updated_at', 'created_at']);
if (null !== $preference && null === $preference->data) {
$preference->delete();
$preference = null;
@@ -92,17 +89,22 @@ class Preferences
return $this->setForUser($user, $name, $default);
}
/**
* @throws FireflyException
*/
private function getUserGroupId(User $user, string $preferenceName): ?int
{
$groupId = null;
$items = config('firefly.admin_specific_prefs') ?? [];
if (in_array($preferenceName, $items, true)) {
$groupId = (int)$user->user_group_id;
}
return $groupId;
}
public function delete(string $name): bool
{
if ('currencyPreference' === $name) {
throw new FireflyException('No longer supports "currencyPreference", please refactor me.');
}
$fullName = sprintf('preference%s%s', auth()->user()->id, $name);
if (\Cache::has($fullName)) {
\Cache::forget($fullName);
if (Cache::has($fullName)) {
Cache::forget($fullName);
}
Preference::where('user_id', auth()->user()->id)->where('name', $name)->delete();
@@ -111,29 +113,19 @@ class Preferences
public function forget(User $user, string $name): void
{
if ('currencyPreference' === $name) {
throw new FireflyException('No longer supports "currencyPreference", please refactor me.');
}
$key = sprintf('preference%s%s', $user->id, $name);
\Cache::forget($key);
\Cache::put($key, '', 5);
Cache::forget($key);
Cache::put($key, '', 5);
}
/**
* @param mixed $value
*
* @throws FireflyException
*/
public function setForUser(User $user, string $name, $value): Preference
public function setForUser(User $user, string $name, null|array|bool|int|string $value): Preference
{
if ('currencyPreference' === $name) {
throw new FireflyException('No longer supports "currencyPreference", please refactor me.');
}
$fullName = sprintf('preference%s%s', $user->id, $name);
\Cache::forget($fullName);
$groupId = $this->getUserGroupId($user, $name);
Cache::forget($fullName);
/** @var null|Preference $pref */
$pref = Preference::where('user_id', $user->id)->where('name', $name)->first(['id', 'name', 'data', 'updated_at', 'created_at']);
$pref = Preference::where('user_group_id', $groupId)->where('user_id', $user->id)->where('name', $name)->first(['id', 'name', 'data', 'updated_at', 'created_at']);
if (null !== $pref && null === $value) {
$pref->delete();
@@ -144,18 +136,14 @@ class Preferences
return new Preference();
}
if (null === $pref) {
$pref = new Preference();
$pref->user_id = (int)$user->id;
$pref->name = $name;
$pref = new Preference();
$pref->user_id = (int)$user->id;
$pref->user_group_id = $groupId;
$pref->name = $name;
}
$pref->data = $value;
try {
$pref->save();
} catch (\PDOException $e) {
throw new FireflyException(sprintf('Could not save preference: %s', $e->getMessage()), 0, $e);
}
\Cache::forever($fullName, $pref);
$pref->save();
Cache::forever($fullName, $pref);
return $pref;
}
@@ -165,19 +153,25 @@ class Preferences
return Preference::where('user_id', $user->id)->where('name', 'LIKE', $search.'%')->get();
}
/**
* Find by name, has no user ID in it, because the method is called from an unauthenticated route any way.
*/
public function findByName(string $name): Collection
{
if ('currencyPreference' === $name) {
throw new FireflyException('No longer supports "currencyPreference", please refactor me.');
}
return Preference::where('name', $name)->get();
}
public function getArrayForUser(User $user, array $list): array
{
$result = [];
$preferences = Preference::where('user_id', $user->id)->whereIn('name', $list)->get(['id', 'name', 'data']);
$preferences = Preference::where('user_id', $user->id)
->where(function (Builder $q) use ($user): void {
$q->whereNull('user_group_id');
$q->orWhere('user_group_id', $user->user_group_id);
})
->whereIn('name', $list)
->get(['id', 'name', 'data'])
;
/** @var Preference $preference */
foreach ($preferences as $preference) {
@@ -192,17 +186,8 @@ class Preferences
return $result;
}
/**
* @param mixed $default
*
* @throws FireflyException
*/
public function getFresh(string $name, $default = null): ?Preference
public function getFresh(string $name, null|array|bool|int|string $default = null): ?Preference
{
if ('currencyPreference' === $name) {
throw new FireflyException('No longer supports "currencyPreference", please refactor me.');
}
/** @var null|User $user */
$user = auth()->user();
if (null === $user) {
@@ -212,22 +197,6 @@ class Preferences
return $preference;
}
return $this->getFreshForUser($user, $name, $default);
}
/**
* TODO remove me.
*
* @param null $default
*
* @throws FireflyException
*/
public function getFreshForUser(User $user, string $name, $default = null): ?Preference
{
if ('currencyPreference' === $name) {
throw new FireflyException('No longer supports "currencyPreference", please refactor me.');
}
return $this->getForUser($user, $name, $default);
}
@@ -252,19 +221,12 @@ class Preferences
public function mark(): void
{
$this->set('lastActivity', microtime());
\Session::forget('first');
Session::forget('first');
}
/**
* @param mixed $value
*
* @throws FireflyException
*/
public function set(string $name, $value): Preference
public function set(string $name, null|array|bool|int|string $value): Preference
{
if ('currencyPreference' === $name) {
throw new FireflyException('No longer supports "currencyPreference", please refactor me.');
}
/** @var null|User $user */
$user = auth()->user();
if (null === $user) {
// make new preference, return it:
@@ -275,6 +237,6 @@ class Preferences
return $pref;
}
return $this->setForUser(auth()->user(), $name, $value);
return $this->setForUser($user, $name, $value);
}
}

View File

@@ -250,7 +250,7 @@ trait ConvertsDataTypes
return null;
}
if (false === $carbon) {
if (null === $carbon) {
app('log')->error(sprintf('[2] "%s" is of an invalid format.', $value));
return null;

View File

@@ -29,7 +29,7 @@ use Symfony\Component\ExpressionLanguage\SyntaxError;
class ActionExpression
{
private static array $NAMES
private static array $NAMES
= [
// 'transaction_group_id',
// 'user_id',

View File

@@ -185,7 +185,7 @@ class AccountTransformer extends AbstractTransformer
// try classic date:
if (10 === strlen($monthlyPaymentDate)) {
$object = Carbon::createFromFormat('!Y-m-d', $monthlyPaymentDate, config('app.timezone'));
if (false === $object) {
if (null === $object) {
$object = today(config('app.timezone'));
}
$monthlyPaymentDate = $object->toAtomString();
@@ -212,7 +212,7 @@ class AccountTransformer extends AbstractTransformer
}
if (null !== $openingBalanceDate) {
$object = Carbon::createFromFormat('Y-m-d H:i:s', $openingBalanceDate, config('app.timezone'));
if (false === $object) {
if (null === $object) {
$object = today(config('app.timezone'));
}
$openingBalanceDate = $object->toAtomString();

View File

@@ -82,7 +82,7 @@ class BillTransformer extends AbstractTransformer
$payDatesFormatted = [];
foreach ($paidData as $object) {
$date = Carbon::createFromFormat('!Y-m-d', $object['date'], config('app.timezone'));
if (false === $date) {
if (null === $date) {
$date = today(config('app.timezone'));
}
$object['date'] = $date->toAtomString();
@@ -91,7 +91,7 @@ class BillTransformer extends AbstractTransformer
foreach ($payDates as $string) {
$date = Carbon::createFromFormat('!Y-m-d', $string, config('app.timezone'));
if (false === $date) {
if (null === $date) {
$date = today(config('app.timezone'));
}
$payDatesFormatted[] = $date->toAtomString();
@@ -104,7 +104,7 @@ class BillTransformer extends AbstractTransformer
if (null !== $firstPayDate) {
$nemDate = Carbon::createFromFormat('!Y-m-d', $firstPayDate, config('app.timezone'));
if (false === $nemDate) {
if (null === $nemDate) {
$nemDate = today(config('app.timezone'));
}
$nem = $nemDate->toAtomString();
@@ -129,7 +129,7 @@ class BillTransformer extends AbstractTransformer
$current = $payDatesFormatted[0] ?? null;
if (null !== $current && !$nemDate->isToday()) {
$temp2 = Carbon::createFromFormat('Y-m-d\TH:i:sP', $current);
if (false === $temp2) {
if (null === $temp2) {
$temp2 = today(config('app.timezone'));
}
$nemDiff = trans('firefly.bill_expected_date', ['date' => $temp2->diffForHumans(today(config('app.timezone')), CarbonInterface::DIFF_RELATIVE_TO_NOW)]);

View File

@@ -35,12 +35,15 @@ class PreferenceTransformer extends AbstractTransformer
*/
public function transform(Preference $preference): array
{
$userGroupId = 0 === $preference->user_group_id ? null : $preference->user_group_id;
return [
'id' => $preference->id,
'created_at' => $preference->created_at->toAtomString(),
'updated_at' => $preference->updated_at->toAtomString(),
'name' => $preference->name,
'data' => $preference->data,
'id' => $preference->id,
'created_at' => $preference->created_at->toAtomString(),
'updated_at' => $preference->updated_at->toAtomString(),
'user_group_id' => $userGroupId,
'name' => $preference->name,
'data' => $preference->data,
];
}
}

View File

@@ -248,7 +248,7 @@ class PiggyBankTransformer extends AbstractTransformer
if (bccomp($currentAmount, $targetAmount) < 1) {
$now = today(config('app.timezone'));
$startDate = null !== $startDate && $startDate->gte($now) ? $startDate : $now;
$diffInMonths = (int) $startDate->diffInMonths($targetDate);
$diffInMonths = (int)$startDate->diffInMonths($targetDate);
$remainingAmount = bcsub($targetAmount, $currentAmount);
// more than 1 month to go and still need money to save:

View File

@@ -462,7 +462,7 @@ class TransactionGroupTransformer extends AbstractTransformer
// app('log')->debug(sprintf('Now in date("%s")', $string));
if (10 === strlen($string)) {
$res = Carbon::createFromFormat('Y-m-d', $string, config('app.timezone'));
if (false === $res) {
if (null === $res) {
return null;
}
@@ -473,7 +473,7 @@ class TransactionGroupTransformer extends AbstractTransformer
}
if (19 === strlen($string) && str_contains($string, 'T')) {
$res = Carbon::createFromFormat('Y-m-d\TH:i:s', substr($string, 0, 19), config('app.timezone'));
if (false === $res) {
if (null === $res) {
return null;
}
@@ -482,7 +482,7 @@ class TransactionGroupTransformer extends AbstractTransformer
// 2022-01-01 01:01:01
$res = Carbon::createFromFormat('Y-m-d H:i:s', substr($string, 0, 19), config('app.timezone'));
if (false === $res) {
if (null === $res) {
return null;
}

View File

@@ -35,9 +35,9 @@ use Illuminate\Support\Collection;
*/
class UserGroupTransformer extends AbstractTransformer
{
private array $inUse;
private array $memberships;
private array $membershipsVisible;
private array $inUse;
public function __construct()
{

View File

@@ -3,6 +3,12 @@
All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/).
## 6.1.14 - 2024-xx-xx
### Changed
- You will have to define again which asset accounts you want to see on the dashboard. Sorry about that.
## 6.1.13 - 2024-04-01
### Added

56
composer.lock generated
View File

@@ -1670,16 +1670,16 @@
},
{
"name": "laravel/framework",
"version": "v11.1.1",
"version": "v11.2.0",
"source": {
"type": "git",
"url": "https://github.com/laravel/framework.git",
"reference": "1437cea6d2b04cbc83743fbb208e1a01efccd9ec"
"reference": "a1750156b671f37cba702380107e2d22161c31e3"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/laravel/framework/zipball/1437cea6d2b04cbc83743fbb208e1a01efccd9ec",
"reference": "1437cea6d2b04cbc83743fbb208e1a01efccd9ec",
"url": "https://api.github.com/repos/laravel/framework/zipball/a1750156b671f37cba702380107e2d22161c31e3",
"reference": "a1750156b671f37cba702380107e2d22161c31e3",
"shasum": ""
},
"require": {
@@ -1871,7 +1871,7 @@
"issues": "https://github.com/laravel/framework/issues",
"source": "https://github.com/laravel/framework"
},
"time": "2024-03-28T15:07:18+00:00"
"time": "2024-04-02T14:01:33+00:00"
},
{
"name": "laravel/passport",
@@ -5481,16 +5481,16 @@
},
{
"name": "spatie/laravel-ignition",
"version": "2.5.0",
"version": "2.5.1",
"source": {
"type": "git",
"url": "https://github.com/spatie/laravel-ignition.git",
"reference": "e23f4e8ce6644dc3d68b9d8a0aed3beaca0d6ada"
"reference": "0c864b3cbd66ce67a2096c5f743e07ce8f1d6ab9"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/spatie/laravel-ignition/zipball/e23f4e8ce6644dc3d68b9d8a0aed3beaca0d6ada",
"reference": "e23f4e8ce6644dc3d68b9d8a0aed3beaca0d6ada",
"url": "https://api.github.com/repos/spatie/laravel-ignition/zipball/0c864b3cbd66ce67a2096c5f743e07ce8f1d6ab9",
"reference": "0c864b3cbd66ce67a2096c5f743e07ce8f1d6ab9",
"shasum": ""
},
"require": {
@@ -5569,7 +5569,7 @@
"type": "github"
}
],
"time": "2024-03-29T14:14:55+00:00"
"time": "2024-04-02T06:30:22+00:00"
},
{
"name": "spatie/period",
@@ -8897,23 +8897,23 @@
"packages-dev": [
{
"name": "barryvdh/laravel-debugbar",
"version": "v3.12.3",
"version": "v3.13.0",
"source": {
"type": "git",
"url": "https://github.com/barryvdh/laravel-debugbar.git",
"reference": "aac8f08b73af8c5d2ab6595c8823ddb26d1453f1"
"reference": "354a42f3e0b083cdd6f9da5a9d1c0c63b074547a"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/barryvdh/laravel-debugbar/zipball/aac8f08b73af8c5d2ab6595c8823ddb26d1453f1",
"reference": "aac8f08b73af8c5d2ab6595c8823ddb26d1453f1",
"url": "https://api.github.com/repos/barryvdh/laravel-debugbar/zipball/354a42f3e0b083cdd6f9da5a9d1c0c63b074547a",
"reference": "354a42f3e0b083cdd6f9da5a9d1c0c63b074547a",
"shasum": ""
},
"require": {
"illuminate/routing": "^9|^10|^11",
"illuminate/session": "^9|^10|^11",
"illuminate/support": "^9|^10|^11",
"maximebf/debugbar": "~1.21.0",
"maximebf/debugbar": "~1.22.0",
"php": "^8.0",
"symfony/finder": "^6|^7"
},
@@ -8926,7 +8926,7 @@
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "3.10-dev"
"dev-master": "3.13-dev"
},
"laravel": {
"providers": [
@@ -8965,7 +8965,7 @@
],
"support": {
"issues": "https://github.com/barryvdh/laravel-debugbar/issues",
"source": "https://github.com/barryvdh/laravel-debugbar/tree/v3.12.3"
"source": "https://github.com/barryvdh/laravel-debugbar/tree/v3.13.0"
},
"funding": [
{
@@ -8977,7 +8977,7 @@
"type": "github"
}
],
"time": "2024-03-31T18:35:30+00:00"
"time": "2024-04-01T16:39:30+00:00"
},
{
"name": "barryvdh/laravel-ide-helper",
@@ -9606,25 +9606,27 @@
},
{
"name": "maximebf/debugbar",
"version": "v1.21.3",
"version": "v1.22.1",
"source": {
"type": "git",
"url": "https://github.com/maximebf/php-debugbar.git",
"reference": "0b407703b08ea0cf6ebc61e267cc96ff7000911b"
"reference": "d7b6e1dc2dc85c01ed63ab158b00a7f46abdebcc"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/maximebf/php-debugbar/zipball/0b407703b08ea0cf6ebc61e267cc96ff7000911b",
"reference": "0b407703b08ea0cf6ebc61e267cc96ff7000911b",
"url": "https://api.github.com/repos/maximebf/php-debugbar/zipball/d7b6e1dc2dc85c01ed63ab158b00a7f46abdebcc",
"reference": "d7b6e1dc2dc85c01ed63ab158b00a7f46abdebcc",
"shasum": ""
},
"require": {
"php": "^7.1|^8",
"php": "^7.2|^8",
"psr/log": "^1|^2|^3",
"symfony/var-dumper": "^4|^5|^6|^7"
},
"require-dev": {
"phpunit/phpunit": ">=7.5.20 <10.0",
"dbrekelmans/bdi": "^1",
"phpunit/phpunit": "^8|^9",
"symfony/panther": "^1|^2.1",
"twig/twig": "^1.38|^2.7|^3.0"
},
"suggest": {
@@ -9635,7 +9637,7 @@
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.21-dev"
"dev-master": "1.22-dev"
}
},
"autoload": {
@@ -9666,9 +9668,9 @@
],
"support": {
"issues": "https://github.com/maximebf/php-debugbar/issues",
"source": "https://github.com/maximebf/php-debugbar/tree/v1.21.3"
"source": "https://github.com/maximebf/php-debugbar/tree/v1.22.1"
},
"time": "2024-03-12T14:23:07+00:00"
"time": "2024-04-01T10:44:20+00:00"
},
{
"name": "mockery/mockery",

View File

@@ -117,9 +117,9 @@ return [
'expression_engine' => false,
// see cer.php for exchange rates feature flag.
],
'version' => '6.1.13',
'version' => 'develop/2024-04-03',
'api_version' => '2.0.13',
'db_version' => 23,
'db_version' => 24,
// generic settings
'maxUploadSize' => 1073741824, // 1 GB
@@ -215,11 +215,14 @@ return [
'zoom_level' => env('MAP_DEFAULT_ZOOM', '6'),
],
// administration specific preferences
'admin_specific_prefs' => ['frontpageAccounts', 'lastActivity'],
// default user-related values
'darkMode' => 'browser',
'list_length' => 10, // to be removed if v1 is cancelled.
'default_preferences' => [
'frontPageAccounts' => [],
'frontpageAccounts' => [],
'listPageSize' => 50,
'currencyPreference' => 'EUR',
'language' => 'en_US',

View File

@@ -21,7 +21,6 @@
*/
declare(strict_types=1);
use Doctrine\DBAL\Schema\Exception\ColumnDoesNotExist;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\QueryException;
use Illuminate\Database\Schema\Blueprint;
@@ -46,7 +45,7 @@ class ExpandTransactionsTable extends Migration
$table->dropColumn('identifier');
}
);
} catch (ColumnDoesNotExist|QueryException $e) {
} catch (QueryException $e) {
app('log')->error(sprintf('Could not drop column "identifier": %s', $e->getMessage()));
app('log')->error('If the column does not exist, this is not an problem. Otherwise, please open a GitHub discussion.');
}

View File

@@ -21,7 +21,6 @@
*/
declare(strict_types=1);
use Doctrine\DBAL\Schema\Exception\ColumnDoesNotExist;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\QueryException;
use Illuminate\Database\Schema\Blueprint;
@@ -74,7 +73,7 @@ class ChangesForV431 extends Migration
$table->renameColumn('start_date', 'startdate');
}
);
} catch (ColumnDoesNotExist|QueryException $e) {
} catch (QueryException $e) {
app('log')->error(sprintf('Could not execute query: %s', $e->getMessage()));
app('log')->error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
}
@@ -89,7 +88,7 @@ class ChangesForV431 extends Migration
$table->dropColumn('end_date');
}
);
} catch (ColumnDoesNotExist|QueryException $e) {
} catch (QueryException $e) {
app('log')->error(sprintf('Could not execute query: %s', $e->getMessage()));
app('log')->error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
}
@@ -103,7 +102,7 @@ class ChangesForV431 extends Migration
$table->dropColumn('decimal_places');
}
);
} catch (ColumnDoesNotExist|QueryException $e) {
} catch (QueryException $e) {
app('log')->error(sprintf('Could not execute query: %s', $e->getMessage()));
app('log')->error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
}
@@ -141,7 +140,7 @@ class ChangesForV431 extends Migration
$table->renameColumn('startdate', 'start_date');
}
);
} catch (ColumnDoesNotExist|QueryException $e) {
} catch (QueryException $e) {
app('log')->error(sprintf('Could not execute query: %s', $e->getMessage()));
app('log')->error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
}
@@ -171,7 +170,7 @@ class ChangesForV431 extends Migration
$table->dropColumn('repeats');
}
);
} catch (ColumnDoesNotExist|QueryException $e) {
} catch (QueryException $e) {
app('log')->error(sprintf('Could not execute query: %s', $e->getMessage()));
app('log')->error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
}
@@ -184,7 +183,7 @@ class ChangesForV431 extends Migration
$table->dropColumn('repeat_freq');
}
);
} catch (ColumnDoesNotExist|QueryException $e) {
} catch (QueryException $e) {
app('log')->error(sprintf('Could not execute query: %s', $e->getMessage()));
app('log')->error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
}

View File

@@ -21,7 +21,6 @@
*/
declare(strict_types=1);
use Doctrine\DBAL\Schema\Exception\ColumnDoesNotExist;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\QueryException;
use Illuminate\Database\Schema\Blueprint;
@@ -53,7 +52,7 @@ class ChangesForV440 extends Migration
}
}
);
} catch (ColumnDoesNotExist|QueryException $e) {
} catch (QueryException $e) {
app('log')->error(sprintf('Could not execute query: %s', $e->getMessage()));
app('log')->error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
}

View File

@@ -21,7 +21,6 @@
*/
declare(strict_types=1);
use Doctrine\DBAL\Schema\Exception\ColumnDoesNotExist;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\QueryException;
use Illuminate\Database\Schema\Blueprint;
@@ -47,7 +46,7 @@ class ChangesForV450 extends Migration
$table->dropColumn('foreign_amount');
}
);
} catch (ColumnDoesNotExist|QueryException $e) {
} catch (QueryException $e) {
app('log')->error(sprintf('Could not execute query: %s', $e->getMessage()));
app('log')->error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
}
@@ -75,7 +74,7 @@ class ChangesForV450 extends Migration
$table->dropColumn('foreign_currency_id');
}
);
} catch (ColumnDoesNotExist|QueryException $e) {
} catch (QueryException $e) {
app('log')->error(sprintf('Could not execute query: %s', $e->getMessage()));
app('log')->error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
}

View File

@@ -21,7 +21,6 @@
*/
declare(strict_types=1);
use Doctrine\DBAL\Schema\Exception\ColumnDoesNotExist;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\QueryException;
use Illuminate\Database\Schema\Blueprint;
@@ -47,7 +46,7 @@ class ChangesForV470a extends Migration
$table->dropColumn('reconciled');
}
);
} catch (ColumnDoesNotExist|QueryException $e) {
} catch (QueryException $e) {
app('log')->error(sprintf('Could not execute query: %s', $e->getMessage()));
app('log')->error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
}

View File

@@ -22,7 +22,6 @@
declare(strict_types=1);
use Doctrine\DBAL\Schema\Exception\ColumnDoesNotExist;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\QueryException;
use Illuminate\Database\Schema\Blueprint;
@@ -61,7 +60,7 @@ class ChangesForV472 extends Migration
$table->dropColumn('order');
}
);
} catch (ColumnDoesNotExist|QueryException $e) {
} catch (QueryException $e) {
app('log')->error(sprintf('Could not execute query: %s', $e->getMessage()));
app('log')->error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
}
@@ -83,7 +82,7 @@ class ChangesForV472 extends Migration
$table->dropColumn('notes');
}
);
} catch (ColumnDoesNotExist|QueryException $e) {
} catch (QueryException $e) {
app('log')->error(sprintf('Could not execute query: %s', $e->getMessage()));
app('log')->error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
}

View File

@@ -22,7 +22,6 @@
declare(strict_types=1);
use Doctrine\DBAL\Schema\Exception\ColumnDoesNotExist;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\QueryException;
use Illuminate\Database\Schema\Blueprint;
@@ -52,7 +51,7 @@ class ChangesForV473 extends Migration
$table->dropColumn('transaction_currency_id');
}
);
} catch (ColumnDoesNotExist|QueryException $e) {
} catch (QueryException $e) {
app('log')->error(sprintf('Could not execute query: %s', $e->getMessage()));
app('log')->error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
}
@@ -66,7 +65,7 @@ class ChangesForV473 extends Migration
$table->dropColumn('strict');
}
);
} catch (ColumnDoesNotExist|QueryException $e) {
} catch (QueryException $e) {
app('log')->error(sprintf('Could not execute query: %s', $e->getMessage()));
app('log')->error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
}

View File

@@ -22,7 +22,6 @@
declare(strict_types=1);
use Doctrine\DBAL\Schema\Exception\ColumnDoesNotExist;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\QueryException;
use Illuminate\Database\Schema\Blueprint;
@@ -52,7 +51,7 @@ class ChangesForV477 extends Migration
$table->dropColumn(['transaction_currency_id']);
}
);
} catch (ColumnDoesNotExist|QueryException $e) {
} catch (QueryException $e) {
app('log')->error(sprintf('Could not execute query: %s', $e->getMessage()));
app('log')->error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
}

View File

@@ -22,7 +22,6 @@
declare(strict_types=1);
use Doctrine\DBAL\Schema\Exception\ColumnDoesNotExist;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\QueryException;
use Illuminate\Database\Schema\Blueprint;
@@ -47,7 +46,7 @@ class ChangesForV479 extends Migration
$table->dropColumn(['enabled']);
}
);
} catch (ColumnDoesNotExist|QueryException $e) {
} catch (QueryException $e) {
app('log')->error(sprintf('Could not execute query: %s', $e->getMessage()));
app('log')->error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
}

View File

@@ -21,7 +21,6 @@
declare(strict_types=1);
use Doctrine\DBAL\Schema\Exception\ColumnDoesNotExist;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\QueryException;
use Illuminate\Database\Schema\Blueprint;
@@ -47,7 +46,7 @@ class FixLdapConfiguration extends Migration
$table->dropColumn(['objectguid']);
}
);
} catch (ColumnDoesNotExist|QueryException $e) {
} catch (QueryException $e) {
app('log')->error(sprintf('Could not execute query: %s', $e->getMessage()));
app('log')->error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
}

View File

@@ -21,7 +21,6 @@
declare(strict_types=1);
use Doctrine\DBAL\Schema\Exception\ColumnDoesNotExist;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\QueryException;
use Illuminate\Database\Schema\Blueprint;
@@ -57,7 +56,7 @@ class ChangesForV480 extends Migration
try {
$table->dropColumn('transaction_group_id');
} catch (ColumnDoesNotExist|QueryException $e) {
} catch (QueryException $e) {
app('log')->error(sprintf('Could not drop column: %s', $e->getMessage()));
app('log')->error('If the column does not exist, this is not an problem. Otherwise, please open a GitHub discussion.');
}
@@ -77,7 +76,7 @@ class ChangesForV480 extends Migration
static function (Blueprint $table): void {
try {
$table->dropColumn('stop_processing');
} catch (ColumnDoesNotExist|QueryException $e) {
} catch (QueryException $e) {
app('log')->error(sprintf('Could not drop column: %s', $e->getMessage()));
app('log')->error('If the column does not exist, this is not an problem. Otherwise, please open a GitHub discussion.');
}
@@ -97,7 +96,7 @@ class ChangesForV480 extends Migration
static function (Blueprint $table): void {
try {
$table->dropColumn('mfa_secret');
} catch (ColumnDoesNotExist|QueryException $e) {
} catch (QueryException $e) {
app('log')->error(sprintf('Could not drop column: %s', $e->getMessage()));
app('log')->error('If the column does not exist, this is not an problem. Otherwise, please open a GitHub discussion.');
}

View File

@@ -22,7 +22,6 @@
declare(strict_types=1);
use Doctrine\DBAL\Schema\Exception\ColumnDoesNotExist;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\QueryException;
use Illuminate\Database\Schema\Blueprint;
@@ -48,7 +47,7 @@ class ChangesForV530a extends Migration
$table->dropColumn('order');
}
);
} catch (ColumnDoesNotExist|QueryException $e) {
} catch (QueryException $e) {
app('log')->error(sprintf('Could not execute query: %s', $e->getMessage()));
app('log')->error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
}

View File

@@ -22,7 +22,6 @@
declare(strict_types=1);
use Doctrine\DBAL\Schema\Exception\ColumnDoesNotExist;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\QueryException;
use Illuminate\Database\Schema\Blueprint;
@@ -48,7 +47,7 @@ class ChangesForV540 extends Migration
$table->dropColumn('provider');
}
);
} catch (ColumnDoesNotExist|QueryException $e) {
} catch (QueryException $e) {
app('log')->error(sprintf('Could not execute query: %s', $e->getMessage()));
app('log')->error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
}
@@ -62,7 +61,7 @@ class ChangesForV540 extends Migration
$table->dropColumn('order');
}
);
} catch (ColumnDoesNotExist|QueryException $e) {
} catch (QueryException $e) {
app('log')->error(sprintf('Could not execute query: %s', $e->getMessage()));
app('log')->error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
}
@@ -76,7 +75,7 @@ class ChangesForV540 extends Migration
$table->dropColumn('end_date');
}
);
} catch (ColumnDoesNotExist|QueryException $e) {
} catch (QueryException $e) {
app('log')->error(sprintf('Could not execute query: %s', $e->getMessage()));
app('log')->error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
}
@@ -89,7 +88,7 @@ class ChangesForV540 extends Migration
$table->dropColumn('extension_date');
}
);
} catch (ColumnDoesNotExist|QueryException $e) {
} catch (QueryException $e) {
app('log')->error(sprintf('Could not execute query: %s', $e->getMessage()));
app('log')->error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
}

View File

@@ -22,7 +22,6 @@
declare(strict_types=1);
use Doctrine\DBAL\Schema\Exception\ColumnDoesNotExist;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\QueryException;
use Illuminate\Database\Schema\Blueprint;
@@ -76,7 +75,7 @@ class ChangesForV550 extends Migration
$table->dropColumn('budget_limit_id');
}
);
} catch (ColumnDoesNotExist|QueryException $e) {
} catch (QueryException $e) {
app('log')->error(sprintf('Could not execute query: %s', $e->getMessage()));
app('log')->error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
}
@@ -95,7 +94,7 @@ class ChangesForV550 extends Migration
$table->dropColumn('period');
}
);
} catch (ColumnDoesNotExist|QueryException $e) {
} catch (QueryException $e) {
app('log')->error(sprintf('Could not execute query: %s', $e->getMessage()));
app('log')->error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
}
@@ -108,7 +107,7 @@ class ChangesForV550 extends Migration
$table->dropColumn('generated');
}
);
} catch (ColumnDoesNotExist|QueryException $e) {
} catch (QueryException $e) {
app('log')->error(sprintf('Could not execute query: %s', $e->getMessage()));
app('log')->error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
}

View File

@@ -22,7 +22,6 @@
declare(strict_types=1);
use Doctrine\DBAL\Schema\Exception\ColumnDoesNotExist;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\QueryException;
use Illuminate\Database\Schema\Blueprint;
@@ -51,7 +50,7 @@ class ChangesForV550b2 extends Migration
}
}
);
} catch (ColumnDoesNotExist|QueryException $e) {
} catch (QueryException $e) {
app('log')->error(sprintf('Could not execute query: %s', $e->getMessage()));
app('log')->error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
}

View File

@@ -22,7 +22,6 @@
declare(strict_types=1);
use Doctrine\DBAL\Schema\Exception\ColumnDoesNotExist;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\QueryException;
use Illuminate\Database\Schema\Blueprint;
@@ -43,7 +42,7 @@ class AddLdapColumnsToUsersTable extends Migration
$table->dropColumn(['domain']);
}
);
} catch (ColumnDoesNotExist|QueryException $e) {
} catch (QueryException $e) {
app('log')->error(sprintf('Could not execute query: %s', $e->getMessage()));
app('log')->error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
}

View File

@@ -22,7 +22,6 @@
declare(strict_types=1);
use Doctrine\DBAL\Schema\Exception\ColumnDoesNotExist;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\QueryException;
use Illuminate\Database\Schema\Blueprint;
@@ -72,7 +71,7 @@ class UserGroups extends Migration
}
}
);
} catch (ColumnDoesNotExist|QueryException $e) {
} catch (QueryException $e) {
app('log')->error(sprintf('Could not execute query: %s', $e->getMessage()));
app('log')->error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
}
@@ -92,7 +91,7 @@ class UserGroups extends Migration
}
}
);
} catch (ColumnDoesNotExist|QueryException $e) {
} catch (QueryException $e) {
app('log')->error(sprintf('Could not execute query: %s', $e->getMessage()));
app('log')->error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
}

View File

@@ -22,7 +22,6 @@
declare(strict_types=1);
use Doctrine\DBAL\Schema\Exception\ColumnDoesNotExist;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\QueryException;
use Illuminate\Database\Schema\Blueprint;
@@ -69,7 +68,7 @@ return new class () extends Migration {
}
}
);
} catch (ColumnDoesNotExist|QueryException $e) {
} catch (QueryException $e) {
app('log')->error(sprintf('Could not execute query: %s', $e->getMessage()));
app('log')->error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
}

View File

@@ -22,7 +22,6 @@
declare(strict_types=1);
use Doctrine\DBAL\Schema\Exception\ColumnDoesNotExist;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\QueryException;
use Illuminate\Database\Schema\Blueprint;
@@ -71,7 +70,7 @@ return new class () extends Migration {
}
}
);
} catch (ColumnDoesNotExist|QueryException $e) {
} catch (QueryException $e) {
app('log')->error(sprintf('Could not execute query: %s', $e->getMessage()));
app('log')->error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
}

View File

@@ -9,7 +9,7 @@ use Illuminate\Support\Facades\Schema;
return new class () extends Migration {
private const string QUERY_ERROR = 'Could not execute query (table "%s", field "%s"): %s';
private const string EXPL = 'If the index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.';
private const string EXPL = 'If the index already exists (see error), or if MySQL can\'t do it, this is not an problem. Otherwise, please open a GitHub discussion.';
/**
* Run the migrations.

View File

@@ -0,0 +1,36 @@
<?php
declare(strict_types=1);
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\QueryException;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class () extends Migration {
/**
* Run the migrations.
*/
public function up(): void
{
try {
Schema::table(
'preferences',
static function (Blueprint $table): void {
if (!Schema::hasColumn('preferences', 'user_group_id')) {
$table->bigInteger('user_group_id', false, true)->nullable()->after('user_id');
$table->foreign('user_group_id', 'preferences_to_ugi')->references('id')->on('user_groups')->onDelete('set null')->onUpdate('cascade');
}
}
);
} catch (QueryException $e) {
app('log')->error(sprintf('Could not execute query: %s', $e->getMessage()));
app('log')->error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
}
}
/**
* Reverse the migrations.
*/
public function down(): void {}
};

12
package-lock.json generated
View File

@@ -432,9 +432,9 @@
}
},
"node_modules/@fortawesome/fontawesome-free": {
"version": "6.5.1",
"resolved": "https://registry.npmjs.org/@fortawesome/fontawesome-free/-/fontawesome-free-6.5.1.tgz",
"integrity": "sha512-CNy5vSwN3fsUStPRLX7fUYojyuzoEMSXPl7zSLJ8TgtRfjv24LOnOWKT2zYwaHZCJGkdyRnTmstR0P+Ah503Gw==",
"version": "6.5.2",
"resolved": "https://registry.npmjs.org/@fortawesome/fontawesome-free/-/fontawesome-free-6.5.2.tgz",
"integrity": "sha512-hRILoInAx8GNT5IMkrtIt9blOdrqHOnPBH+k70aWUAqPZPgopb9G5EQJFpaBx/S8zp2fC+mPW349Bziuk1o28Q==",
"hasInstallScript": true,
"engines": {
"node": ">=6"
@@ -479,9 +479,9 @@
"integrity": "sha512-AG2gQ0amzsdNR9+hebBGBJtOth4/GPWNiFPnNqrBLLH/jLQsbTEUnKsGj0Kg4a8aqmxJfpvjdNaK58FCQ16O1g=="
},
"node_modules/alpinejs": {
"version": "3.13.7",
"resolved": "https://registry.npmjs.org/alpinejs/-/alpinejs-3.13.7.tgz",
"integrity": "sha512-rcTyjTANbsePq1hb7eSekt3qjI94HLGeO6JaRjCssCVbIIc+qBrc7pO5S/+2JB6oojIibjM6FA+xRI3zhGPZIg==",
"version": "3.13.8",
"resolved": "https://registry.npmjs.org/alpinejs/-/alpinejs-3.13.8.tgz",
"integrity": "sha512-XolbBJryCndomtaHd/KHQjQeD/L72FJxy/YhLLFD4Lr7zzGcpcbg+UgXteMR2pYg1KhRUr6V4O3GfN1zJAmRWw==",
"dependencies": {
"@vue/reactivity": "~3.1.1"
}

View File

@@ -3,7 +3,7 @@
"html_language": "nl",
"date_time_fns": "d MMMM yyyy @ HH:mm:ss",
"month_and_day_fns": "d MMMM y",
"date_time_fns_short": "MMMM do, yyyy @ HH:mm"
"date_time_fns_short": "d MMMM yyyy @ HH:mm"
},
"validation": {
"bad_type_source": "Firefly III kan het transactietype niet bepalen op basis van deze bronrekening.",

View File

@@ -3,7 +3,7 @@
"html_language": "nl",
"date_time_fns": "d MMMM yyyy @ HH:mm:ss",
"month_and_day_fns": "d MMMM y",
"date_time_fns_short": "MMMM do, yyyy @ HH:mm"
"date_time_fns_short": "d MMMM yyyy @ HH:mm"
},
"validation": {
"bad_type_source": "Firefly III kan het transactietype niet bepalen op basis van deze bronrekening.",

View File

@@ -23,15 +23,15 @@ import format from "date-fns/format";
export default class Get {
// /**
// *
// * @param identifier
// * @param params
// * @returns {Promise<AxiosResponse<any>>}
// */
// show(identifier, params) {
// return api.get('/api/v2/accounts/' + identifier, {params: params});
// }
/**
*
* @param identifier
* @param params
* @returns {Promise<AxiosResponse<any>>}
*/
show(identifier, params) {
return api.get('/api/v2/user-groups/' + identifier, {params: params});
}
/**
*

Some files were not shown because too many files have changed in this diff Show More