Compare commits

...

180 Commits

Author SHA1 Message Date
James Cole
3f6c19dec4 Merge branch 'release/3.8.4'
# Conflicts:
#	app/Helpers/Csv/PostProcessing/Bill.php
2016-04-24 18:48:16 +02:00
James Cole
93421b50f9 New translations. 2016-04-24 18:47:03 +02:00
James Cole
54e829173a Prep for next release. 2016-04-24 18:44:29 +02:00
James Cole
4fe38bd31b New release 2016-04-24 18:38:58 +02:00
James Cole
fb0638e824 Say what each thing is. 2016-04-24 18:36:44 +02:00
James Cole
108794a6b6 Improved verify command. 2016-04-24 18:35:45 +02:00
James Cole
9c16fc1380 Some small updates. 2016-04-24 18:25:52 +02:00
James Cole
99c219ed97 Three fixes courtesy of user @Bonno 2016-04-24 12:24:59 +02:00
James Cole
ec12238ea1 Some code cleanup. 2016-04-24 09:14:40 +02:00
James Cole
bdbd22f98b Some language and code updates. 2016-04-24 09:02:21 +02:00
James Cole
b8e1944d20 Mass edit #241 2016-04-24 07:18:39 +02:00
James Cole
8883d185fe Fix tests. 2016-04-23 20:00:48 +02:00
James Cole
19e40e9976 Expand transaction lists for mass delete / edit functionality. 2016-04-23 18:55:57 +02:00
James Cole
fa85b2b5b2 Some layout fixes. [skip ci] 2016-04-23 18:53:16 +02:00
James Cole
5cf0131d75 New translations. 2016-04-23 12:14:24 +02:00
James Cole
3948cb8e6c New mass delete form and options. #241 2016-04-23 09:33:54 +02:00
James Cole
f43938726a Simple mass edit JS complete. Fallback for when the list.js is not included. #241 2016-04-23 06:11:31 +02:00
James Cole
8c8bb7a930 Start of mass delete code. #241 2016-04-21 14:57:58 +02:00
James Cole
3972882a33 Fix #251 2016-04-21 11:03:04 +02:00
James Cole
0ef5eeeb55 Take page size into account. [skip ci] 2016-04-21 10:34:16 +02:00
James Cole
ef48a79d0c Take page size into account. [skip ci] 2016-04-21 10:23:19 +02:00
James Cole
2bb883219c Take page size into account. 2016-04-21 09:10:37 +02:00
James Cole
23c0bb49c4 Take page size into account. [skip ci] 2016-04-21 09:04:19 +02:00
James Cole
13e59105ec Set correct path. [skip ci] 2016-04-21 09:01:34 +02:00
James Cole
98c057c516 Take page size into account. 2016-04-21 09:00:32 +02:00
James Cole
e293d69798 Take page size into account. 2016-04-21 08:59:31 +02:00
James Cole
b097e29104 New preference for page size. 2016-04-21 08:59:15 +02:00
James Cole
29fbd46e33 Fixes for translations. [skip ci] 2016-04-20 17:13:25 +02:00
James Cole
6a15afc723 New translations [skip ci] 2016-04-20 17:10:35 +02:00
James Cole
c56a39a726 Update chart js. [skip ci] 2016-04-20 13:54:13 +02:00
James Cole
4b80e46d26 Fix old bug. 2016-04-18 19:55:48 +02:00
James Cole
a6f3e61520 Fix #248 2016-04-18 19:41:16 +02:00
James Cole
cce4ef19e5 Fix #244 2016-04-18 19:34:15 +02:00
James Cole
1951491c04 Merge branch 'develop' of https://github.com/JC5/firefly-iii into develop
* 'develop' of https://github.com/JC5/firefly-iii:
  Fix #243
2016-04-18 19:33:27 +02:00
James Cole
87b72e4bcd Fix #245 2016-04-18 19:33:02 +02:00
James Cole
2c6643d691 Fix #243 2016-04-18 14:15:10 +02:00
James Cole
d02df46517 Fix bug in bill name import routine 2016-04-17 20:40:26 +02:00
James Cole
0c0cc417ee Order chart thing again [skip ci] 2016-04-17 19:59:15 +02:00
James Cole
f0c03e8a3b Update chart order. 2016-04-17 19:58:09 +02:00
James Cole
345766f387 Merge branch 'release/3.8.3' 2016-04-17 12:13:00 +02:00
James Cole
3fa659632c Updated composer.lock [skip ci] 2016-04-17 12:12:35 +02:00
James Cole
95b92b7d1e Should fix test. 2016-04-17 11:43:07 +02:00
James Cole
466e988627 Correct date [skip ci] 2016-04-17 11:32:36 +02:00
James Cole
dc3c967c9f Update stuff in anticipation of new release. 2016-04-17 11:32:18 +02:00
James Cole
1fc31b4d8f Fixed a bug courtesy of Johan. 2016-04-17 11:28:44 +02:00
James Cole
e4a4b0a4eb Config update [skip ci] 2016-04-16 08:41:55 +02:00
James Cole
a9c026884d Fix null pointer. 2016-04-10 21:31:00 +02:00
James Cole
e893000ce9 Fix pie chart. 2016-04-10 20:28:32 +02:00
James Cole
32eeb3424d Code cleanup. 2016-04-10 17:51:51 +02:00
James Cole
ab523b6102 Make chart pretty 2016-04-10 17:03:36 +02:00
James Cole
b062222c45 Update chart options. 2016-04-10 11:28:55 +02:00
James Cole
2dddc843ce Fix chart heights. 2016-04-10 10:20:15 +02:00
James Cole
b74c1c8cf9 Upgrade chart library. 2016-04-10 10:05:50 +02:00
James Cole
d5d4bb2c4b Some javascript upgrades. 2016-04-10 08:23:31 +02:00
James Cole
89ac27ad10 Some code cleanup [skip ci] 2016-04-10 08:18:14 +02:00
James Cole
48b169c026 Fix comma thing [skip ci] 2016-04-09 21:07:43 +02:00
James Cole
0715b7406e Add language in cache as well. 2016-04-09 09:27:04 +02:00
James Cole
6e4991a34b Make help more reliable. 2016-04-09 09:24:17 +02:00
James Cole
8730af59bc Fix help text and debug. 2016-04-09 09:20:16 +02:00
James Cole
bdcc2c6c9f Prep for new report. 2016-04-09 09:16:51 +02:00
James Cole
6f0f6e86a1 Small bug fixes. 2016-04-09 09:10:11 +02:00
James Cole
3962d9da92 Text for error. 2016-04-09 06:02:30 +02:00
James Cole
5ed53d5f04 Some new code for CSV. 2016-04-08 20:36:11 +02:00
James Cole
ddb28b78c3 Some new translations and stuff. 2016-04-08 17:54:25 +02:00
James Cole
7699b6b4ea Update composer lock file. [skip ci] 2016-04-08 15:16:13 +02:00
James Cole
d783d05462 Some query optimisations for the audit report 2016-04-08 15:10:07 +02:00
James Cole
33bf373151 First attempt at audit report (uses lots of queries). 2016-04-08 14:50:18 +02:00
James Cole
8116644526 Some log fine tuning. 2016-04-08 14:44:53 +02:00
James Cole
dc4665e82a Add debug messages. 2016-04-08 11:59:44 +02:00
James Cole
732a85e51d Fix null call 2016-04-06 21:07:03 +02:00
James Cole
32190db8bb Fixed tests. 2016-04-06 21:05:43 +02:00
James Cole
25d3a115e0 Amounts better divided. 2016-04-06 20:59:09 +02:00
James Cole
30e3ed6410 Fix more tests. 2016-04-06 20:52:22 +02:00
James Cole
8b5a775dc5 Nonsense commit to test signing.
Signed-off-by: James Cole <thegrumpydictator@gmail.com>
2016-04-06 20:16:28 +02:00
James Cole
2942c3a4be Nonsense commit to test signing.
Signed-off-by: James Cole <thegrumpydictator@gmail.com>
2016-04-06 19:45:58 +02:00
James Cole
768d3bb3e8 Fix some tests. Won't fix all. 2016-04-06 19:44:42 +02:00
James Cole
250b2c2f53 PHP7 compatible function definitions. 2016-04-06 16:37:28 +02:00
James Cole
c8440af9a5 PHP7 compatible function definitions. 2016-04-06 09:27:45 +02:00
James Cole
37fe2d22b0 PHP7 compatible function definitions. 2016-04-05 22:00:03 +02:00
James Cole
b0b5d90976 Fixes the travis run. 2016-04-05 21:12:50 +02:00
James Cole
27b0c7f425 Moved a lot of files outside of the root. 2016-04-05 21:08:36 +02:00
James Cole
7c23571806 Missing translation. 2016-04-04 19:54:15 +02:00
James Cole
ea378c8d82 Fix search. [skip-ci] 2016-04-04 19:49:11 +02:00
James Cole
0fb45974ef Fix title. 2016-04-04 19:48:07 +02:00
James Cole
6490f9c128 Fix search. 2016-04-04 19:48:00 +02:00
James Cole
2d7f1af52c Add clear cache, for issue #237 2016-04-04 19:47:55 +02:00
James Cole
ac27659a59 Merge pull request #238 from nhaarman/fix_active-bill-expected-amount
Fixed incorrect average of expectedAmount in active bills.
2016-04-04 18:58:42 +02:00
Niek Haarman
11d59c8bd1 Fixed incorrect average of expectedAmount in active bills. 2016-04-04 18:15:38 +02:00
James Cole
a6936cbd02 Merge branch 'release/3.8.2' 2016-04-03 16:47:54 +02:00
James Cole
3be84d76ef Updated composer.lock and other files. [skip ci] 2016-04-03 16:47:27 +02:00
James Cole
9aed1f344f Code cleanup. 2016-04-03 15:47:00 +02:00
James Cole
4fff264630 New translations. 2016-04-03 15:45:41 +02:00
James Cole
2e444da2a3 Better titles. 2016-04-03 14:55:56 +02:00
James Cole
7a216f95ca Add sum. 2016-04-03 14:38:12 +02:00
James Cole
f22a9799a1 Hide some fields. 2016-04-03 14:01:27 +02:00
James Cole
90bdc40393 Fixed balance list. 2016-04-03 13:56:06 +02:00
James Cole
622a97c8d8 Category information. #159 2016-04-03 11:20:55 +02:00
James Cole
03691c81c2 More code for #159 [skip ci] 2016-04-03 11:14:36 +02:00
James Cole
885b56c465 More code for #159 2016-04-03 11:07:51 +02:00
James Cole
23cc7be231 More things [skip ci] 2016-04-03 10:51:37 +02:00
James Cole
bb82b0eb79 Better view for admin [skip ci] 2016-04-03 10:42:46 +02:00
James Cole
2e05f640b8 Title in guest view [skip ci] 2016-04-03 10:35:54 +02:00
James Cole
697a02ffee Page titles. 2016-04-03 10:34:42 +02:00
James Cole
ad402021ed Basic user admin. 2016-04-03 07:07:17 +02:00
James Cole
67caf6ef1f Code cleanup [skip ci] 2016-04-01 16:46:11 +02:00
James Cole
3277858c5a Code cleanup. [skip ci] 2016-04-01 16:44:46 +02:00
James Cole
3fbedf323f Fix list for no budget #159 2016-04-01 16:23:12 +02:00
James Cole
144a6130f2 First code for #159 popups 2016-04-01 16:06:55 +02:00
James Cole
fa38c975b6 New converters for #180 (Tag and accounts) 2016-04-01 14:17:12 +02:00
James Cole
c14fa1021c New converters for #180 (Currency) 2016-04-01 14:10:08 +02:00
James Cole
5e78cc02bd New converters for #180 (Category and some other stuff) 2016-04-01 13:23:12 +02:00
James Cole
429ef80fb9 New converters for #180 (Budget) 2016-04-01 13:17:07 +02:00
James Cole
e4d93cad27 New converters for #180 (Bill) 2016-04-01 13:07:19 +02:00
James Cole
d9a4840e37 New converters for #180 2016-04-01 13:03:38 +02:00
James Cole
a93070b98d Fixes #234. 2016-04-01 09:13:50 +02:00
James Cole
c05a942862 This fixes a null pointer exception. [skip ci] 2016-04-01 05:36:29 +02:00
James Cole
f9a7879c1e Damn git. 2016-03-30 17:51:40 +02:00
James Cole
bdfbc6d6a7 Merge branch 'develop' of https://github.com/JC5/firefly-iii into develop
* 'develop' of https://github.com/JC5/firefly-iii:
  New activation message
2016-03-30 17:48:59 +02:00
James Cole
21181d8d8e Fixes for #233 2016-03-30 17:47:13 +02:00
James Cole
1c7a27b816 New activation message 2016-03-30 12:46:51 +02:00
James Cole
e953f58c74 Merge branch 'release/3.8.1' into develop 2016-03-29 17:42:45 +02:00
James Cole
9250cee9e7 Merge branch 'release/3.8.1' 2016-03-29 17:42:44 +02:00
James Cole
bb075d15ff Add warning about PHP 7.0 2016-03-29 17:42:32 +02:00
James Cole
a31f16bba7 Change log for 3.8.1 [skip ci] 2016-03-29 17:41:43 +02:00
James Cole
88a41c37f3 Bug fix, thank you scrutiniser. 2016-03-29 17:18:42 +02:00
James Cole
d21885ca98 New translations. 2016-03-29 16:38:42 +02:00
James Cole
d774f8e870 Code cleanup. 2016-03-29 16:17:06 +02:00
James Cole
08b5e66628 Some code cleanup. 2016-03-29 16:16:14 +02:00
James Cole
6fdfec3967 Clean up some code. 2016-03-29 16:13:36 +02:00
James Cole
ab4616a3ad Make some vars longer. 2016-03-29 16:10:51 +02:00
James Cole
cb34ff4c83 Clean up some code. 2016-03-29 16:02:54 +02:00
James Cole
bdbead256c Make field a number. 2016-03-29 16:02:09 +02:00
James Cole
f200086d01 Code for #207 2016-03-29 15:55:14 +02:00
James Cole
ef97c3b42d Some new help text for bills. #207 2016-03-29 15:33:09 +02:00
James Cole
ed8b41e8ec Add source account to scan, see issue #226 2016-03-29 15:24:40 +02:00
James Cole
aada3371b7 Better translations for dates and so on. 2016-03-29 15:09:37 +02:00
James Cole
38a9782bdf Debug. 2016-03-29 13:55:57 +02:00
James Cole
c6ac81dcf6 Some more confirmation things. 2016-03-29 13:52:51 +02:00
James Cole
2d3f3f0fde Updated the routes. 2016-03-29 13:45:18 +02:00
James Cole
993a2c7823 New middleware. 2016-03-29 12:23:10 +02:00
James Cole
87b36cf7e3 Update 2FA and account activation 2016-03-29 12:14:01 +02:00
James Cole
742f2c8d9f New middle ware for user activation. 2016-03-29 11:55:49 +02:00
James Cole
0d7ac5f1d8 Move some routes around. 2016-03-29 11:55:38 +02:00
James Cole
3adccff611 New events and their handlers for user activation and other things. 2016-03-29 11:55:25 +02:00
James Cole
08b8bd27f9 Expand Preferences to handle not logged in users. 2016-03-29 11:55:02 +02:00
James Cole
1059c7e2be Updated config for user activation. 2016-03-29 11:54:50 +02:00
James Cole
3ebcd5f738 New translations for user activation. 2016-03-29 11:54:36 +02:00
James Cole
4627ea1dec Updated views for user activation. 2016-03-29 11:54:26 +02:00
James Cole
7ed24e78d5 New emails for the activation. 2016-03-29 11:48:29 +02:00
James Cole
ae02e3fd8d New example configuration that includes user account activation (disabled by default). 2016-03-29 11:46:21 +02:00
James Cole
cc88d5962e Move code to event handlers instead of registration routine. 2016-03-28 19:50:24 +02:00
James Cole
70c8a524cd Should fix the tests 2016-03-22 17:22:48 +01:00
James Cole
9a8efc8a58 Info in tags for #159 2016-03-22 16:59:29 +01:00
James Cole
f0f67b87c4 Code for #159 2016-03-22 16:57:26 +01:00
James Cole
1a3ec98896 Give all icons some context, no value yet. 2016-03-22 16:55:04 +01:00
James Cole
efff44cba9 Merge branch 'develop' of https://github.com/JC5/firefly-iii into develop
* 'develop' of https://github.com/JC5/firefly-iii:
  Fix link to non-existing budget
2016-03-22 16:54:31 +01:00
James Cole
7227418c4c More fine-grained cookie control. 2016-03-22 15:04:51 +01:00
James Cole
29f93a9b73 Fix link to non-existing budget 2016-03-22 09:04:32 +01:00
James Cole
532aa2acd0 Fix amount [skip ci] 2016-03-21 19:29:24 +01:00
James Cole
6aca410f37 Fix amount [skip ci] 2016-03-21 19:28:22 +01:00
James Cole
f20656b516 Merge branch 'develop' of https://github.com/JC5/firefly-iii into develop
* 'develop' of https://github.com/JC5/firefly-iii:
  Fix for #227
2016-03-21 19:27:13 +01:00
James Cole
bcd7866e10 For debug, add float. [skip ci] 2016-03-21 19:24:15 +01:00
James Cole
c1b8d44209 Small various fixes. 2016-03-21 19:22:37 +01:00
James Cole
50e947fbbe Fix for #227 2016-03-21 08:48:36 +01:00
James Cole
189d969ee6 Include "no budget" thing for issue #152 2016-03-20 20:06:05 +01:00
James Cole
201790ff8d Cleanup transaction journal edit. #215 2016-03-20 17:12:34 +01:00
James Cole
cc26ce4143 Some scrutiniser related code cleanup. 2016-03-20 16:49:49 +01:00
James Cole
745e0aa525 Move to object held user object. 2016-03-20 16:47:53 +01:00
James Cole
6602b1587a Some scrutiniser related code cleanup. 2016-03-20 16:46:26 +01:00
James Cole
6698b57f52 Fixed a bug that would leave all amounts at zero. #224 2016-03-20 16:41:48 +01:00
James Cole
628268d47c Code to fix #223 2016-03-20 11:47:10 +01:00
James Cole
56a635212a Code for #155 2016-03-20 11:46:27 +01:00
James Cole
7e67eb17e0 All new translations for #218 2016-03-20 11:38:01 +01:00
James Cole
935d72d672 New English text for issue #218 2016-03-20 11:36:50 +01:00
James Cole
fccb510186 Merge pull request #222 from eddyh/patch-1
Fixed small typo.
2016-03-20 11:34:58 +01:00
Edwin
e7ea0dc842 Fixed small typo. 2016-03-19 18:45:12 +01:00
James Cole
a40d6b0649 Merge branch 'master' into develop
* master:
  Code cleanup [skip ci]
  Quick bug fix.
2016-03-19 17:40:24 +01:00
James Cole
b7429a358f Code cleanup [skip ci] 2016-03-19 17:34:37 +01:00
James Cole
cf8b4e2f76 Quick bug fix. 2016-03-19 17:34:02 +01:00
James Cole
48c865e57a Merge branch 'hotfix/account-repos' into develop 2016-03-19 17:28:16 +01:00
516 changed files with 9178 additions and 3536 deletions

View File

@@ -1,7 +1,7 @@
APP_ENV=production
APP_DEBUG=false
APP_KEY=SomeRandomStringOf32CharsExactly
LOG_LEVEL=warning
DB_CONNECTION=mysql
DB_HOST=localhost
@@ -13,6 +13,10 @@ CACHE_DRIVER=file
SESSION_DRIVER=file
QUEUE_DRIVER=sync
COOKIE_PATH="/"
COOKIE_DOMAIN=
COOKIE_SECURE=false
DEFAULT_CURRENCY=EUR
DEFAULT_LANGUAGE=en_US
@@ -28,6 +32,9 @@ MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null
SEND_REGISTRATION_MAIL=true
MUST_CONFIRM_ACCOUNT=false
SHOW_INCOMPLETE_TRANSLATIONS=false
ANALYTICS_ID=

View File

@@ -1,7 +1,7 @@
APP_ENV=testing
APP_DEBUG=true
APP_KEY=SomeRandomStringOf32CharsExactly
LOG_LEVEL=debug
DB_CONNECTION=sqlite
DB_HOST=localhost

View File

@@ -4,6 +4,7 @@ php:
- 7
install:
- cp _development/phpunit.xml ./phpunit.xml
- phpenv config-rm xdebug.ini
- composer selfupdate
- rm composer.lock

View File

@@ -5,6 +5,64 @@ This project adheres to [Semantic Versioning](http://semver.org/).
## [Unreleased]
- No unreleased changes yet.
## [3.8.4] - 2016-04-24
### Added
- Lots of new translations.
- Can now set page size.
- Can now mass edit transactions.
- Can now mass delete transactions.
- Firefly will now attempt to verify the integrity of your database when updating.
### Changed
- New version of Charts library.
### Fixed
- Several CSV related bugs.
- Several other bugs.
- Bugs fixed by @Bonno.
## [3.8.3] - 2016-04-17
### Added
- New audit report to see what happened.
### Changed
- New Chart JS release used.
- Help function is more reliable.
### Fixed
- Expected bill amount is now correct.
- Upgrade will now invalidate cache.
- Search was broken.
- Queries run better
## [3.8.2] - 2016-04-03
### Added
- Small user administration at /admin.
- Informational popups are working in reports.
### Changed
- User activation emails are better
### Fixed
- Some bugs related to accounts and rules.
## [3.8.1] - 2016-03-29
### Added
- More translations
- Extended cookie control.
- User accounts can now be activated (disabled by default).
- Bills can now take the source and destination account name into account.
### Changed
- The pages related to rules have new URL's.
### Fixed
- Spelling errors.
- Problems related to the "account repository".
- Some views showed empty (0.0) amounts.
## [3.8.0] - 2016-03-20
### Added
- Two factor authentication, thanks to the excellent work of [zjean](https://github.com/zjean).

View File

@@ -1,4 +1,4 @@
Copyright (C) 2016 Sander Dorigo
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:

View File

@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ phpunit.cover.xml
~ Copyright (C) 2016 Sander Dorigo
~ 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.

View File

@@ -0,0 +1,43 @@
<?php
/**
* ConfigureLogging.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.
*/
namespace FireflyIII\Bootstrap;
use Illuminate\Log\Writer;
use Illuminate\Contracts\Foundation\Application;
use Illuminate\Foundation\Bootstrap\ConfigureLogging as IlluminateConfigureLogging;
/**
* Class ConfigureLogging
*
* @package FireflyIII\Bootstrap
*/
class ConfigureLogging extends IlluminateConfigureLogging
{
/**
* @param Application $app
* @param Writer $log
*/
protected function configureSingleHandler(Application $app, Writer $log)
{
$log->useFiles($app->storagePath().'/logs/firefly-iii.log');
}
/**
* @param Application $app
* @param Writer $log
*/
protected function configureDailyHandler(Application $app, Writer $log)
{
$log->useDailyFiles(
$app->storagePath().'/logs/firefly-iii.log',
$app->make('config')->get('app.log_max_files', 5)
);
}
}

View File

@@ -0,0 +1,272 @@
<?php
namespace FireflyIII\Console\Commands;
use Crypt;
use DB;
use FireflyIII\Models\Account;
use FireflyIII\Models\Budget;
use FireflyIII\Models\Category;
use FireflyIII\Models\Tag;
use FireflyIII\Models\Transaction;
use FireflyIII\Models\TransactionJournal;
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
use FireflyIII\Repositories\User\UserRepositoryInterface;
use FireflyIII\User;
use Illuminate\Console\Command;
use Illuminate\Database\Eloquent\Builder;
use stdClass;
/**
* Class VerifyDatabase
*
* @package FireflyIII\Console\Commands
*/
class VerifyDatabase extends Command
{
/**
* The console command description.
*
* @var string
*/
protected $description = 'Will verify your database.';
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'firefly:verify';
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
// accounts with no transactions.
$this->reportAccounts();
// budgets with no limits
$this->reportBudgetLimits();
// budgets with no transactions
$this->reportBudgets();
// categories with no transactions
$this->reportCategories();
// tags with no transactions
$this->reportTags();
// sum of transactions is not zero.
$this->reportSum();
// any deleted transaction journals that have transactions that are NOT deleted:
$this->reportJournals();
// deleted transactions that are connected to a not deleted journal.
$this->reportTransactions();
// deleted accounts that still have not deleted transactions or journals attached to them.
$this->reportDeletedAccounts();
}
/**
* Reports on accounts with no transactions.
*/
private function reportAccounts()
{
$set = Account
::leftJoin('transactions', 'transactions.account_id', '=', 'accounts.id')
->leftJoin('users', 'accounts.user_id', '=', 'users.id')
->groupBy('accounts.id')
->having('transaction_count', '=', 0)
->get(['accounts.id', 'accounts.name', 'accounts.user_id', 'users.email', DB::raw('COUNT(`transactions`.`id`) AS `transaction_count`')]);
/** @var stdClass $entry */
foreach ($set as $entry) {
$line = 'User #' . $entry->user_id . ' (' . $entry->email . ') has account #' . $entry->id . ' ("' . Crypt::decrypt($entry->name)
. '") which has no transactions.';
$this->line($line);
}
}
/**
* Reports on budgets with no budget limits (which makes them pointless).
*/
private function reportBudgetLimits()
{
$set = Budget
::leftJoin('budget_limits', 'budget_limits.budget_id', '=', 'budgets.id')
->leftJoin('users', 'budgets.user_id', '=', 'users.id')
->groupBy('budgets.id')
->having('budget_limit_count', '=', 0)
->get(['budgets.id', 'budgets.name', 'budgets.user_id', 'users.email', DB::raw('COUNT(`budget_limits`.`id`) AS `budget_limit_count`')]);
/** @var stdClass $entry */
foreach ($set as $entry) {
$line = 'Notice: User #' . $entry->user_id . ' (' . $entry->email . ') has budget #' . $entry->id . ' ("' . Crypt::decrypt($entry->name)
. '") which has no budget limits.';
$this->line($line);
}
}
/**
* Reports on budgets without any transactions.
*/
private function reportBudgets()
{
$set = Budget
::leftJoin('budget_transaction_journal', 'budgets.id', '=', 'budget_transaction_journal.budget_id')
->leftJoin('users', 'budgets.user_id', '=', 'users.id')
->distinct()
->get(['budgets.id', 'budgets.name', 'budget_transaction_journal.budget_id', 'budgets.user_id', 'users.email']);
/** @var stdClass $entry */
foreach ($set as $entry) {
$line = 'Notice: User #' . $entry->user_id . ' (' . $entry->email . ') has budget #' . $entry->id . ' ("' . Crypt::decrypt($entry->name)
. '") which has no transactions.';
$this->line($line);
}
}
/**
* Reports on categories without any transactions.
*/
private function reportCategories()
{
$set = Category
::leftJoin('category_transaction_journal', 'categories.id', '=', 'category_transaction_journal.category_id')
->leftJoin('users', 'categories.user_id', '=', 'users.id')
->distinct()
->get(['categories.id', 'categories.name', 'category_transaction_journal.category_id', 'categories.user_id', 'users.email']);
/** @var stdClass $entry */
foreach ($set as $entry) {
$line = 'Notice: User #' . $entry->user_id . ' (' . $entry->email . ') has category #' . $entry->id . ' ("' . Crypt::decrypt($entry->name)
. '") which has no transactions.';
$this->line($line);
}
}
/**
* Reports on deleted accounts that still have not deleted transactions or journals attached to them.
*/
private function reportDeletedAccounts()
{
$set = Account
::leftJoin('transactions', 'transactions.account_id', '=', 'accounts.id')
->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id')
->whereNotNull('accounts.deleted_at')
->whereNotNull('transactions.id')
->where(
function (Builder $q) {
$q->whereNull('transactions.deleted_at');
$q->orWhereNull('transaction_journals.deleted_at');
}
)
->get(
['accounts.id as account_id', 'accounts.deleted_at as account_deleted_at', 'transactions.id as transaction_id',
'transactions.deleted_at as transaction_deleted_at', 'transaction_journals.id as journal_id',
'transaction_journals.deleted_at as journal_deleted_at']
);
/** @var stdClass $entry */
foreach ($set as $entry) {
$date = is_null($entry->transaction_deleted_at) ? $entry->journal_deleted_at : $entry->transaction_deleted_at;
$this->error(
'Error: Account #' . $entry->account_id . ' should have been deleted, but has not.' .
' Find it in the table called `accounts` and change the `deleted_at` field to: "' . $date . '"'
);
}
}
/**
* Any deleted transaction journals that have transactions that are NOT deleted:
*/
private function reportJournals()
{
$set = TransactionJournal
::leftJoin('transactions', 'transactions.transaction_journal_id', '=', 'transaction_journals.id')
->whereNotNull('transaction_journals.deleted_at')// USE THIS
->whereNull('transactions.deleted_at')
->whereNotNull('transactions.id')
->get(
[
'transaction_journals.id as journal_id',
'transaction_journals.description',
'transaction_journals.deleted_at as journal_deleted',
'transactions.id as transaction_id',
'transactions.deleted_at as transaction_deleted_at']
);
/** @var stdClass $entry */
foreach ($set as $entry) {
$this->error(
'Error: Transaction #' . $entry->transaction_id . ' should have been deleted, but has not.' .
' Find it in the table called `transactions` and change the `deleted_at` field to: "' . $entry->journal_deleted . '"'
);
}
}
/**
* Reports for each user when the sum of their transactions is not zero.
*/
private function reportSum()
{
/** @var UserRepositoryInterface $userRepository */
$userRepository = app('FireflyIII\Repositories\User\UserRepositoryInterface');
/** @var User $user */
foreach ($userRepository->all() as $user) {
/** @var AccountRepositoryInterface $repository */
$repository = app('FireflyIII\Repositories\Account\AccountRepositoryInterface', [$user]);
$sum = $repository->sumOfEverything();
if (bccomp($sum, '0') !== 0) {
$this->error('Error: Transactions for user #' . $user->id . ' (' . $user->email . ') are off by ' . $sum . '!');
}
}
}
/**
* Reports on tags without any transactions.
*/
private function reportTags()
{
$set = Tag
::leftJoin('tag_transaction_journal', 'tags.id', '=', 'tag_transaction_journal.tag_id')
->leftJoin('users', 'tags.user_id', '=', 'users.id')
->distinct()
->get(['tags.id', 'tags.tag', 'tag_transaction_journal.tag_id', 'tags.user_id', 'users.email']);
/** @var stdClass $entry */
foreach ($set as $entry) {
$line = 'Notice: User #' . $entry->user_id . ' (' . $entry->email . ') has tag #' . $entry->id . ' ("' . $entry->tag
. '") which has no transactions.';
$this->line($line);
}
}
/**
* Reports on deleted transactions that are connected to a not deleted journal.
*/
private function reportTransactions()
{
$set = Transaction
::leftJoin('transaction_journals', 'transactions.transaction_journal_id', '=', 'transaction_journals.id')
->whereNotNull('transactions.deleted_at')
->whereNull('transaction_journals.deleted_at')
->get(
['transactions.id as transaction_id', 'transactions.deleted_at as transaction_deleted', 'transaction_journals.id as journal_id',
'transaction_journals.deleted_at']
);
/** @var stdClass $entry */
foreach ($set as $entry) {
$this->error(
'Error: Transaction journal #' . $entry->journal_id . ' should have been deleted, but has not.' .
' Find it in the table called `transaction_journals` and change the `deleted_at` field to: "' . $entry->transaction_deleted . '"'
);
}
}
}

View File

@@ -3,7 +3,7 @@ declare(strict_types = 1);
/**
* Kernel.php
* Copyright (C) 2016 Sander Dorigo
* 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.
@@ -12,6 +12,7 @@ declare(strict_types = 1);
namespace FireflyIII\Console;
use FireflyIII\Console\Commands\UpgradeFireflyInstructions;
use FireflyIII\Console\Commands\VerifyDatabase;
use Illuminate\Console\Scheduling\Schedule;
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
@@ -22,6 +23,26 @@ use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
*/
class Kernel extends ConsoleKernel
{
/**
* The bootstrap classes for the application.
*
* This needs to be for with the next upgrade.
*
* @var array
*/
protected $bootstrappers
= [
'Illuminate\Foundation\Bootstrap\DetectEnvironment',
'Illuminate\Foundation\Bootstrap\LoadConfiguration',
'FireflyIII\Bootstrap\ConfigureLogging',
'Illuminate\Foundation\Bootstrap\HandleExceptions',
'Illuminate\Foundation\Bootstrap\RegisterFacades',
'Illuminate\Foundation\Bootstrap\SetRequestForConsole',
'Illuminate\Foundation\Bootstrap\RegisterProviders',
'Illuminate\Foundation\Bootstrap\BootProviders',
];
/**
* The Artisan commands provided by your application.
*
@@ -30,6 +51,7 @@ class Kernel extends ConsoleKernel
protected $commands
= [
UpgradeFireflyInstructions::class,
VerifyDatabase::class,
];
/**

View File

@@ -0,0 +1,39 @@
<?php
declare(strict_types = 1);
/**
* ResendConfirmation.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.
*/
namespace FireflyIII\Events;
use FireflyIII\User;
use Illuminate\Queue\SerializesModels;
/**
* Class ResendConfirmation
*
* @package FireflyIII\Events
*/
class ResendConfirmation extends Event
{
use SerializesModels;
public $ipAddress;
public $user;
/**
* Create a new event instance.
*
* @param User $user
* @param string $ipAddress
*/
public function __construct(User $user, string $ipAddress)
{
$this->user = $user;
$this->ipAddress = $ipAddress;
}
}

View File

@@ -2,7 +2,7 @@
declare(strict_types = 1);
/**
* TransactionJournalStored.php
* Copyright (C) 2016 Sander Dorigo
* 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.
@@ -12,11 +12,11 @@ namespace FireflyIII\Events;
use FireflyIII\Models\TransactionJournal;
use Illuminate\Queue\SerializesModels;
use Log;
/**
* Class TransactionJournalStored
*
* @codeCoverageIgnore
* @package FireflyIII\Events
*/
class TransactionJournalStored extends Event
@@ -35,6 +35,7 @@ class TransactionJournalStored extends Event
*/
public function __construct(TransactionJournal $journal, int $piggyBankId)
{
Log::debug('Created new TransactionJournalStored.');
//
$this->journal = $journal;
$this->piggyBankId = $piggyBankId;

View File

@@ -5,11 +5,11 @@ namespace FireflyIII\Events;
use FireflyIII\Models\TransactionJournal;
use Illuminate\Queue\SerializesModels;
use Log;
/**
* Class TransactionJournalUpdated
*
* @codeCoverageIgnore
* @package FireflyIII\Events
*/
class TransactionJournalUpdated extends Event
@@ -26,6 +26,7 @@ class TransactionJournalUpdated extends Event
*/
public function __construct(TransactionJournal $journal)
{
Log::debug('Created new TransactionJournalUpdated');
//
$this->journal = $journal;
}

View File

@@ -0,0 +1,39 @@
<?php
declare(strict_types = 1);
/**
* UserRegistration.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.
*/
namespace FireflyIII\Events;
use FireflyIII\User;
use Illuminate\Queue\SerializesModels;
/**
* Class UserRegistration
*
* @package FireflyIII\Events
*/
class UserRegistration extends Event
{
use SerializesModels;
public $ipAddress;
public $user;
/**
* Create a new event instance.
*
* @param User $user
* @param string $ipAddress
*/
public function __construct(User $user, string $ipAddress)
{
$this->user = $user;
$this->ipAddress = $ipAddress;
}
}

View File

@@ -6,7 +6,6 @@ namespace FireflyIII\Exceptions;
/**
* Class FireflyException
*
* @codeCoverageIgnore
* @package FireflyIII\Exceptions
*/
class FireflyException extends \Exception

View File

@@ -6,7 +6,6 @@ namespace FireflyIII\Exceptions;
/**
* Class NotImplementedException
*
* @codeCoverageIgnore
* @package FireflyIII\Exceptions
*/
class NotImplementedException extends \Exception

View File

@@ -5,7 +5,6 @@ namespace FireflyIII\Exceptions;
/**
* Class ValidationExceptions
*
* @codeCoverageIgnore
* @package FireflyIII\Exception
*/
class ValidationException extends \Exception

View File

@@ -2,7 +2,7 @@
declare(strict_types = 1);
/**
* AttachmentCollector.php
* Copyright (C) 2016 Sander Dorigo
* 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.
@@ -53,9 +53,9 @@ class AttachmentCollector extends BasicCollector implements CollectorInterface
}
/**
*
* @return bool
*/
public function run()
public function run(): bool
{
// grab all the users attachments:
$attachments = $this->getAttachments();
@@ -70,6 +70,7 @@ class AttachmentCollector extends BasicCollector implements CollectorInterface
$this->exportDisk->put($file, $this->explanationString);
Log::debug('Also put explanation file "' . $file . '" in the zip.');
$this->getFiles()->push($file);
return true;
}
/**

View File

@@ -2,7 +2,7 @@
declare(strict_types = 1);
/**
* BasicCollector.php
* Copyright (C) 2016 Sander Dorigo
* 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.
@@ -40,7 +40,7 @@ class BasicCollector
/**
* @return Collection
*/
public function getFiles()
public function getFiles(): Collection
{
return $this->files;
}

View File

@@ -2,7 +2,7 @@
declare(strict_types = 1);
/**
* CollectorInterface.php
* Copyright (C) 2016 Sander Dorigo
* 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.
@@ -22,12 +22,12 @@ interface CollectorInterface
/**
* @return Collection
*/
public function getFiles();
public function getFiles(): Collection;
/**
* @return bool
*/
public function run();
public function run(): bool;
/**
* @param Collection $files

View File

@@ -2,7 +2,7 @@
declare(strict_types = 1);
/**
* UploadCollector.php
* Copyright (C) 2016 Sander Dorigo
* 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.
@@ -47,9 +47,9 @@ class UploadCollector extends BasicCollector implements CollectorInterface
}
/**
*
* @return bool
*/
public function run()
public function run(): bool
{
// grab upload directory.
$files = $this->uploadDisk->files();
@@ -58,6 +58,7 @@ class UploadCollector extends BasicCollector implements CollectorInterface
foreach ($files as $entry) {
$this->processOldUpload($entry);
}
return true;
}
/**

View File

@@ -2,7 +2,7 @@
declare(strict_types = 1);
/**
* ConfigurationFile.php
* Copyright (C) 2016 Sander Dorigo
* 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.
@@ -38,9 +38,9 @@ class ConfigurationFile
}
/**
* @return bool
* @return string
*/
public function make()
public function make(): string
{
$fields = array_keys(get_class_vars(Entry::class));
$types = Entry::getTypes();

View File

@@ -2,7 +2,7 @@
declare(strict_types = 1);
/**
* Entry.php
* Copyright (C) 2016 Sander Dorigo
* 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.
@@ -58,6 +58,7 @@ class Entry
public $fromAccountId;
/** @var string */
public $fromAccountName;
/** @var int */
public $fromAccountNumber;
/** @var string */
public $fromAccountType;
@@ -132,23 +133,25 @@ class Entry
// key = field name (see top of class)
// value = field type (see csv.php under 'roles')
return [
'amount' => 'amount',
'date' => 'date-transaction',
'description' => 'description',
'billId' => 'bill-id',
'billName' => 'bill-name',
'budgetId' => 'budget-id',
'budgetName' => 'budget-name',
'categoryId' => 'category-id',
'categoryName' => 'category-name',
'fromAccountId' => 'account-id',
'fromAccountName' => 'account-name',
'fromAccountIban' => 'account-iban',
'fromAccountType' => '_ignore', // no, Firefly cannot import what it exports. I know :D
'toAccountId' => 'opposing-id',
'toAccountName' => 'opposing-name',
'toAccountIban' => 'opposing-iban',
'toAccountType' => '_ignore',
'amount' => 'amount',
'date' => 'date-transaction',
'description' => 'description',
'billId' => 'bill-id',
'billName' => 'bill-name',
'budgetId' => 'budget-id',
'budgetName' => 'budget-name',
'categoryId' => 'category-id',
'categoryName' => 'category-name',
'fromAccountId' => 'account-id',
'fromAccountNumber' => 'account-number',
'fromAccountName' => 'account-name',
'fromAccountIban' => 'account-iban',
'fromAccountType' => '_ignore', // no, Firefly cannot import what it exports. I know :D
'toAccountId' => 'opposing-id',
'toAccountNumber' => 'account-number',
'toAccountName' => 'opposing-name',
'toAccountIban' => 'opposing-iban',
'toAccountType' => '_ignore',
];
}
@@ -171,7 +174,7 @@ class Entry
/**
* @return int
*/
public function getBillId()
public function getBillId(): int
{
return $this->billId;
}
@@ -179,7 +182,7 @@ class Entry
/**
* @param int $billId
*/
public function setBillId($billId)
public function setBillId(int $billId)
{
$this->billId = $billId;
}
@@ -187,7 +190,7 @@ class Entry
/**
* @return string
*/
public function getBillName()
public function getBillName(): string
{
return $this->billName;
}
@@ -195,7 +198,7 @@ class Entry
/**
* @param string $billName
*/
public function setBillName($billName)
public function setBillName(string $billName)
{
$this->billName = $billName;
}
@@ -203,7 +206,7 @@ class Entry
/**
* @return int
*/
public function getBudgetId()
public function getBudgetId(): int
{
return $this->budgetId;
}
@@ -211,7 +214,7 @@ class Entry
/**
* @param int $budgetId
*/
public function setBudgetId($budgetId)
public function setBudgetId(int $budgetId)
{
$this->budgetId = $budgetId;
}
@@ -219,7 +222,7 @@ class Entry
/**
* @return string
*/
public function getBudgetName()
public function getBudgetName(): string
{
return $this->budgetName;
}
@@ -227,7 +230,7 @@ class Entry
/**
* @param string $budgetName
*/
public function setBudgetName($budgetName)
public function setBudgetName(string $budgetName)
{
$this->budgetName = $budgetName;
}
@@ -235,7 +238,7 @@ class Entry
/**
* @return int
*/
public function getCategoryId()
public function getCategoryId(): int
{
return $this->categoryId;
}
@@ -243,7 +246,7 @@ class Entry
/**
* @param int $categoryId
*/
public function setCategoryId($categoryId)
public function setCategoryId(int $categoryId)
{
$this->categoryId = $categoryId;
}
@@ -251,7 +254,7 @@ class Entry
/**
* @return string
*/
public function getCategoryName()
public function getCategoryName(): string
{
return $this->categoryName;
}
@@ -259,7 +262,7 @@ class Entry
/**
* @param string $categoryName
*/
public function setCategoryName($categoryName)
public function setCategoryName(string $categoryName)
{
$this->categoryName = $categoryName;
}
@@ -267,7 +270,7 @@ class Entry
/**
* @return string
*/
public function getDate()
public function getDate(): string
{
return $this->date;
}
@@ -283,7 +286,7 @@ class Entry
/**
* @return string
*/
public function getDescription()
public function getDescription(): string
{
return $this->description;
}
@@ -299,7 +302,7 @@ class Entry
/**
* @return string
*/
public function getFromAccountIban()
public function getFromAccountIban(): string
{
return $this->fromAccountIban;
}
@@ -307,7 +310,7 @@ class Entry
/**
* @param string $fromAccountIban
*/
public function setFromAccountIban($fromAccountIban)
public function setFromAccountIban(string $fromAccountIban)
{
$this->fromAccountIban = $fromAccountIban;
}
@@ -315,7 +318,7 @@ class Entry
/**
* @return int
*/
public function getFromAccountId()
public function getFromAccountId():int
{
return $this->fromAccountId;
}
@@ -323,7 +326,7 @@ class Entry
/**
* @param int $fromAccountId
*/
public function setFromAccountId($fromAccountId)
public function setFromAccountId(int $fromAccountId)
{
$this->fromAccountId = $fromAccountId;
}
@@ -331,7 +334,7 @@ class Entry
/**
* @return string
*/
public function getFromAccountName()
public function getFromAccountName(): string
{
return $this->fromAccountName;
}
@@ -339,23 +342,23 @@ class Entry
/**
* @param string $fromAccountName
*/
public function setFromAccountName($fromAccountName)
public function setFromAccountName(string $fromAccountName)
{
$this->fromAccountName = $fromAccountName;
}
/**
* @return mixed
* @return string
*/
public function getFromAccountNumber()
public function getFromAccountNumber(): string
{
return $this->fromAccountNumber;
}
/**
* @param mixed $fromAccountNumber
* @param string $fromAccountNumber
*/
public function setFromAccountNumber($fromAccountNumber)
public function setFromAccountNumber(string $fromAccountNumber)
{
$this->fromAccountNumber = $fromAccountNumber;
}
@@ -363,7 +366,7 @@ class Entry
/**
* @return string
*/
public function getFromAccountType()
public function getFromAccountType(): string
{
return $this->fromAccountType;
}
@@ -371,7 +374,7 @@ class Entry
/**
* @param string $fromAccountType
*/
public function setFromAccountType($fromAccountType)
public function setFromAccountType(string $fromAccountType)
{
$this->fromAccountType = $fromAccountType;
}
@@ -379,7 +382,7 @@ class Entry
/**
* @return string
*/
public function getToAccountIban()
public function getToAccountIban(): string
{
return $this->toAccountIban;
}
@@ -387,7 +390,7 @@ class Entry
/**
* @param string $toAccountIban
*/
public function setToAccountIban($toAccountIban)
public function setToAccountIban(string $toAccountIban)
{
$this->toAccountIban = $toAccountIban;
}
@@ -395,7 +398,7 @@ class Entry
/**
* @return int
*/
public function getToAccountId()
public function getToAccountId(): int
{
return $this->toAccountId;
}
@@ -403,7 +406,7 @@ class Entry
/**
* @param int $toAccountId
*/
public function setToAccountId($toAccountId)
public function setToAccountId(int $toAccountId)
{
$this->toAccountId = $toAccountId;
}
@@ -411,7 +414,7 @@ class Entry
/**
* @return string
*/
public function getToAccountName()
public function getToAccountName(): string
{
return $this->toAccountName;
}
@@ -419,23 +422,23 @@ class Entry
/**
* @param string $toAccountName
*/
public function setToAccountName($toAccountName)
public function setToAccountName(string $toAccountName)
{
$this->toAccountName = $toAccountName;
}
/**
* @return mixed
* @return string
*/
public function getToAccountNumber()
public function getToAccountNumber(): string
{
return $this->toAccountNumber;
}
/**
* @param mixed $toAccountNumber
* @param string $toAccountNumber
*/
public function setToAccountNumber($toAccountNumber)
public function setToAccountNumber(string $toAccountNumber)
{
$this->toAccountNumber = $toAccountNumber;
}
@@ -443,7 +446,7 @@ class Entry
/**
* @return string
*/
public function getToAccountType()
public function getToAccountType(): string
{
return $this->toAccountType;
}
@@ -451,7 +454,7 @@ class Entry
/**
* @param string $toAccountType
*/
public function setToAccountType($toAccountType)
public function setToAccountType(string $toAccountType)
{
$this->toAccountType = $toAccountType;
}

View File

@@ -2,7 +2,7 @@
declare(strict_types = 1);
/**
* BasicExporter.php
* Copyright (C) 2016 Sander Dorigo
* 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.
@@ -39,7 +39,7 @@ class BasicExporter
/**
* @return Collection
*/
public function getEntries()
public function getEntries(): Collection
{
return $this->entries;
}

View File

@@ -2,7 +2,7 @@
declare(strict_types = 1);
/**
* CsvExporter.php
* Copyright (C) 2016 Sander Dorigo
* 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.
@@ -39,15 +39,15 @@ class CsvExporter extends BasicExporter implements ExporterInterface
/**
* @return string
*/
public function getFileName()
public function getFileName(): string
{
return $this->fileName;
}
/**
*
* @return bool
*/
public function run()
public function run(): bool
{
// create temporary file:
$this->tempFile();
@@ -72,6 +72,7 @@ class CsvExporter extends BasicExporter implements ExporterInterface
}
$writer->insertAll($rows);
return true;
}
private function tempFile()

View File

@@ -2,7 +2,7 @@
declare(strict_types = 1);
/**
* ExporterInterface.php
* Copyright (C) 2016 Sander Dorigo
* 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.
@@ -22,17 +22,17 @@ interface ExporterInterface
/**
* @return Collection
*/
public function getEntries();
public function getEntries(): Collection;
/**
* @return string
*/
public function getFileName();
public function getFileName(): string;
/**
*
* @return bool
*/
public function run();
public function run(): bool;
/**
* @param Collection $entries

View File

@@ -2,7 +2,7 @@
declare(strict_types = 1);
/**
* Processor.php
* Copyright (C) 2016 Sander Dorigo
* 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.
@@ -15,6 +15,7 @@ use Config;
use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Models\ExportJob;
use FireflyIII\Models\TransactionJournal;
use FireflyIII\Repositories\Journal\JournalCollector;
use Illuminate\Support\Collection;
use Log;
use Storage;
@@ -73,21 +74,23 @@ class Processor
}
/**
*
* @return bool
*/
public function collectAttachments()
public function collectAttachments(): bool
{
$attachmentCollector = app('FireflyIII\Export\Collector\AttachmentCollector', [$this->job]);
$attachmentCollector->run();
$this->files = $this->files->merge($attachmentCollector->getFiles());
return true;
}
/**
*
* @return bool
*/
public function collectJournals()
public function collectJournals(): bool
{
$args = [$this->accounts, Auth::user(), $this->settings['startDate'], $this->settings['endDate']];
/** @var JournalCollector $journalCollector */
$journalCollector = app('FireflyIII\Repositories\Journal\JournalCollector', $args);
$this->journals = $journalCollector->collect();
Log::debug(
@@ -97,20 +100,25 @@ class Processor
$this->settings['endDate']->format('Y-m-d')
. ').'
);
return true;
}
public function collectOldUploads()
/**
* @return bool
*/
public function collectOldUploads(): bool
{
$uploadCollector = app('FireflyIII\Export\Collector\UploadCollector', [$this->job]);
$uploadCollector->run();
$this->files = $this->files->merge($uploadCollector->getFiles());
return true;
}
/**
*
* @return bool
*/
public function convertJournals()
public function convertJournals(): bool
{
$count = 0;
/** @var TransactionJournal $journal */
@@ -119,15 +127,24 @@ class Processor
$count++;
}
Log::debug('Converted ' . $count . ' journals to "Entry" objects.');
return true;
}
public function createConfigFile()
/**
* @return bool
*/
public function createConfigFile(): bool
{
$this->configurationMaker = app('FireflyIII\Export\ConfigurationFile', [$this->job]);
$this->files->push($this->configurationMaker->make());
return true;
}
public function createZipFile()
/**
* @return bool
* @throws FireflyException
*/
public function createZipFile(): bool
{
$zip = new ZipArchive;
$file = $this->job->key . '.zip';
@@ -156,12 +173,13 @@ class Processor
$disk->delete($file);
}
Log::debug('Done!');
return true;
}
/**
*
* @return bool
*/
public function exportJournals()
public function exportJournals(): bool
{
$exporterClass = Config::get('firefly.export_formats.' . $this->exportFormat);
$exporter = app($exporterClass, [$this->job]);
@@ -170,12 +188,13 @@ class Processor
$exporter->run();
$this->files->push($exporter->getFileName());
Log::debug('Added "' . $exporter->getFileName() . '" to the list of files to include in the zip.');
return true;
}
/**
* @return Collection
*/
public function getFiles()
public function getFiles(): Collection
{
return $this->files;
}

View File

@@ -2,7 +2,7 @@
declare(strict_types = 1);
/**
* AccountChartGeneratorInterface.php
* Copyright (C) 2016 Sander Dorigo
* 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.

View File

@@ -2,7 +2,7 @@
declare(strict_types = 1);
/**
* BillChartGeneratorInterface.php
* Copyright (C) 2016 Sander Dorigo
* 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.

View File

@@ -2,7 +2,7 @@
declare(strict_types = 1);
/**
* ChartJsBillChartGenerator.php
* Copyright (C) 2016 Sander Dorigo
* 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.
@@ -31,18 +31,15 @@ class ChartJsBillChartGenerator implements BillChartGeneratorInterface
public function frontpage(string $paid, string $unpaid): array
{
$data = [
[
'value' => round($unpaid, 2),
'color' => 'rgba(53, 124, 165,0.7)',
'highlight' => 'rgba(53, 124, 165,0.9)',
'label' => trans('firefly.unpaid'),
],
[
'value' => round(bcmul($paid, '-1'), 2), // paid is negative, must be positive.
'color' => 'rgba(0, 141, 76, 0.7)',
'highlight' => 'rgba(0, 141, 76, 0.9)',
'label' => trans('firefly.paid'),
'datasets' => [
[
'data' => [round($unpaid, 2), round(bcmul($paid, '-1'), 2)],
'backgroundColor' => ['rgba(53, 124, 165,0.7)', 'rgba(0, 141, 76, 0.7)',],
],
],
'labels' => [strval(trans('firefly.unpaid')), strval(trans('firefly.paid'))],
];
return $data;
@@ -77,14 +74,17 @@ class ChartJsBillChartGenerator implements BillChartGeneratorInterface
}
$data['datasets'][] = [
'type' => 'bar',
'label' => trans('firefly.minAmount'),
'data' => $minAmount,
];
$data['datasets'][] = [
'type' => 'line',
'label' => trans('firefly.billEntry'),
'data' => $actualAmount,
];
$data['datasets'][] = [
'type' => 'bar',
'label' => trans('firefly.maxAmount'),
'data' => $maxAmount,
];

View File

@@ -2,7 +2,7 @@
declare(strict_types = 1);
/**
* BudgetChartGeneratorInterface.php
* Copyright (C) 2016 Sander Dorigo
* 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.

View File

@@ -50,7 +50,6 @@ class ChartJsBudgetChartGenerator implements BudgetChartGeneratorInterface
}
/**
* @codeCoverageIgnore
*
* @param Collection $entries
*
@@ -88,6 +87,10 @@ class ChartJsBudgetChartGenerator implements BudgetChartGeneratorInterface
$overspent[] = round(bcmul($entry[3], '-1'), 2); // same
}
$data['datasets'][] = [
'label' => trans('firefly.overspent'),
'data' => $overspent,
];
$data['datasets'][] = [
'label' => trans('firefly.left'),
'data' => $left,
@@ -96,12 +99,8 @@ class ChartJsBudgetChartGenerator implements BudgetChartGeneratorInterface
'label' => trans('firefly.spent'),
'data' => $spent,
];
$data['datasets'][] = [
'label' => trans('firefly.overspent'),
'data' => $overspent,
];
$data['count'] = count($data['datasets']);
$data['count'] = 3;
return $data;
}
@@ -159,6 +158,9 @@ class ChartJsBudgetChartGenerator implements BudgetChartGeneratorInterface
foreach ($budgets as $budget) {
$data['labels'][] = $budget->name;
}
// also add "no budget"
$data['labels'][] = strval(trans('firefly.no_budget'));
/** @var array $entry */
foreach ($entries as $entry) {
$array = [

View File

@@ -2,7 +2,7 @@
declare(strict_types = 1);
/**
* CategoryChartGeneratorInterface.php
* Copyright (C) 2016 Sander Dorigo
* 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.
@@ -25,7 +25,7 @@ interface CategoryChartGeneratorInterface
*
* @return array
*/
public function all(Collection $entries);
public function all(Collection $entries): array;
/**
* @param Collection $categories

View File

@@ -148,7 +148,6 @@ class ChartJsCategoryChartGenerator implements CategoryChartGeneratorInterface
}
/**
* @codeCoverageIgnore
*
* @param Collection $entries
*

View File

@@ -2,7 +2,7 @@
declare(strict_types = 1);
/**
* PiggyBankChartGenerator.php
* Copyright (C) 2016 Sander Dorigo
* 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.

View File

@@ -89,7 +89,7 @@ class ChartJsReportChartGenerator implements ReportChartGeneratorInterface
'labels' => [],
'datasets' => [
[
'label' => trans('firefly.net-worth'),
'label' => trans('firefly.net_worth'),
'data' => [],
],
],

View File

@@ -2,7 +2,7 @@
declare(strict_types = 1);
/**
* ReportChartGenerator.php
* Copyright (C) 2016 Sander Dorigo
* 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.

View File

@@ -0,0 +1,52 @@
<?php
declare(strict_types = 1);
/**
* AttachUserRole.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.
*/
namespace FireflyIII\Handlers\Events;
use FireflyIII\Events\UserRegistration;
use FireflyIII\Repositories\User\UserRepositoryInterface;
use Log;
/**
* Class AttachUserRole
*
* @package FireflyIII\Handlers\Events
*/
class AttachUserRole
{
/**
* Create the event listener.
*
*/
public function __construct()
{
//
}
/**
* Handle the event.
*
* @param UserRegistration $event
*/
public function handle(UserRegistration $event)
{
Log::debug('Trigger attachuserrole');
/** @var UserRepositoryInterface $repository */
$repository = app('FireflyIII\Repositories\User\UserRepositoryInterface');
// first user ever?
if ($repository->count() == 1) {
Log::debug('Will attach role.');
$repository->attachRole($event->user, 'owner');
}
}
}

View File

@@ -2,7 +2,7 @@
declare(strict_types = 1);
/**
* FireRulesForStore.php
* Copyright (C) 2016 Sander Dorigo
* 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.
@@ -36,6 +36,7 @@ class FireRulesForStore
*/
public function handle(TransactionJournalStored $event): bool
{
Log::debug('Now running FireRulesForStore because TransactionJournalStored fired.');
// get all the user's rule groups, with the rules, order by 'order'.
/** @var User $user */
$user = Auth::user();

View File

@@ -2,7 +2,7 @@
declare(strict_types = 1);
/**
* FireRulesForUpdate.php
* Copyright (C) 2016 Sander Dorigo
* 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.
@@ -34,6 +34,7 @@ class FireRulesForUpdate
*/
public function handle(TransactionJournalUpdated $event): bool
{
Log::debug('Now running FireRulesForUpdate because TransactionJournalUpdated fired.');
// get all the user's rule groups, with the rules, order by 'order'.
/** @var User $user */
$user = Auth::user();

View File

@@ -2,7 +2,7 @@
declare(strict_types = 1);
/**
* RescanJournalAfterStore.php
* Copyright (C) 2016 Sander Dorigo
* 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.
@@ -16,7 +16,6 @@ use FireflyIII\Support\Events\BillScanner;
/**
* Class RescanJournal
*
* @codeCoverageIgnore
* @package FireflyIII\Handlers\Events
*/
class ScanForBillsAfterStore

View File

@@ -2,7 +2,7 @@
declare(strict_types = 1);
/**
* ScanForBillsAfterUpdate.php
* Copyright (C) 2016 Sander Dorigo
* 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.
@@ -16,7 +16,6 @@ use FireflyIII\Support\Events\BillScanner;
/**
* Class RescanJournal
*
* @codeCoverageIgnore
* @package FireflyIII\Handlers\Events
*/
class ScanForBillsAfterUpdate

View File

@@ -0,0 +1,65 @@
<?php
declare(strict_types = 1);
/**
* SendRegistrationMail.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.
*/
namespace FireflyIII\Handlers\Events;
use FireflyIII\Events\UserRegistration;
use Illuminate\Mail\Message;
use Log;
use Mail;
use Swift_TransportException;
/**
* Class SendRegistrationMail
*
* @package FireflyIII\Handlers\Events
*/
class SendRegistrationMail
{
/**
* Create the event listener.
*
*/
public function __construct()
{
//
}
/**
* Handle the event.
*
* @param UserRegistration $event
*
* @return bool
*/
public function handle(UserRegistration $event): bool
{
$sendMail = env('SEND_REGISTRATION_MAIL', true);
if (!$sendMail) {
return true;
}
// get the email address
$email = $event->user->email;
$address = route('index');
$ipAddress = $event->ipAddress;
// send email.
try {
Mail::send(
['emails.registered-html', 'emails.registered'], ['address' => $address, 'ip' => $ipAddress], function (Message $message) use ($email) {
$message->to($email, $email)->subject('Welcome to Firefly III! ');
}
);
} catch (Swift_TransportException $e) {
Log::error($e->getMessage());
}
return true;
}
}

View File

@@ -10,7 +10,6 @@ use FireflyIII\Models\TransactionJournal;
/**
* Class UpdateJournalConnection
*
* @codeCoverageIgnore
* @package FireflyIII\Handlers\Events
*/
class UpdateJournalConnection

View File

@@ -0,0 +1,121 @@
<?php
declare(strict_types = 1);
/**
* UserConfirmation.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.
*/
namespace FireflyIII\Handlers\Events;
use Exception;
use FireflyIII\Events\ResendConfirmation;
use FireflyIII\Events\UserRegistration;
use FireflyIII\User;
use Illuminate\Mail\Message;
use Log;
use Mail;
use Preferences;
use Swift_TransportException;
/**
* Class UserConfirmation
*
* @package FireflyIII\Handlers\Events
*/
class UserConfirmation
{
/**
* Create the event listener.
*
*/
public function __construct()
{
//
}
/**
* @param ResendConfirmation $event
*
* @return bool
*/
public function resendConfirmation(ResendConfirmation $event): bool
{
$user = $event->user;
$ipAddress = $event->ipAddress;
$this->doConfirm($user, $ipAddress);
return true;
}
/**
* Handle the event.
*
* @param UserRegistration $event
*
* @return bool
*/
public function sendConfirmation(UserRegistration $event): bool
{
$user = $event->user;
$ipAddress = $event->ipAddress;
$this->doConfirm($user, $ipAddress);
return true;
}
/**
* @param User $user
* @param string $ipAddress
*/
private function doConfirm(User $user, string $ipAddress)
{
Log::debug('Trigger UserConfirmation::doConfirm');
// if user must confirm account, send email
$confirmAccount = env('MUST_CONFIRM_ACCOUNT', false);
// otherwise, auto-confirm:
if ($confirmAccount === false) {
Log::debug('Confirm account is false, so user will be auto-confirmed.');
Preferences::setForUser($user, 'user_confirmed', true);
Preferences::setForUser($user, 'user_confirmed_last_mail', 0);
Preferences::mark();
return;
}
// send email message:
$email = $user->email;
$code = str_random(16);
$route = route('do_confirm_account', [$code]);
// set preferences:
Preferences::setForUser($user, 'user_confirmed', false);
Preferences::setForUser($user, 'user_confirmed_last_mail', time());
Preferences::setForUser($user, 'user_confirmed_code', $code);
Log::debug('Set preferences for user.');
// send email.
try {
Log::debug('Now in try block for user email message thing to ' . $email . '.');
Mail::send(
['emails.confirm-account-html', 'emails.confirm-account'], ['route' => $route, 'ip' => $ipAddress],
function (Message $message) use ($email) {
$message->to($email, $email)->subject('Please confirm your Firefly III account');
}
);
} catch (Swift_TransportException $e) {
Log::error($e->getMessage());
} catch (Exception $e) {
Log::debug('Caught general exception.');
Log::error($e->getMessage());
}
Log::debug('Finished mail handling for activation.');
return;
}
}

View File

@@ -1,7 +1,8 @@
<?php
declare(strict_types = 1);
/**
* UserEventListener.php
* Copyright (C) 2016 Sander Dorigo
* 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.
@@ -20,8 +21,10 @@ class UserEventListener
{
/**
* Handle user logout events.
*
* @return bool
*/
public function onUserLogout($event)
public function onUserLogout(): bool
{
// dump stuff from the session:
Session::forget('twofactor-authenticated');
@@ -29,4 +32,4 @@ class UserEventListener
return true;
}
}
}

View File

@@ -5,7 +5,6 @@ namespace FireflyIII\Helpers\Collection;
use Illuminate\Support\Collection;
/**
* @codeCoverageIgnore
* Class Account
*
* @package FireflyIII\Helpers\Collection

View File

@@ -5,7 +5,6 @@ namespace FireflyIII\Helpers\Collection;
use Illuminate\Support\Collection;
/**
* @codeCoverageIgnore
*
* Class Balance
*

View File

@@ -5,7 +5,6 @@ namespace FireflyIII\Helpers\Collection;
use FireflyIII\Models\Account as AccountModel;
/**
* @codeCoverageIgnore
*
* Class BalanceEntry
*

View File

@@ -6,7 +6,6 @@ use FireflyIII\Models\Account as AccountModel;
use Illuminate\Support\Collection;
/**
* @codeCoverageIgnore
*
* Class BalanceHeader
*

View File

@@ -6,7 +6,6 @@ use FireflyIII\Models\Budget as BudgetModel;
use Illuminate\Support\Collection;
/**
* @codeCoverageIgnore
*
* Class BalanceLine
*
@@ -102,7 +101,7 @@ class BalanceLine
return $this->getBudget()->name;
}
if ($this->getRole() == self::ROLE_DEFAULTROLE) {
return trans('firefly.noBudget');
return trans('firefly.no_budget');
}
if ($this->getRole() == self::ROLE_TAGROLE) {
return trans('firefly.coveredWithTags');

View File

@@ -6,7 +6,6 @@ namespace FireflyIII\Helpers\Collection;
use Illuminate\Support\Collection;
/**
* @codeCoverageIgnore
* Class Bill
*
* @package FireflyIII\Helpers\Collection

View File

@@ -5,7 +5,6 @@ namespace FireflyIII\Helpers\Collection;
use FireflyIII\Models\Bill as BillModel;
/**
* @codeCoverageIgnore
*
* Class BillLine
*
@@ -111,7 +110,7 @@ class BillLine
}
/**
* @return boolean
* @return bool
*/
public function isActive(): bool
{
@@ -127,7 +126,7 @@ class BillLine
}
/**
* @return boolean
* @return bool
*/
public function isHit(): bool
{

View File

@@ -5,7 +5,6 @@ namespace FireflyIII\Helpers\Collection;
use Illuminate\Support\Collection;
/**
* @codeCoverageIgnore
*
* Class Budget
*

View File

@@ -6,7 +6,6 @@ use FireflyIII\Models\Budget as BudgetModel;
use FireflyIII\Models\LimitRepetition;
/**
* @codeCoverageIgnore
*
* Class BudgetLine
*

View File

@@ -7,7 +7,6 @@ use Illuminate\Support\Collection;
/**
* @codeCoverageIgnore
*
* Class Category
*

View File

@@ -8,7 +8,6 @@ use Illuminate\Support\Collection;
use stdClass;
/**
* @codeCoverageIgnore
*
* Class Expense
*

View File

@@ -8,7 +8,6 @@ use Illuminate\Support\Collection;
use stdClass;
/**
* @codeCoverageIgnore
*
* Class Income
*

View File

@@ -2,9 +2,8 @@
declare(strict_types = 1);
namespace FireflyIII\Helpers\Csv\Converter;
use Auth;
use FireflyIII\Models\Account;
use Log;
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
/**
* Class AccountId
@@ -19,22 +18,16 @@ class AccountId extends BasicConverter implements ConverterInterface
*/
public function convert(): Account
{
/** @var AccountRepositoryInterface $repository */
$repository = app('FireflyIII\Repositories\Account\AccountRepositoryInterface');
// is mapped? Then it's easy!
if (isset($this->mapped[$this->index][$this->value])) {
/** @var Account $account */
$account = Auth::user()->accounts()->find($this->mapped[$this->index][$this->value]);
$account = $repository->find($this->mapped[$this->index][$this->value]);
} else {
/** @var Account $account */
$account = Auth::user()->accounts()->find($this->value);
if (!is_null($account)) {
Log::debug('Found ' . $account->accountType->type . ' named "******" with ID: ' . $this->value . ' (not mapped) ');
} else {
// new account to prevent TypeErrors.
$account = new Account;
}
$account = $repository->find($this->value);
}
return $account;

View File

@@ -15,7 +15,7 @@ class AmountComma extends BasicConverter implements ConverterInterface
/**
* @return float|int
*/
public function convert()
public function convert(): string
{
$value = str_replace(',', '.', strval($this->value));

View File

@@ -5,6 +5,8 @@ namespace FireflyIII\Helpers\Csv\Converter;
use Auth;
use Carbon\Carbon;
use FireflyIII\Models\Account;
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
use Log;
/**
* Class AssetAccountIban
@@ -19,60 +21,52 @@ class AssetAccountIban extends BasicConverter implements ConverterInterface
*/
public function convert(): Account
{
/** @var AccountRepositoryInterface $repository */
$repository = app('FireflyIII\Repositories\Account\AccountRepositoryInterface');
// is mapped? Then it's easy!
if (isset($this->mapped[$this->index][$this->value])) {
$account = Auth::user()->accounts()->find($this->mapped[$this->index][$this->value]);
$account = $repository->find(intval($this->mapped[$this->index][$this->value]));
Log::debug('Found mapped account for value "' . $this->value . '". It is account #' . $account->id);
return $account;
}
if (strlen($this->value) > 0) {
// find or create new account:
$account = $this->findAccount();
$set = $repository->getAccounts(['Default account', 'Asset account']);
/** @var Account $entry */
foreach ($set as $entry) {
if ($entry->iban == $this->value) {
Log::debug('Found an account with the same IBAN ("' . $this->value . '"). It is account #' . $entry->id);
if (is_null($account->id)) {
// create it if doesn't exist.
$repository = app('FireflyIII\Repositories\Account\AccountRepositoryInterface');
$accountData = [
'name' => $this->value,
'accountType' => 'asset',
'virtualBalance' => 0,
'virtualBalanceCurrency' => 1, // hard coded.
'active' => true,
'user' => Auth::user()->id,
'iban' => null,
'accountNumber' => $this->value,
'accountRole' => null,
'openingBalance' => 0,
'openingBalanceDate' => new Carbon,
'openingBalanceCurrency' => 1, // hard coded.
];
$account = $repository->store($accountData);
return $entry;
}
}
Log::debug('Found no account with the same IBAN ("' . $this->value . '"), so will create a new one.');
// create it if doesn't exist.
$accountData = [
'name' => $this->value,
'accountType' => 'asset',
'virtualBalance' => 0,
'virtualBalanceCurrency' => 1, // hard coded.
'active' => true,
'user' => Auth::user()->id,
'iban' => $this->value,
'accountNumber' => $this->value,
'accountRole' => null,
'openingBalance' => 0,
'openingBalanceDate' => new Carbon,
'openingBalanceCurrency' => 1, // hard coded.
];
$account = $repository->store($accountData);
return $account;
}
return new Account;
}
/**
* @return Account
*/
protected function findAccount(): Account
{
$set = Auth::user()->accounts()->accountTypeIn(['Default account', 'Asset account'])->get(['accounts.*']);
/** @var Account $entry */
foreach ($set as $entry) {
if ($entry->iban == $this->value) {
return $entry;
}
}
return new Account;
}
}

View File

@@ -5,6 +5,7 @@ namespace FireflyIII\Helpers\Csv\Converter;
use Auth;
use Carbon\Carbon;
use FireflyIII\Models\Account;
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
/**
* Class AssetAccountName
@@ -17,16 +18,21 @@ class AssetAccountName extends BasicConverter implements ConverterInterface
/**
* @return Account|null
*/
public function convert()
public function convert(): Account
{
/** @var AccountRepositoryInterface $repository */
$repository = app('FireflyIII\Repositories\Account\AccountRepositoryInterface');
// is mapped? Then it's easy!
if (isset($this->mapped[$this->index][$this->value])) {
$account = Auth::user()->accounts()->find($this->mapped[$this->index][$this->value]);
$account = $repository->find(intval($this->mapped[$this->index][$this->value]));
return $account;
}
// find or create new account:
$set = Auth::user()->accounts()->accountTypeIn(['Asset account', 'Default account'])->get();
$set = $repository->getAccounts(['Default account', 'Asset account']);
/** @var Account $entry */
foreach ($set as $entry) {
if ($entry->name == $this->value) {
@@ -35,8 +41,6 @@ class AssetAccountName extends BasicConverter implements ConverterInterface
}
// create it if doesnt exist.
$repository = app('FireflyIII\Repositories\Account\AccountRepositoryInterface');
$accountData = [
'name' => $this->value,
'accountType' => 'asset',

View File

@@ -1,7 +1,8 @@
<?php
declare(strict_types = 1);
/**
* AssetAccountNumber.php
* Copyright (C) 2016 Sander Dorigo
* 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.
@@ -13,6 +14,7 @@ namespace FireflyIII\Helpers\Csv\Converter;
use Auth;
use Carbon\Carbon;
use FireflyIII\Models\Account;
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
/**
* Class AssetAccountNumber
@@ -25,11 +27,14 @@ class AssetAccountNumber extends BasicConverter implements ConverterInterface
/**
* @return Account|null
*/
public function convert()
public function convert(): Account
{
/** @var AccountRepositoryInterface $repository */
$repository = app('FireflyIII\Repositories\Account\AccountRepositoryInterface');
// is mapped? Then it's easy!
if (isset($this->mapped[$this->index][$this->value])) {
$account = Auth::user()->accounts()->find($this->mapped[$this->index][$this->value]);
$account = $repository->find(intval($this->mapped[$this->index][$this->value]));
return $account;
}
@@ -37,53 +42,38 @@ class AssetAccountNumber extends BasicConverter implements ConverterInterface
$value = $this->value ?? '';
if (strlen($value) > 0) {
// find or create new account:
$account = $this->findAccount();
$set = $repository->getAccounts(['Default account', 'Asset account']);
/** @var Account $entry */
foreach ($set as $entry) {
$accountNumber = $entry->getMeta('accountNumber');
if ($accountNumber == $this->value) {
if (is_null($account->id)) {
// create it if doesn't exist.
$repository = app('FireflyIII\Repositories\Account\AccountRepositoryInterface');
$accountData = [
'name' => $this->value,
'accountType' => 'asset',
'virtualBalance' => 0,
'virtualBalanceCurrency' => 1, // hard coded.
'active' => true,
'user' => Auth::user()->id,
'iban' => null,
'accountNumber' => $this->value,
'accountRole' => null,
'openingBalance' => 0,
'openingBalanceDate' => new Carbon,
'openingBalanceCurrency' => 1, // hard coded.
];
$account = $repository->store($accountData);
return $entry;
}
}
$accountData = [
'name' => $this->value,
'accountType' => 'asset',
'virtualBalance' => 0,
'virtualBalanceCurrency' => 1, // hard coded.
'active' => true,
'user' => Auth::user()->id,
'iban' => null,
'accountNumber' => $this->value,
'accountRole' => null,
'openingBalance' => 0,
'openingBalanceDate' => new Carbon,
'openingBalanceCurrency' => 1, // hard coded.
];
$account = $repository->store($accountData);
return $account;
}
return null;
return null; // is this accepted?
}
/**
* @return Account
*/
protected function findAccount(): Account
{
$set = Auth::user()->accounts()->with(['accountmeta'])->accountTypeIn(['Default account', 'Asset account'])->get(['accounts.*']);
/** @var Account $entry */
foreach ($set as $entry) {
$accountNumber = $entry->getMeta('accountNumber');
if ($accountNumber == $this->value) {
return $entry;
}
}
return new Account;
}
}

View File

@@ -23,7 +23,7 @@ class BasicConverter
/**
* @return array
*/
public function getData()
public function getData(): array
{
return $this->data;
}
@@ -39,7 +39,7 @@ class BasicConverter
/**
* @return string
*/
public function getField()
public function getField(): string
{
return $this->field;
}
@@ -47,7 +47,7 @@ class BasicConverter
/**
* @param string $field
*/
public function setField($field)
public function setField(string $field)
{
$this->field = $field;
}
@@ -55,7 +55,7 @@ class BasicConverter
/**
* @return int
*/
public function getIndex()
public function getIndex(): int
{
return $this->index;
}
@@ -63,7 +63,7 @@ class BasicConverter
/**
* @param int $index
*/
public function setIndex($index)
public function setIndex(int $index)
{
$this->index = $index;
}
@@ -71,7 +71,7 @@ class BasicConverter
/**
* @return array
*/
public function getMapped()
public function getMapped(): array
{
return $this->mapped;
}
@@ -79,7 +79,7 @@ class BasicConverter
/**
* @param array $mapped
*/
public function setMapped($mapped)
public function setMapped(array $mapped)
{
$this->mapped = $mapped;
}
@@ -87,7 +87,7 @@ class BasicConverter
/**
* @return string
*/
public function getValue()
public function getValue(): string
{
return $this->value;
}
@@ -95,7 +95,7 @@ class BasicConverter
/**
* @param string $value
*/
public function setValue($value)
public function setValue(string $value)
{
$this->value = $value;
}

View File

@@ -2,8 +2,8 @@
declare(strict_types = 1);
namespace FireflyIII\Helpers\Csv\Converter;
use Auth;
use FireflyIII\Models\Bill;
use FireflyIII\Repositories\Bill\BillRepositoryInterface;
/**
* Class BillId
@@ -16,13 +16,16 @@ class BillId extends BasicConverter implements ConverterInterface
/**
* @return Bill
*/
public function convert()
public function convert(): Bill
{
/** @var BillRepositoryInterface $repository */
$repository = app('FireflyIII\Repositories\Bill\BillRepositoryInterface');
// is mapped? Then it's easy!
if (isset($this->mapped[$this->index][$this->value])) {
$bill = Auth::user()->bills()->find($this->mapped[$this->index][$this->value]);
$bill = $repository->find($this->mapped[$this->index][$this->value]);
} else {
$bill = Auth::user()->bills()->find($this->value);
$bill = $repository->find($this->value);
}
return $bill;

View File

@@ -2,8 +2,8 @@
declare(strict_types = 1);
namespace FireflyIII\Helpers\Csv\Converter;
use Auth;
use FireflyIII\Models\Bill;
use FireflyIII\Repositories\Bill\BillRepositoryInterface;
/**
* Class BillName
@@ -16,15 +16,17 @@ class BillName extends BasicConverter implements ConverterInterface
/**
* @return Bill
*/
public function convert()
public function convert(): Bill
{
$bill = null;
/** @var BillRepositoryInterface $repository */
$repository = app('FireflyIII\Repositories\Bill\BillRepositoryInterface');
$bill = new Bill;
// is mapped? Then it's easy!
if (isset($this->mapped[$this->index][$this->value])) {
$bill = Auth::user()->bills()->find($this->mapped[$this->index][$this->value]);
$bill = $repository->find($this->mapped[$this->index][$this->value]);
} else {
$bills = Auth::user()->bills()->get();
$bills = $repository->getBills();
/** @var Bill $bill */
foreach ($bills as $bill) {
if ($bill->name == $this->value) {

View File

@@ -2,8 +2,8 @@
declare(strict_types = 1);
namespace FireflyIII\Helpers\Csv\Converter;
use Auth;
use FireflyIII\Models\Budget;
use FireflyIII\Repositories\Budget\BudgetRepositoryInterface;
/**
* Class BudgetId
@@ -16,13 +16,17 @@ class BudgetId extends BasicConverter implements ConverterInterface
/**
* @return Budget
*/
public function convert()
public function convert(): Budget
{
/** @var BudgetRepositoryInterface $repository */
$repository = app('FireflyIII\Repositories\Budget\BudgetRepositoryInterface');
// is mapped? Then it's easy!
if (isset($this->mapped[$this->index][$this->value])) {
$budget = Auth::user()->budgets()->find($this->mapped[$this->index][$this->value]);
$budget = $repository->find($this->mapped[$this->index][$this->value]);
} else {
$budget = Auth::user()->budgets()->find($this->value);
$budget = $repository->find($this->value);
}
return $budget;

View File

@@ -4,6 +4,7 @@ namespace FireflyIII\Helpers\Csv\Converter;
use Auth;
use FireflyIII\Models\Budget;
use FireflyIII\Repositories\Budget\BudgetRepositoryInterface;
/**
* Class BudgetName
@@ -16,14 +17,16 @@ class BudgetName extends BasicConverter implements ConverterInterface
/**
* @return Budget
*/
public function convert()
public function convert(): Budget
{
/** @var BudgetRepositoryInterface $repository */
$repository = app('FireflyIII\Repositories\Budget\BudgetRepositoryInterface');
// is mapped? Then it's easy!
if (isset($this->mapped[$this->index][$this->value])) {
$budget = Auth::user()->budgets()->find($this->mapped[$this->index][$this->value]); // see issue #180
$budget = $repository->find($this->mapped[$this->index][$this->value]);
} else {
$repository = app('FireflyIII\Repositories\Budget\BudgetRepositoryInterface');
$budget = $repository->store(['name' => $this->value, 'user' => Auth::user()->id]);
$budget = $repository->store(['name' => $this->value, 'user' => Auth::user()->id]);
}
return $budget;

View File

@@ -2,8 +2,8 @@
declare(strict_types = 1);
namespace FireflyIII\Helpers\Csv\Converter;
use Auth;
use FireflyIII\Models\Category;
use FireflyIII\Repositories\Category\SingleCategoryRepositoryInterface;
/**
* Class CategoryId
@@ -16,13 +16,16 @@ class CategoryId extends BasicConverter implements ConverterInterface
/**
* @return Category
*/
public function convert()
public function convert(): Category
{
/** @var SingleCategoryRepositoryInterface $repository */
$repository = app('FireflyIII\Repositories\Category\SingleCategoryRepositoryInterface');
// is mapped? Then it's easy!
if (isset($this->mapped[$this->index][$this->value])) {
$category = Auth::user()->categories()->find($this->mapped[$this->index][$this->value]);
$category = $repository->find($this->mapped[$this->index][$this->value]);
} else {
$category = Auth::user()->categories()->find($this->value);
$category = $repository->find($this->value);
}
return $category;

View File

@@ -4,6 +4,7 @@ namespace FireflyIII\Helpers\Csv\Converter;
use Auth;
use FireflyIII\Models\Category;
use FireflyIII\Repositories\Category\SingleCategoryRepositoryInterface;
/**
* Class CategoryName
@@ -16,18 +17,22 @@ class CategoryName extends BasicConverter implements ConverterInterface
/**
* @return Category
*/
public function convert()
public function convert(): Category
{
/** @var SingleCategoryRepositoryInterface $repository */
$repository = app('FireflyIII\Repositories\Category\SingleCategoryRepositoryInterface');
// is mapped? Then it's easy!
if (isset($this->mapped[$this->index][$this->value])) {
$category = Auth::user()->categories()->find($this->mapped[$this->index][$this->value]);
$category = $repository->find($this->mapped[$this->index][$this->value]);
} else {
$category = Category::firstOrCreateEncrypted( // See issue #180
[
'name' => $this->value,
'user_id' => Auth::user()->id,
]
);
$data = [
'name' => $this->value,
'user' => Auth::user()->id,
];
$category = $repository->store($data);
}
return $category;

View File

@@ -24,21 +24,21 @@ interface ConverterInterface
* @param string $field
*
*/
public function setField($field);
public function setField(string $field);
/**
* @param int $index
*/
public function setIndex($index);
public function setIndex(int $index);
/**
* @param array $mapped
*/
public function setMapped($mapped);
public function setMapped(array $mapped);
/**
* @param string $value
*/
public function setValue($value);
public function setValue(string $value);
}

View File

@@ -3,6 +3,7 @@ declare(strict_types = 1);
namespace FireflyIII\Helpers\Csv\Converter;
use FireflyIII\Models\TransactionCurrency;
use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;
/**
* Class CurrencyCode
@@ -15,12 +16,16 @@ class CurrencyCode extends BasicConverter implements ConverterInterface
/**
* @return TransactionCurrency
*/
public function convert()
public function convert(): TransactionCurrency
{
/** @var CurrencyRepositoryInterface $repository */
$repository = app('FireflyIII\Repositories\Currency\CurrencyRepositoryInterface');
if (isset($this->mapped[$this->index][$this->value])) {
$currency = TransactionCurrency::find($this->mapped[$this->index][$this->value]);
$currency = $repository->find($this->mapped[$this->index][$this->value]);
} else {
$currency = TransactionCurrency::whereCode($this->value)->first();
$currency = $repository->findByCode($this->value);
}
return $currency;

View File

@@ -3,6 +3,7 @@ declare(strict_types = 1);
namespace FireflyIII\Helpers\Csv\Converter;
use FireflyIII\Models\TransactionCurrency;
use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;
/**
* Class CurrencyId
@@ -15,12 +16,15 @@ class CurrencyId extends BasicConverter implements ConverterInterface
/**
* @return TransactionCurrency
*/
public function convert()
public function convert(): TransactionCurrency
{
/** @var CurrencyRepositoryInterface $repository */
$repository = app('FireflyIII\Repositories\Currency\CurrencyRepositoryInterface');
if (isset($this->mapped[$this->index][$this->value])) {
$currency = TransactionCurrency::find($this->mapped[$this->index][$this->value]);
$currency = $repository->find($this->mapped[$this->index][$this->value]);
} else {
$currency = TransactionCurrency::find($this->value);
$currency = $repository->find($this->value);
}
return $currency;

View File

@@ -3,6 +3,7 @@ declare(strict_types = 1);
namespace FireflyIII\Helpers\Csv\Converter;
use FireflyIII\Models\TransactionCurrency;
use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;
/**
* Class CurrencyName
@@ -15,12 +16,16 @@ class CurrencyName extends BasicConverter implements ConverterInterface
/**
* @return TransactionCurrency
*/
public function convert()
public function convert(): TransactionCurrency
{
/** @var CurrencyRepositoryInterface $repository */
$repository = app('FireflyIII\Repositories\Currency\CurrencyRepositoryInterface');
if (isset($this->mapped[$this->index][$this->value])) {
$currency = TransactionCurrency::find($this->mapped[$this->index][$this->value]);
$currency = $repository->find($this->mapped[$this->index][$this->value]);
} else {
$currency = TransactionCurrency::whereName($this->value)->first();
$currency = $repository->findByName($this->value);
}
return $currency;

View File

@@ -3,6 +3,7 @@ declare(strict_types = 1);
namespace FireflyIII\Helpers\Csv\Converter;
use FireflyIII\Models\TransactionCurrency;
use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;
/**
* Class CurrencySymbol
@@ -15,12 +16,15 @@ class CurrencySymbol extends BasicConverter implements ConverterInterface
/**
* @return TransactionCurrency
*/
public function convert()
public function convert(): TransactionCurrency
{
/** @var CurrencyRepositoryInterface $repository */
$repository = app('FireflyIII\Repositories\Currency\CurrencyRepositoryInterface');
if (isset($this->mapped[$this->index][$this->value])) {
$currency = TransactionCurrency::find($this->mapped[$this->index][$this->value]);
$currency = $repository->find($this->mapped[$this->index][$this->value]);
} else {
$currency = TransactionCurrency::whereSymbol($this->value)->first();
$currency = $repository->findBySymbol($this->value);
}
return $currency;

View File

@@ -19,7 +19,7 @@ class Date extends BasicConverter implements ConverterInterface
* @return Carbon
* @throws FireflyException
*/
public function convert()
public function convert(): Carbon
{
$format = session('csv-date-format');
try {

View File

@@ -14,7 +14,7 @@ class Description extends BasicConverter implements ConverterInterface
/**
* @return string
*/
public function convert()
public function convert(): string
{
$description = $this->data['description'] ?? '';

View File

@@ -1,7 +1,8 @@
<?php
declare(strict_types = 1);
/**
* INGDebetCredit.php
* Copyright (C) 2016 Sander Dorigo
* 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.
@@ -23,7 +24,7 @@ class INGDebetCredit extends BasicConverter implements ConverterInterface
/**
* @return int
*/
public function convert()
public function convert(): int
{
if ($this->value === 'Af') {
return -1;

View File

@@ -2,9 +2,8 @@
declare(strict_types = 1);
namespace FireflyIII\Helpers\Csv\Converter;
use Auth;
use FireflyIII\Models\Account;
use Log;
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
/**
* Class OpposingAccountIban
@@ -21,15 +20,23 @@ class OpposingAccountIban extends BasicConverter implements ConverterInterface
*/
public function convert()
{
/** @var AccountRepositoryInterface $repository */
$repository = app('FireflyIII\Repositories\Account\AccountRepositoryInterface');
if (isset($this->mapped[$this->index][$this->value])) {
$account = Auth::user()->accounts()->find($this->mapped[$this->index][$this->value]);
$account = $repository->find($this->mapped[$this->index][$this->value]);
return $account;
} else {
if (strlen($this->value) > 0) {
$account = $this->findAccount();
if (!is_null($account)) {
return $account;
$set = $repository->getAccounts([]);
/** @var Account $account */
foreach ($set as $account) {
if ($account->iban == $this->value) {
return $account;
}
}
}
@@ -37,21 +44,4 @@ class OpposingAccountIban extends BasicConverter implements ConverterInterface
}
}
/**
* @return Account|null
*/
protected function findAccount()
{
$set = Auth::user()->accounts()->get();
/** @var Account $account */
foreach ($set as $account) {
if ($account->iban == $this->value) {
Log::debug('OpposingAccountIban::convert found an Account (#' . $account->id . ': ******) with IBAN ******');
return $account;
}
}
return null;
}
}

View File

@@ -2,8 +2,8 @@
declare(strict_types = 1);
namespace FireflyIII\Helpers\Csv\Converter;
use Auth;
use FireflyIII\Models\Account;
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
/**
* Class OpposingAccountId
@@ -17,13 +17,16 @@ class OpposingAccountId extends BasicConverter implements ConverterInterface
/**
* @return Account
*/
public function convert()
public function convert(): Account
{
/** @var AccountRepositoryInterface $repository */
$repository = app('FireflyIII\Repositories\Account\AccountRepositoryInterface');
if (isset($this->mapped[$this->index][$this->value])) {
$account = Auth::user()->accounts()->find($this->mapped[$this->index][$this->value]);
$account = $repository->find($this->mapped[$this->index][$this->value]);
} else {
$account = Auth::user()->accounts()->find($this->value);
$account = $repository->find($this->value);
}
return $account;

View File

@@ -2,8 +2,8 @@
declare(strict_types = 1);
namespace FireflyIII\Helpers\Csv\Converter;
use Auth;
use FireflyIII\Models\Account;
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
/**
* Class OpposingAccountName
@@ -20,8 +20,11 @@ class OpposingAccountName extends BasicConverter implements ConverterInterface
*/
public function convert()
{
/** @var AccountRepositoryInterface $repository */
$repository = app('FireflyIII\Repositories\Account\AccountRepositoryInterface');
if (isset($this->mapped[$this->index][$this->value])) {
$account = Auth::user()->accounts()->find($this->mapped[$this->index][$this->value]);
$account = $repository->find($this->mapped[$this->index][$this->value]);
return $account;
} else {

View File

@@ -15,7 +15,7 @@ class RabobankDebetCredit extends BasicConverter implements ConverterInterface
/**
* @return int
*/
public function convert()
public function convert(): int
{
if ($this->value == 'D') {
return -1;

View File

@@ -2,8 +2,7 @@
declare(strict_types = 1);
namespace FireflyIII\Helpers\Csv\Converter;
use Auth;
use FireflyIII\Models\Tag;
use FireflyIII\Repositories\Tag\TagRepositoryInterface;
use Illuminate\Support\Collection;
/**
@@ -17,19 +16,24 @@ class TagsComma extends BasicConverter implements ConverterInterface
/**
* @return Collection
*/
public function convert()
public function convert(): Collection
{
$tags = new Collection;
/** @var TagRepositoryInterface $repository */
$repository = app('FireflyIII\Repositories\Tag\TagRepositoryInterface');
$tags = new Collection;
$strings = explode(',', $this->value);
foreach ($strings as $string) {
$tag = Tag::firstOrCreateEncrypted( // See issue #180
[
'tag' => $string,
'tagMode' => 'nothing',
'user_id' => Auth::user()->id,
]
);
$data = [
'tag' => $string,
'date' => null,
'description' => null,
'latitude' => null,
'longitude' => null,
'zoomLevel' => null,
'tagMode' => 'nothing',
];
$tag = $repository->store($data); // should validate first?
$tags->push($tag);
}
$tags = $tags->merge($this->data['tags']);

View File

@@ -2,8 +2,7 @@
declare(strict_types = 1);
namespace FireflyIII\Helpers\Csv\Converter;
use Auth;
use FireflyIII\Models\Tag;
use FireflyIII\Repositories\Tag\TagRepositoryInterface;
use Illuminate\Support\Collection;
/**
@@ -17,19 +16,25 @@ class TagsSpace extends BasicConverter implements ConverterInterface
/**
* @return Collection
*/
public function convert()
public function convert(): Collection
{
/** @var TagRepositoryInterface $repository */
$repository = app('FireflyIII\Repositories\Tag\TagRepositoryInterface');
$tags = new Collection;
$strings = explode(' ', $this->value);
foreach ($strings as $string) {
$tag = Tag::firstOrCreateEncrypted( // See issue #180
[
'tag' => $string,
'tagMode' => 'nothing',
'user_id' => Auth::user()->id,
]
);
$data = [
'tag' => $string,
'date' => null,
'description' => null,
'latitude' => null,
'longitude' => null,
'zoomLevel' => null,
'tagMode' => 'nothing',
];
$tag = $repository->store($data); // should validate first?
$tags->push($tag);
}
$tags = $tags->merge($this->data['tags']);

View File

@@ -57,7 +57,7 @@ class Data
*
* @return string
*/
public function getCsvFileContent()
public function getCsvFileContent(): string
{
return $this->csvFileContent ?? '';
}
@@ -72,10 +72,10 @@ class Data
}
/**
*
* FIXME may return null
* @return string
*/
public function getCsvFileLocation()
public function getCsvFileLocation(): string
{
return $this->csvFileLocation;
}
@@ -91,10 +91,10 @@ class Data
}
/**
*
* FIXME may return null
* @return string
*/
public function getDateFormat()
public function getDateFormat(): string
{
return $this->dateFormat;
}
@@ -110,10 +110,10 @@ class Data
}
/**
*
* FIXME may return null
* @return string
*/
public function getDelimiter()
public function getDelimiter(): string
{
return $this->delimiter;
}
@@ -132,7 +132,7 @@ class Data
*
* @return array
*/
public function getMap()
public function getMap(): array
{
return $this->map;
}
@@ -151,7 +151,7 @@ class Data
*
* @return array
*/
public function getMapped()
public function getMapped(): array
{
return $this->mapped;
}
@@ -170,7 +170,7 @@ class Data
*
* @return Reader
*/
public function getReader()
public function getReader(): Reader
{
if (!is_null($this->csvFileContent) && strlen($this->csvFileContent) === 0) {
$this->loadCsvFile();
@@ -188,7 +188,7 @@ class Data
*
* @return array
*/
public function getRoles()
public function getRoles(): array
{
return $this->roles;
}
@@ -207,7 +207,7 @@ class Data
*
* @return array
*/
public function getSpecifix()
public function getSpecifix(): array
{
return is_array($this->specifix) ? $this->specifix : [];
}
@@ -226,7 +226,7 @@ class Data
*
* @return bool
*/
public function hasHeaders()
public function hasHeaders(): bool
{
return $this->hasHeaders;
}

View File

@@ -4,19 +4,15 @@ namespace FireflyIII\Helpers\Csv;
use Auth;
use Config;
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\Rule;
use FireflyIII\Models\RuleGroup;
use FireflyIII\Models\Transaction;
use FireflyIII\Models\TransactionJournal;
use FireflyIII\Models\TransactionType;
use FireflyIII\Rules\Processor;
use FireflyIII\User;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Support\Collection;
use Illuminate\Support\MessageBag;
use Log;
@@ -32,7 +28,7 @@ class Importer
/** @var Data */
protected $data;
/** @var array */
protected $errors;
protected $errors = [];
/** @var array */
protected $importData;
/** @var array */
@@ -57,7 +53,7 @@ class Importer
*
* @return array
*/
public function getErrors()
public function getErrors(): array
{
return $this->errors;
}
@@ -67,7 +63,7 @@ class Importer
*
* @return int
*/
public function getImported()
public function getImported(): int
{
return $this->imported;
}
@@ -75,7 +71,7 @@ class Importer
/**
* @return Collection
*/
public function getJournals()
public function getJournals(): Collection
{
return $this->journals;
}
@@ -85,7 +81,7 @@ class Importer
*
* @return int
*/
public function getRows()
public function getRows(): int
{
return $this->rows;
}
@@ -93,7 +89,7 @@ class Importer
/**
* @return array
*/
public function getSpecifix()
public function getSpecifix(): array
{
return is_array($this->specifix) ? $this->specifix : [];
}
@@ -122,15 +118,11 @@ class Importer
} else {
$this->imported++;
$this->journals->push($result);
event(new TransactionJournalStored($result, 0));
}
Log::debug('---');
}
}
// once all journals have been imported (or not)
// fire the rules.
$this->fireRules();
}
/**
@@ -142,7 +134,6 @@ class Importer
}
/**
*
* @return TransactionJournal|string
*/
protected function createTransactionJournal()
@@ -156,8 +147,15 @@ class Importer
$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'],]
[
'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
@@ -359,55 +357,6 @@ class Importer
return true;
}
/**
* @param Collection $groups
* @param TransactionJournal $journal
*/
private function fireRule(Collection $groups, TransactionJournal $journal)
{
/** @var RuleGroup $group */
foreach ($groups as $group) {
/** @var Rule $rule */
foreach ($group->rules as $rule) {
$processor = Processor::make($rule);
$processor->handleTransactionJournal($journal);
if ($rule->stop_processing) {
break;
}
}
}
}
private function fireRules()
{
// get all users rules.
/** @var User $user */
$user = Auth::user();
$groups = $user
->ruleGroups()
->where('rule_groups.active', 1)
->orderBy('order', 'ASC')
->with(
[
'rules' => function (HasMany $q) {
$q->leftJoin('rule_triggers', 'rules.id', '=', 'rule_triggers.rule_id')
->where('rule_triggers.trigger_type', 'user_action')
->where('rule_triggers.trigger_value', 'store-journal')
->where('rules.active', 1)
->orderBy('rules.order', 'ASC');
},
]
)
->get();
/** @var TransactionJournal $journal */
foreach ($this->journals as $journal) {
$this->fireRule($groups, $journal);
}
}
/**
* @return array
*/

View File

@@ -16,7 +16,7 @@ class AnyAccount implements MapperInterface
/**
* @return array
*/
public function getMap()
public function getMap(): array
{
$result = Auth::user()->accounts()->with('accountType')->orderBy('accounts.name', 'ASC')->get(['accounts.*']);

View File

@@ -17,7 +17,7 @@ class AssetAccount implements MapperInterface
/**
* @return array
*/
public function getMap()
public function getMap(): array
{
$result = Auth::user()->accounts()->with(
['accountmeta' => function (HasMany $query) {

View File

@@ -16,7 +16,7 @@ class Bill implements MapperInterface
/**
* @return array
*/
public function getMap()
public function getMap(): array
{
$result = Auth::user()->bills()->get(['bills.*']);
$list = [];

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