mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-08-16 10:54:39 +00:00
Compare commits
121 Commits
develop-20
...
v6.2.15
Author | SHA1 | Date | |
---|---|---|---|
|
1fae39a49d | ||
|
605ab38660 | ||
|
75b21b20d8 | ||
|
e82459cd29 | ||
|
6dcf80967e | ||
|
3d9edaeaac | ||
|
659240a98b | ||
|
4a5a31bf69 | ||
|
5f73e37657 | ||
|
7a9c0a8172 | ||
|
39914e2380 | ||
|
5a3240f69d | ||
|
19e5fd6277 | ||
|
e9844dc2f5 | ||
|
c9f07c093a | ||
|
6a986d8119 | ||
|
f780de9e71 | ||
|
b830bd2732 | ||
|
e333dedeec | ||
|
6e5a08245c | ||
|
6a82a813e0 | ||
|
7992ecf7f6 | ||
|
967f7cb015 | ||
|
7ca5e03752 | ||
|
e9644c9679 | ||
|
abc6c611fa | ||
|
7673b939a1 | ||
|
c029bd42a7 | ||
|
63d051d9ba | ||
|
1ec5ee08aa | ||
|
66be8ee80e | ||
|
d26d1b4b87 | ||
|
3716b50616 | ||
|
5e398bd07a | ||
|
2ee000debb | ||
|
b8e33201bd | ||
|
1c33be4828 | ||
|
c40229e9fa | ||
|
b7ec7625c0 | ||
|
64170d4957 | ||
|
d82c3b55e0 | ||
|
01800a3534 | ||
|
01404bf9cd | ||
|
2f9d73c0b3 | ||
|
670c2e4872 | ||
|
1261122a57 | ||
|
2a17ec9280 | ||
|
1424410115 | ||
|
f20eccf279 | ||
|
c18cbe1d26 | ||
|
d5a3ae43e0 | ||
|
767abacd27 | ||
|
2b3172ba8e | ||
|
1ff8a48ca3 | ||
|
5b7645b6d5 | ||
|
ae82474b19 | ||
|
d38c59c5b1 | ||
|
a4205afb7b | ||
|
75e187ee34 | ||
|
a37ed82bb4 | ||
|
a7233de561 | ||
|
e87c5eee6b | ||
|
7a75290709 | ||
|
981f6df9ee | ||
|
c4572c66d3 | ||
|
8e7d750a5a | ||
|
94961466f9 | ||
|
0f3fe45b06 | ||
|
0650457ea5 | ||
|
2e1ce03f13 | ||
|
9b345db623 | ||
|
c1afcc5219 | ||
|
fb394b7f45 | ||
|
381598f1bb | ||
|
25b7a76da9 | ||
|
4b03ebe3cb | ||
|
664c59136a | ||
|
27b61aae73 | ||
|
d90fcd1889 | ||
|
979d5c579b | ||
|
5124ca1738 | ||
|
ac5d9b656a | ||
|
9a02739251 | ||
|
4af2aadc48 | ||
|
84779b8d02 | ||
|
145e8d23f0 | ||
|
d0ba0583a5 | ||
|
17d8b54280 | ||
|
2cf0bfe3c4 | ||
|
070a8cf148 | ||
|
f94c21446a | ||
|
1ef1873016 | ||
|
32e4e29e7c | ||
|
65ca0dd9e0 | ||
|
3385e12c01 | ||
|
3566a4afa3 | ||
|
68ff033342 | ||
|
f141b0be5c | ||
|
d399dd160f | ||
|
4c8ed784cd | ||
|
fb3402acd4 | ||
|
8cad430816 | ||
|
01502b456e | ||
|
9b6314066b | ||
|
e61dadcbc6 | ||
|
f7baf5b2fd | ||
|
0545826d57 | ||
|
a29904704c | ||
|
899d374222 | ||
|
07ff2305fd | ||
|
ee96dd3ab6 | ||
|
a766d3a133 | ||
|
67545b0371 | ||
|
6b86d825ea | ||
|
31dbc57e8b | ||
|
00050f629c | ||
|
3760aabf13 | ||
|
22e092b513 | ||
|
a4f7c90e09 | ||
|
4b92ab46a3 | ||
|
0573bf2402 |
@@ -61,7 +61,7 @@ return $config->setRules(
|
||||
'comment_to_phpdoc' => false, // breaks phpstan lines in combination with PHPStorm.
|
||||
'type_declaration_spaces' => false,
|
||||
'cast_spaces' => false,
|
||||
'phpdoc_to_comment' => false, // do not overrule single line comment style, breaks phpstan.
|
||||
'phpdoc_to_comment' => false, // do not overrule single line comment style, breaks phpstan.
|
||||
|
||||
// complex rules
|
||||
'array_syntax' => ['syntax' => 'short'],
|
||||
|
@@ -1,21 +1,70 @@
|
||||
<?php
|
||||
|
||||
|
||||
/*
|
||||
* rector.php
|
||||
* Copyright (c) 2025 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);
|
||||
|
||||
use Rector\Config\RectorConfig;
|
||||
use Rector\EarlyReturn\Rector\If_\ChangeOrIfContinueToMultiContinueRector;
|
||||
|
||||
return RectorConfig::configure()
|
||||
->withPaths([
|
||||
__DIR__ . '/../app',
|
||||
__DIR__ . '/../bootstrap',
|
||||
__DIR__ . '/../config',
|
||||
__DIR__ . '/../public',
|
||||
__DIR__ . '/../resources',
|
||||
__DIR__ . '/../routes',
|
||||
__DIR__ . '/../tests',
|
||||
])
|
||||
// uncomment to reach your current PHP version
|
||||
->withPhpSets()
|
||||
->withTypeCoverageLevel(0)
|
||||
->withDeadCodeLevel(0)
|
||||
->withCodeQualityLevel(0);
|
||||
->withSkip([
|
||||
ChangeOrIfContinueToMultiContinueRector::class,
|
||||
])
|
||||
->withPaths([
|
||||
// __DIR__ . '/../app',
|
||||
__DIR__ . '/../app/Api',
|
||||
__DIR__ . '/../app/Http',
|
||||
// __DIR__ . '/../bootstrap',
|
||||
// __DIR__ . '/../config',
|
||||
// __DIR__ . '/../public',
|
||||
// __DIR__ . '/../resources',
|
||||
// __DIR__ . '/../routes',
|
||||
// __DIR__ . '/../tests',
|
||||
])
|
||||
// uncomment to reach your current PHP version
|
||||
->withPhpSets()
|
||||
->withPreparedSets(
|
||||
codingStyle : false, // leave false
|
||||
privatization: false, // leave false.
|
||||
naming : false, // leave false
|
||||
instanceOf : true,
|
||||
earlyReturn : true,
|
||||
strictBooleans : true,
|
||||
carbon : true,
|
||||
rectorPreset : true,
|
||||
phpunitCodeQuality : true,
|
||||
doctrineCodeQuality: true,
|
||||
symfonyCodeQuality : true,
|
||||
symfonyConfigs : true
|
||||
|
||||
)
|
||||
->withComposerBased(
|
||||
twig: true,
|
||||
doctrine: true,
|
||||
phpunit: true,
|
||||
symfony: true)
|
||||
->withTypeCoverageLevel(0)
|
||||
->withDeadCodeLevel(0)
|
||||
->withCodeQualityLevel(0)
|
||||
|
||||
->withImportNames(removeUnusedImports: true);// import statements instead of full classes.
|
||||
|
@@ -289,20 +289,13 @@ ALLOW_WEBHOOKS=false
|
||||
#
|
||||
# You can set this variable from a file by appending it with _FILE
|
||||
#
|
||||
STATIC_CRON_TOKEN=
|
||||
STATIC_CRON_TOKEN=PLEASE_REPLACE_WITH_32_CHAR_CODE
|
||||
|
||||
# You can fine tune the start-up of a Docker container by editing these environment variables.
|
||||
# Use this at your own risk. Disabling certain checks and features may result in lots of inconsistent data.
|
||||
# However if you know what you're doing you can significantly speed up container start times.
|
||||
# Set each value to true to enable, or false to disable.
|
||||
|
||||
# Set this to true to build all locales supported by Firefly III.
|
||||
# This may take quite some time (several minutes) and is generally not recommended.
|
||||
# If you wish to change or alter the list of locales, start your Docker container with
|
||||
# `docker run -v locale.gen:/etc/locale.gen -e DKR_BUILD_LOCALE=true`
|
||||
# and make sure your preferred locales are in your own locale.gen.
|
||||
DKR_BUILD_LOCALE=false
|
||||
|
||||
# Check if the SQLite database exists. Can be skipped if you're not using SQLite.
|
||||
# Won't significantly speed up things.
|
||||
DKR_CHECK_SQLITE=true
|
||||
|
2
.github/workflows/close-duplicates.yml
vendored
2
.github/workflows/close-duplicates.yml
vendored
@@ -13,7 +13,7 @@ jobs:
|
||||
close_duplicates:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: github/command@v2.0.0
|
||||
- uses: github/command@v2.0.1
|
||||
id: command
|
||||
with:
|
||||
allowed_contexts: "issue"
|
||||
|
7
.github/workflows/sonarcloud.yml
vendored
7
.github/workflows/sonarcloud.yml
vendored
@@ -51,7 +51,10 @@ jobs:
|
||||
wget -q https://github.com/firefly-iii/test-fixtures/raw/refs/heads/main/test-database.sqlite -O storage/database/database.sqlite
|
||||
|
||||
- name: "Upgrades the database to the latest version"
|
||||
run: php artisan firefly-iii:upgrade-database
|
||||
run: |
|
||||
php artisan firefly-iii:upgrade-database
|
||||
chmod 600 storage/oauth-public.key
|
||||
chmod 600 storage/oauth-private.key
|
||||
|
||||
- name: "Integrity Database Report"
|
||||
run: php artisan firefly-iii:report-integrity
|
||||
@@ -63,7 +66,7 @@ jobs:
|
||||
run: sed -i 's@'$GITHUB_WORKSPACE'@/github/workspace/@g' coverage.xml
|
||||
|
||||
- name: SonarCloud Scan
|
||||
uses: SonarSource/sonarcloud-github-action@master
|
||||
uses: SonarSource/sonarqube-scan-action@v5.2.0
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GH_ACTIONS_PERSONAL_ACCESS_TOKEN }}
|
||||
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
|
||||
|
@@ -43,6 +43,7 @@ use Illuminate\Support\Facades\Log;
|
||||
class AccountController extends Controller
|
||||
{
|
||||
use AccountFilter;
|
||||
|
||||
// this array only exists to test if the constructor will use it properly.
|
||||
protected array $accepts = ['application/json', 'application/vnd.api+json'];
|
||||
|
||||
|
@@ -24,6 +24,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Api\V1\Controllers\Autocomplete;
|
||||
|
||||
use FireflyIII\Models\TransactionGroup;
|
||||
use FireflyIII\Api\V1\Controllers\Controller;
|
||||
use FireflyIII\Api\V1\Requests\Autocomplete\AutocompleteRequest;
|
||||
use FireflyIII\Enums\UserRoleEnum;
|
||||
@@ -39,11 +40,10 @@ use Illuminate\Support\Collection;
|
||||
*/
|
||||
class TransactionController extends Controller
|
||||
{
|
||||
protected array $acceptedRoles = [UserRoleEnum::READ_ONLY];
|
||||
private TransactionGroupRepositoryInterface $groupRepository;
|
||||
private JournalRepositoryInterface $repository;
|
||||
|
||||
protected array $acceptedRoles = [UserRoleEnum::READ_ONLY];
|
||||
|
||||
/**
|
||||
* TransactionController constructor.
|
||||
*/
|
||||
@@ -103,7 +103,7 @@ class TransactionController extends Controller
|
||||
if (is_numeric($data['query'])) {
|
||||
// search for group, not journal.
|
||||
$firstResult = $this->groupRepository->find((int) $data['query']);
|
||||
if (null !== $firstResult) {
|
||||
if ($firstResult instanceof TransactionGroup) {
|
||||
// group may contain multiple journals, each a result:
|
||||
foreach ($firstResult->transactionJournals as $journal) {
|
||||
$result->push($journal);
|
||||
|
@@ -24,10 +24,11 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Api\V1\Controllers\Chart;
|
||||
|
||||
use FireflyIII\Models\TransactionCurrency;
|
||||
use Carbon\Carbon;
|
||||
use FireflyIII\Api\V1\Controllers\Controller;
|
||||
use FireflyIII\Api\V1\Requests\Data\DateRequest;
|
||||
use FireflyIII\Api\V1\Requests\Chart\ChartRequest;
|
||||
use FireflyIII\Api\V1\Requests\Data\DateRequest;
|
||||
use FireflyIII\Enums\AccountTypeEnum;
|
||||
use FireflyIII\Exceptions\FireflyException;
|
||||
use FireflyIII\Models\Account;
|
||||
@@ -48,8 +49,8 @@ class AccountController extends Controller
|
||||
use ApiSupport;
|
||||
use CollectsAccountsFromFilter;
|
||||
|
||||
private AccountRepositoryInterface $repository;
|
||||
private ChartData $chartData;
|
||||
private AccountRepositoryInterface $repository;
|
||||
|
||||
/**
|
||||
* AccountController constructor.
|
||||
@@ -93,6 +94,47 @@ class AccountController extends Controller
|
||||
return response()->json($this->chartData->render());
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws FireflyException
|
||||
*/
|
||||
private function renderAccountData(array $params, Account $account): void
|
||||
{
|
||||
$currency = $this->repository->getAccountCurrency($account);
|
||||
if (!$currency instanceof TransactionCurrency) {
|
||||
$currency = $this->default;
|
||||
}
|
||||
$currentSet = [
|
||||
'label' => $account->name,
|
||||
|
||||
// the currency that belongs to the account.
|
||||
'currency_id' => (string) $currency->id,
|
||||
'currency_code' => $currency->code,
|
||||
'currency_symbol' => $currency->symbol,
|
||||
'currency_decimal_places' => $currency->decimal_places,
|
||||
|
||||
// the default currency of the user (could be the same!)
|
||||
'date' => $params['start']->toAtomString(),
|
||||
'start' => $params['start']->toAtomString(),
|
||||
'end' => $params['end']->toAtomString(),
|
||||
'period' => '1D',
|
||||
'entries' => [],
|
||||
];
|
||||
$currentStart = clone $params['start'];
|
||||
$range = Steam::finalAccountBalanceInRange($account, $params['start'], clone $params['end'], $this->convertToNative);
|
||||
|
||||
$previous = array_values($range)[0]['balance'];
|
||||
while ($currentStart <= $params['end']) {
|
||||
$format = $currentStart->format('Y-m-d');
|
||||
$label = $currentStart->toAtomString();
|
||||
$balance = array_key_exists($format, $range) ? $range[$format]['balance'] : $previous;
|
||||
$previous = $balance;
|
||||
|
||||
$currentStart->addDay();
|
||||
$currentSet['entries'][$label] = $balance;
|
||||
}
|
||||
$this->chartData->add($currentSet);
|
||||
}
|
||||
|
||||
/**
|
||||
* This endpoint is documented at:
|
||||
* https://api-docs.firefly-iii.org/?urls.primaryName=2.0.0%20(v1)#/charts/getChartAccountOverview
|
||||
@@ -162,45 +204,4 @@ class AccountController extends Controller
|
||||
|
||||
return response()->json($chartData);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws FireflyException
|
||||
*/
|
||||
private function renderAccountData(array $params, Account $account): void
|
||||
{
|
||||
$currency = $this->repository->getAccountCurrency($account);
|
||||
if (null === $currency) {
|
||||
$currency = $this->default;
|
||||
}
|
||||
$currentSet = [
|
||||
'label' => $account->name,
|
||||
|
||||
// the currency that belongs to the account.
|
||||
'currency_id' => (string) $currency->id,
|
||||
'currency_code' => $currency->code,
|
||||
'currency_symbol' => $currency->symbol,
|
||||
'currency_decimal_places' => $currency->decimal_places,
|
||||
|
||||
// the default currency of the user (could be the same!)
|
||||
'date' => $params['start']->toAtomString(),
|
||||
'start' => $params['start']->toAtomString(),
|
||||
'end' => $params['end']->toAtomString(),
|
||||
'period' => '1D',
|
||||
'entries' => [],
|
||||
];
|
||||
$currentStart = clone $params['start'];
|
||||
$range = Steam::finalAccountBalanceInRange($account, $params['start'], clone $params['end'], $this->convertToNative);
|
||||
|
||||
$previous = array_values($range)[0]['balance'];
|
||||
while ($currentStart <= $params['end']) {
|
||||
$format = $currentStart->format('Y-m-d');
|
||||
$label = $currentStart->toAtomString();
|
||||
$balance = array_key_exists($format, $range) ? $range[$format]['balance'] : $previous;
|
||||
$previous = $balance;
|
||||
|
||||
$currentStart->addDay();
|
||||
$currentSet['entries'][$label] = $balance;
|
||||
}
|
||||
$this->chartData->add($currentSet);
|
||||
}
|
||||
}
|
||||
|
@@ -40,7 +40,6 @@ use Illuminate\Foundation\Bus\DispatchesJobs;
|
||||
use Illuminate\Foundation\Validation\ValidatesRequests;
|
||||
use Illuminate\Pagination\LengthAwarePaginator;
|
||||
use Illuminate\Routing\Controller as BaseController;
|
||||
use Illuminate\Support\Collection;
|
||||
use League\Fractal\Manager;
|
||||
use League\Fractal\Pagination\IlluminatePaginatorAdapter;
|
||||
use League\Fractal\Resource\Collection as FractalCollection;
|
||||
@@ -62,15 +61,15 @@ abstract class Controller extends BaseController
|
||||
use ValidatesRequests;
|
||||
use ValidatesUserGroupTrait;
|
||||
|
||||
protected const string CONTENT_TYPE = 'application/vnd.api+json';
|
||||
protected const string JSON_CONTENT_TYPE = 'application/json';
|
||||
protected const string CONTENT_TYPE = 'application/vnd.api+json';
|
||||
protected const string JSON_CONTENT_TYPE = 'application/json';
|
||||
protected array $accepts = ['application/json', 'application/vnd.api+json'];
|
||||
|
||||
/** @var array<int, string> */
|
||||
protected array $allowedSort;
|
||||
protected ParameterBag $parameters;
|
||||
protected bool $convertToNative = false;
|
||||
protected array $accepts = ['application/json', 'application/vnd.api+json'];
|
||||
protected array $allowedSort;
|
||||
protected bool $convertToNative = false;
|
||||
protected TransactionCurrency $nativeCurrency;
|
||||
protected ParameterBag $parameters;
|
||||
|
||||
/**
|
||||
* Controller constructor.
|
||||
|
@@ -24,6 +24,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Api\V1\Controllers\Models\CurrencyExchangeRate;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use FireflyIII\Api\V1\Controllers\Controller;
|
||||
use FireflyIII\Api\V1\Requests\Models\CurrencyExchangeRate\DestroyRequest;
|
||||
use FireflyIII\Enums\UserRoleEnum;
|
||||
@@ -39,10 +40,8 @@ class DestroyController extends Controller
|
||||
{
|
||||
use ValidatesUserGroupTrait;
|
||||
|
||||
protected array $acceptedRoles = [UserRoleEnum::OWNER];
|
||||
|
||||
public const string RESOURCE_KEY = 'exchange-rates';
|
||||
|
||||
protected array $acceptedRoles = [UserRoleEnum::OWNER];
|
||||
private ExchangeRateRepositoryInterface $repository;
|
||||
|
||||
public function __construct()
|
||||
@@ -61,11 +60,11 @@ class DestroyController extends Controller
|
||||
public function destroy(DestroyRequest $request, TransactionCurrency $from, TransactionCurrency $to): JsonResponse
|
||||
{
|
||||
$date = $request->getDate();
|
||||
if (null === $date) {
|
||||
if (!$date instanceof Carbon) {
|
||||
throw new ValidationException('Date is required');
|
||||
}
|
||||
$rate = $this->repository->getSpecificRateOnDate($from, $to, $date);
|
||||
if (null === $rate) {
|
||||
if (!$rate instanceof CurrencyExchangeRate) {
|
||||
throw new NotFoundHttpException();
|
||||
}
|
||||
$this->repository->deleteRate($rate);
|
||||
|
@@ -24,6 +24,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Api\V1\Controllers\Models\CurrencyExchangeRate;
|
||||
|
||||
use FireflyIII\Models\CurrencyExchangeRate;
|
||||
use FireflyIII\Api\V1\Requests\Models\CurrencyExchangeRate\StoreRequest;
|
||||
use FireflyIII\Api\V2\Controllers\Controller;
|
||||
use FireflyIII\Repositories\ExchangeRate\ExchangeRateRepositoryInterface;
|
||||
@@ -61,11 +62,11 @@ class StoreController extends Controller
|
||||
|
||||
// already has rate?
|
||||
$object = $this->repository->getSpecificRateOnDate($from, $to, $date);
|
||||
if (null !== $object) {
|
||||
if ($object instanceof CurrencyExchangeRate) {
|
||||
// just update it, no matter.
|
||||
$rate = $this->repository->updateExchangeRate($object, $rate, $date);
|
||||
}
|
||||
if (null === $object) {
|
||||
if (!$object instanceof CurrencyExchangeRate) {
|
||||
// store new
|
||||
$rate = $this->repository->storeExchangeRate($from, $to, $rate, $date);
|
||||
}
|
||||
|
@@ -50,9 +50,8 @@ class StoreController extends Controller
|
||||
{
|
||||
use TransactionFilter;
|
||||
|
||||
private TransactionGroupRepositoryInterface $groupRepository;
|
||||
|
||||
protected array $acceptedRoles = [UserRoleEnum::MANAGE_TRANSACTIONS];
|
||||
private TransactionGroupRepositoryInterface $groupRepository;
|
||||
|
||||
/**
|
||||
* TransactionController constructor.
|
||||
|
@@ -24,11 +24,12 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Api\V1\Controllers\Models\TransactionCurrency;
|
||||
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use FireflyIII\Api\V1\Controllers\Controller;
|
||||
use FireflyIII\Exceptions\FireflyException;
|
||||
use FireflyIII\Models\TransactionCurrency;
|
||||
use FireflyIII\Repositories\User\UserRepositoryInterface;
|
||||
use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;
|
||||
use FireflyIII\Repositories\User\UserRepositoryInterface;
|
||||
use FireflyIII\User;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
|
||||
@@ -74,15 +75,15 @@ class DestroyController extends Controller
|
||||
if (!$this->userRepository->hasRole($admin, 'owner')) {
|
||||
// access denied:
|
||||
$messages = ['currency_code' => '200005: You need the "owner" role to do this.'];
|
||||
\Validator::make([], $rules, $messages)->validate();
|
||||
Validator::make([], $rules, $messages)->validate();
|
||||
}
|
||||
if ($this->repository->currencyInUse($currency)) {
|
||||
$messages = ['currency_code' => '200006: Currency in use.'];
|
||||
\Validator::make([], $rules, $messages)->validate();
|
||||
Validator::make([], $rules, $messages)->validate();
|
||||
}
|
||||
if ($this->repository->isFallbackCurrency($currency)) {
|
||||
$messages = ['currency_code' => '200026: Currency is fallback.'];
|
||||
\Validator::make([], $rules, $messages)->validate();
|
||||
Validator::make([], $rules, $messages)->validate();
|
||||
}
|
||||
|
||||
$this->repository->destroy($currency);
|
||||
|
@@ -24,6 +24,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Api\V1\Controllers\Models\TransactionLink;
|
||||
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
use FireflyIII\Api\V1\Controllers\Controller;
|
||||
use FireflyIII\Api\V1\Requests\Models\TransactionLink\StoreRequest;
|
||||
use FireflyIII\Exceptions\FireflyException;
|
||||
@@ -81,7 +82,7 @@ class StoreController extends Controller
|
||||
$data = $request->getAll();
|
||||
$inward = $this->journalRepository->find($data['inward_id'] ?? 0);
|
||||
$outward = $this->journalRepository->find($data['outward_id'] ?? 0);
|
||||
if (null === $inward || null === $outward) {
|
||||
if (!$inward instanceof TransactionJournal || !$outward instanceof TransactionJournal) {
|
||||
throw new FireflyException('200024: Source or destination does not exist.');
|
||||
}
|
||||
$data['direction'] = 'inward';
|
||||
|
@@ -24,6 +24,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Api\V1\Controllers\Models\TransactionLinkType;
|
||||
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use FireflyIII\Api\V1\Controllers\Controller;
|
||||
use FireflyIII\Api\V1\Requests\Models\TransactionLinkType\StoreRequest;
|
||||
use FireflyIII\Exceptions\FireflyException;
|
||||
@@ -81,7 +82,7 @@ class StoreController extends Controller
|
||||
if (!$this->userRepository->hasRole($admin, 'owner')) {
|
||||
// access denied:
|
||||
$messages = ['name' => '200005: You need the "owner" role to do this.'];
|
||||
\Validator::make([], $rules, $messages)->validate();
|
||||
Validator::make([], $rules, $messages)->validate();
|
||||
}
|
||||
$data = $request->getAll();
|
||||
// if currency ID is 0, find the currency by the code:
|
||||
|
@@ -24,6 +24,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Api\V1\Controllers\Models\TransactionLinkType;
|
||||
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use FireflyIII\Api\V1\Controllers\Controller;
|
||||
use FireflyIII\Api\V1\Requests\Models\TransactionLinkType\UpdateRequest;
|
||||
use FireflyIII\Exceptions\FireflyException;
|
||||
@@ -85,7 +86,7 @@ class UpdateController extends Controller
|
||||
|
||||
if (!$this->userRepository->hasRole($admin, 'owner')) {
|
||||
$messages = ['name' => '200005: You need the "owner" role to do this.'];
|
||||
\Validator::make([], $rules, $messages)->validate();
|
||||
Validator::make([], $rules, $messages)->validate();
|
||||
}
|
||||
|
||||
$data = $request->getAll();
|
||||
|
@@ -483,7 +483,7 @@ class BasicController extends Controller
|
||||
|
||||
// first, create an entry for each entry in the "available" array.
|
||||
/** @var array $availableBudget */
|
||||
foreach ($available as $currencyId => $availableBudget) {
|
||||
foreach ($available as $currencyId => $availableBudget) {
|
||||
$currencies[$currencyId] ??= $this->currencyRepos->find($currencyId);
|
||||
$return[$currencyId] = [
|
||||
'key' => sprintf('left-to-spend-in-%s', $currencies[$currencyId]->code),
|
||||
@@ -674,15 +674,14 @@ class BasicController extends Controller
|
||||
*/
|
||||
protected function notInDateRange(Carbon $date, Carbon $start, Carbon $end): bool // Validate a preference
|
||||
{
|
||||
$result = false;
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
@@ -24,6 +24,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Api\V1\Controllers\System;
|
||||
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use FireflyIII\Api\V1\Controllers\Controller;
|
||||
use FireflyIII\Api\V1\Requests\System\UpdateRequest;
|
||||
use FireflyIII\Exceptions\FireflyException;
|
||||
@@ -158,7 +159,7 @@ class ConfigurationController extends Controller
|
||||
$rules = ['value' => 'required'];
|
||||
if (!$this->repository->hasRole(auth()->user(), 'owner')) {
|
||||
$messages = ['value' => '200005: You need the "owner" role to do this.'];
|
||||
\Validator::make([], $rules, $messages)->validate();
|
||||
Validator::make([], $rules, $messages)->validate();
|
||||
}
|
||||
$data = $request->getAll();
|
||||
$shortName = str_replace('configuration.', '', $name);
|
||||
|
@@ -45,7 +45,7 @@ class DestroyRequest extends FormRequest
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'date' => 'required|date|after:1900-01-01|before:2099-12-31',
|
||||
'date' => 'required|date|after:1900-01-01|before:2099-12-31',
|
||||
];
|
||||
}
|
||||
}
|
||||
|
@@ -40,16 +40,16 @@ class StoreRequest extends FormRequest
|
||||
return $this->getCarbonDate('date');
|
||||
}
|
||||
|
||||
public function getRate(): string
|
||||
{
|
||||
return (string) $this->get('rate');
|
||||
}
|
||||
|
||||
public function getFromCurrency(): TransactionCurrency
|
||||
{
|
||||
return TransactionCurrency::where('code', $this->get('from'))->first();
|
||||
}
|
||||
|
||||
public function getRate(): string
|
||||
{
|
||||
return (string) $this->get('rate');
|
||||
}
|
||||
|
||||
public function getToCurrency(): TransactionCurrency
|
||||
{
|
||||
return TransactionCurrency::where('code', $this->get('to'))->first();
|
||||
|
@@ -50,8 +50,8 @@ class UpdateRequest extends FormRequest
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'date' => 'date|after:1900-01-01|before:2099-12-31',
|
||||
'rate' => 'required|numeric|gt:0',
|
||||
'date' => 'date|after:1900-01-01|before:2099-12-31',
|
||||
'rate' => 'required|numeric|gt:0',
|
||||
];
|
||||
}
|
||||
}
|
||||
|
@@ -83,87 +83,87 @@ class StoreRequest extends FormRequest
|
||||
foreach ($this->get('transactions') as $transaction) {
|
||||
$object = new NullArrayObject($transaction);
|
||||
$return[] = [
|
||||
'type' => $this->clearString($object['type']),
|
||||
'date' => $this->dateFromValue($object['date']),
|
||||
'order' => $this->integerFromValue((string) $object['order']),
|
||||
'type' => $this->clearString($object['type']),
|
||||
'date' => $this->dateFromValue($object['date']),
|
||||
'order' => $this->integerFromValue((string) $object['order']),
|
||||
|
||||
'currency_id' => $this->integerFromValue((string) $object['currency_id']),
|
||||
'currency_code' => $this->clearString((string) $object['currency_code']),
|
||||
'currency_id' => $this->integerFromValue((string) $object['currency_id']),
|
||||
'currency_code' => $this->clearString((string) $object['currency_code']),
|
||||
|
||||
// location
|
||||
'latitude' => $this->floatFromValue((string) $object['latitude']),
|
||||
'longitude' => $this->floatFromValue((string) $object['longitude']),
|
||||
'zoom_level' => $this->integerFromValue((string) $object['zoom_level']),
|
||||
'latitude' => $this->floatFromValue((string) $object['latitude']),
|
||||
'longitude' => $this->floatFromValue((string) $object['longitude']),
|
||||
'zoom_level' => $this->integerFromValue((string) $object['zoom_level']),
|
||||
|
||||
// foreign currency info:
|
||||
'foreign_currency_id' => $this->integerFromValue((string) $object['foreign_currency_id']),
|
||||
'foreign_currency_code' => $this->clearString((string) $object['foreign_currency_code']),
|
||||
'foreign_currency_id' => $this->integerFromValue((string) $object['foreign_currency_id']),
|
||||
'foreign_currency_code' => $this->clearString((string) $object['foreign_currency_code']),
|
||||
|
||||
// amount and foreign amount. Cannot be 0.
|
||||
'amount' => $this->clearString((string) $object['amount']),
|
||||
'foreign_amount' => $this->clearString((string) $object['foreign_amount']),
|
||||
'amount' => $this->clearString((string) $object['amount']),
|
||||
'foreign_amount' => $this->clearString((string) $object['foreign_amount']),
|
||||
|
||||
// description.
|
||||
'description' => $this->clearString($object['description']),
|
||||
'description' => $this->clearString($object['description']),
|
||||
|
||||
// source of transaction. If everything is null, assume cash account.
|
||||
'source_id' => $this->integerFromValue((string) $object['source_id']),
|
||||
'source_name' => $this->clearString((string) $object['source_name']),
|
||||
'source_iban' => $this->clearIban((string) $object['source_iban']),
|
||||
'source_number' => $this->clearString((string) $object['source_number']),
|
||||
'source_bic' => $this->clearString((string) $object['source_bic']),
|
||||
'source_id' => $this->integerFromValue((string) $object['source_id']),
|
||||
'source_name' => $this->clearString((string) $object['source_name']),
|
||||
'source_iban' => $this->clearIban((string) $object['source_iban']),
|
||||
'source_number' => $this->clearString((string) $object['source_number']),
|
||||
'source_bic' => $this->clearString((string) $object['source_bic']),
|
||||
|
||||
// destination of transaction. If everything is null, assume cash account.
|
||||
'destination_id' => $this->integerFromValue((string) $object['destination_id']),
|
||||
'destination_name' => $this->clearString((string) $object['destination_name']),
|
||||
'destination_iban' => $this->clearIban((string) $object['destination_iban']),
|
||||
'destination_number' => $this->clearString((string) $object['destination_number']),
|
||||
'destination_bic' => $this->clearString((string) $object['destination_bic']),
|
||||
'destination_id' => $this->integerFromValue((string) $object['destination_id']),
|
||||
'destination_name' => $this->clearString((string) $object['destination_name']),
|
||||
'destination_iban' => $this->clearIban((string) $object['destination_iban']),
|
||||
'destination_number' => $this->clearString((string) $object['destination_number']),
|
||||
'destination_bic' => $this->clearString((string) $object['destination_bic']),
|
||||
|
||||
// budget info
|
||||
'budget_id' => $this->integerFromValue((string) $object['budget_id']),
|
||||
'budget_name' => $this->clearString((string) $object['budget_name']),
|
||||
'budget_id' => $this->integerFromValue((string) $object['budget_id']),
|
||||
'budget_name' => $this->clearString((string) $object['budget_name']),
|
||||
|
||||
// category info
|
||||
'category_id' => $this->integerFromValue((string) $object['category_id']),
|
||||
'category_name' => $this->clearString((string) $object['category_name']),
|
||||
'category_id' => $this->integerFromValue((string) $object['category_id']),
|
||||
'category_name' => $this->clearString((string) $object['category_name']),
|
||||
|
||||
// journal bill reference. Optional. Will only work for withdrawals
|
||||
'bill_id' => $this->integerFromValue((string) $object['bill_id']),
|
||||
'bill_name' => $this->clearString((string) $object['bill_name']),
|
||||
'bill_id' => $this->integerFromValue((string) $object['bill_id']),
|
||||
'bill_name' => $this->clearString((string) $object['bill_name']),
|
||||
|
||||
// piggy bank reference. Optional. Will only work for transfers
|
||||
'piggy_bank_id' => $this->integerFromValue((string) $object['piggy_bank_id']),
|
||||
'piggy_bank_name' => $this->clearString((string) $object['piggy_bank_name']),
|
||||
'piggy_bank_id' => $this->integerFromValue((string) $object['piggy_bank_id']),
|
||||
'piggy_bank_name' => $this->clearString((string) $object['piggy_bank_name']),
|
||||
|
||||
// some other interesting properties
|
||||
'reconciled' => $this->convertBoolean((string) $object['reconciled']),
|
||||
'notes' => $this->clearStringKeepNewlines((string) $object['notes']),
|
||||
'tags' => $this->arrayFromValue($object['tags']),
|
||||
'reconciled' => $this->convertBoolean((string) $object['reconciled']),
|
||||
'notes' => $this->clearStringKeepNewlines((string) $object['notes']),
|
||||
'tags' => $this->arrayFromValue($object['tags']),
|
||||
|
||||
// all custom fields:
|
||||
'internal_reference' => $this->clearString((string) $object['internal_reference']),
|
||||
'external_id' => $this->clearString((string) $object['external_id']),
|
||||
'original_source' => sprintf('ff3-v%s', config('firefly.version')),
|
||||
'recurrence_id' => $this->integerFromValue($object['recurrence_id']),
|
||||
'bunq_payment_id' => $this->clearString((string) $object['bunq_payment_id']),
|
||||
'external_url' => $this->clearString((string) $object['external_url']),
|
||||
'internal_reference' => $this->clearString((string) $object['internal_reference']),
|
||||
'external_id' => $this->clearString((string) $object['external_id']),
|
||||
'original_source' => sprintf('ff3-v%s', config('firefly.version')),
|
||||
'recurrence_id' => $this->integerFromValue($object['recurrence_id']),
|
||||
'bunq_payment_id' => $this->clearString((string) $object['bunq_payment_id']),
|
||||
'external_url' => $this->clearString((string) $object['external_url']),
|
||||
|
||||
'sepa_cc' => $this->clearString((string) $object['sepa_cc']),
|
||||
'sepa_ct_op' => $this->clearString((string) $object['sepa_ct_op']),
|
||||
'sepa_ct_id' => $this->clearString((string) $object['sepa_ct_id']),
|
||||
'sepa_db' => $this->clearString((string) $object['sepa_db']),
|
||||
'sepa_country' => $this->clearString((string) $object['sepa_country']),
|
||||
'sepa_ep' => $this->clearString((string) $object['sepa_ep']),
|
||||
'sepa_ci' => $this->clearString((string) $object['sepa_ci']),
|
||||
'sepa_batch_id' => $this->clearString((string) $object['sepa_batch_id']),
|
||||
'sepa_cc' => $this->clearString((string) $object['sepa_cc']),
|
||||
'sepa_ct_op' => $this->clearString((string) $object['sepa_ct_op']),
|
||||
'sepa_ct_id' => $this->clearString((string) $object['sepa_ct_id']),
|
||||
'sepa_db' => $this->clearString((string) $object['sepa_db']),
|
||||
'sepa_country' => $this->clearString((string) $object['sepa_country']),
|
||||
'sepa_ep' => $this->clearString((string) $object['sepa_ep']),
|
||||
'sepa_ci' => $this->clearString((string) $object['sepa_ci']),
|
||||
'sepa_batch_id' => $this->clearString((string) $object['sepa_batch_id']),
|
||||
// custom date fields. Must be Carbon objects. Presence is optional.
|
||||
'interest_date' => $this->dateFromValue($object['interest_date']),
|
||||
'book_date' => $this->dateFromValue($object['book_date']),
|
||||
'process_date' => $this->dateFromValue($object['process_date']),
|
||||
'due_date' => $this->dateFromValue($object['due_date']),
|
||||
'payment_date' => $this->dateFromValue($object['payment_date']),
|
||||
'invoice_date' => $this->dateFromValue($object['invoice_date']),
|
||||
'interest_date' => $this->dateFromValue($object['interest_date']),
|
||||
'book_date' => $this->dateFromValue($object['book_date']),
|
||||
'process_date' => $this->dateFromValue($object['process_date']),
|
||||
'due_date' => $this->dateFromValue($object['due_date']),
|
||||
'payment_date' => $this->dateFromValue($object['payment_date']),
|
||||
'invoice_date' => $this->dateFromValue($object['invoice_date']),
|
||||
];
|
||||
}
|
||||
|
||||
|
@@ -24,6 +24,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Api\V1\Requests\System;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use FireflyIII\Support\Request\ConvertsDataTypes;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
@@ -58,7 +59,7 @@ class CronRequest extends FormRequest
|
||||
$data['date'] = $this->getCarbonDate('date');
|
||||
}
|
||||
// catch NULL.
|
||||
if (null === $data['date']) {
|
||||
if (!$data['date'] instanceof Carbon) {
|
||||
$data['date'] = today(config('app.timezone'));
|
||||
}
|
||||
|
||||
|
@@ -90,7 +90,7 @@ class AccountController extends Controller
|
||||
'meta' => [
|
||||
'type' => $account->accountType->type,
|
||||
// TODO is multi currency property.
|
||||
'currency_id' => null === $currency ? null : (string) $currency->id,
|
||||
'currency_id' => $currency instanceof TransactionCurrency ? (string) $currency->id : null,
|
||||
'currency_code' => $currency?->code,
|
||||
'currency_symbol' => $currency?->symbol,
|
||||
'currency_decimal_places' => $currency?->decimal_places,
|
||||
|
@@ -94,7 +94,7 @@ class AccountController extends Controller
|
||||
private function renderAccountData(array $params, Account $account): void
|
||||
{
|
||||
$currency = $this->repository->getAccountCurrency($account);
|
||||
if (null === $currency) {
|
||||
if (!$currency instanceof TransactionCurrency) {
|
||||
$currency = $this->default;
|
||||
}
|
||||
$currentSet = [
|
||||
|
@@ -33,7 +33,6 @@ use FireflyIII\Transformers\AbstractTransformer;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Pagination\LengthAwarePaginator;
|
||||
use Illuminate\Routing\Controller as BaseController;
|
||||
use Illuminate\Support\Collection;
|
||||
use League\Fractal\Manager;
|
||||
use League\Fractal\Pagination\IlluminatePaginatorAdapter;
|
||||
use League\Fractal\Resource\Collection as FractalCollection;
|
||||
@@ -56,8 +55,8 @@ class Controller extends BaseController
|
||||
|
||||
protected const string CONTENT_TYPE = 'application/vnd.api+json';
|
||||
protected array $acceptedRoles = [UserRoleEnum::READ_ONLY];
|
||||
protected ParameterBag $parameters;
|
||||
protected bool $convertToNative = false;
|
||||
protected ParameterBag $parameters;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
@@ -118,7 +117,7 @@ class Controller extends BaseController
|
||||
app('log')->warning(sprintf('Ignored invalid date "%s" in API v2 controller parameter check: %s', substr((string) $date, 0, 20), $e->getMessage()));
|
||||
}
|
||||
// out of range? set to null.
|
||||
if (null !== $obj && ($obj->year <= 1900 || $obj->year > 2099)) {
|
||||
if ($obj instanceof Carbon && ($obj->year <= 1900 || $obj->year > 2099)) {
|
||||
app('log')->warning(sprintf('Refuse to use date "%s" in API v2 controller parameter check: %s', $field, $obj->toAtomString()));
|
||||
$obj = null;
|
||||
}
|
||||
|
@@ -398,15 +398,14 @@ class BasicController extends Controller
|
||||
*/
|
||||
protected function notInDateRange(Carbon $date, Carbon $start, Carbon $end): bool // Validate a preference
|
||||
{
|
||||
$result = false;
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
@@ -24,6 +24,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Api\V2\Controllers\Transaction\List;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use FireflyIII\Api\V2\Controllers\Controller;
|
||||
use FireflyIII\Api\V2\Request\Model\Transaction\ListRequest;
|
||||
use FireflyIII\Helpers\Collector\GroupCollectorInterface;
|
||||
@@ -62,11 +63,11 @@ class AccountController extends Controller
|
||||
|
||||
$start = $request->getStartDate();
|
||||
$end = $request->getEndDate();
|
||||
if (null !== $start) {
|
||||
if ($start instanceof Carbon) {
|
||||
app('log')->debug(sprintf('Set start date to %s', $start->toIso8601String()));
|
||||
$collector->setStart($start);
|
||||
}
|
||||
if (null !== $end) {
|
||||
if ($end instanceof Carbon) {
|
||||
app('log')->debug(sprintf('Set end date to %s', $start->toIso8601String()));
|
||||
$collector->setEnd($end);
|
||||
}
|
||||
|
@@ -53,7 +53,7 @@ class InfiniteListRequest extends FormRequest
|
||||
|
||||
$start = $this->getStartDate();
|
||||
$end = $this->getEndDate();
|
||||
if (null !== $start && null !== $end) {
|
||||
if ($start instanceof Carbon && $end instanceof Carbon) {
|
||||
$array['start'] = $start->format('Y-m-d');
|
||||
$array['end'] = $end->format('Y-m-d');
|
||||
}
|
||||
|
@@ -49,7 +49,7 @@ class ListRequest extends FormRequest
|
||||
|
||||
$start = $this->getStartDate();
|
||||
$end = $this->getEndDate();
|
||||
if (null !== $start && null !== $end) {
|
||||
if ($start instanceof Carbon && $end instanceof Carbon) {
|
||||
$array['start'] = $start->format('Y-m-d');
|
||||
$array['end'] = $end->format('Y-m-d');
|
||||
}
|
||||
|
@@ -75,6 +75,65 @@ class CorrectsAmounts extends Command
|
||||
return 0;
|
||||
}
|
||||
|
||||
private function correctTransfers(): void
|
||||
{
|
||||
/** @var AccountRepositoryInterface $repository */
|
||||
$repository = app(AccountRepositoryInterface::class);
|
||||
$type = TransactionType::where('type', TransactionTypeEnum::TRANSFER->value)->first();
|
||||
$journals = TransactionJournal::where('transaction_type_id', $type->id)->get();
|
||||
|
||||
/** @var TransactionJournal $journal */
|
||||
foreach ($journals as $journal) {
|
||||
$repository->setUser($journal->user);
|
||||
$native = Amount::getNativeCurrencyByUserGroup($journal->userGroup);
|
||||
|
||||
/** @var null|Transaction $source */
|
||||
$source = $journal->transactions()->where('amount', '<', 0)->first();
|
||||
|
||||
/** @var null|Transaction $destination */
|
||||
$destination = $journal->transactions()->where('amount', '>', 0)->first();
|
||||
if (null === $source || null === $destination) {
|
||||
continue;
|
||||
}
|
||||
if (null === $source->foreign_currency_id || null === $destination->foreign_currency_id) {
|
||||
continue;
|
||||
}
|
||||
$sourceAccount = $source->account;
|
||||
$destAccount = $destination->account;
|
||||
if (null === $sourceAccount || null === $destAccount) {
|
||||
continue;
|
||||
}
|
||||
$sourceCurrency = $repository->getAccountCurrency($sourceAccount) ?? $native;
|
||||
$destCurrency = $repository->getAccountCurrency($destAccount) ?? $native;
|
||||
|
||||
if ($sourceCurrency->id === $destCurrency->id) {
|
||||
Log::debug('Both accounts have the same currency. Removing foreign currency info.');
|
||||
$source->foreign_currency_id = null;
|
||||
$source->foreign_amount = null;
|
||||
$source->save();
|
||||
$destination->foreign_currency_id = null;
|
||||
$destination->foreign_amount = null;
|
||||
$destination->save();
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
// validate source
|
||||
if ($destCurrency->id !== $source->foreign_currency_id) {
|
||||
Log::debug(sprintf('Journal #%d: Transaction #%d refers to "%s" but should refer to "%s".', $journal->id, $source->id, $source->foreignCurrency->code, $destCurrency->code));
|
||||
$source->foreign_currency_id = $destCurrency->id;
|
||||
$source->save();
|
||||
}
|
||||
|
||||
// validate destination:
|
||||
if ($sourceCurrency->id !== $destination->foreign_currency_id) {
|
||||
Log::debug(sprintf('Journal #%d: Transaction #%d refers to "%s" but should refer to "%s".', $journal->id, $destination->id, $destination->foreignCurrency->code, $sourceCurrency->code));
|
||||
$destination->foreign_currency_id = $sourceCurrency->id;
|
||||
$destination->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function fixAutoBudgets(): void
|
||||
{
|
||||
$count = AutoBudget::where('amount', '<', 0)->update(['amount' => DB::raw('amount * -1')]);
|
||||
@@ -192,63 +251,4 @@ class CorrectsAmounts extends Command
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private function correctTransfers(): void
|
||||
{
|
||||
/** @var AccountRepositoryInterface $repository */
|
||||
$repository = app(AccountRepositoryInterface::class);
|
||||
$type = TransactionType::where('type', TransactionTypeEnum::TRANSFER->value)->first();
|
||||
$journals = TransactionJournal::where('transaction_type_id', $type->id)->get();
|
||||
|
||||
/** @var TransactionJournal $journal */
|
||||
foreach ($journals as $journal) {
|
||||
$repository->setUser($journal->user);
|
||||
$native = Amount::getNativeCurrencyByUserGroup($journal->userGroup);
|
||||
|
||||
/** @var null|Transaction $source */
|
||||
$source = $journal->transactions()->where('amount', '<', 0)->first();
|
||||
|
||||
/** @var null|Transaction $destination */
|
||||
$destination = $journal->transactions()->where('amount', '>', 0)->first();
|
||||
if (null === $source || null === $destination) {
|
||||
continue;
|
||||
}
|
||||
if (null === $source->foreign_currency_id || null === $destination->foreign_currency_id) {
|
||||
continue;
|
||||
}
|
||||
$sourceAccount = $source->account;
|
||||
$destAccount = $destination->account;
|
||||
if (null === $sourceAccount || null === $destAccount) {
|
||||
continue;
|
||||
}
|
||||
$sourceCurrency = $repository->getAccountCurrency($sourceAccount) ?? $native;
|
||||
$destCurrency = $repository->getAccountCurrency($destAccount) ?? $native;
|
||||
|
||||
if ($sourceCurrency->id === $destCurrency->id) {
|
||||
Log::debug('Both accounts have the same currency. Removing foreign currency info.');
|
||||
$source->foreign_currency_id = null;
|
||||
$source->foreign_amount = null;
|
||||
$source->save();
|
||||
$destination->foreign_currency_id = null;
|
||||
$destination->foreign_amount = null;
|
||||
$destination->save();
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
// validate source
|
||||
if ($destCurrency->id !== $source->foreign_currency_id) {
|
||||
Log::debug(sprintf('Journal #%d: Transaction #%d refers to "%s" but should refer to "%s".', $journal->id, $source->id, $source->foreignCurrency->code, $destCurrency->code));
|
||||
$source->foreign_currency_id = $destCurrency->id;
|
||||
$source->save();
|
||||
}
|
||||
|
||||
// validate destination:
|
||||
if ($sourceCurrency->id !== $destination->foreign_currency_id) {
|
||||
Log::debug(sprintf('Journal #%d: Transaction #%d refers to "%s" but should refer to "%s".', $journal->id, $destination->id, $destination->foreignCurrency->code, $sourceCurrency->code));
|
||||
$destination->foreign_currency_id = $sourceCurrency->id;
|
||||
$destination->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -26,6 +26,7 @@ namespace FireflyIII\Console\Commands\Correction;
|
||||
|
||||
use FireflyIII\Console\Commands\ShowsFriendlyMessages;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CorrectsDatabase extends Command
|
||||
{
|
||||
@@ -40,7 +41,7 @@ class CorrectsDatabase extends Command
|
||||
public function handle(): int
|
||||
{
|
||||
// if table does not exist, return false
|
||||
if (!\Schema::hasTable('users')) {
|
||||
if (!Schema::hasTable('users')) {
|
||||
$this->friendlyError('No "users"-table, will not continue.');
|
||||
|
||||
return 1;
|
||||
|
@@ -38,8 +38,8 @@ use FireflyIII\Models\PiggyBankEvent;
|
||||
use FireflyIII\Models\Transaction;
|
||||
use FireflyIII\Models\TransactionCurrency;
|
||||
use FireflyIII\Models\UserGroup;
|
||||
use FireflyIII\Repositories\UserGroup\UserGroupRepositoryInterface;
|
||||
use FireflyIII\Repositories\PiggyBank\PiggyBankRepositoryInterface;
|
||||
use FireflyIII\Repositories\UserGroup\UserGroupRepositoryInterface;
|
||||
use FireflyIII\Support\Facades\Preferences;
|
||||
use FireflyIII\Support\Http\Api\ExchangeRateConverter;
|
||||
use Illuminate\Console\Command;
|
||||
|
@@ -25,9 +25,11 @@ declare(strict_types=1);
|
||||
namespace FireflyIII\Console\Commands\Correction;
|
||||
|
||||
use FireflyIII\Console\Commands\ShowsFriendlyMessages;
|
||||
use FireflyIII\Enums\AccountTypeEnum;
|
||||
use FireflyIII\Enums\TransactionTypeEnum;
|
||||
use FireflyIII\Models\Transaction;
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||
use FireflyIII\Support\Models\AccountBalanceCalculator;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
@@ -47,7 +49,12 @@ class CorrectsUnevenAmount extends Command
|
||||
public function handle(): int
|
||||
{
|
||||
$this->count = 0;
|
||||
// convert transfers with foreign currency info where the amount is NOT uneven (it should be)
|
||||
$this->convertOldStyleTransfers();
|
||||
|
||||
// convert old-style transactions between assets and liabilities.
|
||||
$this->convertOldStyleTransactions();
|
||||
|
||||
$this->fixUnevenAmounts();
|
||||
$this->matchCurrencies();
|
||||
if (true === config('firefly.feature_flags.running_balance_column')) {
|
||||
@@ -72,8 +79,6 @@ class CorrectsUnevenAmount extends Command
|
||||
;
|
||||
$count = 0;
|
||||
|
||||
Log::debug(sprintf('Found %d potential journal(s)', $transactions->count()));
|
||||
|
||||
/** @var Transaction $transaction */
|
||||
foreach ($transactions as $transaction) {
|
||||
/** @var null|TransactionJournal $journal */
|
||||
@@ -115,10 +120,15 @@ class CorrectsUnevenAmount extends Command
|
||||
++$count;
|
||||
}
|
||||
}
|
||||
if (0 === $count) {
|
||||
return;
|
||||
}
|
||||
$this->friendlyPositive(sprintf('Fixed %d transfer(s) with unbalanced amounts.', $count));
|
||||
}
|
||||
|
||||
private function fixUnevenAmounts(): void
|
||||
{
|
||||
Log::debug('fixUnevenAmounts()');
|
||||
$journals = DB::table('transactions')
|
||||
->groupBy('transaction_journal_id')
|
||||
->whereNull('deleted_at')
|
||||
@@ -153,7 +163,7 @@ class CorrectsUnevenAmount extends Command
|
||||
Log::error($e->getTraceAsString());
|
||||
}
|
||||
if (0 !== $res) {
|
||||
$this->fixJournal($entry->transaction_journal_id);
|
||||
$this->fixJournal((int) $entry->transaction_journal_id);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -207,8 +217,8 @@ class CorrectsUnevenAmount extends Command
|
||||
}
|
||||
|
||||
// may still be able to salvage this journal if it is a transfer with foreign currency info
|
||||
if ($this->isForeignCurrencyTransfer($journal)) {
|
||||
Log::debug(sprintf('Can skip foreign currency transfer #%d.', $journal->id));
|
||||
if ($this->isForeignCurrencyTransfer($journal) || $this->isBetweenAssetAndLiability($journal)) {
|
||||
Log::debug(sprintf('Can skip foreign currency transfer / asset+liability transaction #%d.', $journal->id));
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -271,13 +281,13 @@ class CorrectsUnevenAmount extends Command
|
||||
|
||||
/** @var TransactionJournal $journal */
|
||||
foreach ($journals as $journal) {
|
||||
if (!$this->isForeignCurrencyTransfer($journal)) {
|
||||
if (!$this->isForeignCurrencyTransfer($journal) && !$this->isBetweenAssetAndLiability($journal)) {
|
||||
Transaction::where('transaction_journal_id', $journal->id)->update(['transaction_currency_id' => $journal->transaction_currency_id]);
|
||||
++$count;
|
||||
|
||||
continue;
|
||||
}
|
||||
Log::debug(sprintf('Can skip foreign currency transfer #%d.', $journal->id));
|
||||
Log::debug(sprintf('Can skip foreign currency transfer or transaction between asset and liability #%d.', $journal->id));
|
||||
}
|
||||
if (0 === $count) {
|
||||
return;
|
||||
@@ -285,4 +295,155 @@ class CorrectsUnevenAmount extends Command
|
||||
|
||||
$this->friendlyPositive(sprintf('Fixed %d journal(s) with mismatched currencies.', $journals->count()));
|
||||
}
|
||||
|
||||
private function isBetweenAssetAndLiability(TransactionJournal $journal): bool
|
||||
{
|
||||
/** @var Transaction $sourceTransaction */
|
||||
$sourceTransaction = $journal->transactions()->where('amount', '<', 0)->first();
|
||||
|
||||
/** @var Transaction $destinationTransaction */
|
||||
$destinationTransaction = $journal->transactions()->where('amount', '>', 0)->first();
|
||||
if (null === $sourceTransaction || null === $destinationTransaction) {
|
||||
Log::warning('Either transaction is false, stop.');
|
||||
|
||||
return false;
|
||||
}
|
||||
if (null === $sourceTransaction->foreign_amount || null === $destinationTransaction->foreign_amount) {
|
||||
Log::warning('Either foreign amount is false, stop.');
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
$source = $sourceTransaction->account;
|
||||
$destination = $destinationTransaction->account;
|
||||
|
||||
if (null === $source || null === $destination) {
|
||||
Log::warning('Either is false, stop.');
|
||||
|
||||
return false;
|
||||
}
|
||||
$sourceTypes = [AccountTypeEnum::LOAN->value, AccountTypeEnum::DEBT->value, AccountTypeEnum::MORTGAGE->value];
|
||||
|
||||
// source is liability, destination is asset
|
||||
if (in_array($source->accountType->type, $sourceTypes, true) && AccountTypeEnum::ASSET->value === $destination->accountType->type) {
|
||||
Log::debug('Source is a liability account, destination is an asset account, return TRUE.');
|
||||
|
||||
return true;
|
||||
}
|
||||
// source is asset, destination is liability
|
||||
if (in_array($destination->accountType->type, $sourceTypes, true) && AccountTypeEnum::ASSET->value === $source->accountType->type) {
|
||||
Log::debug('Destination is a liability account, source is an asset account, return TRUE.');
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private function convertOldStyleTransactions(): void
|
||||
{
|
||||
|
||||
/** @var AccountRepositoryInterface $repository */
|
||||
$repository = app(AccountRepositoryInterface::class);
|
||||
Log::debug('convertOldStyleTransactions()');
|
||||
$count = 0;
|
||||
$transactions = Transaction::distinct()
|
||||
->leftJoin('transaction_journals', 'transaction_journals.id', 'transactions.transaction_journal_id')
|
||||
->leftJoin('transaction_types', 'transaction_types.id', 'transaction_journals.transaction_type_id')
|
||||
->leftJoin('accounts', 'accounts.id', 'transactions.account_id')
|
||||
->leftJoin('account_types', 'account_types.id', 'accounts.account_type_id')
|
||||
->whereNot('transaction_types.type', TransactionTypeEnum::TRANSFER->value)
|
||||
->whereNotNull('foreign_currency_id')
|
||||
->whereNotNull('foreign_amount')
|
||||
->whereIn('account_types.type', [AccountTypeEnum::ASSET->value, AccountTypeEnum::DEBT->value, AccountTypeEnum::MORTGAGE->value, AccountTypeEnum::LOAN->value])
|
||||
->get(['transactions.transaction_journal_id'])
|
||||
;
|
||||
|
||||
/** @var Transaction $transaction */
|
||||
foreach ($transactions as $transaction) {
|
||||
/** @var null|TransactionJournal $journal */
|
||||
$journal = TransactionJournal::find($transaction->transaction_journal_id);
|
||||
$repository->setUser($journal->user);
|
||||
if (null === $journal) {
|
||||
Log::debug('Found no journal, continue.');
|
||||
|
||||
continue;
|
||||
}
|
||||
if (!$this->isBetweenAssetAndLiability($journal)) {
|
||||
Log::debug('Not between asset and liability, continue.');
|
||||
|
||||
continue;
|
||||
}
|
||||
$source = $journal->transactions()->where('amount', '<', 0)->first();
|
||||
$destination = $journal->transactions()->where('amount', '>', 0)->first();
|
||||
$sourceAccount = $source->account;
|
||||
$destAccount = $destination->account;
|
||||
$sourceCurrency = $repository->getAccountCurrency($sourceAccount);
|
||||
$destCurrency = $repository->getAccountCurrency($destAccount);
|
||||
if (null === $source || null === $destination) {
|
||||
Log::debug('Either transaction is NULL, continue.');
|
||||
|
||||
continue;
|
||||
}
|
||||
if (0 === bccomp($source->amount, $source->foreign_amount) && 0 === bccomp($source->foreign_amount, $source->amount)) {
|
||||
Log::debug('Already fixed, continue.');
|
||||
|
||||
continue;
|
||||
}
|
||||
// source transaction. Switch info when does not match.
|
||||
if ((int) $source->transaction_currency_id !== (int) $sourceCurrency->id) {
|
||||
Log::debug(sprintf('Ready to swap data in transaction #%d.', $source->id));
|
||||
// swap amounts.
|
||||
$amount = $source->amount;
|
||||
$currency = $source->transaction_currency_id;
|
||||
$source->amount = $source->foreign_amount;
|
||||
$source->transaction_currency_id = $source->foreign_currency_id;
|
||||
$source->foreign_amount = $amount;
|
||||
$source->foreign_currency_id = $currency;
|
||||
$source->saveQuietly();
|
||||
$source->refresh();
|
||||
// Log::debug(sprintf('source->amount = %s', $source->amount));
|
||||
// Log::debug(sprintf('source->transaction_currency_id = %s', $source->transaction_currency_id));
|
||||
// Log::debug(sprintf('source->foreign_amount = %s', $source->foreign_amount));
|
||||
// Log::debug(sprintf('source->foreign_currency_id = %s', $source->foreign_currency_id));
|
||||
++$count;
|
||||
}
|
||||
// same but for destination
|
||||
if ((int) $destination->transaction_currency_id !== (int) $destCurrency->id) {
|
||||
++$count;
|
||||
Log::debug(sprintf('Ready to swap data in transaction #%d.', $destination->id));
|
||||
// swap amounts.
|
||||
$amount = $destination->amount;
|
||||
$currency = $destination->transaction_currency_id;
|
||||
$destination->amount = $destination->foreign_amount;
|
||||
$destination->transaction_currency_id = $destination->foreign_currency_id;
|
||||
$destination->foreign_amount = $amount;
|
||||
$destination->foreign_currency_id = $currency;
|
||||
$destination->balance_dirty = true;
|
||||
$destination->saveQuietly();
|
||||
$destination->refresh();
|
||||
// Log::debug(sprintf('destination->amount = %s', $destination->amount));
|
||||
// Log::debug(sprintf('destination->transaction_currency_id = %s', $destination->transaction_currency_id));
|
||||
// Log::debug(sprintf('destination->foreign_amount = %s', $destination->foreign_amount));
|
||||
// Log::debug(sprintf('destination->foreign_currency_id = %s', $destination->foreign_currency_id));
|
||||
}
|
||||
|
||||
|
||||
// // only fix the destination transaction
|
||||
// $destination->foreign_currency_id = $source->transaction_currency_id;
|
||||
// $destination->foreign_amount = app('steam')->positive($source->amount);
|
||||
// $destination->transaction_currency_id = $source->foreign_currency_id;
|
||||
// $destination->amount = app('steam')->positive($source->foreign_amount);
|
||||
// $destination->balance_dirty = true;
|
||||
// $source->balance_dirty = true;
|
||||
// $destination->save();
|
||||
// $source->save();
|
||||
// $this->friendlyWarning(sprintf('Corrected foreign amounts of transaction #%d.', $journal->id));
|
||||
}
|
||||
if (0 === $count) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->friendlyPositive(sprintf('Fixed %d journal(s) with unbalanced amounts.', $count));
|
||||
}
|
||||
}
|
||||
|
@@ -273,7 +273,7 @@ class ExportsData extends Command
|
||||
*/
|
||||
private function exportData(array $options, array $data): void
|
||||
{
|
||||
$date = \Safe\date('Y_m_d');
|
||||
$date = date('Y_m_d');
|
||||
foreach ($data as $key => $content) {
|
||||
$file = sprintf('%s%s_%s.csv', $options['directory'], $date, $key);
|
||||
if (false === $options['force'] && file_exists($file)) {
|
||||
|
@@ -26,6 +26,7 @@ namespace FireflyIII\Console\Commands\Integrity;
|
||||
|
||||
use FireflyIII\Console\Commands\ShowsFriendlyMessages;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class ReportsIntegrity extends Command
|
||||
{
|
||||
@@ -41,7 +42,7 @@ class ReportsIntegrity extends Command
|
||||
public function handle(): int
|
||||
{
|
||||
// if table does not exist, return false
|
||||
if (!\Schema::hasTable('users')) {
|
||||
if (!Schema::hasTable('users')) {
|
||||
return 1;
|
||||
}
|
||||
$commands = [
|
||||
|
@@ -30,13 +30,6 @@ class ValidatesEnvironmentVariables extends Command
|
||||
{
|
||||
use ShowsFriendlyMessages;
|
||||
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'integrity:validates-environment-variables';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
@@ -44,6 +37,13 @@ class ValidatesEnvironmentVariables extends Command
|
||||
*/
|
||||
protected $description = 'Makes sure you use the correct variables.';
|
||||
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'integrity:validates-environment-variables';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*/
|
||||
|
@@ -111,8 +111,8 @@ class OutputsInstructions extends Command
|
||||
*/
|
||||
private function showLogo(): void
|
||||
{
|
||||
$today = \Safe\date('m-d');
|
||||
$month = \Safe\date('m');
|
||||
$today = date('m-d');
|
||||
$month = date('m');
|
||||
// variation in colors and effects just because I can!
|
||||
// default is Ukraine flag:
|
||||
$colors = ['blue', 'blue', 'blue', 'yellow', 'yellow', 'yellow', 'default', 'default'];
|
||||
@@ -172,6 +172,13 @@ class OutputsInstructions extends Command
|
||||
}
|
||||
}
|
||||
|
||||
private function donationText(): void
|
||||
{
|
||||
$this->boxed('Did you know you can support the development of Firefly III?');
|
||||
$this->boxed('You can donate in many ways, like GitHub Sponsors or Patreon.');
|
||||
$this->boxed('For more information, please visit https://bit.ly/donate-to-Firefly-III');
|
||||
}
|
||||
|
||||
/**
|
||||
* Render instructions.
|
||||
*/
|
||||
@@ -225,11 +232,4 @@ class OutputsInstructions extends Command
|
||||
$this->boxed('');
|
||||
$this->showLine();
|
||||
}
|
||||
|
||||
private function donationText(): void
|
||||
{
|
||||
$this->boxed('Did you know you can support the development of Firefly III?');
|
||||
$this->boxed('You can donate in many ways, like GitHub Sponsors or Patreon.');
|
||||
$this->boxed('For more information, please visit https://bit.ly/donate-to-Firefly-III');
|
||||
}
|
||||
}
|
||||
|
@@ -31,13 +31,6 @@ class RecalculatesRunningBalance extends Command
|
||||
{
|
||||
use ShowsFriendlyMessages;
|
||||
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'firefly-iii:refresh-running-balance {--F|force : Force the execution of this command.}';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
@@ -45,6 +38,13 @@ class RecalculatesRunningBalance extends Command
|
||||
*/
|
||||
protected $description = 'Refreshes all running balances. May take a long time to run if forced.';
|
||||
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'firefly-iii:refresh-running-balance {--F|force : Force the execution of this command.}';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*/
|
||||
|
@@ -150,6 +150,23 @@ class Cron extends Command
|
||||
}
|
||||
}
|
||||
|
||||
private function checkForUpdates(bool $force): void
|
||||
{
|
||||
$updateCheck = new UpdateCheckCronjob();
|
||||
$updateCheck->setForce($force);
|
||||
$updateCheck->fire();
|
||||
|
||||
if ($updateCheck->jobErrored) {
|
||||
$this->friendlyError(sprintf('Error in "update check" cron: %s', $updateCheck->message));
|
||||
}
|
||||
if ($updateCheck->jobFired) {
|
||||
$this->friendlyInfo(sprintf('"Update check" cron fired: %s', $updateCheck->message));
|
||||
}
|
||||
if ($updateCheck->jobSucceeded) {
|
||||
$this->friendlyPositive(sprintf('"Update check" cron ran with success: %s', $updateCheck->message));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws FireflyException
|
||||
*/
|
||||
@@ -221,21 +238,4 @@ class Cron extends Command
|
||||
$this->friendlyPositive(sprintf('"Send bill warnings" cron ran with success: %s', $autoBudget->message));
|
||||
}
|
||||
}
|
||||
|
||||
private function checkForUpdates(bool $force): void
|
||||
{
|
||||
$updateCheck = new UpdateCheckCronjob();
|
||||
$updateCheck->setForce($force);
|
||||
$updateCheck->fire();
|
||||
|
||||
if ($updateCheck->jobErrored) {
|
||||
$this->friendlyError(sprintf('Error in "update check" cron: %s', $updateCheck->message));
|
||||
}
|
||||
if ($updateCheck->jobFired) {
|
||||
$this->friendlyInfo(sprintf('"Update check" cron fired: %s', $updateCheck->message));
|
||||
}
|
||||
if ($updateCheck->jobSucceeded) {
|
||||
$this->friendlyPositive(sprintf('"Update check" cron ran with success: %s', $updateCheck->message));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -31,6 +31,7 @@ use FireflyIII\Models\TransactionJournal;
|
||||
use FireflyIII\Repositories\Journal\JournalCLIRepositoryInterface;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Database\QueryException;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class AddsTransactionIdentifiers extends Command
|
||||
{
|
||||
@@ -65,7 +66,7 @@ class AddsTransactionIdentifiers extends Command
|
||||
}
|
||||
|
||||
// if table does not exist, return false
|
||||
if (!\Schema::hasTable('transaction_journals')) {
|
||||
if (!Schema::hasTable('transaction_journals')) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@@ -24,7 +24,14 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Console\Commands\Upgrade;
|
||||
|
||||
\Safe\set_time_limit(0);
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Safe\Exceptions\InfoException;
|
||||
|
||||
try {
|
||||
\Safe\set_time_limit(0);
|
||||
} catch (InfoException) {
|
||||
Log::warning('set_time_limit returned false. This could be an issue, unless you also run XDebug.');
|
||||
}
|
||||
|
||||
use FireflyIII\Console\Commands\ShowsFriendlyMessages;
|
||||
use Illuminate\Console\Command;
|
||||
|
@@ -32,6 +32,7 @@ use Illuminate\Support\Facades\Artisan;
|
||||
class UpgradesNativeAmounts extends Command
|
||||
{
|
||||
use ShowsFriendlyMessages;
|
||||
|
||||
public const string CONFIG_NAME = '620_native_amounts';
|
||||
|
||||
protected $description = 'Runs the native amounts calculations.';
|
||||
@@ -61,7 +62,7 @@ class UpgradesNativeAmounts extends Command
|
||||
{
|
||||
$configVar = app('fireflyconfig')->get(self::CONFIG_NAME, false);
|
||||
if (null !== $configVar) {
|
||||
return (bool)$configVar->data;
|
||||
return (bool) $configVar->data;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
@@ -366,8 +366,8 @@ class UpgradesToGroups extends Command
|
||||
{
|
||||
$groupId = DB::table('transaction_groups')->insertGetId(
|
||||
[
|
||||
'created_at' => \Safe\date('Y-m-d H:i:s'),
|
||||
'updated_at' => \Safe\date('Y-m-d H:i:s'),
|
||||
'created_at' => date('Y-m-d H:i:s'),
|
||||
'updated_at' => date('Y-m-d H:i:s'),
|
||||
'title' => null,
|
||||
'user_id' => $array['user_id'],
|
||||
]
|
||||
|
@@ -32,7 +32,9 @@ use Illuminate\Queue\SerializesModels;
|
||||
*/
|
||||
class DestroyedTransactionLink extends Event
|
||||
{
|
||||
use SerializesModels; // @phpstan-ignore-line
|
||||
use SerializesModels;
|
||||
|
||||
// @phpstan-ignore-line
|
||||
|
||||
/**
|
||||
* DestroyedTransactionLink constructor.
|
||||
|
@@ -37,8 +37,8 @@ class ChangedAmount extends Event
|
||||
{
|
||||
use SerializesModels;
|
||||
|
||||
public string $amount;
|
||||
public PiggyBank $piggyBank;
|
||||
public string $amount;
|
||||
public PiggyBank $piggyBank;
|
||||
|
||||
/**
|
||||
* Create a new event instance.
|
||||
|
@@ -32,6 +32,7 @@ use Illuminate\Queue\SerializesModels;
|
||||
class MFABackupFewLeft extends Event
|
||||
{
|
||||
use SerializesModels;
|
||||
|
||||
public User $user;
|
||||
|
||||
public function __construct(null|Authenticatable|User $user, public int $count)
|
||||
|
@@ -32,6 +32,7 @@ use Illuminate\Queue\SerializesModels;
|
||||
class MFAManyFailedAttempts extends Event
|
||||
{
|
||||
use SerializesModels;
|
||||
|
||||
public User $user;
|
||||
|
||||
public function __construct(null|Authenticatable|User $user, public int $count)
|
||||
|
@@ -31,7 +31,7 @@ class OwnerTestNotificationChannel
|
||||
{
|
||||
use SerializesModels;
|
||||
|
||||
public string $channel;
|
||||
public string $channel;
|
||||
|
||||
/**
|
||||
* Create a new event instance.
|
||||
|
@@ -45,6 +45,7 @@ use Symfony\Component\HttpKernel\Exception\HttpException;
|
||||
use Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException;
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
|
||||
// temp
|
||||
/**
|
||||
* Class Handler
|
||||
*/
|
||||
@@ -227,7 +228,7 @@ class Handler extends ExceptionHandler
|
||||
$data = [
|
||||
'class' => $e::class,
|
||||
'errorMessage' => $e->getMessage(),
|
||||
'time' => \Safe\date('r'),
|
||||
'time' => date('r'),
|
||||
'stackTrace' => $e->getTraceAsString(),
|
||||
'file' => $e->getFile(),
|
||||
'line' => $e->getLine(),
|
||||
|
@@ -34,7 +34,7 @@ use FireflyIII\User;
|
||||
*/
|
||||
class TagFactory
|
||||
{
|
||||
private User $user;
|
||||
private User $user;
|
||||
private UserGroup $userGroup;
|
||||
|
||||
public function findOrCreate(string $tag): ?Tag
|
||||
|
@@ -32,6 +32,7 @@ use FireflyIII\Models\TransactionJournal;
|
||||
use FireflyIII\Rules\UniqueIban;
|
||||
use FireflyIII\Services\Internal\Update\AccountUpdateService;
|
||||
use Illuminate\Database\QueryException;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
|
||||
/**
|
||||
* Class TransactionFactory
|
||||
@@ -152,7 +153,7 @@ class TransactionFactory
|
||||
return;
|
||||
}
|
||||
// validate info:
|
||||
$validator = \Validator::make(['iban' => $this->accountInformation['iban']], [
|
||||
$validator = Validator::make(['iban' => $this->accountInformation['iban']], [
|
||||
'iban' => ['required', new UniqueIban($this->account, $this->account->accountType->type)],
|
||||
]);
|
||||
if ($validator->fails()) {
|
||||
|
@@ -36,8 +36,8 @@ use FireflyIII\User;
|
||||
class TransactionGroupFactory
|
||||
{
|
||||
private readonly TransactionJournalFactory $journalFactory;
|
||||
private User $user;
|
||||
private UserGroup $userGroup;
|
||||
private User $user;
|
||||
private UserGroup $userGroup;
|
||||
|
||||
/**
|
||||
* TransactionGroupFactory constructor.
|
||||
|
@@ -25,6 +25,7 @@ declare(strict_types=1);
|
||||
namespace FireflyIII\Factory;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use FireflyIII\Enums\AccountTypeEnum;
|
||||
use FireflyIII\Enums\TransactionTypeEnum;
|
||||
use FireflyIII\Exceptions\DuplicateTransactionException;
|
||||
use FireflyIII\Exceptions\FireflyException;
|
||||
@@ -39,9 +40,9 @@ use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||
use FireflyIII\Repositories\Bill\BillRepositoryInterface;
|
||||
use FireflyIII\Repositories\Budget\BudgetRepositoryInterface;
|
||||
use FireflyIII\Repositories\Category\CategoryRepositoryInterface;
|
||||
use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;
|
||||
use FireflyIII\Repositories\PiggyBank\PiggyBankRepositoryInterface;
|
||||
use FireflyIII\Repositories\TransactionType\TransactionTypeRepositoryInterface;
|
||||
use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;
|
||||
use FireflyIII\Services\Internal\Destroy\JournalDestroyService;
|
||||
use FireflyIII\Services\Internal\Support\JournalServiceTrait;
|
||||
use FireflyIII\Support\Facades\FireflyConfig;
|
||||
@@ -70,7 +71,7 @@ class TransactionJournalFactory
|
||||
private PiggyBankRepositoryInterface $piggyRepository;
|
||||
private TransactionTypeRepositoryInterface $typeRepository;
|
||||
private User $user;
|
||||
private UserGroup $userGroup;
|
||||
private UserGroup $userGroup;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
@@ -101,15 +102,15 @@ class TransactionJournalFactory
|
||||
*/
|
||||
public function create(array $data): Collection
|
||||
{
|
||||
app('log')->debug('Now in TransactionJournalFactory::create()');
|
||||
Log::debug('Now in TransactionJournalFactory::create()');
|
||||
// convert to special object.
|
||||
$dataObject = new NullArrayObject($data);
|
||||
|
||||
app('log')->debug('Start of TransactionJournalFactory::create()');
|
||||
Log::debug('Start of TransactionJournalFactory::create()');
|
||||
$collection = new Collection();
|
||||
$transactions = $dataObject['transactions'] ?? [];
|
||||
if (0 === count($transactions)) {
|
||||
app('log')->error('There are no transactions in the array, the TransactionJournalFactory cannot continue.');
|
||||
Log::error('There are no transactions in the array, the TransactionJournalFactory cannot continue.');
|
||||
|
||||
return new Collection();
|
||||
}
|
||||
@@ -117,26 +118,26 @@ class TransactionJournalFactory
|
||||
try {
|
||||
/** @var array $row */
|
||||
foreach ($transactions as $index => $row) {
|
||||
app('log')->debug(sprintf('Now creating journal %d/%d', $index + 1, count($transactions)));
|
||||
Log::debug(sprintf('Now creating journal %d/%d', $index + 1, count($transactions)));
|
||||
$journal = $this->createJournal(new NullArrayObject($row));
|
||||
if (null !== $journal) {
|
||||
$collection->push($journal);
|
||||
}
|
||||
if (null === $journal) {
|
||||
app('log')->error('The createJournal() method returned NULL. This may indicate an error.');
|
||||
Log::error('The createJournal() method returned NULL. This may indicate an error.');
|
||||
}
|
||||
}
|
||||
} catch (DuplicateTransactionException $e) {
|
||||
app('log')->warning('TransactionJournalFactory::create() caught a duplicate journal in createJournal()');
|
||||
app('log')->error($e->getMessage());
|
||||
app('log')->error($e->getTraceAsString());
|
||||
Log::warning('TransactionJournalFactory::create() caught a duplicate journal in createJournal()');
|
||||
Log::error($e->getMessage());
|
||||
Log::error($e->getTraceAsString());
|
||||
$this->forceDeleteOnError($collection);
|
||||
|
||||
throw new DuplicateTransactionException($e->getMessage(), 0, $e);
|
||||
} catch (FireflyException $e) {
|
||||
app('log')->warning('TransactionJournalFactory::create() caught an exception.');
|
||||
app('log')->error($e->getMessage());
|
||||
app('log')->error($e->getTraceAsString());
|
||||
Log::warning('TransactionJournalFactory::create() caught an exception.');
|
||||
Log::error($e->getMessage());
|
||||
Log::error($e->getTraceAsString());
|
||||
$this->forceDeleteOnError($collection);
|
||||
|
||||
throw new FireflyException($e->getMessage(), 0, $e);
|
||||
@@ -156,6 +157,7 @@ class TransactionJournalFactory
|
||||
*/
|
||||
private function createJournal(NullArrayObject $row): ?TransactionJournal
|
||||
{
|
||||
Log::debug('Now in TransactionJournalFactory::createJournal()');
|
||||
$row['import_hash_v2'] = $this->hashArray($row);
|
||||
|
||||
$this->errorIfDuplicate($row['import_hash_v2']);
|
||||
@@ -164,7 +166,11 @@ class TransactionJournalFactory
|
||||
$type = $this->typeRepository->findTransactionType(null, $row['type']);
|
||||
$carbon = $row['date'] ?? today(config('app.timezone'));
|
||||
$order = $row['order'] ?? 0;
|
||||
|
||||
Log::debug('Find currency or return default.');
|
||||
$currency = $this->currencyRepository->findCurrency((int) $row['currency_id'], $row['currency_code']);
|
||||
Log::debug('Find foreign currency or return NULL.');
|
||||
|
||||
$foreignCurrency = $this->currencyRepository->findCurrencyNull($row['foreign_currency_id'], $row['foreign_currency_code']);
|
||||
$bill = $this->billRepository->findBill((int) $row['bill_id'], $row['bill_name']);
|
||||
$billId = TransactionTypeEnum::WITHDRAWAL->value === $type->type && null !== $bill ? $bill->id : null;
|
||||
@@ -183,8 +189,8 @@ class TransactionJournalFactory
|
||||
// validate source and destination using a new Validator.
|
||||
$this->validateAccounts($row);
|
||||
} catch (FireflyException $e) {
|
||||
app('log')->error('Could not validate source or destination.');
|
||||
app('log')->error($e->getMessage());
|
||||
Log::error('Could not validate source or destination.');
|
||||
Log::error($e->getMessage());
|
||||
|
||||
return null;
|
||||
}
|
||||
@@ -207,11 +213,12 @@ class TransactionJournalFactory
|
||||
'bic' => $row['destination_bic'],
|
||||
'currency_id' => $currency->id,
|
||||
];
|
||||
app('log')->debug('Source info:', $sourceInfo);
|
||||
app('log')->debug('Destination info:', $destInfo);
|
||||
Log::debug('Source info:', $sourceInfo);
|
||||
Log::debug('Destination info:', $destInfo);
|
||||
$sourceAccount = $this->getAccount($type->type, 'source', $sourceInfo);
|
||||
$destinationAccount = $this->getAccount($type->type, 'destination', $destInfo);
|
||||
app('log')->debug('Done with getAccount(2x)');
|
||||
Log::debug('Done with getAccount(2x)');
|
||||
|
||||
|
||||
// this is the moment for a reconciliation sanity check (again).
|
||||
if (TransactionTypeEnum::RECONCILIATION->value === $type->type) {
|
||||
@@ -223,7 +230,8 @@ class TransactionJournalFactory
|
||||
$foreignCurrency = $this->getForeignByAccount($type->type, $foreignCurrency, $destinationAccount);
|
||||
$description = $this->getDescription($description);
|
||||
|
||||
app('log')->debug(sprintf('Date: %s (%s)', $carbon->toW3cString(), $carbon->getTimezone()->getName()));
|
||||
Log::debug(sprintf('Currency is #%d "%s", foreign currency is #%d "%s"', $currency->id, $currency->code, $foreignCurrency?->id, $foreignCurrency));
|
||||
Log::debug(sprintf('Date: %s (%s)', $carbon->toW3cString(), $carbon->getTimezone()->getName()));
|
||||
|
||||
/** Create a basic journal. */
|
||||
$journal = TransactionJournal::create(
|
||||
@@ -241,7 +249,7 @@ class TransactionJournalFactory
|
||||
'completed' => 0,
|
||||
]
|
||||
);
|
||||
app('log')->debug(sprintf('Created new journal #%d: "%s"', $journal->id, $journal->description));
|
||||
Log::debug(sprintf('Created new journal #%d: "%s"', $journal->id, $journal->description));
|
||||
|
||||
/** Create two transactions. */
|
||||
$transactionFactory = app(TransactionFactory::class);
|
||||
@@ -255,7 +263,7 @@ class TransactionJournalFactory
|
||||
try {
|
||||
$negative = $transactionFactory->createNegative((string) $row['amount'], (string) $row['foreign_amount']);
|
||||
} catch (FireflyException $e) {
|
||||
app('log')->error(sprintf('Exception creating negative transaction: %s', $e->getMessage()));
|
||||
Log::error(sprintf('Exception creating negative transaction: %s', $e->getMessage()));
|
||||
$this->forceDeleteOnError(new Collection([$journal]));
|
||||
|
||||
throw new FireflyException($e->getMessage(), 0, $e);
|
||||
@@ -277,7 +285,7 @@ class TransactionJournalFactory
|
||||
$amount = (string) $row['amount'];
|
||||
$foreignAmount = (string) $row['foreign_amount'];
|
||||
if (null !== $foreignCurrency && $foreignCurrency->id !== $currency->id
|
||||
&& TransactionTypeEnum::TRANSFER->value === $type->type
|
||||
&& (TransactionTypeEnum::TRANSFER->value === $type->type || $this->isBetweenAssetAndLiability($sourceAccount, $destinationAccount))
|
||||
) {
|
||||
$transactionFactory->setCurrency($foreignCurrency);
|
||||
$transactionFactory->setForeignCurrency($currency);
|
||||
@@ -289,7 +297,7 @@ class TransactionJournalFactory
|
||||
try {
|
||||
$transactionFactory->createPositive($amount, $foreignAmount);
|
||||
} catch (FireflyException $e) {
|
||||
app('log')->error(sprintf('Exception creating positive transaction: %s', $e->getMessage()));
|
||||
Log::error(sprintf('Exception creating positive transaction: %s', $e->getMessage()));
|
||||
$this->forceTrDelete($negative);
|
||||
$this->forceDeleteOnError(new Collection([$journal]));
|
||||
|
||||
@@ -317,11 +325,11 @@ class TransactionJournalFactory
|
||||
try {
|
||||
$json = \Safe\json_encode($dataRow, JSON_THROW_ON_ERROR);
|
||||
} catch (\JsonException $e) {
|
||||
app('log')->error(sprintf('Could not encode dataRow: %s', $e->getMessage()));
|
||||
Log::error(sprintf('Could not encode dataRow: %s', $e->getMessage()));
|
||||
$json = microtime();
|
||||
}
|
||||
$hash = hash('sha256', $json);
|
||||
app('log')->debug(sprintf('The hash is: %s', $hash), $dataRow);
|
||||
Log::debug(sprintf('The hash is: %s', $hash), $dataRow);
|
||||
|
||||
return $hash;
|
||||
}
|
||||
@@ -333,11 +341,11 @@ class TransactionJournalFactory
|
||||
*/
|
||||
private function errorIfDuplicate(string $hash): void
|
||||
{
|
||||
app('log')->debug(sprintf('In errorIfDuplicate(%s)', $hash));
|
||||
Log::debug(sprintf('In errorIfDuplicate(%s)', $hash));
|
||||
if (false === $this->errorOnHash) {
|
||||
return;
|
||||
}
|
||||
app('log')->debug('Will verify duplicate!');
|
||||
Log::debug('Will verify duplicate!');
|
||||
|
||||
/** @var null|TransactionJournalMeta $result */
|
||||
$result = TransactionJournalMeta::withTrashed()
|
||||
@@ -349,7 +357,7 @@ class TransactionJournalFactory
|
||||
->first(['journal_meta.*'])
|
||||
;
|
||||
if (null !== $result) {
|
||||
app('log')->warning(sprintf('Found a duplicate in errorIfDuplicate because hash %s is not unique!', $hash));
|
||||
Log::warning(sprintf('Found a duplicate in errorIfDuplicate because hash %s is not unique!', $hash));
|
||||
$journal = $result->transactionJournal()->withTrashed()->first();
|
||||
$group = $journal?->transactionGroup()->withTrashed()->first();
|
||||
$groupId = (int) $group?->id;
|
||||
@@ -363,7 +371,7 @@ class TransactionJournalFactory
|
||||
*/
|
||||
private function validateAccounts(NullArrayObject $data): void
|
||||
{
|
||||
app('log')->debug(sprintf('Now in %s', __METHOD__));
|
||||
Log::debug(sprintf('Now in %s', __METHOD__));
|
||||
$transactionType = $data['type'] ?? 'invalid';
|
||||
$this->accountValidator->setUser($this->user);
|
||||
$this->accountValidator->setTransactionType($transactionType);
|
||||
@@ -381,7 +389,7 @@ class TransactionJournalFactory
|
||||
if (false === $validSource) {
|
||||
throw new FireflyException(sprintf('Source: %s', $this->accountValidator->sourceError));
|
||||
}
|
||||
app('log')->debug('Source seems valid.');
|
||||
Log::debug('Source seems valid.');
|
||||
|
||||
// validate destination account
|
||||
$array = [
|
||||
@@ -414,42 +422,30 @@ class TransactionJournalFactory
|
||||
$this->accountRepository->setUser($this->user);
|
||||
}
|
||||
|
||||
public function setUserGroup(UserGroup $userGroup): void
|
||||
{
|
||||
$this->userGroup = $userGroup;
|
||||
$this->currencyRepository->setUserGroup($userGroup);
|
||||
$this->tagFactory->setUserGroup($userGroup);
|
||||
$this->billRepository->setUserGroup($userGroup);
|
||||
$this->budgetRepository->setUserGroup($userGroup);
|
||||
$this->categoryRepository->setUserGroup($userGroup);
|
||||
$this->piggyRepository->setUserGroup($userGroup);
|
||||
$this->accountRepository->setUserGroup($userGroup);
|
||||
}
|
||||
|
||||
private function reconciliationSanityCheck(?Account $sourceAccount, ?Account $destinationAccount): array
|
||||
{
|
||||
app('log')->debug(sprintf('Now in %s', __METHOD__));
|
||||
Log::debug(sprintf('Now in %s', __METHOD__));
|
||||
if (null !== $sourceAccount && null !== $destinationAccount) {
|
||||
app('log')->debug('Both accounts exist, simply return them.');
|
||||
Log::debug('Both accounts exist, simply return them.');
|
||||
|
||||
return [$sourceAccount, $destinationAccount];
|
||||
}
|
||||
if (null === $destinationAccount) {
|
||||
app('log')->debug('Destination account is NULL, source account is not.');
|
||||
Log::debug('Destination account is NULL, source account is not.');
|
||||
$account = $this->accountRepository->getReconciliation($sourceAccount);
|
||||
app('log')->debug(sprintf('Will return account #%d ("%s") of type "%s"', $account->id, $account->name, $account->accountType->type));
|
||||
Log::debug(sprintf('Will return account #%d ("%s") of type "%s"', $account->id, $account->name, $account->accountType->type));
|
||||
|
||||
return [$sourceAccount, $account];
|
||||
}
|
||||
|
||||
if (null === $sourceAccount) { // @phpstan-ignore-line
|
||||
app('log')->debug('Source account is NULL, destination account is not.');
|
||||
Log::debug('Source account is NULL, destination account is not.');
|
||||
$account = $this->accountRepository->getReconciliation($destinationAccount);
|
||||
app('log')->debug(sprintf('Will return account #%d ("%s") of type "%s"', $account->id, $account->name, $account->accountType->type));
|
||||
Log::debug(sprintf('Will return account #%d ("%s") of type "%s"', $account->id, $account->name, $account->accountType->type));
|
||||
|
||||
return [$account, $destinationAccount];
|
||||
}
|
||||
app('log')->debug('Unused fallback'); // @phpstan-ignore-line
|
||||
Log::debug('Unused fallback'); // @phpstan-ignore-line
|
||||
|
||||
return [$sourceAccount, $destinationAccount];
|
||||
}
|
||||
@@ -459,7 +455,15 @@ class TransactionJournalFactory
|
||||
*/
|
||||
private function getCurrencyByAccount(string $type, ?TransactionCurrency $currency, Account $source, Account $destination): TransactionCurrency
|
||||
{
|
||||
app('log')->debug('Now in getCurrencyByAccount()');
|
||||
Log::debug('Now in getCurrencyByAccount()');
|
||||
|
||||
/*
|
||||
* Deze functie moet bij een transactie van liability naar asset wel degelijk de currency
|
||||
* van de liability teruggeven en niet die van de destination. Fix voor #10265
|
||||
*/
|
||||
if ($this->isBetweenAssetAndLiability($source, $destination) && TransactionTypeEnum::DEPOSIT->value === $type) {
|
||||
return $this->getCurrency($currency, $source);
|
||||
}
|
||||
|
||||
return match ($type) {
|
||||
default => $this->getCurrency($currency, $source),
|
||||
@@ -472,7 +476,7 @@ class TransactionJournalFactory
|
||||
*/
|
||||
private function getCurrency(?TransactionCurrency $currency, Account $account): TransactionCurrency
|
||||
{
|
||||
app('log')->debug('Now in getCurrency()');
|
||||
Log::debug(sprintf('Now in getCurrency(#%d, "%s")', $currency?->id, $account->name));
|
||||
|
||||
/** @var null|TransactionCurrency $preference */
|
||||
$preference = $this->accountRepository->getAccountCurrency($account);
|
||||
@@ -481,7 +485,7 @@ class TransactionJournalFactory
|
||||
return app('amount')->getNativeCurrencyByUserGroup($this->user->userGroup);
|
||||
}
|
||||
$result = $preference ?? $currency;
|
||||
app('log')->debug(sprintf('Currency is now #%d (%s) because of account #%d (%s)', $result->id, $result->code, $account->id, $account->name));
|
||||
Log::debug(sprintf('Currency is now #%d (%s) because of account #%d (%s)', $result->id, $result->code, $account->id, $account->name));
|
||||
|
||||
return $result;
|
||||
}
|
||||
@@ -491,6 +495,7 @@ class TransactionJournalFactory
|
||||
*/
|
||||
private function compareCurrencies(?TransactionCurrency $currency, ?TransactionCurrency $foreignCurrency): ?TransactionCurrency
|
||||
{
|
||||
Log::debug(sprintf('Now in compareCurrencies("%s", "%s")', $currency?->code, $foreignCurrency?->code));
|
||||
if (null === $currency) {
|
||||
return null;
|
||||
}
|
||||
@@ -506,6 +511,7 @@ class TransactionJournalFactory
|
||||
*/
|
||||
private function getForeignByAccount(string $type, ?TransactionCurrency $foreignCurrency, Account $destination): ?TransactionCurrency
|
||||
{
|
||||
Log::debug(sprintf('Now in getForeignByAccount("%s", #%d, "%s")', $type, $foreignCurrency?->id, $destination->name));
|
||||
if (TransactionTypeEnum::TRANSFER->value === $type) {
|
||||
return $this->getCurrency($foreignCurrency, $destination);
|
||||
}
|
||||
@@ -526,12 +532,12 @@ class TransactionJournalFactory
|
||||
*/
|
||||
private function forceDeleteOnError(Collection $collection): void
|
||||
{
|
||||
app('log')->debug(sprintf('forceDeleteOnError on collection size %d item(s)', $collection->count()));
|
||||
Log::debug(sprintf('forceDeleteOnError on collection size %d item(s)', $collection->count()));
|
||||
$service = app(JournalDestroyService::class);
|
||||
|
||||
/** @var TransactionJournal $journal */
|
||||
foreach ($collection as $journal) {
|
||||
app('log')->debug(sprintf('forceDeleteOnError on journal #%d', $journal->id));
|
||||
Log::debug(sprintf('forceDeleteOnError on journal #%d', $journal->id));
|
||||
$service->destroy($journal);
|
||||
}
|
||||
}
|
||||
@@ -546,17 +552,17 @@ class TransactionJournalFactory
|
||||
*/
|
||||
private function storePiggyEvent(TransactionJournal $journal, NullArrayObject $data): void
|
||||
{
|
||||
app('log')->debug('Will now store piggy event.');
|
||||
Log::debug('Will now store piggy event.');
|
||||
|
||||
$piggyBank = $this->piggyRepository->findPiggyBank((int) $data['piggy_bank_id'], $data['piggy_bank_name']);
|
||||
|
||||
if (null !== $piggyBank) {
|
||||
$this->piggyEventFactory->create($journal, $piggyBank);
|
||||
app('log')->debug('Create piggy event.');
|
||||
Log::debug('Create piggy event.');
|
||||
|
||||
return;
|
||||
}
|
||||
app('log')->debug('Create no piggy event');
|
||||
Log::debug('Create no piggy event');
|
||||
}
|
||||
|
||||
private function storeMetaFields(TransactionJournal $journal, NullArrayObject $transaction): void
|
||||
@@ -575,11 +581,11 @@ class TransactionJournalFactory
|
||||
];
|
||||
if ($data[$field] instanceof Carbon) {
|
||||
$data[$field]->setTimezone(config('app.timezone'));
|
||||
app('log')->debug(sprintf('%s Date: %s (%s)', $field, $data[$field], $data[$field]->timezone->getName()));
|
||||
Log::debug(sprintf('%s Date: %s (%s)', $field, $data[$field], $data[$field]->timezone->getName()));
|
||||
$set['data'] = $data[$field]->format('Y-m-d H:i:s');
|
||||
}
|
||||
|
||||
app('log')->debug(sprintf('Going to store meta-field "%s", with value "%s".', $set['name'], $set['data']));
|
||||
Log::debug(sprintf('Going to store meta-field "%s", with value "%s".', $set['name'], $set['data']));
|
||||
|
||||
/** @var TransactionJournalMetaFactory $factory */
|
||||
$factory = app(TransactionJournalMetaFactory::class);
|
||||
@@ -602,7 +608,40 @@ class TransactionJournalFactory
|
||||
{
|
||||
$this->errorOnHash = $errorOnHash;
|
||||
if (true === $errorOnHash) {
|
||||
app('log')->info('Will trigger duplication alert for this journal.');
|
||||
Log::info('Will trigger duplication alert for this journal.');
|
||||
}
|
||||
}
|
||||
|
||||
public function setUserGroup(UserGroup $userGroup): void
|
||||
{
|
||||
$this->userGroup = $userGroup;
|
||||
$this->currencyRepository->setUserGroup($userGroup);
|
||||
$this->tagFactory->setUserGroup($userGroup);
|
||||
$this->billRepository->setUserGroup($userGroup);
|
||||
$this->budgetRepository->setUserGroup($userGroup);
|
||||
$this->categoryRepository->setUserGroup($userGroup);
|
||||
$this->piggyRepository->setUserGroup($userGroup);
|
||||
$this->accountRepository->setUserGroup($userGroup);
|
||||
}
|
||||
|
||||
private function isBetweenAssetAndLiability(Account $source, Account $destination): bool
|
||||
{
|
||||
$sourceTypes = [AccountTypeEnum::LOAN->value, AccountTypeEnum::DEBT->value, AccountTypeEnum::MORTGAGE->value];
|
||||
|
||||
// source is liability, destination is asset
|
||||
if (in_array($source->accountType->type, $sourceTypes, true) && AccountTypeEnum::ASSET->value === $destination->accountType->type) {
|
||||
Log::debug('Source is a liability account, destination is an asset account, return TRUE.');
|
||||
|
||||
return true;
|
||||
}
|
||||
// source is asset, destination is liability
|
||||
if (in_array($destination->accountType->type, $sourceTypes, true) && AccountTypeEnum::ASSET->value === $source->accountType->type) {
|
||||
Log::debug('Destination is a liability account, source is an asset account, return TRUE.');
|
||||
|
||||
return true;
|
||||
}
|
||||
Log::debug('Not between asset and liability, return FALSE');
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@@ -53,6 +53,55 @@ class UpdatedGroupEventHandler
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* This method will make sure all source / destination accounts are the same.
|
||||
*/
|
||||
public function unifyAccounts(UpdatedTransactionGroup $updatedGroupEvent): void
|
||||
{
|
||||
$group = $updatedGroupEvent->transactionGroup;
|
||||
if (1 === $group->transactionJournals->count()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// first journal:
|
||||
/** @var null|TransactionJournal $first */
|
||||
$first = $group->transactionJournals()
|
||||
->orderBy('transaction_journals.date', 'DESC')
|
||||
->orderBy('transaction_journals.order', 'ASC')
|
||||
->orderBy('transaction_journals.id', 'DESC')
|
||||
->orderBy('transaction_journals.description', 'DESC')
|
||||
->first()
|
||||
;
|
||||
|
||||
if (null === $first) {
|
||||
Log::warning(sprintf('Group #%d has no transaction journals.', $group->id));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$all = $group->transactionJournals()->get()->pluck('id')->toArray();
|
||||
|
||||
/** @var Account $sourceAccount */
|
||||
$sourceAccount = $first->transactions()->where('amount', '<', '0')->first()->account;
|
||||
|
||||
/** @var Account $destAccount */
|
||||
$destAccount = $first->transactions()->where('amount', '>', '0')->first()->account;
|
||||
|
||||
$type = $first->transactionType->type;
|
||||
if (TransactionTypeEnum::TRANSFER->value === $type || TransactionTypeEnum::WITHDRAWAL->value === $type) {
|
||||
// set all source transactions to source account:
|
||||
Transaction::whereIn('transaction_journal_id', $all)
|
||||
->where('amount', '<', 0)->update(['account_id' => $sourceAccount->id])
|
||||
;
|
||||
}
|
||||
if (TransactionTypeEnum::TRANSFER->value === $type || TransactionTypeEnum::DEPOSIT->value === $type) {
|
||||
// set all destination transactions to destination account:
|
||||
Transaction::whereIn('transaction_journal_id', $all)
|
||||
->where('amount', '>', 0)->update(['account_id' => $destAccount->id])
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This method will check all the rules when a journal is updated.
|
||||
*/
|
||||
@@ -119,55 +168,6 @@ class UpdatedGroupEventHandler
|
||||
event(new RequestedSendWebhookMessages());
|
||||
}
|
||||
|
||||
/**
|
||||
* This method will make sure all source / destination accounts are the same.
|
||||
*/
|
||||
public function unifyAccounts(UpdatedTransactionGroup $updatedGroupEvent): void
|
||||
{
|
||||
$group = $updatedGroupEvent->transactionGroup;
|
||||
if (1 === $group->transactionJournals->count()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// first journal:
|
||||
/** @var null|TransactionJournal $first */
|
||||
$first = $group->transactionJournals()
|
||||
->orderBy('transaction_journals.date', 'DESC')
|
||||
->orderBy('transaction_journals.order', 'ASC')
|
||||
->orderBy('transaction_journals.id', 'DESC')
|
||||
->orderBy('transaction_journals.description', 'DESC')
|
||||
->first()
|
||||
;
|
||||
|
||||
if (null === $first) {
|
||||
Log::warning(sprintf('Group #%d has no transaction journals.', $group->id));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$all = $group->transactionJournals()->get()->pluck('id')->toArray();
|
||||
|
||||
/** @var Account $sourceAccount */
|
||||
$sourceAccount = $first->transactions()->where('amount', '<', '0')->first()->account;
|
||||
|
||||
/** @var Account $destAccount */
|
||||
$destAccount = $first->transactions()->where('amount', '>', '0')->first()->account;
|
||||
|
||||
$type = $first->transactionType->type;
|
||||
if (TransactionTypeEnum::TRANSFER->value === $type || TransactionTypeEnum::WITHDRAWAL->value === $type) {
|
||||
// set all source transactions to source account:
|
||||
Transaction::whereIn('transaction_journal_id', $all)
|
||||
->where('amount', '<', 0)->update(['account_id' => $sourceAccount->id])
|
||||
;
|
||||
}
|
||||
if (TransactionTypeEnum::TRANSFER->value === $type || TransactionTypeEnum::DEPOSIT->value === $type) {
|
||||
// set all destination transactions to destination account:
|
||||
Transaction::whereIn('transaction_journal_id', $all)
|
||||
->where('amount', '>', 0)->update(['account_id' => $destAccount->id])
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
private function updateRunningBalance(UpdatedTransactionGroup $event): void
|
||||
{
|
||||
Log::debug(__METHOD__);
|
||||
|
@@ -54,8 +54,8 @@ use FireflyIII\Repositories\User\UserRepositoryInterface;
|
||||
use FireflyIII\User;
|
||||
use Illuminate\Auth\Events\Login;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
use Illuminate\Support\Facades\Notification;
|
||||
use Mail;
|
||||
|
||||
/**
|
||||
* Class UserEventHandler.
|
||||
@@ -266,7 +266,7 @@ class UserEventHandler
|
||||
$url = route('profile.confirm-email-change', [$token->data]);
|
||||
|
||||
try {
|
||||
\Mail::to($newEmail)->send(new ConfirmEmailChangeMail($newEmail, $oldEmail, $url));
|
||||
Mail::to($newEmail)->send(new ConfirmEmailChangeMail($newEmail, $oldEmail, $url));
|
||||
} catch (\Exception $e) {
|
||||
app('log')->error($e->getMessage());
|
||||
app('log')->error($e->getTraceAsString());
|
||||
@@ -291,7 +291,7 @@ class UserEventHandler
|
||||
$url = route('profile.undo-email-change', [$token->data, $hashed]);
|
||||
|
||||
try {
|
||||
\Mail::to($oldEmail)->send(new UndoEmailChangeMail($newEmail, $oldEmail, $url));
|
||||
Mail::to($oldEmail)->send(new UndoEmailChangeMail($newEmail, $oldEmail, $url));
|
||||
} catch (\Exception $e) {
|
||||
app('log')->error($e->getMessage());
|
||||
app('log')->error($e->getTraceAsString());
|
||||
@@ -355,7 +355,7 @@ class UserEventHandler
|
||||
$url = route('invite', [$event->invitee->invite_code]);
|
||||
|
||||
try {
|
||||
\Mail::to($invitee)->send(new InvitationMail($invitee, $admin, $url));
|
||||
Mail::to($invitee)->send(new InvitationMail($invitee, $admin, $url));
|
||||
} catch (\Exception $e) {
|
||||
app('log')->error($e->getMessage());
|
||||
app('log')->error($e->getTraceAsString());
|
||||
|
@@ -73,7 +73,7 @@ class VersionCheckEventHandler
|
||||
$diff = $now - $lastCheckTime->data;
|
||||
Log::debug(sprintf('Last check time is %d, current time is %d, difference is %d', $lastCheckTime->data, $now, $diff));
|
||||
if ($diff < 604800) {
|
||||
Log::debug(sprintf('Checked for updates less than a week ago (on %s).', \Safe\date('Y-m-d H:i:s', $lastCheckTime->data)));
|
||||
Log::debug(sprintf('Checked for updates less than a week ago (on %s).', date('Y-m-d H:i:s', $lastCheckTime->data)));
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -105,7 +105,7 @@ class VersionCheckEventHandler
|
||||
$diff = $now - $lastCheckTime->data;
|
||||
Log::debug(sprintf('Last warning time is %d, current time is %d, difference is %d', $lastCheckTime->data, $now, $diff));
|
||||
if ($diff < 604800 * 4) {
|
||||
Log::debug(sprintf('Warned about updates less than four weeks ago (on %s).', \Safe\date('Y-m-d H:i:s', $lastCheckTime->data)));
|
||||
Log::debug(sprintf('Warned about updates less than four weeks ago (on %s).', date('Y-m-d H:i:s', $lastCheckTime->data)));
|
||||
|
||||
return;
|
||||
}
|
||||
|
@@ -29,8 +29,8 @@ use FireflyIII\Models\Attachment;
|
||||
use FireflyIII\Models\Transaction;
|
||||
use FireflyIII\Models\TransactionGroup;
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
use FireflyIII\Repositories\Attachment\AttachmentRepositoryInterface;
|
||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||
use FireflyIII\Repositories\Attachment\AttachmentRepositoryInterface;
|
||||
use FireflyIII\Support\Facades\Amount;
|
||||
use FireflyIII\Support\Http\Api\ExchangeRateConverter;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
@@ -37,12 +37,6 @@ class AutoBudgetObserver
|
||||
$this->updateNativeAmount($autoBudget);
|
||||
}
|
||||
|
||||
public function updated(AutoBudget $autoBudget): void
|
||||
{
|
||||
Log::debug('Observe "updated" of an auto budget.');
|
||||
$this->updateNativeAmount($autoBudget);
|
||||
}
|
||||
|
||||
private function updateNativeAmount(AutoBudget $autoBudget): void
|
||||
{
|
||||
if (!Amount::convertToNative($autoBudget->budget->user)) {
|
||||
@@ -59,4 +53,10 @@ class AutoBudgetObserver
|
||||
$autoBudget->saveQuietly();
|
||||
Log::debug('Auto budget native amount is updated.');
|
||||
}
|
||||
|
||||
public function updated(AutoBudget $autoBudget): void
|
||||
{
|
||||
Log::debug('Observe "updated" of an auto budget.');
|
||||
$this->updateNativeAmount($autoBudget);
|
||||
}
|
||||
}
|
||||
|
@@ -37,12 +37,6 @@ class AvailableBudgetObserver
|
||||
$this->updateNativeAmount($availableBudget);
|
||||
}
|
||||
|
||||
public function updated(AvailableBudget $availableBudget): void
|
||||
{
|
||||
// Log::debug('Observe "updated" of an available budget.');
|
||||
$this->updateNativeAmount($availableBudget);
|
||||
}
|
||||
|
||||
private function updateNativeAmount(AvailableBudget $availableBudget): void
|
||||
{
|
||||
if (!Amount::convertToNative($availableBudget->user)) {
|
||||
@@ -61,4 +55,10 @@ class AvailableBudgetObserver
|
||||
$availableBudget->saveQuietly();
|
||||
Log::debug('Available budget native amount is updated.');
|
||||
}
|
||||
|
||||
public function updated(AvailableBudget $availableBudget): void
|
||||
{
|
||||
// Log::debug('Observe "updated" of an available budget.');
|
||||
$this->updateNativeAmount($availableBudget);
|
||||
}
|
||||
}
|
||||
|
@@ -41,25 +41,6 @@ class BillObserver
|
||||
$this->updateNativeAmount($bill);
|
||||
}
|
||||
|
||||
public function deleting(Bill $bill): void
|
||||
{
|
||||
$repository = app(AttachmentRepositoryInterface::class);
|
||||
$repository->setUser($bill->user);
|
||||
|
||||
// app('log')->debug('Observe "deleting" of a bill.');
|
||||
/** @var Attachment $attachment */
|
||||
foreach ($bill->attachments()->get() as $attachment) {
|
||||
$repository->destroy($attachment);
|
||||
}
|
||||
$bill->notes()->delete();
|
||||
}
|
||||
|
||||
public function updated(Bill $bill): void
|
||||
{
|
||||
// Log::debug('Observe "updated" of a bill.');
|
||||
$this->updateNativeAmount($bill);
|
||||
}
|
||||
|
||||
private function updateNativeAmount(Bill $bill): void
|
||||
{
|
||||
if (!Amount::convertToNative($bill->user)) {
|
||||
@@ -78,4 +59,23 @@ class BillObserver
|
||||
$bill->saveQuietly();
|
||||
Log::debug('Bill native amounts are updated.');
|
||||
}
|
||||
|
||||
public function deleting(Bill $bill): void
|
||||
{
|
||||
$repository = app(AttachmentRepositoryInterface::class);
|
||||
$repository->setUser($bill->user);
|
||||
|
||||
// app('log')->debug('Observe "deleting" of a bill.');
|
||||
/** @var Attachment $attachment */
|
||||
foreach ($bill->attachments()->get() as $attachment) {
|
||||
$repository->destroy($attachment);
|
||||
}
|
||||
$bill->notes()->delete();
|
||||
}
|
||||
|
||||
public function updated(Bill $bill): void
|
||||
{
|
||||
// Log::debug('Observe "updated" of a bill.');
|
||||
$this->updateNativeAmount($bill);
|
||||
}
|
||||
}
|
||||
|
@@ -37,12 +37,6 @@ class BudgetLimitObserver
|
||||
$this->updateNativeAmount($budgetLimit);
|
||||
}
|
||||
|
||||
public function updated(BudgetLimit $budgetLimit): void
|
||||
{
|
||||
Log::debug('Observe "updated" of a budget limit.');
|
||||
$this->updateNativeAmount($budgetLimit);
|
||||
}
|
||||
|
||||
private function updateNativeAmount(BudgetLimit $budgetLimit): void
|
||||
{
|
||||
if (!Amount::convertToNative($budgetLimit->budget->user)) {
|
||||
@@ -61,4 +55,10 @@ class BudgetLimitObserver
|
||||
$budgetLimit->saveQuietly();
|
||||
Log::debug('Budget limit native amounts are updated.');
|
||||
}
|
||||
|
||||
public function updated(BudgetLimit $budgetLimit): void
|
||||
{
|
||||
Log::debug('Observe "updated" of a budget limit.');
|
||||
$this->updateNativeAmount($budgetLimit);
|
||||
}
|
||||
}
|
||||
|
@@ -37,12 +37,6 @@ class PiggyBankEventObserver
|
||||
$this->updateNativeAmount($event);
|
||||
}
|
||||
|
||||
public function updated(PiggyBankEvent $event): void
|
||||
{
|
||||
Log::debug('Observe "updated" of a piggy bank event.');
|
||||
$this->updateNativeAmount($event);
|
||||
}
|
||||
|
||||
private function updateNativeAmount(PiggyBankEvent $event): void
|
||||
{
|
||||
$user = $event->piggyBank->accounts()->first()?->user;
|
||||
@@ -65,4 +59,10 @@ class PiggyBankEventObserver
|
||||
$event->saveQuietly();
|
||||
Log::debug('Piggy bank event native amount is updated.');
|
||||
}
|
||||
|
||||
public function updated(PiggyBankEvent $event): void
|
||||
{
|
||||
Log::debug('Observe "updated" of a piggy bank event.');
|
||||
$this->updateNativeAmount($event);
|
||||
}
|
||||
}
|
||||
|
@@ -41,6 +41,26 @@ class PiggyBankObserver
|
||||
$this->updateNativeAmount($piggyBank);
|
||||
}
|
||||
|
||||
private function updateNativeAmount(PiggyBank $piggyBank): void
|
||||
{
|
||||
$group = $piggyBank->accounts()->first()?->user->userGroup;
|
||||
if (null === $group) {
|
||||
Log::debug(sprintf('No account(s) yet for piggy bank #%d.', $piggyBank->id));
|
||||
|
||||
return;
|
||||
}
|
||||
$userCurrency = app('amount')->getNativeCurrencyByUserGroup($group);
|
||||
$piggyBank->native_target_amount = null;
|
||||
if ($piggyBank->transactionCurrency->id !== $userCurrency->id) {
|
||||
$converter = new ExchangeRateConverter();
|
||||
$converter->setIgnoreSettings(true);
|
||||
$converter->setUserGroup($group);
|
||||
$piggyBank->native_target_amount = $converter->convert($piggyBank->transactionCurrency, $userCurrency, today(), $piggyBank->target_amount);
|
||||
}
|
||||
$piggyBank->saveQuietly();
|
||||
Log::debug('Piggy bank native target amount is updated.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Also delete related objects.
|
||||
*/
|
||||
@@ -67,24 +87,4 @@ class PiggyBankObserver
|
||||
Log::debug('Observe "updated" of a piggy bank.');
|
||||
$this->updateNativeAmount($piggyBank);
|
||||
}
|
||||
|
||||
private function updateNativeAmount(PiggyBank $piggyBank): void
|
||||
{
|
||||
$group = $piggyBank->accounts()->first()?->user->userGroup;
|
||||
if (null === $group) {
|
||||
Log::debug(sprintf('No account(s) yet for piggy bank #%d.', $piggyBank->id));
|
||||
|
||||
return;
|
||||
}
|
||||
$userCurrency = app('amount')->getNativeCurrencyByUserGroup($group);
|
||||
$piggyBank->native_target_amount = null;
|
||||
if ($piggyBank->transactionCurrency->id !== $userCurrency->id) {
|
||||
$converter = new ExchangeRateConverter();
|
||||
$converter->setIgnoreSettings(true);
|
||||
$converter->setUserGroup($group);
|
||||
$piggyBank->native_target_amount = $converter->convert($piggyBank->transactionCurrency, $userCurrency, today(), $piggyBank->target_amount);
|
||||
}
|
||||
$piggyBank->saveQuietly();
|
||||
Log::debug('Piggy bank native target amount is updated.');
|
||||
}
|
||||
}
|
||||
|
@@ -48,24 +48,6 @@ class TransactionObserver
|
||||
$this->updateNativeAmount($transaction);
|
||||
}
|
||||
|
||||
public function deleting(?Transaction $transaction): void
|
||||
{
|
||||
app('log')->debug('Observe "deleting" of a transaction.');
|
||||
$transaction?->transactionJournal?->delete();
|
||||
}
|
||||
|
||||
public function updated(Transaction $transaction): void
|
||||
{
|
||||
// Log::debug('Observe "updated" of a transaction.');
|
||||
if (true === config('firefly.feature_flags.running_balance_column') && true === self::$recalculate) {
|
||||
if (1 === bccomp($transaction->amount, '0')) {
|
||||
Log::debug('Trigger recalculateForJournal');
|
||||
AccountBalanceCalculator::recalculateForJournal($transaction->transactionJournal);
|
||||
}
|
||||
}
|
||||
$this->updateNativeAmount($transaction);
|
||||
}
|
||||
|
||||
private function updateNativeAmount(Transaction $transaction): void
|
||||
{
|
||||
if (!Amount::convertToNative($transaction->transactionJournal->user)) {
|
||||
@@ -92,4 +74,22 @@ class TransactionObserver
|
||||
$transaction->saveQuietly();
|
||||
Log::debug('Transaction native amounts are updated.');
|
||||
}
|
||||
|
||||
public function deleting(?Transaction $transaction): void
|
||||
{
|
||||
app('log')->debug('Observe "deleting" of a transaction.');
|
||||
$transaction?->transactionJournal?->delete();
|
||||
}
|
||||
|
||||
public function updated(Transaction $transaction): void
|
||||
{
|
||||
// Log::debug('Observe "updated" of a transaction.');
|
||||
if (true === config('firefly.feature_flags.running_balance_column') && true === self::$recalculate) {
|
||||
if (1 === bccomp($transaction->amount, '0')) {
|
||||
Log::debug('Trigger recalculateForJournal');
|
||||
AccountBalanceCalculator::recalculateForJournal($transaction->transactionJournal);
|
||||
}
|
||||
}
|
||||
$this->updateNativeAmount($transaction);
|
||||
}
|
||||
}
|
||||
|
@@ -36,6 +36,89 @@ use Illuminate\Support\Facades\Log;
|
||||
*/
|
||||
trait AccountCollection
|
||||
{
|
||||
#[\Override]
|
||||
public function accountBalanceIs(string $direction, string $operator, string $value): GroupCollectorInterface
|
||||
{
|
||||
Log::warning(sprintf('GroupCollector will be SLOW: accountBalanceIs: "%s" "%s" "%s"', $direction, $operator, $value));
|
||||
|
||||
/**
|
||||
* @param int $index
|
||||
* @param array $object
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
$filter = static function (array $object) use ($direction, $operator, $value): bool {
|
||||
/** @var array $transaction */
|
||||
foreach ($object['transactions'] as $transaction) {
|
||||
$key = sprintf('%s_account_id', $direction);
|
||||
$accountId = $transaction[$key] ?? 0;
|
||||
if (0 === $accountId) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// in theory, this could lead to finding other users accounts.
|
||||
/** @var null|Account $account */
|
||||
$account = Account::find($accountId);
|
||||
if (null === $account) {
|
||||
continue;
|
||||
}
|
||||
// the balance must be found BEFORE the transaction date.
|
||||
// so sub one second. This is not perfect, but works well enough.
|
||||
$date = clone $transaction['date'];
|
||||
$date->subSecond();
|
||||
Log::debug(sprintf('accountBalanceIs: Call finalAccountBalance with date/time "%s"', $date->toIso8601String()));
|
||||
$balance = Steam::finalAccountBalance($account, $date);
|
||||
$result = bccomp((string) $balance['balance'], $value);
|
||||
Log::debug(sprintf('"%s" vs "%s" is %d', $balance['balance'], $value, $result));
|
||||
|
||||
switch ($operator) {
|
||||
default:
|
||||
Log::error(sprintf('GroupCollector: accountBalanceIs: unknown operator "%s"', $operator));
|
||||
|
||||
return false;
|
||||
|
||||
case '==':
|
||||
Log::debug('Expect result to be 0 (equal)');
|
||||
|
||||
return 0 === $result;
|
||||
|
||||
case '!=':
|
||||
Log::debug('Expect result to be -1 or 1 (not equal)');
|
||||
|
||||
return 0 !== $result;
|
||||
|
||||
case '>':
|
||||
Log::debug('Expect result to be 1 (greater then)');
|
||||
|
||||
return 1 === $result;
|
||||
|
||||
case '>=':
|
||||
Log::debug('Expect result to be 0 or 1 (greater then or equal)');
|
||||
|
||||
return -1 !== $result;
|
||||
|
||||
case '<':
|
||||
Log::debug('Expect result to be -1 (less than)');
|
||||
|
||||
return -1 === $result;
|
||||
|
||||
case '<=':
|
||||
Log::debug('Expect result to be -1 or 0 (less than or equal)');
|
||||
|
||||
return 1 !== $result;
|
||||
}
|
||||
// if($balance['balance'] $operator $value) {
|
||||
|
||||
// }
|
||||
}
|
||||
|
||||
return false;
|
||||
};
|
||||
$this->postFilters[] = $filter;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* These accounts must not be included.
|
||||
*/
|
||||
@@ -231,87 +314,4 @@ trait AccountCollection
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
#[\Override]
|
||||
public function accountBalanceIs(string $direction, string $operator, string $value): GroupCollectorInterface
|
||||
{
|
||||
Log::warning(sprintf('GroupCollector will be SLOW: accountBalanceIs: "%s" "%s" "%s"', $direction, $operator, $value));
|
||||
|
||||
/**
|
||||
* @param int $index
|
||||
* @param array $object
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
$filter = static function (array $object) use ($direction, $operator, $value): bool {
|
||||
/** @var array $transaction */
|
||||
foreach ($object['transactions'] as $transaction) {
|
||||
$key = sprintf('%s_account_id', $direction);
|
||||
$accountId = $transaction[$key] ?? 0;
|
||||
if (0 === $accountId) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// in theory, this could lead to finding other users accounts.
|
||||
/** @var null|Account $account */
|
||||
$account = Account::find($accountId);
|
||||
if (null === $account) {
|
||||
continue;
|
||||
}
|
||||
// the balance must be found BEFORE the transaction date.
|
||||
// so sub one second. This is not perfect, but works well enough.
|
||||
$date = clone $transaction['date'];
|
||||
$date->subSecond();
|
||||
Log::debug(sprintf('accountBalanceIs: Call finalAccountBalance with date/time "%s"', $date->toIso8601String()));
|
||||
$balance = Steam::finalAccountBalance($account, $date);
|
||||
$result = bccomp((string) $balance['balance'], $value);
|
||||
Log::debug(sprintf('"%s" vs "%s" is %d', $balance['balance'], $value, $result));
|
||||
|
||||
switch ($operator) {
|
||||
default:
|
||||
Log::error(sprintf('GroupCollector: accountBalanceIs: unknown operator "%s"', $operator));
|
||||
|
||||
return false;
|
||||
|
||||
case '==':
|
||||
Log::debug('Expect result to be 0 (equal)');
|
||||
|
||||
return 0 === $result;
|
||||
|
||||
case '!=':
|
||||
Log::debug('Expect result to be -1 or 1 (not equal)');
|
||||
|
||||
return 0 !== $result;
|
||||
|
||||
case '>':
|
||||
Log::debug('Expect result to be 1 (greater then)');
|
||||
|
||||
return 1 === $result;
|
||||
|
||||
case '>=':
|
||||
Log::debug('Expect result to be 0 or 1 (greater then or equal)');
|
||||
|
||||
return -1 !== $result;
|
||||
|
||||
case '<':
|
||||
Log::debug('Expect result to be -1 (less than)');
|
||||
|
||||
return -1 === $result;
|
||||
|
||||
case '<=':
|
||||
Log::debug('Expect result to be -1 or 0 (less than or equal)');
|
||||
|
||||
return 1 !== $result;
|
||||
}
|
||||
// if($balance['balance'] $operator $value) {
|
||||
|
||||
// }
|
||||
}
|
||||
|
||||
return false;
|
||||
};
|
||||
$this->postFilters[] = $filter;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
@@ -37,6 +37,7 @@ trait CollectorProperties
|
||||
|
||||
/** @var array<int, string> */
|
||||
public array $sorting;
|
||||
private array $booleanFields;
|
||||
private ?int $endRow;
|
||||
private bool $expandGroupSearch;
|
||||
private array $fields;
|
||||
@@ -55,7 +56,6 @@ trait CollectorProperties
|
||||
private HasMany $query;
|
||||
private ?int $startRow;
|
||||
private array $stringFields;
|
||||
private array $booleanFields;
|
||||
/*
|
||||
* This array is used to collect ALL tags the user may search for (using 'setTags').
|
||||
* This way the user can call 'setTags' multiple times and get a joined result.
|
||||
|
@@ -29,12 +29,12 @@ use FireflyIII\Models\Bill;
|
||||
use FireflyIII\Models\Budget;
|
||||
use FireflyIII\Models\Category;
|
||||
use FireflyIII\Models\Tag;
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Builder as EloquentBuilder;
|
||||
use Illuminate\Database\Query\JoinClause;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
|
||||
/**
|
||||
* Trait MetaCollection
|
||||
|
@@ -900,16 +900,6 @@ class GroupCollector implements GroupCollectorInterface
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Limit results to a specific currency, only normal one.
|
||||
*/
|
||||
public function setNormalCurrency(TransactionCurrency $currency): GroupCollectorInterface
|
||||
{
|
||||
$this->query->where('source.transaction_currency_id', $currency->id);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setEndRow(int $endRow): self
|
||||
{
|
||||
$this->endRow = $endRow;
|
||||
@@ -957,6 +947,16 @@ class GroupCollector implements GroupCollectorInterface
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Limit results to a specific currency, only normal one.
|
||||
*/
|
||||
public function setNormalCurrency(TransactionCurrency $currency): GroupCollectorInterface
|
||||
{
|
||||
$this->query->where('source.transaction_currency_id', $currency->id);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the page to get.
|
||||
*/
|
||||
|
@@ -41,6 +41,8 @@ use Illuminate\Support\Collection;
|
||||
*/
|
||||
interface GroupCollectorInterface
|
||||
{
|
||||
public function accountBalanceIs(string $direction, string $operator, string $value): self;
|
||||
|
||||
/**
|
||||
* Get transactions with a specific amount.
|
||||
*/
|
||||
@@ -457,11 +459,6 @@ interface GroupCollectorInterface
|
||||
*/
|
||||
public function setCurrency(TransactionCurrency $currency): self;
|
||||
|
||||
/**
|
||||
* Limit results to a specific currency, either foreign or normal one.
|
||||
*/
|
||||
public function setNormalCurrency(TransactionCurrency $currency): self;
|
||||
|
||||
/**
|
||||
* Set destination accounts.
|
||||
*/
|
||||
@@ -526,6 +523,11 @@ interface GroupCollectorInterface
|
||||
*/
|
||||
public function setMetaDateRange(Carbon $start, Carbon $end, string $field): self;
|
||||
|
||||
/**
|
||||
* Limit results to a specific currency, either foreign or normal one.
|
||||
*/
|
||||
public function setNormalCurrency(TransactionCurrency $currency): self;
|
||||
|
||||
/**
|
||||
* Define which accounts can NOT be part of the source and destination transactions.
|
||||
*/
|
||||
@@ -737,6 +739,4 @@ interface GroupCollectorInterface
|
||||
public function yearIs(string $year): self;
|
||||
|
||||
public function yearIsNot(string $year): self;
|
||||
|
||||
public function accountBalanceIs(string $direction, string $operator, string $value): self;
|
||||
}
|
||||
|
@@ -49,7 +49,7 @@ class NetWorth implements NetWorthInterface
|
||||
{
|
||||
private AccountRepositoryInterface $accountRepository;
|
||||
private CurrencyRepositoryInterface $currencyRepos;
|
||||
private User $user; // @phpstan-ignore-line
|
||||
private User $user; // @phpstan-ignore-line
|
||||
private ?UserGroup $userGroup = null; // @phpstan-ignore-line
|
||||
|
||||
/**
|
||||
|
@@ -29,8 +29,8 @@ use FireflyIII\Models\Account;
|
||||
use FireflyIII\Models\Budget;
|
||||
use FireflyIII\Models\Category;
|
||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
|
||||
use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;
|
||||
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
/**
|
||||
|
@@ -24,6 +24,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Http\Controllers\Account;
|
||||
|
||||
use FireflyIII\Models\Location;
|
||||
use FireflyIII\Helpers\Attachments\AttachmentHelperInterface;
|
||||
use FireflyIII\Http\Controllers\Controller;
|
||||
use FireflyIII\Http\Requests\AccountFormRequest;
|
||||
@@ -87,11 +88,11 @@ class EditController extends Controller
|
||||
$roles = $this->getRoles();
|
||||
$liabilityTypes = $this->getLiabilityTypes();
|
||||
$location = $repository->getLocation($account);
|
||||
$latitude = null !== $location ? $location->latitude : config('firefly.default_location.latitude');
|
||||
$longitude = null !== $location ? $location->longitude : config('firefly.default_location.longitude');
|
||||
$zoomLevel = null !== $location ? $location->zoom_level : config('firefly.default_location.zoom_level');
|
||||
$latitude = $location instanceof Location ? $location->latitude : config('firefly.default_location.latitude');
|
||||
$longitude = $location instanceof Location ? $location->longitude : config('firefly.default_location.longitude');
|
||||
$zoomLevel = $location instanceof Location ? $location->zoom_level : config('firefly.default_location.zoom_level');
|
||||
$canEditCurrency = 0 === $account->piggyBanks()->count();
|
||||
$hasLocation = null !== $location;
|
||||
$hasLocation = $location instanceof Location;
|
||||
$locations = [
|
||||
'location' => [
|
||||
'latitude' => old('location_latitude') ?? $latitude,
|
||||
|
@@ -121,6 +121,16 @@ class IndexController extends Controller
|
||||
return view('accounts.index', compact('objectType', 'inactivePage', 'subTitleIcon', 'subTitle', 'page', 'accounts'));
|
||||
}
|
||||
|
||||
private function subtract(array $startBalances, array $endBalances): array
|
||||
{
|
||||
$result = [];
|
||||
foreach ($endBalances as $key => $value) {
|
||||
$result[$key] = bcsub((string) $value, $startBalances[$key] ?? '0');
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Show list of accounts.
|
||||
*
|
||||
@@ -153,7 +163,9 @@ class IndexController extends Controller
|
||||
|
||||
/** @var Carbon $end */
|
||||
$end = clone session('end', today(config('app.timezone'))->endOfMonth());
|
||||
$start->subDay();
|
||||
|
||||
// 2025-05-11 removed this so start is exactly the start of the month.
|
||||
// $start->subDay();
|
||||
|
||||
$ids = $accounts->pluck('id')->toArray();
|
||||
Log::debug(sprintf('index start: finalAccountsBalance("%s")', $start->format('Y-m-d H:i:s')));
|
||||
@@ -199,14 +211,4 @@ class IndexController extends Controller
|
||||
|
||||
return view('accounts.index', compact('objectType', 'inactiveCount', 'subTitleIcon', 'subTitle', 'page', 'accounts'));
|
||||
}
|
||||
|
||||
private function subtract(array $startBalances, array $endBalances): array
|
||||
{
|
||||
$result = [];
|
||||
foreach ($endBalances as $key => $value) {
|
||||
$result[$key] = bcsub((string) $value, $startBalances[$key] ?? '0');
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
@@ -94,7 +94,7 @@ class ReconcileController extends Controller
|
||||
|
||||
// get start and end
|
||||
|
||||
if (null === $start && null === $end) {
|
||||
if (!$start instanceof Carbon && !$end instanceof Carbon) {
|
||||
/** @var Carbon $start */
|
||||
$start = clone session('start', app('navigation')->startOfPeriod(new Carbon(), $range));
|
||||
|
||||
@@ -225,10 +225,10 @@ class ReconcileController extends Controller
|
||||
]
|
||||
);
|
||||
$submission = [
|
||||
'user' => auth()->user(),
|
||||
'user_group' => auth()->user()->userGroup,
|
||||
'group_title' => null,
|
||||
'transactions' => [
|
||||
'user' => auth()->user(),
|
||||
'user_group' => auth()->user()->userGroup,
|
||||
'group_title' => null,
|
||||
'transactions' => [
|
||||
[
|
||||
'user' => auth()->user(),
|
||||
'user_group' => auth()->user()->userGroup,
|
||||
|
@@ -33,7 +33,6 @@ use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||
use FireflyIII\Support\Debug\Timer;
|
||||
use FireflyIII\Support\Facades\Steam;
|
||||
use FireflyIII\Support\Http\Controllers\PeriodOverview;
|
||||
use FireflyIII\Support\JsonApi\Enrichments\TransactionGroupEnrichment;
|
||||
use Illuminate\Contracts\View\Factory;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
@@ -23,6 +23,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Http\Controllers\Admin;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use FireflyIII\Helpers\Update\UpdateTrait;
|
||||
use FireflyIII\Http\Controllers\Controller;
|
||||
use FireflyIII\Http\Middleware\IsDemoUser;
|
||||
@@ -96,7 +97,7 @@ class UpdateController extends Controller
|
||||
$channel = in_array($channel, ['stable', 'beta', 'alpha'], true) ? $channel : 'stable';
|
||||
|
||||
app('fireflyconfig')->set('permission_update_check', $checkForUpdates);
|
||||
app('fireflyconfig')->set('last_update_check', time());
|
||||
app('fireflyconfig')->set('last_update_check', Carbon::now()->getTimestamp());
|
||||
app('fireflyconfig')->set('update_channel', $channel);
|
||||
session()->flash('success', (string) trans('firefly.configuration_updated'));
|
||||
|
||||
|
@@ -34,6 +34,8 @@ use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\View\View;
|
||||
|
||||
use function Safe\parse_url;
|
||||
|
||||
/**
|
||||
* Class ForgotPasswordController
|
||||
*/
|
||||
@@ -101,7 +103,7 @@ class ForgotPasswordController extends Controller
|
||||
*/
|
||||
private function validateHost(): void
|
||||
{
|
||||
$configuredHost = \Safe\parse_url((string) config('app.url'), PHP_URL_HOST);
|
||||
$configuredHost = parse_url((string) config('app.url'), PHP_URL_HOST);
|
||||
if (false === $configuredHost || null === $configuredHost) {
|
||||
throw new FireflyException('Please set a valid and correct Firefly III URL in the APP_URL environment variable.');
|
||||
}
|
||||
|
@@ -23,7 +23,9 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Http\Controllers\Auth;
|
||||
|
||||
use Cookie;
|
||||
use Carbon\Carbon;
|
||||
use FireflyIII\User;
|
||||
use Illuminate\Support\Facades\Cookie;
|
||||
use FireflyIII\Events\ActuallyLoggedIn;
|
||||
use FireflyIII\Events\Security\UnknownUserAttemptedLogin;
|
||||
use FireflyIII\Events\Security\UserAttemptedLogin;
|
||||
@@ -44,6 +46,7 @@ use Illuminate\Routing\Redirector;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Validation\ValidationException;
|
||||
use Symfony\Component\HttpFoundation\Response as ResponseAlias;
|
||||
|
||||
/**
|
||||
* Class LoginController
|
||||
@@ -130,11 +133,11 @@ class LoginController extends Controller
|
||||
app('log')->warning('Login attempt failed.');
|
||||
$username = (string) $request->get($this->username());
|
||||
$user = $this->repository->findByEmail($username);
|
||||
if (null === $user) {
|
||||
if (!$user instanceof User) {
|
||||
// send event to owner.
|
||||
event(new UnknownUserAttemptedLogin($username));
|
||||
}
|
||||
if (null !== $user) {
|
||||
if ($user instanceof User) {
|
||||
event(new UserAttemptedLogin($user));
|
||||
}
|
||||
|
||||
@@ -198,7 +201,7 @@ class LoginController extends Controller
|
||||
|
||||
// also logout current 2FA tokens.
|
||||
$cookieName = config('google2fa.cookie_name', 'google2fa_token');
|
||||
\Cookie::forget($cookieName);
|
||||
Cookie::forget($cookieName);
|
||||
|
||||
$this->guard()->logout();
|
||||
|
||||
@@ -209,7 +212,7 @@ class LoginController extends Controller
|
||||
$this->loggedOut($request);
|
||||
|
||||
return $request->wantsJson()
|
||||
? new Response('', 204)
|
||||
? new Response('', ResponseAlias::HTTP_NO_CONTENT)
|
||||
: redirect('/');
|
||||
}
|
||||
|
||||
@@ -220,7 +223,7 @@ class LoginController extends Controller
|
||||
*
|
||||
* @throws FireflyException
|
||||
*/
|
||||
public function showLoginForm(Request $request)
|
||||
public function showLoginForm(?Request $request = null)
|
||||
{
|
||||
Log::channel('audit')->info('Show login form (1.1).');
|
||||
|
||||
@@ -246,13 +249,13 @@ class LoginController extends Controller
|
||||
$allowReset = false;
|
||||
}
|
||||
|
||||
$email = $request->old('email');
|
||||
$remember = $request->old('remember');
|
||||
$email = $request?->old('email');
|
||||
$remember = $request?->old('remember');
|
||||
|
||||
$storeInCookie = config('google2fa.store_in_cookie', false);
|
||||
if (false !== $storeInCookie) {
|
||||
$cookieName = config('google2fa.cookie_name', 'google2fa_token');
|
||||
\Cookie::queue(\Cookie::make($cookieName, 'invalid-'.time()));
|
||||
Cookie::queue(Cookie::make($cookieName, 'invalid-'.Carbon::now()->getTimestamp()));
|
||||
}
|
||||
$usernameField = $this->username();
|
||||
|
||||
|
@@ -130,7 +130,7 @@ class RegisterController extends Controller
|
||||
$allowRegistration = false;
|
||||
}
|
||||
if ('web' !== $guard) {
|
||||
$allowRegistration = false;
|
||||
return false;
|
||||
}
|
||||
|
||||
return $allowRegistration;
|
||||
@@ -175,7 +175,7 @@ class RegisterController extends Controller
|
||||
*
|
||||
* @throws FireflyException
|
||||
*/
|
||||
public function showRegistrationForm(Request $request)
|
||||
public function showRegistrationForm(?Request $request = null)
|
||||
{
|
||||
$isDemoSite = app('fireflyconfig')->get('is_demo_site', config('firefly.configuration.is_demo_site'))->data;
|
||||
$pageTitle = (string) trans('firefly.register_page_title');
|
||||
@@ -187,7 +187,7 @@ class RegisterController extends Controller
|
||||
return view('error', compact('message'));
|
||||
}
|
||||
|
||||
$email = $request->old('email');
|
||||
$email = $request?->old('email');
|
||||
|
||||
return view('auth.register', compact('isDemoSite', 'email', 'pageTitle'));
|
||||
}
|
||||
|
@@ -23,6 +23,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Http\Controllers\Auth;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use FireflyIII\Events\Security\MFABackupFewLeft;
|
||||
use FireflyIII\Events\Security\MFABackupNoLeft;
|
||||
use FireflyIII\Events\Security\MFAManyFailedAttempts;
|
||||
@@ -129,7 +130,7 @@ class TwoFactorController extends Controller
|
||||
*/
|
||||
private function inMFAHistory(string $mfaCode, array $mfaHistory): bool
|
||||
{
|
||||
$now = time();
|
||||
$now = Carbon::now()->getTimestamp();
|
||||
foreach ($mfaHistory as $entry) {
|
||||
$time = $entry['time'];
|
||||
$code = $entry['code'];
|
||||
@@ -149,7 +150,7 @@ class TwoFactorController extends Controller
|
||||
/** @var array $mfaHistory */
|
||||
$mfaHistory = app('preferences')->get('mfa_history', [])->data;
|
||||
$newHistory = [];
|
||||
$now = time();
|
||||
$now = Carbon::now()->getTimestamp();
|
||||
foreach ($mfaHistory as $entry) {
|
||||
$time = $entry['time'];
|
||||
$code = $entry['code'];
|
||||
@@ -184,7 +185,7 @@ class TwoFactorController extends Controller
|
||||
/** @var array $mfaHistory */
|
||||
$mfaHistory = app('preferences')->get('mfa_history', [])->data;
|
||||
$entry = [
|
||||
'time' => time(),
|
||||
'time' => Carbon::now()->getTimestamp(),
|
||||
'code' => $mfaCode,
|
||||
];
|
||||
$mfaHistory[] = $entry;
|
||||
|
@@ -143,13 +143,13 @@ class BudgetLimitController extends Controller
|
||||
// first search for existing one and update it if necessary.
|
||||
$currency = $this->currencyRepos->find((int) $request->get('transaction_currency_id'));
|
||||
$budget = $this->repository->find((int) $request->get('budget_id'));
|
||||
if (null === $currency || null === $budget) {
|
||||
if (!$currency instanceof TransactionCurrency || !$budget instanceof Budget) {
|
||||
throw new FireflyException('No valid currency or budget.');
|
||||
}
|
||||
$start = Carbon::createFromFormat('Y-m-d', $request->get('start'));
|
||||
$end = Carbon::createFromFormat('Y-m-d', $request->get('end'));
|
||||
|
||||
if (null === $start || null === $end) {
|
||||
if (!$start instanceof Carbon || !$end instanceof Carbon) {
|
||||
return response()->json([]);
|
||||
}
|
||||
|
||||
@@ -167,7 +167,7 @@ class BudgetLimitController extends Controller
|
||||
|
||||
// sanity check on amount:
|
||||
if (0 === bccomp($amount, '0')) {
|
||||
if (null !== $limit) {
|
||||
if ($limit instanceof BudgetLimit) {
|
||||
$this->blRepository->destroyBudgetLimit($limit);
|
||||
}
|
||||
|
||||
@@ -181,11 +181,11 @@ class BudgetLimitController extends Controller
|
||||
$amount = bcmul($amount, '-1');
|
||||
}
|
||||
|
||||
if (null !== $limit) {
|
||||
if ($limit instanceof BudgetLimit) {
|
||||
$limit->amount = $amount;
|
||||
$limit->save();
|
||||
}
|
||||
if (null === $limit) {
|
||||
if (!$limit instanceof BudgetLimit) {
|
||||
$limit = $this->blRepository->store(
|
||||
[
|
||||
'budget_id' => $request->get('budget_id'),
|
||||
|
@@ -24,6 +24,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Http\Controllers\Budget;
|
||||
|
||||
use FireflyIII\Models\AutoBudget;
|
||||
use FireflyIII\Enums\AutoBudgetType;
|
||||
use FireflyIII\Helpers\Attachments\AttachmentHelperInterface;
|
||||
use FireflyIII\Http\Controllers\Controller;
|
||||
@@ -95,7 +96,7 @@ class EditController extends Controller
|
||||
'active' => $hasOldInput ? (bool) $request->old('active') : $budget->active,
|
||||
'auto_budget_currency_id' => $hasOldInput ? (int) $request->old('auto_budget_currency_id') : $this->defaultCurrency->id,
|
||||
];
|
||||
if (null !== $autoBudget) {
|
||||
if ($autoBudget instanceof AutoBudget) {
|
||||
$amount = $hasOldInput ? $request->old('auto_budget_amount') : $autoBudget->amount;
|
||||
if (is_array($amount)) {
|
||||
$amount = '0';
|
||||
|
@@ -316,7 +316,7 @@ class IndexController extends Controller
|
||||
foreach ($budgetIds as $index => $budgetId) {
|
||||
$budgetId = (int) $budgetId;
|
||||
$budget = $repository->find($budgetId);
|
||||
if (null !== $budget) {
|
||||
if ($budget instanceof Budget) {
|
||||
app('log')->debug(sprintf('Set budget #%d ("%s") to position %d', $budget->id, $budget->name, $index + 1));
|
||||
$repository->setBudgetOrder($budget, $index + 1);
|
||||
}
|
||||
|
@@ -24,6 +24,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Http\Controllers\Budget;
|
||||
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
use Carbon\Carbon;
|
||||
use FireflyIII\Enums\TransactionTypeEnum;
|
||||
use FireflyIII\Exceptions\FireflyException;
|
||||
@@ -90,7 +91,7 @@ class ShowController extends Controller
|
||||
|
||||
// get first journal ever to set off the budget period overview.
|
||||
$first = $this->journalRepos->firstNull();
|
||||
$firstDate = null !== $first ? $first->date : $start;
|
||||
$firstDate = $first instanceof TransactionJournal ? $first->date : $start;
|
||||
$periods = $this->getNoBudgetPeriodOverview($firstDate, $end);
|
||||
$page = (int) $request->get('page');
|
||||
$pageSize = (int) app('preferences')->get('listPageSize', 50)->data;
|
||||
@@ -115,7 +116,7 @@ class ShowController extends Controller
|
||||
{
|
||||
$subTitle = (string) trans('firefly.all_journals_without_budget');
|
||||
$first = $this->journalRepos->firstNull();
|
||||
$start = null === $first ? new Carbon() : $first->date;
|
||||
$start = $first instanceof TransactionJournal ? $first->date : new Carbon();
|
||||
$end = today(config('app.timezone'));
|
||||
$page = (int) $request->get('page');
|
||||
$pageSize = (int) app('preferences')->get('listPageSize', 50)->data;
|
||||
|
@@ -24,6 +24,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Http\Controllers\Category;
|
||||
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
use Carbon\Carbon;
|
||||
use FireflyIII\Enums\TransactionTypeEnum;
|
||||
use FireflyIII\Exceptions\FireflyException;
|
||||
@@ -119,7 +120,7 @@ class NoCategoryController extends Controller
|
||||
app('log')->debug('Start of noCategory()');
|
||||
$subTitle = (string) trans('firefly.all_journals_without_category');
|
||||
$first = $this->journalRepos->firstNull();
|
||||
$start = null === $first ? new Carbon() : $first->date;
|
||||
$start = $first instanceof TransactionJournal ? $first->date : new Carbon();
|
||||
$end = today(config('app.timezone'));
|
||||
app('log')->debug(sprintf('Start for noCategory() is %s', $start->format('Y-m-d')));
|
||||
app('log')->debug(sprintf('End for noCategory() is %s', $end->format('Y-m-d')));
|
||||
|
@@ -35,7 +35,6 @@ use FireflyIII\Models\TransactionCurrency;
|
||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||
use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;
|
||||
use FireflyIII\Support\CacheProperties;
|
||||
use FireflyIII\Support\Facades\Amount;
|
||||
use FireflyIII\Support\Facades\Steam;
|
||||
use FireflyIII\Support\Http\Controllers\AugumentData;
|
||||
use FireflyIII\Support\Http\Controllers\ChartGeneration;
|
||||
@@ -44,6 +43,8 @@ use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
use function Safe\json_encode;
|
||||
|
||||
/**
|
||||
* Class AccountController.
|
||||
*/
|
||||
@@ -469,14 +470,14 @@ class AccountController extends Controller
|
||||
Log::debug('Balances exist at:');
|
||||
foreach ($range as $key => $value) {
|
||||
$newRange[] = ['date' => $key, 'info' => $value];
|
||||
Log::debug(sprintf('%d - %s (%s)', count($newRange) - 1, $key, \Safe\json_encode($value)));
|
||||
Log::debug(sprintf('%d - %s (%s)', count($newRange) - 1, $key, json_encode($value)));
|
||||
}
|
||||
$carbon = Carbon::createFromFormat('Y-m-d', $newRange[0]['date'])->endOfDay();
|
||||
Log::debug(sprintf('Start of loop, $carbon is %s', $carbon->format('Y-m-d H:i:s')));
|
||||
while ($end->gte($current)) {
|
||||
$momentBalance = $previous;
|
||||
// $theDate = $current->format('Y-m-d');
|
||||
Log::debug(sprintf('Now at %s, with momentBalance %s', $current->format('Y-m-d H:i:s'), \Safe\json_encode($momentBalance)));
|
||||
Log::debug(sprintf('Now at %s, with momentBalance %s', $current->format('Y-m-d H:i:s'), json_encode($momentBalance)));
|
||||
|
||||
// loop over the array with balances, find one that is earlier or on the same day.
|
||||
while ($carbon->lte($current) && array_key_exists($expectedIndex, $newRange)) {
|
||||
@@ -491,7 +492,7 @@ class AccountController extends Controller
|
||||
$carbon = Carbon::createFromFormat('Y-m-d', $newRange[$expectedIndex]['date'])->endOfDay();
|
||||
}
|
||||
}
|
||||
Log::debug(sprintf('momentBalance is now %s', \Safe\json_encode($momentBalance)));
|
||||
Log::debug(sprintf('momentBalance is now %s', json_encode($momentBalance)));
|
||||
$return = $this->updateChartKeys($return, $momentBalance);
|
||||
$previous = $momentBalance;
|
||||
|
||||
@@ -535,6 +536,17 @@ class AccountController extends Controller
|
||||
return response()->json($data);
|
||||
}
|
||||
|
||||
private function updateChartKeys(array $array, array $balances): array
|
||||
{
|
||||
foreach (array_keys($balances) as $key) {
|
||||
$array[$key] ??= [
|
||||
'key' => $key,
|
||||
];
|
||||
}
|
||||
|
||||
return $array;
|
||||
}
|
||||
|
||||
/**
|
||||
* Shows the balances for a given set of dates and accounts.
|
||||
*
|
||||
@@ -676,15 +688,4 @@ class AccountController extends Controller
|
||||
|
||||
return response()->json($data);
|
||||
}
|
||||
|
||||
private function updateChartKeys(array $array, array $balances): array
|
||||
{
|
||||
foreach (array_keys($balances) as $key) {
|
||||
$array[$key] ??= [
|
||||
'key' => $key,
|
||||
];
|
||||
}
|
||||
|
||||
return $array;
|
||||
}
|
||||
}
|
||||
|
@@ -38,7 +38,6 @@ use FireflyIII\Repositories\Budget\NoBudgetRepositoryInterface;
|
||||
use FireflyIII\Repositories\Budget\OperationsRepositoryInterface;
|
||||
use FireflyIII\Support\CacheProperties;
|
||||
use FireflyIII\Support\Chart\Budget\FrontpageChartGenerator;
|
||||
use FireflyIII\Support\Facades\Amount;
|
||||
use FireflyIII\Support\Http\Controllers\AugumentData;
|
||||
use FireflyIII\Support\Http\Controllers\DateCalculation;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
@@ -203,7 +202,7 @@ class BudgetController extends Controller
|
||||
{
|
||||
/** @var GroupCollectorInterface $collector */
|
||||
$collector = app(GroupCollectorInterface::class);
|
||||
$budgetLimitId = null === $budgetLimit ? 0 : $budgetLimit->id;
|
||||
$budgetLimitId = $budgetLimit instanceof BudgetLimit ? $budgetLimit->id : 0;
|
||||
$cache = new CacheProperties();
|
||||
$cache->addProperty($budget->id);
|
||||
$cache->addProperty($this->convertToNative);
|
||||
@@ -212,7 +211,7 @@ class BudgetController extends Controller
|
||||
$start = session('first', today(config('app.timezone'))->startOfYear());
|
||||
$end = today();
|
||||
|
||||
if (null !== $budgetLimit) {
|
||||
if ($budgetLimit instanceof BudgetLimit) {
|
||||
$start = $budgetLimit->start_date;
|
||||
$end = $budgetLimit->end_date;
|
||||
$collector->setRange($budgetLimit->start_date, $budgetLimit->end_date)->setNormalCurrency($budgetLimit->transactionCurrency);
|
||||
@@ -286,7 +285,7 @@ class BudgetController extends Controller
|
||||
{
|
||||
/** @var GroupCollectorInterface $collector */
|
||||
$collector = app(GroupCollectorInterface::class);
|
||||
$budgetLimitId = null === $budgetLimit ? 0 : $budgetLimit->id;
|
||||
$budgetLimitId = $budgetLimit instanceof BudgetLimit ? $budgetLimit->id : 0;
|
||||
$cache = new CacheProperties();
|
||||
$cache->addProperty($budget->id);
|
||||
$cache->addProperty($this->convertToNative);
|
||||
@@ -294,7 +293,7 @@ class BudgetController extends Controller
|
||||
$cache->addProperty('chart.budget.expense-category');
|
||||
$start = session('first', today(config('app.timezone'))->startOfYear());
|
||||
$end = today();
|
||||
if (null !== $budgetLimit) {
|
||||
if ($budgetLimit instanceof BudgetLimit) {
|
||||
$start = $budgetLimit->start_date;
|
||||
$end = $budgetLimit->end_date;
|
||||
$collector->setNormalCurrency($budgetLimit->transactionCurrency);
|
||||
@@ -368,7 +367,7 @@ class BudgetController extends Controller
|
||||
{
|
||||
/** @var GroupCollectorInterface $collector */
|
||||
$collector = app(GroupCollectorInterface::class);
|
||||
$budgetLimitId = null === $budgetLimit ? 0 : $budgetLimit->id;
|
||||
$budgetLimitId = $budgetLimit instanceof BudgetLimit ? $budgetLimit->id : 0;
|
||||
$cache = new CacheProperties();
|
||||
$cache->addProperty($budget->id);
|
||||
$cache->addProperty($budgetLimitId);
|
||||
@@ -376,7 +375,7 @@ class BudgetController extends Controller
|
||||
$cache->addProperty('chart.budget.expense-expense');
|
||||
$start = session('first', today(config('app.timezone'))->startOfYear());
|
||||
$end = today();
|
||||
if (null !== $budgetLimit) {
|
||||
if ($budgetLimit instanceof BudgetLimit) {
|
||||
$start = $budgetLimit->start_date;
|
||||
$end = $budgetLimit->end_date;
|
||||
$collector->setRange($budgetLimit->start_date, $budgetLimit->end_date)->setNormalCurrency($budgetLimit->transactionCurrency);
|
||||
@@ -530,7 +529,7 @@ class BudgetController extends Controller
|
||||
|
||||
// get budget limit in this period for this currency.
|
||||
$limit = $this->blRepository->find($budget, $currency, $currentStart, $currentEnd);
|
||||
if (null !== $limit) {
|
||||
if ($limit instanceof BudgetLimit) {
|
||||
$chartData[1]['entries'][$title] = app('steam')->bcround($limit->amount, $currency->decimal_places);
|
||||
}
|
||||
|
||||
|
@@ -159,7 +159,7 @@ class CategoryController extends Controller
|
||||
$income = [];
|
||||
$expenses = [];
|
||||
$categoryId = 0;
|
||||
if (null === $category) {
|
||||
if (!$category instanceof Category) {
|
||||
/** @var NoCategoryRepositoryInterface $noCatRepository */
|
||||
$noCatRepository = app(NoCategoryRepositoryInterface::class);
|
||||
|
||||
@@ -168,7 +168,7 @@ class CategoryController extends Controller
|
||||
$income = $noCatRepository->listIncome($start, $end, $accounts);
|
||||
}
|
||||
|
||||
if (null !== $category) {
|
||||
if ($category instanceof Category) {
|
||||
/** @var OperationsRepositoryInterface $opsRepository */
|
||||
$opsRepository = app(OperationsRepositoryInterface::class);
|
||||
$categoryId = $category->id;
|
||||
|
@@ -23,6 +23,8 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Http\Controllers;
|
||||
|
||||
use function Safe\realpath;
|
||||
use function Safe\ini_get;
|
||||
use FireflyIII\Models\TransactionCurrency;
|
||||
use FireflyIII\Support\Facades\Amount;
|
||||
use FireflyIII\Support\Facades\Steam;
|
||||
@@ -32,8 +34,9 @@ use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
|
||||
use Illuminate\Foundation\Bus\DispatchesJobs;
|
||||
use Illuminate\Foundation\Validation\ValidatesRequests;
|
||||
use Illuminate\Routing\Controller as BaseController;
|
||||
use Illuminate\Support\Facades\Config;
|
||||
use Illuminate\Support\Facades\View;
|
||||
use Route;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
|
||||
/**
|
||||
* Class Controller.
|
||||
@@ -51,13 +54,12 @@ abstract class Controller extends BaseController
|
||||
|
||||
// fails on PHP < 8.4
|
||||
public protected(set) string $name;
|
||||
|
||||
protected string $dateTimeFormat;
|
||||
protected string $monthAndDayFormat;
|
||||
protected bool $convertToNative = false;
|
||||
protected bool $convertToNative = false;
|
||||
protected string $dateTimeFormat;
|
||||
protected ?TransactionCurrency $defaultCurrency;
|
||||
protected string $monthFormat;
|
||||
protected string $redirectUrl = '/';
|
||||
protected string $monthAndDayFormat;
|
||||
protected string $monthFormat;
|
||||
protected string $redirectUrl = '/';
|
||||
|
||||
/**
|
||||
* Controller constructor.
|
||||
@@ -81,21 +83,23 @@ abstract class Controller extends BaseController
|
||||
|
||||
// overrule v2 layout back to v1.
|
||||
if ('true' === request()->get('force_default_layout') && 'v2' === config('view.layout')) {
|
||||
View::getFinder()->setPaths([\Safe\realpath(base_path('resources/views'))]); // @phpstan-ignore-line
|
||||
//config('view.layout','v1');
|
||||
Config::set('view.layout', 'v1');
|
||||
View::getFinder()->setPaths([realpath(base_path('resources/views'))]); // @phpstan-ignore-line
|
||||
}
|
||||
|
||||
View::share('authGuard', $authGuard);
|
||||
View::share('logoutUrl', $logoutUrl);
|
||||
|
||||
// upload size
|
||||
$maxFileSize = Steam::phpBytes((string) \Safe\ini_get('upload_max_filesize'));
|
||||
$maxPostSize = Steam::phpBytes((string) \Safe\ini_get('post_max_size'));
|
||||
$maxFileSize = Steam::phpBytes((string) ini_get('upload_max_filesize'));
|
||||
$maxPostSize = Steam::phpBytes((string) ini_get('post_max_size'));
|
||||
$uploadSize = min($maxFileSize, $maxPostSize);
|
||||
View::share('uploadSize', $uploadSize);
|
||||
|
||||
// share is alpha, is beta
|
||||
$isAlpha = false;
|
||||
$isBeta = false;
|
||||
$isAlpha = false;
|
||||
$isBeta = false;
|
||||
$isDevelop = false;
|
||||
if (str_contains((string) config('firefly.version'), 'alpha')) {
|
||||
$isAlpha = true;
|
||||
@@ -120,16 +124,16 @@ abstract class Controller extends BaseController
|
||||
$this->monthAndDayFormat = (string) trans('config.month_and_day_js', [], $locale);
|
||||
$this->dateTimeFormat = (string) trans('config.date_time_js', [], $locale);
|
||||
$darkMode = 'browser';
|
||||
$this->defaultCurrency =null;
|
||||
$this->defaultCurrency = null;
|
||||
// get shown-intro-preference:
|
||||
if (auth()->check()) {
|
||||
$this->defaultCurrency = Amount::getNativeCurrency();
|
||||
$language = Steam::getLanguage();
|
||||
$locale = Steam::getLocale();
|
||||
$darkMode = app('preferences')->get('darkMode', 'browser')->data;
|
||||
$this->convertToNative =Amount::convertToNative();
|
||||
$page = $this->getPageName();
|
||||
$shownDemo = $this->hasSeenDemo();
|
||||
$this->defaultCurrency = Amount::getNativeCurrency();
|
||||
$language = Steam::getLanguage();
|
||||
$locale = Steam::getLocale();
|
||||
$darkMode = app('preferences')->get('darkMode', 'browser')->data;
|
||||
$this->convertToNative = Amount::convertToNative();
|
||||
$page = $this->getPageName();
|
||||
$shownDemo = $this->hasSeenDemo();
|
||||
View::share('language', $language);
|
||||
View::share('locale', $locale);
|
||||
View::share('convertToNative', $this->convertToNative);
|
||||
|
@@ -25,6 +25,7 @@ declare(strict_types=1);
|
||||
namespace FireflyIII\Http\Controllers;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Exception;
|
||||
use FireflyIII\Enums\AccountTypeEnum;
|
||||
use FireflyIII\Enums\TransactionTypeEnum;
|
||||
use FireflyIII\Exceptions\FireflyException;
|
||||
@@ -49,6 +50,9 @@ use Illuminate\View\View;
|
||||
use Monolog\Handler\RotatingFileHandler;
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
|
||||
use function Safe\file_get_contents;
|
||||
use function Safe\ini_get;
|
||||
|
||||
/**
|
||||
* Class DebugController
|
||||
*/
|
||||
@@ -65,110 +69,6 @@ class DebugController extends Controller
|
||||
$this->middleware(IsDemoUser::class)->except(['displayError']);
|
||||
}
|
||||
|
||||
public function routes(Request $request): never
|
||||
{
|
||||
if (!auth()->user()->hasRole('owner')) {
|
||||
throw new NotFoundHttpException();
|
||||
}
|
||||
|
||||
/** @var iterable $routes */
|
||||
$routes = Route::getRoutes();
|
||||
|
||||
if ('true' === $request->get('api')) {
|
||||
$collection = [];
|
||||
$i = 0;
|
||||
|
||||
echo 'PATHS="';
|
||||
|
||||
/** @var \Illuminate\Routing\Route $route */
|
||||
foreach ($routes as $route) {
|
||||
++$i;
|
||||
// skip API and other routes.
|
||||
if (!str_starts_with($route->uri(), 'api/v1')
|
||||
) {
|
||||
continue;
|
||||
}
|
||||
// skip non GET routes
|
||||
if (!in_array('GET', $route->methods(), true)) {
|
||||
continue;
|
||||
}
|
||||
// no name route:
|
||||
if (null === $route->getName()) {
|
||||
var_dump($route);
|
||||
|
||||
exit;
|
||||
}
|
||||
|
||||
echo substr($route->uri(), 3);
|
||||
if (0 === $i % 5) {
|
||||
echo '"<br>PATHS="${PATHS},';
|
||||
}
|
||||
if (0 !== $i % 5) {
|
||||
echo ',';
|
||||
}
|
||||
}
|
||||
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
|
||||
$return = [];
|
||||
|
||||
/** @var \Illuminate\Routing\Route $route */
|
||||
foreach ($routes as $route) {
|
||||
// skip API and other routes.
|
||||
if (
|
||||
str_starts_with($route->uri(), 'api')
|
||||
|| str_starts_with($route->uri(), '_debugbar')
|
||||
|| str_starts_with($route->uri(), '_ignition')
|
||||
|| str_starts_with($route->uri(), 'oauth')
|
||||
|| str_starts_with($route->uri(), 'chart')
|
||||
|| str_starts_with($route->uri(), 'v1/jscript')
|
||||
|| str_starts_with($route->uri(), 'v2/jscript')
|
||||
|| str_starts_with($route->uri(), 'json')
|
||||
|| str_starts_with($route->uri(), 'sanctum')
|
||||
) {
|
||||
continue;
|
||||
}
|
||||
// skip non GET routes
|
||||
if (!in_array('GET', $route->methods(), true)) {
|
||||
continue;
|
||||
}
|
||||
// no name route:
|
||||
if (null === $route->getName()) {
|
||||
var_dump($route);
|
||||
|
||||
exit;
|
||||
}
|
||||
if (!str_contains($route->uri(), '{')) {
|
||||
|
||||
$return[$route->getName()] = route($route->getName());
|
||||
|
||||
continue;
|
||||
}
|
||||
$params = [];
|
||||
foreach ($route->parameterNames() as $name) {
|
||||
$params[] = $this->getParameter($name);
|
||||
}
|
||||
$return[$route->getName()] = route($route->getName(), $params);
|
||||
}
|
||||
$count = 0;
|
||||
echo '<hr>';
|
||||
echo '<h1>Routes</h1>';
|
||||
echo sprintf('<h2>%s</h2>', $count);
|
||||
foreach ($return as $name => $path) {
|
||||
echo sprintf('<a href="%1$s">%2$s</a><br>', $path, $name).PHP_EOL;
|
||||
++$count;
|
||||
if (0 === $count % 10) {
|
||||
echo '<hr>';
|
||||
echo sprintf('<h2>%s</h2>', $count);
|
||||
}
|
||||
}
|
||||
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Show all possible errors.
|
||||
*
|
||||
@@ -242,7 +142,7 @@ class DebugController extends Controller
|
||||
if ($handler instanceof RotatingFileHandler) {
|
||||
$logFile = $handler->getUrl();
|
||||
if (null !== $logFile && file_exists($logFile)) {
|
||||
$logContent = \Safe\file_get_contents($logFile);
|
||||
$logContent = file_get_contents($logFile);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -267,8 +167,8 @@ class DebugController extends Controller
|
||||
|
||||
private function getSystemInformation(): array
|
||||
{
|
||||
$maxFileSize = Steam::phpBytes((string) \Safe\ini_get('upload_max_filesize'));
|
||||
$maxPostSize = Steam::phpBytes((string) \Safe\ini_get('post_max_size'));
|
||||
$maxFileSize = Steam::phpBytes((string) ini_get('upload_max_filesize'));
|
||||
$maxPostSize = Steam::phpBytes((string) ini_get('post_max_size'));
|
||||
$drivers = DB::availableDrivers();
|
||||
$currentDriver = DB::getDriverName();
|
||||
|
||||
@@ -280,8 +180,8 @@ class DebugController extends Controller
|
||||
'interface' => \PHP_SAPI,
|
||||
'bits' => \PHP_INT_SIZE * 8,
|
||||
'bcscale' => bcscale(),
|
||||
'display_errors' => \Safe\ini_get('display_errors'),
|
||||
'error_reporting' => $this->errorReporting((int) \Safe\ini_get('error_reporting')),
|
||||
'display_errors' => ini_get('display_errors'),
|
||||
'error_reporting' => $this->errorReporting((int) ini_get('error_reporting')),
|
||||
'upload_size' => min($maxFileSize, $maxPostSize),
|
||||
'all_drivers' => $drivers,
|
||||
'current_driver' => $currentDriver,
|
||||
@@ -300,7 +200,7 @@ class DebugController extends Controller
|
||||
|
||||
try {
|
||||
if (file_exists('/var/www/counter-main.txt')) {
|
||||
$return['build'] = trim((string) \Safe\file_get_contents('/var/www/counter-main.txt'));
|
||||
$return['build'] = trim((string) file_get_contents('/var/www/counter-main.txt'));
|
||||
app('log')->debug(sprintf('build is now "%s"', $return['build']));
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
@@ -310,16 +210,16 @@ class DebugController extends Controller
|
||||
|
||||
try {
|
||||
if (file_exists('/var/www/build-date-main.txt')) {
|
||||
$return['build_date'] = trim((string) \Safe\file_get_contents('/var/www/build-date-main.txt'));
|
||||
$return['build_date'] = trim((string) file_get_contents('/var/www/build-date-main.txt'));
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
app('log')->debug('Could not check build date, but thats ok.');
|
||||
app('log')->warning($e->getMessage());
|
||||
}
|
||||
if ('' !== (string) env('BASE_IMAGE_BUILD')) { // @phpstan-ignore-line
|
||||
if ('' !== (string) env('BASE_IMAGE_BUILD')) { // @phpstan-ignore-line
|
||||
$return['base_build'] = env('BASE_IMAGE_BUILD'); // @phpstan-ignore-line
|
||||
}
|
||||
if ('' !== (string) env('BASE_IMAGE_DATE')) { // @phpstan-ignore-line
|
||||
if ('' !== (string) env('BASE_IMAGE_DATE')) { // @phpstan-ignore-line
|
||||
$return['base_build_date'] = env('BASE_IMAGE_DATE'); // @phpstan-ignore-line
|
||||
}
|
||||
|
||||
@@ -442,19 +342,107 @@ class DebugController extends Controller
|
||||
return implode(' ', $flags);
|
||||
}
|
||||
|
||||
/**
|
||||
* Flash all types of messages.
|
||||
*
|
||||
* @return Redirector|RedirectResponse
|
||||
*/
|
||||
public function testFlash(Request $request)
|
||||
public function routes(Request $request): never
|
||||
{
|
||||
$request->session()->flash('success', 'This is a success message.');
|
||||
$request->session()->flash('info', 'This is an info message.');
|
||||
$request->session()->flash('warning', 'This is a warning.');
|
||||
$request->session()->flash('error', 'This is an error!');
|
||||
if (!auth()->user()->hasRole('owner')) {
|
||||
throw new NotFoundHttpException();
|
||||
}
|
||||
|
||||
return redirect(route('home'));
|
||||
/** @var iterable $routes */
|
||||
$routes = Route::getRoutes();
|
||||
|
||||
if ('true' === $request->get('api')) {
|
||||
$collection = [];
|
||||
$i = 0;
|
||||
|
||||
echo 'PATHS="';
|
||||
|
||||
/** @var \Illuminate\Routing\Route $route */
|
||||
foreach ($routes as $route) {
|
||||
++$i;
|
||||
// skip API and other routes.
|
||||
if (!str_starts_with($route->uri(), 'api/v1')
|
||||
) {
|
||||
continue;
|
||||
}
|
||||
// skip non GET routes
|
||||
if (!in_array('GET', $route->methods(), true)) {
|
||||
continue;
|
||||
}
|
||||
// no name route:
|
||||
if (null === $route->getName()) {
|
||||
var_dump($route);
|
||||
|
||||
exit;
|
||||
}
|
||||
|
||||
echo substr($route->uri(), 3);
|
||||
if (0 === $i % 5) {
|
||||
echo '"<br>PATHS="${PATHS},';
|
||||
}
|
||||
if (0 !== $i % 5) {
|
||||
echo ',';
|
||||
}
|
||||
}
|
||||
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
$return = [];
|
||||
|
||||
/** @var \Illuminate\Routing\Route $route */
|
||||
foreach ($routes as $route) {
|
||||
// skip API and other routes.
|
||||
if (
|
||||
str_starts_with($route->uri(), 'api')
|
||||
|| str_starts_with($route->uri(), '_debugbar')
|
||||
|| str_starts_with($route->uri(), '_ignition')
|
||||
|| str_starts_with($route->uri(), 'oauth')
|
||||
|| str_starts_with($route->uri(), 'chart')
|
||||
|| str_starts_with($route->uri(), 'v1/jscript')
|
||||
|| str_starts_with($route->uri(), 'v2/jscript')
|
||||
|| str_starts_with($route->uri(), 'json')
|
||||
|| str_starts_with($route->uri(), 'sanctum')
|
||||
) {
|
||||
continue;
|
||||
}
|
||||
// skip non GET routes
|
||||
if (!in_array('GET', $route->methods(), true)) {
|
||||
continue;
|
||||
}
|
||||
// no name route:
|
||||
if (null === $route->getName()) {
|
||||
var_dump($route);
|
||||
|
||||
exit;
|
||||
}
|
||||
if (!str_contains($route->uri(), '{')) {
|
||||
|
||||
$return[$route->getName()] = route($route->getName());
|
||||
|
||||
continue;
|
||||
}
|
||||
$params = [];
|
||||
foreach ($route->parameterNames() as $name) {
|
||||
$params[] = $this->getParameter($name);
|
||||
}
|
||||
$return[$route->getName()] = route($route->getName(), $params);
|
||||
}
|
||||
$count = 0;
|
||||
echo '<hr>';
|
||||
echo '<h1>Routes</h1>';
|
||||
echo sprintf('<h2>%s</h2>', $count);
|
||||
foreach ($return as $name => $path) {
|
||||
echo sprintf('<a href="%1$s">%2$s</a><br>', $path, $name).PHP_EOL;
|
||||
++$count;
|
||||
if (0 === $count % 10) {
|
||||
echo '<hr>';
|
||||
echo sprintf('<h2>%s</h2>', $count);
|
||||
}
|
||||
}
|
||||
|
||||
exit;
|
||||
}
|
||||
|
||||
private function getParameter(string $name): string
|
||||
@@ -582,4 +570,19 @@ class DebugController extends Controller
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Flash all types of messages.
|
||||
*
|
||||
* @return Redirector|RedirectResponse
|
||||
*/
|
||||
public function testFlash(Request $request)
|
||||
{
|
||||
$request->session()->flash('success', 'This is a success message.');
|
||||
$request->session()->flash('info', 'This is an info message.');
|
||||
$request->session()->flash('warning', 'This is a warning.');
|
||||
$request->session()->flash('error', 'This is an error!');
|
||||
|
||||
return redirect(route('home'));
|
||||
}
|
||||
}
|
||||
|
@@ -24,6 +24,8 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Http\Controllers\Export;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
use FireflyIII\Exceptions\FireflyException;
|
||||
use FireflyIII\Http\Controllers\Controller;
|
||||
use FireflyIII\Http\Middleware\IsDemoUser;
|
||||
@@ -84,14 +86,14 @@ class IndexController extends Controller
|
||||
$firstDate = today(config('app.timezone'));
|
||||
$firstDate->subYear();
|
||||
$journal = $this->journalRepository->firstNull();
|
||||
if (null !== $journal) {
|
||||
if ($journal instanceof TransactionJournal) {
|
||||
Log::debug('First journal is NULL, using today() - 1 year.');
|
||||
$firstDate = clone $journal->date;
|
||||
}
|
||||
$generator->setStart($firstDate);
|
||||
$result = $generator->export();
|
||||
|
||||
$name = sprintf('%s_transaction_export.csv', \Safe\date('Y_m_d'));
|
||||
$name = sprintf('%s_transaction_export.csv', Carbon::now()->format('Y_m_d'));
|
||||
$quoted = sprintf('"%s"', addcslashes($name, '"\\'));
|
||||
|
||||
// headers for CSV file.
|
||||
|
@@ -96,7 +96,7 @@ class JavascriptController extends Controller
|
||||
{
|
||||
$account = $repository->find((int) $request->get('account'));
|
||||
$currency = $this->defaultCurrency;
|
||||
if (null !== $account) {
|
||||
if ($account instanceof Account) {
|
||||
$currency = $repository->getAccountCurrency($account) ?? $this->defaultCurrency;
|
||||
}
|
||||
$locale = app('steam')->getLocale();
|
||||
|
@@ -24,6 +24,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Http\Controllers\Json;
|
||||
|
||||
use FireflyIII\Models\AvailableBudget;
|
||||
use Carbon\Carbon;
|
||||
use FireflyIII\Http\Controllers\Controller;
|
||||
use FireflyIII\Models\TransactionCurrency;
|
||||
@@ -72,7 +73,7 @@ class BudgetController extends Controller
|
||||
$available = '0';
|
||||
$percentage = '0';
|
||||
|
||||
if (null !== $availableBudget) {
|
||||
if ($availableBudget instanceof AvailableBudget) {
|
||||
$available = $availableBudget->amount;
|
||||
if (0 !== bccomp($available, '0')) {
|
||||
$percentage = bcmul(bcdiv($budgeted, $available), '100');
|
||||
|
@@ -77,7 +77,7 @@ class ReconcileController extends Controller
|
||||
$amount = '0';
|
||||
$clearedAmount = '0';
|
||||
|
||||
if (null === $start && null === $end) {
|
||||
if (!$start instanceof Carbon && !$end instanceof Carbon) {
|
||||
throw new FireflyException('Invalid dates submitted.');
|
||||
}
|
||||
if ($end->lt($start)) {
|
||||
@@ -183,7 +183,7 @@ class ReconcileController extends Controller
|
||||
*/
|
||||
public function transactions(Account $account, ?Carbon $start = null, ?Carbon $end = null)
|
||||
{
|
||||
if (null === $start || null === $end) {
|
||||
if (!$start instanceof Carbon || !$end instanceof Carbon) {
|
||||
throw new FireflyException('Invalid dates submitted.');
|
||||
}
|
||||
if ($end->lt($start)) {
|
||||
|
@@ -82,12 +82,12 @@ class RecurrenceController extends Controller
|
||||
$skip = $skip < 0 || $skip > 31 ? 0 : $skip;
|
||||
$weekend = $weekend < 1 || $weekend > 4 ? 1 : $weekend;
|
||||
|
||||
if (null === $endDate) {
|
||||
if (!$endDate instanceof Carbon) {
|
||||
// safety catch:
|
||||
$endDate = now()->addYear();
|
||||
}
|
||||
|
||||
if (null === $start || null === $end || null === $firstDate) {
|
||||
if (!$start instanceof Carbon || !$end instanceof Carbon || !$firstDate instanceof Carbon) {
|
||||
return response()->json();
|
||||
}
|
||||
|
||||
@@ -153,7 +153,7 @@ class RecurrenceController extends Controller
|
||||
*/
|
||||
public function suggest(Request $request): JsonResponse
|
||||
{
|
||||
$string = '' === (string) $request->get('date') ? \Safe\date('Y-m-d') : (string) $request->get('date');
|
||||
$string = '' === (string) $request->get('date') ? Carbon::now()->format('Y-m-d') : (string) $request->get('date');
|
||||
$today = today(config('app.timezone'))->startOfDay();
|
||||
|
||||
try {
|
||||
@@ -161,7 +161,7 @@ class RecurrenceController extends Controller
|
||||
} catch (InvalidFormatException) {
|
||||
$date = Carbon::today(config('app.timezone'));
|
||||
}
|
||||
if (null === $date) {
|
||||
if (!$date instanceof Carbon) {
|
||||
return response()->json();
|
||||
}
|
||||
$date->startOfDay();
|
||||
|
@@ -23,6 +23,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Http\Controllers;
|
||||
|
||||
use FireflyIII\Models\TransactionCurrency;
|
||||
use FireflyIII\Enums\AccountTypeEnum;
|
||||
use FireflyIII\Exceptions\FireflyException;
|
||||
use FireflyIII\Http\Requests\NewUserFormRequest;
|
||||
@@ -101,7 +102,7 @@ class NewUserController extends Controller
|
||||
$currency = $currencyRepository->find((int) $request->input('amount_currency_id_bank_balance'));
|
||||
|
||||
// if is null, set to EUR:
|
||||
if (null === $currency) {
|
||||
if (!$currency instanceof TransactionCurrency) {
|
||||
$currency = $currencyRepository->findByCode('EUR');
|
||||
}
|
||||
$currencyRepository->enable($currency);
|
||||
|
@@ -23,6 +23,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Http\Controllers;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use FireflyIII\Enums\AccountTypeEnum;
|
||||
use FireflyIII\Events\Preferences\UserGroupChangedDefaultCurrency;
|
||||
use FireflyIII\Events\Test\UserTestNotificationChannel;
|
||||
@@ -40,6 +41,10 @@ use Illuminate\Routing\Redirector;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\View\View;
|
||||
|
||||
use function Safe\json_decode;
|
||||
use function Safe\file_get_contents;
|
||||
use function Safe\strtotime;
|
||||
|
||||
/**
|
||||
* Class PreferencesController.
|
||||
*/
|
||||
@@ -110,7 +115,7 @@ class PreferencesController extends Controller
|
||||
if (is_array($fiscalYearStartStr)) {
|
||||
$fiscalYearStartStr = '01-01';
|
||||
}
|
||||
$fiscalYearStart = sprintf('%s-%s', \Safe\date('Y'), (string) $fiscalYearStartStr);
|
||||
$fiscalYearStart = sprintf('%s-%s', Carbon::now()->format('Y'), (string) $fiscalYearStartStr);
|
||||
$tjOptionalFields = Preferences::get('transaction_journal_optional_fields', [])->data;
|
||||
$availableDarkModes = config('firefly.available_dark_modes');
|
||||
|
||||
@@ -149,7 +154,7 @@ class PreferencesController extends Controller
|
||||
// list of locales also has "equal" which makes it equal to whatever the language is.
|
||||
|
||||
try {
|
||||
$locales = \Safe\json_decode((string) \Safe\file_get_contents(resource_path(sprintf('locales/%s/locales.json', $language))), true, 512, JSON_THROW_ON_ERROR);
|
||||
$locales = json_decode((string) file_get_contents(resource_path(sprintf('locales/%s/locales.json', $language))), true, 512, JSON_THROW_ON_ERROR);
|
||||
} catch (\JsonException $e) {
|
||||
app('log')->error($e->getMessage());
|
||||
$locales = [];
|
||||
@@ -271,9 +276,9 @@ class PreferencesController extends Controller
|
||||
|
||||
// custom fiscal year
|
||||
$customFiscalYear = 1 === (int) $request->get('customFiscalYear');
|
||||
$string = \Safe\strtotime((string) $request->get('fiscalYearStart'));
|
||||
$string = strtotime((string) $request->get('fiscalYearStart'));
|
||||
if (false !== $string) {
|
||||
$fiscalYearStart = \Safe\date('m-d', $string);
|
||||
$fiscalYearStart = Carbon::createFromTimestamp($string)->format('m-d');
|
||||
Preferences::set('customFiscalYear', $customFiscalYear);
|
||||
Preferences::set('fiscalYearStart', $fiscalYearStart);
|
||||
}
|
||||
|
@@ -24,6 +24,9 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Http\Controllers\Profile;
|
||||
|
||||
use Illuminate\Support\Facades\Cookie;
|
||||
use PragmaRX\Google2FALaravel\Facade as Google2FA;
|
||||
use Carbon\Carbon;
|
||||
use FireflyIII\Events\Security\DisabledMFA;
|
||||
use FireflyIII\Events\Security\EnabledMFA;
|
||||
use FireflyIII\Events\Security\MFANewBackupCodes;
|
||||
@@ -181,7 +184,7 @@ class MfaController extends Controller
|
||||
|
||||
// also logout current 2FA tokens.
|
||||
$cookieName = config('google2fa.cookie_name', 'google2fa_token');
|
||||
\Cookie::forget($cookieName);
|
||||
Cookie::forget($cookieName);
|
||||
|
||||
// send user notification.
|
||||
Log::channel('audit')->info(sprintf('User "%s" has disabled MFA', $user->email));
|
||||
@@ -214,8 +217,8 @@ class MfaController extends Controller
|
||||
}
|
||||
|
||||
$domain = $this->getDomain();
|
||||
$secret = \Google2FA::generateSecretKey();
|
||||
$image = \Google2FA::getQRCodeInline($domain, auth()->user()->email, $secret);
|
||||
$secret = Google2FA::generateSecretKey();
|
||||
$image = Google2FA::getQRCodeInline($domain, auth()->user()->email, $secret);
|
||||
|
||||
app('preferences')->set('temp-mfa-secret', $secret);
|
||||
|
||||
@@ -271,7 +274,7 @@ class MfaController extends Controller
|
||||
|
||||
// make sure MFA is logged out.
|
||||
if ('testing' !== config('app.env')) {
|
||||
\Google2FA::logout();
|
||||
Google2FA::logout();
|
||||
}
|
||||
|
||||
// drop all info from session:
|
||||
@@ -294,7 +297,7 @@ class MfaController extends Controller
|
||||
/** @var array $mfaHistory */
|
||||
$mfaHistory = app('preferences')->get('mfa_history', [])->data;
|
||||
$entry = [
|
||||
'time' => time(),
|
||||
'time' => Carbon::now()->getTimestamp(),
|
||||
'code' => $mfaCode,
|
||||
];
|
||||
$mfaHistory[] = $entry;
|
||||
@@ -311,7 +314,7 @@ class MfaController extends Controller
|
||||
/** @var array $mfaHistory */
|
||||
$mfaHistory = app('preferences')->get('mfa_history', [])->data;
|
||||
$newHistory = [];
|
||||
$now = time();
|
||||
$now = Carbon::now()->getTimestamp();
|
||||
foreach ($mfaHistory as $entry) {
|
||||
$time = $entry['time'];
|
||||
$code = $entry['code'];
|
||||
|
@@ -23,6 +23,8 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Http\Controllers;
|
||||
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use FireflyIII\Events\UserChangedEmail;
|
||||
use FireflyIII\Exceptions\FireflyException;
|
||||
use FireflyIII\Exceptions\ValidationException;
|
||||
@@ -154,7 +156,8 @@ class ProfileController extends Controller
|
||||
if (0 === $count) {
|
||||
/** @var ClientRepository $repository */
|
||||
$repository = app(ClientRepository::class);
|
||||
$repository->createPersonalAccessClient(null, config('app.name').' Personal Access Client', 'http://localhost');
|
||||
$name = sprintf('%s Personal Access Grant Client', config('app.name'));
|
||||
$repository->createPersonalAccessClient(null, $name, 'http://localhost');
|
||||
}
|
||||
|
||||
$accessToken = app('preferences')->get('access_token');
|
||||
@@ -201,9 +204,9 @@ class ProfileController extends Controller
|
||||
return redirect(route('profile.change-email'))->withInput();
|
||||
}
|
||||
$existing = $repository->findByEmail($newEmail);
|
||||
if (null !== $existing) {
|
||||
if ($existing instanceof User) {
|
||||
// force user logout.
|
||||
\Auth::guard()->logout(); // @phpstan-ignore-line (does not recognize function)
|
||||
Auth::guard()->logout(); // @phpstan-ignore-line (does not recognize function)
|
||||
$request->session()->invalidate();
|
||||
|
||||
session()->flash('success', (string) trans('firefly.email_changed'));
|
||||
@@ -217,7 +220,7 @@ class ProfileController extends Controller
|
||||
event(new UserChangedEmail($user, $newEmail, $oldEmail));
|
||||
|
||||
// force user logout.
|
||||
\Auth::guard()->logout(); // @phpstan-ignore-line (does not recognize function)
|
||||
Auth::guard()->logout(); // @phpstan-ignore-line (does not recognize function)
|
||||
$request->session()->invalidate();
|
||||
session()->flash('success', (string) trans('firefly.email_changed'));
|
||||
|
||||
@@ -310,7 +313,7 @@ class ProfileController extends Controller
|
||||
return redirect(route('profile.index'));
|
||||
}
|
||||
|
||||
if (!\Hash::check($request->get('password'), auth()->user()->password)) {
|
||||
if (!Hash::check($request->get('password'), auth()->user()->password)) {
|
||||
session()->flash('error', (string) trans('firefly.invalid_password'));
|
||||
|
||||
return redirect(route('profile.delete-account'));
|
||||
@@ -343,8 +346,8 @@ class ProfileController extends Controller
|
||||
'email' => auth()->user()->email,
|
||||
'password' => $request->get('password'),
|
||||
];
|
||||
if (\Auth::once($creds)) {
|
||||
\Auth::logoutOtherDevices($request->get('password'));
|
||||
if (Auth::once($creds)) {
|
||||
Auth::logoutOtherDevices($request->get('password'));
|
||||
session()->flash('info', (string) trans('firefly.other_sessions_logged_out'));
|
||||
|
||||
return redirect(route('profile.index'));
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user