mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-18 10:16:49 +00:00
Compare commits
168 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
9bdfecbfdc | ||
|
f85e4a24e5 | ||
|
0dda87c78e | ||
|
2fc09ff9d7 | ||
|
e4e0e21293 | ||
|
15089f0d7e | ||
|
7232c1d7bb | ||
|
9a53d8c21c | ||
|
0d198193db | ||
|
45bc23b8af | ||
|
3323c31765 | ||
|
bb7c26b77c | ||
|
9101d6a2c0 | ||
|
ad2b254be0 | ||
|
abc4f856ce | ||
|
b3b66a8f92 | ||
|
2f7cf9b916 | ||
|
b822e0c6e7 | ||
|
6fef9ee72b | ||
|
ab6dd0a1ec | ||
|
9deef5ac92 | ||
|
577187babe | ||
|
577290e813 | ||
|
f3b9798216 | ||
|
4dcaa96d16 | ||
|
0dcbf451d6 | ||
|
e87f6ca40e | ||
|
1f34e33d8c | ||
|
258e87e127 | ||
|
3ec8efcfc1 | ||
|
70ea227bd0 | ||
|
27c832ed58 | ||
|
a31b4ccf01 | ||
|
d221ea68d0 | ||
|
dc9fe58536 | ||
|
f871e29bdb | ||
|
1357352276 | ||
|
e169754693 | ||
|
1cfe4f40ba | ||
|
5545d1c1ba | ||
|
e5f7228fa9 | ||
|
11385494eb | ||
|
ae328de469 | ||
|
0574a706c8 | ||
|
70bb85a75b | ||
|
8cd901b57b | ||
|
8b9818c48e | ||
|
a95099fa46 | ||
|
221e4b7fc0 | ||
|
6cff3eb61e | ||
|
e4fd97ae77 | ||
|
5ca9099654 | ||
|
6e33e26ddf | ||
|
04461a4ab8 | ||
|
a4b9bbff54 | ||
|
4ad4252a77 | ||
|
aac0c9ab98 | ||
|
c123e1044a | ||
|
d25d0454fc | ||
|
f38984398d | ||
|
a07799cfa4 | ||
|
7c52f297ee | ||
|
50a3279b30 | ||
|
0ea14eb987 | ||
|
cf1b98e569 | ||
|
63fb435002 | ||
|
2f8263f53a | ||
|
fb649779d6 | ||
|
bb58f605f7 | ||
|
fccdf56c5d | ||
|
bd53410c71 | ||
|
7d63f124c4 | ||
|
9ffc5d857c | ||
|
2f93784acd | ||
|
d00fbe4eb3 | ||
|
51d9f041ae | ||
|
b872ab8b86 | ||
|
3d25fd79ca | ||
|
3aad78e6ef | ||
|
7d5bb72b0c | ||
|
46e5aae8bb | ||
|
b9e2ee7af3 | ||
|
c1a2892788 | ||
|
2078183e0d | ||
|
fab1d53714 | ||
|
3fe831c7d8 | ||
|
6958f71cfd | ||
|
a7351f348d | ||
|
5379e03447 | ||
|
539058e32d | ||
|
11b6b5a63c | ||
|
1155096226 | ||
|
2920dd356e | ||
|
9c3dac8170 | ||
|
49f9909b15 | ||
|
e4fef6dfc3 | ||
|
2da087401e | ||
|
629baf9de5 | ||
|
29a930dae5 | ||
|
d920537dd2 | ||
|
106b04a5da | ||
|
176752e219 | ||
|
8d19f60091 | ||
|
e937aa2f74 | ||
|
c3ccc4ccdf | ||
|
6c5cd705c0 | ||
|
ce003f217b | ||
|
8c7ef49eb6 | ||
|
29af4bd1b9 | ||
|
2ce5142b06 | ||
|
f3a8a25872 | ||
|
598e97d028 | ||
|
fa110279de | ||
|
8fdeaf73cc | ||
|
a7ffdf062a | ||
|
3bad92dd6d | ||
|
2e88024bca | ||
|
ca2301959c | ||
|
3285fae7f0 | ||
|
312079657b | ||
|
18c183afd6 | ||
|
f424d9cf20 | ||
|
5c3da9fd9e | ||
|
1f321fadd4 | ||
|
65f5d27b12 | ||
|
cdb591de7f | ||
|
a0ea3882e1 | ||
|
a9444ac702 | ||
|
d0c6afc3a9 | ||
|
e7a0a5937c | ||
|
08992b5298 | ||
|
6490a4240d | ||
|
43a7544dd7 | ||
|
0fe70dae17 | ||
|
7079e76886 | ||
|
0ec021c375 | ||
|
ff3396e286 | ||
|
78912903ce | ||
|
4c015e2d12 | ||
|
172634a55a | ||
|
58ca7d551a | ||
|
fd8ed4c9aa | ||
|
c03f5f5ff0 | ||
|
6775fc58c8 | ||
|
9f250fc61b | ||
|
94609f1419 | ||
|
53402aa5e2 | ||
|
5aadb29905 | ||
|
d4f8c41d80 | ||
|
a2e14f8b8d | ||
|
98c4ac955a | ||
|
70b63e1736 | ||
|
106665a468 | ||
|
da5e48d769 | ||
|
85f484e73c | ||
|
d287ae97f8 | ||
|
117bb602dc | ||
|
e440d55034 | ||
|
7f5b94fe43 | ||
|
c58eea6654 | ||
|
bbed5d0701 | ||
|
2775690fc8 | ||
|
1fd9f6e724 | ||
|
3d63903128 | ||
|
ef876a165a | ||
|
c4d6aaeef3 | ||
|
37b735c2e3 | ||
|
62d30c7b0e |
@@ -1,50 +0,0 @@
|
|||||||
---
|
|
||||||
engines:
|
|
||||||
csslint:
|
|
||||||
enabled: true
|
|
||||||
duplication:
|
|
||||||
enabled: true
|
|
||||||
config:
|
|
||||||
languages:
|
|
||||||
- ruby
|
|
||||||
- javascript
|
|
||||||
- python
|
|
||||||
- php
|
|
||||||
eslint:
|
|
||||||
enabled: true
|
|
||||||
fixme:
|
|
||||||
enabled: true
|
|
||||||
phpmd:
|
|
||||||
enabled: true
|
|
||||||
ratings:
|
|
||||||
paths:
|
|
||||||
- "**.css"
|
|
||||||
- "**.inc"
|
|
||||||
- "**.js"
|
|
||||||
- "**.jsx"
|
|
||||||
- "**.module"
|
|
||||||
- "**.php"
|
|
||||||
- "**.py"
|
|
||||||
- "**.rb"
|
|
||||||
exclude_paths:
|
|
||||||
- gulpfile.js
|
|
||||||
- public/packages/maximebf/php-debugbar/debugbar.js
|
|
||||||
- public/packages/maximebf/php-debugbar/widgets.js
|
|
||||||
- public/packages/maximebf/php-debugbar/openhandler.js
|
|
||||||
- public/packages/maximebf/php-debugbar/widgets/sqlqueries/widget.js
|
|
||||||
- public/js/bootstrap3-typeahead.min.js
|
|
||||||
- public/js/bootstrap-sortable.js
|
|
||||||
- public/js/bootstrap-tagsinput.min.js
|
|
||||||
- public/js/bootstrap-tagsinput.min.js.map
|
|
||||||
- public/js/daterangepicker.js
|
|
||||||
- public/js/jquery-2.1.3.min.js
|
|
||||||
- public/js/jquery-2.1.3.min.js.map
|
|
||||||
- public/js/jquery-ui.min.js
|
|
||||||
- public/js/metisMenu.js
|
|
||||||
- public/js/moment.min.js
|
|
||||||
- public/js/sb-admin-2.js
|
|
||||||
- public/bootstrap/*
|
|
||||||
- resources/lang/*
|
|
||||||
- tests/*
|
|
||||||
- database/*
|
|
||||||
- storage/*
|
|
21
.env.example
21
.env.example
@@ -1,15 +1,19 @@
|
|||||||
APP_ENV=production
|
APP_ENV=production
|
||||||
APP_DEBUG=false
|
APP_DEBUG=false
|
||||||
APP_FORCE_SSL=false
|
APP_FORCE_SSL=false
|
||||||
|
APP_FORCE_ROOT=
|
||||||
APP_KEY=SomeRandomStringOf32CharsExactly
|
APP_KEY=SomeRandomStringOf32CharsExactly
|
||||||
LOG_LEVEL=warning
|
APP_LOG_LEVEL=warning
|
||||||
|
APP_URL=http://localhost
|
||||||
|
|
||||||
DB_CONNECTION=mysql
|
DB_CONNECTION=mysql
|
||||||
DB_HOST=localhost
|
DB_HOST=127.0.0.1
|
||||||
|
DB_PORT=3306
|
||||||
DB_DATABASE=homestead
|
DB_DATABASE=homestead
|
||||||
DB_USERNAME=homestead
|
DB_USERNAME=homestead
|
||||||
DB_PASSWORD=secret
|
DB_PASSWORD=secret
|
||||||
|
|
||||||
|
BROADCAST_DRIVER=log
|
||||||
CACHE_DRIVER=file
|
CACHE_DRIVER=file
|
||||||
SESSION_DRIVER=file
|
SESSION_DRIVER=file
|
||||||
QUEUE_DRIVER=sync
|
QUEUE_DRIVER=sync
|
||||||
@@ -18,17 +22,14 @@ COOKIE_PATH="/"
|
|||||||
COOKIE_DOMAIN=
|
COOKIE_DOMAIN=
|
||||||
COOKIE_SECURE=false
|
COOKIE_SECURE=false
|
||||||
|
|
||||||
DEFAULT_CURRENCY=EUR
|
REDIS_HOST=127.0.0.1
|
||||||
DEFAULT_LANGUAGE=en_US
|
|
||||||
|
|
||||||
REDIS_HOST=localhost
|
|
||||||
REDIS_PASSWORD=null
|
REDIS_PASSWORD=null
|
||||||
REDIS_PORT=6379
|
REDIS_PORT=6379
|
||||||
|
|
||||||
MAIL_DRIVER=smtp
|
MAIL_DRIVER=smtp
|
||||||
MAIL_HOST=mailtrap.io
|
MAIL_HOST=mailtrap.io
|
||||||
MAIL_PORT=2525
|
MAIL_PORT=2525
|
||||||
MAIL_FROM=enter_your_email_here
|
MAIL_FROM=changeme@example.com
|
||||||
MAIL_USERNAME=null
|
MAIL_USERNAME=null
|
||||||
MAIL_PASSWORD=null
|
MAIL_PASSWORD=null
|
||||||
MAIL_ENCRYPTION=null
|
MAIL_ENCRYPTION=null
|
||||||
@@ -37,8 +38,10 @@ SEND_REGISTRATION_MAIL=true
|
|||||||
MUST_CONFIRM_ACCOUNT=false
|
MUST_CONFIRM_ACCOUNT=false
|
||||||
|
|
||||||
SHOW_INCOMPLETE_TRANSLATIONS=false
|
SHOW_INCOMPLETE_TRANSLATIONS=false
|
||||||
SHOW_DEMO_WARNING=false
|
|
||||||
|
|
||||||
ANALYTICS_ID=
|
ANALYTICS_ID=
|
||||||
RUNCLEANUP=true
|
|
||||||
SITE_OWNER=mail@example.com
|
SITE_OWNER=mail@example.com
|
||||||
|
|
||||||
|
PUSHER_KEY=
|
||||||
|
PUSHER_SECRET=
|
||||||
|
PUSHER_APP_ID=
|
||||||
|
38
.env.testing
38
.env.testing
@@ -1,38 +0,0 @@
|
|||||||
APP_ENV=testing
|
|
||||||
APP_DEBUG=true
|
|
||||||
APP_FORCE_SSL=false
|
|
||||||
APP_KEY=SomeRandomStringOf32CharsExactly
|
|
||||||
LOG_LEVEL=debug
|
|
||||||
|
|
||||||
DB_CONNECTION=sqlite
|
|
||||||
DB_HOST=localhost
|
|
||||||
DB_DATABASE=homestead
|
|
||||||
DB_USERNAME=homestead
|
|
||||||
DB_PASSWORD=secret
|
|
||||||
|
|
||||||
CACHE_DRIVER=array
|
|
||||||
SESSION_DRIVER=array
|
|
||||||
QUEUE_DRIVER=array
|
|
||||||
|
|
||||||
DEFAULT_CURRENCY=EUR
|
|
||||||
DEFAULT_LANGUAGE=en_US
|
|
||||||
|
|
||||||
REDIS_HOST=localhost
|
|
||||||
REDIS_PASSWORD=null
|
|
||||||
REDIS_PORT=6379
|
|
||||||
|
|
||||||
MAIL_DRIVER=log
|
|
||||||
MAIL_HOST=mailtrap.io
|
|
||||||
MAIL_PORT=2525
|
|
||||||
MAIL_FROM=your_address_here@example.com
|
|
||||||
MAIL_USERNAME=null
|
|
||||||
MAIL_PASSWORD=null
|
|
||||||
MAIL_ENCRYPTION=null
|
|
||||||
|
|
||||||
SHOW_INCOMPLETE_TRANSLATIONS=false
|
|
||||||
|
|
||||||
ANALYTICS_ID=abcde
|
|
||||||
RUNCLEANUP=false
|
|
||||||
SITE_OWNER=your_address_here@example.com
|
|
||||||
|
|
||||||
BLOCKED_DOMAINS=
|
|
2
.gitattributes
vendored
2
.gitattributes
vendored
@@ -1,3 +1,3 @@
|
|||||||
* text=auto
|
* text=auto
|
||||||
*.css linguist-vendored
|
*.css linguist-vendored
|
||||||
*.less linguist-vendored
|
*.scss linguist-vendored
|
||||||
|
7
.gitignore
vendored
Normal file → Executable file
7
.gitignore
vendored
Normal file → Executable file
@@ -1,8 +1,13 @@
|
|||||||
/vendor
|
|
||||||
/node_modules
|
/node_modules
|
||||||
|
/public/storage
|
||||||
|
/vendor
|
||||||
|
/.idea
|
||||||
|
Homestead.json
|
||||||
|
Homestead.yaml
|
||||||
.env
|
.env
|
||||||
_development
|
_development
|
||||||
.env.local
|
.env.local
|
||||||
result.html
|
result.html
|
||||||
test-import.sh
|
test-import.sh
|
||||||
test-import-report.txt
|
test-import-report.txt
|
||||||
|
public/google*.html
|
||||||
|
@@ -4,3 +4,5 @@ tools:
|
|||||||
filter:
|
filter:
|
||||||
excluded_paths:
|
excluded_paths:
|
||||||
- app/Support/Migration/*
|
- app/Support/Migration/*
|
||||||
|
- app/database/migrations/*
|
||||||
|
- database/migrations/*
|
||||||
|
91
CHANGELOG.md
91
CHANGELOG.md
@@ -2,8 +2,84 @@
|
|||||||
All notable changes to this project will be documented in this file.
|
All notable changes to this project will be documented in this file.
|
||||||
This project adheres to [Semantic Versioning](http://semver.org/).
|
This project adheres to [Semantic Versioning](http://semver.org/).
|
||||||
|
|
||||||
## [Unreleased]
|
## [4.0.0] - 2015-05-25
|
||||||
- No unreleased changes yet.
|
### Added
|
||||||
|
- Upgraded to Laravel 5.3, most other libraries upgraded as well.
|
||||||
|
- Added GBP as currency, thanks to @Mortalife
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
- Jump to version 4.0.0.
|
||||||
|
- Firefly III is now subject to a [Creative Commons Attribution-ShareAlike 4.0 International License](https://creativecommons.org/licenses/by-sa/4.0/) license. Previous versions of this software are still MIT licensed.
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
- Support for specific decimal places, thanks to @Mortalife
|
||||||
|
- Various CSS fixes
|
||||||
|
- Various bugs, thanks to @fuf, @sandermulders and @vissert
|
||||||
|
- Various queries optimized for MySQL 5.7
|
||||||
|
|
||||||
|
## [3.10.4] - 2015-09-14
|
||||||
|
### Fixed
|
||||||
|
- Migration fix by @sandermulders
|
||||||
|
- Tricky import bug fix thanks to @vissert
|
||||||
|
- Currency preference will be correctly pulled from user settings, thanks to @fuf
|
||||||
|
- Simplified code for upgrade instructions.
|
||||||
|
|
||||||
|
|
||||||
|
## [3.10.3] - 2016-08-29
|
||||||
|
### Added
|
||||||
|
- More fields for mass-edit, thanks to @Vissert (#282)
|
||||||
|
- First start of German translation
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
- More optional fields for transactions and the ability to filter them.
|
||||||
|
|
||||||
|
### Removed
|
||||||
|
- Preference for budget maximum.
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
- A bug in the translation routine broke the import.
|
||||||
|
- It was possible to destroy your Firefly installation by removing all currencies. Thanks @mondjef
|
||||||
|
- Translation bugs.
|
||||||
|
- Import bug.
|
||||||
|
|
||||||
|
### Security
|
||||||
|
- Firefly will not accept registrations beyond the first one, by default.
|
||||||
|
|
||||||
|
|
||||||
|
## [3.10.2] - 2016-08-29
|
||||||
|
### Added
|
||||||
|
- New Chinese translations. Set Firefly III to show incomplete translations to follow the progress. Want to translate Firefly III in Chinese, or in any other language? Then check out [the Crowdin project](https://crowdin.com/project/firefly-iii).
|
||||||
|
- Added more admin pages. They do nothing yet.
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
- Import routine will now also apply user rules.
|
||||||
|
- Various code cleanup.
|
||||||
|
- Some small HTML changes.
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
- Bug in the mass edit routines.
|
||||||
|
- Firefly III over a proxy will now work (see [issue #290](https://github.com/JC5/firefly-iii/issues/290)), thanks @dfiel for reporting.
|
||||||
|
- Sneaky bug in the import routine, fixed by @Bonno
|
||||||
|
|
||||||
|
## [3.10.1] - 2016-08-25
|
||||||
|
### Added
|
||||||
|
- More feedback in the import procedure.
|
||||||
|
- Extended model for import job.
|
||||||
|
- Web bases import procedure.
|
||||||
|
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
- Scrutinizer configuration
|
||||||
|
- Various code clean up.
|
||||||
|
|
||||||
|
### Removed
|
||||||
|
- Code climate YAML file.
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
- Fixed a bug where a migration would check an empty table name.
|
||||||
|
- Fixed various bugs in the import routine.
|
||||||
|
- Fixed various bugs in the piggy banks pages.
|
||||||
|
- Fixed a bug in the ``firefly:verify`` routine
|
||||||
|
|
||||||
## [3.10] - 2015-05-25
|
## [3.10] - 2015-05-25
|
||||||
### Added
|
### Added
|
||||||
@@ -18,13 +94,6 @@ This project adheres to [Semantic Versioning](http://semver.org/).
|
|||||||
- The date picker now supports more ranges and periods.
|
- The date picker now supports more ranges and periods.
|
||||||
- Rewrote all migrations. #272
|
- Rewrote all migrations. #272
|
||||||
|
|
||||||
|
|
||||||
### Deprecated
|
|
||||||
- Initial release.
|
|
||||||
|
|
||||||
### Removed
|
|
||||||
- Initial release.
|
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
- Issue #264
|
- Issue #264
|
||||||
- Issue #265
|
- Issue #265
|
||||||
@@ -39,10 +108,6 @@ This project adheres to [Semantic Versioning](http://semver.org/).
|
|||||||
- Bulk update problems, #280, thanks @stickgrinder
|
- Bulk update problems, #280, thanks @stickgrinder
|
||||||
- Fixed various problems with amount reporting of split transactions.
|
- Fixed various problems with amount reporting of split transactions.
|
||||||
|
|
||||||
### Security
|
|
||||||
- Initial release.
|
|
||||||
|
|
||||||
|
|
||||||
[3.9.1]
|
[3.9.1]
|
||||||
### Fixed
|
### Fixed
|
||||||
- Fixed a bug where removing money from a piggy bank would not work. See issue #265 and #269
|
- Fixed a bug where removing money from a piggy bank would not work. See issue #265 and #269
|
||||||
|
4
LICENSE
4
LICENSE
@@ -1,7 +1,7 @@
|
|||||||
Copyright (C) 2016 thegrumpydictator@gmail.com
|
Copyright (C) 2016 thegrumpydictator@gmail.com
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
https://creativecommons.org/licenses/by-sa/4.0/
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
@@ -22,24 +22,40 @@ use Illuminate\Log\Writer;
|
|||||||
*/
|
*/
|
||||||
class ConfigureLogging extends IlluminateConfigureLogging
|
class ConfigureLogging extends IlluminateConfigureLogging
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Application $app
|
* Configure the Monolog handlers for the application.
|
||||||
* @param Writer $log
|
*
|
||||||
|
* @param \Illuminate\Contracts\Foundation\Application $app
|
||||||
|
* @param \Illuminate\Log\Writer $log
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
protected function configureDailyHandler(Application $app, Writer $log)
|
protected function configureDailyHandler(Application $app, Writer $log)
|
||||||
{
|
{
|
||||||
|
$config = $app->make('config');
|
||||||
|
|
||||||
|
$maxFiles = $config->get('app.log_max_files');
|
||||||
|
|
||||||
$log->useDailyFiles(
|
$log->useDailyFiles(
|
||||||
$app->storagePath() . '/logs/firefly-iii.log',
|
$app->storagePath() . '/logs/firefly-iii.log', is_null($maxFiles) ? 5 : $maxFiles,
|
||||||
$app->make('config')->get('app.log_max_files', 5)
|
$config->get('app.log_level', 'debug')
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Application $app
|
* Configure the Monolog handlers for the application.
|
||||||
* @param Writer $log
|
*
|
||||||
|
* @param \Illuminate\Contracts\Foundation\Application $app
|
||||||
|
* @param \Illuminate\Log\Writer $log
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
protected function configureSingleHandler(Application $app, Writer $log)
|
protected function configureSingleHandler(Application $app, Writer $log)
|
||||||
{
|
{
|
||||||
$log->useFiles($app->storagePath() . '/logs/firefly-iii.log');
|
$log->useFiles(
|
||||||
|
$app->storagePath() . '/logs/firefly-iii.log',
|
||||||
|
$app->make('config')->get('app.log_level', 'debug')
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -46,8 +46,6 @@ class EncryptFile extends Command
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Execute the console command.
|
* Execute the console command.
|
||||||
*
|
|
||||||
* @return mixed
|
|
||||||
*/
|
*/
|
||||||
public function handle()
|
public function handle()
|
||||||
{
|
{
|
||||||
@@ -64,6 +62,5 @@ class EncryptFile extends Command
|
|||||||
$path = storage_path('upload') . '/' . $newName;
|
$path = storage_path('upload') . '/' . $newName;
|
||||||
file_put_contents($path, $content);
|
file_put_contents($path, $content);
|
||||||
$this->line(sprintf('Encrypted "%s" and put it in "%s"', $file, $path));
|
$this->line(sprintf('Encrypted "%s" and put it in "%s"', $file, $path));
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -11,12 +11,10 @@ declare(strict_types = 1);
|
|||||||
|
|
||||||
namespace FireflyIII\Console\Commands;
|
namespace FireflyIII\Console\Commands;
|
||||||
|
|
||||||
use FireflyIII\Crud\Account\AccountCrud;
|
use FireflyIII\Import\ImportProcedure;
|
||||||
use FireflyIII\Import\Importer\ImporterInterface;
|
|
||||||
use FireflyIII\Import\ImportStorage;
|
|
||||||
use FireflyIII\Import\ImportValidator;
|
|
||||||
use FireflyIII\Import\Logging\CommandHandler;
|
use FireflyIII\Import\Logging\CommandHandler;
|
||||||
use FireflyIII\Models\ImportJob;
|
use FireflyIII\Models\ImportJob;
|
||||||
|
use FireflyIII\Models\TransactionJournal;
|
||||||
use Illuminate\Console\Command;
|
use Illuminate\Console\Command;
|
||||||
use Log;
|
use Log;
|
||||||
|
|
||||||
@@ -59,55 +57,64 @@ class Import extends Command
|
|||||||
{
|
{
|
||||||
$jobKey = $this->argument('key');
|
$jobKey = $this->argument('key');
|
||||||
$job = ImportJob::whereKey($jobKey)->first();
|
$job = ImportJob::whereKey($jobKey)->first();
|
||||||
|
if (!$this->isValid($job)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->line('Going to import job with key "' . $job->key . '" of type ' . $job->file_type);
|
||||||
|
|
||||||
|
$monolog = Log::getMonolog();
|
||||||
|
$handler = new CommandHandler($this);
|
||||||
|
$monolog->pushHandler($handler);
|
||||||
|
|
||||||
|
$result = ImportProcedure::runImport($job);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var int $index
|
||||||
|
* @var TransactionJournal $journal
|
||||||
|
*/
|
||||||
|
foreach ($result as $index => $journal) {
|
||||||
|
if (!is_null($journal->id)) {
|
||||||
|
$this->line(sprintf('Line #%d has been imported as transaction #%d.', $index, $journal->id));
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
$this->error(sprintf('Could not store line #%d', $index));
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->line('The import has completed.');
|
||||||
|
|
||||||
|
// get any errors from the importer:
|
||||||
|
$extendedStatus = $job->extended_status;
|
||||||
|
if (isset($extendedStatus['errors']) && count($extendedStatus['errors']) > 0) {
|
||||||
|
$this->line(sprintf('The following %d error(s) occured during the import:', count($extendedStatus['errors'])));
|
||||||
|
foreach ($extendedStatus['errors'] as $error) {
|
||||||
|
$this->error($error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param ImportJob $job
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
private function isValid(ImportJob $job): bool
|
||||||
|
{
|
||||||
if (is_null($job)) {
|
if (is_null($job)) {
|
||||||
$this->error('This job does not seem to exist.');
|
$this->error('This job does not seem to exist.');
|
||||||
|
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($job->status != 'settings_complete') {
|
if ($job->status != 'settings_complete') {
|
||||||
$this->error('This job is not ready to be imported.');
|
$this->error('This job is not ready to be imported.');
|
||||||
|
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->line('Going to import job with key "' . $job->key . '" of type ' . $job->file_type);
|
return true;
|
||||||
$valid = array_keys(config('firefly.import_formats'));
|
|
||||||
$class = 'INVALID';
|
|
||||||
if (in_array($job->file_type, $valid)) {
|
|
||||||
$class = config('firefly.import_formats.' . $job->file_type);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** @var ImporterInterface $importer */
|
|
||||||
$importer = app($class);
|
|
||||||
$importer->setJob($job);
|
|
||||||
// intercept logging by importer.
|
|
||||||
$monolog = Log::getMonolog();
|
|
||||||
$handler = new CommandHandler($this);
|
|
||||||
|
|
||||||
$monolog->pushHandler($handler);
|
|
||||||
|
|
||||||
// create import entries
|
|
||||||
$collection = $importer->createImportEntries();
|
|
||||||
|
|
||||||
// validate / clean collection:
|
|
||||||
$validator = new ImportValidator($collection);
|
|
||||||
$validator->setUser($job->user);
|
|
||||||
if ($job->configuration['import-account'] != 0) {
|
|
||||||
$repository = app(AccountCrud::class, [$job->user]);
|
|
||||||
$validator->setDefaultImportAccount($repository->find($job->configuration['import-account']));
|
|
||||||
}
|
|
||||||
|
|
||||||
$cleaned = $validator->clean();
|
|
||||||
|
|
||||||
// then import collection:
|
|
||||||
$storage = new ImportStorage($cleaned);
|
|
||||||
$storage->setUser($job->user);
|
|
||||||
|
|
||||||
// and run store routine:
|
|
||||||
$storage->store();
|
|
||||||
|
|
||||||
|
|
||||||
$this->line('Something something import: ' . $jobKey);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
99
app/Console/Commands/ScanAttachments.php
Normal file
99
app/Console/Commands/ScanAttachments.php
Normal file
@@ -0,0 +1,99 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* ScanAttachments.php
|
||||||
|
* Copyright (C) 2016 thegrumpydictator@gmail.com
|
||||||
|
*
|
||||||
|
* This software may be modified and distributed under the terms
|
||||||
|
* of the MIT license. See the LICENSE file for details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
declare(strict_types = 1);
|
||||||
|
|
||||||
|
namespace FireflyIII\Console\Commands;
|
||||||
|
|
||||||
|
use Crypt;
|
||||||
|
use FireflyIII\Models\Attachment;
|
||||||
|
use Illuminate\Console\Command;
|
||||||
|
use Illuminate\Contracts\Encryption\DecryptException;
|
||||||
|
use Illuminate\Contracts\Filesystem\FileNotFoundException;
|
||||||
|
use Storage;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class ScanAttachments
|
||||||
|
*
|
||||||
|
* @package FireflyIII\Console\Commands
|
||||||
|
*/
|
||||||
|
class ScanAttachments extends Command
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The console command description.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $description = 'Rescan all attachments and re-set the MD5 hash and mime.';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The name and signature of the console command.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $signature = 'firefly:scan-attachments';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new command instance.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
parent::__construct();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Execute the console command.
|
||||||
|
*/
|
||||||
|
public function handle()
|
||||||
|
{
|
||||||
|
$attachments = Attachment::get();
|
||||||
|
$disk = Storage::disk('upload');
|
||||||
|
/** @var Attachment $attachment */
|
||||||
|
foreach ($attachments as $attachment) {
|
||||||
|
$fileName = $attachment->fileName();
|
||||||
|
|
||||||
|
// try to grab file content:
|
||||||
|
try {
|
||||||
|
$content = $disk->get($fileName);
|
||||||
|
} catch (FileNotFoundException $e) {
|
||||||
|
$this->error(sprintf('Could not find data for attachment #%d', $attachment->id));
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
// try to decrypt content.
|
||||||
|
try {
|
||||||
|
$decrypted = Crypt::decrypt($content);
|
||||||
|
} catch (DecryptException $e) {
|
||||||
|
$this->error(sprintf('Could not decrypt data of attachment #%d', $attachment->id));
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// make temp file:
|
||||||
|
$tmpfname = tempnam(sys_get_temp_dir(), 'FireflyIII');
|
||||||
|
|
||||||
|
// store content in temp file:
|
||||||
|
file_put_contents($tmpfname, $decrypted);
|
||||||
|
|
||||||
|
// get md5 and mime
|
||||||
|
$md5 = md5_file($tmpfname);
|
||||||
|
$mime = mime_content_type($tmpfname);
|
||||||
|
|
||||||
|
// update attachment:
|
||||||
|
$attachment->md5 = $md5;
|
||||||
|
$attachment->mime = $mime;
|
||||||
|
$attachment->save();
|
||||||
|
|
||||||
|
|
||||||
|
$this->line(sprintf('Fixed attachment #%d', $attachment->id));
|
||||||
|
|
||||||
|
// find file:
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@@ -44,8 +44,6 @@ class UpgradeFireflyInstructions extends Command
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Execute the console command.
|
* Execute the console command.
|
||||||
*
|
|
||||||
* @return mixed
|
|
||||||
*/
|
*/
|
||||||
public function handle()
|
public function handle()
|
||||||
{
|
{
|
||||||
@@ -53,15 +51,22 @@ class UpgradeFireflyInstructions extends Command
|
|||||||
/** @var string $version */
|
/** @var string $version */
|
||||||
$version = config('firefly.version');
|
$version = config('firefly.version');
|
||||||
$config = config('upgrade.text');
|
$config = config('upgrade.text');
|
||||||
$text = $config[$version] ?? null;
|
$text = null;
|
||||||
|
foreach (array_keys($config) as $compare) {
|
||||||
|
// if string starts with:
|
||||||
|
$len = strlen($compare);
|
||||||
|
if (substr($version, 0, $len) === $compare) {
|
||||||
|
$text = $config[$compare];
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
$this->line('+------------------------------------------------------------------------------+');
|
$this->line('+------------------------------------------------------------------------------+');
|
||||||
$this->line('');
|
$this->line('');
|
||||||
|
|
||||||
if (is_null($text)) {
|
if (is_null($text)) {
|
||||||
$this->line('Thank you for installing Firefly III, v' . $version);
|
$this->line('Thank you for installing Firefly III, v' . $version);
|
||||||
$this->line('If you are upgrading from a previous version,');
|
$this->info('There are no extra upgrade instructions.');
|
||||||
$this->info('there are no extra upgrade instructions.');
|
|
||||||
$this->line('Firefly III should be ready for use.');
|
$this->line('Firefly III should be ready for use.');
|
||||||
} else {
|
} else {
|
||||||
$this->line('Thank you for installing Firefly III, v' . $version);
|
$this->line('Thank you for installing Firefly III, v' . $version);
|
||||||
|
@@ -12,13 +12,13 @@ declare(strict_types = 1);
|
|||||||
namespace FireflyIII\Console\Commands;
|
namespace FireflyIII\Console\Commands;
|
||||||
|
|
||||||
use Crypt;
|
use Crypt;
|
||||||
use DB;
|
|
||||||
use FireflyIII\Models\Account;
|
use FireflyIII\Models\Account;
|
||||||
use FireflyIII\Models\Budget;
|
use FireflyIII\Models\Budget;
|
||||||
use FireflyIII\Models\Category;
|
use FireflyIII\Models\Category;
|
||||||
use FireflyIII\Models\Tag;
|
use FireflyIII\Models\Tag;
|
||||||
use FireflyIII\Models\Transaction;
|
use FireflyIII\Models\Transaction;
|
||||||
use FireflyIII\Models\TransactionJournal;
|
use FireflyIII\Models\TransactionJournal;
|
||||||
|
use FireflyIII\Models\TransactionType;
|
||||||
use FireflyIII\Repositories\User\UserRepositoryInterface;
|
use FireflyIII\Repositories\User\UserRepositoryInterface;
|
||||||
use FireflyIII\User;
|
use FireflyIII\User;
|
||||||
use Illuminate\Console\Command;
|
use Illuminate\Console\Command;
|
||||||
@@ -55,8 +55,6 @@ class VerifyDatabase extends Command
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Execute the console command.
|
* Execute the console command.
|
||||||
*
|
|
||||||
* @return mixed
|
|
||||||
*/
|
*/
|
||||||
public function handle()
|
public function handle()
|
||||||
{
|
{
|
||||||
@@ -81,6 +79,9 @@ class VerifyDatabase extends Command
|
|||||||
|
|
||||||
// report on journals with no transactions at all.
|
// report on journals with no transactions at all.
|
||||||
$this->reportNoTransactions();
|
$this->reportNoTransactions();
|
||||||
|
|
||||||
|
// transfers with budgets.
|
||||||
|
$this->reportTransfersBudgets();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -91,14 +92,17 @@ class VerifyDatabase extends Command
|
|||||||
$set = Account
|
$set = Account
|
||||||
::leftJoin('transactions', 'transactions.account_id', '=', 'accounts.id')
|
::leftJoin('transactions', 'transactions.account_id', '=', 'accounts.id')
|
||||||
->leftJoin('users', 'accounts.user_id', '=', 'users.id')
|
->leftJoin('users', 'accounts.user_id', '=', 'users.id')
|
||||||
->groupBy('accounts.id')
|
->groupBy(['accounts.id', 'accounts.encrypted', 'accounts.name', 'accounts.user_id', 'users.email'])
|
||||||
->having('transaction_count', '=', 0)
|
->whereNull('transactions.account_id')
|
||||||
->get(['accounts.id', 'accounts.name', 'accounts.user_id', 'users.email', DB::raw('COUNT(`transactions`.`id`) AS `transaction_count`')]);
|
->get(
|
||||||
|
['accounts.id', 'accounts.encrypted', 'accounts.name', 'accounts.user_id', 'users.email']
|
||||||
|
);
|
||||||
|
|
||||||
/** @var stdClass $entry */
|
/** @var stdClass $entry */
|
||||||
foreach ($set as $entry) {
|
foreach ($set as $entry) {
|
||||||
$line = 'User #' . $entry->user_id . ' (' . $entry->email . ') has account #' . $entry->id . ' ("' . Crypt::decrypt($entry->name)
|
$name = $entry->name;
|
||||||
. '") which has no transactions.';
|
$line = 'User #%d (%s) has account #%d ("%s") which has no transactions.';
|
||||||
|
$line = sprintf($line, $entry->user_id, $entry->email, $entry->id, $name);
|
||||||
$this->line($line);
|
$this->line($line);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -111,9 +115,9 @@ class VerifyDatabase extends Command
|
|||||||
$set = Budget
|
$set = Budget
|
||||||
::leftJoin('budget_limits', 'budget_limits.budget_id', '=', 'budgets.id')
|
::leftJoin('budget_limits', 'budget_limits.budget_id', '=', 'budgets.id')
|
||||||
->leftJoin('users', 'budgets.user_id', '=', 'users.id')
|
->leftJoin('users', 'budgets.user_id', '=', 'users.id')
|
||||||
->groupBy('budgets.id')
|
->groupBy(['budgets.id', 'budgets.name', 'budgets.user_id', 'users.email'])
|
||||||
->having('budget_limit_count', '=', 0)
|
->whereNull('budget_limits.id')
|
||||||
->get(['budgets.id', 'budgets.name', 'budgets.user_id', 'users.email', DB::raw('COUNT(`budget_limits`.`id`) AS `budget_limit_count`')]);
|
->get(['budgets.id', 'budgets.name', 'budgets.user_id', 'users.email']);
|
||||||
|
|
||||||
/** @var stdClass $entry */
|
/** @var stdClass $entry */
|
||||||
foreach ($set as $entry) {
|
foreach ($set as $entry) {
|
||||||
@@ -223,19 +227,16 @@ class VerifyDatabase extends Command
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
private function reportNoTransactions()
|
private function reportNoTransactions()
|
||||||
{
|
{
|
||||||
/*
|
|
||||||
* select transaction_journals.id, count(transactions.id) as transaction_count from transaction_journals
|
|
||||||
left join transactions ON transaction_journals.id = transactions.transaction_journal_id
|
|
||||||
group by transaction_journals.id
|
|
||||||
having transaction_count = 0
|
|
||||||
*/
|
|
||||||
$set = TransactionJournal
|
$set = TransactionJournal
|
||||||
::leftJoin('transactions', 'transactions.transaction_journal_id', '=', 'transaction_journals.id')
|
::leftJoin('transactions', 'transactions.transaction_journal_id', '=', 'transaction_journals.id')
|
||||||
->groupBy('transaction_journals.id')
|
->groupBy('transaction_journals.id')
|
||||||
->having('transaction_count', '=', 0)
|
->whereNull('transactions.transaction_journal_id')
|
||||||
->get(['transaction_journals.id', DB::raw('COUNT(`transactions`.`id`) as `transaction_count`')]);
|
->get(['transaction_journals.id']);
|
||||||
|
|
||||||
foreach ($set as $entry) {
|
foreach ($set as $entry) {
|
||||||
$this->error(
|
$this->error(
|
||||||
@@ -304,4 +305,29 @@ having transaction_count = 0
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private function reportTransfersBudgets()
|
||||||
|
{
|
||||||
|
$set = TransactionJournal
|
||||||
|
::distinct()
|
||||||
|
->leftJoin('transaction_types', 'transaction_types.id', '=', 'transaction_journals.transaction_type_id')
|
||||||
|
->leftJoin('budget_transaction_journal', 'transaction_journals.id', '=', 'budget_transaction_journal.transaction_journal_id')
|
||||||
|
->where('transaction_types.type', TransactionType::TRANSFER)
|
||||||
|
->whereNotNull('budget_transaction_journal.budget_id')->get(['transaction_journals.id']);
|
||||||
|
|
||||||
|
/** @var TransactionJournal $entry */
|
||||||
|
foreach ($set as $entry) {
|
||||||
|
$this->error(
|
||||||
|
sprintf(
|
||||||
|
'Error: Transaction journal #%d is a transfer, but has a budget. Edit it without changing anything, so the budget will be removed.',
|
||||||
|
$entry->id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
28
app/Console/Kernel.php
Normal file → Executable file
28
app/Console/Kernel.php
Normal file → Executable file
@@ -13,8 +13,10 @@ namespace FireflyIII\Console;
|
|||||||
|
|
||||||
use FireflyIII\Console\Commands\EncryptFile;
|
use FireflyIII\Console\Commands\EncryptFile;
|
||||||
use FireflyIII\Console\Commands\Import;
|
use FireflyIII\Console\Commands\Import;
|
||||||
|
use FireflyIII\Console\Commands\ScanAttachments;
|
||||||
use FireflyIII\Console\Commands\UpgradeFireflyInstructions;
|
use FireflyIII\Console\Commands\UpgradeFireflyInstructions;
|
||||||
use FireflyIII\Console\Commands\VerifyDatabase;
|
use FireflyIII\Console\Commands\VerifyDatabase;
|
||||||
|
use Illuminate\Console\Scheduling\Schedule;
|
||||||
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
|
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -24,11 +26,10 @@ use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
|
|||||||
*/
|
*/
|
||||||
class Kernel extends ConsoleKernel
|
class Kernel extends ConsoleKernel
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The bootstrap classes for the application.
|
* The bootstrap classes for the application.
|
||||||
*
|
*
|
||||||
* This needs to be for with the next upgrade.
|
* Next upgrade verify these are the same.
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
@@ -55,5 +56,28 @@ class Kernel extends ConsoleKernel
|
|||||||
VerifyDatabase::class,
|
VerifyDatabase::class,
|
||||||
Import::class,
|
Import::class,
|
||||||
EncryptFile::class,
|
EncryptFile::class,
|
||||||
|
ScanAttachments::class,
|
||||||
|
|
||||||
];
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Register the Closure based commands for the application.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
protected function commands()
|
||||||
|
{
|
||||||
|
require base_path('routes/console.php');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Define the application's command schedule.
|
||||||
|
*
|
||||||
|
* @param \Illuminate\Console\Scheduling\Schedule $schedule
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
protected function schedule(Schedule $schedule)
|
||||||
|
{
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -27,6 +27,8 @@ use Log;
|
|||||||
/**
|
/**
|
||||||
* Class AccountCrud
|
* Class AccountCrud
|
||||||
*
|
*
|
||||||
|
* @SuppressWarnings(PHPMD.ExcessiveClassComplexity)
|
||||||
|
*
|
||||||
* @package FireflyIII\Crud\Account
|
* @package FireflyIII\Crud\Account
|
||||||
*/
|
*/
|
||||||
class AccountCrud implements AccountCrudInterface
|
class AccountCrud implements AccountCrudInterface
|
||||||
@@ -56,15 +58,12 @@ class AccountCrud implements AccountCrudInterface
|
|||||||
public function destroy(Account $account, Account $moveTo): bool
|
public function destroy(Account $account, Account $moveTo): bool
|
||||||
{
|
{
|
||||||
if (!is_null($moveTo->id)) {
|
if (!is_null($moveTo->id)) {
|
||||||
// update all transactions:
|
|
||||||
DB::table('transactions')->where('account_id', $account->id)->update(['account_id' => $moveTo->id]);
|
DB::table('transactions')->where('account_id', $account->id)->update(['account_id' => $moveTo->id]);
|
||||||
}
|
}
|
||||||
if (!is_null($account)) {
|
if (!is_null($account)) {
|
||||||
Log::debug('Now trigger account delete #' . $account->id);
|
|
||||||
$account->delete();
|
$account->delete();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -75,7 +74,6 @@ class AccountCrud implements AccountCrudInterface
|
|||||||
*/
|
*/
|
||||||
public function find(int $accountId): Account
|
public function find(int $accountId): Account
|
||||||
{
|
{
|
||||||
Log::debug('Searching for user ', ['user' => $this->user->id]);
|
|
||||||
$account = $this->user->accounts()->find($accountId);
|
$account = $this->user->accounts()->find($accountId);
|
||||||
if (is_null($account)) {
|
if (is_null($account)) {
|
||||||
return new Account;
|
return new Account;
|
||||||
@@ -146,24 +144,24 @@ class AccountCrud implements AccountCrudInterface
|
|||||||
public function findByName(string $name, array $types): Account
|
public function findByName(string $name, array $types): Account
|
||||||
{
|
{
|
||||||
$query = $this->user->accounts();
|
$query = $this->user->accounts();
|
||||||
Log::debug('Now in findByName()', ['name' => $name, 'types' => $types]);
|
|
||||||
|
|
||||||
if (count($types) > 0) {
|
if (count($types) > 0) {
|
||||||
$query->leftJoin('account_types', 'accounts.account_type_id', '=', 'account_types.id');
|
$query->leftJoin('account_types', 'accounts.account_type_id', '=', 'account_types.id');
|
||||||
$query->whereIn('account_types.type', $types);
|
$query->whereIn('account_types.type', $types);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Log::debug(sprintf('Searching for account named %s of the following type(s)', $name), ['types' => $types]);
|
||||||
|
|
||||||
$accounts = $query->get(['accounts.*']);
|
$accounts = $query->get(['accounts.*']);
|
||||||
Log::debug(sprintf('Total set count is %d ', $accounts->count()));
|
|
||||||
/** @var Account $account */
|
/** @var Account $account */
|
||||||
foreach ($accounts as $account) {
|
foreach ($accounts as $account) {
|
||||||
if ($account->name === $name) {
|
if ($account->name === $name) {
|
||||||
Log::debug('Account name is an exact match. ', ['db' => $account->name, 'source' => $name, 'id' => $account->id]);
|
Log::debug(sprintf('Found #%d (%s) with type id %d', $account->id, $account->name, $account->account_type_id));
|
||||||
|
|
||||||
return $account;
|
return $account;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Log::debug('Found nothing in findByName()', ['name' => $name, 'types' => $types]);
|
Log::debug('Found nothing.');
|
||||||
|
|
||||||
return new Account;
|
return new Account;
|
||||||
}
|
}
|
||||||
@@ -187,7 +185,6 @@ class AccountCrud implements AccountCrudInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
$result = $query->get(['accounts.*']);
|
$result = $query->get(['accounts.*']);
|
||||||
|
|
||||||
$result = $result->sortBy(
|
$result = $result->sortBy(
|
||||||
function (Account $account) {
|
function (Account $account) {
|
||||||
return strtolower($account->name);
|
return strtolower($account->name);
|
||||||
@@ -215,7 +212,6 @@ class AccountCrud implements AccountCrudInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
$result = $query->get(['accounts.*']);
|
$result = $query->get(['accounts.*']);
|
||||||
|
|
||||||
$result = $result->sortBy(
|
$result = $result->sortBy(
|
||||||
function (Account $account) {
|
function (Account $account) {
|
||||||
return strtolower($account->name);
|
return strtolower($account->name);
|
||||||
@@ -229,8 +225,6 @@ class AccountCrud implements AccountCrudInterface
|
|||||||
* @param array $data
|
* @param array $data
|
||||||
*
|
*
|
||||||
* @return Account
|
* @return Account
|
||||||
*
|
|
||||||
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
|
|
||||||
*/
|
*/
|
||||||
public function store(array $data): Account
|
public function store(array $data): Account
|
||||||
{
|
{
|
||||||
@@ -330,6 +324,7 @@ class AccountCrud implements AccountCrudInterface
|
|||||||
$existingAccount = Account::firstOrNullEncrypted($searchData);
|
$existingAccount = Account::firstOrNullEncrypted($searchData);
|
||||||
if (!$existingAccount) {
|
if (!$existingAccount) {
|
||||||
Log::error('Account create error', $newAccount->getErrors()->toArray());
|
Log::error('Account create error', $newAccount->getErrors()->toArray());
|
||||||
|
|
||||||
return new Account;
|
return new Account;
|
||||||
}
|
}
|
||||||
$newAccount = $existingAccount;
|
$newAccount = $existingAccount;
|
||||||
@@ -402,8 +397,6 @@ class AccountCrud implements AccountCrudInterface
|
|||||||
);
|
);
|
||||||
$metaData->save();
|
$metaData->save();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
33
app/Exceptions/Handler.php
Normal file → Executable file
33
app/Exceptions/Handler.php
Normal file → Executable file
@@ -10,14 +10,15 @@
|
|||||||
declare(strict_types = 1);
|
declare(strict_types = 1);
|
||||||
namespace FireflyIII\Exceptions;
|
namespace FireflyIII\Exceptions;
|
||||||
|
|
||||||
use Auth;
|
|
||||||
use ErrorException;
|
use ErrorException;
|
||||||
use Exception;
|
use Exception;
|
||||||
use FireflyIII\Jobs\MailError;
|
use FireflyIII\Jobs\MailError;
|
||||||
use Illuminate\Auth\Access\AuthorizationException;
|
use Illuminate\Auth\Access\AuthorizationException;
|
||||||
|
use Illuminate\Auth\AuthenticationException;
|
||||||
use Illuminate\Database\Eloquent\ModelNotFoundException;
|
use Illuminate\Database\Eloquent\ModelNotFoundException;
|
||||||
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
|
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
|
||||||
use Request;
|
use Illuminate\Session\TokenMismatchException;
|
||||||
|
use Illuminate\Validation\ValidationException as ValException;
|
||||||
use Symfony\Component\HttpKernel\Exception\HttpException;
|
use Symfony\Component\HttpKernel\Exception\HttpException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -34,9 +35,12 @@ class Handler extends ExceptionHandler
|
|||||||
*/
|
*/
|
||||||
protected $dontReport
|
protected $dontReport
|
||||||
= [
|
= [
|
||||||
|
AuthenticationException::class,
|
||||||
AuthorizationException::class,
|
AuthorizationException::class,
|
||||||
HttpException::class,
|
HttpException::class,
|
||||||
ModelNotFoundException::class,
|
ModelNotFoundException::class,
|
||||||
|
TokenMismatchException::class,
|
||||||
|
ValException::class,
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -71,15 +75,14 @@ class Handler extends ExceptionHandler
|
|||||||
*/
|
*/
|
||||||
public function report(Exception $exception)
|
public function report(Exception $exception)
|
||||||
{
|
{
|
||||||
|
|
||||||
if ($exception instanceof FireflyException || $exception instanceof ErrorException) {
|
if ($exception instanceof FireflyException || $exception instanceof ErrorException) {
|
||||||
$userData = [
|
$userData = [
|
||||||
'id' => 0,
|
'id' => 0,
|
||||||
'email' => 'unknown@example.com',
|
'email' => 'unknown@example.com',
|
||||||
];
|
];
|
||||||
if (Auth::check()) {
|
if (auth()->check()) {
|
||||||
$userData['id'] = Auth::user()->id;
|
$userData['id'] = auth()->user()->id;
|
||||||
$userData['email'] = Auth::user()->email;
|
$userData['email'] = auth()->user()->email;
|
||||||
}
|
}
|
||||||
$data = [
|
$data = [
|
||||||
'class' => get_class($exception),
|
'class' => get_class($exception),
|
||||||
@@ -92,10 +95,26 @@ class Handler extends ExceptionHandler
|
|||||||
];
|
];
|
||||||
|
|
||||||
// create job that will mail.
|
// create job that will mail.
|
||||||
$job = new MailError($userData, env('SITE_OWNER'), Request::ip(), $data);
|
$ip = $_SERVER['REMOTE_ADDR'] ?? '0.0.0.0';
|
||||||
|
$job = new MailError($userData, env('SITE_OWNER', ''), $ip, $data);
|
||||||
dispatch($job);
|
dispatch($job);
|
||||||
}
|
}
|
||||||
|
|
||||||
parent::report($exception);
|
parent::report($exception);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert an authentication exception into an unauthenticated response.
|
||||||
|
*
|
||||||
|
* @param \Illuminate\Http\Request $request
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
protected function unauthenticated($request)
|
||||||
|
{
|
||||||
|
if ($request->expectsJson()) {
|
||||||
|
return response()->json(['error' => 'Unauthenticated.'], 401);
|
||||||
|
}
|
||||||
|
|
||||||
|
return redirect()->guest('login');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -92,6 +92,7 @@ class AttachmentCollector extends BasicCollector implements CollectorInterface
|
|||||||
'amount' => Amount::formatJournal($journal, false),
|
'amount' => Amount::formatJournal($journal, false),
|
||||||
];
|
];
|
||||||
$string = trans('firefly.attachment_explanation', $args) . "\n";
|
$string = trans('firefly.attachment_explanation', $args) . "\n";
|
||||||
|
Log::debug('Appended explanation string', ['string' => $string]);
|
||||||
$this->explanationString .= $string;
|
$this->explanationString .= $string;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -11,7 +11,6 @@ declare(strict_types = 1);
|
|||||||
|
|
||||||
namespace FireflyIII\Export\Collector;
|
namespace FireflyIII\Export\Collector;
|
||||||
|
|
||||||
use Auth;
|
|
||||||
use Crypt;
|
use Crypt;
|
||||||
use FireflyIII\Models\ExportJob;
|
use FireflyIII\Models\ExportJob;
|
||||||
use Illuminate\Contracts\Encryption\DecryptException;
|
use Illuminate\Contracts\Encryption\DecryptException;
|
||||||
@@ -29,6 +28,7 @@ class UploadCollector extends BasicCollector implements CollectorInterface
|
|||||||
private $expected;
|
private $expected;
|
||||||
/** @var \Illuminate\Contracts\Filesystem\Filesystem */
|
/** @var \Illuminate\Contracts\Filesystem\Filesystem */
|
||||||
private $exportDisk;
|
private $exportDisk;
|
||||||
|
private $importKeys = [];
|
||||||
/** @var \Illuminate\Contracts\Filesystem\Filesystem */
|
/** @var \Illuminate\Contracts\Filesystem\Filesystem */
|
||||||
private $uploadDisk;
|
private $uploadDisk;
|
||||||
|
|
||||||
@@ -42,10 +42,17 @@ class UploadCollector extends BasicCollector implements CollectorInterface
|
|||||||
{
|
{
|
||||||
parent::__construct($job);
|
parent::__construct($job);
|
||||||
|
|
||||||
|
Log::debug('Going to collect attachments', ['key' => $job->key]);
|
||||||
|
|
||||||
// make storage:
|
// make storage:
|
||||||
$this->uploadDisk = Storage::disk('upload');
|
$this->uploadDisk = Storage::disk('upload');
|
||||||
$this->exportDisk = Storage::disk('export');
|
$this->exportDisk = Storage::disk('export');
|
||||||
$this->expected = 'csv-upload-' . Auth::user()->id . '-';
|
|
||||||
|
// file names associated with the old import routine.
|
||||||
|
$this->expected = 'csv-upload-' . auth()->user()->id . '-';
|
||||||
|
|
||||||
|
// for the new import routine:
|
||||||
|
$this->getImportKeys();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -57,12 +64,26 @@ class UploadCollector extends BasicCollector implements CollectorInterface
|
|||||||
$files = $this->uploadDisk->files();
|
$files = $this->uploadDisk->files();
|
||||||
|
|
||||||
foreach ($files as $entry) {
|
foreach ($files as $entry) {
|
||||||
$this->processOldUpload($entry);
|
$this->processUpload($entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private function getImportKeys()
|
||||||
|
{
|
||||||
|
$set = auth()->user()->importJobs()->where('status', 'import_complete')->get(['import_jobs.*']);
|
||||||
|
if ($set->count() > 0) {
|
||||||
|
$keys = $set->pluck('key')->toArray();
|
||||||
|
$this->importKeys = $keys;
|
||||||
|
|
||||||
|
}
|
||||||
|
Log::debug('Valid import keys are ', $this->importKeys);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $entry
|
* @param string $entry
|
||||||
*
|
*
|
||||||
@@ -83,9 +104,28 @@ class UploadCollector extends BasicCollector implements CollectorInterface
|
|||||||
*
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
private function isValidFile(string $entry): bool
|
private function isImportFile(string $entry): bool
|
||||||
|
{
|
||||||
|
$name = str_replace('.upload', '', $entry);
|
||||||
|
if (in_array($name, $this->importKeys)) {
|
||||||
|
Log::debug(sprintf('Import file "%s" is in array', $name), $this->importKeys);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
Log::debug(sprintf('Import file "%s" is NOT in array', $name), $this->importKeys);
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $entry
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
private function isOldImport(string $entry): bool
|
||||||
{
|
{
|
||||||
$len = strlen($this->expected);
|
$len = strlen($this->expected);
|
||||||
|
// file is part of the old import routine:
|
||||||
if (substr($entry, 0, $len) === $this->expected) {
|
if (substr($entry, 0, $len) === $this->expected) {
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@@ -97,23 +137,63 @@ class UploadCollector extends BasicCollector implements CollectorInterface
|
|||||||
/**
|
/**
|
||||||
* @param $entry
|
* @param $entry
|
||||||
*/
|
*/
|
||||||
private function processOldUpload(string $entry)
|
private function processUpload(string $entry)
|
||||||
{
|
{
|
||||||
$content = '';
|
// file is old import:
|
||||||
|
if ($this->isOldImport($entry)) {
|
||||||
if ($this->isValidFile($entry)) {
|
$this->saveOldImportFile($entry);
|
||||||
try {
|
|
||||||
$content = Crypt::decrypt($this->uploadDisk->get($entry));
|
|
||||||
} catch (DecryptException $e) {
|
|
||||||
Log::error('Could not decrypt old CSV import file ' . $entry . '. Skipped because ' . $e->getMessage());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (strlen($content) > 0) {
|
|
||||||
// continue with file:
|
// file is current import.
|
||||||
$date = $this->getOriginalUploadDate($entry);
|
if ($this->isImportFile($entry)) {
|
||||||
$file = $this->job->key . '-Old CSV import dated ' . $date . '.csv';
|
$this->saveImportFile($entry);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $entry
|
||||||
|
*/
|
||||||
|
private function saveImportFile(string $entry)
|
||||||
|
{
|
||||||
|
// find job associated with import file:
|
||||||
|
$name = str_replace('.upload', '', $entry);
|
||||||
|
$job = auth()->user()->importJobs()->where('key', $name)->first();
|
||||||
|
$content = '';
|
||||||
|
try {
|
||||||
|
$content = Crypt::decrypt($this->uploadDisk->get($entry));
|
||||||
|
} catch (DecryptException $e) {
|
||||||
|
Log::error('Could not decrypt old import file ' . $entry . '. Skipped because ' . $e->getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!is_null($job) && strlen($content) > 0) {
|
||||||
|
// add to export disk.
|
||||||
|
$date = $job->created_at->format('Y-m-d');
|
||||||
|
$file = sprintf('%s-Old %s import dated %s.%s', $this->job->key, strtoupper($job->file_type), $date, $job->file_type);
|
||||||
$this->exportDisk->put($file, $content);
|
$this->exportDisk->put($file, $content);
|
||||||
$this->getFiles()->push($file);
|
$this->getFiles()->push($file);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $entry
|
||||||
|
*/
|
||||||
|
private function saveOldImportFile(string $entry)
|
||||||
|
{
|
||||||
|
$content = '';
|
||||||
|
try {
|
||||||
|
$content = Crypt::decrypt($this->uploadDisk->get($entry));
|
||||||
|
} catch (DecryptException $e) {
|
||||||
|
Log::error('Could not decrypt old CSV import file ' . $entry . '. Skipped because ' . $e->getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (strlen($content) > 0) {
|
||||||
|
// add to export disk.
|
||||||
|
$date = $this->getOriginalUploadDate($entry);
|
||||||
|
$file = $this->job->key . '-Old import dated ' . $date . '.csv';
|
||||||
|
$this->exportDisk->put($file, $content);
|
||||||
|
$this->getFiles()->push($file);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -11,7 +11,6 @@ declare(strict_types = 1);
|
|||||||
|
|
||||||
namespace FireflyIII\Handlers\Events;
|
namespace FireflyIII\Handlers\Events;
|
||||||
|
|
||||||
use Auth;
|
|
||||||
use FireflyIII\Events\TransactionJournalStored;
|
use FireflyIII\Events\TransactionJournalStored;
|
||||||
use FireflyIII\Models\PiggyBank;
|
use FireflyIII\Models\PiggyBank;
|
||||||
use FireflyIII\Models\PiggyBankEvent;
|
use FireflyIII\Models\PiggyBankEvent;
|
||||||
@@ -39,7 +38,7 @@ class ConnectJournalToPiggyBank
|
|||||||
$piggyBankId = $event->piggyBankId;
|
$piggyBankId = $event->piggyBankId;
|
||||||
|
|
||||||
/** @var PiggyBank $piggyBank */
|
/** @var PiggyBank $piggyBank */
|
||||||
$piggyBank = Auth::user()->piggybanks()->where('piggy_banks.id', $piggyBankId)->first(['piggy_banks.*']);
|
$piggyBank = auth()->user()->piggyBanks()->where('piggy_banks.id', $piggyBankId)->first(['piggy_banks.*']);
|
||||||
|
|
||||||
if (is_null($piggyBank)) {
|
if (is_null($piggyBank)) {
|
||||||
return true;
|
return true;
|
||||||
|
@@ -37,7 +37,7 @@ class ConnectTransactionToPiggyBank
|
|||||||
$repository = app(PiggyBankRepositoryInterface::class);
|
$repository = app(PiggyBankRepositoryInterface::class);
|
||||||
$transaction = $event->transaction;
|
$transaction = $event->transaction;
|
||||||
|
|
||||||
$piggyBank = $repository->find($transaction['piggy_bank_id']);
|
$piggyBank = $repository->find($transaction['piggy_bank_id']);
|
||||||
|
|
||||||
// valid piggy:
|
// valid piggy:
|
||||||
if (is_null($piggyBank->id)) {
|
if (is_null($piggyBank->id)) {
|
||||||
|
@@ -17,7 +17,6 @@ use FireflyIII\Models\Rule;
|
|||||||
use FireflyIII\Models\RuleGroup;
|
use FireflyIII\Models\RuleGroup;
|
||||||
use FireflyIII\Rules\Processor;
|
use FireflyIII\Rules\Processor;
|
||||||
use FireflyIII\User;
|
use FireflyIII\User;
|
||||||
use Illuminate\Support\Facades\Auth;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class FireRulesForStore
|
* Class FireRulesForStore
|
||||||
@@ -38,7 +37,7 @@ class FireRulesForStore
|
|||||||
{
|
{
|
||||||
// get all the user's rule groups, with the rules, order by 'order'.
|
// get all the user's rule groups, with the rules, order by 'order'.
|
||||||
/** @var User $user */
|
/** @var User $user */
|
||||||
$user = Auth::user();
|
$user = auth()->user();
|
||||||
$groups = $user->ruleGroups()->where('rule_groups.active', 1)->orderBy('order', 'ASC')->get();
|
$groups = $user->ruleGroups()->where('rule_groups.active', 1)->orderBy('order', 'ASC')->get();
|
||||||
//
|
//
|
||||||
/** @var RuleGroup $group */
|
/** @var RuleGroup $group */
|
||||||
|
@@ -11,7 +11,6 @@ declare(strict_types = 1);
|
|||||||
|
|
||||||
namespace FireflyIII\Handlers\Events;
|
namespace FireflyIII\Handlers\Events;
|
||||||
|
|
||||||
use Auth;
|
|
||||||
use FireflyIII\Events\TransactionJournalUpdated;
|
use FireflyIII\Events\TransactionJournalUpdated;
|
||||||
use FireflyIII\Models\Rule;
|
use FireflyIII\Models\Rule;
|
||||||
use FireflyIII\Models\RuleGroup;
|
use FireflyIII\Models\RuleGroup;
|
||||||
@@ -36,7 +35,7 @@ class FireRulesForUpdate
|
|||||||
{
|
{
|
||||||
// get all the user's rule groups, with the rules, order by 'order'.
|
// get all the user's rule groups, with the rules, order by 'order'.
|
||||||
/** @var User $user */
|
/** @var User $user */
|
||||||
$user = Auth::user();
|
$user = auth()->user();
|
||||||
$groups = $user->ruleGroups()->where('rule_groups.active', 1)->orderBy('order', 'ASC')->get();
|
$groups = $user->ruleGroups()->where('rule_groups.active', 1)->orderBy('order', 'ASC')->get();
|
||||||
//
|
//
|
||||||
/** @var RuleGroup $group */
|
/** @var RuleGroup $group */
|
||||||
|
@@ -27,6 +27,7 @@ class UpdateJournalConnection
|
|||||||
* Handle the event.
|
* Handle the event.
|
||||||
*
|
*
|
||||||
* @param TransactionJournalUpdated $event
|
* @param TransactionJournalUpdated $event
|
||||||
|
* @SuppressWarnings(PHPMD.CyclomaticComplexity) // it's exactly 5.
|
||||||
*
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
@@ -46,7 +47,7 @@ class UpdateJournalConnection
|
|||||||
}
|
}
|
||||||
$piggyBank = $event->piggyBank()->first();
|
$piggyBank = $event->piggyBank()->first();
|
||||||
$repetition = null;
|
$repetition = null;
|
||||||
if ($piggyBank) {
|
if (!is_null($piggyBank)) {
|
||||||
/** @var PiggyBankRepetition $repetition */
|
/** @var PiggyBankRepetition $repetition */
|
||||||
$repetition = $piggyBank->piggyBankRepetitions()->relevantOnDate($journal->date)->first();
|
$repetition = $piggyBank->piggyBankRepetitions()->relevantOnDate($journal->date)->first();
|
||||||
}
|
}
|
||||||
|
@@ -13,7 +13,6 @@ namespace FireflyIII\Handlers\Events;
|
|||||||
|
|
||||||
use FireflyIII\Events\UserIsConfirmed;
|
use FireflyIII\Events\UserIsConfirmed;
|
||||||
use FireflyIII\Events\UserRegistration;
|
use FireflyIII\Events\UserRegistration;
|
||||||
use FireflyIII\User;
|
|
||||||
use Preferences;
|
use Preferences;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -32,20 +31,6 @@ class UserSaveIpAddress
|
|||||||
//
|
//
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Handle the event.
|
|
||||||
*
|
|
||||||
* @param UserRegistration $event
|
|
||||||
*
|
|
||||||
* @return bool
|
|
||||||
*/
|
|
||||||
public function saveFromRegistration(UserRegistration $event): bool
|
|
||||||
{
|
|
||||||
Preferences::setForUser($event->user, 'registration_ip_address', $event->ipAddress);
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handle the event.
|
* Handle the event.
|
||||||
*
|
*
|
||||||
@@ -59,4 +44,18 @@ class UserSaveIpAddress
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle the event.
|
||||||
|
*
|
||||||
|
* @param UserRegistration $event
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function saveFromRegistration(UserRegistration $event): bool
|
||||||
|
{
|
||||||
|
Preferences::setForUser($event->user, 'registration_ip_address', $event->ipAddress);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -10,7 +10,6 @@
|
|||||||
declare(strict_types = 1);
|
declare(strict_types = 1);
|
||||||
namespace FireflyIII\Helpers\Attachments;
|
namespace FireflyIII\Helpers\Attachments;
|
||||||
|
|
||||||
use Auth;
|
|
||||||
use Crypt;
|
use Crypt;
|
||||||
use FireflyIII\Models\Attachment;
|
use FireflyIII\Models\Attachment;
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
@@ -60,7 +59,7 @@ class AttachmentHelper implements AttachmentHelperInterface
|
|||||||
*/
|
*/
|
||||||
public function getAttachmentLocation(Attachment $attachment): string
|
public function getAttachmentLocation(Attachment $attachment): string
|
||||||
{
|
{
|
||||||
$path = storage_path('upload') . DIRECTORY_SEPARATOR . 'at-' . $attachment->id . '.data';
|
$path = sprintf('%s%sat-%d.data', storage_path('upload'), DIRECTORY_SEPARATOR, intval($attachment->id));
|
||||||
|
|
||||||
return $path;
|
return $path;
|
||||||
}
|
}
|
||||||
@@ -112,7 +111,7 @@ class AttachmentHelper implements AttachmentHelperInterface
|
|||||||
$md5 = md5_file($file->getRealPath());
|
$md5 = md5_file($file->getRealPath());
|
||||||
$name = $file->getClientOriginalName();
|
$name = $file->getClientOriginalName();
|
||||||
$class = get_class($model);
|
$class = get_class($model);
|
||||||
$count = Auth::user()->attachments()->where('md5', $md5)->where('attachable_id', $model->id)->where('attachable_type', $class)->count();
|
$count = auth()->user()->attachments()->where('md5', $md5)->where('attachable_id', $model->id)->where('attachable_type', $class)->count();
|
||||||
|
|
||||||
if ($count > 0) {
|
if ($count > 0) {
|
||||||
$msg = (string)trans('validation.file_already_attached', ['name' => $name]);
|
$msg = (string)trans('validation.file_already_attached', ['name' => $name]);
|
||||||
@@ -139,7 +138,7 @@ class AttachmentHelper implements AttachmentHelperInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
$attachment = new Attachment; // create Attachment object.
|
$attachment = new Attachment; // create Attachment object.
|
||||||
$attachment->user()->associate(Auth::user());
|
$attachment->user()->associate(auth()->user());
|
||||||
$attachment->attachable()->associate($model);
|
$attachment->attachable()->associate($model);
|
||||||
$attachment->md5 = md5_file($file->getRealPath());
|
$attachment->md5 = md5_file($file->getRealPath());
|
||||||
$attachment->filename = $file->getClientOriginalName();
|
$attachment->filename = $file->getClientOriginalName();
|
||||||
@@ -250,6 +249,8 @@ class AttachmentHelper implements AttachmentHelperInterface
|
|||||||
/**
|
/**
|
||||||
* @param array $files
|
* @param array $files
|
||||||
*
|
*
|
||||||
|
* @param Model $model
|
||||||
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
private function processFiles(array $files, Model $model): bool
|
private function processFiles(array $files, Model $model): bool
|
||||||
|
@@ -32,14 +32,12 @@ class BalanceLine
|
|||||||
|
|
||||||
/** @var BudgetModel */
|
/** @var BudgetModel */
|
||||||
protected $budget;
|
protected $budget;
|
||||||
|
|
||||||
/** @var Carbon */
|
|
||||||
protected $startDate;
|
|
||||||
/** @var Carbon */
|
/** @var Carbon */
|
||||||
protected $endDate;
|
protected $endDate;
|
||||||
|
|
||||||
/** @var int */
|
/** @var int */
|
||||||
protected $role = self::ROLE_DEFAULTROLE;
|
protected $role = self::ROLE_DEFAULTROLE;
|
||||||
|
/** @var Carbon */
|
||||||
|
protected $startDate;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@@ -90,6 +88,22 @@ class BalanceLine
|
|||||||
$this->budget = $budget;
|
$this->budget = $budget;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Carbon
|
||||||
|
*/
|
||||||
|
public function getEndDate()
|
||||||
|
{
|
||||||
|
return $this->endDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Carbon $endDate
|
||||||
|
*/
|
||||||
|
public function setEndDate($endDate)
|
||||||
|
{
|
||||||
|
$this->endDate = $endDate;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
@@ -106,6 +120,22 @@ class BalanceLine
|
|||||||
$this->role = $role;
|
$this->role = $role;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Carbon
|
||||||
|
*/
|
||||||
|
public function getStartDate()
|
||||||
|
{
|
||||||
|
return $this->startDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Carbon $startDate
|
||||||
|
*/
|
||||||
|
public function setStartDate($startDate)
|
||||||
|
{
|
||||||
|
$this->startDate = $startDate;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
@@ -127,39 +157,6 @@ class BalanceLine
|
|||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return Carbon
|
|
||||||
*/
|
|
||||||
public function getStartDate()
|
|
||||||
{
|
|
||||||
return $this->startDate;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param Carbon $startDate
|
|
||||||
*/
|
|
||||||
public function setStartDate($startDate)
|
|
||||||
{
|
|
||||||
$this->startDate = $startDate;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return Carbon
|
|
||||||
*/
|
|
||||||
public function getEndDate()
|
|
||||||
{
|
|
||||||
return $this->endDate;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param Carbon $endDate
|
|
||||||
*/
|
|
||||||
public function setEndDate($endDate)
|
|
||||||
{
|
|
||||||
$this->endDate = $endDate;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If a BalanceLine has a budget/repetition, each BalanceEntry in this BalanceLine
|
* If a BalanceLine has a budget/repetition, each BalanceEntry in this BalanceLine
|
||||||
* should have a "spent" value, which is the amount of money that has been spent
|
* should have a "spent" value, which is the amount of money that has been spent
|
||||||
|
@@ -41,46 +41,66 @@ class Budget
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param BudgetLine $budgetLine
|
* @param BudgetLine $budgetLine
|
||||||
|
*
|
||||||
|
* @return Budget
|
||||||
*/
|
*/
|
||||||
public function addBudgetLine(BudgetLine $budgetLine)
|
public function addBudgetLine(BudgetLine $budgetLine): Budget
|
||||||
{
|
{
|
||||||
$this->budgetLines->push($budgetLine);
|
$this->budgetLines->push($budgetLine);
|
||||||
|
|
||||||
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $add
|
* @param string $add
|
||||||
|
*
|
||||||
|
* @return Budget
|
||||||
*/
|
*/
|
||||||
public function addBudgeted(string $add)
|
public function addBudgeted(string $add): Budget
|
||||||
{
|
{
|
||||||
$add = strval(round($add, 2));
|
$add = strval(round($add, 2));
|
||||||
$this->budgeted = bcadd($this->budgeted, $add);
|
$this->budgeted = bcadd($this->budgeted, $add);
|
||||||
|
|
||||||
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $add
|
* @param string $add
|
||||||
|
*
|
||||||
|
* @return Budget
|
||||||
*/
|
*/
|
||||||
public function addLeft(string $add)
|
public function addLeft(string $add): Budget
|
||||||
{
|
{
|
||||||
$add = strval(round($add, 2));
|
$add = strval(round($add, 2));
|
||||||
$this->left = bcadd($this->left, $add);
|
$this->left = bcadd($this->left, $add);
|
||||||
|
|
||||||
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $add
|
* @param string $add
|
||||||
|
*
|
||||||
|
* @return Budget
|
||||||
*/
|
*/
|
||||||
public function addOverspent(string $add)
|
public function addOverspent(string $add): Budget
|
||||||
{
|
{
|
||||||
$add = strval(round($add, 2));
|
$add = strval(round($add, 2));
|
||||||
$this->overspent = bcadd($this->overspent, $add);
|
$this->overspent = bcadd($this->overspent, $add);
|
||||||
|
|
||||||
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $add
|
* @param string $add
|
||||||
|
*
|
||||||
|
* @return Budget
|
||||||
*/
|
*/
|
||||||
public function addSpent(string $add)
|
public function addSpent(string $add): Budget
|
||||||
{
|
{
|
||||||
$add = strval(round($add, 2));
|
$add = strval(round($add, 2));
|
||||||
$this->spent = bcadd($this->spent, $add);
|
$this->spent = bcadd($this->spent, $add);
|
||||||
|
|
||||||
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -101,10 +121,14 @@ class Budget
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $budgeted
|
* @param string $budgeted
|
||||||
|
*
|
||||||
|
* @return Budget
|
||||||
*/
|
*/
|
||||||
public function setBudgeted(string $budgeted)
|
public function setBudgeted(string $budgeted): Budget
|
||||||
{
|
{
|
||||||
$this->budgeted = $budgeted;
|
$this->budgeted = $budgeted;
|
||||||
|
|
||||||
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -117,10 +141,14 @@ class Budget
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $left
|
* @param string $left
|
||||||
|
*
|
||||||
|
* @return Budget
|
||||||
*/
|
*/
|
||||||
public function setLeft(string $left)
|
public function setLeft(string $left): Budget
|
||||||
{
|
{
|
||||||
$this->left = $left;
|
$this->left = $left;
|
||||||
|
|
||||||
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -133,10 +161,14 @@ class Budget
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $overspent
|
* @param string $overspent
|
||||||
|
*
|
||||||
|
* @return Budget
|
||||||
*/
|
*/
|
||||||
public function setOverspent(string $overspent)
|
public function setOverspent(string $overspent): Budget
|
||||||
{
|
{
|
||||||
$this->overspent = strval(round($overspent, 2));
|
$this->overspent = strval(round($overspent, 2));
|
||||||
|
|
||||||
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -149,10 +181,14 @@ class Budget
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $spent
|
* @param string $spent
|
||||||
|
*
|
||||||
|
* @return Budget
|
||||||
*/
|
*/
|
||||||
public function setSpent(string $spent)
|
public function setSpent(string $spent): Budget
|
||||||
{
|
{
|
||||||
$this->spent = strval(round($spent, 2));
|
$this->spent = strval(round($spent, 2));
|
||||||
|
|
||||||
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -45,10 +45,14 @@ class BudgetLine
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param BudgetModel $budget
|
* @param BudgetModel $budget
|
||||||
|
*
|
||||||
|
* @return BudgetLine
|
||||||
*/
|
*/
|
||||||
public function setBudget(BudgetModel $budget)
|
public function setBudget(BudgetModel $budget): BudgetLine
|
||||||
{
|
{
|
||||||
$this->budget = $budget;
|
$this->budget = $budget;
|
||||||
|
|
||||||
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -61,10 +65,14 @@ class BudgetLine
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $budgeted
|
* @param string $budgeted
|
||||||
|
*
|
||||||
|
* @return BudgetLine
|
||||||
*/
|
*/
|
||||||
public function setBudgeted(string $budgeted)
|
public function setBudgeted(string $budgeted): BudgetLine
|
||||||
{
|
{
|
||||||
$this->budgeted = $budgeted;
|
$this->budgeted = $budgeted;
|
||||||
|
|
||||||
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -77,10 +85,14 @@ class BudgetLine
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $left
|
* @param string $left
|
||||||
|
*
|
||||||
|
* @return BudgetLine
|
||||||
*/
|
*/
|
||||||
public function setLeft(string $left)
|
public function setLeft(string $left): BudgetLine
|
||||||
{
|
{
|
||||||
$this->left = $left;
|
$this->left = $left;
|
||||||
|
|
||||||
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -93,10 +105,14 @@ class BudgetLine
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $overspent
|
* @param string $overspent
|
||||||
|
*
|
||||||
|
* @return BudgetLine
|
||||||
*/
|
*/
|
||||||
public function setOverspent(string $overspent)
|
public function setOverspent(string $overspent): BudgetLine
|
||||||
{
|
{
|
||||||
$this->overspent = $overspent;
|
$this->overspent = $overspent;
|
||||||
|
|
||||||
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -109,10 +125,14 @@ class BudgetLine
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param LimitRepetition $repetition
|
* @param LimitRepetition $repetition
|
||||||
|
*
|
||||||
|
* @return BudgetLine
|
||||||
*/
|
*/
|
||||||
public function setRepetition(LimitRepetition $repetition)
|
public function setRepetition(LimitRepetition $repetition): BudgetLine
|
||||||
{
|
{
|
||||||
$this->repetition = $repetition;
|
$this->repetition = $repetition;
|
||||||
|
|
||||||
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -125,10 +145,14 @@ class BudgetLine
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $spent
|
* @param string $spent
|
||||||
|
*
|
||||||
|
* @return BudgetLine
|
||||||
*/
|
*/
|
||||||
public function setSpent(string $spent)
|
public function setSpent(string $spent): BudgetLine
|
||||||
{
|
{
|
||||||
$this->spent = $spent;
|
$this->spent = $spent;
|
||||||
|
|
||||||
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -1,385 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* Importer.php
|
|
||||||
* Copyright (C) 2016 thegrumpydictator@gmail.com
|
|
||||||
*
|
|
||||||
* This software may be modified and distributed under the terms
|
|
||||||
* of the MIT license. See the LICENSE file for details.
|
|
||||||
*/
|
|
||||||
|
|
||||||
declare(strict_types = 1);
|
|
||||||
namespace FireflyIII\Helpers\Csv;
|
|
||||||
|
|
||||||
use Auth;
|
|
||||||
use FireflyIII\Events\TransactionJournalStored;
|
|
||||||
use FireflyIII\Exceptions\FireflyException;
|
|
||||||
use FireflyIII\Helpers\Csv\Converter\ConverterInterface;
|
|
||||||
use FireflyIII\Helpers\Csv\PostProcessing\PostProcessorInterface;
|
|
||||||
use FireflyIII\Helpers\Csv\Specifix\SpecifixInterface;
|
|
||||||
use FireflyIII\Models\Account;
|
|
||||||
use FireflyIII\Models\Transaction;
|
|
||||||
use FireflyIII\Models\TransactionJournal;
|
|
||||||
use FireflyIII\Models\TransactionType;
|
|
||||||
use Illuminate\Support\Collection;
|
|
||||||
use Illuminate\Support\MessageBag;
|
|
||||||
use Log;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Class Importer
|
|
||||||
*
|
|
||||||
* @package FireflyIII\Helpers\Csv
|
|
||||||
*/
|
|
||||||
class Importer
|
|
||||||
{
|
|
||||||
|
|
||||||
/** @var Data */
|
|
||||||
protected $data;
|
|
||||||
/** @var array */
|
|
||||||
protected $errors = [];
|
|
||||||
/** @var array */
|
|
||||||
protected $importData;
|
|
||||||
/** @var array */
|
|
||||||
protected $importRow;
|
|
||||||
/** @var int */
|
|
||||||
protected $imported = 0;
|
|
||||||
/** @var Collection */
|
|
||||||
protected $journals;
|
|
||||||
/** @var array */
|
|
||||||
protected $map;
|
|
||||||
/** @var array */
|
|
||||||
protected $mapped;
|
|
||||||
/** @var array */
|
|
||||||
protected $roles;
|
|
||||||
/** @var int */
|
|
||||||
protected $rows = 0;
|
|
||||||
/** @var array */
|
|
||||||
protected $specifix = [];
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Used by CsvController.
|
|
||||||
*
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
public function getErrors(): array
|
|
||||||
{
|
|
||||||
return $this->errors;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Used by CsvController
|
|
||||||
*
|
|
||||||
* @return int
|
|
||||||
*/
|
|
||||||
public function getImported(): int
|
|
||||||
{
|
|
||||||
return $this->imported;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return Collection
|
|
||||||
*/
|
|
||||||
public function getJournals(): Collection
|
|
||||||
{
|
|
||||||
return $this->journals;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Used by CsvController
|
|
||||||
*
|
|
||||||
* @return int
|
|
||||||
*/
|
|
||||||
public function getRows(): int
|
|
||||||
{
|
|
||||||
return $this->rows;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
public function getSpecifix(): array
|
|
||||||
{
|
|
||||||
return is_array($this->specifix) ? $this->specifix : [];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @throws FireflyException
|
|
||||||
*/
|
|
||||||
public function run()
|
|
||||||
{
|
|
||||||
set_time_limit(0);
|
|
||||||
|
|
||||||
$this->journals = new Collection;
|
|
||||||
$this->map = $this->data->getMap();
|
|
||||||
$this->roles = $this->data->getRoles();
|
|
||||||
$this->mapped = $this->data->getMapped();
|
|
||||||
$this->specifix = $this->data->getSpecifix();
|
|
||||||
|
|
||||||
foreach ($this->data->getReader() as $index => $row) {
|
|
||||||
if ($this->parseRow($index)) {
|
|
||||||
$this->rows++;
|
|
||||||
$result = $this->importRow($row);
|
|
||||||
if (!($result instanceof TransactionJournal)) {
|
|
||||||
Log::error('Caught error at row #' . $index . ': ' . $result);
|
|
||||||
$this->errors[$index] = $result;
|
|
||||||
} else {
|
|
||||||
$this->imported++;
|
|
||||||
$this->journals->push($result);
|
|
||||||
event(new TransactionJournalStored($result, 0));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param Data $data
|
|
||||||
*/
|
|
||||||
public function setData(Data $data)
|
|
||||||
{
|
|
||||||
$this->data = $data;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return TransactionJournal|string
|
|
||||||
*/
|
|
||||||
protected function createTransactionJournal()
|
|
||||||
{
|
|
||||||
$date = $this->importData['date'];
|
|
||||||
if (is_null($this->importData['date'])) {
|
|
||||||
$date = $this->importData['date-rent'];
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
$transactionType = $this->getTransactionType(); // defaults to deposit
|
|
||||||
$errors = new MessageBag;
|
|
||||||
|
|
||||||
$journal = TransactionJournal::create(
|
|
||||||
[
|
|
||||||
'user_id' => Auth::user()->id,
|
|
||||||
'transaction_type_id' => $transactionType->id,
|
|
||||||
'transaction_currency_id' => $this->importData['currency']->id,
|
|
||||||
'description' => $this->importData['description'],
|
|
||||||
'completed' => 0,
|
|
||||||
'date' => $date,
|
|
||||||
'bill_id' => $this->importData['bill-id'],
|
|
||||||
]
|
|
||||||
);
|
|
||||||
if ($journal->getErrors()->count() == 0) {
|
|
||||||
// first transaction
|
|
||||||
$accountId = $this->importData['asset-account-object']->id; // create first transaction:
|
|
||||||
$amount = $this->importData['amount'];
|
|
||||||
$transaction = Transaction::create(['transaction_journal_id' => $journal->id, 'account_id' => $accountId, 'amount' => $amount]);
|
|
||||||
$errors = $transaction->getErrors();
|
|
||||||
|
|
||||||
// second transaction
|
|
||||||
$accountId = $this->importData['opposing-account-object']->id; // create second transaction:
|
|
||||||
$amount = bcmul($this->importData['amount'], '-1');
|
|
||||||
$transaction = Transaction::create(['transaction_journal_id' => $journal->id, 'account_id' => $accountId, 'amount' => $amount]);
|
|
||||||
$errors = $transaction->getErrors()->merge($errors);
|
|
||||||
}
|
|
||||||
if ($errors->count() == 0) {
|
|
||||||
$journal->completed = 1;
|
|
||||||
$journal->save();
|
|
||||||
} else {
|
|
||||||
$text = join(',', $errors->all());
|
|
||||||
|
|
||||||
return $text;
|
|
||||||
}
|
|
||||||
$this->saveBudget($journal);
|
|
||||||
$this->saveCategory($journal);
|
|
||||||
$this->saveTags($journal);
|
|
||||||
|
|
||||||
// some debug info:
|
|
||||||
$journalId = $journal->id;
|
|
||||||
$type = $journal->transaction_type_type ?? $journal->transactionType->type;
|
|
||||||
/** @var Account $asset */
|
|
||||||
$asset = $this->importData['asset-account-object'];
|
|
||||||
/** @var Account $opposing */
|
|
||||||
$opposing = $this->importData['opposing-account-object'];
|
|
||||||
|
|
||||||
Log::info('Created journal #' . $journalId . ' of type ' . $type . '!');
|
|
||||||
Log::info('Asset account #' . $asset->id . ' lost/gained: ' . $this->importData['amount']);
|
|
||||||
Log::info($opposing->accountType->type . ' #' . $opposing->id . ' lost/gained: ' . bcmul($this->importData['amount'], '-1'));
|
|
||||||
|
|
||||||
return $journal;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return TransactionType
|
|
||||||
*/
|
|
||||||
protected function getTransactionType()
|
|
||||||
{
|
|
||||||
$transactionType = TransactionType::where('type', TransactionType::DEPOSIT)->first();
|
|
||||||
if ($this->importData['amount'] < 0) {
|
|
||||||
$transactionType = TransactionType::where('type', TransactionType::WITHDRAWAL)->first();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (in_array($this->importData['opposing-account-object']->accountType->type, ['Asset account', 'Default account'])) {
|
|
||||||
$transactionType = TransactionType::where('type', TransactionType::TRANSFER)->first();
|
|
||||||
}
|
|
||||||
|
|
||||||
return $transactionType;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param array $row
|
|
||||||
*
|
|
||||||
* @throws FireflyException
|
|
||||||
* @return string|bool
|
|
||||||
*/
|
|
||||||
protected function importRow(array $row)
|
|
||||||
{
|
|
||||||
|
|
||||||
$data = $this->getFiller(); // These fields are necessary to create a new transaction journal. Some are optional
|
|
||||||
foreach ($row as $index => $value) {
|
|
||||||
$role = $this->roles[$index] ?? '_ignore';
|
|
||||||
$class = config('csv.roles.' . $role . '.converter');
|
|
||||||
$field = config('csv.roles.' . $role . '.field');
|
|
||||||
|
|
||||||
|
|
||||||
// here would be the place where preprocessors would fire.
|
|
||||||
|
|
||||||
/** @var ConverterInterface $converter */
|
|
||||||
$converter = app('FireflyIII\Helpers\Csv\Converter\\' . $class);
|
|
||||||
$converter->setData($data); // the complete array so far.
|
|
||||||
$converter->setField($field);
|
|
||||||
$converter->setIndex($index);
|
|
||||||
$converter->setMapped($this->mapped);
|
|
||||||
$converter->setValue($value);
|
|
||||||
$data[$field] = $converter->convert();
|
|
||||||
}
|
|
||||||
// move to class vars.
|
|
||||||
$this->importData = $data;
|
|
||||||
$this->importRow = $row;
|
|
||||||
unset($data, $row);
|
|
||||||
// post processing and validating.
|
|
||||||
$this->postProcess();
|
|
||||||
$result = $this->validateData();
|
|
||||||
|
|
||||||
if (!($result === true)) {
|
|
||||||
return $result; // return error.
|
|
||||||
}
|
|
||||||
$journal = $this->createTransactionJournal();
|
|
||||||
|
|
||||||
return $journal;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param int $index
|
|
||||||
*
|
|
||||||
* @return bool
|
|
||||||
*/
|
|
||||||
protected function parseRow(int $index)
|
|
||||||
{
|
|
||||||
return (($this->data->hasHeaders() && $index >= 1) || !$this->data->hasHeaders());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Row denotes the original data.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
protected function postProcess()
|
|
||||||
{
|
|
||||||
// do bank specific fixes (must be enabled but now all of them.
|
|
||||||
|
|
||||||
foreach ($this->getSpecifix() as $className) {
|
|
||||||
/** @var SpecifixInterface $specifix */
|
|
||||||
$specifix = app('FireflyIII\Helpers\Csv\Specifix\\' . $className);
|
|
||||||
if ($specifix->getProcessorType() == SpecifixInterface::POST_PROCESSOR) {
|
|
||||||
$specifix->setData($this->importData);
|
|
||||||
$specifix->setRow($this->importRow);
|
|
||||||
$this->importData = $specifix->fix();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
$set = config('csv.post_processors');
|
|
||||||
foreach ($set as $className) {
|
|
||||||
/** @var PostProcessorInterface $postProcessor */
|
|
||||||
$postProcessor = app('FireflyIII\Helpers\Csv\PostProcessing\\' . $className);
|
|
||||||
$array = $this->importData ?? [];
|
|
||||||
$postProcessor->setData($array);
|
|
||||||
$this->importData = $postProcessor->process();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param TransactionJournal $journal
|
|
||||||
*/
|
|
||||||
protected function saveBudget(TransactionJournal $journal)
|
|
||||||
{
|
|
||||||
// add budget:
|
|
||||||
if (!is_null($this->importData['budget'])) {
|
|
||||||
$journal->budgets()->save($this->importData['budget']);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param TransactionJournal $journal
|
|
||||||
*/
|
|
||||||
protected function saveCategory(TransactionJournal $journal)
|
|
||||||
{
|
|
||||||
// add category:
|
|
||||||
if (!is_null($this->importData['category'])) {
|
|
||||||
$journal->categories()->save($this->importData['category']);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param TransactionJournal $journal
|
|
||||||
*/
|
|
||||||
protected function saveTags(TransactionJournal $journal)
|
|
||||||
{
|
|
||||||
if (!is_null($this->importData['tags'])) {
|
|
||||||
foreach ($this->importData['tags'] as $tag) {
|
|
||||||
$journal->tags()->save($tag);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @return bool|string
|
|
||||||
*/
|
|
||||||
protected function validateData()
|
|
||||||
{
|
|
||||||
$date = $this->importData['date'] ?? null;
|
|
||||||
$rentDate = $this->importData['date-rent'] ?? null;
|
|
||||||
if (is_null($date) && is_null($rentDate)) {
|
|
||||||
return 'No date value for this row.';
|
|
||||||
}
|
|
||||||
if (is_null($this->importData['opposing-account-object'])) {
|
|
||||||
return 'Opposing account is null';
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!($this->importData['asset-account-object'] instanceof Account)) {
|
|
||||||
return 'No asset account to import into.';
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
private function getFiller()
|
|
||||||
{
|
|
||||||
$filler = [];
|
|
||||||
foreach (config('csv.roles') as $role) {
|
|
||||||
if (isset($role['field'])) {
|
|
||||||
$fieldName = $role['field'];
|
|
||||||
$filler[$fieldName] = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// some extra's:
|
|
||||||
$filler['bill-id'] = null;
|
|
||||||
$filler['opposing-account-object'] = null;
|
|
||||||
$filler['asset-account-object'] = null;
|
|
||||||
$filler['amount-modifier'] = '1';
|
|
||||||
|
|
||||||
return $filler;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@@ -11,7 +11,6 @@ declare(strict_types = 1);
|
|||||||
|
|
||||||
namespace FireflyIII\Helpers\Report;
|
namespace FireflyIII\Helpers\Report;
|
||||||
|
|
||||||
use Auth;
|
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use DB;
|
use DB;
|
||||||
use FireflyIII\Helpers\Collection\Balance;
|
use FireflyIII\Helpers\Collection\Balance;
|
||||||
@@ -102,34 +101,34 @@ class BalanceReportHelper implements BalanceReportHelperInterface
|
|||||||
private function allCoveredByBalancingActs(Collection $accounts, Carbon $start, Carbon $end): Collection
|
private function allCoveredByBalancingActs(Collection $accounts, Carbon $start, Carbon $end): Collection
|
||||||
{
|
{
|
||||||
$ids = $accounts->pluck('id')->toArray();
|
$ids = $accounts->pluck('id')->toArray();
|
||||||
$set = Auth::user()->tags()
|
$set = auth()->user()->tags()
|
||||||
->leftJoin('tag_transaction_journal', 'tag_transaction_journal.tag_id', '=', 'tags.id')
|
->leftJoin('tag_transaction_journal', 'tag_transaction_journal.tag_id', '=', 'tags.id')
|
||||||
->leftJoin('transaction_journals', 'tag_transaction_journal.transaction_journal_id', '=', 'transaction_journals.id')
|
->leftJoin('transaction_journals', 'tag_transaction_journal.transaction_journal_id', '=', 'transaction_journals.id')
|
||||||
->leftJoin('transaction_types', 'transaction_journals.transaction_type_id', '=', 'transaction_types.id')
|
->leftJoin('transaction_types', 'transaction_journals.transaction_type_id', '=', 'transaction_types.id')
|
||||||
->leftJoin(
|
->leftJoin(
|
||||||
'transactions AS t_source', function (JoinClause $join) {
|
'transactions AS t_source', function (JoinClause $join) {
|
||||||
$join->on('transaction_journals.id', '=', 't_source.transaction_journal_id')->where('t_source.amount', '<', 0);
|
$join->on('transaction_journals.id', '=', 't_source.transaction_journal_id')->where('t_source.amount', '<', 0);
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
->leftJoin(
|
->leftJoin(
|
||||||
'transactions AS t_destination', function (JoinClause $join) {
|
'transactions AS t_destination', function (JoinClause $join) {
|
||||||
$join->on('transaction_journals.id', '=', 't_destination.transaction_journal_id')->where('t_destination.amount', '>', 0);
|
$join->on('transaction_journals.id', '=', 't_destination.transaction_journal_id')->where('t_destination.amount', '>', 0);
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
->where('tags.tagMode', 'balancingAct')
|
->where('tags.tagMode', 'balancingAct')
|
||||||
->where('transaction_types.type', TransactionType::TRANSFER)
|
->where('transaction_types.type', TransactionType::TRANSFER)
|
||||||
->where('transaction_journals.date', '>=', $start->format('Y-m-d'))
|
->where('transaction_journals.date', '>=', $start->format('Y-m-d'))
|
||||||
->where('transaction_journals.date', '<=', $end->format('Y-m-d'))
|
->where('transaction_journals.date', '<=', $end->format('Y-m-d'))
|
||||||
->whereNull('transaction_journals.deleted_at')
|
->whereNull('transaction_journals.deleted_at')
|
||||||
->whereIn('t_source.account_id', $ids)
|
->whereIn('t_source.account_id', $ids)
|
||||||
->whereIn('t_destination.account_id', $ids)
|
->whereIn('t_destination.account_id', $ids)
|
||||||
->groupBy('t_destination.account_id')
|
->groupBy('t_destination.account_id')
|
||||||
->get(
|
->get(
|
||||||
[
|
[
|
||||||
't_destination.account_id',
|
't_destination.account_id',
|
||||||
DB::raw('SUM(`t_destination`.`amount`) as `sum`'),
|
DB::raw('SUM(`t_destination`.`amount`) as `sum`'),
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
return $set;
|
return $set;
|
||||||
}
|
}
|
||||||
@@ -261,6 +260,7 @@ class BalanceReportHelper implements BalanceReportHelperInterface
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Balance $balance
|
* @param Balance $balance
|
||||||
|
* @SuppressWarnings(PHPMD.CyclomaticComplexity) // it's exactly 5.
|
||||||
*
|
*
|
||||||
* @return Balance
|
* @return Balance
|
||||||
*/
|
*/
|
||||||
|
@@ -42,6 +42,9 @@ class BudgetReportHelper implements BudgetReportHelperInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @SuppressWarnings(PHPMD.ExcessiveMethodLength) // at 43, its ok.
|
||||||
|
* @SuppressWarnings(PHPMD.CyclomaticComplexity) // it's exactly 5.
|
||||||
|
*
|
||||||
* @param Carbon $start
|
* @param Carbon $start
|
||||||
* @param Carbon $end
|
* @param Carbon $end
|
||||||
* @param Collection $accounts
|
* @param Collection $accounts
|
||||||
@@ -59,38 +62,22 @@ class BudgetReportHelper implements BudgetReportHelperInterface
|
|||||||
if ($cache->has()) {
|
if ($cache->has()) {
|
||||||
return $cache->get();
|
return $cache->get();
|
||||||
}
|
}
|
||||||
|
|
||||||
$headers = [];
|
|
||||||
$current = clone $start;
|
$current = clone $start;
|
||||||
$return = new Collection;
|
$return = new Collection;
|
||||||
$set = $this->repository->getBudgets();
|
$set = $this->repository->getBudgets();
|
||||||
$budgets = [];
|
$budgets = [];
|
||||||
$spent = [];
|
$spent = [];
|
||||||
while ($current < $end) {
|
$headers = $this->createYearHeaders($current, $end);
|
||||||
$short = $current->format('m-Y');
|
|
||||||
$headers[$short] = $current->formatLocalized((string)trans('config.month'));
|
|
||||||
$current->addMonth();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/** @var Budget $budget */
|
/** @var Budget $budget */
|
||||||
foreach ($set as $budget) {
|
foreach ($set as $budget) {
|
||||||
$id = $budget->id;
|
$id = $budget->id;
|
||||||
$budgets[$id] = $budget->name;
|
$budgets[$id] = $budget->name;
|
||||||
$spent[$id] = [];
|
|
||||||
$current = clone $start;
|
$current = clone $start;
|
||||||
$sum = '0';
|
$budgetData = $this->getBudgetSpentData($current, $end, $budget, $accounts);
|
||||||
|
$sum = $budgetData['sum'];
|
||||||
|
$spent[$id] = $budgetData['spent'];
|
||||||
while ($current < $end) {
|
|
||||||
$currentEnd = clone $current;
|
|
||||||
$currentEnd->endOfMonth();
|
|
||||||
$format = $current->format('m-Y');
|
|
||||||
$budgetSpent = $this->repository->spentInPeriod(new Collection([$budget]), $accounts, $current, $currentEnd);
|
|
||||||
$spent[$id][$format] = $budgetSpent;
|
|
||||||
$sum = bcadd($sum, $budgetSpent);
|
|
||||||
$current->addMonth();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (bccomp('0', $sum) === 0) {
|
if (bccomp('0', $sum) === 0) {
|
||||||
// not spent anything.
|
// not spent anything.
|
||||||
@@ -131,10 +118,8 @@ class BudgetReportHelper implements BudgetReportHelperInterface
|
|||||||
|
|
||||||
if ($spent > 0) {
|
if ($spent > 0) {
|
||||||
$budgetLine = new BudgetLine;
|
$budgetLine = new BudgetLine;
|
||||||
$budgetLine->setBudget($budget);
|
$budgetLine->setBudget($budget)->setOverspent($spent);
|
||||||
$budgetLine->setOverspent($spent);
|
$object->addOverspent($spent)->addBudgetLine($budgetLine);
|
||||||
$object->addOverspent($spent);
|
|
||||||
$object->addBudgetLine($budgetLine);
|
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -144,18 +129,12 @@ class BudgetReportHelper implements BudgetReportHelperInterface
|
|||||||
$data = $this->calculateExpenses($budget, $repetition, $accounts);
|
$data = $this->calculateExpenses($budget, $repetition, $accounts);
|
||||||
|
|
||||||
$budgetLine = new BudgetLine;
|
$budgetLine = new BudgetLine;
|
||||||
$budgetLine->setBudget($budget);
|
$budgetLine->setBudget($budget)->setRepetition($repetition)
|
||||||
$budgetLine->setRepetition($repetition);
|
->setLeft($data['left'])->setSpent($data['expenses'])->setOverspent($data['overspent'])
|
||||||
$budgetLine->setLeft($data['left']);
|
->setBudgeted(strval($repetition->amount));
|
||||||
$budgetLine->setSpent($data['expenses']);
|
|
||||||
$budgetLine->setOverspent($data['overspent']);
|
|
||||||
$budgetLine->setBudgeted($repetition->amount);
|
|
||||||
|
|
||||||
$object->addBudgeted($repetition->amount);
|
$object->addBudgeted(strval($repetition->amount))->addSpent($data['spent'])
|
||||||
$object->addSpent($data['spent']);
|
->addLeft($data['left'])->addOverspent($data['overspent'])->addBudgetLine($budgetLine);
|
||||||
$object->addLeft($data['left']);
|
|
||||||
$object->addOverspent($data['overspent']);
|
|
||||||
$object->addBudgetLine($budgetLine);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -165,10 +144,8 @@ class BudgetReportHelper implements BudgetReportHelperInterface
|
|||||||
|
|
||||||
$noBudget = $this->repository->spentInPeriodWithoutBudget($accounts, $start, $end);
|
$noBudget = $this->repository->spentInPeriodWithoutBudget($accounts, $start, $end);
|
||||||
$budgetLine = new BudgetLine;
|
$budgetLine = new BudgetLine;
|
||||||
$budgetLine->setOverspent($noBudget);
|
$budgetLine->setOverspent($noBudget)->setSpent($noBudget);
|
||||||
$budgetLine->setSpent($noBudget);
|
$object->addOverspent($noBudget)->addBudgetLine($budgetLine);
|
||||||
$object->addOverspent($noBudget);
|
|
||||||
$object->addBudgetLine($budgetLine);
|
|
||||||
|
|
||||||
return $object;
|
return $object;
|
||||||
}
|
}
|
||||||
@@ -249,4 +226,50 @@ class BudgetReportHelper implements BudgetReportHelperInterface
|
|||||||
return $array;
|
return $array;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Carbon $current
|
||||||
|
* @param Carbon $end
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
private function createYearHeaders(Carbon $current, Carbon $end): array
|
||||||
|
{
|
||||||
|
$headers = [];
|
||||||
|
while ($current < $end) {
|
||||||
|
$short = $current->format('m-Y');
|
||||||
|
$headers[$short] = $current->formatLocalized((string)trans('config.month'));
|
||||||
|
$current->addMonth();
|
||||||
|
}
|
||||||
|
|
||||||
|
return $headers;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Carbon $current
|
||||||
|
* @param Carbon $end
|
||||||
|
* @param Budget $budget
|
||||||
|
* @param Collection $accounts
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
private function getBudgetSpentData(Carbon $current, Carbon $end, Budget $budget, Collection $accounts): array
|
||||||
|
{
|
||||||
|
$sum = '0';
|
||||||
|
$spent = [];
|
||||||
|
while ($current < $end) {
|
||||||
|
$currentEnd = clone $current;
|
||||||
|
$currentEnd->endOfMonth();
|
||||||
|
$format = $current->format('m-Y');
|
||||||
|
$budgetSpent = $this->repository->spentInPeriod(new Collection([$budget]), $accounts, $current, $currentEnd);
|
||||||
|
$spent[$format] = $budgetSpent;
|
||||||
|
$sum = bcadd($sum, $budgetSpent);
|
||||||
|
$current->addMonth();
|
||||||
|
}
|
||||||
|
|
||||||
|
return [
|
||||||
|
'spent' => $spent,
|
||||||
|
'sum' => $sum,
|
||||||
|
];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -82,8 +82,8 @@ class ReportHelper implements ReportHelperInterface
|
|||||||
$billLine = new BillLine;
|
$billLine = new BillLine;
|
||||||
$billLine->setBill($bill);
|
$billLine->setBill($bill);
|
||||||
$billLine->setActive(intval($bill->active) === 1);
|
$billLine->setActive(intval($bill->active) === 1);
|
||||||
$billLine->setMin($bill->amount_min);
|
$billLine->setMin(strval($bill->amount_min));
|
||||||
$billLine->setMax($bill->amount_max);
|
$billLine->setMax(strval($bill->amount_max));
|
||||||
$billLine->setHit(false);
|
$billLine->setHit(false);
|
||||||
// is hit in period?
|
// is hit in period?
|
||||||
|
|
||||||
|
@@ -11,7 +11,6 @@ declare(strict_types = 1);
|
|||||||
|
|
||||||
namespace FireflyIII\Http\Controllers;
|
namespace FireflyIII\Http\Controllers;
|
||||||
|
|
||||||
use Auth;
|
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use ExpandedForm;
|
use ExpandedForm;
|
||||||
use FireflyIII\Crud\Account\AccountCrudInterface;
|
use FireflyIII\Crud\Account\AccountCrudInterface;
|
||||||
@@ -50,7 +49,7 @@ class AccountController extends Controller
|
|||||||
/**
|
/**
|
||||||
* @param string $what
|
* @param string $what
|
||||||
*
|
*
|
||||||
* @return \Illuminate\View\View
|
* @return View
|
||||||
*/
|
*/
|
||||||
public function create(string $what = 'asset')
|
public function create(string $what = 'asset')
|
||||||
{
|
{
|
||||||
@@ -116,7 +115,7 @@ class AccountController extends Controller
|
|||||||
* @param ARI $repository
|
* @param ARI $repository
|
||||||
* @param Account $account
|
* @param Account $account
|
||||||
*
|
*
|
||||||
* @return \Illuminate\View\View
|
* @return View
|
||||||
*/
|
*/
|
||||||
public function edit(ARI $repository, Account $account)
|
public function edit(ARI $repository, Account $account)
|
||||||
{
|
{
|
||||||
@@ -172,8 +171,10 @@ class AccountController extends Controller
|
|||||||
$subTitleIcon = config('firefly.subIconsByIdentifier.' . $what);
|
$subTitleIcon = config('firefly.subIconsByIdentifier.' . $what);
|
||||||
$types = config('firefly.accountTypesByIdentifier.' . $what);
|
$types = config('firefly.accountTypesByIdentifier.' . $what);
|
||||||
$accounts = $crud->getAccountsByType($types);
|
$accounts = $crud->getAccountsByType($types);
|
||||||
$start = clone session('start', Carbon::now()->startOfMonth());
|
/** @var Carbon $start */
|
||||||
$end = clone session('end', Carbon::now()->endOfMonth());
|
$start = clone session('start', Carbon::now()->startOfMonth());
|
||||||
|
/** @var Carbon $end */
|
||||||
|
$end = clone session('end', Carbon::now()->endOfMonth());
|
||||||
$start->subDay();
|
$start->subDay();
|
||||||
|
|
||||||
$ids = $accounts->pluck('id')->toArray();
|
$ids = $accounts->pluck('id')->toArray();
|
||||||
@@ -196,7 +197,7 @@ class AccountController extends Controller
|
|||||||
* @param ARI $repository
|
* @param ARI $repository
|
||||||
* @param Account $account
|
* @param Account $account
|
||||||
*
|
*
|
||||||
* @return \Illuminate\View\View
|
* @return View
|
||||||
*/
|
*/
|
||||||
public function show(ARI $repository, Account $account)
|
public function show(ARI $repository, Account $account)
|
||||||
{
|
{
|
||||||
@@ -204,15 +205,17 @@ class AccountController extends Controller
|
|||||||
$subTitleIcon = config('firefly.subIconsByIdentifier.' . $account->accountType->type);
|
$subTitleIcon = config('firefly.subIconsByIdentifier.' . $account->accountType->type);
|
||||||
$subTitle = $account->name;
|
$subTitle = $account->name;
|
||||||
$range = Preferences::get('viewRange', '1M')->data;
|
$range = Preferences::get('viewRange', '1M')->data;
|
||||||
$start = session('start', Navigation::startOfPeriod(new Carbon, $range));
|
/** @var Carbon $start */
|
||||||
$end = session('end', Navigation::endOfPeriod(new Carbon, $range));
|
$start = session('start', Navigation::startOfPeriod(new Carbon, $range));
|
||||||
$page = intval(Input::get('page'));
|
/** @var Carbon $end */
|
||||||
$pageSize = Preferences::get('transactionPageSize', 50)->data;
|
$end = session('end', Navigation::endOfPeriod(new Carbon, $range));
|
||||||
$offset = ($page - 1) * $pageSize;
|
$page = intval(Input::get('page'));
|
||||||
$set = $repository->journalsInPeriod(new Collection([$account]), [], $start, $end);
|
$pageSize = Preferences::get('transactionPageSize', 50)->data;
|
||||||
$count = $set->count();
|
$offset = ($page - 1) * $pageSize;
|
||||||
$subSet = $set->splice($offset, $pageSize);
|
$set = $repository->journalsInPeriod(new Collection([$account]), [], $start, $end);
|
||||||
$journals = new LengthAwarePaginator($subSet, $count, $pageSize, $page);
|
$count = $set->count();
|
||||||
|
$subSet = $set->splice($offset, $pageSize);
|
||||||
|
$journals = new LengthAwarePaginator($subSet, $count, $pageSize, $page);
|
||||||
$journals->setPath('accounts/show/' . $account->id);
|
$journals->setPath('accounts/show/' . $account->id);
|
||||||
|
|
||||||
// grouped other months thing:
|
// grouped other months thing:
|
||||||
@@ -287,7 +290,7 @@ class AccountController extends Controller
|
|||||||
* @param AccountFormRequest $request
|
* @param AccountFormRequest $request
|
||||||
* @param AccountCrudInterface $crud
|
* @param AccountCrudInterface $crud
|
||||||
*
|
*
|
||||||
* @return $this|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
|
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
|
||||||
*/
|
*/
|
||||||
public function store(AccountFormRequest $request, AccountCrudInterface $crud)
|
public function store(AccountFormRequest $request, AccountCrudInterface $crud)
|
||||||
{
|
{
|
||||||
@@ -297,7 +300,7 @@ class AccountController extends Controller
|
|||||||
'virtualBalance' => round($request->input('virtualBalance'), 2),
|
'virtualBalance' => round($request->input('virtualBalance'), 2),
|
||||||
'virtualBalanceCurrency' => intval($request->input('amount_currency_id_virtualBalance')),
|
'virtualBalanceCurrency' => intval($request->input('amount_currency_id_virtualBalance')),
|
||||||
'active' => true,
|
'active' => true,
|
||||||
'user' => Auth::user()->id,
|
'user' => auth()->user()->id,
|
||||||
'iban' => $request->input('iban'),
|
'iban' => $request->input('iban'),
|
||||||
'accountNumber' => $request->input('accountNumber'),
|
'accountNumber' => $request->input('accountNumber'),
|
||||||
'accountRole' => $request->input('accountRole'),
|
'accountRole' => $request->input('accountRole'),
|
||||||
@@ -335,7 +338,7 @@ class AccountController extends Controller
|
|||||||
* @param AccountCrudInterface $crud
|
* @param AccountCrudInterface $crud
|
||||||
* @param Account $account
|
* @param Account $account
|
||||||
*
|
*
|
||||||
* @return $this|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
|
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
|
||||||
*/
|
*/
|
||||||
public function update(AccountFormRequest $request, AccountCrudInterface $crud, Account $account)
|
public function update(AccountFormRequest $request, AccountCrudInterface $crud, Account $account)
|
||||||
{
|
{
|
||||||
@@ -343,7 +346,7 @@ class AccountController extends Controller
|
|||||||
$accountData = [
|
$accountData = [
|
||||||
'name' => $request->input('name'),
|
'name' => $request->input('name'),
|
||||||
'active' => $request->input('active'),
|
'active' => $request->input('active'),
|
||||||
'user' => Auth::user()->id,
|
'user' => auth()->user()->id,
|
||||||
'iban' => $request->input('iban'),
|
'iban' => $request->input('iban'),
|
||||||
'accountNumber' => $request->input('accountNumber'),
|
'accountNumber' => $request->input('accountNumber'),
|
||||||
'accountRole' => $request->input('accountRole'),
|
'accountRole' => $request->input('accountRole'),
|
||||||
|
77
app/Http/Controllers/Admin/ConfigurationController.php
Normal file
77
app/Http/Controllers/Admin/ConfigurationController.php
Normal file
@@ -0,0 +1,77 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* ConfigurationController.php
|
||||||
|
* Copyright (C) 2016 thegrumpydictator@gmail.com
|
||||||
|
*
|
||||||
|
* This software may be modified and distributed under the terms
|
||||||
|
* of the MIT license. See the LICENSE file for details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
declare(strict_types = 1);
|
||||||
|
|
||||||
|
namespace FireflyIII\Http\Controllers\Admin;
|
||||||
|
|
||||||
|
|
||||||
|
use Config;
|
||||||
|
use FireflyIII\Http\Controllers\Controller;
|
||||||
|
use FireflyIII\Http\Requests\ConfigurationRequest;
|
||||||
|
use FireflyIII\Support\Facades\FireflyConfig;
|
||||||
|
use Preferences;
|
||||||
|
use Redirect;
|
||||||
|
use Session;
|
||||||
|
use View;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class ConfigurationController
|
||||||
|
*
|
||||||
|
* @package FireflyIII\Http\Controllers\Admin
|
||||||
|
*/
|
||||||
|
class ConfigurationController extends Controller
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* ConfigurationController constructor.
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
parent::__construct();
|
||||||
|
|
||||||
|
View::share('title', strval(trans('firefly.administration')));
|
||||||
|
View::share('mainTitleIcon', 'fa-hand-spock-o');
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return View
|
||||||
|
*/
|
||||||
|
public function index()
|
||||||
|
{
|
||||||
|
$subTitle = strval(trans('firefly.instance_configuration'));
|
||||||
|
$subTitleIcon = 'fa-wrench';
|
||||||
|
|
||||||
|
// all available configuration and their default value in case
|
||||||
|
// they don't exist yet.
|
||||||
|
$singleUserMode = FireflyConfig::get('single_user_mode', Config::get('firefly.configuration.single_user_mode'))->data;
|
||||||
|
|
||||||
|
return view('admin.configuration.index', compact('subTitle', 'subTitleIcon', 'singleUserMode'));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param ConfigurationRequest $request
|
||||||
|
*/
|
||||||
|
public function store(ConfigurationRequest $request)
|
||||||
|
{
|
||||||
|
// get config values:
|
||||||
|
$singleUserMode = intval($request->get('single_user_mode')) === 1 ? true : false;
|
||||||
|
|
||||||
|
// store config values
|
||||||
|
FireflyConfig::set('single_user_mode', $singleUserMode);
|
||||||
|
|
||||||
|
// flash message
|
||||||
|
Session::flash('success', strval(trans('firefly.configuration_updated')));
|
||||||
|
Preferences::mark();
|
||||||
|
|
||||||
|
return Redirect::route('admin.configuration.index');
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@@ -35,7 +35,7 @@ class DomainController extends Controller
|
|||||||
$title = strval(trans('firefly.administration'));
|
$title = strval(trans('firefly.administration'));
|
||||||
$mainTitleIcon = 'fa-hand-spock-o';
|
$mainTitleIcon = 'fa-hand-spock-o';
|
||||||
$subTitle = strval(trans('firefly.blocked_domains'));
|
$subTitle = strval(trans('firefly.blocked_domains'));
|
||||||
$subTitleIcon = 'fa-users';
|
$subTitleIcon = 'fa-exclamation-circle';
|
||||||
$domains = FireflyConfig::get('blocked-domains', [])->data;
|
$domains = FireflyConfig::get('blocked-domains', [])->data;
|
||||||
|
|
||||||
// known domains
|
// known domains
|
||||||
@@ -58,7 +58,7 @@ class DomainController extends Controller
|
|||||||
return redirect(route('admin.users.domains'));
|
return redirect(route('admin.users.domains'));
|
||||||
}
|
}
|
||||||
|
|
||||||
$domain = $request->get('domain');
|
$domain = strtolower($request->get('domain'));
|
||||||
$blocked = FireflyConfig::get('blocked-domains', [])->data;
|
$blocked = FireflyConfig::get('blocked-domains', [])->data;
|
||||||
|
|
||||||
if (in_array($domain, $blocked)) {
|
if (in_array($domain, $blocked)) {
|
||||||
|
@@ -47,7 +47,7 @@ class AttachmentController extends Controller
|
|||||||
/**
|
/**
|
||||||
* @param Attachment $attachment
|
* @param Attachment $attachment
|
||||||
*
|
*
|
||||||
* @return \Illuminate\View\View
|
* @return View
|
||||||
*/
|
*/
|
||||||
public function delete(Attachment $attachment)
|
public function delete(Attachment $attachment)
|
||||||
{
|
{
|
||||||
@@ -93,10 +93,10 @@ class AttachmentController extends Controller
|
|||||||
|
|
||||||
if ($disk->exists($file)) {
|
if ($disk->exists($file)) {
|
||||||
|
|
||||||
$quoted = sprintf('"%s"', addcslashes(basename($attachment->filename), '"\\'));
|
$quoted = sprintf('"%s"', addcslashes(basename($attachment->filename), '"\\'));
|
||||||
$content = Crypt::decrypt($disk->get($file));
|
$content = Crypt::decrypt($disk->get($file));
|
||||||
|
|
||||||
Log::debug('Send file to user', ['file' => $quoted, 'size' => strlen($content)]);
|
Log::debug('Send file to user', ['file' => $quoted, 'size' => strlen($content)]);
|
||||||
|
|
||||||
return response($content, 200)
|
return response($content, 200)
|
||||||
->header('Content-Description', 'File Transfer')
|
->header('Content-Description', 'File Transfer')
|
||||||
@@ -116,7 +116,7 @@ class AttachmentController extends Controller
|
|||||||
/**
|
/**
|
||||||
* @param Attachment $attachment
|
* @param Attachment $attachment
|
||||||
*
|
*
|
||||||
* @return \Illuminate\View\View
|
* @return View
|
||||||
*/
|
*/
|
||||||
public function edit(Attachment $attachment)
|
public function edit(Attachment $attachment)
|
||||||
{
|
{
|
||||||
|
@@ -11,21 +11,10 @@ declare(strict_types = 1);
|
|||||||
|
|
||||||
namespace FireflyIII\Http\Controllers\Auth;
|
namespace FireflyIII\Http\Controllers\Auth;
|
||||||
|
|
||||||
use Auth;
|
|
||||||
use FireflyIII\Events\UserRegistration;
|
|
||||||
use FireflyIII\Exceptions\FireflyException;
|
|
||||||
use FireflyIII\Http\Controllers\Controller;
|
use FireflyIII\Http\Controllers\Controller;
|
||||||
use FireflyIII\Support\Facades\FireflyConfig;
|
|
||||||
use FireflyIII\User;
|
use FireflyIII\User;
|
||||||
use Illuminate\Foundation\Auth\AuthenticatesAndRegistersUsers;
|
use Illuminate\Foundation\Auth\AuthenticatesAndRegistersUsers;
|
||||||
use Illuminate\Foundation\Auth\ThrottlesLogins;
|
use Illuminate\Foundation\Auth\ThrottlesLogins;
|
||||||
use Illuminate\Http\Request;
|
|
||||||
use Illuminate\Mail\Message;
|
|
||||||
use Illuminate\Support\Facades\Lang;
|
|
||||||
use Log;
|
|
||||||
use Mail;
|
|
||||||
use Session;
|
|
||||||
use Swift_TransportException;
|
|
||||||
use Validator;
|
use Validator;
|
||||||
|
|
||||||
|
|
||||||
@@ -55,107 +44,6 @@ class AuthController extends Controller
|
|||||||
parent::__construct();
|
parent::__construct();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Handle a login request to the application.
|
|
||||||
*
|
|
||||||
* @param \Illuminate\Http\Request $request
|
|
||||||
*
|
|
||||||
* @return \Illuminate\Http\Response
|
|
||||||
*/
|
|
||||||
public function login(Request $request)
|
|
||||||
{
|
|
||||||
|
|
||||||
$this->validate($request, [$this->loginUsername() => 'required', 'password' => 'required',]);
|
|
||||||
$throttles = $this->isUsingThrottlesLoginsTrait();
|
|
||||||
|
|
||||||
if ($throttles && $this->hasTooManyLoginAttempts($request)) {
|
|
||||||
return $this->sendLockoutResponse($request);
|
|
||||||
}
|
|
||||||
|
|
||||||
$credentials = $this->getCredentials($request);
|
|
||||||
$credentials['blocked'] = 0; // most not be blocked.
|
|
||||||
|
|
||||||
if (Auth::guard($this->getGuard())->attempt($credentials, $request->has('remember'))) {
|
|
||||||
return $this->handleUserWasAuthenticated($request, $throttles);
|
|
||||||
}
|
|
||||||
|
|
||||||
// check if user is blocked:
|
|
||||||
$errorMessage = '';
|
|
||||||
/** @var User $foundUser */
|
|
||||||
$foundUser = User::where('email', $credentials['email'])->where('blocked', 1)->first();
|
|
||||||
if (!is_null($foundUser)) {
|
|
||||||
// if it exists, show message:
|
|
||||||
$code = strlen(strval($foundUser->blocked_code)) > 0 ? $foundUser->blocked_code : 'general_blocked';
|
|
||||||
$errorMessage = strval(trans('firefly.' . $code . '_error', ['email' => $credentials['email']]));
|
|
||||||
$this->reportBlockedUserLoginAttempt($foundUser, $code, $request->ip());
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($throttles) {
|
|
||||||
$this->incrementLoginAttempts($request);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this->sendFailedLoginResponse($request, $errorMessage);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Handle a registration request for the application.
|
|
||||||
*
|
|
||||||
* @param \Illuminate\Http\Request $request
|
|
||||||
*
|
|
||||||
* @return \Illuminate\Http\Response
|
|
||||||
* @throws FireflyException
|
|
||||||
* @throws \Illuminate\Foundation\Validation\ValidationException
|
|
||||||
*/
|
|
||||||
public function register(Request $request)
|
|
||||||
{
|
|
||||||
$validator = $this->validator($request->all());
|
|
||||||
|
|
||||||
if ($validator->fails()) {
|
|
||||||
$this->throwValidationException(
|
|
||||||
$request, $validator
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
$data = $request->all();
|
|
||||||
$data['password'] = bcrypt($data['password']);
|
|
||||||
|
|
||||||
// is user email domain blocked?
|
|
||||||
if ($this->isBlockedDomain($data['email'])) {
|
|
||||||
$validator->getMessageBag()->add('email', (string)trans('validation.invalid_domain'));
|
|
||||||
|
|
||||||
$this->reportBlockedDomainRegistrationAttempt($data['email'], $request->ip());
|
|
||||||
|
|
||||||
$this->throwValidationException(
|
|
||||||
$request, $validator
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
$user = $this->create($request->all());
|
|
||||||
|
|
||||||
// trigger user registration event:
|
|
||||||
event(new UserRegistration($user, $request->ip()));
|
|
||||||
|
|
||||||
Auth::login($user);
|
|
||||||
|
|
||||||
Session::flash('success', strval(trans('firefly.registered')));
|
|
||||||
Session::flash('gaEventCategory', 'user');
|
|
||||||
Session::flash('gaEventAction', 'new-registration');
|
|
||||||
|
|
||||||
return redirect($this->redirectPath());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Show the application registration form.
|
|
||||||
*
|
|
||||||
* @return \Illuminate\Http\Response
|
|
||||||
*/
|
|
||||||
public function showRegistrationForm()
|
|
||||||
{
|
|
||||||
$showDemoWarning = env('SHOW_DEMO_WARNING', false);
|
|
||||||
|
|
||||||
return view('auth.register', compact('showDemoWarning'));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new user instance after a valid registration.
|
* Create a new user instance after a valid registration.
|
||||||
@@ -174,67 +62,6 @@ class AuthController extends Controller
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
protected function getBlockedDomains()
|
|
||||||
{
|
|
||||||
return FireflyConfig::get('blocked-domains', [])->data;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the failed login message.
|
|
||||||
*
|
|
||||||
* @param string $message
|
|
||||||
*
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
protected function getFailedLoginMessage(string $message)
|
|
||||||
{
|
|
||||||
if (strlen($message) > 0) {
|
|
||||||
return $message;
|
|
||||||
}
|
|
||||||
|
|
||||||
return Lang::has('auth.failed')
|
|
||||||
? Lang::get('auth.failed')
|
|
||||||
: 'These credentials do not match our records.';
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param string $email
|
|
||||||
*
|
|
||||||
* @return bool
|
|
||||||
*/
|
|
||||||
protected function isBlockedDomain(string $email)
|
|
||||||
{
|
|
||||||
$parts = explode('@', $email);
|
|
||||||
$blocked = $this->getBlockedDomains();
|
|
||||||
|
|
||||||
if (isset($parts[1]) && in_array($parts[1], $blocked)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the failed login response instance.
|
|
||||||
*
|
|
||||||
* @param \Illuminate\Http\Request $request
|
|
||||||
* @param string $message
|
|
||||||
*
|
|
||||||
* @return \Illuminate\Http\Response
|
|
||||||
*/
|
|
||||||
protected function sendFailedLoginResponse(Request $request, string $message)
|
|
||||||
{
|
|
||||||
return redirect()->back()
|
|
||||||
->withInput($request->only($this->loginUsername(), 'remember'))
|
|
||||||
->withErrors(
|
|
||||||
[
|
|
||||||
$this->loginUsername() => $this->getFailedLoginMessage($message),
|
|
||||||
]
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a validator for an incoming registration request.
|
* Get a validator for an incoming registration request.
|
||||||
@@ -253,61 +80,5 @@ class AuthController extends Controller
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Send a message home about a blocked domain and the address attempted to register.
|
|
||||||
*
|
|
||||||
* @param string $registrationMail
|
|
||||||
* @param string $ipAddress
|
|
||||||
*/
|
|
||||||
private function reportBlockedDomainRegistrationAttempt(string $registrationMail, string $ipAddress)
|
|
||||||
{
|
|
||||||
try {
|
|
||||||
$email = env('SITE_OWNER', false);
|
|
||||||
$parts = explode('@', $registrationMail);
|
|
||||||
$domain = $parts[1];
|
|
||||||
$fields = [
|
|
||||||
'email_address' => $registrationMail,
|
|
||||||
'blocked_domain' => $domain,
|
|
||||||
'ip' => $ipAddress,
|
|
||||||
];
|
|
||||||
|
|
||||||
Mail::send(
|
|
||||||
['emails.blocked-registration-html', 'emails.blocked-registration'], $fields, function (Message $message) use ($email, $domain) {
|
|
||||||
$message->to($email, $email)->subject('Blocked a registration attempt with domain ' . $domain . '.');
|
|
||||||
}
|
|
||||||
);
|
|
||||||
} catch (Swift_TransportException $e) {
|
|
||||||
Log::error($e->getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Send a message home about the blocked attempt to login.
|
|
||||||
* Perhaps in a later stage, simply log these messages.
|
|
||||||
*
|
|
||||||
* @param User $user
|
|
||||||
* @param string $code
|
|
||||||
* @param string $ipAddress
|
|
||||||
*/
|
|
||||||
private function reportBlockedUserLoginAttempt(User $user, string $code, string $ipAddress)
|
|
||||||
{
|
|
||||||
|
|
||||||
try {
|
|
||||||
$email = env('SITE_OWNER', false);
|
|
||||||
$fields = [
|
|
||||||
'user_id' => $user->id,
|
|
||||||
'user_address' => $user->email,
|
|
||||||
'code' => $code,
|
|
||||||
'ip' => $ipAddress,
|
|
||||||
];
|
|
||||||
|
|
||||||
Mail::send(
|
|
||||||
['emails.blocked-login-html', 'emails.blocked-login'], $fields, function (Message $message) use ($email, $user) {
|
|
||||||
$message->to($email, $email)->subject('Blocked a login attempt from ' . trim($user->email) . '.');
|
|
||||||
}
|
|
||||||
);
|
|
||||||
} catch (Swift_TransportException $e) {
|
|
||||||
Log::error($e->getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@@ -11,7 +11,6 @@ declare(strict_types = 1);
|
|||||||
|
|
||||||
namespace FireflyIII\Http\Controllers\Auth;
|
namespace FireflyIII\Http\Controllers\Auth;
|
||||||
|
|
||||||
use Auth;
|
|
||||||
use FireflyIII\Events\ResendConfirmation;
|
use FireflyIII\Events\ResendConfirmation;
|
||||||
use FireflyIII\Events\UserIsConfirmed;
|
use FireflyIII\Events\UserIsConfirmed;
|
||||||
use FireflyIII\Exceptions\FireflyException;
|
use FireflyIII\Exceptions\FireflyException;
|
||||||
@@ -55,10 +54,10 @@ class ConfirmationController extends Controller
|
|||||||
if ($database === $code && ($now - $time <= $maxDiff)) {
|
if ($database === $code && ($now - $time <= $maxDiff)) {
|
||||||
|
|
||||||
// trigger user registration event:
|
// trigger user registration event:
|
||||||
event(new UserIsConfirmed(Auth::user(), $request->ip()));
|
event(new UserIsConfirmed(auth()->user(), $request->ip()));
|
||||||
|
|
||||||
Preferences::setForUser(Auth::user(), 'user_confirmed', true);
|
Preferences::setForUser(auth()->user(), 'user_confirmed', true);
|
||||||
Preferences::setForUser(Auth::user(), 'user_confirmed_confirmed', time());
|
Preferences::setForUser(auth()->user(), 'user_confirmed_confirmed', time());
|
||||||
Session::flash('success', strval(trans('firefly.account_is_confirmed')));
|
Session::flash('success', strval(trans('firefly.account_is_confirmed')));
|
||||||
|
|
||||||
return redirect(route('home'));
|
return redirect(route('home'));
|
||||||
@@ -68,6 +67,8 @@ class ConfirmationController extends Controller
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Request $request
|
* @param Request $request
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
||||||
*/
|
*/
|
||||||
public function resendConfirmation(Request $request)
|
public function resendConfirmation(Request $request)
|
||||||
{
|
{
|
||||||
@@ -77,7 +78,7 @@ class ConfirmationController extends Controller
|
|||||||
$owner = env('SITE_OWNER', 'mail@example.com');
|
$owner = env('SITE_OWNER', 'mail@example.com');
|
||||||
$view = 'auth.confirmation.no-resent';
|
$view = 'auth.confirmation.no-resent';
|
||||||
if ($now - $time > $maxDiff) {
|
if ($now - $time > $maxDiff) {
|
||||||
event(new ResendConfirmation(Auth::user(), $request->ip()));
|
event(new ResendConfirmation(auth()->user(), $request->ip()));
|
||||||
$view = 'auth.confirmation.resent';
|
$view = 'auth.confirmation.resent';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
34
app/Http/Controllers/Auth/ForgotPasswordController.php
Executable file
34
app/Http/Controllers/Auth/ForgotPasswordController.php
Executable file
@@ -0,0 +1,34 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* ForgotPasswordController.php
|
||||||
|
* Copyright (C) 2016 thegrumpydictator@gmail.com
|
||||||
|
*
|
||||||
|
* This software may be modified and distributed under the terms
|
||||||
|
* of the MIT license. See the LICENSE file for details.
|
||||||
|
*/
|
||||||
|
declare(strict_types = 1);
|
||||||
|
|
||||||
|
namespace FireflyIII\Http\Controllers\Auth;
|
||||||
|
|
||||||
|
use FireflyIII\Http\Controllers\Controller;
|
||||||
|
use Illuminate\Foundation\Auth\SendsPasswordResetEmails;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class ForgotPasswordController
|
||||||
|
*
|
||||||
|
* @package FireflyIII\Http\Controllers\Auth
|
||||||
|
*/
|
||||||
|
class ForgotPasswordController extends Controller
|
||||||
|
{
|
||||||
|
use SendsPasswordResetEmails;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new controller instance.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
parent::__construct();
|
||||||
|
$this->middleware('guest');
|
||||||
|
}
|
||||||
|
}
|
195
app/Http/Controllers/Auth/LoginController.php
Executable file
195
app/Http/Controllers/Auth/LoginController.php
Executable file
@@ -0,0 +1,195 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* LoginController.php
|
||||||
|
* Copyright (C) 2016 thegrumpydictator@gmail.com
|
||||||
|
*
|
||||||
|
* This software may be modified and distributed under the terms
|
||||||
|
* of the MIT license. See the LICENSE file for details.
|
||||||
|
*/
|
||||||
|
declare(strict_types = 1);
|
||||||
|
|
||||||
|
namespace FireflyIII\Http\Controllers\Auth;
|
||||||
|
|
||||||
|
use Config;
|
||||||
|
use FireflyConfig;
|
||||||
|
use FireflyIII\Http\Controllers\Controller;
|
||||||
|
use FireflyIII\User;
|
||||||
|
use Illuminate\Foundation\Auth\AuthenticatesUsers;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Mail\Message;
|
||||||
|
use Lang;
|
||||||
|
use Log;
|
||||||
|
use Mail;
|
||||||
|
use Swift_TransportException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class LoginController
|
||||||
|
*
|
||||||
|
* @package FireflyIII\Http\Controllers\Auth
|
||||||
|
*/
|
||||||
|
class LoginController extends Controller
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Login Controller
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| This controller handles authenticating users for the application and
|
||||||
|
| redirecting them to your home screen. The controller uses a trait
|
||||||
|
| to conveniently provide its functionality to your applications.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
use AuthenticatesUsers;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Where to redirect users after login / registration.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $redirectTo = '/home';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new controller instance.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
parent::__construct();
|
||||||
|
$this->middleware('guest', ['except' => 'logout']);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle a login request to the application.
|
||||||
|
*
|
||||||
|
* @param \Illuminate\Http\Request $request
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function login(Request $request)
|
||||||
|
{
|
||||||
|
$this->validateLogin($request);
|
||||||
|
|
||||||
|
// If the class is using the ThrottlesLogins trait, we can automatically throttle
|
||||||
|
// the login attempts for this application. We'll key this by the username and
|
||||||
|
// the IP address of the client making these requests into this application.
|
||||||
|
if ($lockedOut = $this->hasTooManyLoginAttempts($request)) {
|
||||||
|
$this->fireLockoutEvent($request);
|
||||||
|
|
||||||
|
return $this->sendLockoutResponse($request);
|
||||||
|
}
|
||||||
|
|
||||||
|
$credentials = $this->credentials($request);
|
||||||
|
$credentials['blocked'] = 0; // most not be blocked.
|
||||||
|
|
||||||
|
if ($this->guard()->attempt($credentials, $request->has('remember'))) {
|
||||||
|
return $this->sendLoginResponse($request);
|
||||||
|
}
|
||||||
|
|
||||||
|
// check if user is blocked:
|
||||||
|
$errorMessage = '';
|
||||||
|
/** @var User $foundUser */
|
||||||
|
$foundUser = User::where('email', $credentials['email'])->where('blocked', 1)->first();
|
||||||
|
if (!is_null($foundUser)) {
|
||||||
|
// if it exists, show message:
|
||||||
|
$code = strlen(strval($foundUser->blocked_code)) > 0 ? $foundUser->blocked_code : 'general_blocked';
|
||||||
|
$errorMessage = strval(trans('firefly.' . $code . '_error', ['email' => $credentials['email']]));
|
||||||
|
$this->reportBlockedUserLoginAttempt($foundUser, $code, $request->ip());
|
||||||
|
}
|
||||||
|
|
||||||
|
// If the login attempt was unsuccessful we will increment the number of attempts
|
||||||
|
// to login and redirect the user back to the login form. Of course, when this
|
||||||
|
// user surpasses their maximum number of attempts they will get locked out.
|
||||||
|
if (!$lockedOut) {
|
||||||
|
$this->incrementLoginAttempts($request);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->sendFailedLoginResponse($request, $errorMessage);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the application login form.
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function showLoginForm(Request $request)
|
||||||
|
{
|
||||||
|
// is allowed to?
|
||||||
|
$singleUserMode = FireflyConfig::get('single_user_mode', Config::get('firefly.configuration.single_user_mode'))->data;
|
||||||
|
$userCount = User::count();
|
||||||
|
$allowRegistration = true;
|
||||||
|
if ($singleUserMode === true && $userCount > 0) {
|
||||||
|
$allowRegistration = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
$email = $request->old('email');
|
||||||
|
$remember = $request->old('remember');
|
||||||
|
|
||||||
|
return view('auth.login', compact('allowRegistration', 'email', 'remember'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the failed login message.
|
||||||
|
*
|
||||||
|
* @param string $message
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
protected function getFailedLoginMessage(string $message)
|
||||||
|
{
|
||||||
|
if (strlen($message) > 0) {
|
||||||
|
return $message;
|
||||||
|
}
|
||||||
|
|
||||||
|
return Lang::has('auth.failed') ? Lang::get('auth.failed') : 'These credentials do not match our records.';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the failed login response instance.
|
||||||
|
*
|
||||||
|
* @param \Illuminate\Http\Request $request
|
||||||
|
* @param string $message
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Http\RedirectResponse
|
||||||
|
*/
|
||||||
|
protected function sendFailedLoginResponse(Request $request, string $message)
|
||||||
|
{
|
||||||
|
return redirect()->back()
|
||||||
|
->withInput($request->only($this->username(), 'remember'))
|
||||||
|
->withErrors(
|
||||||
|
[
|
||||||
|
$this->username() => $this->getFailedLoginMessage($message),
|
||||||
|
]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Send a message home about the blocked attempt to login.
|
||||||
|
* Perhaps in a later stage, simply log these messages.
|
||||||
|
*
|
||||||
|
* @param User $user
|
||||||
|
* @param string $code
|
||||||
|
* @param string $ipAddress
|
||||||
|
*/
|
||||||
|
private function reportBlockedUserLoginAttempt(User $user, string $code, string $ipAddress)
|
||||||
|
{
|
||||||
|
|
||||||
|
try {
|
||||||
|
$email = env('SITE_OWNER', false);
|
||||||
|
$fields = [
|
||||||
|
'user_id' => $user->id,
|
||||||
|
'user_address' => $user->email,
|
||||||
|
'code' => $code,
|
||||||
|
'ip' => $ipAddress,
|
||||||
|
];
|
||||||
|
|
||||||
|
Mail::send(
|
||||||
|
['emails.blocked-login-html', 'emails.blocked-login'], $fields, function (Message $message) use ($email, $user) {
|
||||||
|
$message->to($email, $email)->subject('Blocked a login attempt from ' . trim($user->email) . '.');
|
||||||
|
}
|
||||||
|
);
|
||||||
|
} catch (Swift_TransportException $e) {
|
||||||
|
Log::error($e->getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@@ -23,6 +23,7 @@ use Illuminate\Support\Facades\Password;
|
|||||||
* Class PasswordController
|
* Class PasswordController
|
||||||
*
|
*
|
||||||
* @package FireflyIII\Http\Controllers\Auth
|
* @package FireflyIII\Http\Controllers\Auth
|
||||||
|
* @method getEmailSubject
|
||||||
*/
|
*/
|
||||||
class PasswordController extends Controller
|
class PasswordController extends Controller
|
||||||
{
|
{
|
||||||
@@ -55,7 +56,7 @@ class PasswordController extends Controller
|
|||||||
*
|
*
|
||||||
* @param \Illuminate\Http\Request $request
|
* @param \Illuminate\Http\Request $request
|
||||||
*
|
*
|
||||||
* @return \Illuminate\Http\Response
|
* @return \Symfony\Component\HttpFoundation\Response
|
||||||
*/
|
*/
|
||||||
public function sendResetLinkEmail(Request $request)
|
public function sendResetLinkEmail(Request $request)
|
||||||
{
|
{
|
||||||
|
224
app/Http/Controllers/Auth/RegisterController.php
Executable file
224
app/Http/Controllers/Auth/RegisterController.php
Executable file
@@ -0,0 +1,224 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* RegisterController.php
|
||||||
|
* Copyright (C) 2016 thegrumpydictator@gmail.com
|
||||||
|
*
|
||||||
|
* This software may be modified and distributed under the terms
|
||||||
|
* of the MIT license. See the LICENSE file for details.
|
||||||
|
*/
|
||||||
|
declare(strict_types = 1);
|
||||||
|
|
||||||
|
namespace FireflyIII\Http\Controllers\Auth;
|
||||||
|
|
||||||
|
use Auth;
|
||||||
|
use Config;
|
||||||
|
use FireflyIII\Events\UserRegistration;
|
||||||
|
use FireflyIII\Http\Controllers\Controller;
|
||||||
|
use FireflyIII\Support\Facades\FireflyConfig;
|
||||||
|
use FireflyIII\User;
|
||||||
|
use Illuminate\Foundation\Auth\RegistersUsers;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Mail\Message;
|
||||||
|
use Log;
|
||||||
|
use Mail;
|
||||||
|
use Session;
|
||||||
|
use Swift_TransportException;
|
||||||
|
use Validator;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class RegisterController
|
||||||
|
*
|
||||||
|
* @package FireflyIII\Http\Controllers\Auth
|
||||||
|
*/
|
||||||
|
class RegisterController extends Controller
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Register Controller
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| This controller handles the registration of new users as well as their
|
||||||
|
| validation and creation. By default this controller uses a trait to
|
||||||
|
| provide this functionality without requiring any additional code.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
use RegistersUsers;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Where to redirect users after login / registration.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $redirectTo = '/home';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new controller instance.
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
parent::__construct();
|
||||||
|
$this->middleware('guest');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Request $request
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Contracts\View\Factory|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector|\Illuminate\View\View
|
||||||
|
*/
|
||||||
|
public function register(Request $request)
|
||||||
|
{
|
||||||
|
// is allowed to?
|
||||||
|
$singleUserMode = FireflyConfig::get('single_user_mode', Config::get('firefly.configuration.single_user_mode'))->data;
|
||||||
|
$userCount = User::count();
|
||||||
|
if ($singleUserMode === true && $userCount > 0) {
|
||||||
|
$message = 'Registration is currently not available.';
|
||||||
|
|
||||||
|
return view('error', compact('message'));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
$validator = $this->validator($request->all());
|
||||||
|
|
||||||
|
if ($validator->fails()) {
|
||||||
|
$this->throwValidationException($request, $validator);
|
||||||
|
}
|
||||||
|
|
||||||
|
$data = $request->all();
|
||||||
|
$data['password'] = bcrypt($data['password']);
|
||||||
|
|
||||||
|
// is user email domain blocked?
|
||||||
|
if ($this->isBlockedDomain($data['email'])) {
|
||||||
|
$validator->getMessageBag()->add('email', (string)trans('validation.invalid_domain'));
|
||||||
|
|
||||||
|
$this->reportBlockedDomainRegistrationAttempt($data['email'], $request->ip());
|
||||||
|
|
||||||
|
$this->throwValidationException($request, $validator);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
$user = $this->create($request->all());
|
||||||
|
|
||||||
|
// trigger user registration event:
|
||||||
|
event(new UserRegistration($user, $request->ip()));
|
||||||
|
|
||||||
|
Auth::login($user);
|
||||||
|
|
||||||
|
Session::flash('success', strval(trans('firefly.registered')));
|
||||||
|
Session::flash('gaEventCategory', 'user');
|
||||||
|
Session::flash('gaEventAction', 'new-registration');
|
||||||
|
|
||||||
|
return redirect($this->redirectPath());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* OLD
|
||||||
|
* Show the application registration form.
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function showRegistrationForm(Request $request)
|
||||||
|
{
|
||||||
|
$showDemoWarning = config('firefly.show-demo-warning', false);
|
||||||
|
|
||||||
|
// is allowed to?
|
||||||
|
$singleUserMode = FireflyConfig::get('single_user_mode', Config::get('firefly.configuration.single_user_mode'))->data;
|
||||||
|
$userCount = User::count();
|
||||||
|
if ($singleUserMode === true && $userCount > 0) {
|
||||||
|
$message = 'Registration is currently not available.';
|
||||||
|
|
||||||
|
return view('error', compact('message'));
|
||||||
|
}
|
||||||
|
|
||||||
|
$email = $request->old('email');
|
||||||
|
|
||||||
|
return view('auth.register', compact('showDemoWarning', 'email'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new user instance after a valid registration.
|
||||||
|
*
|
||||||
|
* @param array $data
|
||||||
|
*
|
||||||
|
* @return User
|
||||||
|
*/
|
||||||
|
protected function create(array $data)
|
||||||
|
{
|
||||||
|
return User::create(
|
||||||
|
[
|
||||||
|
'email' => $data['email'],
|
||||||
|
'password' => bcrypt($data['password']),
|
||||||
|
]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a validator for an incoming registration request.
|
||||||
|
*
|
||||||
|
* @param array $data
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Contracts\Validation\Validator
|
||||||
|
*/
|
||||||
|
protected function validator(array $data)
|
||||||
|
{
|
||||||
|
return Validator::make(
|
||||||
|
$data, [
|
||||||
|
'email' => 'required|email|max:255|unique:users',
|
||||||
|
'password' => 'required|min:6|confirmed',
|
||||||
|
]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
private function getBlockedDomains()
|
||||||
|
{
|
||||||
|
return FireflyConfig::get('blocked-domains', [])->data;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $email
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
private function isBlockedDomain(string $email)
|
||||||
|
{
|
||||||
|
$parts = explode('@', $email);
|
||||||
|
$blocked = $this->getBlockedDomains();
|
||||||
|
|
||||||
|
if (isset($parts[1]) && in_array($parts[1], $blocked)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Send a message home about a blocked domain and the address attempted to register.
|
||||||
|
*
|
||||||
|
* @param string $registrationMail
|
||||||
|
* @param string $ipAddress
|
||||||
|
*/
|
||||||
|
private function reportBlockedDomainRegistrationAttempt(string $registrationMail, string $ipAddress)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$email = env('SITE_OWNER', false);
|
||||||
|
$parts = explode('@', $registrationMail);
|
||||||
|
$domain = $parts[1];
|
||||||
|
$fields = [
|
||||||
|
'email_address' => $registrationMail,
|
||||||
|
'blocked_domain' => $domain,
|
||||||
|
'ip' => $ipAddress,
|
||||||
|
];
|
||||||
|
|
||||||
|
Mail::send(
|
||||||
|
['emails.blocked-registration-html', 'emails.blocked-registration'], $fields, function (Message $message) use ($email, $domain) {
|
||||||
|
$message->to($email, $email)->subject('Blocked a registration attempt with domain ' . $domain . '.');
|
||||||
|
}
|
||||||
|
);
|
||||||
|
} catch (Swift_TransportException $e) {
|
||||||
|
Log::error($e->getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
44
app/Http/Controllers/Auth/ResetPasswordController.php
Executable file
44
app/Http/Controllers/Auth/ResetPasswordController.php
Executable file
@@ -0,0 +1,44 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* ResetPasswordController.php
|
||||||
|
* Copyright (C) 2016 thegrumpydictator@gmail.com
|
||||||
|
*
|
||||||
|
* This software may be modified and distributed under the terms
|
||||||
|
* of the MIT license. See the LICENSE file for details.
|
||||||
|
*/
|
||||||
|
declare(strict_types = 1);
|
||||||
|
|
||||||
|
namespace FireflyIII\Http\Controllers\Auth;
|
||||||
|
|
||||||
|
use FireflyIII\Http\Controllers\Controller;
|
||||||
|
use Illuminate\Foundation\Auth\ResetsPasswords;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class ResetPasswordController
|
||||||
|
*
|
||||||
|
* @package FireflyIII\Http\Controllers\Auth
|
||||||
|
*/
|
||||||
|
class ResetPasswordController extends Controller
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Password Reset Controller
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| This controller is responsible for handling password reset requests
|
||||||
|
| and uses a simple trait to include this behavior. You're free to
|
||||||
|
| explore this trait and override any methods you wish to tweak.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
use ResetsPasswords;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new controller instance.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->middleware('guest');
|
||||||
|
}
|
||||||
|
}
|
@@ -11,7 +11,6 @@ declare(strict_types = 1);
|
|||||||
|
|
||||||
namespace FireflyIII\Http\Controllers\Auth;
|
namespace FireflyIII\Http\Controllers\Auth;
|
||||||
|
|
||||||
use Auth;
|
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use FireflyIII\Exceptions\FireflyException;
|
use FireflyIII\Exceptions\FireflyException;
|
||||||
use FireflyIII\Http\Controllers\Controller;
|
use FireflyIII\Http\Controllers\Controller;
|
||||||
@@ -34,7 +33,7 @@ class TwoFactorController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function index()
|
public function index()
|
||||||
{
|
{
|
||||||
$user = Auth::user();
|
$user = auth()->user();
|
||||||
|
|
||||||
// to make sure the validator in the next step gets the secret, we push it in session
|
// to make sure the validator in the next step gets the secret, we push it in session
|
||||||
$secret = Preferences::get('twoFactorAuthSecret', '')->data;
|
$secret = Preferences::get('twoFactorAuthSecret', '')->data;
|
||||||
@@ -54,7 +53,7 @@ class TwoFactorController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function lostTwoFactor()
|
public function lostTwoFactor()
|
||||||
{
|
{
|
||||||
$user = Auth::user();
|
$user = auth()->user();
|
||||||
$siteOwner = env('SITE_OWNER', '');
|
$siteOwner = env('SITE_OWNER', '');
|
||||||
$title = strval(trans('firefly.two_factor_forgot_title'));
|
$title = strval(trans('firefly.two_factor_forgot_title'));
|
||||||
|
|
||||||
|
@@ -41,7 +41,7 @@ class BillController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return \Illuminate\View\View
|
* @return View
|
||||||
*/
|
*/
|
||||||
public function create()
|
public function create()
|
||||||
{
|
{
|
||||||
@@ -66,7 +66,7 @@ class BillController extends Controller
|
|||||||
/**
|
/**
|
||||||
* @param Bill $bill
|
* @param Bill $bill
|
||||||
*
|
*
|
||||||
* @return \Illuminate\View\View
|
* @return View
|
||||||
*/
|
*/
|
||||||
public function delete(Bill $bill)
|
public function delete(Bill $bill)
|
||||||
{
|
{
|
||||||
@@ -99,7 +99,7 @@ class BillController extends Controller
|
|||||||
/**
|
/**
|
||||||
* @param Bill $bill
|
* @param Bill $bill
|
||||||
*
|
*
|
||||||
* @return \Illuminate\View\View
|
* @return View
|
||||||
*/
|
*/
|
||||||
public function edit(Bill $bill)
|
public function edit(Bill $bill)
|
||||||
{
|
{
|
||||||
@@ -123,12 +123,14 @@ class BillController extends Controller
|
|||||||
/**
|
/**
|
||||||
* @param BillRepositoryInterface $repository
|
* @param BillRepositoryInterface $repository
|
||||||
*
|
*
|
||||||
* @return \Illuminate\View\View
|
* @return View
|
||||||
*/
|
*/
|
||||||
public function index(BillRepositoryInterface $repository)
|
public function index(BillRepositoryInterface $repository)
|
||||||
{
|
{
|
||||||
|
/** @var Carbon $start */
|
||||||
$start = session('start');
|
$start = session('start');
|
||||||
$end = session('end');
|
/** @var Carbon $end */
|
||||||
|
$end = session('end');
|
||||||
|
|
||||||
$bills = $repository->getBills();
|
$bills = $repository->getBills();
|
||||||
$bills->each(
|
$bills->each(
|
||||||
@@ -187,7 +189,7 @@ class BillController extends Controller
|
|||||||
* @param BillRepositoryInterface $repository
|
* @param BillRepositoryInterface $repository
|
||||||
* @param Bill $bill
|
* @param Bill $bill
|
||||||
*
|
*
|
||||||
* @return \Illuminate\View\View
|
* @return View
|
||||||
*/
|
*/
|
||||||
public function show(BillRepositoryInterface $repository, Bill $bill)
|
public function show(BillRepositoryInterface $repository, Bill $bill)
|
||||||
{
|
{
|
||||||
@@ -195,7 +197,7 @@ class BillController extends Controller
|
|||||||
$date = session('start');
|
$date = session('start');
|
||||||
$year = $date->year;
|
$year = $date->year;
|
||||||
$page = intval(Input::get('page')) == 0 ? 1 : intval(Input::get('page'));
|
$page = intval(Input::get('page')) == 0 ? 1 : intval(Input::get('page'));
|
||||||
$pageSize = Preferences::get('transactionPageSize', 50)->data;
|
$pageSize = intval(Preferences::get('transactionPageSize', 50)->data);
|
||||||
$journals = $repository->getJournals($bill, $page, $pageSize);
|
$journals = $repository->getJournals($bill, $page, $pageSize);
|
||||||
$yearAverage = $repository->getYearAverage($bill, $date);
|
$yearAverage = $repository->getYearAverage($bill, $date);
|
||||||
$overallAverage = $repository->getOverallAverage($bill);
|
$overallAverage = $repository->getOverallAverage($bill);
|
||||||
|
@@ -12,7 +12,6 @@ declare(strict_types = 1);
|
|||||||
namespace FireflyIII\Http\Controllers;
|
namespace FireflyIII\Http\Controllers;
|
||||||
|
|
||||||
use Amount;
|
use Amount;
|
||||||
use Auth;
|
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use Config;
|
use Config;
|
||||||
use FireflyIII\Crud\Account\AccountCrudInterface;
|
use FireflyIII\Crud\Account\AccountCrudInterface;
|
||||||
@@ -82,7 +81,7 @@ class BudgetController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return \Illuminate\View\View
|
* @return View
|
||||||
*/
|
*/
|
||||||
public function create()
|
public function create()
|
||||||
{
|
{
|
||||||
@@ -101,7 +100,7 @@ class BudgetController extends Controller
|
|||||||
/**
|
/**
|
||||||
* @param Budget $budget
|
* @param Budget $budget
|
||||||
*
|
*
|
||||||
* @return \Illuminate\View\View
|
* @return View
|
||||||
*/
|
*/
|
||||||
public function delete(Budget $budget)
|
public function delete(Budget $budget)
|
||||||
{
|
{
|
||||||
@@ -138,7 +137,7 @@ class BudgetController extends Controller
|
|||||||
/**
|
/**
|
||||||
* @param Budget $budget
|
* @param Budget $budget
|
||||||
*
|
*
|
||||||
* @return \Illuminate\View\View
|
* @return View
|
||||||
*/
|
*/
|
||||||
public function edit(Budget $budget)
|
public function edit(Budget $budget)
|
||||||
{
|
{
|
||||||
@@ -221,12 +220,11 @@ class BudgetController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$budgetMaximum = Preferences::get('budgetMaximum', 1000)->data;
|
|
||||||
$defaultCurrency = Amount::getDefaultCurrency();
|
$defaultCurrency = Amount::getDefaultCurrency();
|
||||||
|
|
||||||
return view(
|
return view(
|
||||||
'budgets.index', compact(
|
'budgets.index', compact(
|
||||||
'budgetMaximum', 'periodStart', 'periodEnd',
|
'periodStart', 'periodEnd',
|
||||||
'period', 'range', 'budgetIncomeTotal',
|
'period', 'range', 'budgetIncomeTotal',
|
||||||
'defaultCurrency', 'inactive', 'budgets',
|
'defaultCurrency', 'inactive', 'budgets',
|
||||||
'spent', 'budgeted'
|
'spent', 'budgeted'
|
||||||
@@ -237,7 +235,7 @@ class BudgetController extends Controller
|
|||||||
/**
|
/**
|
||||||
* @param BudgetRepositoryInterface $repository
|
* @param BudgetRepositoryInterface $repository
|
||||||
*
|
*
|
||||||
* @return \Illuminate\View\View
|
* @return View
|
||||||
*/
|
*/
|
||||||
public function noBudget(BudgetRepositoryInterface $repository)
|
public function noBudget(BudgetRepositoryInterface $repository)
|
||||||
{
|
{
|
||||||
@@ -360,7 +358,7 @@ class BudgetController extends Controller
|
|||||||
{
|
{
|
||||||
$budgetData = [
|
$budgetData = [
|
||||||
'name' => $request->input('name'),
|
'name' => $request->input('name'),
|
||||||
'user' => Auth::user()->id,
|
'user' => auth()->user()->id,
|
||||||
];
|
];
|
||||||
$budget = $repository->store($budgetData);
|
$budget = $repository->store($budgetData);
|
||||||
|
|
||||||
@@ -411,7 +409,7 @@ class BudgetController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return \Illuminate\View\View
|
* @return View
|
||||||
*/
|
*/
|
||||||
public function updateIncome()
|
public function updateIncome()
|
||||||
{
|
{
|
||||||
|
@@ -11,7 +11,6 @@ declare(strict_types = 1);
|
|||||||
|
|
||||||
namespace FireflyIII\Http\Controllers;
|
namespace FireflyIII\Http\Controllers;
|
||||||
|
|
||||||
use Auth;
|
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use FireflyIII\Crud\Account\AccountCrudInterface;
|
use FireflyIII\Crud\Account\AccountCrudInterface;
|
||||||
use FireflyIII\Http\Requests\CategoryFormRequest;
|
use FireflyIII\Http\Requests\CategoryFormRequest;
|
||||||
@@ -47,7 +46,7 @@ class CategoryController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return \Illuminate\View\View
|
* @return View
|
||||||
*/
|
*/
|
||||||
public function create()
|
public function create()
|
||||||
{
|
{
|
||||||
@@ -66,7 +65,7 @@ class CategoryController extends Controller
|
|||||||
/**
|
/**
|
||||||
* @param Category $category
|
* @param Category $category
|
||||||
*
|
*
|
||||||
* @return \Illuminate\View\View
|
* @return View
|
||||||
*/
|
*/
|
||||||
public function delete(Category $category)
|
public function delete(Category $category)
|
||||||
{
|
{
|
||||||
@@ -101,7 +100,7 @@ class CategoryController extends Controller
|
|||||||
/**
|
/**
|
||||||
* @param Category $category
|
* @param Category $category
|
||||||
*
|
*
|
||||||
* @return \Illuminate\View\View
|
* @return View
|
||||||
*/
|
*/
|
||||||
public function edit(Category $category)
|
public function edit(Category $category)
|
||||||
{
|
{
|
||||||
@@ -122,7 +121,7 @@ class CategoryController extends Controller
|
|||||||
/**
|
/**
|
||||||
* @param CRI $repository
|
* @param CRI $repository
|
||||||
*
|
*
|
||||||
* @return \Illuminate\View\View
|
* @return View
|
||||||
*/
|
*/
|
||||||
public function index(CRI $repository)
|
public function index(CRI $repository)
|
||||||
{
|
{
|
||||||
@@ -140,7 +139,7 @@ class CategoryController extends Controller
|
|||||||
/**
|
/**
|
||||||
* @param CRI $repository
|
* @param CRI $repository
|
||||||
*
|
*
|
||||||
* @return \Illuminate\View\View
|
* @return View
|
||||||
*/
|
*/
|
||||||
public function noCategory(CRI $repository)
|
public function noCategory(CRI $repository)
|
||||||
{
|
{
|
||||||
@@ -166,9 +165,10 @@ class CategoryController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function show(CRI $repository, AccountCrudInterface $crud, Category $category)
|
public function show(CRI $repository, AccountCrudInterface $crud, Category $category)
|
||||||
{
|
{
|
||||||
/** @var Carbon $carbon */
|
$range = Preferences::get('viewRange', '1M')->data;
|
||||||
$range = Preferences::get('viewRange', '1M')->data;
|
/** @var Carbon $start */
|
||||||
$start = session('start', Navigation::startOfPeriod(new Carbon, $range));
|
$start = session('start', Navigation::startOfPeriod(new Carbon, $range));
|
||||||
|
/** @var Carbon $end */
|
||||||
$end = session('end', Navigation::endOfPeriod(new Carbon, $range));
|
$end = session('end', Navigation::endOfPeriod(new Carbon, $range));
|
||||||
$hideCategory = true; // used in list.
|
$hideCategory = true; // used in list.
|
||||||
$page = intval(Input::get('page'));
|
$page = intval(Input::get('page'));
|
||||||
@@ -183,7 +183,7 @@ class CategoryController extends Controller
|
|||||||
$journals->setPath('categories/show/' . $category->id);
|
$journals->setPath('categories/show/' . $category->id);
|
||||||
|
|
||||||
// oldest transaction in category:
|
// oldest transaction in category:
|
||||||
$start = $repository->firstUseDate($category, new Collection);
|
$start = $repository->firstUseDate($category);
|
||||||
if ($start->year == 1900) {
|
if ($start->year == 1900) {
|
||||||
$start = new Carbon;
|
$start = new Carbon;
|
||||||
}
|
}
|
||||||
@@ -232,7 +232,7 @@ class CategoryController extends Controller
|
|||||||
*
|
*
|
||||||
* @param $date
|
* @param $date
|
||||||
*
|
*
|
||||||
* @return \Illuminate\View\View
|
* @return View
|
||||||
*/
|
*/
|
||||||
public function showWithDate(CRI $repository, Category $category, string $date)
|
public function showWithDate(CRI $repository, Category $category, string $date)
|
||||||
{
|
{
|
||||||
@@ -264,7 +264,7 @@ class CategoryController extends Controller
|
|||||||
{
|
{
|
||||||
$categoryData = [
|
$categoryData = [
|
||||||
'name' => $request->input('name'),
|
'name' => $request->input('name'),
|
||||||
'user' => Auth::user()->id,
|
'user' => auth()->user()->id,
|
||||||
];
|
];
|
||||||
$category = $repository->store($categoryData);
|
$category = $repository->store($categoryData);
|
||||||
|
|
||||||
|
@@ -20,6 +20,7 @@ use FireflyIII\Models\TransactionJournal;
|
|||||||
use FireflyIII\Repositories\Budget\BudgetRepositoryInterface;
|
use FireflyIII\Repositories\Budget\BudgetRepositoryInterface;
|
||||||
use FireflyIII\Support\CacheProperties;
|
use FireflyIII\Support\CacheProperties;
|
||||||
use Illuminate\Support\Collection;
|
use Illuminate\Support\Collection;
|
||||||
|
use Log;
|
||||||
use Navigation;
|
use Navigation;
|
||||||
use Preferences;
|
use Preferences;
|
||||||
use Response;
|
use Response;
|
||||||
@@ -35,19 +36,14 @@ class BudgetController extends Controller
|
|||||||
/** @var BudgetChartGeneratorInterface */
|
/** @var BudgetChartGeneratorInterface */
|
||||||
protected $generator;
|
protected $generator;
|
||||||
|
|
||||||
/** @var BudgetRepositoryInterface */
|
|
||||||
protected $repository;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* BudgetController constructor.
|
||||||
*/
|
*/
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
// create chart generator:
|
// create chart generator:
|
||||||
$this->generator = app(BudgetChartGeneratorInterface::class);
|
$this->generator = app(BudgetChartGeneratorInterface::class);
|
||||||
|
|
||||||
$this->repository = app(BudgetRepositoryInterface::class);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -143,8 +139,9 @@ class BudgetController extends Controller
|
|||||||
*
|
*
|
||||||
* @return \Symfony\Component\HttpFoundation\Response
|
* @return \Symfony\Component\HttpFoundation\Response
|
||||||
*/
|
*/
|
||||||
public function frontpage()
|
public function frontpage(BudgetRepositoryInterface $repository)
|
||||||
{
|
{
|
||||||
|
Log::debug('Hello');
|
||||||
$start = session('start', Carbon::now()->startOfMonth());
|
$start = session('start', Carbon::now()->startOfMonth());
|
||||||
$end = session('end', Carbon::now()->endOfMonth());
|
$end = session('end', Carbon::now()->endOfMonth());
|
||||||
// chart properties for cache:
|
// chart properties for cache:
|
||||||
@@ -156,8 +153,8 @@ class BudgetController extends Controller
|
|||||||
if ($cache->has()) {
|
if ($cache->has()) {
|
||||||
return Response::json($cache->get());
|
return Response::json($cache->get());
|
||||||
}
|
}
|
||||||
$budgets = $this->repository->getActiveBudgets();
|
$budgets = $repository->getActiveBudgets();
|
||||||
$repetitions = $this->repository->getAllBudgetLimitRepetitions($start, $end);
|
$repetitions = $repository->getAllBudgetLimitRepetitions($start, $end);
|
||||||
$allEntries = new Collection;
|
$allEntries = new Collection;
|
||||||
|
|
||||||
/** @var Budget $budget */
|
/** @var Budget $budget */
|
||||||
@@ -166,15 +163,15 @@ class BudgetController extends Controller
|
|||||||
$reps = $this->filterRepetitions($repetitions, $budget, $start, $end);
|
$reps = $this->filterRepetitions($repetitions, $budget, $start, $end);
|
||||||
|
|
||||||
if ($reps->count() === 0) {
|
if ($reps->count() === 0) {
|
||||||
$collection = $this->spentInPeriodSingle($budget, $start, $end);
|
$collection = $this->spentInPeriodSingle($repository, $budget, $start, $end);
|
||||||
$allEntries = $allEntries->merge($collection);
|
$allEntries = $allEntries->merge($collection);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
$collection = $this->spentInPeriodMulti($budget, $reps);
|
$collection = $this->spentInPeriodMulti($repository, $budget, $reps);
|
||||||
$allEntries = $allEntries->merge($collection);
|
$allEntries = $allEntries->merge($collection);
|
||||||
|
|
||||||
}
|
}
|
||||||
$entry = $this->spentInPeriodWithout($start, $end);
|
$entry = $this->spentInPeriodWithout($repository, $start, $end);
|
||||||
$allEntries->push($entry);
|
$allEntries->push($entry);
|
||||||
$data = $this->generator->frontpage($allEntries);
|
$data = $this->generator->frontpage($allEntries);
|
||||||
$cache->store($data);
|
$cache->store($data);
|
||||||
@@ -214,8 +211,10 @@ class BudgetController extends Controller
|
|||||||
$repetitions = $repetitions->filter(
|
$repetitions = $repetitions->filter(
|
||||||
function (LimitRepetition $repetition) use ($budgetIds) {
|
function (LimitRepetition $repetition) use ($budgetIds) {
|
||||||
if (in_array(strval($repetition->budget_id), $budgetIds)) {
|
if (in_array(strval($repetition->budget_id), $budgetIds)) {
|
||||||
return $repetition;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
/** @var LimitRepetition $repetition */
|
/** @var LimitRepetition $repetition */
|
||||||
@@ -289,8 +288,10 @@ class BudgetController extends Controller
|
|||||||
$reps = $repetitions->filter(
|
$reps = $repetitions->filter(
|
||||||
function (LimitRepetition $repetition) use ($budget, $currentStart) {
|
function (LimitRepetition $repetition) use ($budget, $currentStart) {
|
||||||
if ($repetition->budget_id === $budget->id && $repetition->startdate == $currentStart) {
|
if ($repetition->budget_id === $budget->id && $repetition->startdate == $currentStart) {
|
||||||
return $repetition;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
$budgeted = $reps->sum('amount');
|
$budgeted = $reps->sum('amount');
|
||||||
@@ -325,26 +326,29 @@ class BudgetController extends Controller
|
|||||||
return $repetitions->filter(
|
return $repetitions->filter(
|
||||||
function (LimitRepetition $repetition) use ($budget, $start, $end) {
|
function (LimitRepetition $repetition) use ($budget, $start, $end) {
|
||||||
if ($repetition->startdate < $end && $repetition->enddate > $start && $repetition->budget_id === $budget->id) {
|
if ($repetition->startdate < $end && $repetition->enddate > $start && $repetition->budget_id === $budget->id) {
|
||||||
return $repetition;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Budget $budget
|
* @param BudgetRepositoryInterface $repository
|
||||||
* @param Collection $repetitions
|
* @param Budget $budget
|
||||||
|
* @param Collection $repetitions
|
||||||
*
|
*
|
||||||
* @return Collection
|
* @return Collection
|
||||||
*/
|
*/
|
||||||
private function spentInPeriodMulti(Budget $budget, Collection $repetitions): Collection
|
private function spentInPeriodMulti(BudgetRepositoryInterface $repository, Budget $budget, Collection $repetitions): Collection
|
||||||
{
|
{
|
||||||
$format = strval(trans('config.month_and_day'));
|
$format = strval(trans('config.month_and_day'));
|
||||||
$collection = new Collection;
|
$collection = new Collection;
|
||||||
$name = $budget->name;
|
$name = $budget->name;
|
||||||
/** @var LimitRepetition $repetition */
|
/** @var LimitRepetition $repetition */
|
||||||
foreach ($repetitions as $repetition) {
|
foreach ($repetitions as $repetition) {
|
||||||
$expenses = $this->repository->spentInPeriod(new Collection([$budget]), new Collection, $repetition->startdate, $repetition->enddate);
|
$expenses = $repository->spentInPeriod(new Collection([$budget]), new Collection, $repetition->startdate, $repetition->enddate);
|
||||||
|
|
||||||
if ($repetitions->count() > 1) {
|
if ($repetitions->count() > 1) {
|
||||||
$name = $budget->name . ' ' . trans(
|
$name = $budget->name . ' ' . trans(
|
||||||
@@ -364,18 +368,19 @@ class BudgetController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Budget $budget
|
* @param BudgetRepositoryInterface $repository
|
||||||
* @param Carbon $start
|
* @param Budget $budget
|
||||||
* @param Carbon $end
|
* @param Carbon $start
|
||||||
|
* @param Carbon $end
|
||||||
*
|
*
|
||||||
* @return Collection
|
* @return Collection
|
||||||
*/
|
*/
|
||||||
private function spentInPeriodSingle(Budget $budget, Carbon $start, Carbon $end): Collection
|
private function spentInPeriodSingle(BudgetRepositoryInterface $repository, Budget $budget, Carbon $start, Carbon $end): Collection
|
||||||
{
|
{
|
||||||
$collection = new Collection;
|
$collection = new Collection;
|
||||||
$amount = '0';
|
$amount = '0';
|
||||||
$left = '0';
|
$left = '0';
|
||||||
$spent = $this->repository->spentInPeriod(new Collection([$budget]), new Collection, $start, $end);
|
$spent = $repository->spentInPeriod(new Collection([$budget]), new Collection, $start, $end);
|
||||||
$overspent = '0';
|
$overspent = '0';
|
||||||
$array = [$budget->name, $left, $spent, $overspent, $amount, $spent];
|
$array = [$budget->name, $left, $spent, $overspent, $amount, $spent];
|
||||||
$collection->push($array);
|
$collection->push($array);
|
||||||
@@ -384,14 +389,15 @@ class BudgetController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Carbon $start
|
* @param BudgetRepositoryInterface $repository
|
||||||
* @param Carbon $end
|
* @param Carbon $start
|
||||||
|
* @param Carbon $end
|
||||||
*
|
*
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
private function spentInPeriodWithout(Carbon $start, Carbon $end):array
|
private function spentInPeriodWithout(BudgetRepositoryInterface $repository, Carbon $start, Carbon $end):array
|
||||||
{
|
{
|
||||||
$list = $this->repository->journalsInPeriodWithoutBudget(new Collection, $start, $end);
|
$list = $repository->journalsInPeriodWithoutBudget(new Collection, $start, $end);
|
||||||
$sum = '0';
|
$sum = '0';
|
||||||
/** @var TransactionJournal $entry */
|
/** @var TransactionJournal $entry */
|
||||||
foreach ($list as $entry) {
|
foreach ($list as $entry) {
|
||||||
|
@@ -58,7 +58,7 @@ class CategoryController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function all(CRI $repository, AccountCrudInterface $crud, Category $category)
|
public function all(CRI $repository, AccountCrudInterface $crud, Category $category)
|
||||||
{
|
{
|
||||||
$start = $repository->firstUseDate($category, new Collection);
|
$start = $repository->firstUseDate($category);
|
||||||
$range = Preferences::get('viewRange', '1M')->data;
|
$range = Preferences::get('viewRange', '1M')->data;
|
||||||
$start = Navigation::startOfPeriod($start, $range);
|
$start = Navigation::startOfPeriod($start, $range);
|
||||||
$categoryCollection = new Collection([$category]);
|
$categoryCollection = new Collection([$category]);
|
||||||
@@ -108,13 +108,12 @@ class CategoryController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Show this month's category overview.
|
* @param CRI $repository
|
||||||
|
* @param AccountCrudInterface $crud
|
||||||
*
|
*
|
||||||
* @param CRI $repository
|
* @return \Illuminate\Http\JsonResponse
|
||||||
*
|
|
||||||
* @return \Symfony\Component\HttpFoundation\Response
|
|
||||||
*/
|
*/
|
||||||
public function frontpage(CRI $repository)
|
public function frontpage(CRI $repository, AccountCrudInterface $crud)
|
||||||
{
|
{
|
||||||
$start = session('start', Carbon::now()->startOfMonth());
|
$start = session('start', Carbon::now()->startOfMonth());
|
||||||
$end = session('end', Carbon::now()->endOfMonth());
|
$end = session('end', Carbon::now()->endOfMonth());
|
||||||
@@ -128,10 +127,11 @@ class CategoryController extends Controller
|
|||||||
return Response::json($cache->get());
|
return Response::json($cache->get());
|
||||||
}
|
}
|
||||||
$categories = $repository->getCategories();
|
$categories = $repository->getCategories();
|
||||||
|
$accounts = $crud->getAccountsByType([AccountType::ASSET, AccountType::DEFAULT]);
|
||||||
$set = new Collection;
|
$set = new Collection;
|
||||||
/** @var Category $category */
|
/** @var Category $category */
|
||||||
foreach ($categories as $category) {
|
foreach ($categories as $category) {
|
||||||
$spent = $repository->spentInPeriod(new Collection([$category]), new Collection, $start, $end);
|
$spent = $repository->spentInPeriod(new Collection([$category]), $accounts, $start, $end);
|
||||||
if (bccomp($spent, '0') === -1) {
|
if (bccomp($spent, '0') === -1) {
|
||||||
$category->spent = $spent;
|
$category->spent = $spent;
|
||||||
$set->push($category);
|
$set->push($category);
|
||||||
|
38
app/Http/Controllers/Controller.php
Normal file → Executable file
38
app/Http/Controllers/Controller.php
Normal file → Executable file
@@ -11,15 +11,11 @@ declare(strict_types = 1);
|
|||||||
|
|
||||||
namespace FireflyIII\Http\Controllers;
|
namespace FireflyIII\Http\Controllers;
|
||||||
|
|
||||||
use App;
|
|
||||||
use Auth;
|
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
|
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
|
||||||
use Illuminate\Foundation\Bus\DispatchesJobs;
|
use Illuminate\Foundation\Bus\DispatchesJobs;
|
||||||
use Illuminate\Foundation\Validation\ValidatesRequests;
|
use Illuminate\Foundation\Validation\ValidatesRequests;
|
||||||
use Illuminate\Routing\Controller as BaseController;
|
use Illuminate\Routing\Controller as BaseController;
|
||||||
use NumberFormatter;
|
|
||||||
use Preferences;
|
|
||||||
use View;
|
use View;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -48,36 +44,11 @@ class Controller extends BaseController
|
|||||||
View::share('hideBills', false);
|
View::share('hideBills', false);
|
||||||
View::share('hideTags', false);
|
View::share('hideTags', false);
|
||||||
|
|
||||||
if (Auth::check()) {
|
// save some formats:
|
||||||
$pref = Preferences::get('language', env('DEFAULT_LANGUAGE', 'en_US'));
|
$this->monthFormat = (string)trans('config.month');
|
||||||
$lang = $pref->data;
|
$this->monthAndDayFormat = (string)trans('config.month_and_day');
|
||||||
|
$this->dateTimeFormat = (string)trans('config.date_time');
|
||||||
|
|
||||||
App::setLocale($lang);
|
|
||||||
Carbon::setLocale(substr($lang, 0, 2));
|
|
||||||
$locale = explode(',', trans('config.locale'));
|
|
||||||
$locale = array_map('trim', $locale);
|
|
||||||
|
|
||||||
setlocale(LC_TIME, $locale);
|
|
||||||
setlocale(LC_MONETARY, $locale);
|
|
||||||
|
|
||||||
// save some formats:
|
|
||||||
$this->monthFormat = (string)trans('config.month');
|
|
||||||
$this->monthAndDayFormat = (string)trans('config.month_and_day');
|
|
||||||
$this->dateTimeFormat = (string)trans('config.date_time');
|
|
||||||
|
|
||||||
// change localeconv to a new array:
|
|
||||||
$numberFormatter = numfmt_create($lang, NumberFormatter::CURRENCY);
|
|
||||||
$localeconv = [
|
|
||||||
'mon_decimal_point' => $numberFormatter->getSymbol($numberFormatter->getAttribute(NumberFormatter::DECIMAL_SEPARATOR_SYMBOL)),
|
|
||||||
'mon_thousands_sep' => $numberFormatter->getSymbol($numberFormatter->getAttribute(NumberFormatter::MONETARY_GROUPING_SEPARATOR_SYMBOL)),
|
|
||||||
'frac_digits' => $numberFormatter->getAttribute(NumberFormatter::MAX_FRACTION_DIGITS),
|
|
||||||
];
|
|
||||||
View::share('monthFormat', $this->monthFormat);
|
|
||||||
View::share('monthAndDayFormat', $this->monthAndDayFormat);
|
|
||||||
View::share('dateTimeFormat', $this->dateTimeFormat);
|
|
||||||
View::share('language', $lang);
|
|
||||||
View::share('localeconv', $localeconv);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -107,5 +78,4 @@ class Controller extends BaseController
|
|||||||
return $sum;
|
return $sum;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -11,7 +11,6 @@ declare(strict_types = 1);
|
|||||||
|
|
||||||
namespace FireflyIII\Http\Controllers;
|
namespace FireflyIII\Http\Controllers;
|
||||||
|
|
||||||
use Auth;
|
|
||||||
use Cache;
|
use Cache;
|
||||||
use FireflyIII\Http\Requests\CurrencyFormRequest;
|
use FireflyIII\Http\Requests\CurrencyFormRequest;
|
||||||
use FireflyIII\Models\TransactionCurrency;
|
use FireflyIII\Models\TransactionCurrency;
|
||||||
@@ -43,7 +42,7 @@ class CurrencyController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return \Illuminate\View\View
|
* @return View
|
||||||
*/
|
*/
|
||||||
public function create()
|
public function create()
|
||||||
{
|
{
|
||||||
@@ -81,20 +80,19 @@ class CurrencyController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param CurrencyRepositoryInterface $repository
|
* @param TransactionCurrency $currency
|
||||||
* @param TransactionCurrency $currency
|
|
||||||
*
|
*
|
||||||
* @return \Illuminate\Http\RedirectResponse|View
|
* @return \Illuminate\Http\RedirectResponse|View
|
||||||
*/
|
*/
|
||||||
public function delete(CurrencyRepositoryInterface $repository, TransactionCurrency $currency)
|
public function delete(TransactionCurrency $currency)
|
||||||
{
|
{
|
||||||
|
if (!$this->canDeleteCurrency($currency)) {
|
||||||
if ($repository->countJournals($currency) > 0) {
|
|
||||||
Session::flash('error', trans('firefly.cannot_delete_currency', ['name' => $currency->name]));
|
Session::flash('error', trans('firefly.cannot_delete_currency', ['name' => $currency->name]));
|
||||||
|
|
||||||
return redirect(route('currency.index'));
|
return redirect(route('currency.index'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// put previous url in session
|
// put previous url in session
|
||||||
Session::put('currency.delete.url', URL::previous());
|
Session::put('currency.delete.url', URL::previous());
|
||||||
Session::flash('gaEventCategory', 'currency');
|
Session::flash('gaEventCategory', 'currency');
|
||||||
@@ -106,22 +104,21 @@ class CurrencyController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param CurrencyRepositoryInterface $repository
|
* @param TransactionCurrency $currency
|
||||||
* @param TransactionCurrency $currency
|
|
||||||
*
|
*
|
||||||
* @return \Illuminate\Http\RedirectResponse
|
* @return \Illuminate\Http\RedirectResponse
|
||||||
* @throws \Exception
|
* @throws \Exception
|
||||||
*/
|
*/
|
||||||
public function destroy(CurrencyRepositoryInterface $repository, TransactionCurrency $currency)
|
public function destroy(TransactionCurrency $currency)
|
||||||
{
|
{
|
||||||
if ($repository->countJournals($currency) > 0) {
|
if (!$this->canDeleteCurrency($currency)) {
|
||||||
Session::flash('error', trans('firefly.cannot_delete_currency', ['name' => $currency->name]));
|
Session::flash('error', trans('firefly.cannot_delete_currency', ['name' => $currency->name]));
|
||||||
|
|
||||||
return redirect(route('currency.index'));
|
return redirect(route('currency.index'));
|
||||||
}
|
}
|
||||||
|
|
||||||
Session::flash('success', trans('firefly.deleted_currency', ['name' => $currency->name]));
|
Session::flash('success', trans('firefly.deleted_currency', ['name' => $currency->name]));
|
||||||
if (Auth::user()->hasRole('owner')) {
|
if (auth()->user()->hasRole('owner')) {
|
||||||
$currency->delete();
|
$currency->delete();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -131,12 +128,12 @@ class CurrencyController extends Controller
|
|||||||
/**
|
/**
|
||||||
* @param TransactionCurrency $currency
|
* @param TransactionCurrency $currency
|
||||||
*
|
*
|
||||||
* @return \Illuminate\View\View
|
* @return View
|
||||||
*/
|
*/
|
||||||
public function edit(TransactionCurrency $currency)
|
public function edit(TransactionCurrency $currency)
|
||||||
{
|
{
|
||||||
$subTitleIcon = 'fa-pencil';
|
$subTitleIcon = 'fa-pencil';
|
||||||
$subTitle = trans('firefly.edit_currency', ['name' => $currency->name]);
|
$subTitle = trans('breadcrumbs.edit_currency', ['name' => $currency->name]);
|
||||||
$currency->symbol = htmlentities($currency->symbol);
|
$currency->symbol = htmlentities($currency->symbol);
|
||||||
|
|
||||||
// put previous url in session if not redirect from store (not "return_to_edit").
|
// put previous url in session if not redirect from store (not "return_to_edit").
|
||||||
@@ -154,15 +151,15 @@ class CurrencyController extends Controller
|
|||||||
/**
|
/**
|
||||||
* @param CurrencyRepositoryInterface $repository
|
* @param CurrencyRepositoryInterface $repository
|
||||||
*
|
*
|
||||||
* @return \Illuminate\View\View
|
* @return View
|
||||||
*/
|
*/
|
||||||
public function index(CurrencyRepositoryInterface $repository)
|
public function index(CurrencyRepositoryInterface $repository)
|
||||||
{
|
{
|
||||||
$currencies = $repository->get();
|
$currencies = $repository->get();
|
||||||
$defaultCurrency = $repository->getCurrencyByPreference(Preferences::get('currencyPreference', env('DEFAULT_CURRENCY', 'EUR')));
|
$defaultCurrency = $repository->getCurrencyByPreference(Preferences::get('currencyPreference', config('firefly.default_currency', 'EUR')));
|
||||||
|
|
||||||
|
|
||||||
if (!Auth::user()->hasRole('owner')) {
|
if (!auth()->user()->hasRole('owner')) {
|
||||||
Session::flash('warning', trans('firefly.ask_site_owner', ['owner' => env('SITE_OWNER')]));
|
Session::flash('warning', trans('firefly.ask_site_owner', ['owner' => env('SITE_OWNER')]));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -175,12 +172,12 @@ class CurrencyController extends Controller
|
|||||||
* @param CurrencyFormRequest $request
|
* @param CurrencyFormRequest $request
|
||||||
* @param CurrencyRepositoryInterface $repository
|
* @param CurrencyRepositoryInterface $repository
|
||||||
*
|
*
|
||||||
* @return $this|\Illuminate\Http\RedirectResponse
|
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
|
||||||
*/
|
*/
|
||||||
public function store(CurrencyFormRequest $request, CurrencyRepositoryInterface $repository)
|
public function store(CurrencyFormRequest $request, CurrencyRepositoryInterface $repository)
|
||||||
{
|
{
|
||||||
if (!Auth::user()->hasRole('owner')) {
|
if (!auth()->user()->hasRole('owner')) {
|
||||||
Log::error('User ' . Auth::user()->id . ' is not admin, but tried to store a currency.');
|
Log::error('User ' . auth()->user()->id . ' is not admin, but tried to store a currency.');
|
||||||
|
|
||||||
return redirect(session('currency.create.url'));
|
return redirect(session('currency.create.url'));
|
||||||
}
|
}
|
||||||
@@ -211,7 +208,7 @@ class CurrencyController extends Controller
|
|||||||
public function update(CurrencyFormRequest $request, CurrencyRepositoryInterface $repository, TransactionCurrency $currency)
|
public function update(CurrencyFormRequest $request, CurrencyRepositoryInterface $repository, TransactionCurrency $currency)
|
||||||
{
|
{
|
||||||
$data = $request->getCurrencyData();
|
$data = $request->getCurrencyData();
|
||||||
if (Auth::user()->hasRole('owner')) {
|
if (auth()->user()->hasRole('owner')) {
|
||||||
$currency = $repository->update($currency, $data);
|
$currency = $repository->update($currency, $data);
|
||||||
}
|
}
|
||||||
Session::flash('success', trans('firefly.updated_currency', ['name' => $currency->name]));
|
Session::flash('success', trans('firefly.updated_currency', ['name' => $currency->name]));
|
||||||
@@ -229,4 +226,39 @@ class CurrencyController extends Controller
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param TransactionCurrency $currency
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
private function canDeleteCurrency(TransactionCurrency $currency): bool
|
||||||
|
{
|
||||||
|
$repository = app(CurrencyRepositoryInterface::class);
|
||||||
|
|
||||||
|
// has transactions still
|
||||||
|
if ($repository->countJournals($currency) > 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// is the only currency left
|
||||||
|
if ($repository->get()->count() === 1) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// is the default currency for the user or the system
|
||||||
|
$defaultCode = Preferences::get('currencyPreference', config('firefly.default_currency', 'EUR'))->data;
|
||||||
|
if ($currency->code === $defaultCode) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// is the default currency for the system
|
||||||
|
$defaultSystemCode = config('firefly.default_currency', 'EUR');
|
||||||
|
if ($currency->code === $defaultSystemCode) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// can be deleted
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -10,7 +10,6 @@
|
|||||||
declare(strict_types = 1);
|
declare(strict_types = 1);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
namespace FireflyIII\Http\Controllers;
|
namespace FireflyIII\Http\Controllers;
|
||||||
|
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
@@ -18,7 +17,6 @@ use ExpandedForm;
|
|||||||
use FireflyIII\Crud\Account\AccountCrudInterface;
|
use FireflyIII\Crud\Account\AccountCrudInterface;
|
||||||
use FireflyIII\Exceptions\FireflyException;
|
use FireflyIII\Exceptions\FireflyException;
|
||||||
use FireflyIII\Export\Processor;
|
use FireflyIII\Export\Processor;
|
||||||
use FireflyIII\Http\Requests;
|
|
||||||
use FireflyIII\Http\Requests\ExportFormRequest;
|
use FireflyIII\Http\Requests\ExportFormRequest;
|
||||||
use FireflyIII\Models\AccountType;
|
use FireflyIII\Models\AccountType;
|
||||||
use FireflyIII\Models\ExportJob;
|
use FireflyIII\Models\ExportJob;
|
||||||
@@ -94,7 +92,7 @@ class ExportController extends Controller
|
|||||||
* @param AccountCrudInterface $crud
|
* @param AccountCrudInterface $crud
|
||||||
* @param EJRI $jobs
|
* @param EJRI $jobs
|
||||||
*
|
*
|
||||||
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
* @return View
|
||||||
*/
|
*/
|
||||||
public function index(AccountCrudInterface $crud, EJRI $jobs)
|
public function index(AccountCrudInterface $crud, EJRI $jobs)
|
||||||
{
|
{
|
||||||
|
@@ -39,7 +39,7 @@ class HelpController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function show(HelpInterface $help, string $route)
|
public function show(HelpInterface $help, string $route)
|
||||||
{
|
{
|
||||||
$language = Preferences::get('language', env('DEFAULT_LANGUAGE', 'en_US'))->data;
|
$language = Preferences::get('language', config('firefly.default_language', 'en_US'))->data;
|
||||||
$content = [
|
$content = [
|
||||||
'text' => '<p>' . strval(trans('firefly.route_has_no_help')) . '</p>',
|
'text' => '<p>' . strval(trans('firefly.route_has_no_help')) . '</p>',
|
||||||
'title' => 'Help',
|
'title' => 'Help',
|
||||||
|
@@ -97,7 +97,7 @@ class HomeController extends Controller
|
|||||||
|
|
||||||
/** @var Tag $tag */
|
/** @var Tag $tag */
|
||||||
foreach ($tags as $tag) {
|
foreach ($tags as $tag) {
|
||||||
foreach ($tag->transactionjournals()->get() as $journal) {
|
foreach ($tag->transactionJournals()->get() as $journal) {
|
||||||
$count = $journal->tags()->count();
|
$count = $journal->tags()->count();
|
||||||
$journal->tag_count = $count;
|
$journal->tag_count = $count;
|
||||||
$journal->save();
|
$journal->save();
|
||||||
@@ -222,4 +222,5 @@ class HomeController extends Controller
|
|||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -6,18 +6,21 @@
|
|||||||
* This software may be modified and distributed under the terms
|
* This software may be modified and distributed under the terms
|
||||||
* of the MIT license. See the LICENSE file for details.
|
* of the MIT license. See the LICENSE file for details.
|
||||||
*/
|
*/
|
||||||
|
declare(strict_types = 1);
|
||||||
|
|
||||||
namespace FireflyIII\Http\Controllers;
|
namespace FireflyIII\Http\Controllers;
|
||||||
|
|
||||||
use Crypt;
|
use Crypt;
|
||||||
use FireflyIII\Exceptions\FireflyException;
|
use FireflyIII\Exceptions\FireflyException;
|
||||||
use FireflyIII\Http\Requests;
|
|
||||||
use FireflyIII\Http\Requests\ImportUploadRequest;
|
use FireflyIII\Http\Requests\ImportUploadRequest;
|
||||||
|
use FireflyIII\Import\ImportProcedure;
|
||||||
use FireflyIII\Import\Setup\SetupInterface;
|
use FireflyIII\Import\Setup\SetupInterface;
|
||||||
use FireflyIII\Models\ImportJob;
|
use FireflyIII\Models\ImportJob;
|
||||||
use FireflyIII\Repositories\ImportJob\ImportJobRepositoryInterface;
|
use FireflyIII\Repositories\ImportJob\ImportJobRepositoryInterface;
|
||||||
|
use FireflyIII\Repositories\Tag\TagRepositoryInterface;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Log;
|
use Log;
|
||||||
|
use Response;
|
||||||
use SplFileObject;
|
use SplFileObject;
|
||||||
use Storage;
|
use Storage;
|
||||||
use Symfony\Component\HttpFoundation\File\UploadedFile;
|
use Symfony\Component\HttpFoundation\File\UploadedFile;
|
||||||
@@ -53,7 +56,7 @@ class ImportController extends Controller
|
|||||||
if (!$this->jobInCorrectStep($job, 'complete')) {
|
if (!$this->jobInCorrectStep($job, 'complete')) {
|
||||||
return $this->redirectToCorrectStep($job);
|
return $this->redirectToCorrectStep($job);
|
||||||
}
|
}
|
||||||
$subTitle = trans('firefy.import_complete');
|
$subTitle = trans('firefly.import_complete');
|
||||||
$subTitleIcon = 'fa-star';
|
$subTitleIcon = 'fa-star';
|
||||||
|
|
||||||
return view('import.complete', compact('job', 'subTitle', 'subTitleIcon'));
|
return view('import.complete', compact('job', 'subTitle', 'subTitleIcon'));
|
||||||
@@ -119,6 +122,25 @@ class ImportController extends Controller
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param ImportJob $job
|
||||||
|
*
|
||||||
|
* @return View
|
||||||
|
*/
|
||||||
|
public function finished(ImportJob $job)
|
||||||
|
{
|
||||||
|
if (!$this->jobInCorrectStep($job, 'finished')) {
|
||||||
|
Log::debug('Job is not in correct state for finished()', ['status' => $job->status]);
|
||||||
|
|
||||||
|
return $this->redirectToCorrectStep($job);
|
||||||
|
}
|
||||||
|
|
||||||
|
$subTitle = trans('firefly.import_finished');
|
||||||
|
$subTitleIcon = 'fa-star';
|
||||||
|
|
||||||
|
return view('import.finished', compact('job', 'subTitle', 'subTitleIcon'));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is step 1. Upload a file.
|
* This is step 1. Upload a file.
|
||||||
*
|
*
|
||||||
@@ -139,6 +161,48 @@ class ImportController extends Controller
|
|||||||
return view('import.index', compact('subTitle', 'subTitleIcon', 'importFileTypes', 'defaultImportType'));
|
return view('import.index', compact('subTitle', 'subTitleIcon', 'importFileTypes', 'defaultImportType'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param ImportJob $job
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Http\JsonResponse
|
||||||
|
*/
|
||||||
|
public function json(ImportJob $job)
|
||||||
|
{
|
||||||
|
$result = [
|
||||||
|
'showPercentage' => false,
|
||||||
|
'started' => false,
|
||||||
|
'finished' => false,
|
||||||
|
'running' => false,
|
||||||
|
'errors' => $job->extended_status['errors'],
|
||||||
|
'percentage' => 0,
|
||||||
|
'steps' => $job->extended_status['total_steps'],
|
||||||
|
'stepsDone' => $job->extended_status['steps_done'],
|
||||||
|
'statusText' => trans('firefly.import_status_' . $job->status),
|
||||||
|
'finishedText' => '',
|
||||||
|
];
|
||||||
|
$percentage = 0;
|
||||||
|
if ($job->extended_status['total_steps'] !== 0) {
|
||||||
|
$percentage = round(($job->extended_status['steps_done'] / $job->extended_status['total_steps']) * 100, 0);
|
||||||
|
}
|
||||||
|
if ($job->status === 'import_complete') {
|
||||||
|
$tagId = $job->extended_status['importTag'];
|
||||||
|
/** @var TagRepositoryInterface $repository */
|
||||||
|
$repository = app(TagRepositoryInterface::class);
|
||||||
|
$tag = $repository->find($tagId);
|
||||||
|
$result['finished'] = true;
|
||||||
|
$result['finishedText'] = trans('firefly.import_finished_link', ['link' => route('tags.show', [$tag->id]), 'tag' => $tag->tag]);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($job->status === 'import_running') {
|
||||||
|
$result['started'] = true;
|
||||||
|
$result['running'] = true;
|
||||||
|
$result['showPercentage'] = true;
|
||||||
|
$result['percentage'] = $percentage;
|
||||||
|
}
|
||||||
|
|
||||||
|
return Response::json($result);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Step 4. Save the configuration.
|
* Step 4. Save the configuration.
|
||||||
*
|
*
|
||||||
@@ -200,7 +264,7 @@ class ImportController extends Controller
|
|||||||
*
|
*
|
||||||
* @param ImportJob $job
|
* @param ImportJob $job
|
||||||
*
|
*
|
||||||
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
|
* @return View
|
||||||
* @throws FireflyException
|
* @throws FireflyException
|
||||||
*/
|
*/
|
||||||
public function settings(ImportJob $job)
|
public function settings(ImportJob $job)
|
||||||
@@ -237,6 +301,36 @@ class ImportController extends Controller
|
|||||||
// depends of course on the data in the job.
|
// depends of course on the data in the job.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param ImportJob $job
|
||||||
|
*/
|
||||||
|
public function start(ImportJob $job)
|
||||||
|
{
|
||||||
|
set_time_limit(0);
|
||||||
|
if ($job->status == 'settings_complete') {
|
||||||
|
ImportProcedure::runImport($job);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This is the last step before the import starts.
|
||||||
|
*
|
||||||
|
* @param ImportJob $job
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector|View
|
||||||
|
*/
|
||||||
|
public function status(ImportJob $job)
|
||||||
|
{
|
||||||
|
Log::debug('Now in status()', ['job' => $job->key]);
|
||||||
|
if (!$this->jobInCorrectStep($job, 'status')) {
|
||||||
|
return $this->redirectToCorrectStep($job);
|
||||||
|
}
|
||||||
|
$subTitle = trans('firefly.import_status');
|
||||||
|
$subTitleIcon = 'fa-star';
|
||||||
|
|
||||||
|
return view('import.status', compact('job', 'subTitle', 'subTitleIcon'));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is step 2. It creates an Import Job. Stores the import.
|
* This is step 2. It creates an Import Job. Stores the import.
|
||||||
*
|
*
|
||||||
@@ -306,8 +400,12 @@ class ImportController extends Controller
|
|||||||
case 'settings':
|
case 'settings':
|
||||||
case 'store-settings':
|
case 'store-settings':
|
||||||
return $job->status === 'import_configuration_saved';
|
return $job->status === 'import_configuration_saved';
|
||||||
|
case 'finished':
|
||||||
|
return $job->status === 'import_complete';
|
||||||
case 'complete':
|
case 'complete':
|
||||||
return $job->status === 'settings_complete';
|
return $job->status === 'settings_complete';
|
||||||
|
case 'status':
|
||||||
|
return ($job->status === 'settings_complete') || ($job->status === 'import_running');
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
@@ -318,16 +416,25 @@ class ImportController extends Controller
|
|||||||
* @param ImportJob $job
|
* @param ImportJob $job
|
||||||
*
|
*
|
||||||
* @return SetupInterface
|
* @return SetupInterface
|
||||||
|
* @throws FireflyException
|
||||||
*/
|
*/
|
||||||
private function makeImporter(ImportJob $job): SetupInterface
|
private function makeImporter(ImportJob $job): SetupInterface
|
||||||
{
|
{
|
||||||
// create proper importer (depends on job)
|
// create proper importer (depends on job)
|
||||||
$type = $job->file_type;
|
$type = strtolower($job->file_type);
|
||||||
/** @var SetupInterface $importer */
|
|
||||||
$importer = app('FireflyIII\Import\Setup\\' . ucfirst($type) . 'Setup');
|
|
||||||
$importer->setJob($job);
|
|
||||||
|
|
||||||
return $importer;
|
// validate type:
|
||||||
|
$validTypes = array_keys(config('firefly.import_formats'));
|
||||||
|
|
||||||
|
|
||||||
|
if (in_array($type, $validTypes)) {
|
||||||
|
/** @var SetupInterface $importer */
|
||||||
|
$importer = app('FireflyIII\Import\Setup\\' . ucfirst($type) . 'Setup');
|
||||||
|
$importer->setJob($job);
|
||||||
|
|
||||||
|
return $importer;
|
||||||
|
}
|
||||||
|
throw new FireflyException(sprintf('"%s" is not a valid file type', $type));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -353,6 +460,10 @@ class ImportController extends Controller
|
|||||||
Log::debug('Will redirect to complete()');
|
Log::debug('Will redirect to complete()');
|
||||||
|
|
||||||
return redirect(route('import.complete', [$job->key]));
|
return redirect(route('import.complete', [$job->key]));
|
||||||
|
case 'import_complete':
|
||||||
|
Log::debug('Will redirect to finished()');
|
||||||
|
|
||||||
|
return redirect(route('import.finished', [$job->key]));
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new FireflyException('Cannot redirect for job state ' . $job->status);
|
throw new FireflyException('Cannot redirect for job state ' . $job->status);
|
||||||
|
@@ -10,7 +10,6 @@
|
|||||||
declare(strict_types = 1);
|
declare(strict_types = 1);
|
||||||
namespace FireflyIII\Http\Controllers;
|
namespace FireflyIII\Http\Controllers;
|
||||||
|
|
||||||
use Auth;
|
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use FireflyIII\Crud\Account\AccountCrudInterface;
|
use FireflyIII\Crud\Account\AccountCrudInterface;
|
||||||
use FireflyIII\Http\Requests\NewUserFormRequest;
|
use FireflyIII\Http\Requests\NewUserFormRequest;
|
||||||
@@ -38,12 +37,12 @@ class NewUserController extends Controller
|
|||||||
/**
|
/**
|
||||||
* @param ARI $repository
|
* @param ARI $repository
|
||||||
*
|
*
|
||||||
* @@return \Illuminate\Http\RedirectResponse|\Illuminate\View\View
|
* @@return View
|
||||||
*/
|
*/
|
||||||
public function index(ARI $repository)
|
public function index(ARI $repository)
|
||||||
{
|
{
|
||||||
|
|
||||||
View::share('title', 'Welcome to Firefly!');
|
View::share('title', trans('firefly.welcome'));
|
||||||
View::share('mainTitleIcon', 'fa-fire');
|
View::share('mainTitleIcon', 'fa-fire');
|
||||||
|
|
||||||
|
|
||||||
@@ -107,7 +106,7 @@ class NewUserController extends Controller
|
|||||||
'accountType' => 'asset',
|
'accountType' => 'asset',
|
||||||
'virtualBalance' => 0,
|
'virtualBalance' => 0,
|
||||||
'active' => true,
|
'active' => true,
|
||||||
'user' => Auth::user()->id,
|
'user' => auth()->user()->id,
|
||||||
'accountRole' => 'defaultAsset',
|
'accountRole' => 'defaultAsset',
|
||||||
'openingBalance' => round($request->input('bank_balance'), 2),
|
'openingBalance' => round($request->input('bank_balance'), 2),
|
||||||
'openingBalanceDate' => new Carbon,
|
'openingBalanceDate' => new Carbon,
|
||||||
@@ -133,7 +132,7 @@ class NewUserController extends Controller
|
|||||||
'accountType' => 'asset',
|
'accountType' => 'asset',
|
||||||
'virtualBalance' => 0,
|
'virtualBalance' => 0,
|
||||||
'active' => true,
|
'active' => true,
|
||||||
'user' => Auth::user()->id,
|
'user' => auth()->user()->id,
|
||||||
'accountRole' => 'savingAsset',
|
'accountRole' => 'savingAsset',
|
||||||
'openingBalance' => round($request->input('savings_balance'), 2),
|
'openingBalance' => round($request->input('savings_balance'), 2),
|
||||||
'openingBalanceDate' => new Carbon,
|
'openingBalanceDate' => new Carbon,
|
||||||
@@ -158,7 +157,7 @@ class NewUserController extends Controller
|
|||||||
'accountType' => 'asset',
|
'accountType' => 'asset',
|
||||||
'virtualBalance' => round($request->get('credit_card_limit'), 2),
|
'virtualBalance' => round($request->get('credit_card_limit'), 2),
|
||||||
'active' => true,
|
'active' => true,
|
||||||
'user' => Auth::user()->id,
|
'user' => auth()->user()->id,
|
||||||
'accountRole' => 'ccAsset',
|
'accountRole' => 'ccAsset',
|
||||||
'openingBalance' => null,
|
'openingBalance' => null,
|
||||||
'openingBalanceDate' => null,
|
'openingBalanceDate' => null,
|
||||||
|
@@ -48,46 +48,46 @@ class PiggyBankController extends Controller
|
|||||||
View::share('mainTitleIcon', 'fa-sort-amount-asc');
|
View::share('mainTitleIcon', 'fa-sort-amount-asc');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Add money to piggy bank (for mobile devices)
|
|
||||||
*
|
|
||||||
* @param ARI $repository
|
|
||||||
* @param PiggyBank $piggyBank
|
|
||||||
*
|
|
||||||
* @return $this
|
|
||||||
*/
|
|
||||||
public function addMobile(ARI $repository, PiggyBank $piggyBank)
|
|
||||||
{
|
|
||||||
/** @var Carbon $date */
|
|
||||||
$date = session('end', Carbon::now()->endOfMonth());
|
|
||||||
$leftOnAccount = $repository->leftOnAccount($piggyBank->account, $date);
|
|
||||||
$savedSoFar = $piggyBank->currentRelevantRep()->currentamount;
|
|
||||||
$leftToSave = bcsub($piggyBank->targetamount, $savedSoFar);
|
|
||||||
$maxAmount = min($leftOnAccount, $leftToSave);
|
|
||||||
|
|
||||||
return view('piggy-banks.add-mobile', compact('piggyBank', 'maxAmount'));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add money to piggy bank
|
* Add money to piggy bank
|
||||||
*
|
*
|
||||||
* @param ARI $repository
|
* @param ARI $repository
|
||||||
* @param PiggyBank $piggyBank
|
* @param PiggyBank $piggyBank
|
||||||
*
|
*
|
||||||
* @return $this
|
* @return View
|
||||||
*/
|
*/
|
||||||
public function add(ARI $repository, PiggyBank $piggyBank)
|
public function add(ARI $repository, PiggyBank $piggyBank)
|
||||||
{
|
{
|
||||||
/** @var Carbon $date */
|
/** @var Carbon $date */
|
||||||
$date = session('end', Carbon::now()->endOfMonth());
|
$date = session('end', Carbon::now()->endOfMonth());
|
||||||
$leftOnAccount = $repository->leftOnAccount($piggyBank->account, $date);
|
$leftOnAccount = $repository->leftOnAccount($piggyBank->account, $date);
|
||||||
$savedSoFar = $piggyBank->currentRelevantRep()->currentamount;
|
$savedSoFar = $piggyBank->currentRelevantRep()->currentamount ?? '0';
|
||||||
$leftToSave = bcsub($piggyBank->targetamount, $savedSoFar);
|
$leftToSave = bcsub($piggyBank->targetamount, $savedSoFar);
|
||||||
$maxAmount = min($leftOnAccount, $leftToSave);
|
$maxAmount = min($leftOnAccount, $leftToSave);
|
||||||
|
|
||||||
return view('piggy-banks.add', compact('piggyBank', 'maxAmount'));
|
return view('piggy-banks.add', compact('piggyBank', 'maxAmount'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add money to piggy bank (for mobile devices)
|
||||||
|
*
|
||||||
|
* @param ARI $repository
|
||||||
|
* @param PiggyBank $piggyBank
|
||||||
|
*
|
||||||
|
* @return View
|
||||||
|
*/
|
||||||
|
public function addMobile(ARI $repository, PiggyBank $piggyBank)
|
||||||
|
{
|
||||||
|
/** @var Carbon $date */
|
||||||
|
$date = session('end', Carbon::now()->endOfMonth());
|
||||||
|
$leftOnAccount = $repository->leftOnAccount($piggyBank->account, $date);
|
||||||
|
$savedSoFar = $piggyBank->currentRelevantRep()->currentamount?? '0';
|
||||||
|
$leftToSave = bcsub($piggyBank->targetamount, $savedSoFar);
|
||||||
|
$maxAmount = min($leftOnAccount, $leftToSave);
|
||||||
|
|
||||||
|
return view('piggy-banks.add-mobile', compact('piggyBank', 'maxAmount'));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param AccountCrudInterface $crud
|
* @param AccountCrudInterface $crud
|
||||||
*
|
*
|
||||||
@@ -113,7 +113,7 @@ class PiggyBankController extends Controller
|
|||||||
/**
|
/**
|
||||||
* @param PiggyBank $piggyBank
|
* @param PiggyBank $piggyBank
|
||||||
*
|
*
|
||||||
* @return $this
|
* @return View
|
||||||
*/
|
*/
|
||||||
public function delete(PiggyBank $piggyBank)
|
public function delete(PiggyBank $piggyBank)
|
||||||
{
|
{
|
||||||
@@ -253,7 +253,8 @@ class PiggyBankController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function postAdd(PiggyBankRepositoryInterface $repository, ARI $accounts, PiggyBank $piggyBank)
|
public function postAdd(PiggyBankRepositoryInterface $repository, ARI $accounts, PiggyBank $piggyBank)
|
||||||
{
|
{
|
||||||
$amount = strval(round(Input::get('amount'), 2));
|
$amount = strval(round(Input::get('amount'), 2));
|
||||||
|
/** @var Carbon $date */
|
||||||
$date = session('end', Carbon::now()->endOfMonth());
|
$date = session('end', Carbon::now()->endOfMonth());
|
||||||
$leftOnAccount = $accounts->leftOnAccount($piggyBank->account, $date);
|
$leftOnAccount = $accounts->leftOnAccount($piggyBank->account, $date);
|
||||||
$savedSoFar = strval($piggyBank->currentRelevantRep()->currentamount);
|
$savedSoFar = strval($piggyBank->currentRelevantRep()->currentamount);
|
||||||
@@ -262,7 +263,8 @@ class PiggyBankController extends Controller
|
|||||||
|
|
||||||
if ($amount <= $maxAmount) {
|
if ($amount <= $maxAmount) {
|
||||||
$repetition = $piggyBank->currentRelevantRep();
|
$repetition = $piggyBank->currentRelevantRep();
|
||||||
$repetition->currentamount = bcadd($repetition->currentamount, $amount);
|
$currentAmount = $repetition->currentamount ?? '0';
|
||||||
|
$repetition->currentamount = bcadd($currentAmount, $amount);
|
||||||
$repetition->save();
|
$repetition->save();
|
||||||
|
|
||||||
// create event
|
// create event
|
||||||
@@ -319,13 +321,25 @@ class PiggyBankController extends Controller
|
|||||||
* @param PiggyBank $piggyBank
|
* @param PiggyBank $piggyBank
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* @return \Illuminate\View\View
|
* @return View
|
||||||
*/
|
*/
|
||||||
public function remove(PiggyBank $piggyBank)
|
public function remove(PiggyBank $piggyBank)
|
||||||
{
|
{
|
||||||
return view('piggy-banks.remove', compact('piggyBank'));
|
return view('piggy-banks.remove', compact('piggyBank'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove money from piggy bank (for mobile devices)
|
||||||
|
*
|
||||||
|
* @param PiggyBank $piggyBank
|
||||||
|
*
|
||||||
|
* @return View
|
||||||
|
*/
|
||||||
|
public function removeMobile(PiggyBank $piggyBank)
|
||||||
|
{
|
||||||
|
return view('piggy-banks.remove-mobile', compact('piggyBank'));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param PiggyBankRepositoryInterface $repository
|
* @param PiggyBankRepositoryInterface $repository
|
||||||
* @param PiggyBank $piggyBank
|
* @param PiggyBank $piggyBank
|
||||||
@@ -345,18 +359,18 @@ class PiggyBankController extends Controller
|
|||||||
* @param PiggyBankFormRequest $request
|
* @param PiggyBankFormRequest $request
|
||||||
* @param PiggyBankRepositoryInterface $repository
|
* @param PiggyBankRepositoryInterface $repository
|
||||||
*
|
*
|
||||||
* @return $this|\Illuminate\Http\RedirectResponse
|
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
|
||||||
*/
|
*/
|
||||||
public function store(PiggyBankFormRequest $request, PiggyBankRepositoryInterface $repository)
|
public function store(PiggyBankFormRequest $request, PiggyBankRepositoryInterface $repository)
|
||||||
{
|
{
|
||||||
|
|
||||||
$piggyBankData = [
|
$piggyBankData = [
|
||||||
'name' => $request->get('name'),
|
'name' => $request->get('name'),
|
||||||
'startdate' => new Carbon,
|
'startdate' => new Carbon,
|
||||||
'account_id' => intval($request->get('account_id')),
|
'account_id' => intval($request->get('account_id')),
|
||||||
'targetamount' => round($request->get('targetamount'), 2),
|
'targetamount' => round($request->get('targetamount'), 2),
|
||||||
'order' => $repository->getMaxOrder() + 1,
|
'order' => $repository->getMaxOrder() + 1,
|
||||||
'targetdate' => strlen($request->get('targetdate')) > 0 ? new Carbon($request->get('targetdate')) : null,
|
'targetdate' => strlen($request->get('targetdate')) > 0 ? new Carbon($request->get('targetdate')) : null,
|
||||||
];
|
];
|
||||||
|
|
||||||
$piggyBank = $repository->store($piggyBankData);
|
$piggyBank = $repository->store($piggyBankData);
|
||||||
@@ -385,11 +399,11 @@ class PiggyBankController extends Controller
|
|||||||
public function update(PiggyBankRepositoryInterface $repository, PiggyBankFormRequest $request, PiggyBank $piggyBank)
|
public function update(PiggyBankRepositoryInterface $repository, PiggyBankFormRequest $request, PiggyBank $piggyBank)
|
||||||
{
|
{
|
||||||
$piggyBankData = [
|
$piggyBankData = [
|
||||||
'name' => $request->get('name'),
|
'name' => $request->get('name'),
|
||||||
'startdate' => is_null($piggyBank->startdate) ? $piggyBank->created_at : $piggyBank->startdate,
|
'startdate' => is_null($piggyBank->startdate) ? $piggyBank->created_at : $piggyBank->startdate,
|
||||||
'account_id' => intval($request->get('account_id')),
|
'account_id' => intval($request->get('account_id')),
|
||||||
'targetamount' => round($request->get('targetamount'), 2),
|
'targetamount' => round($request->get('targetamount'), 2),
|
||||||
'targetdate' => strlen($request->get('targetdate')) > 0 ? new Carbon($request->get('targetdate')) : null,
|
'targetdate' => strlen($request->get('targetdate')) > 0 ? new Carbon($request->get('targetdate')) : null,
|
||||||
];
|
];
|
||||||
|
|
||||||
$piggyBank = $repository->update($piggyBank, $piggyBankData);
|
$piggyBank = $repository->update($piggyBank, $piggyBankData);
|
||||||
|
@@ -13,6 +13,7 @@ namespace FireflyIII\Http\Controllers\Popup;
|
|||||||
|
|
||||||
|
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
|
use FireflyIII\Crud\Account\AccountCrudInterface;
|
||||||
use FireflyIII\Exceptions\FireflyException;
|
use FireflyIII\Exceptions\FireflyException;
|
||||||
use FireflyIII\Helpers\Collection\BalanceLine;
|
use FireflyIII\Helpers\Collection\BalanceLine;
|
||||||
use FireflyIII\Http\Controllers\Controller;
|
use FireflyIII\Http\Controllers\Controller;
|
||||||
@@ -110,8 +111,10 @@ class ReportController extends Controller
|
|||||||
function (TransactionJournal $journal) {
|
function (TransactionJournal $journal) {
|
||||||
$tags = $journal->tags()->where('tagMode', 'balancingAct')->count();
|
$tags = $journal->tags()->where('tagMode', 'balancingAct')->count();
|
||||||
if ($tags === 0) {
|
if ($tags === 0) {
|
||||||
return $journal;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
@@ -182,7 +185,7 @@ class ReportController extends Controller
|
|||||||
{
|
{
|
||||||
/** @var AccountRepositoryInterface $repository */
|
/** @var AccountRepositoryInterface $repository */
|
||||||
$repository = app(AccountRepositoryInterface::class);
|
$repository = app(AccountRepositoryInterface::class);
|
||||||
$crud = app('FireflyIII\Crud\Account\AccountCrudInterface');
|
$crud = app(AccountCrudInterface::class);
|
||||||
$account = $crud->find(intval($attributes['accountId']));
|
$account = $crud->find(intval($attributes['accountId']));
|
||||||
$types = [TransactionType::WITHDRAWAL, TransactionType::TRANSFER];
|
$types = [TransactionType::WITHDRAWAL, TransactionType::TRANSFER];
|
||||||
$journals = $repository->journalsInPeriod($attributes['accounts'], $types, $attributes['startDate'], $attributes['endDate']);
|
$journals = $repository->journalsInPeriod($attributes['accounts'], $types, $attributes['startDate'], $attributes['endDate']);
|
||||||
@@ -190,9 +193,12 @@ class ReportController extends Controller
|
|||||||
// filter for transfers and withdrawals TO the given $account
|
// filter for transfers and withdrawals TO the given $account
|
||||||
$journals = $journals->filter(
|
$journals = $journals->filter(
|
||||||
function (TransactionJournal $journal) use ($account) {
|
function (TransactionJournal $journal) use ($account) {
|
||||||
if ($journal->destination_account_id === $account->id) {
|
$destinations = TransactionJournal::destinationAccountList($journal)->pluck('id')->toArray();
|
||||||
return $journal;
|
if (in_array($account->id, $destinations)) {
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -219,14 +225,19 @@ class ReportController extends Controller
|
|||||||
$journals = $repository->journalsInPeriod(new Collection([$account]), $types, $attributes['startDate'], $attributes['endDate']);
|
$journals = $repository->journalsInPeriod(new Collection([$account]), $types, $attributes['startDate'], $attributes['endDate']);
|
||||||
$destinations = $attributes['accounts']->pluck('id')->toArray();
|
$destinations = $attributes['accounts']->pluck('id')->toArray();
|
||||||
// filter for transfers and withdrawals FROM the given $account
|
// filter for transfers and withdrawals FROM the given $account
|
||||||
|
|
||||||
$journals = $journals->filter(
|
$journals = $journals->filter(
|
||||||
function (TransactionJournal $journal) use ($account, $destinations) {
|
function (TransactionJournal $journal) use ($account, $destinations) {
|
||||||
|
$currentSources = TransactionJournal::sourceAccountList($journal)->pluck('id')->toArray();
|
||||||
|
$currentDest = TransactionJournal::destinationAccountList($journal)->pluck('id')->toArray();
|
||||||
if (
|
if (
|
||||||
$journal->source_account_id === $account->id
|
!empty(array_intersect([$account->id], $currentSources))
|
||||||
&& in_array($journal->destination_account_id, $destinations)
|
&& !empty(array_intersect($destinations, $currentDest))
|
||||||
) {
|
) {
|
||||||
return $journal;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@@ -10,11 +10,10 @@
|
|||||||
declare(strict_types = 1);
|
declare(strict_types = 1);
|
||||||
namespace FireflyIII\Http\Controllers;
|
namespace FireflyIII\Http\Controllers;
|
||||||
|
|
||||||
use Auth;
|
|
||||||
use FireflyIII\Crud\Account\AccountCrudInterface;
|
use FireflyIII\Crud\Account\AccountCrudInterface;
|
||||||
use FireflyIII\Http\Requests\TokenFormRequest;
|
use FireflyIII\Http\Requests\TokenFormRequest;
|
||||||
use FireflyIII\Models\AccountType;
|
use FireflyIII\Models\AccountType;
|
||||||
use Input;
|
use Illuminate\Http\Request;
|
||||||
use PragmaRX\Google2FA\Contracts\Google2FA;
|
use PragmaRX\Google2FA\Contracts\Google2FA;
|
||||||
use Preferences;
|
use Preferences;
|
||||||
use Session;
|
use Session;
|
||||||
@@ -46,7 +45,8 @@ class PreferencesController extends Controller
|
|||||||
public function code(Google2FA $google2fa)
|
public function code(Google2FA $google2fa)
|
||||||
{
|
{
|
||||||
$domain = $this->getDomain();
|
$domain = $this->getDomain();
|
||||||
$secret = $google2fa->generateSecretKey(16, Auth::user()->id);
|
/** @noinspection PhpMethodParametersCountMismatchInspection */
|
||||||
|
$secret = $google2fa->generateSecretKey(16, auth()->user()->id);
|
||||||
Session::flash('two-factor-secret', $secret);
|
Session::flash('two-factor-secret', $secret);
|
||||||
$image = $google2fa->getQRCodeInline('Firefly III at ' . $domain, null, $secret, 150);
|
$image = $google2fa->getQRCodeInline('Firefly III at ' . $domain, null, $secret, 150);
|
||||||
|
|
||||||
@@ -78,13 +78,12 @@ class PreferencesController extends Controller
|
|||||||
$viewRangePref = Preferences::get('viewRange', '1M');
|
$viewRangePref = Preferences::get('viewRange', '1M');
|
||||||
$viewRange = $viewRangePref->data;
|
$viewRange = $viewRangePref->data;
|
||||||
$frontPageAccounts = Preferences::get('frontPageAccounts', []);
|
$frontPageAccounts = Preferences::get('frontPageAccounts', []);
|
||||||
$budgetMax = Preferences::get('budgetMaximum', 1000);
|
$language = Preferences::get('language', config('firefly.default_language', 'en_US'))->data;
|
||||||
$language = Preferences::get('language', env('DEFAULT_LANGUAGE', 'en_US'))->data;
|
|
||||||
$budgetMaximum = $budgetMax->data;
|
|
||||||
$transactionPageSize = Preferences::get('transactionPageSize', 50)->data;
|
$transactionPageSize = Preferences::get('transactionPageSize', 50)->data;
|
||||||
$customFiscalYear = Preferences::get('customFiscalYear', 0)->data;
|
$customFiscalYear = Preferences::get('customFiscalYear', 0)->data;
|
||||||
$fiscalYearStartStr = Preferences::get('fiscalYearStart', '01-01')->data;
|
$fiscalYearStartStr = Preferences::get('fiscalYearStart', '01-01')->data;
|
||||||
$fiscalYearStart = date('Y') . '-' . $fiscalYearStartStr;
|
$fiscalYearStart = date('Y') . '-' . $fiscalYearStartStr;
|
||||||
|
$tjOptionalFields = Preferences::get('transaction_journal_optional_fields', [])->data;
|
||||||
$is2faEnabled = Preferences::get('twoFactorAuthEnabled', 0)->data; // twoFactorAuthEnabled
|
$is2faEnabled = Preferences::get('twoFactorAuthEnabled', 0)->data; // twoFactorAuthEnabled
|
||||||
$has2faSecret = !is_null(Preferences::get('twoFactorAuthSecret')); // hasTwoFactorAuthSecret
|
$has2faSecret = !is_null(Preferences::get('twoFactorAuthSecret')); // hasTwoFactorAuthSecret
|
||||||
$showIncomplete = env('SHOW_INCOMPLETE_TRANSLATIONS', false) === true;
|
$showIncomplete = env('SHOW_INCOMPLETE_TRANSLATIONS', false) === true;
|
||||||
@@ -92,7 +91,7 @@ class PreferencesController extends Controller
|
|||||||
return view(
|
return view(
|
||||||
'preferences.index',
|
'preferences.index',
|
||||||
compact(
|
compact(
|
||||||
'budgetMaximum', 'language', 'accounts', 'frontPageAccounts',
|
'language', 'accounts', 'frontPageAccounts', 'tjOptionalFields',
|
||||||
'viewRange', 'customFiscalYear', 'transactionPageSize', 'fiscalYearStart', 'is2faEnabled',
|
'viewRange', 'customFiscalYear', 'transactionPageSize', 'fiscalYearStart', 'is2faEnabled',
|
||||||
'has2faSecret', 'showIncomplete'
|
'has2faSecret', 'showIncomplete'
|
||||||
)
|
)
|
||||||
@@ -116,38 +115,36 @@ class PreferencesController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return \Illuminate\Http\RedirectResponse
|
* @param Request $request
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
|
||||||
*/
|
*/
|
||||||
public function postIndex()
|
public function postIndex(Request $request)
|
||||||
{
|
{
|
||||||
// front page accounts
|
// front page accounts
|
||||||
$frontPageAccounts = [];
|
$frontPageAccounts = [];
|
||||||
if (is_array(Input::get('frontPageAccounts'))) {
|
if (is_array($request->get('frontPageAccounts'))) {
|
||||||
foreach (Input::get('frontPageAccounts') as $id) {
|
foreach ($request->get('frontPageAccounts') as $id) {
|
||||||
$frontPageAccounts[] = intval($id);
|
$frontPageAccounts[] = intval($id);
|
||||||
}
|
}
|
||||||
Preferences::set('frontPageAccounts', $frontPageAccounts);
|
Preferences::set('frontPageAccounts', $frontPageAccounts);
|
||||||
}
|
}
|
||||||
|
|
||||||
// view range:
|
// view range:
|
||||||
Preferences::set('viewRange', Input::get('viewRange'));
|
Preferences::set('viewRange', $request->get('viewRange'));
|
||||||
// forget session values:
|
// forget session values:
|
||||||
Session::forget('start');
|
Session::forget('start');
|
||||||
Session::forget('end');
|
Session::forget('end');
|
||||||
Session::forget('range');
|
Session::forget('range');
|
||||||
|
|
||||||
// budget maximum:
|
|
||||||
$budgetMaximum = intval(Input::get('budgetMaximum'));
|
|
||||||
Preferences::set('budgetMaximum', $budgetMaximum);
|
|
||||||
|
|
||||||
// custom fiscal year
|
// custom fiscal year
|
||||||
$customFiscalYear = intval(Input::get('customFiscalYear')) === 1;
|
$customFiscalYear = intval($request->get('customFiscalYear')) === 1;
|
||||||
$fiscalYearStart = date('m-d', strtotime(Input::get('fiscalYearStart')));
|
$fiscalYearStart = date('m-d', strtotime($request->get('fiscalYearStart')));
|
||||||
Preferences::set('customFiscalYear', $customFiscalYear);
|
Preferences::set('customFiscalYear', $customFiscalYear);
|
||||||
Preferences::set('fiscalYearStart', $fiscalYearStart);
|
Preferences::set('fiscalYearStart', $fiscalYearStart);
|
||||||
|
|
||||||
// save page size:
|
// save page size:
|
||||||
$transactionPageSize = intval(Input::get('transactionPageSize'));
|
$transactionPageSize = intval($request->get('transactionPageSize'));
|
||||||
if ($transactionPageSize > 0 && $transactionPageSize < 1337) {
|
if ($transactionPageSize > 0 && $transactionPageSize < 1337) {
|
||||||
Preferences::set('transactionPageSize', $transactionPageSize);
|
Preferences::set('transactionPageSize', $transactionPageSize);
|
||||||
} else {
|
} else {
|
||||||
@@ -155,7 +152,7 @@ class PreferencesController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
// two factor auth
|
// two factor auth
|
||||||
$twoFactorAuthEnabled = intval(Input::get('twoFactorAuthEnabled'));
|
$twoFactorAuthEnabled = intval($request->get('twoFactorAuthEnabled'));
|
||||||
$hasTwoFactorAuthSecret = !is_null(Preferences::get('twoFactorAuthSecret'));
|
$hasTwoFactorAuthSecret = !is_null(Preferences::get('twoFactorAuthSecret'));
|
||||||
|
|
||||||
// If we already have a secret, just set the two factor auth enabled to 1, and let the user continue with the existing secret.
|
// If we already have a secret, just set the two factor auth enabled to 1, and let the user continue with the existing secret.
|
||||||
@@ -164,11 +161,26 @@ class PreferencesController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
// language:
|
// language:
|
||||||
$lang = Input::get('language');
|
$lang = $request->get('language');
|
||||||
if (in_array($lang, array_keys(config('firefly.languages')))) {
|
if (in_array($lang, array_keys(config('firefly.languages')))) {
|
||||||
Preferences::set('language', $lang);
|
Preferences::set('language', $lang);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// optional fields for transactions:
|
||||||
|
$setOptions = $request->get('tj');
|
||||||
|
$optionalTj = [
|
||||||
|
'interest_date' => isset($setOptions['interest_date']),
|
||||||
|
'book_date' => isset($setOptions['book_date']),
|
||||||
|
'process_date' => isset($setOptions['process_date']),
|
||||||
|
'due_date' => isset($setOptions['due_date']),
|
||||||
|
'payment_date' => isset($setOptions['payment_date']),
|
||||||
|
'invoice_date' => isset($setOptions['invoice_date']),
|
||||||
|
'internal_reference' => isset($setOptions['internal_reference']),
|
||||||
|
'notes' => isset($setOptions['notes']),
|
||||||
|
'attachments' => isset($setOptions['attachments']),
|
||||||
|
];
|
||||||
|
Preferences::set('transaction_journal_optional_fields', $optionalTj);
|
||||||
|
|
||||||
|
|
||||||
Session::flash('success', strval(trans('firefly.saved_preferences')));
|
Session::flash('success', strval(trans('firefly.saved_preferences')));
|
||||||
Preferences::mark();
|
Preferences::mark();
|
||||||
|
@@ -11,7 +11,6 @@ declare(strict_types = 1);
|
|||||||
|
|
||||||
namespace FireflyIII\Http\Controllers;
|
namespace FireflyIII\Http\Controllers;
|
||||||
|
|
||||||
use Auth;
|
|
||||||
use FireflyIII\Events\UserIsDeleted;
|
use FireflyIII\Events\UserIsDeleted;
|
||||||
use FireflyIII\Http\Requests\DeleteAccountFormRequest;
|
use FireflyIII\Http\Requests\DeleteAccountFormRequest;
|
||||||
use FireflyIII\Http\Requests\ProfileFormRequest;
|
use FireflyIII\Http\Requests\ProfileFormRequest;
|
||||||
@@ -19,6 +18,7 @@ use FireflyIII\User;
|
|||||||
use Hash;
|
use Hash;
|
||||||
use Preferences;
|
use Preferences;
|
||||||
use Session;
|
use Session;
|
||||||
|
use View;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class ProfileController
|
* Class ProfileController
|
||||||
@@ -36,32 +36,32 @@ class ProfileController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return \Illuminate\View\View
|
* @return View
|
||||||
*/
|
*/
|
||||||
public function changePassword()
|
public function changePassword()
|
||||||
{
|
{
|
||||||
return view('profile.change-password')->with('title', Auth::user()->email)->with('subTitle', trans('firefly.change_your_password'))->with(
|
return view('profile.change-password')->with('title', auth()->user()->email)->with('subTitle', trans('firefly.change_your_password'))->with(
|
||||||
'mainTitleIcon', 'fa-user'
|
'mainTitleIcon', 'fa-user'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return \Illuminate\View\View
|
* @return View
|
||||||
*/
|
*/
|
||||||
public function deleteAccount()
|
public function deleteAccount()
|
||||||
{
|
{
|
||||||
return view('profile.delete-account')->with('title', Auth::user()->email)->with('subTitle', trans('firefly.delete_account'))->with(
|
return view('profile.delete-account')->with('title', auth()->user()->email)->with('subTitle', trans('firefly.delete_account'))->with(
|
||||||
'mainTitleIcon', 'fa-user'
|
'mainTitleIcon', 'fa-user'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return \Illuminate\View\View
|
* @return View
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public function index()
|
public function index()
|
||||||
{
|
{
|
||||||
return view('profile.index')->with('title', trans('firefly.profile'))->with('subTitle', Auth::user()->email)->with('mainTitleIcon', 'fa-user');
|
return view('profile.index')->with('title', trans('firefly.profile'))->with('subTitle', auth()->user()->email)->with('mainTitleIcon', 'fa-user');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -72,7 +72,7 @@ class ProfileController extends Controller
|
|||||||
public function postChangePassword(ProfileFormRequest $request)
|
public function postChangePassword(ProfileFormRequest $request)
|
||||||
{
|
{
|
||||||
// old, new1, new2
|
// old, new1, new2
|
||||||
if (!Hash::check($request->get('current_password'), Auth::user()->password)) {
|
if (!Hash::check($request->get('current_password'), auth()->user()->password)) {
|
||||||
Session::flash('error', strval(trans('firefly.invalid_current_password')));
|
Session::flash('error', strval(trans('firefly.invalid_current_password')));
|
||||||
|
|
||||||
return redirect(route('profile.change-password'));
|
return redirect(route('profile.change-password'));
|
||||||
@@ -85,8 +85,8 @@ class ProfileController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
// update the user with the new password.
|
// update the user with the new password.
|
||||||
Auth::user()->password = bcrypt($request->get('new_password'));
|
auth()->user()->password = bcrypt($request->get('new_password'));
|
||||||
Auth::user()->save();
|
auth()->user()->save();
|
||||||
|
|
||||||
Session::flash('success', strval(trans('firefly.password_changed')));
|
Session::flash('success', strval(trans('firefly.password_changed')));
|
||||||
|
|
||||||
@@ -102,22 +102,22 @@ class ProfileController extends Controller
|
|||||||
public function postDeleteAccount(DeleteAccountFormRequest $request)
|
public function postDeleteAccount(DeleteAccountFormRequest $request)
|
||||||
{
|
{
|
||||||
// old, new1, new2
|
// old, new1, new2
|
||||||
if (!Hash::check($request->get('password'), Auth::user()->password)) {
|
if (!Hash::check($request->get('password'), auth()->user()->password)) {
|
||||||
Session::flash('error', strval(trans('firefly.invalid_password')));
|
Session::flash('error', strval(trans('firefly.invalid_password')));
|
||||||
|
|
||||||
return redirect(route('profile.delete-account'));
|
return redirect(route('profile.delete-account'));
|
||||||
}
|
}
|
||||||
|
|
||||||
// respond to deletion:
|
// respond to deletion:
|
||||||
event(new UserIsDeleted(Auth::user(), $request->ip()));
|
event(new UserIsDeleted(auth()->user(), $request->ip()));
|
||||||
|
|
||||||
// store some stuff for the future:
|
// store some stuff for the future:
|
||||||
$registration = Preferences::get('registration_ip_address')->data;
|
$registration = Preferences::get('registration_ip_address')->data;
|
||||||
$confirmation = Preferences::get('confirmation_ip_address')->data;
|
$confirmation = Preferences::get('confirmation_ip_address')->data;
|
||||||
|
|
||||||
// DELETE!
|
// DELETE!
|
||||||
$email = Auth::user()->email;
|
$email = auth()->user()->email;
|
||||||
Auth::user()->delete();
|
auth()->user()->delete();
|
||||||
Session::flush();
|
Session::flush();
|
||||||
Session::flash('gaEventCategory', 'user');
|
Session::flash('gaEventCategory', 'user');
|
||||||
Session::flash('gaEventAction', 'delete-account');
|
Session::flash('gaEventAction', 'delete-account');
|
||||||
|
@@ -50,18 +50,11 @@ class ReportController extends Controller
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*
|
|
||||||
* @param ReportHelperInterface $helper
|
|
||||||
*/
|
*/
|
||||||
public function __construct(ReportHelperInterface $helper)
|
public function __construct()
|
||||||
{
|
{
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
|
|
||||||
$this->helper = $helper;
|
|
||||||
$this->accountHelper = app(AccountReportHelperInterface::class);
|
|
||||||
$this->budgetHelper = app(BudgetReportHelperInterface::class);
|
|
||||||
$this->balanceHelper = app(BalanceReportHelperInterface::class);
|
|
||||||
|
|
||||||
View::share('title', trans('firefly.reports'));
|
View::share('title', trans('firefly.reports'));
|
||||||
View::share('mainTitleIcon', 'fa-line-chart');
|
View::share('mainTitleIcon', 'fa-line-chart');
|
||||||
|
|
||||||
@@ -74,6 +67,7 @@ class ReportController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function index(AccountCrudInterface $crud)
|
public function index(AccountCrudInterface $crud)
|
||||||
{
|
{
|
||||||
|
$this->createRepositories();
|
||||||
/** @var Carbon $start */
|
/** @var Carbon $start */
|
||||||
$start = clone session('first');
|
$start = clone session('first');
|
||||||
$months = $this->helper->listOfMonths($start);
|
$months = $this->helper->listOfMonths($start);
|
||||||
@@ -104,6 +98,7 @@ class ReportController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function report(string $reportType, Carbon $start, Carbon $end, Collection $accounts)
|
public function report(string $reportType, Carbon $start, Carbon $end, Collection $accounts)
|
||||||
{
|
{
|
||||||
|
$this->createRepositories();
|
||||||
// throw an error if necessary.
|
// throw an error if necessary.
|
||||||
if ($end < $start) {
|
if ($end < $start) {
|
||||||
throw new FireflyException('End date cannot be before start date, silly!');
|
throw new FireflyException('End date cannot be before start date, silly!');
|
||||||
@@ -192,8 +187,9 @@ class ReportController extends Controller
|
|||||||
$transactionAmount = $journal->source_amount;
|
$transactionAmount = $journal->source_amount;
|
||||||
|
|
||||||
// get currently relevant transaction:
|
// get currently relevant transaction:
|
||||||
if (intval($journal->destination_account_id) === $account->id) {
|
$destinations = TransactionJournal::destinationAccountList($journal)->pluck('id')->toArray();
|
||||||
$transactionAmount = $journal->destination_amount;
|
if (in_array($account->id, $destinations)) {
|
||||||
|
$transactionAmount = TransactionJournal::amountPositive($journal);
|
||||||
}
|
}
|
||||||
$newBalance = bcadd($startBalance, $transactionAmount);
|
$newBalance = bcadd($startBalance, $transactionAmount);
|
||||||
$journal->after = $newBalance;
|
$journal->after = $newBalance;
|
||||||
@@ -215,14 +211,32 @@ class ReportController extends Controller
|
|||||||
$reportType = 'audit';
|
$reportType = 'audit';
|
||||||
$accountIds = join(',', $accounts->pluck('id')->toArray());
|
$accountIds = join(',', $accounts->pluck('id')->toArray());
|
||||||
|
|
||||||
$hideable = ['buttons', 'icon', 'description', 'balance_before', 'amount', 'balance_after', 'date', 'book_date', 'process_date', 'interest_date',
|
$hideable = ['buttons', 'icon', 'description', 'balance_before', 'amount', 'balance_after', 'date',
|
||||||
'from', 'to', 'budget', 'category', 'bill', 'create_date', 'update_date',
|
'interest_date', 'book_date', 'process_date',
|
||||||
|
// three new optional fields.
|
||||||
|
'due_date', 'payment_date', 'invoice_date',
|
||||||
|
'from', 'to', 'budget', 'category', 'bill',
|
||||||
|
// more new optional fields
|
||||||
|
'internal_reference', 'notes',
|
||||||
|
|
||||||
|
'create_date', 'update_date',
|
||||||
];
|
];
|
||||||
$defaultShow = ['icon', 'description', 'balance_before', 'amount', 'balance_after', 'date', 'to'];
|
$defaultShow = ['icon', 'description', 'balance_before', 'amount', 'balance_after', 'date', 'to'];
|
||||||
|
|
||||||
return view('reports.audit.report', compact('start', 'end', 'reportType', 'accountIds', 'accounts', 'auditData', 'hideable', 'defaultShow'));
|
return view('reports.audit.report', compact('start', 'end', 'reportType', 'accountIds', 'accounts', 'auditData', 'hideable', 'defaultShow'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private function createRepositories()
|
||||||
|
{
|
||||||
|
$this->helper = app(ReportHelperInterface::class);
|
||||||
|
$this->accountHelper = app(AccountReportHelperInterface::class);
|
||||||
|
$this->budgetHelper = app(BudgetReportHelperInterface::class);
|
||||||
|
$this->balanceHelper = app(BalanceReportHelperInterface::class);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $reportType
|
* @param $reportType
|
||||||
* @param Carbon $start
|
* @param Carbon $start
|
||||||
|
@@ -11,7 +11,6 @@ declare(strict_types = 1);
|
|||||||
|
|
||||||
namespace FireflyIII\Http\Controllers;
|
namespace FireflyIII\Http\Controllers;
|
||||||
|
|
||||||
use Auth;
|
|
||||||
use FireflyIII\Http\Requests\RuleFormRequest;
|
use FireflyIII\Http\Requests\RuleFormRequest;
|
||||||
use FireflyIII\Http\Requests\TestRuleFormRequest;
|
use FireflyIII\Http\Requests\TestRuleFormRequest;
|
||||||
use FireflyIII\Models\Rule;
|
use FireflyIII\Models\Rule;
|
||||||
@@ -189,7 +188,7 @@ class RuleController extends Controller
|
|||||||
{
|
{
|
||||||
$this->createDefaultRuleGroup();
|
$this->createDefaultRuleGroup();
|
||||||
$this->createDefaultRule();
|
$this->createDefaultRule();
|
||||||
$ruleGroups = $repository->getRuleGroupsWithRules(Auth::user());
|
$ruleGroups = $repository->getRuleGroupsWithRules(auth()->user());
|
||||||
|
|
||||||
return view('rules.index', compact('ruleGroups'));
|
return view('rules.index', compact('ruleGroups'));
|
||||||
}
|
}
|
||||||
@@ -233,7 +232,7 @@ class RuleController extends Controller
|
|||||||
* @param RuleRepositoryInterface $repository
|
* @param RuleRepositoryInterface $repository
|
||||||
* @param RuleGroup $ruleGroup
|
* @param RuleGroup $ruleGroup
|
||||||
*
|
*
|
||||||
* @return $this|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
|
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
|
||||||
*/
|
*/
|
||||||
public function store(RuleFormRequest $request, RuleRepositoryInterface $repository, RuleGroup $ruleGroup)
|
public function store(RuleFormRequest $request, RuleRepositoryInterface $repository, RuleGroup $ruleGroup)
|
||||||
{
|
{
|
||||||
@@ -243,7 +242,7 @@ class RuleController extends Controller
|
|||||||
$data = [
|
$data = [
|
||||||
'rule_group_id' => $ruleGroup->id,
|
'rule_group_id' => $ruleGroup->id,
|
||||||
'title' => $request->get('title'),
|
'title' => $request->get('title'),
|
||||||
'user_id' => Auth::user()->id,
|
'user_id' => auth()->user()->id,
|
||||||
'trigger' => $request->get('trigger'),
|
'trigger' => $request->get('trigger'),
|
||||||
'description' => $request->get('description'),
|
'description' => $request->get('description'),
|
||||||
'rule-triggers' => $request->get('rule-trigger'),
|
'rule-triggers' => $request->get('rule-trigger'),
|
||||||
@@ -281,7 +280,7 @@ class RuleController extends Controller
|
|||||||
*
|
*
|
||||||
* @param TestRuleFormRequest $request
|
* @param TestRuleFormRequest $request
|
||||||
*
|
*
|
||||||
* @return \Illuminate\View\View
|
* @return \Illuminate\Http\JsonResponse
|
||||||
*/
|
*/
|
||||||
public function testTriggers(TestRuleFormRequest $request)
|
public function testTriggers(TestRuleFormRequest $request)
|
||||||
{
|
{
|
||||||
@@ -336,7 +335,7 @@ class RuleController extends Controller
|
|||||||
* @param RuleFormRequest $request
|
* @param RuleFormRequest $request
|
||||||
* @param Rule $rule
|
* @param Rule $rule
|
||||||
*
|
*
|
||||||
* @return $this|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
|
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
|
||||||
*/
|
*/
|
||||||
public function update(RuleRepositoryInterface $repository, RuleFormRequest $request, Rule $rule)
|
public function update(RuleRepositoryInterface $repository, RuleFormRequest $request, Rule $rule)
|
||||||
{
|
{
|
||||||
@@ -380,7 +379,7 @@ class RuleController extends Controller
|
|||||||
$data = [
|
$data = [
|
||||||
'rule_group_id' => $repository->getFirstRuleGroup()->id,
|
'rule_group_id' => $repository->getFirstRuleGroup()->id,
|
||||||
'stop_processing' => 0,
|
'stop_processing' => 0,
|
||||||
'user_id' => Auth::user()->id,
|
'user_id' => auth()->user()->id,
|
||||||
'title' => trans('firefly.default_rule_name'),
|
'title' => trans('firefly.default_rule_name'),
|
||||||
'description' => trans('firefly.default_rule_description'),
|
'description' => trans('firefly.default_rule_description'),
|
||||||
'trigger' => 'store-journal',
|
'trigger' => 'store-journal',
|
||||||
@@ -413,7 +412,7 @@ class RuleController extends Controller
|
|||||||
|
|
||||||
if ($repository->count() === 0) {
|
if ($repository->count() === 0) {
|
||||||
$data = [
|
$data = [
|
||||||
'user_id' => Auth::user()->id,
|
'user_id' => auth()->user()->id,
|
||||||
'title' => trans('firefly.default_rule_group_name'),
|
'title' => trans('firefly.default_rule_group_name'),
|
||||||
'description' => trans('firefly.default_rule_group_description'),
|
'description' => trans('firefly.default_rule_group_description'),
|
||||||
];
|
];
|
||||||
|
@@ -11,7 +11,6 @@ declare(strict_types = 1);
|
|||||||
|
|
||||||
namespace FireflyIII\Http\Controllers;
|
namespace FireflyIII\Http\Controllers;
|
||||||
|
|
||||||
use Auth;
|
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use ExpandedForm;
|
use ExpandedForm;
|
||||||
use FireflyIII\Crud\Account\AccountCrudInterface;
|
use FireflyIII\Crud\Account\AccountCrudInterface;
|
||||||
@@ -96,7 +95,7 @@ class RuleGroupController extends Controller
|
|||||||
{
|
{
|
||||||
|
|
||||||
$title = $ruleGroup->title;
|
$title = $ruleGroup->title;
|
||||||
$moveTo = Auth::user()->ruleGroups()->find(intval(Input::get('move_rules_before_delete')));
|
$moveTo = auth()->user()->ruleGroups()->find(intval(Input::get('move_rules_before_delete')));
|
||||||
|
|
||||||
$repository->destroy($ruleGroup, $moveTo);
|
$repository->destroy($ruleGroup, $moveTo);
|
||||||
|
|
||||||
@@ -163,7 +162,7 @@ class RuleGroupController extends Controller
|
|||||||
$job = new ExecuteRuleGroupOnExistingTransactions($ruleGroup);
|
$job = new ExecuteRuleGroupOnExistingTransactions($ruleGroup);
|
||||||
|
|
||||||
// Apply parameters to the job
|
// Apply parameters to the job
|
||||||
$job->setUser(Auth::user());
|
$job->setUser(auth()->user());
|
||||||
$job->setAccounts($accounts);
|
$job->setAccounts($accounts);
|
||||||
$job->setStartDate($startDate);
|
$job->setStartDate($startDate);
|
||||||
$job->setEndDate($endDate);
|
$job->setEndDate($endDate);
|
||||||
@@ -200,14 +199,14 @@ class RuleGroupController extends Controller
|
|||||||
* @param RuleGroupFormRequest $request
|
* @param RuleGroupFormRequest $request
|
||||||
* @param RuleGroupRepositoryInterface $repository
|
* @param RuleGroupRepositoryInterface $repository
|
||||||
*
|
*
|
||||||
* @return $this|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
|
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
|
||||||
*/
|
*/
|
||||||
public function store(RuleGroupFormRequest $request, RuleGroupRepositoryInterface $repository)
|
public function store(RuleGroupFormRequest $request, RuleGroupRepositoryInterface $repository)
|
||||||
{
|
{
|
||||||
$data = [
|
$data = [
|
||||||
'title' => $request->input('title'),
|
'title' => $request->input('title'),
|
||||||
'description' => $request->input('description'),
|
'description' => $request->input('description'),
|
||||||
'user_id' => Auth::user()->id,
|
'user_id' => auth()->user()->id,
|
||||||
];
|
];
|
||||||
|
|
||||||
$ruleGroup = $repository->store($data);
|
$ruleGroup = $repository->store($data);
|
||||||
@@ -245,7 +244,7 @@ class RuleGroupController extends Controller
|
|||||||
* @param RuleGroupRepositoryInterface $repository
|
* @param RuleGroupRepositoryInterface $repository
|
||||||
* @param RuleGroup $ruleGroup
|
* @param RuleGroup $ruleGroup
|
||||||
*
|
*
|
||||||
* @return $this|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
|
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
|
||||||
*/
|
*/
|
||||||
public function update(RuleGroupFormRequest $request, RuleGroupRepositoryInterface $repository, RuleGroup $ruleGroup)
|
public function update(RuleGroupFormRequest $request, RuleGroupRepositoryInterface $repository, RuleGroup $ruleGroup)
|
||||||
{
|
{
|
||||||
|
@@ -11,7 +11,6 @@ declare(strict_types = 1);
|
|||||||
|
|
||||||
namespace FireflyIII\Http\Controllers;
|
namespace FireflyIII\Http\Controllers;
|
||||||
|
|
||||||
use Auth;
|
|
||||||
use FireflyIII\Http\Requests\TagFormRequest;
|
use FireflyIII\Http\Requests\TagFormRequest;
|
||||||
use FireflyIII\Models\Preference;
|
use FireflyIII\Models\Preference;
|
||||||
use FireflyIII\Models\Tag;
|
use FireflyIII\Models\Tag;
|
||||||
@@ -61,7 +60,7 @@ class TagController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return \Illuminate\View\View
|
* @return View
|
||||||
*/
|
*/
|
||||||
public function create()
|
public function create()
|
||||||
{
|
{
|
||||||
@@ -88,7 +87,7 @@ class TagController extends Controller
|
|||||||
/**
|
/**
|
||||||
* @param Tag $tag
|
* @param Tag $tag
|
||||||
*
|
*
|
||||||
* @return \Illuminate\View\View
|
* @return View
|
||||||
*/
|
*/
|
||||||
public function delete(Tag $tag)
|
public function delete(Tag $tag)
|
||||||
{
|
{
|
||||||
@@ -123,7 +122,7 @@ class TagController extends Controller
|
|||||||
/**
|
/**
|
||||||
* @param Tag $tag
|
* @param Tag $tag
|
||||||
*
|
*
|
||||||
* @return \Illuminate\View\View
|
* @return View
|
||||||
*/
|
*/
|
||||||
public function edit(Tag $tag)
|
public function edit(Tag $tag)
|
||||||
{
|
{
|
||||||
@@ -194,7 +193,7 @@ class TagController extends Controller
|
|||||||
foreach ($types as $type) {
|
foreach ($types as $type) {
|
||||||
|
|
||||||
/** @var Collection $tags */
|
/** @var Collection $tags */
|
||||||
$tags = Auth::user()->tags()->where('tagMode', $type)->orderBy('date', 'ASC')->get();
|
$tags = auth()->user()->tags()->where('tagMode', $type)->orderBy('date', 'ASC')->get();
|
||||||
$tags = $tags->sortBy(
|
$tags = $tags->sortBy(
|
||||||
function (Tag $tag) {
|
function (Tag $tag) {
|
||||||
$date = !is_null($tag->date) ? $tag->date->format('Ymd') : '000000';
|
$date = !is_null($tag->date) ? $tag->date->format('Ymd') : '000000';
|
||||||
@@ -218,18 +217,17 @@ class TagController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Tag $tag
|
* @param Tag $tag
|
||||||
|
* @param TagRepositoryInterface $repository
|
||||||
*
|
*
|
||||||
* @return \Illuminate\View\View
|
* @return View
|
||||||
*/
|
*/
|
||||||
public function show(Tag $tag)
|
public function show(Tag $tag, TagRepositoryInterface $repository)
|
||||||
{
|
{
|
||||||
$subTitle = $tag->tag;
|
$subTitle = $tag->tag;
|
||||||
$subTitleIcon = 'fa-tag';
|
$subTitleIcon = 'fa-tag';
|
||||||
/** @var Collection $journals */
|
$journals = $repository->getJournals($tag);
|
||||||
$journals = $tag->transactionjournals()->sortCorrectly()->expanded()->get(TransactionJournal::queryFields());
|
$sum = $journals->sum(
|
||||||
|
|
||||||
$sum = $journals->sum(
|
|
||||||
function (TransactionJournal $journal) {
|
function (TransactionJournal $journal) {
|
||||||
return TransactionJournal::amount($journal);
|
return TransactionJournal::amount($journal);
|
||||||
}
|
}
|
||||||
|
@@ -11,7 +11,6 @@ declare(strict_types = 1);
|
|||||||
|
|
||||||
namespace FireflyIII\Http\Controllers\Transaction;
|
namespace FireflyIII\Http\Controllers\Transaction;
|
||||||
|
|
||||||
use Auth;
|
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use ExpandedForm;
|
use ExpandedForm;
|
||||||
use FireflyIII\Http\Controllers\Controller;
|
use FireflyIII\Http\Controllers\Controller;
|
||||||
@@ -75,7 +74,7 @@ class MassController extends Controller
|
|||||||
/** @var int $journalId */
|
/** @var int $journalId */
|
||||||
foreach ($ids as $journalId) {
|
foreach ($ids as $journalId) {
|
||||||
/** @var TransactionJournal $journal */
|
/** @var TransactionJournal $journal */
|
||||||
$journal = $repository->find($journalId);
|
$journal = $repository->find(intval($journalId));
|
||||||
if (!is_null($journal->id) && $journalId == $journal->id) {
|
if (!is_null($journal->id) && $journalId == $journal->id) {
|
||||||
$set->push($journal);
|
$set->push($journal);
|
||||||
}
|
}
|
||||||
@@ -192,7 +191,7 @@ class MassController extends Controller
|
|||||||
$destAccountName = $request->get('destination_account_name')[$journal->id] ?? '';
|
$destAccountName = $request->get('destination_account_name')[$journal->id] ?? '';
|
||||||
|
|
||||||
$budgetId = $journal->budgets->first() ? $journal->budgets->first()->id : 0;
|
$budgetId = $journal->budgets->first() ? $journal->budgets->first()->id : 0;
|
||||||
$category = $journal->categories->first() ? $journal->categories->first()->name : '';
|
$category = $request->get('category')[$journal->id];
|
||||||
$tags = $journal->tags->pluck('tag')->toArray();
|
$tags = $journal->tags->pluck('tag')->toArray();
|
||||||
|
|
||||||
// build data array
|
// build data array
|
||||||
@@ -201,11 +200,11 @@ class MassController extends Controller
|
|||||||
'what' => $what,
|
'what' => $what,
|
||||||
'description' => $request->get('description')[$journal->id],
|
'description' => $request->get('description')[$journal->id],
|
||||||
'source_account_id' => intval($sourceAccountId),
|
'source_account_id' => intval($sourceAccountId),
|
||||||
'source_account_name' => intval($destAccountId),
|
'source_account_name' => $sourceAccountName,
|
||||||
'destination_account_id' => $sourceAccountName,
|
'destination_account_id' => intval($destAccountId),
|
||||||
'destination_account_name' => $destAccountName,
|
'destination_account_name' => $destAccountName,
|
||||||
'amount' => round($request->get('amount')[$journal->id], 4),
|
'amount' => round($request->get('amount')[$journal->id], 4),
|
||||||
'user' => Auth::user()->id,
|
'user' => auth()->user()->id,
|
||||||
'amount_currency_id_amount' => intval($request->get('amount_currency_id_amount_' . $journal->id)),
|
'amount_currency_id_amount' => intval($request->get('amount_currency_id_amount_' . $journal->id)),
|
||||||
'date' => new Carbon($request->get('date')[$journal->id]),
|
'date' => new Carbon($request->get('date')[$journal->id]),
|
||||||
'interest_date' => $journal->interest_date,
|
'interest_date' => $journal->interest_date,
|
||||||
|
@@ -67,6 +67,7 @@ class SplitController extends Controller
|
|||||||
$budgets = ExpandedForm::makeSelectListWithEmpty($budgetRepository->getActiveBudgets());
|
$budgets = ExpandedForm::makeSelectListWithEmpty($budgetRepository->getActiveBudgets());
|
||||||
$piggyBanks = ExpandedForm::makeSelectListWithEmpty($piggyRepository->getPiggyBanksWithAmount());
|
$piggyBanks = ExpandedForm::makeSelectListWithEmpty($piggyRepository->getPiggyBanksWithAmount());
|
||||||
$subTitle = trans('form.add_new_' . $sessionData['what']);
|
$subTitle = trans('form.add_new_' . $sessionData['what']);
|
||||||
|
$optionalFields = Preferences::get('transaction_journal_optional_fields', [])->data;
|
||||||
$subTitleIcon = 'fa-plus';
|
$subTitleIcon = 'fa-plus';
|
||||||
$preFilled = [
|
$preFilled = [
|
||||||
'what' => $sessionData['what'] ?? 'withdrawal',
|
'what' => $sessionData['what'] ?? 'withdrawal',
|
||||||
@@ -83,7 +84,7 @@ class SplitController extends Controller
|
|||||||
|
|
||||||
return view(
|
return view(
|
||||||
'split.journals.create',
|
'split.journals.create',
|
||||||
compact('journal', 'piggyBanks', 'subTitle', 'subTitleIcon', 'preFilled', 'assetAccounts', 'currencies', 'budgets', 'uploadSize')
|
compact('journal', 'piggyBanks', 'subTitle', 'optionalFields', 'subTitleIcon', 'preFilled', 'assetAccounts', 'currencies', 'budgets', 'uploadSize')
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -101,6 +102,7 @@ class SplitController extends Controller
|
|||||||
$uploadSize = min(Steam::phpBytes(ini_get('upload_max_filesize')), Steam::phpBytes(ini_get('post_max_size')));
|
$uploadSize = min(Steam::phpBytes(ini_get('upload_max_filesize')), Steam::phpBytes(ini_get('post_max_size')));
|
||||||
$currencies = ExpandedForm::makeSelectList($currencyRepository->get());
|
$currencies = ExpandedForm::makeSelectList($currencyRepository->get());
|
||||||
$assetAccounts = ExpandedForm::makeSelectList($crud->getAccountsByType(['Default account', 'Asset account']));
|
$assetAccounts = ExpandedForm::makeSelectList($crud->getAccountsByType(['Default account', 'Asset account']));
|
||||||
|
$optionalFields = Preferences::get('transaction_journal_optional_fields', [])->data;
|
||||||
$budgets = ExpandedForm::makeSelectListWithEmpty($budgetRepository->getActiveBudgets());
|
$budgets = ExpandedForm::makeSelectListWithEmpty($budgetRepository->getActiveBudgets());
|
||||||
$preFilled = $this->arrayFromJournal($request, $journal);
|
$preFilled = $this->arrayFromJournal($request, $journal);
|
||||||
$subTitle = trans('breadcrumbs.edit_journal', ['description' => $journal->description]);
|
$subTitle = trans('breadcrumbs.edit_journal', ['description' => $journal->description]);
|
||||||
@@ -118,7 +120,8 @@ class SplitController extends Controller
|
|||||||
return view(
|
return view(
|
||||||
'split.journals.edit',
|
'split.journals.edit',
|
||||||
compact(
|
compact(
|
||||||
'subTitleIcon', 'currencies', 'preFilled', 'subTitle', 'amount', 'sourceAccounts', 'uploadSize', 'destinationAccounts', 'assetAccounts',
|
'subTitleIcon', 'currencies', 'optionalFields',
|
||||||
|
'preFilled', 'subTitle', 'amount', 'sourceAccounts', 'uploadSize', 'destinationAccounts', 'assetAccounts',
|
||||||
'budgets', 'journal'
|
'budgets', 'journal'
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
@@ -160,7 +163,7 @@ class SplitController extends Controller
|
|||||||
* @param JournalInterface $repository
|
* @param JournalInterface $repository
|
||||||
* @param AttachmentHelperInterface $att
|
* @param AttachmentHelperInterface $att
|
||||||
*
|
*
|
||||||
* @return $this|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
|
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
|
||||||
*/
|
*/
|
||||||
public function update(TransactionJournal $journal, SplitJournalFormRequest $request, JournalInterface $repository, AttachmentHelperInterface $att)
|
public function update(TransactionJournal $journal, SplitJournalFormRequest $request, JournalInterface $repository, AttachmentHelperInterface $att)
|
||||||
{
|
{
|
||||||
|
@@ -44,12 +44,18 @@ class TransactionController extends Controller
|
|||||||
parent::__construct();
|
parent::__construct();
|
||||||
View::share('title', trans('firefly.transactions'));
|
View::share('title', trans('firefly.transactions'));
|
||||||
View::share('mainTitleIcon', 'fa-repeat');
|
View::share('mainTitleIcon', 'fa-repeat');
|
||||||
|
|
||||||
|
$maxFileSize = Steam::phpBytes(ini_get('upload_max_filesize'));
|
||||||
|
$maxPostSize = Steam::phpBytes(ini_get('post_max_size'));
|
||||||
|
$uploadSize = min($maxFileSize, $maxPostSize);
|
||||||
|
|
||||||
|
View::share('uploadSize', $uploadSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $what
|
* @param string $what
|
||||||
*
|
*
|
||||||
* @return \Illuminate\View\View
|
* @return View
|
||||||
*/
|
*/
|
||||||
public function create(string $what = TransactionType::DEPOSIT)
|
public function create(string $what = TransactionType::DEPOSIT)
|
||||||
{
|
{
|
||||||
@@ -65,6 +71,7 @@ class TransactionController extends Controller
|
|||||||
$preFilled = Session::has('preFilled') ? session('preFilled') : [];
|
$preFilled = Session::has('preFilled') ? session('preFilled') : [];
|
||||||
$subTitle = trans('form.add_new_' . $what);
|
$subTitle = trans('form.add_new_' . $what);
|
||||||
$subTitleIcon = 'fa-plus';
|
$subTitleIcon = 'fa-plus';
|
||||||
|
$optionalFields = Preferences::get('transaction_journal_optional_fields', [])->data;
|
||||||
|
|
||||||
Session::put('preFilled', $preFilled);
|
Session::put('preFilled', $preFilled);
|
||||||
|
|
||||||
@@ -80,7 +87,7 @@ class TransactionController extends Controller
|
|||||||
asort($piggies);
|
asort($piggies);
|
||||||
|
|
||||||
|
|
||||||
return view('transactions.create', compact('assetAccounts', 'subTitleIcon', 'uploadSize', 'budgets', 'what', 'piggies', 'subTitle'));
|
return view('transactions.create', compact('assetAccounts', 'subTitleIcon', 'uploadSize', 'budgets', 'what', 'piggies', 'subTitle', 'optionalFields'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -88,7 +95,7 @@ class TransactionController extends Controller
|
|||||||
*
|
*
|
||||||
* @param TransactionJournal $journal
|
* @param TransactionJournal $journal
|
||||||
*
|
*
|
||||||
* @return \Illuminate\View\View
|
* @return View
|
||||||
*/
|
*/
|
||||||
public function delete(TransactionJournal $journal)
|
public function delete(TransactionJournal $journal)
|
||||||
{
|
{
|
||||||
@@ -135,19 +142,23 @@ class TransactionController extends Controller
|
|||||||
if ($count > 2) {
|
if ($count > 2) {
|
||||||
return redirect(route('split.journal.edit', [$journal->id]));
|
return redirect(route('split.journal.edit', [$journal->id]));
|
||||||
}
|
}
|
||||||
$budgetRepository = app('FireflyIII\Repositories\Budget\BudgetRepositoryInterface');
|
|
||||||
$piggyRepository = app('FireflyIII\Repositories\PiggyBank\PiggyBankRepositoryInterface');
|
// code to get list data:
|
||||||
$crud = app('FireflyIII\Crud\Account\AccountCrudInterface');
|
$budgetRepository = app('FireflyIII\Repositories\Budget\BudgetRepositoryInterface');
|
||||||
$assetAccounts = ExpandedForm::makeSelectList($crud->getAccountsByType(['Default account', 'Asset account']));
|
$piggyRepository = app('FireflyIII\Repositories\PiggyBank\PiggyBankRepositoryInterface');
|
||||||
$budgetList = ExpandedForm::makeSelectListWithEmpty($budgetRepository->getActiveBudgets());
|
$crud = app('FireflyIII\Crud\Account\AccountCrudInterface');
|
||||||
$piggyBankList = ExpandedForm::makeSelectListWithEmpty($piggyRepository->getPiggyBanks());
|
$assetAccounts = ExpandedForm::makeSelectList($crud->getAccountsByType(['Default account', 'Asset account']));
|
||||||
$maxFileSize = Steam::phpBytes(ini_get('upload_max_filesize'));
|
$budgetList = ExpandedForm::makeSelectListWithEmpty($budgetRepository->getActiveBudgets());
|
||||||
$maxPostSize = Steam::phpBytes(ini_get('post_max_size'));
|
$piggyBankList = ExpandedForm::makeSelectListWithEmpty($piggyRepository->getPiggyBanks());
|
||||||
$uploadSize = min($maxFileSize, $maxPostSize);
|
|
||||||
$what = strtolower(TransactionJournal::transactionTypeStr($journal));
|
// view related code
|
||||||
$subTitle = trans('breadcrumbs.edit_journal', ['description' => $journal->description]);
|
$subTitle = trans('breadcrumbs.edit_journal', ['description' => $journal->description]);
|
||||||
|
$what = strtolower(TransactionJournal::transactionTypeStr($journal));
|
||||||
|
|
||||||
|
// journal related code
|
||||||
$sourceAccounts = TransactionJournal::sourceAccountList($journal);
|
$sourceAccounts = TransactionJournal::sourceAccountList($journal);
|
||||||
$destinationAccounts = TransactionJournal::destinationAccountList($journal);
|
$destinationAccounts = TransactionJournal::destinationAccountList($journal);
|
||||||
|
$optionalFields = Preferences::get('transaction_journal_optional_fields', [])->data;
|
||||||
$preFilled = [
|
$preFilled = [
|
||||||
'date' => TransactionJournal::dateAsString($journal),
|
'date' => TransactionJournal::dateAsString($journal),
|
||||||
'interest_date' => TransactionJournal::dateAsString($journal, 'interest_date'),
|
'interest_date' => TransactionJournal::dateAsString($journal, 'interest_date'),
|
||||||
@@ -162,6 +173,13 @@ class TransactionController extends Controller
|
|||||||
'destination_account_id' => $destinationAccounts->first()->id,
|
'destination_account_id' => $destinationAccounts->first()->id,
|
||||||
'destination_account_name' => $destinationAccounts->first()->name,
|
'destination_account_name' => $destinationAccounts->first()->name,
|
||||||
'amount' => TransactionJournal::amountPositive($journal),
|
'amount' => TransactionJournal::amountPositive($journal),
|
||||||
|
|
||||||
|
// new custom fields:
|
||||||
|
'due_date' => TransactionJournal::dateAsString($journal, 'due_date'),
|
||||||
|
'payment_date' => TransactionJournal::dateAsString($journal, 'payment_date'),
|
||||||
|
'invoice_date' => TransactionJournal::dateAsString($journal, 'invoice_date'),
|
||||||
|
'interal_reference' => $journal->getMeta('internal_reference'),
|
||||||
|
'notes' => $journal->getMeta('notes'),
|
||||||
];
|
];
|
||||||
|
|
||||||
if ($journal->isWithdrawal() && $destinationAccounts->first()->accountType->type == AccountType::CASH) {
|
if ($journal->isWithdrawal() && $destinationAccounts->first()->accountType->type == AccountType::CASH) {
|
||||||
@@ -183,9 +201,10 @@ class TransactionController extends Controller
|
|||||||
}
|
}
|
||||||
Session::forget('transactions.edit.fromUpdate');
|
Session::forget('transactions.edit.fromUpdate');
|
||||||
|
|
||||||
return view('transactions.edit', compact('journal', 'uploadSize', 'assetAccounts', 'what', 'budgetList', 'piggyBankList', 'subTitle'))->with(
|
return view(
|
||||||
'data', $preFilled
|
'transactions.edit',
|
||||||
);
|
compact('journal', 'optionalFields', 'assetAccounts', 'what', 'budgetList', 'piggyBankList', 'subTitle')
|
||||||
|
)->with('data', $preFilled);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -273,7 +292,7 @@ class TransactionController extends Controller
|
|||||||
|
|
||||||
// store the journal only, flash the rest.
|
// store the journal only, flash the rest.
|
||||||
if ($doSplit) {
|
if ($doSplit) {
|
||||||
$journal = $repository->storeJournal($journalData);
|
$journal = $repository->storeJournal($journalData);
|
||||||
$journal->completed = false;
|
$journal->completed = false;
|
||||||
$journal->save();
|
$journal->save();
|
||||||
|
|
||||||
@@ -336,7 +355,7 @@ class TransactionController extends Controller
|
|||||||
* @param AttachmentHelperInterface $att
|
* @param AttachmentHelperInterface $att
|
||||||
* @param TransactionJournal $journal
|
* @param TransactionJournal $journal
|
||||||
*
|
*
|
||||||
* @return $this|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
|
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
|
||||||
*/
|
*/
|
||||||
public function update(JournalFormRequest $request, JournalRepositoryInterface $repository, AttachmentHelperInterface $att, TransactionJournal $journal)
|
public function update(JournalFormRequest $request, JournalRepositoryInterface $repository, AttachmentHelperInterface $att, TransactionJournal $journal)
|
||||||
{
|
{
|
||||||
|
18
app/Http/Kernel.php
Normal file → Executable file
18
app/Http/Kernel.php
Normal file → Executable file
@@ -6,7 +6,6 @@
|
|||||||
* This software may be modified and distributed under the terms
|
* This software may be modified and distributed under the terms
|
||||||
* of the MIT license. See the LICENSE file for details.
|
* of the MIT license. See the LICENSE file for details.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
declare(strict_types = 1);
|
declare(strict_types = 1);
|
||||||
|
|
||||||
namespace FireflyIII\Http;
|
namespace FireflyIII\Http;
|
||||||
@@ -23,9 +22,11 @@ use FireflyIII\Http\Middleware\RedirectIfAuthenticated;
|
|||||||
use FireflyIII\Http\Middleware\RedirectIfTwoFactorAuthenticated;
|
use FireflyIII\Http\Middleware\RedirectIfTwoFactorAuthenticated;
|
||||||
use FireflyIII\Http\Middleware\VerifyCsrfToken;
|
use FireflyIII\Http\Middleware\VerifyCsrfToken;
|
||||||
use Illuminate\Auth\Middleware\AuthenticateWithBasicAuth;
|
use Illuminate\Auth\Middleware\AuthenticateWithBasicAuth;
|
||||||
|
use Illuminate\Auth\Middleware\Authorize;
|
||||||
use Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse;
|
use Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse;
|
||||||
use Illuminate\Foundation\Http\Kernel as HttpKernel;
|
use Illuminate\Foundation\Http\Kernel as HttpKernel;
|
||||||
use Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode;
|
use Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode;
|
||||||
|
use Illuminate\Routing\Middleware\SubstituteBindings;
|
||||||
use Illuminate\Routing\Middleware\ThrottleRequests;
|
use Illuminate\Routing\Middleware\ThrottleRequests;
|
||||||
use Illuminate\Session\Middleware\StartSession;
|
use Illuminate\Session\Middleware\StartSession;
|
||||||
use Illuminate\View\Middleware\ShareErrorsFromSession;
|
use Illuminate\View\Middleware\ShareErrorsFromSession;
|
||||||
@@ -37,10 +38,11 @@ use Illuminate\View\Middleware\ShareErrorsFromSession;
|
|||||||
*/
|
*/
|
||||||
class Kernel extends HttpKernel
|
class Kernel extends HttpKernel
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The bootstrap classes for the application.
|
* The bootstrap classes for the application.
|
||||||
*
|
*
|
||||||
* Next upgrade should verify these are all here.
|
* Next upgrade verify these are the same.
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
@@ -83,6 +85,7 @@ class Kernel extends HttpKernel
|
|||||||
StartSession::class,
|
StartSession::class,
|
||||||
ShareErrorsFromSession::class,
|
ShareErrorsFromSession::class,
|
||||||
VerifyCsrfToken::class,
|
VerifyCsrfToken::class,
|
||||||
|
SubstituteBindings::class,
|
||||||
],
|
],
|
||||||
// MUST NOT be logged in. Does not care about 2FA or confirmation.
|
// MUST NOT be logged in. Does not care about 2FA or confirmation.
|
||||||
'user-not-logged-in' => [
|
'user-not-logged-in' => [
|
||||||
@@ -91,9 +94,9 @@ class Kernel extends HttpKernel
|
|||||||
StartSession::class,
|
StartSession::class,
|
||||||
ShareErrorsFromSession::class,
|
ShareErrorsFromSession::class,
|
||||||
VerifyCsrfToken::class,
|
VerifyCsrfToken::class,
|
||||||
|
SubstituteBindings::class,
|
||||||
RedirectIfAuthenticated::class,
|
RedirectIfAuthenticated::class,
|
||||||
],
|
],
|
||||||
|
|
||||||
// MUST be logged in.
|
// MUST be logged in.
|
||||||
// MUST NOT have 2FA
|
// MUST NOT have 2FA
|
||||||
// don't care about confirmation:
|
// don't care about confirmation:
|
||||||
@@ -103,6 +106,7 @@ class Kernel extends HttpKernel
|
|||||||
StartSession::class,
|
StartSession::class,
|
||||||
ShareErrorsFromSession::class,
|
ShareErrorsFromSession::class,
|
||||||
VerifyCsrfToken::class,
|
VerifyCsrfToken::class,
|
||||||
|
SubstituteBindings::class,
|
||||||
Authenticate::class,
|
Authenticate::class,
|
||||||
RedirectIfTwoFactorAuthenticated::class,
|
RedirectIfTwoFactorAuthenticated::class,
|
||||||
],
|
],
|
||||||
@@ -115,6 +119,7 @@ class Kernel extends HttpKernel
|
|||||||
StartSession::class,
|
StartSession::class,
|
||||||
ShareErrorsFromSession::class,
|
ShareErrorsFromSession::class,
|
||||||
VerifyCsrfToken::class,
|
VerifyCsrfToken::class,
|
||||||
|
SubstituteBindings::class,
|
||||||
Authenticate::class,
|
Authenticate::class,
|
||||||
AuthenticateTwoFactor::class,
|
AuthenticateTwoFactor::class,
|
||||||
IsNotConfirmed::class,
|
IsNotConfirmed::class,
|
||||||
@@ -129,6 +134,7 @@ class Kernel extends HttpKernel
|
|||||||
StartSession::class,
|
StartSession::class,
|
||||||
ShareErrorsFromSession::class,
|
ShareErrorsFromSession::class,
|
||||||
VerifyCsrfToken::class,
|
VerifyCsrfToken::class,
|
||||||
|
SubstituteBindings::class,
|
||||||
Authenticate::class,
|
Authenticate::class,
|
||||||
],
|
],
|
||||||
|
|
||||||
@@ -142,6 +148,7 @@ class Kernel extends HttpKernel
|
|||||||
StartSession::class,
|
StartSession::class,
|
||||||
ShareErrorsFromSession::class,
|
ShareErrorsFromSession::class,
|
||||||
VerifyCsrfToken::class,
|
VerifyCsrfToken::class,
|
||||||
|
SubstituteBindings::class,
|
||||||
Authenticate::class,
|
Authenticate::class,
|
||||||
AuthenticateTwoFactor::class,
|
AuthenticateTwoFactor::class,
|
||||||
IsConfirmed::class,
|
IsConfirmed::class,
|
||||||
@@ -159,6 +166,7 @@ class Kernel extends HttpKernel
|
|||||||
StartSession::class,
|
StartSession::class,
|
||||||
ShareErrorsFromSession::class,
|
ShareErrorsFromSession::class,
|
||||||
VerifyCsrfToken::class,
|
VerifyCsrfToken::class,
|
||||||
|
SubstituteBindings::class,
|
||||||
Authenticate::class,
|
Authenticate::class,
|
||||||
AuthenticateTwoFactor::class,
|
AuthenticateTwoFactor::class,
|
||||||
IsConfirmed::class,
|
IsConfirmed::class,
|
||||||
@@ -168,8 +176,10 @@ class Kernel extends HttpKernel
|
|||||||
|
|
||||||
],
|
],
|
||||||
|
|
||||||
|
|
||||||
'api' => [
|
'api' => [
|
||||||
'throttle:60,1',
|
'throttle:60,1',
|
||||||
|
'bindings',
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
|
|
||||||
@@ -184,6 +194,8 @@ class Kernel extends HttpKernel
|
|||||||
= [
|
= [
|
||||||
'auth' => Authenticate::class,
|
'auth' => Authenticate::class,
|
||||||
'auth.basic' => AuthenticateWithBasicAuth::class,
|
'auth.basic' => AuthenticateWithBasicAuth::class,
|
||||||
|
'bindings' => SubstituteBindings::class,
|
||||||
|
'can' => Authorize::class,
|
||||||
'guest' => RedirectIfAuthenticated::class,
|
'guest' => RedirectIfAuthenticated::class,
|
||||||
'throttle' => ThrottleRequests::class,
|
'throttle' => ThrottleRequests::class,
|
||||||
'range' => Range::class,
|
'range' => Range::class,
|
||||||
|
@@ -41,7 +41,7 @@ class Authenticate
|
|||||||
|
|
||||||
return redirect()->guest('login');
|
return redirect()->guest('login');
|
||||||
}
|
}
|
||||||
if (intval(Auth::user()->blocked) === 1) {
|
if (intval(auth()->user()->blocked) === 1) {
|
||||||
Auth::guard($guard)->logout();
|
Auth::guard($guard)->logout();
|
||||||
Session::flash('logoutMessage', trans('firefly.block_account_logout'));
|
Session::flash('logoutMessage', trans('firefly.block_account_logout'));
|
||||||
|
|
||||||
|
@@ -45,7 +45,7 @@ class AuthenticateTwoFactor
|
|||||||
return redirect()->guest('login');
|
return redirect()->guest('login');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (intval(Auth::user()->blocked) === 1) {
|
if (intval(auth()->user()->blocked) === 1) {
|
||||||
Auth::guard($guard)->logout();
|
Auth::guard($guard)->logout();
|
||||||
Session::flash('logoutMessage', trans('firefly.block_account_logout'));
|
Session::flash('logoutMessage', trans('firefly.block_account_logout'));
|
||||||
|
|
||||||
|
1
app/Http/Middleware/EncryptCookies.php
Normal file → Executable file
1
app/Http/Middleware/EncryptCookies.php
Normal file → Executable file
@@ -6,7 +6,6 @@
|
|||||||
* This software may be modified and distributed under the terms
|
* This software may be modified and distributed under the terms
|
||||||
* of the MIT license. See the LICENSE file for details.
|
* of the MIT license. See the LICENSE file for details.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
declare(strict_types = 1);
|
declare(strict_types = 1);
|
||||||
|
|
||||||
namespace FireflyIII\Http\Middleware;
|
namespace FireflyIII\Http\Middleware;
|
||||||
|
@@ -43,7 +43,7 @@ class IsAdmin
|
|||||||
return redirect()->guest('login');
|
return redirect()->guest('login');
|
||||||
}
|
}
|
||||||
/** @var User $user */
|
/** @var User $user */
|
||||||
$user = Auth::user();
|
$user = auth()->user();
|
||||||
if (!$user->hasRole('owner')) {
|
if (!$user->hasRole('owner')) {
|
||||||
return redirect(route('home'));
|
return redirect(route('home'));
|
||||||
}
|
}
|
||||||
|
@@ -11,6 +11,7 @@ declare(strict_types = 1);
|
|||||||
|
|
||||||
namespace FireflyIII\Http\Middleware;
|
namespace FireflyIII\Http\Middleware;
|
||||||
|
|
||||||
|
use App;
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use Closure;
|
use Closure;
|
||||||
use FireflyIII\Exceptions\FireflyException;
|
use FireflyIII\Exceptions\FireflyException;
|
||||||
@@ -19,6 +20,7 @@ use Illuminate\Contracts\Auth\Guard;
|
|||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Support\Facades\Auth;
|
use Illuminate\Support\Facades\Auth;
|
||||||
use Navigation;
|
use Navigation;
|
||||||
|
use NumberFormatter;
|
||||||
use Preferences;
|
use Preferences;
|
||||||
use Session;
|
use Session;
|
||||||
use View;
|
use View;
|
||||||
@@ -62,36 +64,56 @@ class Range
|
|||||||
public function handle(Request $request, Closure $theNext, $guard = null)
|
public function handle(Request $request, Closure $theNext, $guard = null)
|
||||||
{
|
{
|
||||||
if (!Auth::guard($guard)->guest()) {
|
if (!Auth::guard($guard)->guest()) {
|
||||||
// ignore preference. set the range to be the current month:
|
|
||||||
if (!Session::has('start') && !Session::has('end')) {
|
|
||||||
|
|
||||||
$viewRange = Preferences::get('viewRange', '1M')->data;
|
// set start, end and finish:
|
||||||
$start = new Carbon;
|
$this->setRange();
|
||||||
$start = Navigation::updateStartDate($viewRange, $start);
|
|
||||||
$end = Navigation::updateEndDate($viewRange, $start);
|
|
||||||
|
|
||||||
Session::put('start', $start);
|
// get variables for date range:
|
||||||
Session::put('end', $end);
|
$this->datePicker();
|
||||||
}
|
|
||||||
if (!Session::has('first')) {
|
|
||||||
/** @var JournalRepositoryInterface $repository */
|
|
||||||
$repository = app(JournalRepositoryInterface::class);
|
|
||||||
$journal = $repository->first();
|
|
||||||
$first = Carbon::now()->startOfYear();
|
|
||||||
|
|
||||||
if (!is_null($journal->id)) {
|
|
||||||
$first = $journal->date;
|
|
||||||
}
|
|
||||||
Session::put('first', $first);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
// set view variables.
|
||||||
|
$this->configureView();
|
||||||
}
|
}
|
||||||
$this->datePicker();
|
|
||||||
|
|
||||||
return $theNext($request);
|
return $theNext($request);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function configureView()
|
||||||
|
{
|
||||||
|
$pref = Preferences::get('language', config('firefly.default_language', 'en_US'));
|
||||||
|
$lang = $pref->data;
|
||||||
|
|
||||||
|
App::setLocale($lang);
|
||||||
|
Carbon::setLocale(substr($lang, 0, 2));
|
||||||
|
$locale = explode(',', trans('config.locale'));
|
||||||
|
$locale = array_map('trim', $locale);
|
||||||
|
|
||||||
|
setlocale(LC_TIME, $locale);
|
||||||
|
setlocale(LC_MONETARY, $locale);
|
||||||
|
|
||||||
|
// save some formats:
|
||||||
|
$monthFormat = (string)trans('config.month');
|
||||||
|
$monthAndDayFormat = (string)trans('config.month_and_day');
|
||||||
|
$dateTimeFormat = (string)trans('config.date_time');
|
||||||
|
|
||||||
|
// change localeconv to a new array:
|
||||||
|
$numberFormatter = numfmt_create($lang, NumberFormatter::CURRENCY);
|
||||||
|
$localeconv = [
|
||||||
|
'mon_decimal_point' => $numberFormatter->getSymbol($numberFormatter->getAttribute(NumberFormatter::DECIMAL_SEPARATOR_SYMBOL)),
|
||||||
|
'mon_thousands_sep' => $numberFormatter->getSymbol($numberFormatter->getAttribute(NumberFormatter::MONETARY_GROUPING_SEPARATOR_SYMBOL)),
|
||||||
|
'frac_digits' => $numberFormatter->getAttribute(NumberFormatter::MAX_FRACTION_DIGITS),
|
||||||
|
];
|
||||||
|
View::share('monthFormat', $monthFormat);
|
||||||
|
View::share('monthAndDayFormat', $monthAndDayFormat);
|
||||||
|
View::share('dateTimeFormat', $dateTimeFormat);
|
||||||
|
View::share('language', $lang);
|
||||||
|
View::share('localeconv', $localeconv);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @throws FireflyException
|
||||||
|
*/
|
||||||
private function datePicker()
|
private function datePicker()
|
||||||
{
|
{
|
||||||
$viewRange = Preferences::get('viewRange', '1M')->data;
|
$viewRange = Preferences::get('viewRange', '1M')->data;
|
||||||
@@ -141,4 +163,33 @@ class Range
|
|||||||
View::share('dpRanges', $ranges);
|
View::share('dpRanges', $ranges);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private function setRange()
|
||||||
|
{
|
||||||
|
// ignore preference. set the range to be the current month:
|
||||||
|
if (!Session::has('start') && !Session::has('end')) {
|
||||||
|
|
||||||
|
$viewRange = Preferences::get('viewRange', '1M')->data;
|
||||||
|
$start = new Carbon;
|
||||||
|
$start = Navigation::updateStartDate($viewRange, $start);
|
||||||
|
$end = Navigation::updateEndDate($viewRange, $start);
|
||||||
|
|
||||||
|
Session::put('start', $start);
|
||||||
|
Session::put('end', $end);
|
||||||
|
}
|
||||||
|
if (!Session::has('first')) {
|
||||||
|
/** @var JournalRepositoryInterface $repository */
|
||||||
|
$repository = app(JournalRepositoryInterface::class);
|
||||||
|
$journal = $repository->first();
|
||||||
|
$first = Carbon::now()->startOfYear();
|
||||||
|
|
||||||
|
if (!is_null($journal->id)) {
|
||||||
|
$first = $journal->date;
|
||||||
|
}
|
||||||
|
Session::put('first', $first);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
2
app/Http/Middleware/RedirectIfAuthenticated.php
Normal file → Executable file
2
app/Http/Middleware/RedirectIfAuthenticated.php
Normal file → Executable file
@@ -6,7 +6,6 @@
|
|||||||
* This software may be modified and distributed under the terms
|
* This software may be modified and distributed under the terms
|
||||||
* of the MIT license. See the LICENSE file for details.
|
* of the MIT license. See the LICENSE file for details.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
declare(strict_types = 1);
|
declare(strict_types = 1);
|
||||||
|
|
||||||
namespace FireflyIII\Http\Middleware;
|
namespace FireflyIII\Http\Middleware;
|
||||||
@@ -33,7 +32,6 @@ class RedirectIfAuthenticated
|
|||||||
public function handle($request, Closure $next, $guard = null)
|
public function handle($request, Closure $next, $guard = null)
|
||||||
{
|
{
|
||||||
if (Auth::guard($guard)->check()) {
|
if (Auth::guard($guard)->check()) {
|
||||||
|
|
||||||
return redirect('/');
|
return redirect('/');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
2
app/Http/Middleware/VerifyCsrfToken.php
Normal file → Executable file
2
app/Http/Middleware/VerifyCsrfToken.php
Normal file → Executable file
@@ -6,8 +6,8 @@
|
|||||||
* This software may be modified and distributed under the terms
|
* This software may be modified and distributed under the terms
|
||||||
* of the MIT license. See the LICENSE file for details.
|
* of the MIT license. See the LICENSE file for details.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
declare(strict_types = 1);
|
declare(strict_types = 1);
|
||||||
|
|
||||||
namespace FireflyIII\Http\Middleware;
|
namespace FireflyIII\Http\Middleware;
|
||||||
|
|
||||||
use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken as BaseVerifier;
|
use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken as BaseVerifier;
|
||||||
|
@@ -11,7 +11,6 @@ declare(strict_types = 1);
|
|||||||
|
|
||||||
namespace FireflyIII\Http\Requests;
|
namespace FireflyIII\Http\Requests;
|
||||||
|
|
||||||
use Auth;
|
|
||||||
use FireflyIII\Models\Account;
|
use FireflyIII\Models\Account;
|
||||||
use Input;
|
use Input;
|
||||||
|
|
||||||
@@ -29,7 +28,7 @@ class AccountFormRequest extends Request
|
|||||||
public function authorize()
|
public function authorize()
|
||||||
{
|
{
|
||||||
// Only allow logged in users
|
// Only allow logged in users
|
||||||
return Auth::check();
|
return auth()->check();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -11,8 +11,6 @@ declare(strict_types = 1);
|
|||||||
|
|
||||||
namespace FireflyIII\Http\Requests;
|
namespace FireflyIII\Http\Requests;
|
||||||
|
|
||||||
use Auth;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class AttachmentFormRequest
|
* Class AttachmentFormRequest
|
||||||
*
|
*
|
||||||
@@ -27,7 +25,7 @@ class AttachmentFormRequest extends Request
|
|||||||
public function authorize()
|
public function authorize()
|
||||||
{
|
{
|
||||||
// Only allow logged in users
|
// Only allow logged in users
|
||||||
return Auth::check();
|
return auth()->check();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -11,7 +11,6 @@ declare(strict_types = 1);
|
|||||||
|
|
||||||
namespace FireflyIII\Http\Requests;
|
namespace FireflyIII\Http\Requests;
|
||||||
|
|
||||||
use Auth;
|
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use Input;
|
use Input;
|
||||||
|
|
||||||
@@ -29,7 +28,7 @@ class BillFormRequest extends Request
|
|||||||
public function authorize()
|
public function authorize()
|
||||||
{
|
{
|
||||||
// Only allow logged in users
|
// Only allow logged in users
|
||||||
return Auth::check();
|
return auth()->check();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -45,7 +44,7 @@ class BillFormRequest extends Request
|
|||||||
'amount_currency_id_amount_max' => intval($this->get('amount_currency_id_amount_max')),
|
'amount_currency_id_amount_max' => intval($this->get('amount_currency_id_amount_max')),
|
||||||
'amount_max' => round($this->get('amount_max'), 2),
|
'amount_max' => round($this->get('amount_max'), 2),
|
||||||
'date' => new Carbon($this->get('date')),
|
'date' => new Carbon($this->get('date')),
|
||||||
'user' => Auth::user()->id,
|
'user' => auth()->user()->id,
|
||||||
'repeat_freq' => $this->get('repeat_freq'),
|
'repeat_freq' => $this->get('repeat_freq'),
|
||||||
'skip' => intval($this->get('skip')),
|
'skip' => intval($this->get('skip')),
|
||||||
'automatch' => intval($this->get('automatch')) === 1,
|
'automatch' => intval($this->get('automatch')) === 1,
|
||||||
|
@@ -11,7 +11,6 @@ declare(strict_types = 1);
|
|||||||
|
|
||||||
namespace FireflyIII\Http\Requests;
|
namespace FireflyIII\Http\Requests;
|
||||||
|
|
||||||
use Auth;
|
|
||||||
use FireflyIII\Models\Budget;
|
use FireflyIII\Models\Budget;
|
||||||
use Input;
|
use Input;
|
||||||
|
|
||||||
@@ -29,7 +28,7 @@ class BudgetFormRequest extends Request
|
|||||||
public function authorize()
|
public function authorize()
|
||||||
{
|
{
|
||||||
// Only allow logged in users
|
// Only allow logged in users
|
||||||
return Auth::check();
|
return auth()->check();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -11,7 +11,6 @@ declare(strict_types = 1);
|
|||||||
|
|
||||||
namespace FireflyIII\Http\Requests;
|
namespace FireflyIII\Http\Requests;
|
||||||
|
|
||||||
use Auth;
|
|
||||||
use FireflyIII\Models\Category;
|
use FireflyIII\Models\Category;
|
||||||
use Input;
|
use Input;
|
||||||
|
|
||||||
@@ -29,7 +28,7 @@ class CategoryFormRequest extends Request
|
|||||||
public function authorize()
|
public function authorize()
|
||||||
{
|
{
|
||||||
// Only allow logged in users
|
// Only allow logged in users
|
||||||
return Auth::check();
|
return auth()->check();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
42
app/Http/Requests/ConfigurationRequest.php
Normal file
42
app/Http/Requests/ConfigurationRequest.php
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* ConfigurationRequest.php
|
||||||
|
* Copyright (C) 2016 thegrumpydictator@gmail.com
|
||||||
|
*
|
||||||
|
* This software may be modified and distributed under the terms
|
||||||
|
* of the MIT license. See the LICENSE file for details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
declare(strict_types = 1);
|
||||||
|
|
||||||
|
namespace FireflyIII\Http\Requests;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class ConfigurationRequest
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @package FireflyIII\Http\Requests
|
||||||
|
*/
|
||||||
|
class ConfigurationRequest extends Request
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function authorize()
|
||||||
|
{
|
||||||
|
// Only allow logged in users and admins
|
||||||
|
return auth()->check() && auth()->user()->hasRole('owner');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function rules()
|
||||||
|
{
|
||||||
|
$rules = [
|
||||||
|
'single_user_mode' => 'between:0,1|numeric',
|
||||||
|
];
|
||||||
|
|
||||||
|
return $rules;
|
||||||
|
}
|
||||||
|
}
|
@@ -11,7 +11,6 @@ declare(strict_types = 1);
|
|||||||
|
|
||||||
namespace FireflyIII\Http\Requests;
|
namespace FireflyIII\Http\Requests;
|
||||||
|
|
||||||
use Auth;
|
|
||||||
use Input;
|
use Input;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -28,7 +27,7 @@ class CurrencyFormRequest extends Request
|
|||||||
public function authorize()
|
public function authorize()
|
||||||
{
|
{
|
||||||
// Only allow logged in users
|
// Only allow logged in users
|
||||||
return Auth::check();
|
return auth()->check();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -11,8 +11,6 @@ declare(strict_types = 1);
|
|||||||
|
|
||||||
namespace FireflyIII\Http\Requests;
|
namespace FireflyIII\Http\Requests;
|
||||||
|
|
||||||
use Auth;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class DeleteAccountFormRequest
|
* Class DeleteAccountFormRequest
|
||||||
*
|
*
|
||||||
@@ -27,7 +25,7 @@ class DeleteAccountFormRequest extends Request
|
|||||||
public function authorize()
|
public function authorize()
|
||||||
{
|
{
|
||||||
// Only allow logged in users
|
// Only allow logged in users
|
||||||
return Auth::check();
|
return auth()->check();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -11,7 +11,6 @@ declare(strict_types = 1);
|
|||||||
|
|
||||||
namespace FireflyIII\Http\Requests;
|
namespace FireflyIII\Http\Requests;
|
||||||
|
|
||||||
use Auth;
|
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -28,7 +27,7 @@ class ExportFormRequest extends Request
|
|||||||
public function authorize()
|
public function authorize()
|
||||||
{
|
{
|
||||||
// Only allow logged in users
|
// Only allow logged in users
|
||||||
return Auth::check();
|
return auth()->check();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -11,8 +11,6 @@ declare(strict_types = 1);
|
|||||||
|
|
||||||
namespace FireflyIII\Http\Requests;
|
namespace FireflyIII\Http\Requests;
|
||||||
|
|
||||||
use Auth;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class ImportUploadRequest
|
* Class ImportUploadRequest
|
||||||
*
|
*
|
||||||
@@ -27,7 +25,7 @@ class ImportUploadRequest extends Request
|
|||||||
public function authorize()
|
public function authorize()
|
||||||
{
|
{
|
||||||
// Only allow logged in users
|
// Only allow logged in users
|
||||||
return Auth::check();
|
return auth()->check();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -11,7 +11,6 @@ declare(strict_types = 1);
|
|||||||
|
|
||||||
namespace FireflyIII\Http\Requests;
|
namespace FireflyIII\Http\Requests;
|
||||||
|
|
||||||
use Auth;
|
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use Exception;
|
use Exception;
|
||||||
use FireflyIII\Exceptions\FireflyException;
|
use FireflyIII\Exceptions\FireflyException;
|
||||||
@@ -32,7 +31,7 @@ class JournalFormRequest extends Request
|
|||||||
public function authorize()
|
public function authorize()
|
||||||
{
|
{
|
||||||
// Only allow logged in users
|
// Only allow logged in users
|
||||||
return Auth::check();
|
return auth()->check();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -40,26 +39,34 @@ class JournalFormRequest extends Request
|
|||||||
*/
|
*/
|
||||||
public function getJournalData()
|
public function getJournalData()
|
||||||
{
|
{
|
||||||
$tags = $this->get('tags') ?? '';
|
$tags = $this->getFieldOrEmptyString('tags');
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'what' => $this->get('what'),
|
'what' => $this->get('what'),
|
||||||
'description' => $this->get('description'),
|
'description' => $this->get('description'),
|
||||||
'source_account_id' => intval($this->get('source_account_id')),
|
'source_account_id' => intval($this->get('source_account_id')),
|
||||||
'source_account_name' => $this->get('source_account_name') ?? '',
|
'source_account_name' => $this->getFieldOrEmptyString('source_account_name'),
|
||||||
'destination_account_id' => intval($this->get('destination_account_id')),
|
'destination_account_id' => intval($this->get('destination_account_id')),
|
||||||
'destination_account_name' => $this->get('destination_account_name') ?? '',
|
'destination_account_name' => $this->getFieldOrEmptyString('destination_account_name'),
|
||||||
'amount' => round($this->get('amount'), 2),
|
'amount' => round($this->get('amount'), 2),
|
||||||
'user' => Auth::user()->id,
|
'user' => auth()->user()->id,
|
||||||
'amount_currency_id_amount' => intval($this->get('amount_currency_id_amount')),
|
'amount_currency_id_amount' => intval($this->get('amount_currency_id_amount')),
|
||||||
'date' => new Carbon($this->get('date')),
|
'date' => new Carbon($this->get('date')),
|
||||||
'interest_date' => $this->get('interest_date') ? new Carbon($this->get('interest_date')) : null,
|
'interest_date' => $this->getDateOrNull('interest_date'),
|
||||||
'book_date' => $this->get('book_date') ? new Carbon($this->get('book_date')) : null,
|
'book_date' => $this->getDateOrNull('book_date'),
|
||||||
'process_date' => $this->get('process_date') ? new Carbon($this->get('process_date')) : null,
|
'process_date' => $this->getDateOrNull('process_date'),
|
||||||
'budget_id' => intval($this->get('budget_id')),
|
'budget_id' => intval($this->get('budget_id')),
|
||||||
'category' => $this->get('category') ?? '',
|
'category' => $this->getFieldOrEmptyString('category'),
|
||||||
'tags' => explode(',', $tags),
|
'tags' => explode(',', $tags),
|
||||||
'piggy_bank_id' => $this->get('piggy_bank_id') ? intval($this->get('piggy_bank_id')) : 0,
|
'piggy_bank_id' => intval($this->get('piggy_bank_id')),
|
||||||
|
|
||||||
|
// new custom fields here:
|
||||||
|
'due_date' => $this->getDateOrNull('due_date'),
|
||||||
|
'payment_date' => $this->getDateOrNull('payment_date'),
|
||||||
|
'invoice_date' => $this->getDateOrNull('invoice_date'),
|
||||||
|
'internal_reference' => $this->get('internal_reference'),
|
||||||
|
'notes' => $this->get('notes'),
|
||||||
|
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -81,6 +88,12 @@ class JournalFormRequest extends Request
|
|||||||
'category' => 'between:1,255',
|
'category' => 'between:1,255',
|
||||||
'amount_currency_id_amount' => 'required|exists:transaction_currencies,id',
|
'amount_currency_id_amount' => 'required|exists:transaction_currencies,id',
|
||||||
'piggy_bank_id' => 'numeric',
|
'piggy_bank_id' => 'numeric',
|
||||||
|
|
||||||
|
// new custom fields here:
|
||||||
|
'due_date' => 'date',
|
||||||
|
'payment_date' => 'date',
|
||||||
|
'internal_reference' => 'min:1,max:255',
|
||||||
|
'notes' => 'min:1,max:65536',
|
||||||
];
|
];
|
||||||
|
|
||||||
switch ($what) {
|
switch ($what) {
|
||||||
@@ -106,4 +119,24 @@ class JournalFormRequest extends Request
|
|||||||
|
|
||||||
return $rules;
|
return $rules;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $field
|
||||||
|
*
|
||||||
|
* @return Carbon|null
|
||||||
|
*/
|
||||||
|
private function getDateOrNull(string $field)
|
||||||
|
{
|
||||||
|
return $this->get($field) ? new Carbon($this->get($field)) : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $field
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
private function getFieldOrEmptyString(string $field): string
|
||||||
|
{
|
||||||
|
return $this->get($field) ?? '';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -11,8 +11,6 @@ declare(strict_types = 1);
|
|||||||
|
|
||||||
namespace FireflyIII\Http\Requests;
|
namespace FireflyIII\Http\Requests;
|
||||||
|
|
||||||
use Auth;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class MassDeleteJournalRequest
|
* Class MassDeleteJournalRequest
|
||||||
*
|
*
|
||||||
@@ -27,7 +25,7 @@ class MassDeleteJournalRequest extends Request
|
|||||||
public function authorize()
|
public function authorize()
|
||||||
{
|
{
|
||||||
// Only allow logged in users
|
// Only allow logged in users
|
||||||
return Auth::check();
|
return auth()->check();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -11,8 +11,6 @@ declare(strict_types = 1);
|
|||||||
|
|
||||||
namespace FireflyIII\Http\Requests;
|
namespace FireflyIII\Http\Requests;
|
||||||
|
|
||||||
use Auth;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class MassEditJournalRequest
|
* Class MassEditJournalRequest
|
||||||
*
|
*
|
||||||
@@ -27,7 +25,7 @@ class MassEditJournalRequest extends Request
|
|||||||
public function authorize()
|
public function authorize()
|
||||||
{
|
{
|
||||||
// Only allow logged in users
|
// Only allow logged in users
|
||||||
return Auth::check();
|
return auth()->check();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -11,8 +11,6 @@ declare(strict_types = 1);
|
|||||||
|
|
||||||
namespace FireflyIII\Http\Requests;
|
namespace FireflyIII\Http\Requests;
|
||||||
|
|
||||||
use Auth;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class NewUserFormRequest
|
* Class NewUserFormRequest
|
||||||
*
|
*
|
||||||
@@ -27,7 +25,7 @@ class NewUserFormRequest extends Request
|
|||||||
public function authorize()
|
public function authorize()
|
||||||
{
|
{
|
||||||
// Only allow logged in users
|
// Only allow logged in users
|
||||||
return Auth::check();
|
return auth()->check();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -11,7 +11,6 @@ declare(strict_types = 1);
|
|||||||
|
|
||||||
namespace FireflyIII\Http\Requests;
|
namespace FireflyIII\Http\Requests;
|
||||||
|
|
||||||
use Auth;
|
|
||||||
use Input;
|
use Input;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -28,7 +27,7 @@ class PiggyBankFormRequest extends Request
|
|||||||
public function authorize()
|
public function authorize()
|
||||||
{
|
{
|
||||||
// Only allow logged in users
|
// Only allow logged in users
|
||||||
return Auth::check();
|
return auth()->check();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -11,8 +11,6 @@ declare(strict_types = 1);
|
|||||||
|
|
||||||
namespace FireflyIII\Http\Requests;
|
namespace FireflyIII\Http\Requests;
|
||||||
|
|
||||||
use Auth;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class ProfileFormRequest
|
* Class ProfileFormRequest
|
||||||
*
|
*
|
||||||
@@ -27,7 +25,7 @@ class ProfileFormRequest extends Request
|
|||||||
public function authorize()
|
public function authorize()
|
||||||
{
|
{
|
||||||
// Only allow logged in users
|
// Only allow logged in users
|
||||||
return Auth::check();
|
return auth()->check();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -11,7 +11,6 @@ declare(strict_types = 1);
|
|||||||
|
|
||||||
namespace FireflyIII\Http\Requests;
|
namespace FireflyIII\Http\Requests;
|
||||||
|
|
||||||
use Auth;
|
|
||||||
use FireflyIII\Models\RuleGroup;
|
use FireflyIII\Models\RuleGroup;
|
||||||
use Input;
|
use Input;
|
||||||
|
|
||||||
@@ -29,7 +28,7 @@ class RuleFormRequest extends Request
|
|||||||
public function authorize()
|
public function authorize()
|
||||||
{
|
{
|
||||||
// Only allow logged in users
|
// Only allow logged in users
|
||||||
return Auth::check();
|
return auth()->check();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -18,7 +18,6 @@ declare(strict_types = 1);
|
|||||||
|
|
||||||
namespace FireflyIII\Http\Requests;
|
namespace FireflyIII\Http\Requests;
|
||||||
|
|
||||||
use Auth;
|
|
||||||
use FireflyIII\Models\RuleGroup;
|
use FireflyIII\Models\RuleGroup;
|
||||||
use Input;
|
use Input;
|
||||||
|
|
||||||
@@ -36,7 +35,7 @@ class RuleGroupFormRequest extends Request
|
|||||||
public function authorize()
|
public function authorize()
|
||||||
{
|
{
|
||||||
// Only allow logged in users
|
// Only allow logged in users
|
||||||
return Auth::check();
|
return auth()->check();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -11,7 +11,6 @@ declare(strict_types = 1);
|
|||||||
|
|
||||||
namespace FireflyIII\Http\Requests;
|
namespace FireflyIII\Http\Requests;
|
||||||
|
|
||||||
use Auth;
|
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -28,7 +27,7 @@ class SelectTransactionsRequest extends Request
|
|||||||
public function authorize()
|
public function authorize()
|
||||||
{
|
{
|
||||||
// Only allow logged in users
|
// Only allow logged in users
|
||||||
return Auth::check();
|
return auth()->check();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -11,7 +11,6 @@ declare(strict_types = 1);
|
|||||||
|
|
||||||
namespace FireflyIII\Http\Requests;
|
namespace FireflyIII\Http\Requests;
|
||||||
|
|
||||||
use Auth;
|
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
|
|
||||||
|
|
||||||
@@ -28,7 +27,7 @@ class SplitJournalFormRequest extends Request
|
|||||||
public function authorize(): bool
|
public function authorize(): bool
|
||||||
{
|
{
|
||||||
// Only allow logged in users
|
// Only allow logged in users
|
||||||
return Auth::check();
|
return auth()->check();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -10,7 +10,6 @@
|
|||||||
declare(strict_types = 1);
|
declare(strict_types = 1);
|
||||||
namespace FireflyIII\Http\Requests;
|
namespace FireflyIII\Http\Requests;
|
||||||
|
|
||||||
use Auth;
|
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use FireflyIII\Models\Tag;
|
use FireflyIII\Models\Tag;
|
||||||
use Input;
|
use Input;
|
||||||
@@ -29,7 +28,7 @@ class TagFormRequest extends Request
|
|||||||
public function authorize()
|
public function authorize()
|
||||||
{
|
{
|
||||||
// Only allow logged in users
|
// Only allow logged in users
|
||||||
return Auth::check();
|
return auth()->check();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -11,8 +11,6 @@ declare(strict_types = 1);
|
|||||||
|
|
||||||
namespace FireflyIII\Http\Requests;
|
namespace FireflyIII\Http\Requests;
|
||||||
|
|
||||||
use Auth;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class RuleFormRequest
|
* Class RuleFormRequest
|
||||||
*
|
*
|
||||||
@@ -27,7 +25,7 @@ class TestRuleFormRequest extends Request
|
|||||||
public function authorize()
|
public function authorize()
|
||||||
{
|
{
|
||||||
// Only allow logged in users
|
// Only allow logged in users
|
||||||
return Auth::check();
|
return auth()->check();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -11,8 +11,6 @@ declare(strict_types = 1);
|
|||||||
|
|
||||||
namespace FireflyIII\Http\Requests;
|
namespace FireflyIII\Http\Requests;
|
||||||
|
|
||||||
use Auth;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class TokenFormRequest
|
* Class TokenFormRequest
|
||||||
*
|
*
|
||||||
@@ -27,7 +25,7 @@ class TokenFormRequest extends Request
|
|||||||
public function authorize()
|
public function authorize()
|
||||||
{
|
{
|
||||||
// Only allow logged in users
|
// Only allow logged in users
|
||||||
return Auth::check();
|
return auth()->check();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -120,6 +120,14 @@ Breadcrumbs::register(
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
Breadcrumbs::register(
|
||||||
|
'admin.configuration.index', function (BreadCrumbGenerator $breadcrumbs) {
|
||||||
|
$breadcrumbs->parent('admin.index');
|
||||||
|
$breadcrumbs->push(trans('firefly.instance_configuration'), route('admin.configuration.index'));
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ATTACHMENTS
|
* ATTACHMENTS
|
||||||
*/
|
*/
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user