Compare commits

..

45 Commits

Author SHA1 Message Date
github-actions[bot]
8235c24c13 Merge pull request #11421 from firefly-iii/release-1767107945
🤖 Automatically merge the PR into the develop branch.
2025-12-30 16:19:14 +01:00
JC5
7ca96a766f 🤖 Auto commit for release 'develop' on 2025-12-30 2025-12-30 16:19:05 +01:00
James Cole
27586a7ec2 Allow transactions to be moved to the future and still have the running balance calculated correctly. 2025-12-30 16:13:28 +01:00
James Cole
dc3c3bb092 Add setting for anonymous amounts in preferences. 2025-12-30 07:24:14 +01:00
github-actions[bot]
7287c29778 Merge pull request #11419 from firefly-iii/release-1767020049
🤖 Automatically merge the PR into the develop branch.
2025-12-29 15:54:17 +01:00
JC5
7d374b22f9 🤖 Auto commit for release 'develop' on 2025-12-29 2025-12-29 15:54:09 +01:00
James Cole
e0542f1270 Fix end of quarter issue. 2025-12-29 11:10:28 +01:00
James Cole
73a9be0605 Fix #11410 2025-12-29 11:05:48 +01:00
github-actions[bot]
1f343bda1a Merge pull request #11416 from firefly-iii/release-1766995950
🤖 Automatically merge the PR into the develop branch.
2025-12-29 09:12:40 +01:00
JC5
1c8eaf93a6 🤖 Auto commit for release 'develop' on 2025-12-29 2025-12-29 09:12:30 +01:00
James Cole
ccfee25000 Merge pull request #11414 from oboxodo/develop
Add Uruguayan Peso to currency seeder
2025-12-29 09:11:25 +01:00
Diego Algorta
07c6dac766 Add Uruguayan Peso to currency seeder 2025-12-28 12:06:08 -03:00
github-actions[bot]
b0b2e5b752 Merge pull request #11411 from firefly-iii/release-1766901579
🤖 Automatically merge the PR into the develop branch.
2025-12-28 06:59:46 +01:00
JC5
ff3a935e9d 🤖 Auto commit for release 'develop' on 2025-12-28 2025-12-28 06:59:39 +01:00
James Cole
f0e2f09da7 Fix some end of period stuff. 2025-12-28 06:54:03 +01:00
github-actions[bot]
f3fbebb9a4 Merge pull request #11409 from firefly-iii/release-1766836192
🤖 Automatically merge the PR into the develop branch.
2025-12-27 12:49:59 +01:00
JC5
6e6e42dab6 🤖 Auto commit for release 'develop' on 2025-12-27 2025-12-27 12:49:53 +01:00
James Cole
d9efd63fad Add debug details. 2025-12-27 12:45:46 +01:00
github-actions[bot]
bc273ada39 Merge pull request #11406 from firefly-iii/release-1766776026
🤖 Automatically merge the PR into the develop branch.
2025-12-26 20:07:14 +01:00
JC5
75c76bb6dd 🤖 Auto commit for release 'develop' on 2025-12-26 2025-12-26 20:07:06 +01:00
James Cole
4d2dd1d8f7 Fix view of running balance column 2025-12-26 20:02:09 +01:00
James Cole
456e73ac16 Fix #11403 2025-12-26 07:09:04 +01:00
James Cole
86f1d8a1bc Fix ALE amount logging. 2025-12-24 07:45:03 +01:00
James Cole
7dac164556 Remove maxlength 2025-12-22 15:39:41 +01:00
James Cole
532df54f10 Merge pull request #11394 from firefly-iii/dependabot/composer/develop/mailersend/laravel-driver-2.12.0 2025-12-22 05:20:33 +01:00
mergify[bot]
daa76d01ca Merge branch 'develop' into dependabot/composer/develop/mailersend/laravel-driver-2.12.0 2025-12-22 03:37:04 +00:00
github-actions[bot]
aa3a435022 Merge pull request #11395 from firefly-iii/release-1766374574
🤖 Automatically merge the PR into the develop branch.
2025-12-22 04:36:21 +01:00
JC5
bc4018481f 🤖 Auto commit for release 'develop' on 2025-12-22 2025-12-22 04:36:14 +01:00
dependabot[bot]
6b7aed7658 Bump mailersend/laravel-driver from 2.9.1 to 2.12.0
Bumps [mailersend/laravel-driver](https://github.com/mailersend/mailersend-laravel-driver) from 2.9.1 to 2.12.0.
- [Release notes](https://github.com/mailersend/mailersend-laravel-driver/releases)
- [Commits](https://github.com/mailersend/mailersend-laravel-driver/compare/v2.9.1...v2.12.0)

---
updated-dependencies:
- dependency-name: mailersend/laravel-driver
  dependency-version: 2.12.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-12-22 03:01:04 +00:00
James Cole
92a535c644 Only update amount when it's actually changed. 2025-12-20 20:12:07 +01:00
James Cole
340540bd5a Replace calls to Amount facade. 2025-12-20 08:21:05 +01:00
James Cole
c63f4a941b Expand debug info for currency search. 2025-12-20 08:08:57 +01:00
James Cole
7491cb5f58 Merge branches 'develop' and 'develop' of github.com:firefly-iii/firefly-iii into develop 2025-12-20 08:08:30 +01:00
James Cole
31c1e28c76 Add message. 2025-12-20 08:08:20 +01:00
github-actions[bot]
0ece35feca Merge pull request #11393 from firefly-iii/release-1766210807
🤖 Automatically merge the PR into the develop branch.
2025-12-20 07:06:54 +01:00
JC5
3b8caba37c 🤖 Auto commit for release 'develop' on 2025-12-20 2025-12-20 07:06:47 +01:00
James Cole
8e729d6bbf Replace references to hard coded config with variables. 2025-12-20 07:00:53 +01:00
James Cole
0f0cdb8e96 Replace config calls. 2025-12-20 06:42:11 +01:00
James Cole
b0cc5f3a46 Remove entries from .env file. 2025-12-20 06:39:58 +01:00
James Cole
71c5bdb198 Move settings to the settings page, out of the .env file. 2025-12-20 06:39:05 +01:00
James Cole
be9078fe99 Remove unused settings. 2025-12-20 06:10:51 +01:00
github-actions[bot]
d235e32c34 Merge pull request #11391 from firefly-iii/release-1766164682
🤖 Automatically merge the PR into the develop branch.
2025-12-19 18:18:09 +01:00
JC5
e34b89da08 🤖 Auto commit for release 'develop' on 2025-12-19 2025-12-19 18:18:02 +01:00
James Cole
f5428595d5 Merge branch 'develop' of github.com:firefly-iii/firefly-iii into develop
# Conflicts:
#	app/Console/Commands/Correction/CorrectsAmounts.php
2025-12-19 18:13:58 +01:00
James Cole
87cb1e1a2b Fix #11378 2025-12-19 18:13:04 +01:00
139 changed files with 1062 additions and 672 deletions

View File

@@ -731,16 +731,16 @@
},
{
"name": "react/child-process",
"version": "v0.6.6",
"version": "v0.6.7",
"source": {
"type": "git",
"url": "https://github.com/reactphp/child-process.git",
"reference": "1721e2b93d89b745664353b9cfc8f155ba8a6159"
"reference": "970f0e71945556422ee4570ccbabaedc3cf04ad3"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/reactphp/child-process/zipball/1721e2b93d89b745664353b9cfc8f155ba8a6159",
"reference": "1721e2b93d89b745664353b9cfc8f155ba8a6159",
"url": "https://api.github.com/repos/reactphp/child-process/zipball/970f0e71945556422ee4570ccbabaedc3cf04ad3",
"reference": "970f0e71945556422ee4570ccbabaedc3cf04ad3",
"shasum": ""
},
"require": {
@@ -794,7 +794,7 @@
],
"support": {
"issues": "https://github.com/reactphp/child-process/issues",
"source": "https://github.com/reactphp/child-process/tree/v0.6.6"
"source": "https://github.com/reactphp/child-process/tree/v0.6.7"
},
"funding": [
{
@@ -802,7 +802,7 @@
"type": "open_collective"
}
],
"time": "2025-01-01T16:37:48+00:00"
"time": "2025-12-23T15:25:20+00:00"
},
{
"name": "react/dns",

View File

@@ -188,39 +188,11 @@ MAILERSEND_API_KEY=
# Firefly III can send you the following messages.
SEND_ERROR_MESSAGE=true
# These messages contain (sensitive) transaction information:
SEND_REPORT_JOURNALS=true
# Set this value to true if you want to set the location of certain things, like transactions.
# Since this involves an external service, it's optional and disabled by default.
ENABLE_EXTERNAL_MAP=false
#
# Enable or disable exchange rate conversion.
#
ENABLE_EXCHANGE_RATES=false
# Set this value to true if you want Firefly III to download currency exchange rates
# from the internet. These rates are hosted by the creator of Firefly III inside
# an Azure Storage Container.
# Not all currencies may be available. Rates may be wrong.
ENABLE_EXTERNAL_RATES=false
# The map will default to this location:
MAP_DEFAULT_LAT=51.983333
MAP_DEFAULT_LONG=5.916667
MAP_DEFAULT_ZOOM=6
#
# Some objects have room for an URL, like transactions and webhooks.
# By default, the following protocols are allowed:
# http, https, ftp, ftps, mailto
#
# To change this, set your preferred comma separated set below.
# Be sure to include http, https and other default ones if you need to.
#
VALID_URL_PROTOCOLS=
#
# Firefly III authentication settings
#
@@ -275,11 +247,6 @@ DISABLE_CSP_HEADER=false
TRACKER_SITE_ID=
TRACKER_URL=
#
# Firefly III supports webhooks. These are security sensitive and must be enabled manually first.
#
ALLOW_WEBHOOKS=false
#
# The static cron job token can be useful when you use Docker and wish to manage cron jobs.
# 1. Set this token to any 32-character value (this is important!).
@@ -313,25 +280,12 @@ PUSHER_ID=
DEMO_USERNAME=
DEMO_PASSWORD=
#
# Disable or enable the running balance column data.
# If you enable this, please also run "php artisan firefly-iii:correct-database"
# This will take some time the first run.
#
USE_RUNNING_BALANCE=false
#
# The v2 layout is very experimental. If it breaks you get to keep both parts.
# Be wary of data loss.
#
FIREFLY_III_LAYOUT=v1
#
# Which Query Parser implementation to use for the search engine and rules
# 'new' is experimental, 'legacy' is the classic one
#
QUERY_PARSER_IMPLEMENTATION=new
#
# Please make sure this URL matches the external URL of your Firefly III installation.
# It is used to validate specific requests and to generate URLs in emails.

View File

@@ -4,6 +4,7 @@ Over time, many people have contributed to Firefly III. Their efforts are not al
Please find below all the people who contributed to the Firefly III code. Their names are mentioned in the year of their first contribution.
## 2025
- Diego Algorta
- Jihad
- jreyesr
- codearena-bot

View File

@@ -29,6 +29,7 @@ use FireflyIII\Api\V1\Requests\System\CronRequest;
use FireflyIII\Support\Http\Controllers\CronRunner;
use Illuminate\Http\JsonResponse;
use Illuminate\Support\Facades\Log;
use FireflyIII\Support\Facades\FireflyConfig;
/**
* Class CronController
@@ -50,7 +51,7 @@ class CronController extends Controller
$return = [];
$return['recurring_transactions'] = $this->runRecurring($config['force'], $config['date']);
$return['auto_budgets'] = $this->runAutoBudget($config['force'], $config['date']);
if (true === config('cer.download_enabled')) {
if (true === FireflyConfig::get('enable_external_rates', config('cer.download_enabled'))->data) {
$return['exchange_rates'] = $this->exchangeRatesCronJob($config['force'], $config['date']);
}
$return['bill_notifications'] = $this->billWarningCronJob($config['force'], $config['date']);

View File

@@ -38,6 +38,7 @@ use League\Fractal\Pagination\IlluminatePaginatorAdapter;
use League\Fractal\Resource\Collection as FractalCollection;
use League\Fractal\Resource\Item;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use FireflyIII\Support\Facades\FireflyConfig;
/**
* Class AttemptController
@@ -71,7 +72,7 @@ class AttemptController extends Controller
if ($message->webhook_id !== $webhook->id) {
throw new FireflyException('200040: Webhook and webhook message are no match');
}
if (false === config('firefly.allow_webhooks')) {
if (false === FireflyConfig::get('allow_webhooks', config('firefly.allow_webhooks'))->data) {
Log::channel('audit')->warning(sprintf('User lists webhook attempts of webhook #%d and message #%d, but webhooks are DISABLED.', $webhook->id, $message->id));
throw new NotFoundHttpException('Webhooks are not enabled.');
@@ -115,7 +116,7 @@ class AttemptController extends Controller
throw new FireflyException('200041: Webhook message and webhook attempt are no match');
}
if (false === config('firefly.allow_webhooks')) {
if (false === FireflyConfig::get('allow_webhooks', config('firefly.allow_webhooks'))->data) {
Log::channel('audit')->warning(sprintf('User views single webhook attempt #%d of webhook #%d and message #%d, but webhooks are DISABLED', $attempt->id, $webhook->id, $message->id));
throw new NotFoundHttpException('Webhooks are not enabled.');

View File

@@ -34,6 +34,7 @@ use FireflyIII\Support\Facades\Preferences;
use Illuminate\Http\JsonResponse;
use Illuminate\Support\Facades\Log;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use FireflyIII\Support\Facades\FireflyConfig;
/**
* Class DestroyController
@@ -63,7 +64,7 @@ class DestroyController extends Controller
*/
public function destroy(Webhook $webhook): JsonResponse
{
if (false === config('firefly.allow_webhooks')) {
if (false === FireflyConfig::get('allow_webhooks', config('firefly.allow_webhooks'))->data) {
Log::channel('audit')->warning(sprintf('User tries to destroy webhook #%d. but webhooks are DISABLED.', $webhook->id));
throw new NotFoundHttpException('Webhooks are not enabled.');
@@ -93,7 +94,7 @@ class DestroyController extends Controller
throw new FireflyException('200041: Webhook message and webhook attempt are no match');
}
if (false === config('firefly.allow_webhooks')) {
if (false === FireflyConfig::get('allow_webhooks', config('firefly.allow_webhooks'))->data) {
Log::channel('audit')->warning(sprintf('User tries to destroy webhook #%d, message #%d, attempt #%d, but webhooks are DISABLED.', $webhook->id, $message->id, $attempt->id));
throw new NotFoundHttpException('Webhooks are not enabled.');
@@ -121,7 +122,7 @@ class DestroyController extends Controller
throw new FireflyException('200040: Webhook and webhook message are no match');
}
if (false === config('firefly.allow_webhooks')) {
if (false === FireflyConfig::get('allow_webhooks', config('firefly.allow_webhooks'))->data) {
Log::channel('audit')->warning(sprintf('User tries to destroy webhook #%d, message #%d, but webhooks are DISABLED.', $webhook->id, $message->id));
throw new NotFoundHttpException('Webhooks are not enabled.');

View File

@@ -37,6 +37,7 @@ use League\Fractal\Pagination\IlluminatePaginatorAdapter;
use League\Fractal\Resource\Collection as FractalCollection;
use League\Fractal\Resource\Item;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use FireflyIII\Support\Facades\FireflyConfig;
/**
* Class MessageController
@@ -65,7 +66,7 @@ class MessageController extends Controller
*/
public function index(Webhook $webhook): JsonResponse
{
if (false === config('firefly.allow_webhooks')) {
if (false === FireflyConfig::get('allow_webhooks', config('firefly.allow_webhooks'))->data) {
Log::channel('audit')->warning(sprintf('User tries to view messages of webhook #%d, but webhooks are DISABLED.', $webhook->id));
throw new NotFoundHttpException('Webhooks are not enabled.');
@@ -105,7 +106,7 @@ class MessageController extends Controller
if ($message->webhook_id !== $webhook->id) {
throw new FireflyException('200040: Webhook and webhook message are no match');
}
if (false === config('firefly.allow_webhooks')) {
if (false === FireflyConfig::get('allow_webhooks', config('firefly.allow_webhooks'))->data) {
Log::channel('audit')->warning(sprintf('User tries to view message #%d of webhook #%d, but webhooks are DISABLED.', $message->id, $webhook->id));
throw new NotFoundHttpException('Webhooks are not enabled.');

View File

@@ -42,6 +42,7 @@ use League\Fractal\Pagination\IlluminatePaginatorAdapter;
use League\Fractal\Resource\Collection as FractalCollection;
use League\Fractal\Resource\Item;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use FireflyIII\Support\Facades\FireflyConfig;
/**
* Class ShowController
@@ -72,7 +73,7 @@ class ShowController extends Controller
*/
public function index(): JsonResponse
{
if (false === config('firefly.allow_webhooks')) {
if (false === FireflyConfig::get('allow_webhooks', config('firefly.allow_webhooks'))->data) {
Log::channel('audit')->info('User tries to view all webhooks, but webhooks are DISABLED.');
throw new NotFoundHttpException('Webhooks are not enabled.');
@@ -114,7 +115,7 @@ class ShowController extends Controller
*/
public function show(Webhook $webhook): JsonResponse
{
if (false === config('firefly.allow_webhooks')) {
if (false === FireflyConfig::get('allow_webhooks', config('firefly.allow_webhooks'))->data) {
Log::channel('audit')->info(sprintf('User tries to view webhook #%d, but webhooks are DISABLED.', $webhook->id));
throw new NotFoundHttpException('Webhooks are not enabled.');
@@ -146,7 +147,7 @@ class ShowController extends Controller
*/
public function triggerTransaction(Webhook $webhook, TransactionGroup $group): JsonResponse
{
if (false === config('firefly.allow_webhooks')) {
if (false === FireflyConfig::get('allow_webhooks', config('firefly.allow_webhooks'))->data) {
Log::channel('audit')->info(sprintf('User tries to trigger webhook #%d on transaction group #%d, but webhooks are DISABLED.', $webhook->id, $group->id));
throw new NotFoundHttpException('Webhooks are not enabled.');

View File

@@ -34,6 +34,7 @@ use Illuminate\Http\JsonResponse;
use Illuminate\Support\Facades\Log;
use League\Fractal\Resource\Item;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use FireflyIII\Support\Facades\FireflyConfig;
/**
* Class StoreController
@@ -63,7 +64,7 @@ class StoreController extends Controller
public function store(CreateRequest $request): JsonResponse
{
$data = $request->getData();
if (false === config('firefly.allow_webhooks')) {
if (false === FireflyConfig::get('allow_webhooks', config('firefly.allow_webhooks'))->data) {
Log::channel('audit')->info('User tries to store new webhook, but webhooks are DISABLED.', $data);
throw new NotFoundHttpException('Webhooks are not enabled.');

View File

@@ -28,6 +28,7 @@ use FireflyIII\Api\V1\Controllers\Controller;
use FireflyIII\Jobs\SendWebhookMessage;
use FireflyIII\Models\Webhook;
use FireflyIII\Repositories\Webhook\WebhookRepositoryInterface;
use FireflyIII\Support\Facades\FireflyConfig;
use Illuminate\Http\JsonResponse;
use Illuminate\Support\Facades\Log;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
@@ -58,7 +59,7 @@ class SubmitController extends Controller
*/
public function submit(Webhook $webhook): JsonResponse
{
if (false === config('firefly.allow_webhooks')) {
if (false === FireflyConfig::get('allow_webhooks', config('firefly.allow_webhooks'))->data) {
Log::channel('audit')->info(sprintf('User tries to submit webhook #%d, but webhooks are DISABLED.', $webhook->id));
throw new NotFoundHttpException('Webhooks are not enabled.');

View File

@@ -35,6 +35,7 @@ use Illuminate\Http\JsonResponse;
use Illuminate\Support\Facades\Log;
use League\Fractal\Resource\Item;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use FireflyIII\Support\Facades\FireflyConfig;
/**
* Class UpdateController
@@ -63,7 +64,7 @@ class UpdateController extends Controller
public function update(Webhook $webhook, UpdateRequest $request): JsonResponse
{
$data = $request->getData();
if (false === config('firefly.allow_webhooks')) {
if (false === FireflyConfig::get('allow_webhooks', config('firefly.allow_webhooks'))->data) {
Log::channel('audit')->info(sprintf('User tries to update webhook #%d, but webhooks are DISABLED.', $webhook->id), $data);
throw new NotFoundHttpException('Webhooks are not enabled.');

View File

@@ -40,6 +40,7 @@ use FireflyIII\Validation\GroupValidation;
use FireflyIII\Validation\TransactionValidation;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Support\Facades\Log;
use FireflyIII\Support\Facades\FireflyConfig;
/**
* Class StoreRequest
@@ -176,7 +177,7 @@ class StoreRequest extends FormRequest
public function rules(): array
{
Log::debug('Collect rules of TransactionStoreRequest');
$validProtocols = config('firefly.valid_url_protocols');
$validProtocols = FireflyConfig::get('valid_url_protocols', config('firefly.valid_url_protocols'))->data;
$locationRules = Location::requestRules([]);
return [

View File

@@ -38,6 +38,7 @@ use FireflyIII\Validation\GroupValidation;
use FireflyIII\Validation\TransactionValidation;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Support\Facades\Log;
use FireflyIII\Support\Facades\FireflyConfig;
/**
* Class UpdateRequest
@@ -248,7 +249,7 @@ class UpdateRequest extends FormRequest
public function rules(): array
{
Log::debug(sprintf('Now in %s', __METHOD__));
$validProtocols = config('firefly.valid_url_protocols');
$validProtocols = FireflyConfig::get('valid_url_protocols', config('firefly.valid_url_protocols'))->data;
return [
// basic fields for group:

View File

@@ -31,6 +31,7 @@ use FireflyIII\Support\Request\ChecksLogin;
use FireflyIII\Support\Request\ConvertsDataTypes;
use FireflyIII\Support\Request\ValidatesWebhooks;
use Illuminate\Foundation\Http\FormRequest;
use FireflyIII\Support\Facades\FireflyConfig;
/**
* Class CreateRequest
@@ -73,7 +74,7 @@ class CreateRequest extends FormRequest
$triggers = implode(',', array_values(Webhook::getTriggers()));
$responses = implode(',', array_values(Webhook::getResponses()));
$deliveries = implode(',', array_values(Webhook::getDeliveries()));
$validProtocols = config('firefly.valid_url_protocols');
$validProtocols = FireflyConfig::get('valid_url_protocols', config('firefly.valid_url_protocols'))->data;
return [
'title' => 'required|min:1|max:255|uniqueObjectForUser:webhooks,title',

View File

@@ -31,6 +31,7 @@ use FireflyIII\Support\Request\ChecksLogin;
use FireflyIII\Support\Request\ConvertsDataTypes;
use FireflyIII\Support\Request\ValidatesWebhooks;
use Illuminate\Foundation\Http\FormRequest;
use FireflyIII\Support\Facades\FireflyConfig;
/**
* Class UpdateRequest
@@ -73,7 +74,7 @@ class UpdateRequest extends FormRequest
$triggers = implode(',', array_values(Webhook::getTriggers()));
$responses = implode(',', array_values(Webhook::getResponses()));
$deliveries = implode(',', array_values(Webhook::getDeliveries()));
$validProtocols = config('firefly.valid_url_protocols');
$validProtocols = FireflyConfig::get('valid_url_protocols', config('firefly.valid_url_protocols'))->data;
/** @var Webhook $webhook */
$webhook = $this->route()->parameter('webhook');

View File

@@ -39,11 +39,11 @@ use FireflyIII\Models\TransactionJournal;
use FireflyIII\Models\TransactionType;
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
use FireflyIII\Support\Facades\Amount;
use FireflyIII\Support\Facades\Steam;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log;
use ValueError;
use FireflyIII\Support\Facades\Steam;
class CorrectsAmounts extends Command
{
@@ -79,38 +79,33 @@ class CorrectsAmounts extends Command
private function correctTransfers(): void
{
Log::debug('Will now correct transfers.');
/** @var AccountRepositoryInterface $repository */
$repository = app(AccountRepositoryInterface::class);
$type = TransactionType::where('type', TransactionTypeEnum::TRANSFER->value)->first();
$journals = TransactionJournal::where('transaction_type_id', $type->id)->get();
$journals = TransactionJournal::leftJoin('transactions', 'transactions.transaction_journal_id', '=', 'transaction_journals.id')->whereNotNull('transactions.foreign_amount')->where('transaction_journals.transaction_type_id', $type->id)->distinct()->get(['transaction_journals.*']);
/** @var TransactionJournal $journal */
foreach ($journals as $journal) {
$repository->setUser($journal->user);
$primary = Amount::getPrimaryCurrencyByUserGroup($journal->userGroup);
/** @var null|Transaction $source */
$source = $journal->transactions()->where('amount', '<', 0)->first();
$valid = $this->validateJournal($journal);
if (false === $valid) {
// Log::debug(sprintf('Journal #%d does not need to be fixed or is invalid (see previous messages)', $journal->id));
/** @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;
}
if (null === $source->foreign_amount || null === $destination->foreign_amount) {
continue;
}
Log::debug(sprintf('Journal #%d is ready to be corrected (if necessary).', $journal->id));
$source = $journal->transactions()->where('amount', '<', '0')->first();
$destination = $journal->transactions()->where('amount', '>', '0')->first();
$sourceAccount = $source->account;
$destAccount = $destination->account;
if (null === $sourceAccount || null === $destAccount) {
continue;
}
$sourceCurrency = $repository->getAccountCurrency($sourceAccount) ?? $primary;
$destCurrency = $repository->getAccountCurrency($destAccount) ?? $primary;
Log::debug(sprintf('Currency of source account #%d "%s" is %s', $sourceAccount->id, $sourceAccount->name, $sourceCurrency->code));
Log::debug(sprintf('Currency of destination account #%d "%s" is %s', $destAccount->id, $destAccount->name, $destCurrency->code));
if ($sourceCurrency->id === $destCurrency->id) {
Log::debug('Both accounts have the same currency. Removing foreign currency info.');
@@ -124,22 +119,40 @@ class CorrectsAmounts extends Command
continue;
}
// validate source
// validate source transaction
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));
Log::debug(sprintf('[a] Journal #%d: transaction #%d refers to foreign currency "%s" but should refer to "%s".', $journal->id, $source->id, $source->foreignCurrency->code, $destCurrency->code));
$source->foreign_currency_id = $destCurrency->id;
$source->save();
}
if ($sourceCurrency->id !== $source->transaction_currency_id) {
Log::debug(sprintf('[b] Journal #%d: transaction #%d refers to currency "%s" but should refer to "%s".', $journal->id, $source->id, $source->transactionCurrency->code, $sourceCurrency->code));
$source->transaction_currency_id = $sourceCurrency->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));
Log::debug(sprintf('[c] Journal #%d: transaction #%d refers to foreign currency "%s" but should refer to "%s".', $journal->id, $destination->id, $destination->foreignCurrency->code, $sourceCurrency->code));
$destination->foreign_currency_id = $sourceCurrency->id;
$destination->save();
}
if ($destCurrency->id !== $destination->transaction_currency_id) {
Log::debug(sprintf('[d] Journal #%d: transaction #%d refers to currency "%s" but should refer to "%s".', $journal->id, $destination->id, $destination->transactionCurrency->code, $destCurrency->code));
$destination->transaction_currency_id = $destCurrency->id;
$destination->save();
}
Log::debug(sprintf('Done with journal #%d.', $journal->id));
}
}
private function deleteJournal(TransactionJournal $journal): void
{
$journal->transactionGroup?->delete();
$journal->delete();
}
private function fixAutoBudgets(): void
{
$count = AutoBudget::where('amount', '<', 0)->update(['amount' => DB::raw('amount * -1')]);
@@ -239,7 +252,7 @@ class CorrectsAmounts extends Command
private function fixRuleTrigger(RuleTrigger $item): bool
{
try {
$check = bccomp((string) $item->trigger_value, '0');
$check = bccomp((string)$item->trigger_value, '0');
} catch (ValueError) {
$this->friendlyError(sprintf('Rule #%d contained invalid %s-trigger "%s". The trigger has been removed, and the rule is disabled.', $item->rule_id, $item->trigger_type, $item->trigger_value));
$item->rule->active = false;
@@ -257,4 +270,57 @@ class CorrectsAmounts extends Command
return false;
}
private function validateJournal(TransactionJournal $journal): bool
{
$countSource = $journal->transactions()->where('amount', '<', 0)->count();
$countDest = $journal->transactions()->where('amount', '>', 0)->count();
if (1 !== $countSource || 1 !== $countDest) {
$this->friendlyError(sprintf('Transaction journal #%d has bad transaction information. Will delete.', $journal->id));
$this->deleteJournal($journal);
Log::error(sprintf('Transaction journal #%d has bad transaction information. Will delete.', $journal->id));
return false;
}
/** @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) {
$this->friendlyError(sprintf('Could not find source OR destination for journal #%d .', $journal->id));
Log::error(sprintf('Could not find source OR destination for journal #%d .', $journal->id));
$this->deleteJournal($journal);
return false;
}
if (null === $source->foreign_currency_id || null === $destination->foreign_currency_id) {
// Log::debug('No foreign currency information is present, can safely continue with other transactions.');
return false;
}
if (null === $source->foreign_amount || null === $destination->foreign_amount) {
$this->friendlyError(sprintf('Transactions of journal #%d have no foreign amount, but have foreign currency info. Will reset this.', $journal->id));
$source->foreign_currency_id = null;
$source->save();
$destination->foreign_currency_id = null;
$source->save();
return false;
}
$sourceAccount = $source->account;
$destAccount = $destination->account;
if (null === $sourceAccount || null === $destAccount) {
$this->friendlyError(sprintf('Could not find accounts for journal #%d,', $journal->id));
$this->deleteJournal($journal);
return false;
}
return true;
}
}

View File

@@ -36,6 +36,7 @@ use Illuminate\Console\Command;
use Illuminate\Support\Collection;
use Illuminate\Support\Facades\Log;
use Symfony\Component\Console\Command\Command as CommandAlias;
use FireflyIII\Support\Facades\Amount;
class CorrectsCurrencies extends Command
{
@@ -63,7 +64,7 @@ class CorrectsCurrencies extends Command
$repos = app(CurrencyRepositoryInterface::class);
// first check if the user has any default currency (not necessarily the case, so can be forced).
$primaryCurrency = app('amount')->getPrimaryCurrencyByUserGroup($userGroup);
$primaryCurrency = Amount::getPrimaryCurrencyByUserGroup($userGroup);
Log::debug(sprintf('Now correcting currencies for user group #%d', $userGroup->id));
$found = [$primaryCurrency->id];

View File

@@ -35,6 +35,7 @@ use FireflyIII\Repositories\Account\AccountRepositoryInterface;
use Illuminate\Console\Command;
use Illuminate\Support\Collection;
use Illuminate\Support\Facades\Log;
use FireflyIII\Support\Facades\Amount;
class CorrectsOpeningBalanceCurrencies extends Command
{
@@ -133,6 +134,6 @@ class CorrectsOpeningBalanceCurrencies extends Command
$repos = app(AccountRepositoryInterface::class);
$repos->setUser($account->user);
return $repos->getAccountCurrency($account) ?? app('amount')->getPrimaryCurrencyByUserGroup($account->userGroup);
return $repos->getAccountCurrency($account) ?? Amount::getPrimaryCurrencyByUserGroup($account->userGroup);
}
}

View File

@@ -48,6 +48,7 @@ use Illuminate\Database\Eloquent\Builder as EloquentBuilder;
use Illuminate\Database\Query\Builder as DatabaseBuilder;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log;
use FireflyIII\Support\Facades\FireflyConfig;
class CorrectsPrimaryCurrencyAmounts extends Command
{
@@ -62,7 +63,7 @@ class CorrectsPrimaryCurrencyAmounts extends Command
*/
public function handle(): int
{
if (false === config('cer.enabled')) {
if (false === FireflyConfig::get('enable_exchange_rates', config('cer.enabled'))->data) {
$this->friendlyInfo('This command will not run because currency exchange rates are disabled.');
return 0;

View File

@@ -30,6 +30,7 @@ use FireflyIII\Enums\TransactionTypeEnum;
use FireflyIII\Models\Transaction;
use FireflyIII\Models\TransactionJournal;
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
use FireflyIII\Support\Facades\FireflyConfig;
use FireflyIII\Support\Facades\Steam;
use FireflyIII\Support\Models\AccountBalanceCalculator;
use Illuminate\Console\Command;
@@ -60,7 +61,7 @@ class CorrectsUnevenAmount extends Command
$this->fixUnevenAmounts();
$this->matchCurrencies();
if (true === config('firefly.feature_flags.running_balance_column')) {
if (true === FireflyConfig::get('use_running_balance', config('firefly.feature_flags.running_balance_column'))->data) {
$this->friendlyInfo('Will recalculate transaction running balance columns. This may take a LONG time. Please be patient.');
AccountBalanceCalculator::recalculateAll(false);
$this->friendlyInfo('Done recalculating transaction running balance columns.');

View File

@@ -28,6 +28,7 @@ namespace FireflyIII\Console\Commands\System;
use FireflyIII\Console\Commands\ShowsFriendlyMessages;
use FireflyIII\Support\Models\AccountBalanceCalculator;
use Illuminate\Console\Command;
use FireflyIII\Support\Facades\FireflyConfig;
class RecalculatesRunningBalance extends Command
{
@@ -52,7 +53,7 @@ class RecalculatesRunningBalance extends Command
*/
public function handle(): int
{
if (true === config('firefly.feature_flags.running_balance_column')) {
if (true === FireflyConfig::get('use_running_balance', config('firefly.feature_flags.running_balance_column'))->data) {
$this->friendlyInfo('Will recalculate account balances. This may take a LONG time. Please be patient.');
$this->correctBalanceAmounts($this->option('force'));
$this->friendlyInfo('Done recalculating account balances.');

View File

@@ -31,6 +31,7 @@ use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Storage;
use League\Flysystem\FilesystemException;
use Safe\Exceptions\JsonException;
use FireflyIII\Support\Facades\FireflyConfig;
use function Safe\json_decode;
@@ -107,8 +108,8 @@ class VerifySecurityAlerts extends Command
private function removeOldAdvisory(): void
{
try {
app('fireflyconfig')->delete('upgrade_security_message');
app('fireflyconfig')->delete('upgrade_security_level');
FireflyConfig::delete('upgrade_security_message');
FireflyConfig::delete('upgrade_security_level');
} catch (QueryException $e) {
Log::debug(sprintf('Could not delete old security advisory, but thats OK: %s', $e->getMessage()));
}
@@ -117,8 +118,8 @@ class VerifySecurityAlerts extends Command
private function saveSecurityAdvisory(array $array): void
{
try {
app('fireflyconfig')->set('upgrade_security_message', $array['message']);
app('fireflyconfig')->set('upgrade_security_level', $array['level']);
FireflyConfig::set('upgrade_security_message', $array['message']);
FireflyConfig::set('upgrade_security_level', $array['level']);
} catch (QueryException $e) {
Log::debug(sprintf('Could not save new security advisory, but thats OK: %s', $e->getMessage()));
}

View File

@@ -36,6 +36,7 @@ use FireflyIII\Support\Cronjobs\WebhookCronjob;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Log;
use InvalidArgumentException;
use FireflyIII\Support\Facades\FireflyConfig;
class Cron extends Command
{
@@ -72,7 +73,7 @@ class Cron extends Command
$force = (bool) $this->option('force'); // @phpstan-ignore-line
// Fire exchange rates cron job.
if (true === config('cer.download_enabled') && ($doAll || $this->option('download-cer'))) {
if (true === FireflyConfig::get('enable_external_rates', config('cer.download_enabled'))->data && ($doAll || $this->option('download-cer'))) {
try {
$this->exchangeRatesCronJob($force, $date);
} catch (FireflyException $e) {

View File

@@ -32,6 +32,7 @@ use Illuminate\Console\Command;
use Illuminate\Database\QueryException;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Schema;
use FireflyIII\Support\Facades\FireflyConfig;
class AddsTransactionIdentifiers extends Command
{
@@ -97,7 +98,7 @@ class AddsTransactionIdentifiers extends Command
private function isExecuted(): bool
{
$configVar = app('fireflyconfig')->get(self::CONFIG_NAME, false);
$configVar = FireflyConfig::get(self::CONFIG_NAME, false);
return (bool)$configVar?->data;
@@ -157,6 +158,6 @@ class AddsTransactionIdentifiers extends Command
private function markAsExecuted(): void
{
app('fireflyconfig')->set(self::CONFIG_NAME, true);
FireflyConfig::set(self::CONFIG_NAME, true);
}
}

View File

@@ -34,6 +34,7 @@ use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log;
use JsonException;
use stdClass;
use FireflyIII\Support\Facades\FireflyConfig;
use function Safe\json_decode;
@@ -86,7 +87,7 @@ class RemovesDatabaseDecryption extends Command
$this->friendlyPositive(sprintf('Decrypted the data in table "%s".', $table));
// mark as decrypted:
$configName = sprintf('is_decrypted_%s', $table);
app('fireflyconfig')->set($configName, true);
FireflyConfig::set($configName, true);
}
private function isDecrypted(string $table): bool
@@ -95,7 +96,7 @@ class RemovesDatabaseDecryption extends Command
$configVar = null;
try {
$configVar = app('fireflyconfig')->get($configName, false);
$configVar = FireflyConfig::get($configName, false);
} catch (FireflyException $e) {
Log::error($e->getMessage());
}

View File

@@ -27,6 +27,7 @@ namespace FireflyIII\Console\Commands\Upgrade;
use FireflyIII\Console\Commands\ShowsFriendlyMessages;
use FireflyIII\Support\Models\AccountBalanceCalculator;
use Illuminate\Console\Command;
use FireflyIII\Support\Facades\FireflyConfig;
class RepairsAccountBalances extends Command
{
@@ -43,7 +44,7 @@ class RepairsAccountBalances extends Command
return 0;
}
if (true === config('firefly.feature_flags.running_balance_column')) {
if (true === FireflyConfig::get('use_running_balance', config('firefly.feature_flags.running_balance_column'))->data) {
$this->friendlyInfo('Will recalculate account balances. This may take a LONG time. Please be patient.');
$this->markAsExecuted();
$this->correctBalanceAmounts();
@@ -58,14 +59,14 @@ class RepairsAccountBalances extends Command
private function isExecuted(): bool
{
$configVar = app('fireflyconfig')->get(self::CONFIG_NAME, false);
$configVar = FireflyConfig::get(self::CONFIG_NAME, false);
return (bool) $configVar?->data;
}
private function markAsExecuted(): void
{
app('fireflyconfig')->set(self::CONFIG_NAME, true);
FireflyConfig::set(self::CONFIG_NAME, true);
}
private function correctBalanceAmounts(): void

View File

@@ -41,7 +41,7 @@ class UpgradeSkeleton extends Command
*/
private function isExecuted(): bool
{
$configVar = app('fireflyconfig')->get(self::CONFIG_NAME, false);
$configVar = \FireflyIII\Support\Facades\FireflyConfig::get(self::CONFIG_NAME, false);
if (null !== $configVar) {
return (bool)$configVar->data;
}
@@ -55,6 +55,6 @@ class UpgradeSkeleton extends Command
*/
private function markAsExecuted(): void
{
app('fireflyconfig')->set(self::CONFIG_NAME, true);
\FireflyIII\Support\Facades\FireflyConfig::set(self::CONFIG_NAME, true);
}
}

View File

@@ -35,6 +35,8 @@ use FireflyIII\Repositories\Account\AccountRepositoryInterface;
use FireflyIII\Repositories\User\UserRepositoryInterface;
use FireflyIII\User;
use Illuminate\Console\Command;
use FireflyIII\Support\Facades\FireflyConfig;
use FireflyIII\Support\Facades\Amount;
class UpgradesAccountCurrencies extends Command
{
@@ -85,7 +87,7 @@ class UpgradesAccountCurrencies extends Command
private function isExecuted(): bool
{
$configVar = app('fireflyconfig')->get(self::CONFIG_NAME, false);
$configVar = FireflyConfig::get(self::CONFIG_NAME, false);
return (bool) $configVar?->data;
}
@@ -104,7 +106,7 @@ class UpgradesAccountCurrencies extends Command
$accounts = $this->accountRepos->getAccountsByType([AccountTypeEnum::DEFAULT->value, AccountTypeEnum::ASSET->value]);
// get user's currency preference:
$primaryCurrency = app('amount')->getPrimaryCurrencyByUserGroup($user->userGroup);
$primaryCurrency = Amount::getPrimaryCurrencyByUserGroup($user->userGroup);
/** @var Account $account */
foreach ($accounts as $account) {
@@ -155,6 +157,6 @@ class UpgradesAccountCurrencies extends Command
private function markAsExecuted(): void
{
app('fireflyconfig')->set(self::CONFIG_NAME, true);
FireflyConfig::set(self::CONFIG_NAME, true);
}
}

View File

@@ -28,6 +28,7 @@ use FireflyIII\Console\Commands\ShowsFriendlyMessages;
use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Models\AccountMeta;
use Illuminate\Console\Command;
use FireflyIII\Support\Facades\FireflyConfig;
class UpgradesAccountMetaData extends Command
{
@@ -82,7 +83,7 @@ class UpgradesAccountMetaData extends Command
private function isExecuted(): bool
{
$configVar = app('fireflyconfig')->get(self::CONFIG_NAME, false);
$configVar = FireflyConfig::get(self::CONFIG_NAME, false);
return (bool)$configVar?->data;
@@ -90,6 +91,6 @@ class UpgradesAccountMetaData extends Command
private function markAsExecuted(): void
{
app('fireflyconfig')->set(self::CONFIG_NAME, true);
FireflyConfig::set(self::CONFIG_NAME, true);
}
}

View File

@@ -30,6 +30,7 @@ use FireflyIII\Models\Attachment;
use FireflyIII\Models\Note;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Log;
use FireflyIII\Support\Facades\FireflyConfig;
class UpgradesAttachments extends Command
{
@@ -92,7 +93,7 @@ class UpgradesAttachments extends Command
private function isExecuted(): bool
{
$configVar = app('fireflyconfig')->get(self::CONFIG_NAME, false);
$configVar = FireflyConfig::get(self::CONFIG_NAME, false);
return (bool)$configVar?->data;
@@ -100,6 +101,6 @@ class UpgradesAttachments extends Command
private function markAsExecuted(): void
{
app('fireflyconfig')->set(self::CONFIG_NAME, true);
FireflyConfig::set(self::CONFIG_NAME, true);
}
}

View File

@@ -36,6 +36,7 @@ use FireflyIII\Repositories\User\UserRepositoryInterface;
use FireflyIII\Support\Facades\Preferences;
use FireflyIII\User;
use Illuminate\Console\Command;
use FireflyIII\Support\Facades\FireflyConfig;
class UpgradesBillsToRules extends Command
{
@@ -99,7 +100,7 @@ class UpgradesBillsToRules extends Command
private function isExecuted(): bool
{
$configVar = app('fireflyconfig')->get(self::CONFIG_NAME, false);
$configVar = FireflyConfig::get(self::CONFIG_NAME, false);
return (bool)$configVar?->data;
@@ -206,6 +207,6 @@ class UpgradesBillsToRules extends Command
private function markAsExecuted(): void
{
app('fireflyconfig')->set(self::CONFIG_NAME, true);
FireflyConfig::set(self::CONFIG_NAME, true);
}
}

View File

@@ -28,6 +28,7 @@ use FireflyIII\Console\Commands\ShowsFriendlyMessages;
use FireflyIII\Models\BudgetLimit;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Log;
use FireflyIII\Support\Facades\FireflyConfig;
class UpgradesBudgetLimitPeriods extends Command
{
@@ -58,7 +59,7 @@ class UpgradesBudgetLimitPeriods extends Command
private function isExecuted(): bool
{
$configVar = app('fireflyconfig')->get(self::CONFIG_NAME, false);
$configVar = FireflyConfig::get(self::CONFIG_NAME, false);
return (bool) $configVar->data;
}
@@ -152,6 +153,6 @@ class UpgradesBudgetLimitPeriods extends Command
private function markAsExecuted(): void
{
app('fireflyconfig')->set(self::CONFIG_NAME, true);
FireflyConfig::set(self::CONFIG_NAME, true);
}
}

View File

@@ -30,6 +30,8 @@ use FireflyIII\Models\Budget;
use FireflyIII\Models\BudgetLimit;
use FireflyIII\User;
use Illuminate\Console\Command;
use FireflyIII\Support\Facades\FireflyConfig;
use FireflyIII\Support\Facades\Amount;
class UpgradesBudgetLimits extends Command
{
@@ -66,7 +68,7 @@ class UpgradesBudgetLimits extends Command
/** @var null|User $user */
$user = $budget->user;
if (null !== $user) {
$currency = app('amount')->getPrimaryCurrencyByUserGroup($user->userGroup);
$currency = Amount::getPrimaryCurrencyByUserGroup($user->userGroup);
$budgetLimit->transaction_currency_id = $currency->id;
$budgetLimit->save();
$this->friendlyInfo(
@@ -84,7 +86,7 @@ class UpgradesBudgetLimits extends Command
private function isExecuted(): bool
{
$configVar = app('fireflyconfig')->get(self::CONFIG_NAME, false);
$configVar = FireflyConfig::get(self::CONFIG_NAME, false);
return (bool)$configVar?->data;
@@ -92,6 +94,6 @@ class UpgradesBudgetLimits extends Command
private function markAsExecuted(): void
{
app('fireflyconfig')->set(self::CONFIG_NAME, true);
FireflyConfig::set(self::CONFIG_NAME, true);
}
}

View File

@@ -31,6 +31,7 @@ use FireflyIII\Models\Account;
use FireflyIII\Models\AccountType;
use Illuminate\Console\Command;
use Illuminate\Support\Collection;
use FireflyIII\Support\Facades\FireflyConfig;
class UpgradesCreditCardLiabilities extends Command
{
@@ -80,13 +81,13 @@ class UpgradesCreditCardLiabilities extends Command
private function isExecuted(): bool
{
$configVar = app('fireflyconfig')->get(self::CONFIG_NAME, false);
$configVar = FireflyConfig::get(self::CONFIG_NAME, false);
return (bool) $configVar?->data;
}
private function markAsExecuted(): void
{
app('fireflyconfig')->set(self::CONFIG_NAME, true);
FireflyConfig::set(self::CONFIG_NAME, true);
}
}

View File

@@ -33,6 +33,7 @@ use FireflyIII\Support\Facades\Amount;
use FireflyIII\User;
use Illuminate\Console\Command;
use Illuminate\Support\Collection;
use FireflyIII\Support\Facades\FireflyConfig;
class UpgradesCurrencyPreferences extends Command
{
@@ -65,7 +66,7 @@ class UpgradesCurrencyPreferences extends Command
private function isExecuted(): bool
{
$configVar = app('fireflyconfig')->get(self::CONFIG_NAME, false);
$configVar = FireflyConfig::get(self::CONFIG_NAME, false);
return (bool)$configVar?->data;
@@ -144,6 +145,6 @@ class UpgradesCurrencyPreferences extends Command
private function markAsExecuted(): void
{
app('fireflyconfig')->set(self::CONFIG_NAME, true);
FireflyConfig::set(self::CONFIG_NAME, true);
}
}

View File

@@ -32,6 +32,7 @@ use FireflyIII\Models\TransactionJournal;
use Illuminate\Console\Command;
use Illuminate\Support\Collection;
use Illuminate\Support\Facades\DB;
use FireflyIII\Support\Facades\FireflyConfig;
class UpgradesJournalMetaData extends Command
{
@@ -69,14 +70,14 @@ class UpgradesJournalMetaData extends Command
private function isMigrated(): bool
{
$configVar = app('fireflyconfig')->get(UpgradesToGroups::CONFIG_NAME, false);
$configVar = FireflyConfig::get(UpgradesToGroups::CONFIG_NAME, false);
return (bool) $configVar->data;
}
private function isExecuted(): bool
{
$configVar = app('fireflyconfig')->get(self::CONFIG_NAME, false);
$configVar = FireflyConfig::get(self::CONFIG_NAME, false);
return (bool) $configVar->data;
}
@@ -218,6 +219,6 @@ class UpgradesJournalMetaData extends Command
private function markAsExecuted(): void
{
app('fireflyconfig')->set(self::CONFIG_NAME, true);
FireflyConfig::set(self::CONFIG_NAME, true);
}
}

View File

@@ -29,6 +29,7 @@ use FireflyIII\Models\Note;
use FireflyIII\Models\TransactionJournalMeta;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Log;
use FireflyIII\Support\Facades\FireflyConfig;
class UpgradesJournalNotes extends Command
{
@@ -86,7 +87,7 @@ class UpgradesJournalNotes extends Command
private function isExecuted(): bool
{
$configVar = app('fireflyconfig')->get(self::CONFIG_NAME, false);
$configVar = FireflyConfig::get(self::CONFIG_NAME, false);
return (bool)$configVar?->data;
@@ -94,6 +95,6 @@ class UpgradesJournalNotes extends Command
private function markAsExecuted(): void
{
app('fireflyconfig')->set(self::CONFIG_NAME, true);
FireflyConfig::set(self::CONFIG_NAME, true);
}
}

View File

@@ -33,6 +33,7 @@ use FireflyIII\Repositories\Account\AccountRepositoryInterface;
use FireflyIII\Services\Internal\Support\CreditRecalculateService;
use FireflyIII\User;
use Illuminate\Console\Command;
use FireflyIII\Support\Facades\FireflyConfig;
class UpgradesLiabilities extends Command
{
@@ -61,7 +62,7 @@ class UpgradesLiabilities extends Command
private function isExecuted(): bool
{
$configVar = app('fireflyconfig')->get(self::CONFIG_NAME, false);
$configVar = FireflyConfig::get(self::CONFIG_NAME, false);
return (bool)$configVar?->data;
@@ -148,6 +149,6 @@ class UpgradesLiabilities extends Command
private function markAsExecuted(): void
{
app('fireflyconfig')->set(self::CONFIG_NAME, true);
FireflyConfig::set(self::CONFIG_NAME, true);
}
}

View File

@@ -36,6 +36,7 @@ use FireflyIII\Services\Internal\Support\CreditRecalculateService;
use FireflyIII\User;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Log;
use FireflyIII\Support\Facades\FireflyConfig;
class UpgradesLiabilitiesEight extends Command
{
@@ -63,7 +64,7 @@ class UpgradesLiabilitiesEight extends Command
private function isExecuted(): bool
{
$configVar = app('fireflyconfig')->get(self::CONFIG_NAME, false);
$configVar = FireflyConfig::get(self::CONFIG_NAME, false);
return (bool)$configVar?->data;
@@ -207,6 +208,6 @@ class UpgradesLiabilitiesEight extends Command
private function markAsExecuted(): void
{
app('fireflyconfig')->set(self::CONFIG_NAME, true);
FireflyConfig::set(self::CONFIG_NAME, true);
}
}

View File

@@ -31,6 +31,8 @@ use FireflyIII\Repositories\Account\AccountRepositoryInterface;
use FireflyIII\Repositories\PiggyBank\PiggyBankRepositoryInterface;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Log;
use FireflyIII\Support\Facades\FireflyConfig;
use FireflyIII\Support\Facades\Amount;
class UpgradesMultiPiggyBanks extends Command
{
@@ -64,7 +66,7 @@ class UpgradesMultiPiggyBanks extends Command
private function isExecuted(): bool
{
$configVar = app('fireflyconfig')->get(self::CONFIG_NAME, false);
$configVar = FireflyConfig::get(self::CONFIG_NAME, false);
return (bool)$configVar?->data;
@@ -94,7 +96,7 @@ class UpgradesMultiPiggyBanks extends Command
$this->repository->setUser($piggyBank->account->user);
$this->accountRepository->setUser($piggyBank->account->user);
$repetition = $this->repository->getRepetition($piggyBank, true);
$currency = $this->accountRepository->getAccountCurrency($piggyBank->account) ?? app('amount')->getPrimaryCurrencyByUserGroup($piggyBank->account->user->userGroup);
$currency = $this->accountRepository->getAccountCurrency($piggyBank->account) ?? Amount::getPrimaryCurrencyByUserGroup($piggyBank->account->user->userGroup);
// update piggy bank to have a currency.
$piggyBank->transaction_currency_id = $currency->id;
@@ -112,6 +114,6 @@ class UpgradesMultiPiggyBanks extends Command
private function markAsExecuted(): void
{
app('fireflyconfig')->set(self::CONFIG_NAME, true);
FireflyConfig::set(self::CONFIG_NAME, true);
}
}

View File

@@ -28,6 +28,7 @@ namespace FireflyIII\Console\Commands\Upgrade;
use FireflyIII\Console\Commands\ShowsFriendlyMessages;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Artisan;
use FireflyIII\Support\Facades\FireflyConfig;
class UpgradesPrimaryCurrencyAmounts extends Command
{
@@ -60,7 +61,7 @@ class UpgradesPrimaryCurrencyAmounts extends Command
private function isExecuted(): bool
{
$configVar = app('fireflyconfig')->get(self::CONFIG_NAME, false);
$configVar = FireflyConfig::get(self::CONFIG_NAME, false);
return (bool)$configVar?->data;
@@ -68,6 +69,6 @@ class UpgradesPrimaryCurrencyAmounts extends Command
private function markAsExecuted(): void
{
app('fireflyconfig')->set(self::CONFIG_NAME, true);
FireflyConfig::set(self::CONFIG_NAME, true);
}
}

View File

@@ -29,6 +29,7 @@ use FireflyIII\Models\Recurrence;
use FireflyIII\Models\RecurrenceMeta;
use FireflyIII\Models\RecurrenceTransactionMeta;
use Illuminate\Console\Command;
use FireflyIII\Support\Facades\FireflyConfig;
use function Safe\json_encode;
@@ -65,7 +66,7 @@ class UpgradesRecurrenceMetaData extends Command
private function isExecuted(): bool
{
$configVar = app('fireflyconfig')->get(self::CONFIG_NAME, false);
$configVar = FireflyConfig::get(self::CONFIG_NAME, false);
return (bool)$configVar?->data;
@@ -117,6 +118,6 @@ class UpgradesRecurrenceMetaData extends Command
private function markAsExecuted(): void
{
app('fireflyconfig')->set(self::CONFIG_NAME, true);
FireflyConfig::set(self::CONFIG_NAME, true);
}
}

View File

@@ -28,6 +28,7 @@ namespace FireflyIII\Console\Commands\Upgrade;
use FireflyIII\Console\Commands\ShowsFriendlyMessages;
use FireflyIII\Models\RuleAction;
use Illuminate\Console\Command;
use FireflyIII\Support\Facades\FireflyConfig;
class UpgradesRuleActions extends Command
{
@@ -63,7 +64,7 @@ class UpgradesRuleActions extends Command
private function isExecuted(): bool
{
$configVar = app('fireflyconfig')->get(self::CONFIG_NAME, false);
$configVar = FireflyConfig::get(self::CONFIG_NAME, false);
return (bool)$configVar?->data;
@@ -183,6 +184,6 @@ class UpgradesRuleActions extends Command
private function markAsExecuted(): void
{
app('fireflyconfig')->set(self::CONFIG_NAME, true);
FireflyConfig::set(self::CONFIG_NAME, true);
}
}

View File

@@ -28,6 +28,7 @@ use FireflyIII\Console\Commands\ShowsFriendlyMessages;
use FireflyIII\Models\Location;
use FireflyIII\Models\Tag;
use Illuminate\Console\Command;
use FireflyIII\Support\Facades\FireflyConfig;
class UpgradesTagLocations extends Command
{
@@ -57,7 +58,7 @@ class UpgradesTagLocations extends Command
private function isExecuted(): bool
{
$configVar = app('fireflyconfig')->get(self::CONFIG_NAME, false);
$configVar = FireflyConfig::get(self::CONFIG_NAME, false);
return (bool)$configVar?->data;
@@ -97,6 +98,6 @@ class UpgradesTagLocations extends Command
private function markAsExecuted(): void
{
app('fireflyconfig')->set(self::CONFIG_NAME, true);
FireflyConfig::set(self::CONFIG_NAME, true);
}
}

View File

@@ -39,6 +39,7 @@ use Illuminate\Console\Command;
use Illuminate\Support\Collection;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log;
use FireflyIII\Support\Facades\FireflyConfig;
class UpgradesToGroups extends Command
{
@@ -97,7 +98,7 @@ class UpgradesToGroups extends Command
private function isMigrated(): bool
{
$configVar = app('fireflyconfig')->get(self::CONFIG_NAME, false);
$configVar = FireflyConfig::get(self::CONFIG_NAME, false);
return (bool)$configVar?->data;
@@ -379,6 +380,6 @@ class UpgradesToGroups extends Command
private function markAsMigrated(): void
{
app('fireflyconfig')->set(self::CONFIG_NAME, true);
FireflyConfig::set(self::CONFIG_NAME, true);
}
}

View File

@@ -34,6 +34,7 @@ use FireflyIII\Repositories\Account\AccountRepositoryInterface;
use FireflyIII\Repositories\Journal\JournalCLIRepositoryInterface;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Log;
use FireflyIII\Support\Facades\FireflyConfig;
class UpgradesTransferCurrencies extends Command
{
@@ -105,7 +106,7 @@ class UpgradesTransferCurrencies extends Command
private function isExecuted(): bool
{
$configVar = app('fireflyconfig')->get(self::CONFIG_NAME, false);
$configVar = FireflyConfig::get(self::CONFIG_NAME, false);
return (bool)$configVar?->data;
@@ -480,6 +481,6 @@ class UpgradesTransferCurrencies extends Command
private function markAsExecuted(): void
{
app('fireflyconfig')->set(self::CONFIG_NAME, true);
FireflyConfig::set(self::CONFIG_NAME, true);
}
}

View File

@@ -35,6 +35,7 @@ use FireflyIII\Repositories\Account\AccountRepositoryInterface;
use FireflyIII\Repositories\Journal\JournalCLIRepositoryInterface;
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
use Illuminate\Console\Command;
use FireflyIII\Support\Facades\FireflyConfig;
class UpgradesVariousCurrencyInformation extends Command
{
@@ -86,7 +87,7 @@ class UpgradesVariousCurrencyInformation extends Command
private function isExecuted(): bool
{
$configVar = app('fireflyconfig')->get(self::CONFIG_NAME, false);
$configVar = FireflyConfig::get(self::CONFIG_NAME, false);
return (bool)$configVar?->data;
@@ -246,6 +247,6 @@ class UpgradesVariousCurrencyInformation extends Command
private function markAsExecuted(): void
{
app('fireflyconfig')->set(self::CONFIG_NAME, true);
FireflyConfig::set(self::CONFIG_NAME, true);
}
}

View File

@@ -34,6 +34,7 @@ use FireflyIII\Models\WebhookDelivery as WebhookDeliveryModel;
use FireflyIII\Models\WebhookResponse as WebhookResponseModel;
use FireflyIII\Models\WebhookTrigger as WebhookTriggerModel;
use Illuminate\Console\Command;
use FireflyIII\Support\Facades\FireflyConfig;
class UpgradesWebhooks extends Command
{
@@ -63,7 +64,7 @@ class UpgradesWebhooks extends Command
private function isExecuted(): bool
{
$configVar = app('fireflyconfig')->get(self::CONFIG_NAME, false);
$configVar = FireflyConfig::get(self::CONFIG_NAME, false);
return (bool)$configVar?->data;
@@ -109,6 +110,6 @@ class UpgradesWebhooks extends Command
private function markAsExecuted(): void
{
app('fireflyconfig')->set(self::CONFIG_NAME, true);
FireflyConfig::set(self::CONFIG_NAME, true);
}
}

View File

@@ -32,6 +32,7 @@ use FireflyIII\Services\Internal\Support\BillServiceTrait;
use FireflyIII\User;
use Illuminate\Database\QueryException;
use Illuminate\Support\Facades\Log;
use FireflyIII\Support\Facades\Amount;
/**
* Class BillFactory
@@ -51,7 +52,7 @@ class BillFactory
Log::debug(sprintf('Now in %s', __METHOD__), $data);
$factory = app(TransactionCurrencyFactory::class);
$currency = $factory->find((int) ($data['currency_id'] ?? null), (string) ($data['currency_code'] ?? null))
?? app('amount')->getPrimaryCurrencyByUserGroup($this->user->userGroup);
?? Amount::getPrimaryCurrencyByUserGroup($this->user->userGroup);
try {
$skip = array_key_exists('skip', $data) ? $data['skip'] : 0;

View File

@@ -36,6 +36,7 @@ use FireflyIII\Repositories\PiggyBank\PiggyBankRepositoryInterface;
use FireflyIII\User;
use Illuminate\Database\QueryException;
use Illuminate\Support\Facades\Log;
use FireflyIII\Support\Facades\Amount;
use function Safe\json_encode;
@@ -126,7 +127,7 @@ class PiggyBankFactory
private function getCurrency(array $data): TransactionCurrency
{
// currency:
$primaryCurrency = app('amount')->getPrimaryCurrency();
$primaryCurrency = Amount::getPrimaryCurrency();
$currency = null;
if (array_key_exists('transaction_currency_code', $data)) {
$currency = $this->currencyRepository->findByCode((string)($data['transaction_currency_code'] ?? ''));

View File

@@ -55,6 +55,7 @@ use FireflyIII\Validation\AccountValidator;
use Illuminate\Support\Collection;
use Illuminate\Support\Facades\Log;
use JsonException;
use FireflyIII\Support\Facades\Amount;
use function Safe\json_encode;
@@ -251,7 +252,7 @@ class TransactionJournalFactory
$foreignCurrency = $this->getForeignByAccount($type->type, $foreignCurrency, $destinationAccount);
$description = $this->getDescription($description);
Log::debug(sprintf('Currency is #%d "%s", foreign currency is #%d "%s"', $currency->id, $currency->code, $foreignCurrency?->id, $foreignCurrency));
Log::debug(sprintf('Currency is #%d "%s", foreign currency is #%d "%s"', $currency->id, $currency->code, $foreignCurrency?->id, $foreignCurrency?->code));
Log::debug(sprintf('Date: %s (%s)', $carbon->toW3cString(), $carbon->getTimezone()->getName()));
/** Create a basic journal. */
@@ -502,7 +503,7 @@ class TransactionJournalFactory
$preference = $this->accountRepository->getAccountCurrency($account);
if (null === $preference && !$currency instanceof TransactionCurrency) {
// return user's default:
return app('amount')->getPrimaryCurrencyByUserGroup($this->user->userGroup);
return Amount::getPrimaryCurrencyByUserGroup($this->user->userGroup);
}
$result = $preference ?? $currency;
Log::debug(sprintf('Currency is now #%d (%s) because of account #%d (%s)', $result->id, $result->code, $account->id, $account->name));

View File

@@ -51,7 +51,7 @@ class TransactionJournalMetaFactory
Log::debug('Is a carbon object.');
$value = $data['data']->toW3cString();
}
if ('' === (string) $value) {
if ('' === (string)$value) {
// Log::debug('Is an empty string.');
// don't store blank strings.
if (null !== $entry) {

View File

@@ -35,6 +35,7 @@ use FireflyIII\Support\Facades\Steam;
use Illuminate\Support\Collection;
use Illuminate\Support\Facades\Log;
use Throwable;
use FireflyIII\Support\Facades\Amount;
/**
* Class MonthReportGenerator.
@@ -144,7 +145,7 @@ class MonthReportGenerator implements ReportGeneratorInterface
$dayBeforeBalance = Steam::accountsBalancesOptimized(new Collection()->push($account), $date)[$account->id];
$startBalance = $dayBeforeBalance['balance'];
$primaryCurrency = app('amount')->getPrimaryCurrencyByUserGroup($account->user->userGroup);
$primaryCurrency = Amount::getPrimaryCurrencyByUserGroup($account->user->userGroup);
$currency = $accountRepository->getAccountCurrency($account) ?? $primaryCurrency;
foreach ($journals as $index => $journal) {

View File

@@ -37,6 +37,7 @@ use FireflyIII\Notifications\Test\OwnerTestNotificationPushover;
use FireflyIII\Notifications\Test\OwnerTestNotificationSlack;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Notification;
use FireflyIII\Support\Facades\FireflyConfig;
/**
* Class AdminEventHandler.
@@ -45,7 +46,7 @@ class AdminEventHandler
{
public function sendInvitationNotification(InvitationCreated $event): void
{
$sendMail = app('fireflyconfig')->get('notification_invite_created', true)->data;
$sendMail = FireflyConfig::get('notification_invite_created', true)->data;
if (false === $sendMail) {
return;
}
@@ -96,7 +97,7 @@ class AdminEventHandler
*/
public function sendNewVersion(NewVersionAvailable $event): void
{
$sendMail = app('fireflyconfig')->get('notification_new_version', true)->data;
$sendMail = FireflyConfig::get('notification_new_version', true)->data;
if (false === $sendMail) {
return;
}

View File

@@ -57,6 +57,7 @@ use Illuminate\Auth\Events\Login;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Mail;
use Illuminate\Support\Facades\Notification;
use FireflyIII\Support\Facades\FireflyConfig;
/**
* Class UserEventHandler.
@@ -224,7 +225,7 @@ class UserEventHandler
public function sendAdminRegistrationNotification(RegisteredUser $event): void
{
$sendMail = (bool)app('fireflyconfig')->get('notification_admin_new_reg', true)->data;
$sendMail = (bool)FireflyConfig::get('notification_admin_new_reg', true)->data;
if ($sendMail) {
$owner = $event->owner;
@@ -367,7 +368,7 @@ class UserEventHandler
*/
public function sendRegistrationMail(RegisteredUser $event): void
{
$sendMail = (bool)app('fireflyconfig')->get('notification_user_new_reg', true)->data;
$sendMail = (bool)FireflyConfig::get('notification_user_new_reg', true)->data;
if ($sendMail) {
try {
Notification::send($event->user, new UserRegistrationNotification());

View File

@@ -33,6 +33,7 @@ use FireflyIII\Repositories\User\UserRepositoryInterface;
use Illuminate\Support\Facades\Log;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\NotFoundExceptionInterface;
use FireflyIII\Support\Facades\FireflyConfig;
/**
* Class VersionCheckEventHandler
@@ -54,7 +55,7 @@ class VersionCheckEventHandler
Log::debug('Now in checkForUpdates()');
// should not check for updates:
$permission = app('fireflyconfig')->get('permission_update_check', -1);
$permission = FireflyConfig::get('permission_update_check', -1);
$value = (int) $permission->data;
if (1 !== $value) {
Log::debug('Update check is not enabled.');
@@ -73,7 +74,7 @@ class VersionCheckEventHandler
}
/** @var Configuration $lastCheckTime */
$lastCheckTime = app('fireflyconfig')->get('last_update_check', Carbon::now()->getTimestamp());
$lastCheckTime = FireflyConfig::get('last_update_check', Carbon::now()->getTimestamp());
$now = Carbon::now()->getTimestamp();
$diff = $now - $lastCheckTime->data;
Log::debug(sprintf('Last check time is %d, current time is %d, difference is %d', $lastCheckTime->data, $now, $diff));
@@ -87,7 +88,7 @@ class VersionCheckEventHandler
$release = $this->getLatestRelease();
session()->flash($release['level'], $release['message']);
app('fireflyconfig')->set('last_update_check', Carbon::now()->getTimestamp());
FireflyConfig::set('last_update_check', Carbon::now()->getTimestamp());
}
/**
@@ -107,7 +108,7 @@ class VersionCheckEventHandler
}
/** @var Configuration $lastCheckTime */
$lastCheckTime = app('fireflyconfig')->get('last_update_warning', Carbon::now()->getTimestamp());
$lastCheckTime = FireflyConfig::get('last_update_warning', Carbon::now()->getTimestamp());
$now = Carbon::now()->getTimestamp();
$diff = $now - $lastCheckTime->data;
Log::debug(sprintf('Last warning time is %d, current time is %d, difference is %d', $lastCheckTime->data, $now, $diff));
@@ -120,6 +121,6 @@ class VersionCheckEventHandler
Log::debug('Have warned about a new version in four weeks!');
session()->flash('info', (string) trans('firefly.disabled_but_check'));
app('fireflyconfig')->set('last_update_warning', Carbon::now()->getTimestamp());
FireflyConfig::set('last_update_warning', Carbon::now()->getTimestamp());
}
}

View File

@@ -27,6 +27,7 @@ namespace FireflyIII\Handlers\Events;
use FireflyIII\Jobs\SendWebhookMessage;
use FireflyIII\Models\WebhookMessage;
use Illuminate\Support\Facades\Log;
use FireflyIII\Support\Facades\FireflyConfig;
/**
* Class WebhookEventHandler
@@ -39,7 +40,7 @@ class WebhookEventHandler
public function sendWebhookMessages(): void
{
Log::debug(sprintf('Now in %s', __METHOD__));
if (false === config('firefly.feature_flags.webhooks') || false === config('firefly.allow_webhooks')) {
if (false === config('firefly.feature_flags.webhooks') || false === FireflyConfig::get('allow_webhooks', config('firefly.allow_webhooks'))->data) {
Log::debug('Webhook event handler is disabled, do not run sendWebhookMessages().');
return;

View File

@@ -52,7 +52,7 @@ class AccountObserver
if (!Amount::convertToPrimary($account->user)) {
return;
}
$userCurrency = app('amount')->getPrimaryCurrencyByUserGroup($account->user->userGroup);
$userCurrency = Amount::getPrimaryCurrencyByUserGroup($account->user->userGroup);
$repository = app(AccountRepositoryInterface::class);
$currency = $repository->getAccountCurrency($account);
if (null !== $currency && $currency->id !== $userCurrency->id && '' !== (string) $account->virtual_balance && 0 !== bccomp($account->virtual_balance, '0')) {

View File

@@ -42,7 +42,7 @@ class AutoBudgetObserver
if (!Amount::convertToPrimary($autoBudget->budget->user)) {
return;
}
$userCurrency = app('amount')->getPrimaryCurrencyByUserGroup($autoBudget->budget->user->userGroup);
$userCurrency = Amount::getPrimaryCurrencyByUserGroup($autoBudget->budget->user->userGroup);
$autoBudget->native_amount = null;
if ($autoBudget->transactionCurrency->id !== $userCurrency->id) {
$converter = new ExchangeRateConverter();

View File

@@ -44,7 +44,7 @@ class AvailableBudgetObserver
return;
}
$userCurrency = app('amount')->getPrimaryCurrencyByUserGroup($availableBudget->user->userGroup);
$userCurrency = Amount::getPrimaryCurrencyByUserGroup($availableBudget->user->userGroup);
$availableBudget->native_amount = null;
if ($availableBudget->transactionCurrency->id !== $userCurrency->id) {
$converter = new ExchangeRateConverter();

View File

@@ -46,7 +46,7 @@ class BillObserver
if (!Amount::convertToPrimary($bill->user)) {
return;
}
$userCurrency = app('amount')->getPrimaryCurrencyByUserGroup($bill->user->userGroup);
$userCurrency = Amount::getPrimaryCurrencyByUserGroup($bill->user->userGroup);
$bill->native_amount_min = null;
$bill->native_amount_max = null;
if ($bill->transactionCurrency->id !== $userCurrency->id) {

View File

@@ -72,7 +72,7 @@ class BudgetLimitObserver
return;
}
$userCurrency = app('amount')->getPrimaryCurrencyByUserGroup($budgetLimit->budget->user->userGroup);
$userCurrency = Amount::getPrimaryCurrencyByUserGroup($budgetLimit->budget->user->userGroup);
$budgetLimit->native_amount = null;
if ($budgetLimit->transactionCurrency->id !== $userCurrency->id) {
$converter = new ExchangeRateConverter();

View File

@@ -48,7 +48,7 @@ class PiggyBankEventObserver
if (!Amount::convertToPrimary($user)) {
return;
}
$userCurrency = app('amount')->getPrimaryCurrencyByUserGroup($event->piggyBank->accounts()->first()->user->userGroup);
$userCurrency = Amount::getPrimaryCurrencyByUserGroup($event->piggyBank->accounts()->first()->user->userGroup);
$event->native_amount = null;
if ($event->piggyBank->transactionCurrency->id !== $userCurrency->id) {
$converter = new ExchangeRateConverter();

View File

@@ -29,6 +29,7 @@ use FireflyIII\Models\PiggyBank;
use FireflyIII\Repositories\Attachment\AttachmentRepositoryInterface;
use FireflyIII\Support\Http\Api\ExchangeRateConverter;
use Illuminate\Support\Facades\Log;
use FireflyIII\Support\Facades\Amount;
/**
* Class PiggyBankObserver
@@ -49,7 +50,7 @@ class PiggyBankObserver
return;
}
$userCurrency = app('amount')->getPrimaryCurrencyByUserGroup($group);
$userCurrency = Amount::getPrimaryCurrencyByUserGroup($group);
$piggyBank->native_target_amount = null;
if ($piggyBank->transactionCurrency->id !== $userCurrency->id) {
$converter = new ExchangeRateConverter();

View File

@@ -24,7 +24,9 @@ declare(strict_types=1);
namespace FireflyIII\Handlers\Observer;
use FireflyIII\Models\Transaction;
use FireflyIII\Models\TransactionJournal;
use FireflyIII\Support\Facades\Amount;
use FireflyIII\Support\Facades\FireflyConfig;
use FireflyIII\Support\Http\Api\ExchangeRateConverter;
use FireflyIII\Support\Models\AccountBalanceCalculator;
use Illuminate\Support\Facades\Log;
@@ -39,9 +41,12 @@ class TransactionObserver
public function created(Transaction $transaction): void
{
Log::debug('Observe "created" of a transaction.');
if (true === config('firefly.feature_flags.running_balance_column') && (1 === bccomp($transaction->amount, '0') && self::$recalculate)) {
if (true === FireflyConfig::get('use_running_balance', config('firefly.feature_flags.running_balance_column'))->data && (1 === bccomp($transaction->amount, '0') && self::$recalculate)) {
Log::debug('Trigger recalculateForJournal');
AccountBalanceCalculator::recalculateForJournal($transaction->transactionJournal);
$journal = $transaction->transactionJournal;
if ($journal instanceof TransactionJournal) {
AccountBalanceCalculator::recalculateForJournal($journal);
}
}
$this->updatePrimaryCurrencyAmount($transaction);
}
@@ -51,11 +56,14 @@ class TransactionObserver
if (!Amount::convertToPrimary($transaction->transactionJournal->user)) {
return;
}
$userCurrency = app('amount')->getPrimaryCurrencyByUserGroup($transaction->transactionJournal->user->userGroup);
$userCurrency = Amount::getPrimaryCurrencyByUserGroup($transaction->transactionJournal->user->userGroup);
$transaction->native_amount = null;
$transaction->native_foreign_amount = null;
// first normal amount
if ($transaction->transactionCurrency->id !== $userCurrency->id && (null === $transaction->foreign_currency_id || (null !== $transaction->foreign_currency_id && $transaction->foreign_currency_id !== $userCurrency->id))) {
if ($transaction->transactionCurrency->id !== $userCurrency->id
&& (null === $transaction->foreign_currency_id
|| (null !== $transaction->foreign_currency_id
&& $transaction->foreign_currency_id !== $userCurrency->id))) {
$converter = new ExchangeRateConverter();
$converter->setUserGroup($transaction->transactionJournal->user->userGroup);
$converter->setIgnoreSettings(true);
@@ -82,7 +90,7 @@ class TransactionObserver
public function updated(Transaction $transaction): void
{
// Log::debug('Observe "updated" of a transaction.');
if (true === config('firefly.feature_flags.running_balance_column') && self::$recalculate && 1 === bccomp($transaction->amount, '0')) {
if (true === FireflyConfig::get('use_running_balance', config('firefly.feature_flags.running_balance_column'))->data && self::$recalculate && 1 === bccomp($transaction->amount, '0')) {
Log::debug('Trigger recalculateForJournal');
AccountBalanceCalculator::recalculateForJournal($transaction->transactionJournal);
}

View File

@@ -26,6 +26,7 @@ namespace FireflyIII\Helpers\Update;
use FireflyIII\Services\FireflyIIIOrg\Update\UpdateRequestInterface;
use Illuminate\Support\Facades\Log;
use FireflyIII\Support\Facades\FireflyConfig;
/**
* Trait UpdateTrait
@@ -43,7 +44,7 @@ trait UpdateTrait
/** @var UpdateRequestInterface $checker */
$checker = app(UpdateRequestInterface::class);
$channelConfig = app('fireflyconfig')->get('update_channel', 'stable');
$channelConfig = FireflyConfig::get('update_channel', 'stable');
$channel = (string) $channelConfig->data;
return $checker->getUpdateInformation($channel);

View File

@@ -23,11 +23,11 @@ declare(strict_types=1);
namespace FireflyIII\Http\Controllers\Admin;
use FireflyIII\Support\Facades\Preferences;
use FireflyIII\Http\Controllers\Controller;
use FireflyIII\Http\Middleware\IsDemoUser;
use FireflyIII\Http\Requests\ConfigurationRequest;
use FireflyIII\Support\Facades\FireflyConfig;
use FireflyIII\Support\Facades\Preferences;
use Illuminate\Contracts\View\Factory;
use Illuminate\Http\RedirectResponse;
use Illuminate\Support\Facades\Log;
@@ -47,7 +47,7 @@ class ConfigurationController extends Controller
$this->middleware(
static function ($request, $next) {
app('view')->share('title', (string) trans('firefly.system_settings'));
app('view')->share('title', (string)trans('firefly.system_settings'));
app('view')->share('mainTitleIcon', 'fa-hand-spock-o');
return $next($request);
@@ -63,20 +63,39 @@ class ConfigurationController extends Controller
*/
public function index(): Factory|\Illuminate\Contracts\View\View
{
$subTitle = (string) trans('firefly.instance_configuration');
$subTitleIcon = 'fa-wrench';
$subTitle = (string)trans('firefly.instance_configuration');
$subTitleIcon = 'fa-wrench';
Log::channel('audit')->info('User visits admin config index.');
// all available configuration and their default value in case
// they don't exist yet.
$singleUserMode = FireflyConfig::get('single_user_mode', config('firefly.configuration.single_user_mode'))->data;
$isDemoSite = FireflyConfig::get('is_demo_site', config('firefly.configuration.is_demo_site'))->data;
$siteOwner = config('firefly.site_owner');
$singleUserMode = FireflyConfig::get('single_user_mode', config('firefly.configuration.single_user_mode'))->data;
$isDemoSite = FireflyConfig::get('is_demo_site', config('firefly.configuration.is_demo_site'))->data;
$siteOwner = config('firefly.site_owner');
$enableExchangeRates = FireflyConfig::get('enable_exchange_rates', config('cer.enabled'))->data;
$useRunningBalance = FireflyConfig::get('use_running_balance', config('firefly.feature_flags.running_balance_column'))->data;
$enableExternalMap = FireflyConfig::get('enable_external_map', config('firefly.enable_external_map'))->data;
$enableExternalRates = FireflyConfig::get('enable_external_rates', config('cer.download_enabled'))->data;
$allowWebhooks = FireflyConfig::get('allow_webhooks', config('firefly.allow_webhooks'))->data;
$validUrlProtocols = FireflyConfig::get('valid_url_protocols', config('firefly.valid_url_protocols'))->data;
return view(
'settings.configuration.index',
['subTitle' => $subTitle, 'subTitleIcon' => $subTitleIcon, 'singleUserMode' => $singleUserMode, 'isDemoSite' => $isDemoSite, 'siteOwner' => $siteOwner]
[
'subTitle' => $subTitle,
'subTitleIcon' => $subTitleIcon,
'singleUserMode' => $singleUserMode,
'isDemoSite' => $isDemoSite,
'siteOwner' => $siteOwner,
'enableExchangeRates' => $enableExchangeRates,
'useRunningBalance' => $useRunningBalance,
'enableExternalMap' => $enableExternalMap,
'enableExternalRates' => $enableExternalRates,
'allowWebhooks' => $allowWebhooks,
'validUrlProtocols' => $validUrlProtocols,
]
);
}
@@ -92,10 +111,19 @@ class ConfigurationController extends Controller
// store config values
FireflyConfig::set('single_user_mode', $data['single_user_mode']);
FireflyConfig::set('enable_exchange_rates', $data['enable_exchange_rates']);
FireflyConfig::set('use_running_balance', $data['use_running_balance']);
FireflyConfig::set('enable_external_map', $data['enable_external_map']);
FireflyConfig::set('enable_external_rates', $data['enable_external_rates']);
FireflyConfig::set('allow_webhooks', $data['allow_webhooks']);
FireflyConfig::set('valid_url_protocols', $data['valid_url_protocols']);
FireflyConfig::set('is_demo_site', $data['is_demo_site']);
// flash message
session()->flash('success', (string) trans('firefly.configuration_updated'));
session()->flash('success', (string)trans('firefly.configuration_updated'));
Preferences::mark();
return redirect()->route('settings.configuration.index');

View File

@@ -42,6 +42,7 @@ use Illuminate\Routing\Redirector;
use Illuminate\View\View;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\NotFoundExceptionInterface;
use FireflyIII\Support\Facades\FireflyConfig;
/**
* Class UserController.
@@ -164,7 +165,7 @@ class UserController extends Controller
$subTitle = (string) trans('firefly.user_administration');
$subTitleIcon = 'fa-users';
$users = $this->repository->all();
$singleUserMode = (bool) app('fireflyconfig')->get('single_user_mode', config('firefly.configuration.single_user_mode'))->data;
$singleUserMode = (bool) FireflyConfig::get('single_user_mode', config('firefly.configuration.single_user_mode'))->data;
$allowInvites = false;
if (!$this->externalIdentity && $singleUserMode) {
// also registration enabled.

View File

@@ -36,6 +36,7 @@ use Illuminate\View\View;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\NotFoundExceptionInterface;
use Safe\Exceptions\UrlException;
use FireflyIII\Support\Facades\FireflyConfig;
use function Safe\parse_url;
@@ -142,7 +143,7 @@ class ForgotPasswordController extends Controller
}
// is allowed to?
$singleUserMode = app('fireflyconfig')->get('single_user_mode', config('firefly.configuration.single_user_mode'))->data;
$singleUserMode = FireflyConfig::get('single_user_mode', config('firefly.configuration.single_user_mode'))->data;
$userCount = User::count();
$allowRegistration = true;
$pageTitle = (string) trans('firefly.forgot_pw_page_title');

View File

@@ -50,6 +50,7 @@ use Illuminate\Validation\ValidationException;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\NotFoundExceptionInterface;
use Symfony\Component\HttpFoundation\Response as ResponseAlias;
use FireflyIII\Support\Facades\FireflyConfig;
/**
* Class LoginController
@@ -236,7 +237,7 @@ class LoginController extends Controller
}
// is allowed to register, etc.
$singleUserMode = app('fireflyconfig')->get('single_user_mode', config('firefly.configuration.single_user_mode'))->data;
$singleUserMode = FireflyConfig::get('single_user_mode', config('firefly.configuration.single_user_mode'))->data;
$allowRegistration = true;
$allowReset = true;
if (true === $singleUserMode && $count > 0) {

View File

@@ -41,6 +41,7 @@ use Illuminate\Validation\ValidationException;
use Illuminate\View\View;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\NotFoundExceptionInterface;
use FireflyIII\Support\Facades\FireflyConfig;
/**
* Class RegisterController
@@ -121,7 +122,7 @@ class RegisterController extends Controller
$allowRegistration = true;
try {
$singleUserMode = app('fireflyconfig')->get('single_user_mode', config('firefly.configuration.single_user_mode'))->data;
$singleUserMode = FireflyConfig::get('single_user_mode', config('firefly.configuration.single_user_mode'))->data;
} catch (ContainerExceptionInterface|NotFoundExceptionInterface) {
$singleUserMode = true;
}
@@ -148,7 +149,7 @@ class RegisterController extends Controller
*/
public function showInviteForm(Request $request, string $code): Factory|\Illuminate\Contracts\View\View
{
$isDemoSite = app('fireflyconfig')->get('is_demo_site', config('firefly.configuration.is_demo_site'))->data;
$isDemoSite = FireflyConfig::get('is_demo_site', config('firefly.configuration.is_demo_site'))->data;
$pageTitle = (string) trans('firefly.register_page_title');
$repository = app(UserRepositoryInterface::class);
$allowRegistration = $this->allowedToRegister();
@@ -182,7 +183,7 @@ class RegisterController extends Controller
*/
public function showRegistrationForm(?Request $request = null): Factory|\Illuminate\Contracts\View\View
{
$isDemoSite = app('fireflyconfig')->get('is_demo_site', config('firefly.configuration.is_demo_site'))->data;
$isDemoSite = FireflyConfig::get('is_demo_site', config('firefly.configuration.is_demo_site'))->data;
$pageTitle = (string) trans('firefly.register_page_title');
$allowRegistration = $this->allowedToRegister();

View File

@@ -36,6 +36,7 @@ use Illuminate\Validation\ValidationException;
use Illuminate\View\View;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\NotFoundExceptionInterface;
use FireflyIII\Support\Facades\FireflyConfig;
/**
* Class ResetPasswordController
@@ -131,7 +132,7 @@ class ResetPasswordController extends Controller
}
// is allowed to register?
$singleUserMode = app('fireflyconfig')->get('single_user_mode', config('firefly.configuration.single_user_mode'))->data;
$singleUserMode = FireflyConfig::get('single_user_mode', config('firefly.configuration.single_user_mode'))->data;
$userCount = User::count();
$allowRegistration = true;
$pageTitle = (string) trans('firefly.reset_pw_page_title');

View File

@@ -45,6 +45,7 @@ use Illuminate\Routing\Redirector;
use Illuminate\Support\Collection;
use Illuminate\View\View;
use FireflyIII\Support\Facades\Steam;
use FireflyIII\Support\Facades\Amount;
/**
* Class BudgetLimitController
@@ -205,14 +206,14 @@ class BudgetLimitController extends Controller
// add some extra metadata:
$spentArr = $this->opsRepository->sumExpenses($limit->start_date, $limit->end_date, null, new Collection()->push($budget), $currency);
$array['spent'] = $spentArr[$currency->id]['sum'] ?? '0';
$array['left_formatted'] = app('amount')->formatAnything($limit->transactionCurrency, bcadd($array['spent'], (string) $array['amount']));
$array['amount_formatted'] = app('amount')->formatAnything($limit->transactionCurrency, $limit['amount']);
$array['left_formatted'] = Amount::formatAnything($limit->transactionCurrency, bcadd($array['spent'], (string) $array['amount']));
$array['amount_formatted'] = Amount::formatAnything($limit->transactionCurrency, $limit['amount']);
$array['days_left'] = (string) $this->activeDaysLeft($start, $end);
// left per day:
$array['left_per_day'] = 0 === bccomp('0', $array['days_left']) ? bcadd((string) $array['spent'], (string) $array['amount']) : bcdiv(bcadd((string) $array['spent'], (string) $array['amount']), $array['days_left']);
// left per day formatted.
$array['left_per_day_formatted'] = app('amount')->formatAnything($limit->transactionCurrency, $array['left_per_day']);
$array['left_per_day_formatted'] = Amount::formatAnything($limit->transactionCurrency, $array['left_per_day']);
// notes:
$array['notes'] = $this->blRepository->getNoteText($limit);
@@ -239,8 +240,8 @@ class BudgetLimitController extends Controller
$this->blRepository->destroyBudgetLimit($budgetLimit);
$array = [
'budget_id' => $budgetId,
'left_formatted' => app('amount')->formatAnything($currency, '0'),
'left_per_day_formatted' => app('amount')->formatAnything($currency, '0'),
'left_formatted' => Amount::formatAnything($currency, '0'),
'left_per_day_formatted' => Amount::formatAnything($currency, '0'),
'transaction_currency_id' => $currency->id,
];
@@ -269,14 +270,14 @@ class BudgetLimitController extends Controller
);
$daysLeft = $this->activeDaysLeft($limit->start_date, $limit->end_date);
$array['spent'] = $spentArr[$budgetLimit->transactionCurrency->id]['sum'] ?? '0';
$array['left_formatted'] = app('amount')->formatAnything($limit->transactionCurrency, bcadd($array['spent'], (string) $array['amount']));
$array['amount_formatted'] = app('amount')->formatAnything($limit->transactionCurrency, $limit['amount']);
$array['left_formatted'] = Amount::formatAnything($limit->transactionCurrency, bcadd($array['spent'], (string) $array['amount']));
$array['amount_formatted'] = Amount::formatAnything($limit->transactionCurrency, $limit['amount']);
$array['days_left'] = (string) $daysLeft;
$array['left_per_day'] = 0 === $daysLeft ? bcadd((string) $array['spent'], (string) $array['amount']) : bcdiv(bcadd((string) $array['spent'], (string) $array['amount']), $array['days_left']);
// left per day formatted.
$array['amount'] = Steam::bcround($limit['amount'], $limit->transactionCurrency->decimal_places);
$array['left_per_day_formatted'] = app('amount')->formatAnything($limit->transactionCurrency, $array['left_per_day']);
$array['left_per_day_formatted'] = Amount::formatAnything($limit->transactionCurrency, $array['left_per_day']);
if ('true' === $request->get('redirect')) {
return redirect(route('budgets.index'));
}

View File

@@ -38,6 +38,7 @@ use Illuminate\Support\Facades\Config;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Route;
use Illuminate\Support\Facades\View;
use FireflyIII\Support\Facades\FireflyConfig;
use function Safe\ini_get;
use function Safe\realpath;
@@ -71,7 +72,7 @@ abstract class Controller extends BaseController
public function __construct()
{
// is site a demo site?
$isDemoSiteConfig = app('fireflyconfig')->get('is_demo_site', config('firefly.configuration.is_demo_site', false));
$isDemoSiteConfig = FireflyConfig::get('is_demo_site', config('firefly.configuration.is_demo_site', false));
$isDemoSite = (bool) $isDemoSiteConfig->data;
View::share('IS_DEMO_SITE', $isDemoSite);
View::share('DEMO_USERNAME', config('firefly.demo_username'));
@@ -80,7 +81,7 @@ abstract class Controller extends BaseController
View::share('FF_BUILD_TIME', config('firefly.build_time'));
// is webhooks enabled?
View::share('featuringWebhooks', true === config('firefly.feature_flags.webhooks') && true === config('firefly.allow_webhooks'));
View::share('featuringWebhooks', true === config('firefly.feature_flags.webhooks') && true === FireflyConfig::get('allow_webhooks', config('firefly.allow_webhooks'))->data);
// share custom auth guard info.
$authGuard = config('firefly.authentication_guard');

View File

@@ -51,6 +51,7 @@ use Illuminate\View\View;
use Monolog\Handler\RotatingFileHandler;
use Safe\Exceptions\FilesystemException;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use FireflyIII\Support\Facades\FireflyConfig;
use function Safe\file_get_contents;
use function Safe\ini_get;
@@ -241,7 +242,7 @@ class DebugController extends Controller
{
$userGuard = config('auth.defaults.guard');
$config = app('fireflyconfig')->get('last_rt_job', 0);
$config = FireflyConfig::get('last_rt_job', 0);
$lastTime = (int) $config->data;
$lastCronjob = 'never';
$lastCronjobAgo = 'never';

View File

@@ -28,6 +28,7 @@ use FireflyIII\Http\Controllers\Controller;
use FireflyIII\Models\TransactionCurrency;
use Illuminate\View\View;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use FireflyIII\Support\Facades\FireflyConfig;
class IndexController extends Controller
{
@@ -47,7 +48,7 @@ class IndexController extends Controller
return $next($request);
}
);
if (false === config('cer.enabled')) {
if (false === FireflyConfig::get('enable_exchange_rates', config('cer.enabled'))->data) {
throw new NotFoundHttpException();
}
}

View File

@@ -37,6 +37,7 @@ use Illuminate\Http\Request;
use Illuminate\Http\Response;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\NotFoundExceptionInterface;
use FireflyIII\Support\Facades\Amount;
/**
* Class JavascriptController.
@@ -106,7 +107,7 @@ class JavascriptController extends Controller
$currency = $repository->getAccountCurrency($account) ?? $this->primaryCurrency;
}
$locale = Steam::getLocale();
$accounting = app('amount')->getJsConfig();
$accounting = Amount::getJsConfig();
$accounting['frac_digits'] = $currency->decimal_places;
$pref = Preferences::get('language', config('firefly.default_language', 'en_US'));
$lang = $pref->data;

View File

@@ -121,15 +121,15 @@ class BoxController extends Controller
$keys = array_keys($sums);
foreach ($keys as $currencyId) {
$currency = $repository->find($currencyId);
$sums[$currencyId] = app('amount')->formatAnything($currency, $sums[$currencyId], false);
$incomes[$currencyId] = app('amount')->formatAnything($currency, $incomes[$currencyId] ?? '0', false);
$expenses[$currencyId] = app('amount')->formatAnything($currency, $expenses[$currencyId] ?? '0', false);
$sums[$currencyId] = Amount::formatAnything($currency, $sums[$currencyId], false);
$incomes[$currencyId] = Amount::formatAnything($currency, $incomes[$currencyId] ?? '0', false);
$expenses[$currencyId] = Amount::formatAnything($currency, $expenses[$currencyId] ?? '0', false);
}
if (0 === count($sums)) {
$currency = $this->primaryCurrency;
$sums[$this->primaryCurrency->id] = app('amount')->formatAnything($this->primaryCurrency, '0', false);
$incomes[$this->primaryCurrency->id] = app('amount')->formatAnything($this->primaryCurrency, '0', false);
$expenses[$this->primaryCurrency->id] = app('amount')->formatAnything($this->primaryCurrency, '0', false);
$sums[$this->primaryCurrency->id] = Amount::formatAnything($this->primaryCurrency, '0', false);
$incomes[$this->primaryCurrency->id] = Amount::formatAnything($this->primaryCurrency, '0', false);
$expenses[$this->primaryCurrency->id] = Amount::formatAnything($this->primaryCurrency, '0', false);
}
$response = [
@@ -187,7 +187,7 @@ class BoxController extends Controller
if ('primary' === $key) {
continue;
}
$return[$data['currency_id']] = app('amount')->formatFlat($data['currency_symbol'], $data['currency_decimal_places'], $data['balance'], false);
$return[$data['currency_id']] = Amount::formatFlat($data['currency_symbol'], $data['currency_decimal_places'], $data['balance'], false);
}
$return = [
'net_worths' => array_values($return),

View File

@@ -33,6 +33,7 @@ use FireflyIII\Repositories\Budget\BudgetLimitRepositoryInterface;
use FireflyIII\Repositories\Budget\BudgetRepositoryInterface;
use FireflyIII\Support\Http\Controllers\DateCalculation;
use Illuminate\Http\JsonResponse;
use FireflyIII\Support\Facades\Amount;
/**
* Class BudgetController
@@ -84,9 +85,9 @@ class BudgetController extends Controller
return response()->json(
[
'budgeted' => $budgeted,
'budgeted_formatted' => app('amount')->formatAnything($currency, $budgeted, true),
'budgeted_formatted' => Amount::formatAnything($currency, $budgeted, true),
'available' => $available,
'available_formatted' => app('amount')->formatAnything($currency, $available, true),
'available_formatted' => Amount::formatAnything($currency, $available, true),
'percentage' => $percentage,
'currency_id' => $currency->id,
'currency_code' => $currency->code,

View File

@@ -35,6 +35,7 @@ use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Log;
use Illuminate\View\View;
use FireflyIII\Support\Facades\Amount;
/**
* Class AmountController
@@ -167,7 +168,7 @@ class AmountController extends Controller
$piggyBank->refresh();
}
if (0 !== bccomp($total, '0')) {
session()->flash('success', (string) trans('firefly.added_amount_to_piggy', ['amount' => app('amount')->formatAnything($piggyBank->transactionCurrency, $total, false), 'name' => $piggyBank->name]));
session()->flash('success', (string) trans('firefly.added_amount_to_piggy', ['amount' => Amount::formatAnything($piggyBank->transactionCurrency, $total, false), 'name' => $piggyBank->name]));
Preferences::mark();
return redirect(route('piggy-banks.index'));
@@ -177,7 +178,7 @@ class AmountController extends Controller
'error',
(string) trans(
'firefly.cannot_add_amount_piggy',
['amount' => app('amount')->formatAnything($piggyBank->transactionCurrency, $total, false), 'name' => e($piggyBank->name)]
['amount' => Amount::formatAnything($piggyBank->transactionCurrency, $total, false), 'name' => e($piggyBank->name)]
)
);
@@ -214,7 +215,7 @@ class AmountController extends Controller
'success',
(string) trans(
'firefly.removed_amount_from_piggy',
['amount' => app('amount')->formatAnything($piggyBank->transactionCurrency, $total, false), 'name' => $piggyBank->name]
['amount' => Amount::formatAnything($piggyBank->transactionCurrency, $total, false), 'name' => $piggyBank->name]
)
);
Preferences::mark();
@@ -226,7 +227,7 @@ class AmountController extends Controller
'error',
(string) trans(
'firefly.cannot_remove_from_piggy',
['amount' => app('amount')->formatAnything($piggyBank->transactionCurrency, $total, false), 'name' => e($piggyBank->name)]
['amount' => Amount::formatAnything($piggyBank->transactionCurrency, $total, false), 'name' => e($piggyBank->name)]
)
);

View File

@@ -23,7 +23,6 @@ declare(strict_types=1);
namespace FireflyIII\Http\Controllers;
use FireflyIII\Support\Facades\Navigation;
use Carbon\Carbon;
use FireflyIII\Enums\AccountTypeEnum;
use FireflyIII\Events\Preferences\UserGroupChangedPrimaryCurrency;
@@ -33,7 +32,9 @@ use FireflyIII\Http\Requests\PreferencesRequest;
use FireflyIII\Models\Account;
use FireflyIII\Models\Preference;
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
use FireflyIII\Support\Facades\Navigation;
use FireflyIII\Support\Facades\Preferences;
use FireflyIII\Support\Facades\Steam;
use FireflyIII\Support\Singleton\PreferencesSingleton;
use FireflyIII\User;
use Illuminate\Contracts\View\Factory;
@@ -44,7 +45,6 @@ use Illuminate\Support\Facades\Log;
use Illuminate\View\View;
use JsonException;
use Safe\Exceptions\FilesystemException;
use FireflyIII\Support\Facades\Steam;
use function Safe\file_get_contents;
use function Safe\json_decode;
@@ -63,7 +63,7 @@ class PreferencesController extends Controller
$this->middleware(
static function ($request, $next) {
app('view')->share('title', (string) trans('firefly.preferences'));
app('view')->share('title', (string)trans('firefly.preferences'));
app('view')->share('mainTitleIcon', 'fa-gear');
return $next($request);
@@ -87,8 +87,8 @@ class PreferencesController extends Controller
/** @var Account $account */
foreach ($accounts as $account) {
$type = $account->accountType->type;
$role = sprintf('opt_group_%s', $repository->getMetaValue($account, 'account_role'));
$type = $account->accountType->type;
$role = sprintf('opt_group_%s', $repository->getMetaValue($account, 'account_role'));
if (in_array($type, [AccountTypeEnum::MORTGAGE->value, AccountTypeEnum::DEBT->value, AccountTypeEnum::LOAN->value], true)) {
$role = sprintf('opt_group_l_%s', $type);
@@ -97,7 +97,7 @@ class PreferencesController extends Controller
if ('opt_group_' === $role) {
$role = 'opt_group_defaultAsset';
}
$groupedAccounts[(string) trans(sprintf('firefly.%s', $role))][$account->id] = $account->name;
$groupedAccounts[(string)trans(sprintf('firefly.%s', $role))][$account->id] = $account->name;
}
ksort($groupedAccounts);
@@ -120,21 +120,22 @@ class PreferencesController extends Controller
if (is_array($fiscalYearStartStr)) {
$fiscalYearStartStr = '01-01';
}
$fiscalYearStart = sprintf('%s-%s', Carbon::now()->format('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');
// notifications settings
$slackUrl = Preferences::getEncrypted('slack_webhook_url', '')->data;
$pushoverAppToken = (string) Preferences::getEncrypted('pushover_app_token', '')->data;
$pushoverUserToken = (string) Preferences::getEncrypted('pushover_user_token', '')->data;
$pushoverAppToken = (string)Preferences::getEncrypted('pushover_app_token', '')->data;
$pushoverUserToken = (string)Preferences::getEncrypted('pushover_user_token', '')->data;
$ntfyServer = Preferences::getEncrypted('ntfy_server', 'https://ntfy.sh')->data;
$ntfyTopic = (string) Preferences::getEncrypted('ntfy_topic', '')->data;
$ntfyTopic = (string)Preferences::getEncrypted('ntfy_topic', '')->data;
$ntfyAuth = '1' === Preferences::get('ntfy_auth', false)->data;
$ntfyUser = Preferences::getEncrypted('ntfy_user', '')->data;
$ntfyPass = (string) Preferences::getEncrypted('ntfy_pass', '')->data;
$ntfyPass = (string)Preferences::getEncrypted('ntfy_pass', '')->data;
$channels = config('notifications.channels');
$forcedAvailability = [];
$anonymous = Steam::anonymous();
// notification preferences
$notifications = [];
@@ -164,7 +165,7 @@ class PreferencesController extends Controller
Log::error($e->getMessage());
$locales = [];
}
$locales = ['equal' => (string) trans('firefly.equal_to_language')] + $locales;
$locales = ['equal' => (string)trans('firefly.equal_to_language')] + $locales;
// an important fallback is that the frontPageAccount array gets refilled automatically
// when it turns up empty.
if (0 === count($frontpageAccounts)) {
@@ -184,7 +185,7 @@ class PreferencesController extends Controller
$ntfyPass = '';
}
return view('preferences.index', ['language' => $language, 'pushoverAppToken' => $pushoverAppToken, 'pushoverUserToken' => $pushoverUserToken, 'ntfyServer' => $ntfyServer, 'ntfyTopic' => $ntfyTopic, 'ntfyAuth' => $ntfyAuth, 'channels' => $channels, 'ntfyUser' => $ntfyUser, 'forcedAvailability' => $forcedAvailability, 'ntfyPass' => $ntfyPass, 'groupedAccounts' => $groupedAccounts, 'isDocker' => $isDocker, 'frontpageAccounts' => $frontpageAccounts, 'languages' => $languages, 'darkMode' => $darkMode, 'availableDarkModes' => $availableDarkModes, 'notifications' => $notifications, 'convertToPrimary' => $convertToPrimary, 'slackUrl' => $slackUrl, 'locales' => $locales, 'locale' => $locale, 'tjOptionalFields' => $tjOptionalFields, 'viewRange' => $viewRange, 'customFiscalYear' => $customFiscalYear, 'listPageSize' => $listPageSize, 'fiscalYearStart' => $fiscalYearStart]);
return view('preferences.index', ['anonymous' => $anonymous, 'language' => $language, 'pushoverAppToken' => $pushoverAppToken, 'pushoverUserToken' => $pushoverUserToken, 'ntfyServer' => $ntfyServer, 'ntfyTopic' => $ntfyTopic, 'ntfyAuth' => $ntfyAuth, 'channels' => $channels, 'ntfyUser' => $ntfyUser, 'forcedAvailability' => $forcedAvailability, 'ntfyPass' => $ntfyPass, 'groupedAccounts' => $groupedAccounts, 'isDocker' => $isDocker, 'frontpageAccounts' => $frontpageAccounts, 'languages' => $languages, 'darkMode' => $darkMode, 'availableDarkModes' => $availableDarkModes, 'notifications' => $notifications, 'convertToPrimary' => $convertToPrimary, 'slackUrl' => $slackUrl, 'locales' => $locales, 'locale' => $locale, 'tjOptionalFields' => $tjOptionalFields, 'viewRange' => $viewRange, 'customFiscalYear' => $customFiscalYear, 'listPageSize' => $listPageSize, 'fiscalYearStart' => $fiscalYearStart]);
}
/**
@@ -201,7 +202,7 @@ class PreferencesController extends Controller
$frontpageAccounts = [];
if (is_array($request->get('frontpageAccounts')) && count($request->get('frontpageAccounts')) > 0) {
foreach ($request->get('frontpageAccounts') as $id) {
$frontpageAccounts[] = (int) $id;
$frontpageAccounts[] = (int)$id;
}
Preferences::set('frontpageAccounts', $frontpageAccounts);
}
@@ -241,7 +242,7 @@ class PreferencesController extends Controller
}
// convert primary
$convertToPrimary = 1 === (int) $request->get('convertToPrimary');
$convertToPrimary = 1 === (int)$request->get('convertToPrimary');
if ($convertToPrimary && !$this->convertToPrimary) {
// set to true!
Log::debug('User sets convertToPrimary to true.');
@@ -253,9 +254,9 @@ class PreferencesController extends Controller
Preferences::set('convert_to_primary', $convertToPrimary);
// custom fiscal year
$customFiscalYear = 1 === (int) $request->get('customFiscalYear');
$customFiscalYear = 1 === (int)$request->get('customFiscalYear');
Preferences::set('customFiscalYear', $customFiscalYear);
$fiscalYearString = (string) $request->get('fiscalYearStart');
$fiscalYearString = (string)$request->get('fiscalYearStart');
if ('' !== $fiscalYearString) {
$fiscalYearStart = Carbon::parse($fiscalYearString, config('app.timezone'))->format('m-d');
Preferences::set('fiscalYearStart', $fiscalYearStart);
@@ -263,7 +264,7 @@ class PreferencesController extends Controller
// save page size:
Preferences::set('listPageSize', 50);
$listPageSize = (int) $request->get('listPageSize');
$listPageSize = (int)$request->get('listPageSize');
if ($listPageSize > 0 && $listPageSize < 1337) {
Preferences::set('listPageSize', $listPageSize);
}
@@ -282,7 +283,7 @@ class PreferencesController extends Controller
// same for locale:
if (!auth()->user()->hasRole('demo')) {
$locale = (string) $request->get('locale');
$locale = (string)$request->get('locale');
$locale = '' === $locale ? null : $locale;
Preferences::set('locale', $locale);
}
@@ -311,7 +312,12 @@ class PreferencesController extends Controller
Preferences::set('darkMode', $darkMode);
}
session()->flash('success', (string) trans('firefly.saved_preferences'));
// anonymous amounts?
$anonymous = '1' === $request->get('anonymous');
Preferences::set('anonymous', $anonymous);
// save and continue
session()->flash('success', (string)trans('firefly.saved_preferences'));
Preferences::mark();
return redirect(route('preferences.index'));
@@ -325,7 +331,7 @@ class PreferencesController extends Controller
switch ($channel) {
default:
session()->flash('error', (string) trans('firefly.notification_test_failed', ['channel' => $channel]));
session()->flash('error', (string)trans('firefly.notification_test_failed', ['channel' => $channel]));
break;
@@ -337,7 +343,7 @@ class PreferencesController extends Controller
$user = auth()->user();
Log::debug(sprintf('Now in testNotification("%s") controller.', $channel));
event(new UserTestNotificationChannel($channel, $user));
session()->flash('success', (string) trans('firefly.notification_test_executed', ['channel' => $channel]));
session()->flash('success', (string)trans('firefly.notification_test_executed', ['channel' => $channel]));
}
return '';

View File

@@ -38,6 +38,7 @@ use Illuminate\Http\Request;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\NotFoundExceptionInterface;
use Safe\Exceptions\UrlException;
use FireflyIII\Support\Facades\FireflyConfig;
use function Safe\parse_url;
@@ -140,7 +141,7 @@ class CreateController extends Controller
];
$optionalFields['external_url'] ??= false;
$optionalFields['location'] ??= false;
$optionalFields['location'] = $optionalFields['location'] && true === config('firefly.enable_external_map');
$optionalFields['location'] = $optionalFields['location'] && true === FireflyConfig::get('enable_external_map', config('firefly.enable_external_map'))->data;
// map info:
$longitude = config('firefly.default_location.longitude');

View File

@@ -38,6 +38,7 @@ use Illuminate\View\View;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\NotFoundExceptionInterface;
use Safe\Exceptions\UrlException;
use FireflyIII\Support\Facades\FireflyConfig;
use function Safe\parse_url;
@@ -114,7 +115,7 @@ class EditController extends Controller
];
$optionalFields['external_url'] ??= false;
$optionalFields['location'] ??= false;
$optionalFields['location'] = $optionalFields['location'] && true === config('firefly.enable_external_map');
$optionalFields['location'] = $optionalFields['location'] && true === FireflyConfig::get('enable_external_map', config('firefly.enable_external_map'))->data;
// map info voor v2:
$longitude = config('firefly.default_location.longitude');

View File

@@ -29,6 +29,7 @@ use Illuminate\Contracts\View\Factory;
use Illuminate\Support\Facades\Log;
use Illuminate\View\View;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use FireflyIII\Support\Facades\FireflyConfig;
/**
* Class CreateController
@@ -59,7 +60,7 @@ class CreateController extends Controller
*/
public function index(): Factory|\Illuminate\Contracts\View\View
{
if (false === config('firefly.allow_webhooks')) {
if (false === FireflyConfig::get('allow_webhooks', config('firefly.allow_webhooks'))->data) {
Log::channel('audit')->warning('User visits webhook create page, but webhooks are DISABLED.');
throw new NotFoundHttpException('Webhooks are not enabled.');

View File

@@ -31,6 +31,7 @@ use Illuminate\Contracts\View\Factory;
use Illuminate\Contracts\View\View;
use Illuminate\Support\Facades\Log;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use FireflyIII\Support\Facades\FireflyConfig;
/**
* Class DeleteController
@@ -64,7 +65,7 @@ class DeleteController extends Controller
*/
public function index(Webhook $webhook): Factory|View
{
if (false === config('firefly.allow_webhooks')) {
if (false === FireflyConfig::get('allow_webhooks', config('firefly.allow_webhooks'))->data) {
Log::channel('audit')->warning('User visits webhook delete page, but webhooks are DISABLED.');
throw new NotFoundHttpException('Webhooks are not enabled.');

View File

@@ -31,6 +31,7 @@ use Illuminate\Contracts\View\Factory;
use Illuminate\Contracts\View\View;
use Illuminate\Support\Facades\Log;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use FireflyIII\Support\Facades\FireflyConfig;
/**
* Class EditController
@@ -63,7 +64,7 @@ class EditController extends Controller
*/
public function index(Webhook $webhook): Factory|View
{
if (false === config('firefly.allow_webhooks')) {
if (false === FireflyConfig::get('allow_webhooks', config('firefly.allow_webhooks'))->data) {
Log::channel('audit')->warning('User visits webhook edit page, but webhooks are DISABLED.');
throw new NotFoundHttpException('Webhooks are not enabled.');

View File

@@ -29,6 +29,7 @@ use Illuminate\Contracts\View\Factory;
use Illuminate\Support\Facades\Log;
use Illuminate\View\View;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use FireflyIII\Support\Facades\FireflyConfig;
/**
* Class IndexController
@@ -55,7 +56,7 @@ class IndexController extends Controller
*/
public function index(): Factory|\Illuminate\Contracts\View\View
{
if (false === config('firefly.allow_webhooks')) {
if (false === FireflyConfig::get('allow_webhooks', config('firefly.allow_webhooks'))->data) {
Log::channel('audit')->warning('User visits webhook index page, but webhooks are DISABLED.');
throw new NotFoundHttpException('Webhooks are not enabled.');

View File

@@ -31,6 +31,7 @@ use Illuminate\Contracts\View\Factory;
use Illuminate\Contracts\View\View;
use Illuminate\Support\Facades\Log;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use FireflyIII\Support\Facades\FireflyConfig;
/**
* Class ShowController
@@ -63,7 +64,7 @@ class ShowController extends Controller
*/
public function index(Webhook $webhook): Factory|View
{
if (false === config('firefly.allow_webhooks')) {
if (false === FireflyConfig::get('allow_webhooks', config('firefly.allow_webhooks'))->data) {
Log::channel('audit')->warning(sprintf('User visits webhook #%d page, but webhooks are DISABLED.', $webhook->id));
throw new NotFoundHttpException('Webhooks are not enabled.');

View File

@@ -34,6 +34,7 @@ use FireflyIII\Support\Http\Controllers\RequestInformation;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\App;
use Illuminate\Support\Facades\Log;
use FireflyIII\Support\Facades\FireflyConfig;
/**
* Class SessionFilter.
@@ -144,11 +145,11 @@ class Range
// share security message:
if (
app('fireflyconfig')->has('upgrade_security_message')
&& app('fireflyconfig')->has('upgrade_security_level')
FireflyConfig::has('upgrade_security_message')
&& FireflyConfig::has('upgrade_security_level')
) {
app('view')->share('upgrade_security_message', app('fireflyconfig')->get('upgrade_security_message')->data);
app('view')->share('upgrade_security_level', app('fireflyconfig')->get('upgrade_security_level')->data);
app('view')->share('upgrade_security_message', FireflyConfig::get('upgrade_security_message')->data);
app('view')->share('upgrade_security_level', FireflyConfig::get('upgrade_security_level')->data);
}
}
}

View File

@@ -23,8 +23,8 @@ declare(strict_types=1);
namespace FireflyIII\Http\Requests;
use Illuminate\Contracts\Validation\Validator;
use FireflyIII\Support\Request\ChecksLogin;
use Illuminate\Contracts\Validation\Validator;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Support\Facades\Log;
@@ -41,8 +41,17 @@ class ConfigurationRequest extends FormRequest
public function getConfigurationData(): array
{
return [
'single_user_mode' => $this->boolean('single_user_mode'),
'is_demo_site' => $this->boolean('is_demo_site'),
'single_user_mode' => $this->boolean('single_user_mode'),
'enable_exchange_rates' => $this->boolean('enable_exchange_rates'),
'use_running_balance' => $this->boolean('use_running_balance'),
'enable_external_map' => $this->boolean('enable_external_map'),
'enable_external_rates' => $this->boolean('enable_external_rates'),
'allow_webhooks' => $this->boolean('allow_webhooks'),
'valid_url_protocols' => $this->string('valid_url_protocols'),
'is_demo_site' => $this->boolean('is_demo_site'),
];
}
@@ -53,8 +62,19 @@ class ConfigurationRequest extends FormRequest
{
// fixed
return [
'single_user_mode' => 'min:0|max:1|numeric',
'is_demo_site' => 'min:0|max:1|numeric',
'single_user_mode' => 'min:0|max:1|numeric',
'enable_exchange_rates' => 'min:0|max:1|numeric',
'use_running_balance' => 'min:0|max:1|numeric',
'enable_external_map' => 'min:0|max:1|numeric',
'enable_external_rates' => 'min:0|max:1|numeric',
'allow_webhooks' => 'min:0|max:1|numeric',
'valid_url_protocols' => 'min:0|max:255',
'is_demo_site' => 'min:0|max:1|numeric',
];
}

View File

@@ -31,6 +31,7 @@ use Illuminate\Database\Eloquent\Relations\BelongsToMany;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\SoftDeletes;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use FireflyIII\Support\Facades\Amount;
class TransactionCurrency extends Model
{
@@ -65,7 +66,7 @@ class TransactionCurrency extends Model
public function refreshForUser(User $user): void
{
$current = $user->userGroup->currencies()->where('transaction_currencies.id', $this->id)->first();
$native = app('amount')->getPrimaryCurrencyByUserGroup($user->userGroup);
$native = Amount::getPrimaryCurrencyByUserGroup($user->userGroup);
$this->userGroupNative = $native->id === $this->id;
$this->userGroupEnabled = null !== $current;
}

View File

@@ -28,6 +28,7 @@ use Illuminate\Notifications\Notification;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Str;
use NotificationChannels\Pushover\PushoverReceiver;
use FireflyIII\Support\Facades\FireflyConfig;
class OwnerNotifiable
{
@@ -58,8 +59,8 @@ class OwnerNotifiable
public function routeNotificationForPushover(): PushoverReceiver
{
Log::debug('Return settings for routeNotificationForPushover');
$pushoverAppToken = (string) app('fireflyconfig')->getEncrypted('pushover_app_token', '')->data;
$pushoverUserToken = (string) app('fireflyconfig')->getEncrypted('pushover_user_token', '')->data;
$pushoverAppToken = (string) FireflyConfig::getEncrypted('pushover_app_token', '')->data;
$pushoverUserToken = (string) FireflyConfig::getEncrypted('pushover_user_token', '')->data;
return PushoverReceiver::withUserKey($pushoverUserToken)
->withApplicationToken($pushoverAppToken)
@@ -68,7 +69,7 @@ class OwnerNotifiable
public function routeNotificationForSlack(): string
{
$res = app('fireflyconfig')->getEncrypted('slack_webhook_url', '')->data;
$res = FireflyConfig::getEncrypted('slack_webhook_url', '')->data;
if (is_array($res)) {
$res = '';
}

View File

@@ -29,6 +29,7 @@ use FireflyIII\Support\Notifications\UrlValidator;
use FireflyIII\User;
use Illuminate\Support\Facades\Log;
use NotificationChannels\Pushover\PushoverChannel;
use FireflyIII\Support\Facades\FireflyConfig;
// use Wijourdil\NtfyNotificationChannel\Channels\NtfyChannel;
@@ -54,7 +55,7 @@ class ReturnsAvailableChannels
$channels = ['mail'];
if (true === config('notifications.channels.slack.enabled', false)) {
$slackUrl = app('fireflyconfig')->getEncrypted('slack_webhook_url', '')->data;
$slackUrl = FireflyConfig::getEncrypted('slack_webhook_url', '')->data;
if (UrlValidator::isValidWebhookURL($slackUrl)) {
$channels[] = 'slack';
}
@@ -62,19 +63,19 @@ class ReturnsAvailableChannels
// if (true === config('notifications.channels.ntfy.enabled', false)) {
// // validate presence of of Ntfy settings.
// if ('' !== (string) app('fireflyconfig')->getEncrypted('ntfy_topic', '')->data) {
// if ('' !== (string) \FireflyIII\Support\Facades\FireflyConfig::getEncrypted('ntfy_topic', '')->data) {
// Log::debug('Enabled ntfy.');
// $channels[] = NtfyChannel::class;
// }
// if ('' === (string) app('fireflyconfig')->getEncrypted('ntfy_topic', '')->data) {
// if ('' === (string) \FireflyIII\Support\Facades\FireflyConfig::getEncrypted('ntfy_topic', '')->data) {
// Log::warning('No topic name for Ntfy, channel is disabled.');
// }
// }
// pushover
if (true === config('notifications.channels.pushover.enabled', false)) {
$pushoverAppToken = (string) app('fireflyconfig')->getEncrypted('pushover_app_token', '')->data;
$pushoverUserToken = (string) app('fireflyconfig')->getEncrypted('pushover_user_token', '')->data;
$pushoverAppToken = (string) FireflyConfig::getEncrypted('pushover_app_token', '')->data;
$pushoverUserToken = (string) FireflyConfig::getEncrypted('pushover_user_token', '')->data;
if ('' === $pushoverAppToken || '' === $pushoverUserToken) {
Log::warning('[b] No Pushover token, channel is disabled.');
}

View File

@@ -50,12 +50,14 @@ class SearchServiceProvider extends ServiceProvider
{
$this->app->bind(
static function (): QueryParserInterface {
$implementation = config('search.query_parser');
return match ($implementation) {
'new' => app(QueryParser::class),
default => app(GdbotsQueryParser::class),
};
return app(QueryParser::class);
// 2025-12-20 ignore this setting.
// $implementation = config('search.query_parser');
//
// return match ($implementation) {
// 'new' => app(QueryParser::class),
// default => app(GdbotsQueryParser::class),
// };
}
);

View File

@@ -353,7 +353,7 @@ class AccountRepository implements AccountRepositoryInterface, UserGroupInterfac
if (AccountTypeEnum::ASSET->value !== $account->accountType->type) {
throw new FireflyException(sprintf('%s is not an asset account.', $account->name));
}
$currency = $this->getAccountCurrency($account) ?? app('amount')->getPrimaryCurrency();
$currency = $this->getAccountCurrency($account) ?? Amount::getPrimaryCurrency();
$name = trans('firefly.reconciliation_account_name', ['name' => $account->name, 'currency' => $currency->code]);
/** @var AccountType $type */

View File

@@ -34,6 +34,7 @@ use FireflyIII\Support\Repositories\UserGroup\UserGroupInterface;
use FireflyIII\Support\Repositories\UserGroup\UserGroupTrait;
use Illuminate\Support\Collection;
use Illuminate\Support\Facades\Log;
use FireflyIII\Support\Facades\Amount;
/**
* Class AccountTasker.
@@ -59,7 +60,7 @@ class AccountTasker implements AccountTaskerInterface, UserGroupInterface
/** @var AccountRepositoryInterface $repository */
$repository = app(AccountRepositoryInterface::class);
$primaryCurrency = app('amount')->getPrimaryCurrencyByUserGroup($this->user->userGroup);
$primaryCurrency = Amount::getPrimaryCurrencyByUserGroup($this->user->userGroup);
$return = [
'accounts' => [],
@@ -146,7 +147,7 @@ class AccountTasker implements AccountTaskerInterface, UserGroupInterface
private function groupExpenseByDestination(array $array): array
{
$primaryCurrency = app('amount')->getPrimaryCurrencyByUserGroup($this->user->userGroup);
$primaryCurrency = Amount::getPrimaryCurrencyByUserGroup($this->user->userGroup);
/** @var CurrencyRepositoryInterface $currencyRepos */
$currencyRepos = app(CurrencyRepositoryInterface::class);
@@ -231,7 +232,7 @@ class AccountTasker implements AccountTaskerInterface, UserGroupInterface
private function groupIncomeBySource(array $array): array
{
$primaryCurrency = app('amount')->getPrimaryCurrencyByUserGroup($this->user->userGroup);
$primaryCurrency = Amount::getPrimaryCurrencyByUserGroup($this->user->userGroup);
/** @var CurrencyRepositoryInterface $currencyRepos */
$currencyRepos = app(CurrencyRepositoryInterface::class);

View File

@@ -27,8 +27,6 @@ use FireflyIII\Enums\UserRoleEnum;
use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Models\Attachment;
use FireflyIII\Models\UserGroup;
use FireflyIII\User;
use Illuminate\Contracts\Auth\Authenticatable;
use Illuminate\Support\Collection;
/**
@@ -38,7 +36,6 @@ use Illuminate\Support\Collection;
* @method getUserGroup()
* @method getUser()
* @method checkUserGroupAccess(UserRoleEnum $role)
* @method setUser(null|Authenticatable|User $user)
* @method setUserGroupById(int $userGroupId)
*/
interface AttachmentRepositoryInterface

View File

@@ -536,7 +536,7 @@ class BillRepository implements BillRepositoryInterface, UserGroupInterface
$bills = $this->getActiveBills();
$return = [];
$convertToPrimary = Amount::convertToPrimary($this->user);
$primary = app('amount')->getPrimaryCurrency();
$primary = Amount::getPrimaryCurrency();
/** @var Bill $bill */
foreach ($bills as $bill) {
@@ -602,7 +602,7 @@ class BillRepository implements BillRepositoryInterface, UserGroupInterface
$bills = $this->getActiveBills();
$return = [];
$convertToPrimary = Amount::convertToPrimary($this->user);
$primary = app('amount')->getPrimaryCurrency();
$primary = Amount::getPrimaryCurrency();
/** @var Bill $bill */
foreach ($bills as $bill) {

View File

@@ -51,6 +51,7 @@ use Illuminate\Support\Collection;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Storage;
use FireflyIII\Support\Facades\Amount;
/**
* Class BudgetRepository.
@@ -94,7 +95,7 @@ class BudgetRepository implements BudgetRepositoryInterface, UserGroupInterface
$limitRepository = app(BudgetLimitRepository::class);
$limitRepository->setUser($this->user);
$budgets = $this->getActiveBudgets();
$primaryCurrency = app('amount')->getPrimaryCurrency();
$primaryCurrency = Amount::getPrimaryCurrency();
$converter = new ExchangeRateConverter();
/** @var Budget $budget */
@@ -393,7 +394,7 @@ class BudgetRepository implements BudgetRepositoryInterface, UserGroupInterface
$autoBudget = $this->getAutoBudget($budget);
// grab default currency:
$currency = app('amount')->getPrimaryCurrencyByUserGroup($this->user->userGroup);
$currency = Amount::getPrimaryCurrencyByUserGroup($this->user->userGroup);
if (!$autoBudget instanceof AutoBudget) {
// at this point it's a blind assumption auto_budget_type is 1 or 2.
@@ -778,7 +779,7 @@ class BudgetRepository implements BudgetRepositoryInterface, UserGroupInterface
$currency = $repos->findByCode((string) $data['currency_code']);
}
if (null === $currency) {
$currency = app('amount')->getPrimaryCurrencyByUserGroup($this->user->userGroup);
$currency = Amount::getPrimaryCurrencyByUserGroup($this->user->userGroup);
}
$autoBudget = new AutoBudget();

View File

@@ -242,7 +242,7 @@ class CurrencyRepository implements CurrencyRepositoryInterface, UserGroupInterf
Log::debug('Grabbing default currency for this user...');
/** @var null|TransactionCurrency $result */
$result = app('amount')->getPrimaryCurrencyByUserGroup($this->user->userGroup);
$result = Amount::getPrimaryCurrencyByUserGroup($this->user->userGroup);
}
Log::debug(sprintf('Final result: %s', $result->code));
@@ -260,22 +260,28 @@ class CurrencyRepository implements CurrencyRepositoryInterface, UserGroupInterf
public function findCurrencyNull(?int $currencyId, ?string $currencyCode): ?TransactionCurrency
{
Log::debug(sprintf('Now in findCurrencyNull(%s, "%s")', var_export($currencyId, true), $currencyCode));
$result = $this->find((int)$currencyId);
if ($result instanceof TransactionCurrency) {
Log::debug(sprintf('Found currency by ID: %s', $result->code));
if (null !== $currencyId && 0 !== $currencyId) {
$result = $this->find((int)$currencyId);
if ($result instanceof TransactionCurrency) {
Log::debug(sprintf('Found currency by ID: %s', $result->code));
return $result;
}
}
if (null !== $currencyCode && '' !== $currencyCode) {
Log::debug(sprintf('Searching for currency with code "%s"...', $currencyCode));
$result = $this->findByCode($currencyCode);
if ($result instanceof TransactionCurrency && false === $result->enabled) {
Log::debug(sprintf('Also enabled currency %s', $result->code));
$this->enable($result);
}
return $result;
}
Log::debug(sprintf('Searching for currency with code "%s"...', $currencyCode));
$result = $this->findByCode((string)$currencyCode);
if ($result instanceof TransactionCurrency && false === $result->enabled) {
Log::debug(sprintf('Also enabled currency %s', $result->code));
$this->enable($result);
}
Log::debug('Found no currency, returning NULL.');
return $result;
return null;
}
#[Override]
@@ -438,7 +444,7 @@ class CurrencyRepository implements CurrencyRepositoryInterface, UserGroupInterf
public function makePrimary(TransactionCurrency $currency): void
{
$current = app('amount')->getPrimaryCurrencyByUserGroup($this->userGroup);
$current = Amount::getPrimaryCurrencyByUserGroup($this->userGroup);
Log::debug(sprintf('Enabled + made default currency %s for user #%d', $currency->code, $this->userGroup->id));
$this->userGroup->currencies()->detach($currency->id);
foreach ($this->userGroup->currencies()->get() as $item) {

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