mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-17 09:51:40 +00:00
Compare commits
253 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
389ffa820f | ||
|
28d6885178 | ||
|
00f579909e | ||
|
a35bccb940 | ||
|
1cba62aa42 | ||
|
0974591a8f | ||
|
326bef66ee | ||
|
67ba8cee09 | ||
|
08107f7103 | ||
|
f5c075936f | ||
|
d493820cc8 | ||
|
af4a006192 | ||
|
946e3fb540 | ||
|
b19338e2f3 | ||
|
d4a44e6089 | ||
|
c90c181785 | ||
|
b75178a184 | ||
|
a77187135f | ||
|
61e24a41a2 | ||
|
07c7bf1d49 | ||
|
d4cb72cb77 | ||
|
948cdf7e5e | ||
|
e93292d98c | ||
|
7105d34fb3 | ||
|
29847c9711 | ||
|
3db778a2b1 | ||
|
361f78542a | ||
|
15d0e04431 | ||
|
b968ef416a | ||
|
6191362fe0 | ||
|
6d8fd79922 | ||
|
0227879a69 | ||
|
e4d2b121c1 | ||
|
f8941ab507 | ||
|
f3ac8a5888 | ||
|
64ac3927ec | ||
|
a558613189 | ||
|
7535ca9a26 | ||
|
03670e2dfe | ||
|
be797f5353 | ||
|
da38df6e4b | ||
|
2d53eb300a | ||
|
523ea78166 | ||
|
3b33730e48 | ||
|
351272cc27 | ||
|
a293827739 | ||
|
ead2cf92d3 | ||
|
dea9e21382 | ||
|
69725eb8c3 | ||
|
d31bb1f9b6 | ||
|
b64979e45a | ||
|
3dd3d2cabb | ||
|
94e7c3527f | ||
|
1a71d22146 | ||
|
fdc3b80f1f | ||
|
b978de78e4 | ||
|
8b6bd296e1 | ||
|
4d075feed6 | ||
|
e0e16489a1 | ||
|
deeb4933fc | ||
|
be8a0ddb3e | ||
|
49b1a6d844 | ||
|
3c1361e377 | ||
|
a7ab5b7504 | ||
|
0c8229d689 | ||
|
aebf45697f | ||
|
d5d5530a8e | ||
|
8aa7776072 | ||
|
f427267f5b | ||
|
3195dd0db0 | ||
|
e67c62e6cd | ||
|
d319a21b01 | ||
|
f8963179c3 | ||
|
d3cd657501 | ||
|
6c6bb2cd1e | ||
|
1771b3964e | ||
|
351c0ee2d7 | ||
|
1c9c380c8c | ||
|
24455bf980 | ||
|
e21b40b46c | ||
|
29eabf9c8a | ||
|
60e20ceeb1 | ||
|
37b35661be | ||
|
b54bb20617 | ||
|
19ce6b71e2 | ||
|
b68663c977 | ||
|
ac385e2647 | ||
|
bc70174f44 | ||
|
b8668b44a0 | ||
|
86a87cc951 | ||
|
be58b1d2be | ||
|
61733f6553 | ||
|
15e772d9dc | ||
|
ae7b81bf86 | ||
|
2c9ac0982a | ||
|
2df390065b | ||
|
247c9aebf3 | ||
|
0783500eaa | ||
|
c2e542004d | ||
|
806ad918f0 | ||
|
84406a74c3 | ||
|
09990acaa2 | ||
|
a73247ec8c | ||
|
e98d43dd65 | ||
|
dbd68cedc9 | ||
|
e6e8200912 | ||
|
7b1380366b | ||
|
1eda806c17 | ||
|
782ecca6a9 | ||
|
e6338705a7 | ||
|
09226e6f12 | ||
|
5ff1991cdc | ||
|
4ebb6de520 | ||
|
1ba7d65582 | ||
|
4e6063a4f8 | ||
|
85476f3549 | ||
|
ef9714b7e0 | ||
|
8d20029557 | ||
|
0f04b44ca1 | ||
|
44ed45502e | ||
|
5bcafe1311 | ||
|
5a771ccc5f | ||
|
c6145b4a3b | ||
|
b20aeca849 | ||
|
793918f2f3 | ||
|
5d410e577e | ||
|
9ec786ec3a | ||
|
e532b4d4fc | ||
|
58585d03c6 | ||
|
a4f66b3d86 | ||
|
c847621874 | ||
|
86f14885eb | ||
|
173e196bc8 | ||
|
7505db871f | ||
|
946dde8957 | ||
|
9a52cfbfbe | ||
|
b248bd6d0c | ||
|
3fff9ad0a2 | ||
|
a695a1bba2 | ||
|
91e384aae8 | ||
|
1ac95b6fa7 | ||
|
6757b6211d | ||
|
4dfb78837e | ||
|
af50ad3db4 | ||
|
01cb94aabc | ||
|
5ffc5060b9 | ||
|
43d7c956a4 | ||
|
863b07951a | ||
|
2101717edb | ||
|
e7ac1476c5 | ||
|
5d24c1fee1 | ||
|
53eb863f9d | ||
|
3c3ba637b5 | ||
|
be8286b15c | ||
|
6f6087995d | ||
|
2ff8a35171 | ||
|
7f8ed7abb6 | ||
|
2ff0c37c12 | ||
|
c593936b32 | ||
|
c54204ede9 | ||
|
d9132bbee3 | ||
|
c1be98762e | ||
|
c2733e2a8f | ||
|
722cf9b4fe | ||
|
01e31e73e0 | ||
|
dba7d05296 | ||
|
a8709a4a45 | ||
|
49b1435cba | ||
|
6a25b41952 | ||
|
c561f99de6 | ||
|
9d9053d828 | ||
|
c3c9a2f3c0 | ||
|
28465142e9 | ||
|
5473a618c9 | ||
|
ac1a8d8053 | ||
|
15ae9203b6 | ||
|
9dfc2ae20b | ||
|
230de7cbdd | ||
|
feaa003a52 | ||
|
295d01dc16 | ||
|
cbf1fde45e | ||
|
6cc47287d3 | ||
|
4bbe728376 | ||
|
427a90ec85 | ||
|
55ddb26dac | ||
|
891777f079 | ||
|
1655286b67 | ||
|
dd81636bf2 | ||
|
56a43a707d | ||
|
c2f92c6e45 | ||
|
61bd2dc840 | ||
|
f6a675f2e2 | ||
|
85b43055a7 | ||
|
e63f7bcc70 | ||
|
384dd37430 | ||
|
c6b336171c | ||
|
d2f4399a1a | ||
|
02d1bc093c | ||
|
420e493987 | ||
|
0a15479bff | ||
|
a9b76a3679 | ||
|
d1a3cd9044 | ||
|
81735d59f8 | ||
|
1d8da7f9f0 | ||
|
c5f0684030 | ||
|
25867adcb9 | ||
|
d55694cd68 | ||
|
05f069d61e | ||
|
5f6e7ad138 | ||
|
61bc38921e | ||
|
94c660545d | ||
|
4d3907948d | ||
|
e6442dd8af | ||
|
7905e0bd70 | ||
|
f4b1da352d | ||
|
0d33348941 | ||
|
c7c875e95f | ||
|
19d24b3e2a | ||
|
8fed6b6657 | ||
|
b5eafa1910 | ||
|
c15501937f | ||
|
4c743bd5b0 | ||
|
44289cbd95 | ||
|
b2f1642cfe | ||
|
341ef0220c | ||
|
9df88115bc | ||
|
c7273edb5e | ||
|
c398aa2b69 | ||
|
aa786eaaf3 | ||
|
e58a5e12d6 | ||
|
12b3575c5c | ||
|
3ca186dc8f | ||
|
1535f596f6 | ||
|
2cc326caa1 | ||
|
43436ae942 | ||
|
fbfd8475de | ||
|
405752f353 | ||
|
2af98b259a | ||
|
015242a666 | ||
|
54933fda2e | ||
|
852d057a47 | ||
|
1778f0b4f3 | ||
|
6daf083b3f | ||
|
4a7d9b130a | ||
|
4163efba55 | ||
|
db5847b49b | ||
|
6829003f5e | ||
|
047927718e | ||
|
91deb22a3f | ||
|
1629ca0739 | ||
|
8b87204f10 | ||
|
f920d90e3d | ||
|
1cb91282af |
50
.env.example
50
.env.example
@@ -22,15 +22,15 @@ APP_KEY=SomeRandomStringOf32CharsExactly
|
||||
# If text is still in English, remember that not everything may have been translated.
|
||||
DEFAULT_LANGUAGE=en_US
|
||||
|
||||
# The locale defines how numbers are formatted.
|
||||
# by default this value is the same as whatever the language is.
|
||||
DEFAULT_LOCALE=equal
|
||||
|
||||
# Change this value to your preferred time zone.
|
||||
# Example: Europe/Amsterdam
|
||||
# For a list of supported time zones, see https://en.wikipedia.org/wiki/List_of_tz_database_time_zones
|
||||
TZ=Europe/Amsterdam
|
||||
|
||||
# This variable must match your installation's external address but keep in mind that
|
||||
# it's only used on the command line as a fallback value.
|
||||
APP_URL=http://localhost
|
||||
|
||||
# TRUSTED_PROXIES is a useful variable when using Docker and/or a reverse proxy.
|
||||
# Set it to ** and reverse proxies work just fine.
|
||||
TRUSTED_PROXIES=
|
||||
@@ -58,13 +58,24 @@ APP_LOG_LEVEL=notice
|
||||
# For other database types, please see the FAQ: https://docs.firefly-iii.org/support/faq
|
||||
# If you use Docker or similar, you can set these variables from a file by appending them with _FILE
|
||||
# Use "mysql" for MySQL and MariaDB. Use "sqlite" for SQLite.
|
||||
DB_CONNECTION=pgsql
|
||||
DB_CONNECTION=mysql
|
||||
DB_HOST=fireflyiiidb
|
||||
DB_PORT=5432
|
||||
DB_PORT=3306
|
||||
DB_DATABASE=firefly
|
||||
DB_USERNAME=firefly
|
||||
DB_PASSWORD=secret_firefly_password
|
||||
|
||||
# MySQL supports SSL. You can configure it here.
|
||||
# If you use Docker or similar, you can set these variables from a file by appending them with _FILE
|
||||
MYSQL_USE_SSL=false
|
||||
MYSQL_SSL_VERIFY_SERVER_CERT=true
|
||||
# You need to set at least of these options
|
||||
MYSQL_SSL_CAPATH=/etc/ssl/certs/
|
||||
MYSQL_SSL_CA=
|
||||
MYSQL_SSL_CERT=
|
||||
MYSQL_SSL_KEY=
|
||||
MYSQL_SSL_CIPHER=
|
||||
|
||||
# PostgreSQL supports SSL. You can configure it here.
|
||||
# If you use Docker or similar, you can set these variables from a file by appending them with _FILE
|
||||
PGSQL_SSL_MODE=prefer
|
||||
@@ -170,8 +181,16 @@ ADLDAP_PORT=389
|
||||
ADLDAP_TIMEOUT=5
|
||||
ADLDAP_BASEDN=""
|
||||
ADLDAP_FOLLOW_REFFERALS=false
|
||||
|
||||
# SSL/TLS settings
|
||||
ADLDAP_USE_SSL=false
|
||||
ADLDAP_USE_TLS=false
|
||||
ADLDAP_SSL_CACERTDIR=
|
||||
ADLDAP_SSL_CACERTFILE=
|
||||
ADLDAP_SSL_CERTFILE=
|
||||
ADLDAP_SSL_KEYFILE=
|
||||
ADLDAP_SSL_CIPHER_SUITE=
|
||||
ADLDAP_SSL_REQUIRE_CERT=
|
||||
|
||||
# You can set the following variables from a file by appending them with _FILE:
|
||||
ADLDAP_ADMIN_USERNAME=
|
||||
@@ -191,6 +210,7 @@ ADLDAP_AUTH_FIELD=distinguishedname
|
||||
|
||||
# Will allow SSO if your server provides an AUTH_USER field.
|
||||
# You can set the following variables from a file by appending them with _FILE:
|
||||
WINDOWS_SSO_ENABLED=false
|
||||
WINDOWS_SSO_DISCOVER=samaccountname
|
||||
WINDOWS_SSO_KEY=AUTH_USER
|
||||
|
||||
@@ -218,8 +238,9 @@ TRACKER_SITE_ID=
|
||||
TRACKER_URL=
|
||||
|
||||
#
|
||||
# Firefly III could (in the future) collect telemetry on how you use Firefly III.
|
||||
# In order to allow this, change the following variable to true:
|
||||
# Firefly III can collect telemetry on how you use Firefly III. This is opt-in.
|
||||
# In order to allow this, change the following variable to true.
|
||||
# To read more about this feature, go to this page: https://docs.firefly-iii.org/support/telemetry
|
||||
SEND_TELEMETRY=false
|
||||
|
||||
# You can fine tune the start-up of a Docker container by editing these environment variables.
|
||||
@@ -267,6 +288,17 @@ DEMO_USERNAME=
|
||||
DEMO_PASSWORD=
|
||||
USE_ENCRYPTION=false
|
||||
IS_SANDSTORM=false
|
||||
IS_DOCKER=false
|
||||
IS_HEROKU=false
|
||||
BUNQ_USE_SANDBOX=false
|
||||
|
||||
#
|
||||
# If you have trouble configuring your Firefly III installation, DON'T BOTHER setting this variable.
|
||||
# It won't work. It doesn't do ANYTHING. Don't believe the lies you read online. I'm not joking.
|
||||
# This configuration value WILL NOT HELP.
|
||||
#
|
||||
# This variable is ONLY used in some of the emails Firefly III sends around. Nowhere else.
|
||||
# So when configuring anything WEB related this variable doesn't do anything. Nothing
|
||||
#
|
||||
# If you're stuck I understand you get desperate but look SOMEWHERE ELSE.
|
||||
#
|
||||
APP_URL=http://localhost
|
||||
|
12
.github/ISSUE_TEMPLATE/Bug_report.md
vendored
12
.github/ISSUE_TEMPLATE/Bug_report.md
vendored
@@ -16,10 +16,10 @@ I am running Firefly III version x.x.x, and my problem is:
|
||||
<!-- Please add extra info here, such as OS, browser, and the output from the /debug page of your Firefly III installation (click the version at the bottom). -->
|
||||
|
||||
**Bonus points**
|
||||
<!-- Earn bonus points by checking the boxes -->
|
||||
<!-- Before you submit, verify the following please: -->
|
||||
|
||||
- [ ] Nobody reported this bug before
|
||||
- [ ] I have added a stack trace from my log files <!-- (see https://bit.ly/FF3-get-debug-info) -->
|
||||
- [ ] I have added a screenshot.
|
||||
- [ ] I was able to replicate it on the demo site https://demo.firefly-iii.org/
|
||||
<!-- - [ ] I donated money (this is a joke :wink:)-->
|
||||
- I searched and nobody reported this bug before
|
||||
- I have added a stack trace from my log files <!-- (see https://bit.ly/FF3-get-debug-info) -->
|
||||
- I have added a screenshot.
|
||||
- I was able to replicate it on the demo site https://demo.firefly-iii.org/
|
||||
<!-- - I donated money (this is a joke ;)-->
|
||||
|
10
.github/ISSUE_TEMPLATE/Custom.md
vendored
10
.github/ISSUE_TEMPLATE/Custom.md
vendored
@@ -16,8 +16,8 @@ I am running Firefly III version x.x.x.
|
||||
|
||||
<!-- Complete the following checklist for bonus points -->
|
||||
|
||||
- [ ] I have read the FAQ at https://bit.ly/FF3-FAQ
|
||||
- [ ] I added a screenshot
|
||||
- [ ] I added log files <!-- (see https://bit.ly/FF3-get-debug-info) -->
|
||||
- [ ] I was able to replicate the issue on the demo site.
|
||||
<!-- - [ ] I donated money (this is a joke :wink:)-->
|
||||
- I have read the FAQ at https://bit.ly/FF3-FAQ
|
||||
- I added a screenshot
|
||||
- I added log files <!-- (see https://bit.ly/FF3-get-debug-info) -->
|
||||
- I was able to replicate the issue on the demo site.
|
||||
<!-- - I donated money (this is a joke :wink:)-->
|
||||
|
2
.github/lock.yml
vendored
2
.github/lock.yml
vendored
@@ -32,4 +32,4 @@ setLockReason: true
|
||||
# daysUntilLock: 30
|
||||
|
||||
# Repository to extend settings from
|
||||
# _extends: repo
|
||||
# _extends: repo
|
||||
|
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1,4 +1,5 @@
|
||||
/node_modules
|
||||
/frontend/node_modules
|
||||
/public/hot
|
||||
/public/storage
|
||||
/storage/*.key
|
||||
|
@@ -23,10 +23,12 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Api\V1\Controllers;
|
||||
|
||||
use FireflyIII\Api\V1\Middleware\ApiDemoUser;
|
||||
use FireflyIII\Api\V1\Requests\AttachmentStoreRequest;
|
||||
use FireflyIII\Api\V1\Requests\AttachmentUpdateRequest;
|
||||
use FireflyIII\Exceptions\FireflyException;
|
||||
use FireflyIII\Helpers\Attachments\AttachmentHelperInterface;
|
||||
use FireflyIII\Http\Middleware\IsDemoUser;
|
||||
use FireflyIII\Models\Attachment;
|
||||
use FireflyIII\Repositories\Attachment\AttachmentRepositoryInterface;
|
||||
use FireflyIII\Transformers\AttachmentTransformer;
|
||||
@@ -58,6 +60,7 @@ class AttachmentController extends Controller
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->middleware(ApiDemoUser::class)->except(['delete', 'download', 'show', 'index']);
|
||||
$this->middleware(
|
||||
function ($request, $next) {
|
||||
/** @var User $user */
|
||||
@@ -65,6 +68,7 @@ class AttachmentController extends Controller
|
||||
$this->repository = app(AttachmentRepositoryInterface::class);
|
||||
$this->repository->setUser($user);
|
||||
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
);
|
||||
|
@@ -269,6 +269,7 @@ class TransactionController extends Controller
|
||||
*
|
||||
* @param TransactionStoreRequest $request
|
||||
*
|
||||
* @throws FireflyException
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function store(TransactionStoreRequest $request): JsonResponse
|
||||
@@ -283,7 +284,7 @@ class TransactionController extends Controller
|
||||
try {
|
||||
$transactionGroup = $this->groupRepository->store($data);
|
||||
} catch (DuplicateTransactionException $e) {
|
||||
Log::warning('Caught a duplicate. Return error message.');
|
||||
Log::warning('Caught a duplicate transaction. Return error message.');
|
||||
// return bad validation message.
|
||||
// TODO use Laravel's internal validation thing to do this.
|
||||
$response = [
|
||||
@@ -326,7 +327,7 @@ class TransactionController extends Controller
|
||||
|
||||
$selectedGroup = $collector->getGroups()->first();
|
||||
if (null === $selectedGroup) {
|
||||
throw new NotFoundHttpException(); // @codeCoverageIgnore
|
||||
throw new FireflyException('Cannot find transaction. Possibly, a rule deleted this transaction after its creation.');
|
||||
}
|
||||
/** @var TransactionGroupTransformer $transformer */
|
||||
$transformer = app(TransactionGroupTransformer::class);
|
||||
|
61
app/Api/V1/Middleware/ApiDemoUser.php
Normal file
61
app/Api/V1/Middleware/ApiDemoUser.php
Normal file
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
/**
|
||||
* ApiDemoUser.php
|
||||
* Copyright (c) 2019 james@firefly-iii.org
|
||||
*
|
||||
* This file is part of Firefly III (https://github.com/firefly-iii).
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Api\V1\Middleware;
|
||||
|
||||
use Closure;
|
||||
use FireflyIII\Repositories\User\UserRepositoryInterface;
|
||||
use FireflyIII\User;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
/**
|
||||
* Class ApiDemoUser.
|
||||
*/
|
||||
class ApiDemoUser
|
||||
{
|
||||
/**
|
||||
* Handle an incoming request.
|
||||
*
|
||||
* @param Request $request
|
||||
* @param Closure $next
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle(Request $request, Closure $next)
|
||||
{
|
||||
/** @var User $user */
|
||||
$user = $request->user();
|
||||
|
||||
if (null === $user) {
|
||||
return $next($request);
|
||||
}
|
||||
|
||||
/** @var UserRepositoryInterface $repository */
|
||||
$repository = app(UserRepositoryInterface::class);
|
||||
|
||||
if ($repository->hasRole($user, 'demo')) {
|
||||
return response('', 403);
|
||||
}
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
}
|
@@ -83,8 +83,6 @@ class CorrectDatabase extends Command
|
||||
echo $result;
|
||||
}
|
||||
|
||||
// app('telemetry')->feature('executed-command', $this->signature);
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
@@ -77,8 +77,6 @@ class CorrectOpeningBalanceCurrencies extends Command
|
||||
$this->info('There was nothing to fix in the opening balance transactions.');
|
||||
}
|
||||
|
||||
// app('telemetry')->feature('executed-command', $this->signature);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@@ -78,8 +78,6 @@ class CreateAccessTokens extends Command
|
||||
$end = round(microtime(true) - $start, 2);
|
||||
$this->info(sprintf('Verify access tokens in %s seconds.', $end));
|
||||
|
||||
// app('telemetry')->feature('executed-command', $this->signature);
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
@@ -79,8 +79,6 @@ class CreateLinkTypes extends Command
|
||||
$end = round(microtime(true) - $start, 2);
|
||||
$this->info(sprintf('Verified link types in %s seconds', $end));
|
||||
|
||||
// app('telemetry')->feature('executed-command', $this->signature);
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
@@ -76,8 +76,6 @@ class DeleteEmptyGroups extends Command
|
||||
$end = round(microtime(true) - $start, 2);
|
||||
$this->info(sprintf('Verified empty groups in %s seconds', $end));
|
||||
|
||||
// app('telemetry')->feature('executed-command', $this->signature);
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
@@ -58,8 +58,6 @@ class DeleteEmptyJournals extends Command
|
||||
$this->deleteUnevenJournals();
|
||||
$this->deleteEmptyJournals();
|
||||
|
||||
// app('telemetry')->feature('executed-command', $this->signature);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@@ -62,7 +62,6 @@ class DeleteOrphanedTransactions extends Command
|
||||
$end = round(microtime(true) - $start, 2);
|
||||
$this->info(sprintf('Verified orphans in %s seconds', $end));
|
||||
|
||||
// app('telemetry')->feature('executed-command', $this->signature);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@@ -78,8 +78,6 @@ class DeleteZeroAmount extends Command
|
||||
$end = round(microtime(true) - $start, 2);
|
||||
$this->info(sprintf('Verified zero-amount integrity in %s seconds', $end));
|
||||
|
||||
// app('telemetry')->feature('executed-command', $this->signature);
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
@@ -101,8 +101,6 @@ class EnableCurrencies extends Command
|
||||
$end = round(microtime(true) - $start, 2);
|
||||
$this->info(sprintf('Verified currencies in %s seconds.', $end));
|
||||
|
||||
// app('telemetry')->feature('executed-command', $this->signature);
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
@@ -106,7 +106,6 @@ class FixAccountTypes extends Command
|
||||
$end = round(microtime(true) - $start, 2);
|
||||
$this->info(sprintf('Verifying account types took %s seconds', $end));
|
||||
|
||||
// app('telemetry')->feature('executed-command', $this->signature);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@@ -75,7 +75,6 @@ class FixLongDescriptions extends Command
|
||||
$end = round(microtime(true) - $start, 2);
|
||||
$this->info(sprintf('Verified all transaction group and journal title lengths in %s seconds.', $end));
|
||||
|
||||
// app('telemetry')->feature('executed-command', $this->signature);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
@@ -98,7 +98,6 @@ class FixPiggies extends Command
|
||||
$end = round(microtime(true) - $start, 2);
|
||||
$this->line(sprintf('Verified the content of %d piggy bank events in %s seconds.', $set->count(), $end));
|
||||
|
||||
// app('telemetry')->feature('executed-command', $this->signature);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
@@ -67,7 +67,6 @@ class FixRecurringTransactions extends Command
|
||||
$end = round(microtime(true) - $start, 2);
|
||||
$this->info(sprintf('Corrected recurring transactions %s seconds.', $end));
|
||||
|
||||
// app('telemetry')->feature('executed-command', $this->signature);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@@ -75,7 +75,6 @@ class FixUnevenAmount extends Command
|
||||
$end = round(microtime(true) - $start, 2);
|
||||
$this->info(sprintf('Verified amount integrity in %s seconds', $end));
|
||||
|
||||
// app('telemetry')->feature('executed-command', $this->signature);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@@ -71,7 +71,6 @@ class RemoveBills extends Command
|
||||
$end = round(microtime(true) - $start, 2);
|
||||
$this->info(sprintf('Verified bills / journals in %s seconds', $end));
|
||||
|
||||
// app('telemetry')->feature('executed-command', $this->signature);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
@@ -83,7 +83,6 @@ class RenameMetaFields extends Command
|
||||
$end = round(microtime(true) - $start, 2);
|
||||
$this->info(sprintf('Renamed meta fields in %s seconds', $end));
|
||||
|
||||
// app('telemetry')->feature('executed-command', $this->signature);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@@ -74,7 +74,6 @@ class TransferBudgets extends Command
|
||||
$end = round(microtime(true) - $start, 2);
|
||||
$this->info(sprintf('Verified budget/journals in %s seconds.', $end));
|
||||
|
||||
// app('telemetry')->feature('executed-command', $this->signature);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
@@ -123,7 +123,6 @@ class DecryptDatabase extends Command
|
||||
}
|
||||
$this->info('Done!');
|
||||
|
||||
// app('telemetry')->feature('executed-command', $this->signature);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@@ -137,11 +137,11 @@ class ExportData extends Command
|
||||
} catch (FireflyException $e) {
|
||||
$this->error(sprintf('Could not store data: %s', $e->getMessage()));
|
||||
|
||||
// app('telemetry')->feature('executed-command-with-error', $this->signature);
|
||||
app('telemetry')->feature('system.command.errored', $this->signature);
|
||||
return 1;
|
||||
}
|
||||
|
||||
// app('telemetry')->feature('executed-command', $this->signature);
|
||||
app('telemetry')->feature('system.command.executed', $this->signature);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@@ -63,279 +63,14 @@ class CreateCSVImport extends Command
|
||||
{configuration? : The configuration file to use for the import.}
|
||||
{--user=1 : The user ID that the import should import for.}
|
||||
{--token= : The user\'s access token.}';
|
||||
/** @var ImportJob */
|
||||
private $importJob;
|
||||
/** @var ImportJobRepositoryInterface */
|
||||
private $importRepository;
|
||||
/** @var UserRepositoryInterface */
|
||||
private $userRepository;
|
||||
|
||||
/**
|
||||
* Run the command.
|
||||
*/
|
||||
public function handle(): int
|
||||
{
|
||||
$this->stupidLaravel();
|
||||
// @codeCoverageIgnoreStart
|
||||
if (!$this->verifyAccessToken()) {
|
||||
$this->errorLine('Invalid access token.');
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (!$this->validArguments()) {
|
||||
$this->errorLine('Invalid arguments.');
|
||||
|
||||
return 1;
|
||||
}
|
||||
// @codeCoverageIgnoreEnd
|
||||
/** @var User $user */
|
||||
$user = $this->userRepository->findNull((int) $this->option('user'));
|
||||
$file = (string) $this->argument('file');
|
||||
$configuration = (string) $this->argument('configuration');
|
||||
|
||||
$this->importRepository->setUser($user);
|
||||
|
||||
$configurationData = json_decode(file_get_contents($configuration), true, 512, JSON_THROW_ON_ERROR);
|
||||
$this->importJob = $this->importRepository->create('file');
|
||||
|
||||
|
||||
// inform user (and log it)
|
||||
$this->infoLine(sprintf('Import file : %s', $file));
|
||||
$this->infoLine(sprintf('Configuration file : %s', $configuration));
|
||||
$this->infoLine(sprintf('User : #%d (%s)', $user->id, $user->email));
|
||||
$this->infoLine(sprintf('Job : %s', $this->importJob->key));
|
||||
|
||||
try {
|
||||
$this->storeFile($file);
|
||||
} catch (FireflyException $e) {
|
||||
$this->errorLine($e->getMessage());
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
// job is ready to go
|
||||
$this->importRepository->setConfiguration($this->importJob, $configurationData);
|
||||
$this->importRepository->setStatus($this->importJob, 'ready_to_run');
|
||||
|
||||
$this->infoLine('The import routine has started. The process is not visible. Please wait.');
|
||||
Log::debug('Go for import!');
|
||||
|
||||
|
||||
// keep repeating this call until job lands on "provider_finished"
|
||||
try {
|
||||
$this->processFile();
|
||||
} catch (FireflyException $e) {
|
||||
$this->errorLine($e->getMessage());
|
||||
|
||||
// app('telemetry')->feature('executed-command-with-error', $this->signature);
|
||||
return 1;
|
||||
}
|
||||
|
||||
// then store data:
|
||||
try {
|
||||
$this->storeData();
|
||||
} catch (FireflyException $e) {
|
||||
$this->errorLine($e->getMessage());
|
||||
|
||||
// app('telemetry')->feature('executed-command-with-error', $this->signature);
|
||||
return 1;
|
||||
}
|
||||
|
||||
// give feedback:
|
||||
$this->giveFeedback();
|
||||
|
||||
// clear cache for user:
|
||||
app('preferences')->setForUser($user, 'lastActivity', microtime());
|
||||
|
||||
// app('telemetry')->feature('executed-command', $this->signature);
|
||||
return 0;
|
||||
$this->error('This command is disabled.');
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $message
|
||||
* @param array|null $data
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
private function errorLine(string $message, array $data = null): void
|
||||
{
|
||||
Log::error($message, $data ?? []);
|
||||
$this->error($message);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private function giveFeedback(): void
|
||||
{
|
||||
$this->infoLine('Job has finished.');
|
||||
|
||||
|
||||
if (null !== $this->importJob->tag) {
|
||||
$this->infoLine(sprintf('%d transaction(s) have been imported.', $this->importJob->tag->transactionJournals->count()));
|
||||
$this->infoLine(sprintf('You can find your transactions under tag "%s"', $this->importJob->tag->tag));
|
||||
}
|
||||
|
||||
if (null === $this->importJob->tag) {
|
||||
$this->errorLine('No transactions have been imported :(.');
|
||||
}
|
||||
if (count($this->importJob->errors) > 0) {
|
||||
$this->infoLine(sprintf('%d error(s) occurred:', count($this->importJob->errors)));
|
||||
foreach ($this->importJob->errors as $err) {
|
||||
$this->errorLine('- ' . $err);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $message
|
||||
* @param array $data
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
private function infoLine(string $message, array $data = null): void
|
||||
{
|
||||
Log::info($message, $data ?? []);
|
||||
$this->line($message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Keep repeating import call until job lands on "provider_finished".
|
||||
*
|
||||
* @throws FireflyException
|
||||
*/
|
||||
private function processFile(): void
|
||||
{
|
||||
$className = config('import.routine.file');
|
||||
$valid = ['provider_finished'];
|
||||
$count = 0;
|
||||
|
||||
while (!in_array($this->importJob->status, $valid, true) && $count < 6) {
|
||||
Log::debug(sprintf('Now in loop #%d.', $count + 1));
|
||||
/** @var RoutineInterface $routine */
|
||||
$routine = app($className);
|
||||
$routine->setImportJob($this->importJob);
|
||||
try {
|
||||
$routine->run();
|
||||
} catch (FireflyException|Exception $e) {
|
||||
$message = 'The import routine crashed: ' . $e->getMessage();
|
||||
Log::error($message);
|
||||
Log::error($e->getTraceAsString());
|
||||
|
||||
// set job errored out:
|
||||
$this->importRepository->setStatus($this->importJob, 'error');
|
||||
throw new FireflyException($message);
|
||||
}
|
||||
$count++;
|
||||
}
|
||||
$this->importRepository->setStatus($this->importJob, 'provider_finished');
|
||||
$this->importJob->status = 'provider_finished';
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @throws FireflyException
|
||||
*/
|
||||
private function storeData(): void
|
||||
{
|
||||
if ('provider_finished' === $this->importJob->status) {
|
||||
$this->infoLine('Import has finished. Please wait for storage of data.');
|
||||
// set job to be storing data:
|
||||
$this->importRepository->setStatus($this->importJob, 'storing_data');
|
||||
|
||||
/** @var ImportArrayStorage $storage */
|
||||
$storage = app(ImportArrayStorage::class);
|
||||
$storage->setImportJob($this->importJob);
|
||||
|
||||
try {
|
||||
$storage->store();
|
||||
} catch (FireflyException|Exception $e) {
|
||||
$message = 'The import routine crashed: ' . $e->getMessage();
|
||||
Log::error($message);
|
||||
Log::error($e->getTraceAsString());
|
||||
|
||||
// set job errored out:
|
||||
$this->importRepository->setStatus($this->importJob, 'error');
|
||||
throw new FireflyException($message);
|
||||
|
||||
}
|
||||
// set storage to be finished:
|
||||
$this->importRepository->setStatus($this->importJob, 'storage_finished');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Store the supplied file as an attachment to this job.
|
||||
*
|
||||
* @param string $file
|
||||
*
|
||||
* @throws FireflyException
|
||||
*/
|
||||
private function storeFile(string $file): void
|
||||
{
|
||||
// store file as attachment.
|
||||
if ('' !== $file) {
|
||||
$messages = $this->importRepository->storeCLIUpload($this->importJob, 'import_file', $file);
|
||||
if ($messages->count() > 0) {
|
||||
throw new FireflyException($messages->first());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Laravel will execute ALL __construct() methods for ALL commands whenever a SINGLE command is
|
||||
* executed. This leads to noticeable slow-downs and class calls. To prevent this, this method should
|
||||
* be called from the handle method instead of using the constructor to initialize the command.
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
private function stupidLaravel(): void
|
||||
{
|
||||
$this->userRepository = app(UserRepositoryInterface::class);
|
||||
$this->importRepository = app(ImportJobRepositoryInterface::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Verify user inserts correct arguments.
|
||||
*
|
||||
* @noinspection MultipleReturnStatementsInspection
|
||||
* @return bool
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
private function validArguments(): bool
|
||||
{
|
||||
$file = (string) $this->argument('file');
|
||||
$configuration = (string) $this->argument('configuration');
|
||||
$cwd = getcwd();
|
||||
$enabled = (bool) config('import.enabled.file');
|
||||
|
||||
if (false === $enabled) {
|
||||
$this->errorLine('CSV Provider is not enabled.');
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!file_exists($file)) {
|
||||
$this->errorLine(sprintf('Firefly III cannot find file "%s" (working directory: "%s").', $file, $cwd));
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!file_exists($configuration)) {
|
||||
$this->errorLine(sprintf('Firefly III cannot find configuration file "%s" (working directory: "%s").', $configuration, $cwd));
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
$configurationData = json_decode(file_get_contents($configuration), true, 512, JSON_THROW_ON_ERROR);
|
||||
if (null === $configurationData) {
|
||||
$this->errorLine(sprintf('Firefly III cannot read the contents of configuration file "%s" (working directory: "%s").', $configuration, $cwd));
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@@ -64,7 +64,6 @@ class ReportEmptyObjects extends Command
|
||||
$end = round(microtime(true) - $start, 2);
|
||||
$this->info(sprintf('Report on empty objects finished in %s seconds', $end));
|
||||
|
||||
// app('telemetry')->feature('executed-command', $this->signature);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@@ -69,7 +69,6 @@ class ReportIntegrity extends Command
|
||||
echo $result;
|
||||
}
|
||||
|
||||
// app('telemetry')->feature('executed-command', $this->signature);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
@@ -54,7 +54,6 @@ class ReportSum extends Command
|
||||
{
|
||||
$this->reportSum();
|
||||
|
||||
// app('telemetry')->feature('executed-command', $this->signature);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@@ -24,6 +24,7 @@ namespace FireflyIII\Console\Commands\Integrity;
|
||||
|
||||
use FireflyIII\Support\System\OAuthKeys;
|
||||
use Illuminate\Console\Command;
|
||||
use Log;
|
||||
|
||||
/**
|
||||
* Class RestoreOAuthKeys
|
||||
@@ -52,7 +53,6 @@ class RestoreOAuthKeys extends Command
|
||||
{
|
||||
$this->restoreOAuthKeys();
|
||||
|
||||
// app('telemetry')->feature('executed-command', $this->signature);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -93,7 +93,9 @@ class RestoreOAuthKeys extends Command
|
||||
*/
|
||||
private function restoreOAuthKeys(): void
|
||||
{
|
||||
Log::debug('Going to restoreOAuthKeys()');
|
||||
if (!$this->keysInDatabase() && !$this->keysOnDrive()) {
|
||||
Log::debug('Keys are not in DB and keys are not on the drive.');
|
||||
$this->generateKeys();
|
||||
$this->storeKeysInDB();
|
||||
$this->line('Generated and stored new keys.');
|
||||
@@ -101,12 +103,14 @@ class RestoreOAuthKeys extends Command
|
||||
return;
|
||||
}
|
||||
if ($this->keysInDatabase() && !$this->keysOnDrive()) {
|
||||
Log::debug('Keys are in DB and keys are not on the drive. Restore.');
|
||||
$this->restoreKeysFromDB();
|
||||
$this->line('Restored OAuth keys from database.');
|
||||
|
||||
return;
|
||||
}
|
||||
if (!$this->keysInDatabase() && $this->keysOnDrive()) {
|
||||
Log::debug('Keys are not in DB and keys are on the drive. Save in DB.');
|
||||
$this->storeKeysInDB();
|
||||
$this->line('Stored OAuth keys in database.');
|
||||
|
||||
|
@@ -86,7 +86,7 @@ class ScanAttachments extends Command
|
||||
$this->line(sprintf('Fixed attachment #%d', $attachment->id));
|
||||
}
|
||||
|
||||
// app('telemetry')->feature('executed-command', $this->signature);
|
||||
app('telemetry')->feature('system.command.executed', $this->signature);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
@@ -59,7 +59,7 @@ class SetLatestVersion extends Command
|
||||
app('fireflyconfig')->set('ff3_version', config('firefly.version'));
|
||||
$this->line('Updated version.');
|
||||
|
||||
// app('telemetry')->feature('executed-command', $this->signature);
|
||||
app('telemetry')->feature('system.command.executed', $this->signature);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@@ -112,7 +112,7 @@ class ApplyRules extends Command
|
||||
|
||||
$result = $this->verifyInput();
|
||||
if (false === $result) {
|
||||
// app('telemetry')->feature('executed-command-with-error', $this->signature);
|
||||
app('telemetry')->feature('system.command.errored', $this->signature);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -131,7 +131,7 @@ class ApplyRules extends Command
|
||||
$this->warn(' --rule_groups=1,2,...');
|
||||
$this->warn(' --all_rules');
|
||||
|
||||
// app('telemetry')->feature('executed-command-with-error', $this->signature);
|
||||
app('telemetry')->feature('system.command.errored', $this->signature);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -167,7 +167,7 @@ class ApplyRules extends Command
|
||||
$this->line('');
|
||||
$this->line('Done!');
|
||||
|
||||
// app('telemetry')->feature('executed-command', $this->signature);
|
||||
app('telemetry')->feature('system.command.executed', $this->signature);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@@ -94,10 +94,10 @@ class Cron extends Command
|
||||
}
|
||||
|
||||
/*
|
||||
* Fire telemetry cron job (disabled):
|
||||
* Fire telemetry cron job
|
||||
*/
|
||||
try {
|
||||
//$this->telemetryCronJob($force, $date);
|
||||
$this->telemetryCronJob($force, $date);
|
||||
} catch (FireflyException $e) {
|
||||
Log::error($e->getMessage());
|
||||
Log::error($e->getTraceAsString());
|
||||
@@ -106,7 +106,7 @@ class Cron extends Command
|
||||
|
||||
$this->info('More feedback on the cron jobs can be found in the log files.');
|
||||
|
||||
// app('telemetry')->feature('executed-command', $this->signature);
|
||||
app('telemetry')->feature('system.command.executed', $this->signature);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@@ -87,7 +87,6 @@ class AccountCurrencies extends Command
|
||||
$this->info(sprintf('Verified and fixed account currencies in %s seconds.', $end));
|
||||
$this->markAsExecuted();
|
||||
|
||||
// app('telemetry')->feature('executed-command', $this->signature);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@@ -78,8 +78,6 @@ class BackToJournals extends Command
|
||||
$this->info(sprintf('Updated category and budget info for all transaction journals in %s seconds.', $end));
|
||||
$this->markAsExecuted();
|
||||
|
||||
// app('telemetry')->feature('executed-command', $this->signature);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@@ -92,8 +92,6 @@ class BudgetLimitCurrency extends Command
|
||||
|
||||
$this->markAsExecuted();
|
||||
|
||||
// app('telemetry')->feature('executed-command', $this->signature);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@@ -91,8 +91,6 @@ class CCLiabilities extends Command
|
||||
$this->info(sprintf('Verified credit card liabilities in %s seconds', $end));
|
||||
$this->markAsExecuted();
|
||||
|
||||
// app('telemetry')->feature('executed-command', $this->signature);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@@ -101,8 +101,6 @@ class MigrateAttachments extends Command
|
||||
$this->info(sprintf('Migrated attachment notes in %s seconds.', $end));
|
||||
$this->markAsExecuted();
|
||||
|
||||
// app('telemetry')->feature('executed-command', $this->signature);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@@ -100,8 +100,6 @@ class MigrateJournalNotes extends Command
|
||||
$this->info(sprintf('Migrated notes in %s seconds.', $end));
|
||||
$this->markAsExecuted();
|
||||
|
||||
// app('telemetry')->feature('executed-command', $this->signature);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@@ -72,8 +72,6 @@ class MigrateRecurrenceMeta extends Command
|
||||
$end = round(microtime(true) - $start, 2);
|
||||
$this->info(sprintf('Migrated recurrence meta data in %s seconds.', $end));
|
||||
|
||||
// app('telemetry')->feature('executed-command', $this->signature);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@@ -65,7 +65,6 @@ class MigrateTagLocations extends Command
|
||||
$end = round(microtime(true) - $start, 2);
|
||||
$this->info(sprintf('Migrated tag locations in %s seconds.', $end));
|
||||
|
||||
// app('telemetry')->feature('executed-command', $this->signature);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@@ -112,8 +112,6 @@ class MigrateToGroups extends Command
|
||||
|
||||
$this->markAsMigrated();
|
||||
|
||||
// app('telemetry')->feature('executed-command', $this->signature);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@@ -99,7 +99,6 @@ class MigrateToRules extends Command
|
||||
$this->info(sprintf('Verified and fixed bills in %s seconds.', $end));
|
||||
$this->markAsExecuted();
|
||||
|
||||
// app('telemetry')->feature('executed-command', $this->signature);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@@ -90,7 +90,6 @@ class OtherCurrenciesCorrections extends Command
|
||||
$end = round(microtime(true) - $start, 2);
|
||||
$this->info(sprintf('Verified and fixed transaction currencies in %s seconds.', $end));
|
||||
|
||||
// app('telemetry')->feature('executed-command', $this->signature);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@@ -91,7 +91,6 @@ class RenameAccountMeta extends Command
|
||||
$end = round(microtime(true) - $start, 2);
|
||||
$this->info(sprintf('Fixed account meta data in %s seconds.', $end));
|
||||
|
||||
// app('telemetry')->feature('executed-command', $this->signature);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@@ -101,7 +101,6 @@ class TransactionIdentifier extends Command
|
||||
$this->info(sprintf('Verified and fixed transaction identifiers in %s seconds.', $end));
|
||||
$this->markAsExecuted();
|
||||
|
||||
// app('telemetry')->feature('executed-command', $this->signature);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@@ -111,7 +111,6 @@ class TransferCurrenciesCorrections extends Command
|
||||
$end = round(microtime(true) - $start, 2);
|
||||
$this->info(sprintf('Verified and fixed currency information for transfers in %s seconds.', $end));
|
||||
|
||||
// app('telemetry')->feature('executed-command', $this->signature);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@@ -117,7 +117,6 @@ class UpgradeDatabase extends Command
|
||||
// index will set FF3 version.
|
||||
app('fireflyconfig')->set('ff3_version', (string) config('firefly.version'));
|
||||
|
||||
// app('telemetry')->feature('executed-command', $this->signature);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@@ -23,6 +23,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Console\Commands;
|
||||
|
||||
use FireflyIII\Support\System\GeneratesInstallationId;
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
/**
|
||||
@@ -32,6 +33,8 @@ use Illuminate\Console\Command;
|
||||
*/
|
||||
class UpgradeFireflyInstructions extends Command
|
||||
{
|
||||
use GeneratesInstallationId;
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
@@ -50,6 +53,7 @@ class UpgradeFireflyInstructions extends Command
|
||||
*/
|
||||
public function handle(): int
|
||||
{
|
||||
$this->generateInstallationId();
|
||||
if ('update' === (string) $this->argument('task')) {
|
||||
$this->updateInstructions();
|
||||
}
|
||||
@@ -57,7 +61,14 @@ class UpgradeFireflyInstructions extends Command
|
||||
$this->installInstructions();
|
||||
}
|
||||
|
||||
// app('telemetry')->feature('executed-command', $this->signature);
|
||||
// collect system telemetry
|
||||
$isDocker = true === env('IS_DOCKER', false) ? 'true' : 'false';
|
||||
app('telemetry')->feature('system.php.version', PHP_VERSION);
|
||||
app('telemetry')->feature('system.os.version', PHP_OS);
|
||||
app('telemetry')->feature('system.database.driver', env('DB_CONNECTION', '(unknown)'));
|
||||
app('telemetry')->feature('system.os.is_docker', $isDocker);
|
||||
app('telemetry')->feature('system.command.executed', $this->signature);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@@ -87,7 +87,7 @@ class Handler extends ExceptionHandler
|
||||
);
|
||||
}
|
||||
|
||||
return response()->json(['message' => 'Internal Firefly III Exception. See log files.', 'exception' => get_class($exception)], 500);
|
||||
return response()->json(['message' => sprintf('Internal Firefly III Exception: %s', $exception->getMessage()), 'exception' => get_class($exception)], 500);
|
||||
}
|
||||
|
||||
if ($exception instanceof NotFoundHttpException) {
|
||||
|
@@ -98,7 +98,7 @@ class AccountFactory
|
||||
'user_id' => $this->user->id,
|
||||
'account_type_id' => $type->id,
|
||||
'name' => $data['name'],
|
||||
'virtual_balance' => $data['virtual_balance'] ?? '0',
|
||||
'virtual_balance' => $data['virtual_balance'] ?? null,
|
||||
'active' => true === $data['active'],
|
||||
'iban' => $data['iban'],
|
||||
];
|
||||
@@ -109,12 +109,12 @@ class AccountFactory
|
||||
|
||||
// remove virtual balance when not an asset account or a liability
|
||||
if (!in_array($type->type, $this->canHaveVirtual, true)) {
|
||||
$databaseData['virtual_balance'] = '0';
|
||||
$databaseData['virtual_balance'] = null;
|
||||
}
|
||||
|
||||
// fix virtual balance when it's empty
|
||||
if ('' === $databaseData['virtual_balance']) {
|
||||
$databaseData['virtual_balance'] = '0';
|
||||
if ('' === (string)$databaseData['virtual_balance']) {
|
||||
$databaseData['virtual_balance'] = null;
|
||||
}
|
||||
|
||||
$return = Account::create($databaseData);
|
||||
|
@@ -280,25 +280,29 @@ class TransactionJournalFactory
|
||||
|
||||
/** create or get source and destination accounts */
|
||||
$sourceInfo = [
|
||||
'id' => (int) $row['source_id'],
|
||||
'name' => $row['source_name'],
|
||||
'iban' => $row['source_iban'],
|
||||
'number' => $row['source_number'],
|
||||
'bic' => $row['source_bic'],
|
||||
'id' => (int) $row['source_id'],
|
||||
'name' => $row['source_name'],
|
||||
'iban' => $row['source_iban'],
|
||||
'number' => $row['source_number'],
|
||||
'bic' => $row['source_bic'],
|
||||
'currency_id' => $currency->id,
|
||||
];
|
||||
|
||||
$destInfo = [
|
||||
'id' => (int) $row['destination_id'],
|
||||
'name' => $row['destination_name'],
|
||||
'iban' => $row['destination_iban'],
|
||||
'number' => $row['destination_number'],
|
||||
'bic' => $row['destination_bic'],
|
||||
'id' => (int) $row['destination_id'],
|
||||
'name' => $row['destination_name'],
|
||||
'iban' => $row['destination_iban'],
|
||||
'number' => $row['destination_number'],
|
||||
'bic' => $row['destination_bic'],
|
||||
'currency_id' => $currency->id,
|
||||
];
|
||||
Log::debug('Source info:', $sourceInfo);
|
||||
Log::debug('Destination info:', $destInfo);
|
||||
|
||||
$sourceAccount = $this->getAccount($type->type, 'source', $sourceInfo);
|
||||
Log::debug('Now calling getAccount for the source.');
|
||||
$sourceAccount = $this->getAccount($type->type, 'source', $sourceInfo);
|
||||
Log::debug('Now calling getAccount for the destination.');
|
||||
$destinationAccount = $this->getAccount($type->type, 'destination', $destInfo);
|
||||
Log::debug('Done with getAccount(2x)');
|
||||
$currency = $this->getCurrencyByAccount($type->type, $currency, $sourceAccount, $destinationAccount);
|
||||
$foreignCurrency = $this->compareCurrencies($currency, $foreignCurrency);
|
||||
$foreignCurrency = $this->getForeignByAccount($type->type, $foreignCurrency, $destinationAccount);
|
||||
@@ -424,7 +428,7 @@ class TransactionJournalFactory
|
||||
->first();
|
||||
}
|
||||
if (null !== $result) {
|
||||
Log::warning('Found a duplicate!');
|
||||
Log::warning(sprintf('Found a duplicate in errorIfDuplicate because hash %s is not unique!', $hash));
|
||||
throw new DuplicateTransactionException(sprintf('Duplicate of transaction #%d.', $result->transactionJournal->transaction_group_id));
|
||||
}
|
||||
}
|
||||
@@ -468,6 +472,7 @@ class TransactionJournalFactory
|
||||
*/
|
||||
private function getCurrency(?TransactionCurrency $currency, Account $account): TransactionCurrency
|
||||
{
|
||||
Log::debug('Now in getCurrency()');
|
||||
$preference = $this->accountRepository->getAccountCurrency($account);
|
||||
if (null === $preference && null === $currency) {
|
||||
// return user's default:
|
||||
@@ -489,6 +494,7 @@ class TransactionJournalFactory
|
||||
*/
|
||||
private function getCurrencyByAccount(string $type, ?TransactionCurrency $currency, Account $source, Account $destination): TransactionCurrency
|
||||
{
|
||||
Log::debug('Now ingetCurrencyByAccount()');
|
||||
switch ($type) {
|
||||
default:
|
||||
case TransactionType::WITHDRAWAL:
|
||||
@@ -538,15 +544,15 @@ class TransactionJournalFactory
|
||||
$dataRow = $row->getArrayCopy();
|
||||
|
||||
unset($dataRow['import_hash_v2'], $dataRow['original_source']);
|
||||
$json = json_encode($dataRow);
|
||||
$json = json_encode($dataRow, JSON_THROW_ON_ERROR, 512);
|
||||
if (false === $json) {
|
||||
// @codeCoverageIgnoreStart
|
||||
$json = json_encode((string) microtime());
|
||||
$json = json_encode((string) microtime(), JSON_THROW_ON_ERROR, 512);
|
||||
Log::error(sprintf('Could not hash the original row! %s', json_last_error_msg()), $dataRow);
|
||||
// @codeCoverageIgnoreEnd
|
||||
}
|
||||
$hash = hash('sha256', $json);
|
||||
Log::debug(sprintf('The hash is: %s', $hash));
|
||||
Log::debug(sprintf('The hash is: %s', $hash), $dataRow);
|
||||
|
||||
return $hash;
|
||||
}
|
||||
@@ -601,7 +607,7 @@ class TransactionJournalFactory
|
||||
|
||||
// validate source account.
|
||||
$sourceId = isset($data['source_id']) ? (int) $data['source_id'] : null;
|
||||
$sourceName = $data['source_name'] ?? null;
|
||||
$sourceName = isset($data['source_name']) ? (string) $data['source_name'] : null;
|
||||
$validSource = $this->accountValidator->validateSource($sourceId, $sourceName, null);
|
||||
|
||||
// do something with result:
|
||||
@@ -611,7 +617,7 @@ class TransactionJournalFactory
|
||||
Log::debug('Source seems valid.');
|
||||
// validate destination account
|
||||
$destinationId = isset($data['destination_id']) ? (int) $data['destination_id'] : null;
|
||||
$destinationName = (string)($data['destination_name'] ?? null);
|
||||
$destinationName = isset($data['destination_name']) ? (string) $data['destination_name'] : null;
|
||||
$validDestination = $this->accountValidator->validateDestination($destinationId, $destinationName, null);
|
||||
// do something with result:
|
||||
if (false === $validDestination) {
|
||||
|
@@ -154,14 +154,14 @@ class MonthReportGenerator implements ReportGeneratorInterface
|
||||
$journals[$index]['invoice_date'] = $journalRepository->getMetaDateById($journal['transaction_journal_id'], 'invoice_date');
|
||||
|
||||
}
|
||||
|
||||
$locale = app('steam')->getLocale();
|
||||
$return = [
|
||||
'journals' => $journals,
|
||||
'currency' => $currency,
|
||||
'exists' => count($journals) > 0,
|
||||
'end' => $this->end->formatLocalized((string) trans('config.month_and_day')),
|
||||
'end' => $this->end->formatLocalized((string) trans('config.month_and_day', [], $locale)),
|
||||
'endBalance' => app('steam')->balance($account, $this->end),
|
||||
'dayBefore' => $date->formatLocalized((string) trans('config.month_and_day')),
|
||||
'dayBefore' => $date->formatLocalized((string) trans('config.month_and_day', [], $locale)),
|
||||
'dayBeforeBalance' => $dayBeforeBalance,
|
||||
];
|
||||
|
||||
|
@@ -118,6 +118,7 @@ class UserEventHandler
|
||||
if ($repository->hasRole($user, 'demo')) {
|
||||
// set user back to English.
|
||||
app('preferences')->setForUser($user, 'language', 'en_US');
|
||||
app('preferences')->setForUser($user, 'locale', 'equal');
|
||||
app('preferences')->mark();
|
||||
}
|
||||
|
||||
@@ -165,7 +166,8 @@ class UserEventHandler
|
||||
$user = $event->user;
|
||||
$ipAddress = $event->ipAddress;
|
||||
$token = app('preferences')->getForUser($user, 'email_change_undo_token', 'invalid');
|
||||
$uri = route('profile.undo-email-change', [$token->data, hash('sha256', $oldEmail)]);
|
||||
$hashed = hash('sha256', sprintf('%s%s', (string) config('app.key'), $oldEmail));
|
||||
$uri = route('profile.undo-email-change', [$token->data,$hashed]);
|
||||
try {
|
||||
Mail::to($oldEmail)->send(new UndoEmailChangeMail($newEmail, $oldEmail, $uri, $ipAddress));
|
||||
// @codeCoverageIgnoreStart
|
||||
|
@@ -54,6 +54,7 @@ class VersionCheckEventHandler
|
||||
$value = (int) $permission->data;
|
||||
if (1 !== $value) {
|
||||
Log::info('Update check is not enabled.');
|
||||
$this->warnToCheckForUpdates($event);
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -85,4 +86,36 @@ class VersionCheckEventHandler
|
||||
session()->flash($release['level'], $release['message']);
|
||||
app('fireflyconfig')->set('last_update_check', time());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param RequestedVersionCheckStatus $event
|
||||
*/
|
||||
protected function warnToCheckForUpdates(RequestedVersionCheckStatus $event): void
|
||||
{
|
||||
/** @var UserRepositoryInterface $repository */
|
||||
$repository = app(UserRepositoryInterface::class);
|
||||
/** @var User $user */
|
||||
$user = $event->user;
|
||||
if (!$repository->hasRole($user, 'owner')) {
|
||||
Log::debug('User is not admin, done.');
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/** @var Configuration $lastCheckTime */
|
||||
$lastCheckTime = app('fireflyconfig')->get('last_update_warning', time());
|
||||
$now = time();
|
||||
$diff = $now - $lastCheckTime->data;
|
||||
Log::debug(sprintf('Last warning time is %d, current time is %d, difference is %d', $lastCheckTime->data, $now, $diff));
|
||||
if ($diff < 604800 * 4) {
|
||||
Log::debug(sprintf('Warned about updates less than four weeks ago (on %s).', date('Y-m-d H:i:s', $lastCheckTime->data)));
|
||||
|
||||
return;
|
||||
}
|
||||
// last check time was more than a week ago.
|
||||
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', time());
|
||||
}
|
||||
}
|
||||
|
@@ -230,4 +230,4 @@ trait AccountCollection
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -84,4 +84,4 @@ trait AmountCollection
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -56,4 +56,4 @@ trait CollectorProperties
|
||||
private $total;
|
||||
/** @var User The user object. */
|
||||
private $user;
|
||||
}
|
||||
}
|
||||
|
@@ -288,4 +288,4 @@ trait MetaCollection
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
@@ -91,8 +91,9 @@ trait TimeCollection
|
||||
if ($end < $start) {
|
||||
[$start, $end] = [$end, $start];
|
||||
}
|
||||
$startStr = $start->format('Y-m-d H:i:s');
|
||||
$endStr = $end->format('Y-m-d H:i:s');
|
||||
// always got to end of day / start of day for ranges.
|
||||
$startStr = $start->format('Y-m-d 00:00:00');
|
||||
$endStr = $end->format('Y-m-d 23:59:59');
|
||||
|
||||
$this->query->where('transaction_journals.date', '>=', $startStr);
|
||||
$this->query->where('transaction_journals.date', '<=', $endStr);
|
||||
@@ -117,4 +118,4 @@ trait TimeCollection
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -31,16 +31,11 @@ use FireflyIII\Helpers\Collector\Extensions\AmountCollection;
|
||||
use FireflyIII\Helpers\Collector\Extensions\CollectorProperties;
|
||||
use FireflyIII\Helpers\Collector\Extensions\MetaCollection;
|
||||
use FireflyIII\Helpers\Collector\Extensions\TimeCollection;
|
||||
use FireflyIII\Models\Bill;
|
||||
use FireflyIII\Models\Budget;
|
||||
use FireflyIII\Models\Category;
|
||||
use FireflyIII\Models\Tag;
|
||||
use FireflyIII\Models\TransactionCurrency;
|
||||
use FireflyIII\Models\TransactionGroup;
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
use FireflyIII\User;
|
||||
use Illuminate\Database\Eloquent\Builder as EloquentBuilder;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Database\Query\JoinClause;
|
||||
use Illuminate\Pagination\LengthAwarePaginator;
|
||||
use Illuminate\Support\Collection;
|
||||
@@ -526,7 +521,7 @@ class GroupCollector implements GroupCollectorInterface
|
||||
}
|
||||
// or parse the rest.
|
||||
$journalId = (int) $augumentedJournal->transaction_journal_id;
|
||||
$groups[$groupId]['count']++;
|
||||
|
||||
|
||||
if (isset($groups[$groupId]['transactions'][$journalId])) {
|
||||
// append data to existing group + journal (for multiple tags or multiple attachments)
|
||||
@@ -536,6 +531,7 @@ class GroupCollector implements GroupCollectorInterface
|
||||
|
||||
if (!isset($groups[$groupId]['transactions'][$journalId])) {
|
||||
// create second, third, fourth split:
|
||||
$groups[$groupId]['count']++;
|
||||
$groups[$groupId]['transactions'][$journalId] = $this->parseAugmentedJournal($augumentedJournal);
|
||||
}
|
||||
}
|
||||
|
@@ -109,15 +109,13 @@ class NetWorth implements NetWorthInterface
|
||||
|
||||
Log::debug(sprintf('Balance is %s', $balance));
|
||||
|
||||
// if the account is a credit card, subtract the virtual balance from the balance,
|
||||
// to better reflect that this is not money that is actually "yours".
|
||||
$role = (string) $this->accountRepository->getMetaValue($account, 'account_role');
|
||||
// always subtract virtual balance.
|
||||
$virtualBalance = (string) $account->virtual_balance;
|
||||
if ('ccAsset' === $role && '' !== $virtualBalance && (float) $virtualBalance > 0) {
|
||||
if ('' !== $virtualBalance) {
|
||||
$balance = bcsub($balance, $virtualBalance);
|
||||
}
|
||||
|
||||
Log::debug(sprintf('Balance corrected to %s', $balance));
|
||||
Log::debug(sprintf('Balance corrected to %s because of virtual balance (%s)', $balance, $virtualBalance));
|
||||
|
||||
if (!isset($netWorth[$currencyId])) {
|
||||
$netWorth[$currencyId] = '0';
|
||||
|
@@ -151,7 +151,12 @@ class CreateController extends Controller
|
||||
// store attachment(s):
|
||||
/** @var array $files */
|
||||
$files = $request->hasFile('attachments') ? $request->file('attachments') : null;
|
||||
$this->attachments->saveAttachmentsForModel($account, $files);
|
||||
if (null !== $files && !auth()->user()->hasRole('demo')) {
|
||||
$this->attachments->saveAttachmentsForModel($account, $files);
|
||||
}
|
||||
if (null !== $files && auth()->user()->hasRole('demo')) {
|
||||
session()->flash('info',(string)trans('firefly.no_att_demo_user'));
|
||||
}
|
||||
|
||||
if (count($this->attachments->getMessages()->get('attachments')) > 0) {
|
||||
$request->session()->flash('info', $this->attachments->getMessages()->get('attachments')); // @codeCoverageIgnore
|
||||
|
@@ -190,9 +190,13 @@ class EditController extends Controller
|
||||
app('preferences')->mark();
|
||||
|
||||
// store new attachment(s):
|
||||
/** @var array $files */
|
||||
$files = $request->hasFile('attachments') ? $request->file('attachments') : null;
|
||||
$this->attachments->saveAttachmentsForModel($account, $files);
|
||||
if (null !== $files && !auth()->user()->hasRole('demo')) {
|
||||
$this->attachments->saveAttachmentsForModel($account, $files);
|
||||
}
|
||||
if (null !== $files && auth()->user()->hasRole('demo')) {
|
||||
session()->flash('info',(string)trans('firefly.no_att_demo_user'));
|
||||
}
|
||||
|
||||
if (count($this->attachments->getMessages()->get('attachments')) > 0) {
|
||||
$request->session()->flash('info', $this->attachments->getMessages()->get('attachments')); // @codeCoverageIgnore
|
||||
|
@@ -101,7 +101,8 @@ class TelemetryController extends Controller
|
||||
app('view')->share('subTitleIcon', 'fa-eye');
|
||||
app('view')->share('subTitle', (string) trans('firefly.telemetry_admin_index'));
|
||||
$version = config('firefly.version');
|
||||
$enabled = config('firefly.telemetry', false);
|
||||
$enabled = config('firefly.send_telemetry', false) && config('firefly.feature_flags.telemetry');
|
||||
|
||||
$count = $this->repository->count();
|
||||
|
||||
return view('admin.telemetry.index', compact('version', 'enabled', 'count'));
|
||||
|
@@ -82,14 +82,8 @@ class LoginController extends Controller
|
||||
Log::channel('audit')->info(sprintf('User is trying to login using "%s"', $request->get('email')));
|
||||
Log::info(sprintf('User is trying to login.'));
|
||||
if ('ldap' === config('auth.providers.users.driver')) {
|
||||
/**
|
||||
* Temporary bug fix for something that doesn't seem to work in
|
||||
* AdLdap.
|
||||
*/
|
||||
$schema = config('ldap.connections.default.schema');
|
||||
|
||||
/** @var Adldap\Connections\Provider $provider */
|
||||
Adldap::getProvider('default')->setSchema(new $schema);
|
||||
Adldap::getProvider('default');
|
||||
}
|
||||
|
||||
$this->validateLogin($request);
|
||||
@@ -137,6 +131,7 @@ class LoginController extends Controller
|
||||
return redirect(route('register')); // @codeCoverageIgnore
|
||||
}
|
||||
|
||||
|
||||
// is allowed to?
|
||||
$singleUserMode = app('fireflyconfig')->get('single_user_mode', config('firefly.configuration.single_user_mode'))->data;
|
||||
$allowRegistration = true;
|
||||
@@ -154,6 +149,9 @@ class LoginController extends Controller
|
||||
$email = $request->old('email');
|
||||
$remember = $request->old('remember');
|
||||
|
||||
// todo must forget 2FA if user ends up here.
|
||||
|
||||
|
||||
return view('auth.login', compact('allowRegistration', 'email', 'remember', 'allowReset', 'title'));
|
||||
}
|
||||
|
||||
|
@@ -104,6 +104,9 @@ class RegisterController extends Controller
|
||||
|
||||
$this->registered($request, $user);
|
||||
|
||||
// telemetry
|
||||
\Telemetry::feature('system.users.count', User::count());
|
||||
|
||||
return redirect($this->redirectPath());
|
||||
}
|
||||
|
||||
|
@@ -284,7 +284,7 @@ class BillController extends Controller
|
||||
}
|
||||
|
||||
|
||||
$request->session()->flash('success', (string) trans('firefly.rescanned_bill', ['total' => $total]));
|
||||
$request->session()->flash('success', (string) trans_choice('firefly.rescanned_bill', $total));
|
||||
app('preferences')->mark();
|
||||
|
||||
return redirect(route('bills.show', [$bill->id]));
|
||||
@@ -383,7 +383,12 @@ class BillController extends Controller
|
||||
|
||||
/** @var array $files */
|
||||
$files = $request->hasFile('attachments') ? $request->file('attachments') : null;
|
||||
$this->attachments->saveAttachmentsForModel($bill, $files);
|
||||
if (null !== $files && !auth()->user()->hasRole('demo')) {
|
||||
$this->attachments->saveAttachmentsForModel($bill, $files);
|
||||
}
|
||||
if (null !== $files && auth()->user()->hasRole('demo')) {
|
||||
session()->flash('info',(string)trans('firefly.no_att_demo_user'));
|
||||
}
|
||||
|
||||
if (count($this->attachments->getMessages()->get('attachments')) > 0) {
|
||||
$request->session()->flash('info', $this->attachments->getMessages()->get('attachments')); // @codeCoverageIgnore
|
||||
@@ -410,7 +415,12 @@ class BillController extends Controller
|
||||
|
||||
/** @var array $files */
|
||||
$files = $request->hasFile('attachments') ? $request->file('attachments') : null;
|
||||
$this->attachments->saveAttachmentsForModel($bill, $files);
|
||||
if (null !== $files && !auth()->user()->hasRole('demo')) {
|
||||
$this->attachments->saveAttachmentsForModel($bill, $files);
|
||||
}
|
||||
if (null !== $files && auth()->user()->hasRole('demo')) {
|
||||
session()->flash('info',(string)trans('firefly.no_att_demo_user'));
|
||||
}
|
||||
|
||||
// flash messages
|
||||
if (count($this->attachments->getMessages()->get('attachments')) > 0) {
|
||||
|
@@ -59,7 +59,7 @@ class AvailableBudgetController extends Controller
|
||||
$this->middleware(
|
||||
function ($request, $next) {
|
||||
app('view')->share('title', (string) trans('firefly.budgets'));
|
||||
app('view')->share('mainTitleIcon', 'fa-tasks');
|
||||
app('view')->share('mainTitleIcon', 'fa-pie-chart');
|
||||
$this->abRepository = app(AvailableBudgetRepositoryInterface::class);
|
||||
$this->currencyRepos = app(CurrencyRepositoryInterface::class);
|
||||
|
||||
@@ -157,6 +157,7 @@ class AvailableBudgetController extends Controller
|
||||
*/
|
||||
public function edit(AvailableBudget $availableBudget, Carbon $start, Carbon $end)
|
||||
{
|
||||
$availableBudget->amount = round($availableBudget->amount, $availableBudget->transactionCurrency->decimal_places);
|
||||
return view('budgets.available-budgets.edit', compact('availableBudget', 'start', 'end'));
|
||||
}
|
||||
|
||||
@@ -176,12 +177,26 @@ class AvailableBudgetController extends Controller
|
||||
$end = session()->get('end');
|
||||
Log::info($e->getMessage());
|
||||
}
|
||||
|
||||
// validate amount
|
||||
$amount = (string) $request->get('amount');
|
||||
if ('' === $amount) {
|
||||
session()->flash('error', trans('firefly.invalid_amount'));
|
||||
|
||||
return redirect(route('budgets.index', [$start->format('Y-m-d'), $end->format('Y-m-d')]));
|
||||
}
|
||||
if (0 === bccomp('0', $amount)) {
|
||||
session()->flash('error', trans('firefly.invalid_amount'));
|
||||
|
||||
return redirect(route('budgets.index', [$start->format('Y-m-d'), $end->format('Y-m-d')]));
|
||||
}
|
||||
|
||||
// find currency
|
||||
$currency = $this->currencyRepos->find((int) $request->get('currency_id'));
|
||||
if (null === $currency) {
|
||||
session()->flash('error', trans('firefly.invalid_currency'));
|
||||
|
||||
return redirect(route('budgets.index'));
|
||||
return redirect(route('budgets.index', [$start->format('Y-m-d'), $end->format('Y-m-d')]));
|
||||
}
|
||||
|
||||
// find existing AB
|
||||
@@ -189,7 +204,7 @@ class AvailableBudgetController extends Controller
|
||||
if (null === $existing) {
|
||||
$this->abRepository->store(
|
||||
[
|
||||
'amount' => $request->get('amount'),
|
||||
'amount' => $amount,
|
||||
'currency' => $currency,
|
||||
'start' => $start,
|
||||
'end' => $end,
|
||||
@@ -198,7 +213,7 @@ class AvailableBudgetController extends Controller
|
||||
}
|
||||
if (null !== $existing) {
|
||||
// update amount:
|
||||
$this->abRepository->update($existing, ['amount' => $request->get('amount')]);
|
||||
$this->abRepository->update($existing, ['amount' => $amount]);
|
||||
}
|
||||
session()->flash('success', trans('firefly.set_ab'));
|
||||
|
||||
@@ -216,7 +231,21 @@ class AvailableBudgetController extends Controller
|
||||
*/
|
||||
public function update(Request $request, AvailableBudget $availableBudget, Carbon $start, Carbon $end)
|
||||
{
|
||||
$this->abRepository->update($availableBudget, ['amount' => $request->get('amount')]);
|
||||
// validate amount
|
||||
$amount = (string) $request->get('amount');
|
||||
if ('' === $amount) {
|
||||
session()->flash('error', trans('firefly.invalid_amount'));
|
||||
|
||||
return redirect(route('budgets.index', [$start->format('Y-m-d'), $end->format('Y-m-d')]));
|
||||
}
|
||||
if (0 === bccomp('0', $amount)) {
|
||||
session()->flash('error', trans('firefly.invalid_amount'));
|
||||
|
||||
return redirect(route('budgets.index', [$start->format('Y-m-d'), $end->format('Y-m-d')]));
|
||||
}
|
||||
|
||||
|
||||
$this->abRepository->update($availableBudget, ['amount' => $amount]);
|
||||
session()->flash('success', trans('firefly.updated_ab'));
|
||||
|
||||
return redirect(route('budgets.index', [$start->format('Y-m-d'), $end->format('Y-m-d')]));
|
||||
|
@@ -70,7 +70,7 @@ class BudgetLimitController extends Controller
|
||||
$this->middleware(
|
||||
function ($request, $next) {
|
||||
app('view')->share('title', (string) trans('firefly.budgets'));
|
||||
app('view')->share('mainTitleIcon', 'fa-tasks');
|
||||
app('view')->share('mainTitleIcon', 'fa-pie-chart');
|
||||
$this->repository = app(BudgetRepositoryInterface::class);
|
||||
$this->opsRepository = app(OperationsRepositoryInterface::class);
|
||||
$this->blRepository = app(BudgetLimitRepositoryInterface::class);
|
||||
@@ -132,6 +132,7 @@ class BudgetLimitController extends Controller
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
Log::debug('Going to store new budget-limit.', $request->all());
|
||||
// first search for existing one and update it if necessary.
|
||||
$currency = $this->currencyRepos->find((int) $request->get('transaction_currency_id'));
|
||||
$budget = $this->repository->findNull((int) $request->get('budget_id'));
|
||||
@@ -143,7 +144,6 @@ class BudgetLimitController extends Controller
|
||||
$start->startOfDay();
|
||||
$end->endOfDay();
|
||||
|
||||
|
||||
Log::debug(sprintf('Start: %s, end: %s', $start->format('Y-m-d H:i:s'), $end->format('Y-m-d H:i:s')));
|
||||
|
||||
$limit = $this->blRepository->find($budget, $currency, $start, $end);
|
||||
|
@@ -58,7 +58,7 @@ class CreateController extends Controller
|
||||
$this->middleware(
|
||||
function ($request, $next) {
|
||||
app('view')->share('title', (string) trans('firefly.budgets'));
|
||||
app('view')->share('mainTitleIcon', 'fa-tasks');
|
||||
app('view')->share('mainTitleIcon', 'fa-pie-chart');
|
||||
$this->repository = app(BudgetRepositoryInterface::class);
|
||||
$this->attachments = app(AttachmentHelperInterface::class);
|
||||
|
||||
@@ -130,9 +130,13 @@ class CreateController extends Controller
|
||||
app('preferences')->mark();
|
||||
|
||||
// store attachment(s):
|
||||
/** @var array $files */
|
||||
$files = $request->hasFile('attachments') ? $request->file('attachments') : null;
|
||||
$this->attachments->saveAttachmentsForModel($budget, $files);
|
||||
if (null !== $files && !auth()->user()->hasRole('demo')) {
|
||||
$this->attachments->saveAttachmentsForModel($budget, $files);
|
||||
}
|
||||
if (null !== $files && auth()->user()->hasRole('demo')) {
|
||||
session()->flash('info',(string)trans('firefly.no_att_demo_user'));
|
||||
}
|
||||
|
||||
if (count($this->attachments->getMessages()->get('attachments')) > 0) {
|
||||
$request->session()->flash('info', $this->attachments->getMessages()->get('attachments')); // @codeCoverageIgnore
|
||||
|
@@ -54,7 +54,7 @@ class DeleteController extends Controller
|
||||
$this->middleware(
|
||||
function ($request, $next) {
|
||||
app('view')->share('title', (string) trans('firefly.budgets'));
|
||||
app('view')->share('mainTitleIcon', 'fa-tasks');
|
||||
app('view')->share('mainTitleIcon', 'fa-pie-chart');
|
||||
$this->repository = app(BudgetRepositoryInterface::class);
|
||||
|
||||
return $next($request);
|
||||
|
@@ -59,7 +59,7 @@ class EditController extends Controller
|
||||
$this->middleware(
|
||||
function ($request, $next) {
|
||||
app('view')->share('title', (string) trans('firefly.budgets'));
|
||||
app('view')->share('mainTitleIcon', 'fa-tasks');
|
||||
app('view')->share('mainTitleIcon', 'fa-pie-chart');
|
||||
$this->repository = app(BudgetRepositoryInterface::class);
|
||||
$this->attachments = app(AttachmentHelperInterface::class);
|
||||
|
||||
@@ -137,9 +137,13 @@ class EditController extends Controller
|
||||
$redirect = redirect($this->getPreviousUri('budgets.edit.uri'));
|
||||
|
||||
// store new attachment(s):
|
||||
/** @var array $files */
|
||||
$files = $request->hasFile('attachments') ? $request->file('attachments') : null;
|
||||
$this->attachments->saveAttachmentsForModel($budget, $files);
|
||||
if (null !== $files && !auth()->user()->hasRole('demo')) {
|
||||
$this->attachments->saveAttachmentsForModel($budget, $files);
|
||||
}
|
||||
if (null !== $files && auth()->user()->hasRole('demo')) {
|
||||
session()->flash('info',(string)trans('firefly.no_att_demo_user'));
|
||||
}
|
||||
|
||||
if (count($this->attachments->getMessages()->get('attachments')) > 0) {
|
||||
$request->session()->flash('info', $this->attachments->getMessages()->get('attachments')); // @codeCoverageIgnore
|
||||
|
@@ -72,7 +72,7 @@ class IndexController extends Controller
|
||||
$this->middleware(
|
||||
function ($request, $next) {
|
||||
app('view')->share('title', (string) trans('firefly.budgets'));
|
||||
app('view')->share('mainTitleIcon', 'fa-tasks');
|
||||
app('view')->share('mainTitleIcon', 'fa-pie-chart');
|
||||
$this->repository = app(BudgetRepositoryInterface::class);
|
||||
$this->opsRepository = app(OperationsRepositoryInterface::class);
|
||||
$this->abRepository = app(AvailableBudgetRepositoryInterface::class);
|
||||
@@ -86,7 +86,6 @@ class IndexController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO the "budgeted" progress bar doesn't update.
|
||||
* Show all budgets.
|
||||
*
|
||||
* @param Request $request
|
||||
@@ -98,6 +97,7 @@ class IndexController extends Controller
|
||||
*/
|
||||
public function index(Request $request, Carbon $start = null, Carbon $end = null)
|
||||
{
|
||||
Log::debug('Start of IndexController::index()');
|
||||
// collect some basic vars:
|
||||
$range = app('preferences')->get('viewRange', '1M')->data;
|
||||
$start = $start ?? session('start', Carbon::now()->startOfMonth());
|
||||
@@ -105,16 +105,18 @@ class IndexController extends Controller
|
||||
$defaultCurrency = app('amount')->getDefaultCurrency();
|
||||
$budgeted = '0';
|
||||
$spent = '0';
|
||||
|
||||
Log::debug(sprintf('1) Start is "%s", end is "%s"', $start->format('Y-m-d H:i:s'), $end->format('Y-m-d H:i:s')));
|
||||
|
||||
// new period stuff:
|
||||
$periodTitle = app('navigation')->periodShow($start, $range);
|
||||
$prevLoop = $this->getPreviousPeriods($start, $range);
|
||||
$nextLoop = $this->getNextPeriods($start, $range);
|
||||
Log::debug(sprintf('2) Start is "%s", end is "%s"', $start->format('Y-m-d H:i:s'), $end->format('Y-m-d H:i:s')));
|
||||
|
||||
// get all available budgets.
|
||||
$ab = $this->abRepository->get($start, $end);
|
||||
$availableBudgets = [];
|
||||
Log::debug(sprintf('3) Start is "%s", end is "%s"', $start->format('Y-m-d H:i:s'), $end->format('Y-m-d H:i:s')));
|
||||
// for each, complement with spent amount:
|
||||
/** @var AvailableBudget $entry */
|
||||
foreach ($ab as $entry) {
|
||||
@@ -131,6 +133,7 @@ class IndexController extends Controller
|
||||
$array['budgeted'] = $budgeted;
|
||||
$availableBudgets[] = $array;
|
||||
unset($spentArr);
|
||||
Log::debug(sprintf('4) Start is "%s", end is "%s"', $start->format('Y-m-d H:i:s'), $end->format('Y-m-d H:i:s')));
|
||||
}
|
||||
|
||||
if (0 === count($availableBudgets)) {
|
||||
@@ -139,6 +142,7 @@ class IndexController extends Controller
|
||||
$spentArr = $this->opsRepository->sumExpenses($start, $end, null, null, $defaultCurrency);
|
||||
$spent = $spentArr[$defaultCurrency->id]['sum'] ?? '0';
|
||||
unset($spentArr);
|
||||
Log::debug(sprintf('5) Start is "%s", end is "%s"', $start->format('Y-m-d H:i:s'), $end->format('Y-m-d H:i:s')));
|
||||
}
|
||||
|
||||
// count the number of enabled currencies. This determines if we display a "+" button.
|
||||
@@ -148,11 +152,12 @@ class IndexController extends Controller
|
||||
// number of days for consistent budgeting.
|
||||
$activeDaysPassed = $this->activeDaysPassed($start, $end); // see method description.
|
||||
$activeDaysLeft = $this->activeDaysLeft($start, $end); // see method description.
|
||||
Log::debug(sprintf('Start: %s, end: %s', $start->format('Y-m-d H:i:s'), $end->format('Y-m-d H:i:s')));
|
||||
Log::debug(sprintf('6) Start is "%s", end is "%s"', $start->format('Y-m-d H:i:s'), $end->format('Y-m-d H:i:s')));
|
||||
|
||||
// get all budgets, and paginate them into $budgets.
|
||||
$collection = $this->repository->getActiveBudgets();
|
||||
$budgets = [];
|
||||
Log::debug(sprintf('7) Start is "%s", end is "%s"', $start->format('Y-m-d H:i:s'), $end->format('Y-m-d H:i:s')));
|
||||
|
||||
// complement budget with budget limits in range, and expenses in currency X in range.
|
||||
/** @var Budget $current */
|
||||
@@ -163,18 +168,22 @@ class IndexController extends Controller
|
||||
$array['attachments'] = $this->repository->getAttachments($current);
|
||||
$array['auto_budget'] = $this->repository->getAutoBudget($current);
|
||||
$budgetLimits = $this->blRepository->getBudgetLimits($current, $start, $end);
|
||||
|
||||
Log::debug(sprintf('8) Start is "%s", end is "%s"', $start->format('Y-m-d H:i:s'), $end->format('Y-m-d H:i:s')));
|
||||
/** @var BudgetLimit $limit */
|
||||
foreach ($budgetLimits as $limit) {
|
||||
$currency = $limit->transactionCurrency ?? $defaultCurrency;
|
||||
$array['budgeted'][] = [
|
||||
'id' => $limit->id,
|
||||
'amount' => round($limit->amount, $currency->decimal_places),
|
||||
'start_date' => $limit->start_date->formatLocalized($this->monthAndDayFormat),
|
||||
'end_date' => $limit->end_date->formatLocalized($this->monthAndDayFormat),
|
||||
'in_range' => $limit->start_date->isSameDay($start) && $limit->end_date->isSameDay($end),
|
||||
'currency_id' => $currency->id,
|
||||
'currency_symbol' => $currency->symbol,
|
||||
'currency_name' => $currency->name,
|
||||
'currency_decimal_places' => $currency->decimal_places,
|
||||
];
|
||||
Log::debug(sprintf('9) Start is "%s", end is "%s"', $start->format('Y-m-d H:i:s'), $end->format('Y-m-d H:i:s')));
|
||||
}
|
||||
|
||||
/** @var TransactionCurrency $currency */
|
||||
@@ -185,6 +194,7 @@ class IndexController extends Controller
|
||||
$array['spent'][$currency->id]['currency_id'] = $currency->id;
|
||||
$array['spent'][$currency->id]['currency_symbol'] = $currency->symbol;
|
||||
$array['spent'][$currency->id]['currency_decimal_places'] = $currency->decimal_places;
|
||||
Log::debug(sprintf('10) Start is "%s", end is "%s"', $start->format('Y-m-d H:i:s'), $end->format('Y-m-d H:i:s')));
|
||||
}
|
||||
}
|
||||
$budgets[] = $array;
|
||||
@@ -192,7 +202,7 @@ class IndexController extends Controller
|
||||
|
||||
// get all inactive budgets, and simply list them:
|
||||
$inactive = $this->repository->getInactiveBudgets();
|
||||
|
||||
Log::debug(sprintf('11) Start is "%s", end is "%s"', $start->format('Y-m-d H:i:s'), $end->format('Y-m-d H:i:s')));
|
||||
|
||||
return view(
|
||||
'budgets.index',
|
||||
|
@@ -64,7 +64,7 @@ class ShowController extends Controller
|
||||
$this->middleware(
|
||||
function ($request, $next) {
|
||||
app('view')->share('title', (string) trans('firefly.budgets'));
|
||||
app('view')->share('mainTitleIcon', 'fa-tasks');
|
||||
app('view')->share('mainTitleIcon', 'fa-pie-chart');
|
||||
$this->journalRepos = app(JournalRepositoryInterface::class);
|
||||
$this->repository = app(BudgetRepositoryInterface::class);
|
||||
|
||||
|
@@ -57,7 +57,7 @@ class CreateController extends Controller
|
||||
$this->middleware(
|
||||
function ($request, $next) {
|
||||
app('view')->share('title', (string) trans('firefly.categories'));
|
||||
app('view')->share('mainTitleIcon', 'fa-bar-chart');
|
||||
app('view')->share('mainTitleIcon', 'fa-bookmark');
|
||||
$this->repository = app(CategoryRepositoryInterface::class);
|
||||
$this->attachments = app(AttachmentHelperInterface::class);
|
||||
|
||||
@@ -102,9 +102,13 @@ class CreateController extends Controller
|
||||
app('preferences')->mark();
|
||||
|
||||
// store attachment(s):
|
||||
/** @var array $files */
|
||||
$files = $request->hasFile('attachments') ? $request->file('attachments') : null;
|
||||
$this->attachments->saveAttachmentsForModel($category, $files);
|
||||
if (null !== $files && !auth()->user()->hasRole('demo')) {
|
||||
$this->attachments->saveAttachmentsForModel($category, $files);
|
||||
}
|
||||
if (null !== $files && auth()->user()->hasRole('demo')) {
|
||||
session()->flash('info',(string)trans('firefly.no_att_demo_user'));
|
||||
}
|
||||
|
||||
if (count($this->attachments->getMessages()->get('attachments')) > 0) {
|
||||
$request->session()->flash('info', $this->attachments->getMessages()->get('attachments')); // @codeCoverageIgnore
|
||||
|
@@ -53,7 +53,7 @@ class DeleteController extends Controller
|
||||
$this->middleware(
|
||||
function ($request, $next) {
|
||||
app('view')->share('title', (string) trans('firefly.categories'));
|
||||
app('view')->share('mainTitleIcon', 'fa-bar-chart');
|
||||
app('view')->share('mainTitleIcon', 'fa-bookmark');
|
||||
$this->repository = app(CategoryRepositoryInterface::class);
|
||||
|
||||
return $next($request);
|
||||
|
@@ -59,7 +59,7 @@ class EditController extends Controller
|
||||
$this->middleware(
|
||||
function ($request, $next) {
|
||||
app('view')->share('title', (string) trans('firefly.categories'));
|
||||
app('view')->share('mainTitleIcon', 'fa-bar-chart');
|
||||
app('view')->share('mainTitleIcon', 'fa-bookmark');
|
||||
$this->repository = app(CategoryRepositoryInterface::class);
|
||||
$this->attachments = app(AttachmentHelperInterface::class);
|
||||
|
||||
@@ -107,9 +107,13 @@ class EditController extends Controller
|
||||
app('preferences')->mark();
|
||||
|
||||
// store new attachment(s):
|
||||
/** @var array $files */
|
||||
$files = $request->hasFile('attachments') ? $request->file('attachments') : null;
|
||||
$this->attachments->saveAttachmentsForModel($category, $files);
|
||||
if (null !== $files && !auth()->user()->hasRole('demo')) {
|
||||
$this->attachments->saveAttachmentsForModel($category, $files);
|
||||
}
|
||||
if (null !== $files && auth()->user()->hasRole('demo')) {
|
||||
session()->flash('info',(string)trans('firefly.no_att_demo_user'));
|
||||
}
|
||||
|
||||
if (count($this->attachments->getMessages()->get('attachments')) > 0) {
|
||||
$request->session()->flash('info', $this->attachments->getMessages()->get('attachments')); // @codeCoverageIgnore
|
||||
|
@@ -53,7 +53,7 @@ class IndexController extends Controller
|
||||
$this->middleware(
|
||||
function ($request, $next) {
|
||||
app('view')->share('title', (string) trans('firefly.categories'));
|
||||
app('view')->share('mainTitleIcon', 'fa-bar-chart');
|
||||
app('view')->share('mainTitleIcon', 'fa-bookmark');
|
||||
$this->repository = app(CategoryRepositoryInterface::class);
|
||||
|
||||
return $next($request);
|
||||
|
@@ -59,7 +59,7 @@ class NoCategoryController extends Controller
|
||||
$this->middleware(
|
||||
function ($request, $next) {
|
||||
app('view')->share('title', (string) trans('firefly.categories'));
|
||||
app('view')->share('mainTitleIcon', 'fa-bar-chart');
|
||||
app('view')->share('mainTitleIcon', 'fa-bookmark');
|
||||
$this->journalRepos = app(JournalRepositoryInterface::class);
|
||||
|
||||
return $next($request);
|
||||
|
@@ -58,7 +58,7 @@ class ShowController extends Controller
|
||||
$this->middleware(
|
||||
function ($request, $next) {
|
||||
app('view')->share('title', (string) trans('firefly.categories'));
|
||||
app('view')->share('mainTitleIcon', 'fa-bar-chart');
|
||||
app('view')->share('mainTitleIcon', 'fa-bookmark');
|
||||
$this->repository = app(CategoryRepositoryInterface::class);
|
||||
|
||||
return $next($request);
|
||||
@@ -84,7 +84,7 @@ class ShowController extends Controller
|
||||
$start = $start ?? session('start', Carbon::now()->startOfMonth());
|
||||
/** @var Carbon $end */
|
||||
$end = $end ?? session('end', Carbon::now()->endOfMonth());
|
||||
$subTitleIcon = 'fa-bar-chart';
|
||||
$subTitleIcon = 'fa-bookmark';
|
||||
$page = (int) $request->get('page');
|
||||
$attachments = $this->repository->getAttachments($category);
|
||||
$pageSize = (int) app('preferences')->get('listPageSize', 50)->data;
|
||||
@@ -122,7 +122,7 @@ class ShowController extends Controller
|
||||
public function showAll(Request $request, Category $category)
|
||||
{
|
||||
// default values:
|
||||
$subTitleIcon = 'fa-bar-chart';
|
||||
$subTitleIcon = 'fa-bookmark';
|
||||
$page = (int) $request->get('page');
|
||||
$pageSize = (int) app('preferences')->get('listPageSize', 50)->data;
|
||||
$start = null;
|
||||
|
@@ -432,9 +432,15 @@ class AccountController extends Controller
|
||||
$cache->addProperty($end);
|
||||
$cache->addProperty($account->id);
|
||||
if ($cache->has()) {
|
||||
return response()->json($cache->get()); // @codeCoverageIgnore
|
||||
return response()->json($cache->get()); // @codeCoverageIgnore
|
||||
}
|
||||
$currencies = $this->accountRepository->getUsedCurrencies($account);
|
||||
|
||||
// if the account is not expense or revenue, just use the account's default currency.
|
||||
if (!in_array($account->accountType->type, [AccountType::REVENUE, AccountType::EXPENSE], true)) {
|
||||
$currencies = [$this->accountRepository->getAccountCurrency($account) ?? app('amount')->getDefaultCurrency()];
|
||||
}
|
||||
|
||||
/** @var TransactionCurrency $currency */
|
||||
foreach ($currencies as $currency) {
|
||||
$chartData[] = $this->periodByCurrency($start, $end, $account, $currency);
|
||||
@@ -565,6 +571,7 @@ class AccountController extends Controller
|
||||
*/
|
||||
private function periodByCurrency(Carbon $start, Carbon $end, Account $account, TransactionCurrency $currency): array
|
||||
{
|
||||
$locale = app('steam')->getLocale();
|
||||
$step = $this->calculateStep($start, $end);
|
||||
$result = [
|
||||
'label' => sprintf('%s (%s)', $account->name, $currency->symbol),
|
||||
@@ -576,7 +583,7 @@ class AccountController extends Controller
|
||||
switch ($step) {
|
||||
case '1D':
|
||||
// per day the entire period, balance for every day.
|
||||
$format = (string) trans('config.month_and_day');
|
||||
$format = (string) trans('config.month_and_day', [], $locale);
|
||||
$range = app('steam')->balanceInRange($account, $start, $end, $currency);
|
||||
$previous = array_values($range)[0];
|
||||
while ($end >= $current) {
|
||||
|
@@ -111,6 +111,7 @@ class BillController extends Controller
|
||||
if ($cache->has()) {
|
||||
return response()->json($cache->get()); // @codeCoverageIgnore
|
||||
}
|
||||
$locale = app('steam')->getLocale();
|
||||
|
||||
/** @var GroupCollectorInterface $collector */
|
||||
$collector = app(GroupCollectorInterface::class);
|
||||
@@ -131,7 +132,7 @@ class BillController extends Controller
|
||||
];
|
||||
|
||||
foreach ($journals as $journal) {
|
||||
$date = $journal['date']->formatLocalized((string) trans('config.month_and_day'));
|
||||
$date = $journal['date']->formatLocalized((string) trans('config.month_and_day', [], $locale));
|
||||
$chartData[0]['entries'][$date] = $bill->amount_min; // minimum amount of bill
|
||||
$chartData[1]['entries'][$date] = $bill->amount_max; // maximum amount of bill
|
||||
|
||||
|
@@ -179,14 +179,14 @@ class BudgetController extends Controller
|
||||
if ($cache->has()) {
|
||||
return response()->json($cache->get()); // @codeCoverageIgnore
|
||||
}
|
||||
|
||||
$locale = app('steam')->getLocale();
|
||||
$entries = [];
|
||||
$amount = $budgetLimit->amount;
|
||||
$budgetCollection = new Collection([$budget]);
|
||||
while ($start <= $end) {
|
||||
$spent = $this->opsRepository->spentInPeriod($budgetCollection, new Collection, $start, $start);
|
||||
$amount = bcadd($amount, $spent);
|
||||
$format = $start->formatLocalized((string)trans('config.month_and_day'));
|
||||
$format = $start->formatLocalized((string)trans('config.month_and_day', [], $locale));
|
||||
$entries[$format] = $amount;
|
||||
|
||||
$start->addDay();
|
||||
|
@@ -76,6 +76,7 @@ class PiggyBankController extends Controller
|
||||
}
|
||||
$set = $repository->getEvents($piggyBank);
|
||||
$set = $set->reverse();
|
||||
$locale =app('steam')->getLocale();
|
||||
|
||||
// get first event or start date of piggy bank or today
|
||||
$startDate = $piggyBank->start_date ?? new Carbon;
|
||||
@@ -99,7 +100,7 @@ class PiggyBankController extends Controller
|
||||
}
|
||||
);
|
||||
$currentSum = $filtered->sum('amount');
|
||||
$label = $oldest->formatLocalized((string) trans('config.month_and_day'));
|
||||
$label = $oldest->formatLocalized((string) trans('config.month_and_day', [], $locale));
|
||||
$chartData[$label] = $currentSum;
|
||||
$oldest = app('navigation')->addPeriod($oldest, $step, 0);
|
||||
}
|
||||
@@ -110,7 +111,7 @@ class PiggyBankController extends Controller
|
||||
}
|
||||
);
|
||||
$finalSum = $finalFiltered->sum('amount');
|
||||
$finalLabel = $today->formatLocalized((string) trans('config.month_and_day'));
|
||||
$finalLabel = $today->formatLocalized((string) trans('config.month_and_day', [], $locale));
|
||||
$chartData[$finalLabel] = $finalSum;
|
||||
|
||||
$data = $this->generator->singleSet($piggyBank->name, $chartData);
|
||||
|
@@ -79,6 +79,7 @@ class ReportController extends Controller
|
||||
if ($cache->has()) {
|
||||
return response()->json($cache->get()); // @codeCoverageIgnore
|
||||
}
|
||||
$locale = app('steam')->getLocale();
|
||||
$current = clone $start;
|
||||
$chartData = [];
|
||||
/** @var NetWorthInterface $helper */
|
||||
@@ -110,7 +111,7 @@ class ReportController extends Controller
|
||||
/** @var array $netWorthItem */
|
||||
foreach ($result as $netWorthItem) {
|
||||
$currencyId = $netWorthItem['currency']->id;
|
||||
$label = $current->formatLocalized((string) trans('config.month_and_day'));
|
||||
$label = $current->formatLocalized((string) trans('config.month_and_day', [], $locale));
|
||||
if (!isset($chartData[$currencyId])) {
|
||||
$chartData[$currencyId] = [
|
||||
'label' => 'Net worth in ' . $netWorthItem['currency']->name,
|
||||
|
@@ -82,21 +82,11 @@ class TransactionController extends Controller
|
||||
foreach ($result as $journal) {
|
||||
$budget = $journal['budget_name'] ?? (string) trans('firefly.no_budget');
|
||||
$title = sprintf('%s (%s)', $budget, $journal['currency_symbol']);
|
||||
// key => [value => x, 'currency_symbol' => 'x']
|
||||
$data[$title] = $data[$title] ?? [
|
||||
'amount' => '0',
|
||||
'currency_symbol' => $journal['currency_symbol'],
|
||||
];
|
||||
$data[$title]['amount'] = bcadd($data[$title]['amount'], $journal['amount']);
|
||||
|
||||
if (null !== $journal['foreign_amount']) {
|
||||
$title = sprintf('%s (%s)', $budget, $journal['foreign_currency_symbol']);
|
||||
$data[$title] = $data[$title] ?? [
|
||||
'amount' => $journal['foreign_amount'],
|
||||
'currency_symbol' => $journal['currency_symbol'],
|
||||
];
|
||||
$data[$title]['amount'] = bcadd($data[$title]['amount'], $journal['foreign_amount']);
|
||||
}
|
||||
}
|
||||
$chart = $this->generator->multiCurrencyPieChart($data);
|
||||
$cache->store($chart);
|
||||
@@ -138,6 +128,7 @@ class TransactionController extends Controller
|
||||
$collector->setTypes([TransactionType::DEPOSIT]);
|
||||
break;
|
||||
case 'transfers':
|
||||
case 'transfer':
|
||||
$collector->setTypes([TransactionType::TRANSFER]);
|
||||
break;
|
||||
}
|
||||
@@ -149,21 +140,12 @@ class TransactionController extends Controller
|
||||
foreach ($result as $journal) {
|
||||
$category = $journal['category_name'] ?? (string) trans('firefly.no_category');
|
||||
$title = sprintf('%s (%s)', $category, $journal['currency_symbol']);
|
||||
// key => [value => x, 'currency_symbol' => 'x']
|
||||
$data[$title] = $data[$title] ?? [
|
||||
'amount' => '0',
|
||||
'currency_symbol' => $journal['currency_symbol'],
|
||||
];
|
||||
$data[$title]['amount'] = bcadd($data[$title]['amount'], $journal['amount']);
|
||||
|
||||
if (null !== $journal['foreign_amount']) {
|
||||
$title = sprintf('%s (%s)', $category, $journal['foreign_currency_symbol']);
|
||||
$data[$title] = $data[$title] ?? [
|
||||
'amount' => $journal['foreign_amount'],
|
||||
'currency_symbol' => $journal['currency_symbol'],
|
||||
];
|
||||
$data[$title]['amount'] = bcadd($data[$title]['amount'], $journal['foreign_amount']);
|
||||
}
|
||||
}
|
||||
$chart = $this->generator->multiCurrencyPieChart($data);
|
||||
$cache->store($chart);
|
||||
@@ -222,15 +204,6 @@ class TransactionController extends Controller
|
||||
'currency_symbol' => $journal['currency_symbol'],
|
||||
];
|
||||
$data[$title]['amount'] = bcadd($data[$title]['amount'], $journal['amount']);
|
||||
|
||||
if (null !== $journal['foreign_amount']) {
|
||||
$title = sprintf('%s (%s)', $name, $journal['foreign_currency_symbol']);
|
||||
$data[$title] = $data[$title] ?? [
|
||||
'amount' => $journal['foreign_amount'],
|
||||
'currency_symbol' => $journal['currency_symbol'],
|
||||
];
|
||||
$data[$title]['amount'] = bcadd($data[$title]['amount'], $journal['foreign_amount']);
|
||||
}
|
||||
}
|
||||
$chart = $this->generator->multiCurrencyPieChart($data);
|
||||
$cache->store($chart);
|
||||
@@ -290,14 +263,6 @@ class TransactionController extends Controller
|
||||
];
|
||||
$data[$title]['amount'] = bcadd($data[$title]['amount'], $journal['amount']);
|
||||
|
||||
if (null !== $journal['foreign_amount']) {
|
||||
$title = sprintf('%s (%s)', $name, $journal['foreign_currency_symbol']);
|
||||
$data[$title] = $data[$title] ?? [
|
||||
'amount' => $journal['foreign_amount'],
|
||||
'currency_symbol' => $journal['currency_symbol'],
|
||||
];
|
||||
$data[$title]['amount'] = bcadd($data[$title]['amount'], $journal['foreign_amount']);
|
||||
}
|
||||
}
|
||||
$chart = $this->generator->multiCurrencyPieChart($data);
|
||||
$cache->store($chart);
|
||||
|
@@ -85,17 +85,20 @@ class Controller extends BaseController
|
||||
|
||||
$this->middleware(
|
||||
function ($request, $next) {
|
||||
$locale = app('steam')->getLocale();
|
||||
// translations for specific strings:
|
||||
$this->monthFormat = (string) trans('config.month');
|
||||
$this->monthAndDayFormat = (string) trans('config.month_and_day');
|
||||
$this->dateTimeFormat = (string) trans('config.date_time');
|
||||
$this->monthFormat = (string) trans('config.month', [], $locale);
|
||||
$this->monthAndDayFormat = (string) trans('config.month_and_day', [], $locale);
|
||||
$this->dateTimeFormat = (string) trans('config.date_time', [], $locale);
|
||||
|
||||
// get shown-intro-preference:
|
||||
if (auth()->check()) {
|
||||
$language = $this->getLanguage();
|
||||
$language = app('steam')->getLanguage();
|
||||
$locale = app('steam')->getLocale();
|
||||
$page = $this->getPageName();
|
||||
$shownDemo = $this->hasSeenDemo();
|
||||
app('view')->share('language', $language);
|
||||
app('view')->share('locale', $locale);
|
||||
app('view')->share('shownDemo', $shownDemo);
|
||||
app('view')->share('current_route_name', $page);
|
||||
app('view')->share('original_route_name', Route::currentRouteName());
|
||||
|
@@ -121,12 +121,11 @@ class DebugController extends Controller
|
||||
$search = ['~', '#'];
|
||||
$replace = ['\~', '# '];
|
||||
|
||||
$now = Carbon::now()->format('Y-m-d H:i:s e');
|
||||
$installationId = app('fireflyconfig')->get('installation_id', '')->data;
|
||||
$phpVersion = str_replace($search, $replace, PHP_VERSION);
|
||||
$phpOs = str_replace($search, $replace, PHP_OS);
|
||||
$interface = PHP_SAPI;
|
||||
$now = Carbon::now()->format('Y-m-d H:i:s e');
|
||||
$extensions = implode(', ', get_loaded_extensions());
|
||||
$drivers = implode(', ', DB::availableDrivers());
|
||||
$currentDriver = DB::getDriverName();
|
||||
$userAgent = $request->header('user-agent');
|
||||
@@ -138,14 +137,23 @@ class DebugController extends Controller
|
||||
$logChannel = config('logging.default');
|
||||
$appLogLevel = config('logging.level');
|
||||
$cacheDriver = config('cache.default');
|
||||
$loginProvider = config('auth.driver');
|
||||
$loginProvider = config('auth.providers.users.driver');
|
||||
|
||||
// some new vars.
|
||||
$telemetry = true === config('firefly.send_telemetry') && true === config('firefly.feature_flags.telemetry');
|
||||
$defaultLanguage = (string) config('firefly.default_language');
|
||||
$defaultLocale = (string) config('firefly.default_locale');
|
||||
$userLanguage = app('steam')->getLanguage();
|
||||
$userLocale = app('steam')->getLocale();
|
||||
$isDocker = env('IS_DOCKER', false);
|
||||
|
||||
// set languages, see what happens:
|
||||
$original = setlocale(LC_ALL, 0);
|
||||
$localeAttempts = [];
|
||||
$parts = explode(',', (string) trans('config.locale'));
|
||||
$parts = app('steam')->getLocaleArray(app('steam')->getLocale());
|
||||
foreach ($parts as $code) {
|
||||
$code = trim($code);
|
||||
$code = trim($code);
|
||||
Log::debug(sprintf('Trying to set %s', $code));
|
||||
$localeAttempts[$code] = var_export(setlocale(LC_ALL, $code), true);
|
||||
}
|
||||
setlocale(LC_ALL, $original);
|
||||
@@ -178,7 +186,6 @@ class DebugController extends Controller
|
||||
'debug',
|
||||
compact(
|
||||
'phpVersion',
|
||||
'extensions',
|
||||
'localeAttempts',
|
||||
'appEnv',
|
||||
'appDebug',
|
||||
@@ -196,7 +203,14 @@ class DebugController extends Controller
|
||||
'interface',
|
||||
'logContent',
|
||||
'cacheDriver',
|
||||
'trustedProxies'
|
||||
'trustedProxies',
|
||||
'telemetry',
|
||||
'userLanguage',
|
||||
'userLocale',
|
||||
'defaultLanguage',
|
||||
'defaultLocale',
|
||||
'isDocker'
|
||||
|
||||
)
|
||||
);
|
||||
}
|
||||
|
@@ -117,7 +117,7 @@ class HomeController extends Controller
|
||||
if (0 === $count) {
|
||||
return redirect(route('new-user.index'));
|
||||
}
|
||||
$subTitle = (string) trans('firefly.welcomeBack');
|
||||
$subTitle = (string) trans('firefly.welcome_back');
|
||||
$transactions = [];
|
||||
$frontPage = app('preferences')->get(
|
||||
'frontPageAccounts',
|
||||
|
@@ -126,7 +126,7 @@ class JavascriptController extends Controller
|
||||
/** @noinspection NullPointerExceptionInspection */
|
||||
$lang = $pref->data;
|
||||
$dateRange = $this->getDateRangeConfig();
|
||||
$uid = substr(hash('sha256', auth()->user()->id . auth()->user()->email), 0, 12);
|
||||
$uid = substr(hash('sha256', sprintf('%s-%s-%s', (string) config('app.key'), auth()->user()->id, auth()->user()->email)), 0, 12);
|
||||
|
||||
$data = [
|
||||
'currencyCode' => $currency->code,
|
||||
|
@@ -263,7 +263,7 @@ class BoxController extends Controller
|
||||
*/
|
||||
public function netWorth(): JsonResponse
|
||||
{
|
||||
$date = Carbon::now()->startOfDay();
|
||||
$date = Carbon::now()->endOfDay();
|
||||
|
||||
// start and end in the future? use $end
|
||||
if ($this->notInSessionRange($date)) {
|
||||
|
@@ -63,7 +63,7 @@ class BudgetController extends Controller
|
||||
$this->middleware(
|
||||
function ($request, $next) {
|
||||
app('view')->share('title', (string) trans('firefly.budgets'));
|
||||
app('view')->share('mainTitleIcon', 'fa-tasks');
|
||||
app('view')->share('mainTitleIcon', 'fa-pie-chart');
|
||||
$this->repository = app(BudgetRepositoryInterface::class);
|
||||
$this->opsRepository = app(OperationsRepositoryInterface::class);
|
||||
$this->abRepository = app(AvailableBudgetRepositoryInterface::class);
|
||||
@@ -108,4 +108,4 @@ class BudgetController extends Controller
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@@ -151,6 +151,7 @@ class RecurrenceController extends Controller
|
||||
$today = Carbon::now()->startOfDay();
|
||||
$date = Carbon::createFromFormat('Y-m-d', $string)->startOfDay();
|
||||
$preSelected = (string) $request->get('pre_select');
|
||||
$locale = app('steam')->getLocale();
|
||||
|
||||
Log::debug(sprintf('date = %s, today = %s. date > today? %s', $date->toAtomString(), $today->toAtomString(), var_export($date > $today, true)));
|
||||
Log::debug(sprintf('past = true? %s', var_export('true' === (string) $request->get('past'), true)));
|
||||
@@ -163,7 +164,7 @@ class RecurrenceController extends Controller
|
||||
$dayOfWeek = (string) trans(sprintf('config.dow_%s', $date->dayOfWeekIso));
|
||||
$ndom = sprintf('ndom,%s,%s', $date->weekOfMonth, $date->dayOfWeekIso);
|
||||
$yearly = sprintf('yearly,%s', $date->format('Y-m-d'));
|
||||
$yearlyDate = $date->formatLocalized((string) trans('config.month_and_day_no_year'));
|
||||
$yearlyDate = $date->formatLocalized((string) trans('config.month_and_day_no_year', [], $locale));
|
||||
$result = [
|
||||
'daily' => ['label' => (string) trans('firefly.recurring_daily'), 'selected' => 0 === strpos($preSelected, 'daily')],
|
||||
$weekly => ['label' => (string) trans('firefly.recurring_weekly', ['weekday' => $dayOfWeek]),
|
||||
|
@@ -23,6 +23,7 @@ declare(strict_types=1);
|
||||
namespace FireflyIII\Http\Controllers;
|
||||
|
||||
use FireflyIII\Http\Requests\NewUserFormRequest;
|
||||
use FireflyIII\Models\AccountType;
|
||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||
use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;
|
||||
use FireflyIII\Support\Http\Controllers\CreateStuff;
|
||||
@@ -110,6 +111,12 @@ class NewUserController extends Controller
|
||||
|
||||
// store currency preference:
|
||||
app('preferences')->set('currencyPreference', $currency->code);
|
||||
|
||||
// store frontpage preferences:
|
||||
$accounts = $this->repository->getAccountsByType([AccountType::ASSET])->pluck('id')->toArray();
|
||||
app('preferences')->set('frontPageAccounts', $accounts);
|
||||
|
||||
// mark.
|
||||
app('preferences')->mark();
|
||||
|
||||
// set default optional fields:
|
||||
@@ -117,6 +124,11 @@ class NewUserController extends Controller
|
||||
'invoice_date' => false, 'internal_reference' => false, 'notes' => true, 'attachments' => true,];
|
||||
app('preferences')->set('transaction_journal_optional_fields', $visibleFields);
|
||||
|
||||
// telemetry: user language preference + default language.
|
||||
app('telemetry')->feature('config.firefly.default_language', config('firefly.default_language', 'en_US'));
|
||||
app('telemetry')->feature('user.preferences.language', app('steam')->getLanguage());
|
||||
app('telemetry')->feature('user.preferences.locale', app('steam')->getLocale());
|
||||
|
||||
session()->flash('success', (string) trans('firefly.stored_new_accounts_new_user'));
|
||||
app('preferences')->mark();
|
||||
|
||||
|
@@ -71,7 +71,7 @@ class PiggyBankController extends Controller
|
||||
$this->middleware(
|
||||
function ($request, $next) {
|
||||
app('view')->share('title', (string) trans('firefly.piggyBanks'));
|
||||
app('view')->share('mainTitleIcon', 'fa-sort-amount-asc');
|
||||
app('view')->share('mainTitleIcon', 'fa-bullseye');
|
||||
|
||||
$this->attachments = app(AttachmentHelperInterface::class);
|
||||
$this->piggyRepos = app(PiggyBankRepositoryInterface::class);
|
||||
@@ -92,9 +92,7 @@ class PiggyBankController extends Controller
|
||||
*/
|
||||
public function add(PiggyBank $piggyBank)
|
||||
{
|
||||
/** @var Carbon $date */
|
||||
$date = session('end', Carbon::now()->endOfMonth());
|
||||
$leftOnAccount = $this->piggyRepos->leftOnAccount($piggyBank, $date);
|
||||
$leftOnAccount = $this->piggyRepos->leftOnAccount($piggyBank, new Carbon);
|
||||
$savedSoFar = $this->piggyRepos->getCurrentAmount($piggyBank);
|
||||
$leftToSave = bcsub($piggyBank->targetamount, $savedSoFar);
|
||||
$maxAmount = min($leftOnAccount, $leftToSave);
|
||||
@@ -113,7 +111,7 @@ class PiggyBankController extends Controller
|
||||
public function addMobile(PiggyBank $piggyBank)
|
||||
{
|
||||
/** @var Carbon $date */
|
||||
$date = session('end', Carbon::now()->endOfMonth());
|
||||
$date = session('end', new Carbon);
|
||||
$leftOnAccount = $this->piggyRepos->leftOnAccount($piggyBank, $date);
|
||||
$savedSoFar = $this->piggyRepos->getCurrentAmount($piggyBank);
|
||||
$leftToSave = bcsub($piggyBank->targetamount, $savedSoFar);
|
||||
@@ -456,7 +454,12 @@ class PiggyBankController extends Controller
|
||||
// store attachment(s):
|
||||
/** @var array $files */
|
||||
$files = $request->hasFile('attachments') ? $request->file('attachments') : null;
|
||||
$this->attachments->saveAttachmentsForModel($piggyBank, $files);
|
||||
if (null !== $files && !auth()->user()->hasRole('demo')) {
|
||||
$this->attachments->saveAttachmentsForModel($piggyBank, $files);
|
||||
}
|
||||
if (null !== $files && auth()->user()->hasRole('demo')) {
|
||||
session()->flash('info',(string)trans('firefly.no_att_demo_user'));
|
||||
}
|
||||
|
||||
if (count($this->attachments->getMessages()->get('attachments')) > 0) {
|
||||
$request->session()->flash('info', $this->attachments->getMessages()->get('attachments')); // @codeCoverageIgnore
|
||||
@@ -495,7 +498,12 @@ class PiggyBankController extends Controller
|
||||
// store new attachment(s):
|
||||
/** @var array $files */
|
||||
$files = $request->hasFile('attachments') ? $request->file('attachments') : null;
|
||||
$this->attachments->saveAttachmentsForModel($piggyBank, $files);
|
||||
if (null !== $files && !auth()->user()->hasRole('demo')) {
|
||||
$this->attachments->saveAttachmentsForModel($piggyBank, $files);
|
||||
}
|
||||
if (null !== $files && auth()->user()->hasRole('demo')) {
|
||||
session()->flash('info',(string)trans('firefly.no_att_demo_user'));
|
||||
}
|
||||
|
||||
if (count($this->attachments->getMessages()->get('attachments')) > 0) {
|
||||
$request->session()->flash('info', $this->attachments->getMessages()->get('attachments')); // @codeCoverageIgnore
|
||||
|
@@ -31,6 +31,7 @@ use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Routing\Redirector;
|
||||
use Illuminate\View\View;
|
||||
use JsonException;
|
||||
|
||||
/**
|
||||
* Class PreferencesController.
|
||||
@@ -90,8 +91,9 @@ class PreferencesController extends Controller
|
||||
|
||||
$viewRange = $viewRangePref->data;
|
||||
$frontPageAccounts = app('preferences')->get('frontPageAccounts', $accountIds);
|
||||
$language = app('preferences')->get('language', config('firefly.default_language', 'en_US'))->data;
|
||||
$language = app('steam')->getLanguage();
|
||||
$languages = config('firefly.languages');
|
||||
$locale = app('preferences')->get('locale', config('firefly.default_locale', 'equal'))->data;
|
||||
$listPageSize = app('preferences')->get('listPageSize', 50)->data;
|
||||
$customFiscalYear = app('preferences')->get('customFiscalYear', 0)->data;
|
||||
$fiscalYearStartStr = app('preferences')->get('fiscalYearStart', '01-01')->data;
|
||||
@@ -100,6 +102,15 @@ class PreferencesController extends Controller
|
||||
|
||||
ksort($languages);
|
||||
|
||||
// list of locales also has "equal" which makes it equal to whatever the language is.
|
||||
|
||||
try {
|
||||
$locales = json_decode(file_get_contents(resource_path(sprintf('lang/%s/locales.json', $language))), true, 512, JSON_THROW_ON_ERROR);
|
||||
} catch (JsonException $e) {
|
||||
Log::error($e->getMessage());
|
||||
$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->data)) {
|
||||
@@ -113,6 +124,8 @@ class PreferencesController extends Controller
|
||||
'groupedAccounts',
|
||||
'frontPageAccounts',
|
||||
'languages',
|
||||
'locales',
|
||||
'locale',
|
||||
'tjOptionalFields',
|
||||
'viewRange',
|
||||
'customFiscalYear',
|
||||
@@ -172,6 +185,13 @@ class PreferencesController extends Controller
|
||||
session()->flash('info', 'All translations are supplied by volunteers. There might be errors and mistakes. I appreciate your feedback.');
|
||||
}
|
||||
|
||||
// same for locale:
|
||||
if (!auth()->user()->hasRole('demo')) {
|
||||
/** @var Preference $currentLocale */
|
||||
$locale = $request->get('locale');
|
||||
app('preferences')->set('locale', $locale);
|
||||
}
|
||||
|
||||
// optional fields for transactions:
|
||||
$setOptions = $request->get('tj');
|
||||
$optionalTj = [
|
||||
@@ -190,6 +210,11 @@ class PreferencesController extends Controller
|
||||
session()->flash('success', (string) trans('firefly.saved_preferences'));
|
||||
app('preferences')->mark();
|
||||
|
||||
// telemetry: user language preference + default language.
|
||||
app('telemetry')->feature('config.firefly.default_language', config('firefly.default_language', 'en_US'));
|
||||
app('telemetry')->feature('user.preferences.language', app('steam')->getLanguage());
|
||||
app('telemetry')->feature('user.preferences.locale', app('steam')->getLocale());
|
||||
|
||||
return redirect(route('preferences.index'));
|
||||
}
|
||||
}
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user