Compare commits

..

180 Commits

Author SHA1 Message Date
James Cole
4650a2ea52 Merge branch 'release/4.7.2.2' 2018-04-04 19:26:51 +02:00
James Cole
7cd51a7747 Update version. 2018-04-04 19:18:59 +02:00
James Cole
b55545b959 Fix #1317 2018-04-04 19:18:01 +02:00
James Cole
2685256c93 Fix split edit. 2018-04-04 19:15:05 +02:00
James Cole
3819de4e74 Fix security issue with markdown, thanks to @simhnna 2018-04-04 19:14:47 +02:00
James Cole
73fee4eb6b Fix #1313 2018-04-03 19:15:06 +02:00
James Cole
609c193b88 Fix #1312 2018-04-03 19:12:59 +02:00
James Cole
03a42976b1 Configure logging for Slack. [skip ci] 2018-04-02 20:05:18 +02:00
James Cole
6db0efdfbc Fix extremely specific piggy bank percentage. 2018-04-02 17:30:30 +02:00
James Cole
ebbbe1a620 Merge branch 'release/4.7.2.1' 2018-04-02 16:52:23 +02:00
James Cole
5d1c77cb16 New version: 4.7.2.1 2018-04-02 15:40:43 +02:00
James Cole
d48fb3ba55 Create keys by hand if not existing. 2018-04-02 15:26:33 +02:00
James Cole
8c024a1ae9 Create default token if none exist. 2018-04-02 15:17:03 +02:00
James Cole
a3c34e6b3c Code cleanup 2018-04-02 15:10:40 +02:00
James Cole
fa7ab45a40 Code cleanup 2018-04-02 14:50:17 +02:00
James Cole
379b104778 Refer to classes directly. 2018-04-02 14:43:06 +02:00
James Cole
d956c795a4 Vue components will now work in subdirs too. 2018-04-02 14:42:30 +02:00
James Cole
7d02d0f762 Code cleanup. 2018-04-02 14:42:07 +02:00
James Cole
f96f38b172 Code cleanup. 2018-04-02 14:17:11 +02:00
James Cole
4cea5d65a6 Expand language list #1310 2018-04-02 06:56:19 +02:00
James Cole
40d94e7a62 Avoid using serialised preferences for security purposes. This might break existing preferences. 2018-04-01 19:22:30 +02:00
James Cole
66019fdbbf Code for #1309 2018-04-01 16:00:15 +02:00
James Cole
37b02e3d5b Merge branch 'release/4.7.2' 2018-04-01 11:46:41 +02:00
James Cole
093bdd6090 Fix some last minute issues. 2018-04-01 08:50:23 +02:00
James Cole
52656b25da Let's cancel these tests for now. 2018-04-01 08:04:19 +02:00
James Cole
1386c9d915 Disable some tests. 2018-04-01 07:40:30 +02:00
James Cole
02c9441727 Last minute language updates. 2018-04-01 07:24:18 +02:00
James Cole
b1e926f2cb Use php unit 7, not 6. 2018-04-01 07:13:29 +02:00
James Cole
df9dcb395b Change composer build instructions 2018-04-01 07:02:46 +02:00
James Cole
ad59dad921 Remove deprecated features. 2018-03-31 21:42:08 +02:00
James Cole
46e75968f5 Update composer 2018-03-31 21:05:53 +02:00
James Cole
0df5c5121d Update language strings 2018-03-31 21:05:43 +02:00
James Cole
16f04b45ac Update composer file. 2018-03-31 21:05:17 +02:00
James Cole
5ce35a50c2 Make sure tests work. 2018-03-31 21:05:06 +02:00
James Cole
7110c1178a Fix bad parse error. 2018-03-30 22:49:46 +02:00
James Cole
220f5e2913 Add support for Italian. 2018-03-30 22:48:00 +02:00
James Cole
9f8c75efc6 Fix null pointer in account format. 2018-03-30 22:44:37 +02:00
James Cole
8f3e84df4d Fix possible null pointer. 2018-03-30 22:40:20 +02:00
James Cole
08ff3d8ad0 Implement test of import command. 2018-03-30 19:41:16 +02:00
James Cole
5c4d7734ac Expand test code for create export routine. 2018-03-30 16:44:33 +02:00
James Cole
15f8cd49d3 Log file security. 2018-03-30 14:50:44 +02:00
James Cole
62b3986fcd Update env files for #1280 2018-03-30 07:00:20 +02:00
James Cole
55b6d711f3 Currency exchange rate will not be saved when rate is 0. 2018-03-30 06:33:04 +02:00
James Cole
7e51d57d21 Update composer file. 2018-03-29 19:01:59 +02:00
James Cole
170d23d768 Code cleanup before release. 2018-03-29 19:01:47 +02:00
James Cole
40266c6821 Add support for Italian and update language files. 2018-03-29 19:00:21 +02:00
James Cole
0a71077513 Push updated tests. 2018-03-28 19:38:20 +02:00
James Cole
be5c44af61 Update some code, add security txt file. 2018-03-28 19:37:59 +02:00
James Cole
720dcb0fe5 Fix #1300 2018-03-27 19:29:58 +02:00
James Cole
c86b207b1c Fix #1297 2018-03-26 20:48:47 +02:00
James Cole
413c1bc2fe Fix #1294 2018-03-26 19:19:11 +02:00
James Cole
5ca31ea3dd Fix #1296 2018-03-26 19:09:58 +02:00
James Cole
dd5d2d1616 Consistent overview for #1292 2018-03-25 21:16:46 +02:00
James Cole
5f08790f12 Restore chart #1292 2018-03-25 20:52:21 +02:00
James Cole
d5ef5ee5a7 Fix #1293 2018-03-25 20:42:56 +02:00
James Cole
f641c70172 Fix #1292 2018-03-25 18:26:35 +02:00
James Cole
992657b942 Code for #1257 2018-03-25 13:30:55 +02:00
James Cole
41e468b507 Fix #1247 2018-03-25 10:17:07 +02:00
James Cole
6660306ac4 Various code cleanup. 2018-03-25 09:01:43 +02:00
James Cole
dd9694890a Code for #1291 2018-03-25 09:00:45 +02:00
James Cole
0b8654d865 Fix #1252 2018-03-25 07:59:06 +02:00
James Cole
f07dc7bd81 Finalize bunq import #1248 2018-03-25 07:55:31 +02:00
James Cole
6a6482dc7f Finish up bunq import routine. 2018-03-24 18:55:02 +01:00
James Cole
3c9b7c07af Move import to factory #1222 2018-03-24 14:05:29 +01:00
James Cole
796ab4bf2c Fixed some small issues in import routine. 2018-03-24 11:49:26 +01:00
James Cole
55602d632d Clean up code for import routine. 2018-03-24 10:35:42 +01:00
James Cole
310ed9f504 Add budget warnings #1202 2018-03-24 06:46:37 +01:00
James Cole
dafddfa39a Fix all tests. 2018-03-24 06:08:50 +01:00
James Cole
3e22c9860e Fix some tests. 2018-03-23 05:31:45 +01:00
James Cole
fb0a0c3fb5 Fix a few tests. 2018-03-23 05:31:30 +01:00
James Cole
3b735c7533 Expand views and files to use new methods. 2018-03-19 19:39:26 +01:00
James Cole
1645490f5c Avoid using model methods and use repository instead 2018-03-19 19:39:02 +01:00
James Cole
aecffe10d9 Import routine can handle new SEPA fields and many new date fields. See #1248 2018-03-19 19:38:17 +01:00
James Cole
4e69bc0e32 Add reference to FAQ [skip ci] 2018-03-19 15:44:08 +01:00
James Cole
909f72e6be Move notes for attachments to different object. This sacrifices the original notes. 2018-03-19 15:28:35 +01:00
James Cole
6a1d39d5f8 Add newlines and strict type declarations. 2018-03-19 13:23:26 +01:00
James Cole
c5d4ec17c3 Move strict type declaration. 2018-03-19 13:22:08 +01:00
James Cole
ed33a72945 Make sure that strict_types declaration is always at the very top of the file. 2018-03-19 12:09:12 +01:00
James Cole
d8c0091680 Make sure that strict_types declaration is always at the very top of the file. 2018-03-19 12:08:50 +01:00
James Cole
6419d68626 Add newlines to end of file. 2018-03-19 12:08:22 +01:00
James Cole
e2ecaf5bcf Include BIC in import routine 2018-03-19 10:03:08 +01:00
James Cole
31146954d1 Fix #1258 2018-03-19 09:33:48 +01:00
James Cole
601ca9ec80 Update German translations [skip ci] 2018-03-19 09:09:47 +01:00
James Cole
082b5ba895 Fix #1262 2018-03-19 09:09:02 +01:00
James Cole
e06361d5d7 Push strict declaration to top. 2018-03-19 08:17:42 +01:00
James Cole
552a8e130c Add support methods. 2018-03-19 08:17:31 +01:00
James Cole
40787bc29a Improve bunq import. 2018-03-19 08:17:15 +01:00
James Cole
6ab03bb228 Improve IBAN uniqueness. 2018-03-19 08:16:54 +01:00
James Cole
3fdb782321 Fix various tests. 2018-03-11 21:19:35 +01:00
James Cole
c8f52a1c40 Code cleanup [skip ci] 2018-03-11 20:41:03 +01:00
James Cole
eb63090387 Fix custom range thing for accounts #1240 [skip ci] 2018-03-11 19:01:19 +01:00
James Cole
5bc8f31c31 Add verify routine to installer. 2018-03-11 18:47:26 +01:00
James Cole
5776de7745 Update various tests. 2018-03-11 18:46:41 +01:00
James Cole
f45d0bb317 Expand install routine. 2018-03-11 18:46:18 +01:00
James Cole
93aa5b7753 Fix null pointer in chart JS [skip ci] 2018-03-11 18:40:08 +01:00
James Cole
dd6a6a565f Fix null pointer in budget report [skip ci] 2018-03-11 18:38:35 +01:00
James Cole
aba8025645 Move docker files, include kubernetes files. 2018-03-11 18:27:30 +01:00
James Cole
b12872e5de Various code cleanup. 2018-03-11 16:24:07 +01:00
James Cole
5a7b1ba292 Remove unused methods. 2018-03-11 15:55:36 +01:00
James Cole
24715c72a2 Remove unused functions. 2018-03-11 15:54:33 +01:00
James Cole
ed3a4e4663 View extension for amounts [skip ci] 2018-03-11 14:19:28 +01:00
James Cole
e97283b34b Make sure transfers can't get a budget. 2018-03-11 14:13:23 +01:00
James Cole
c2dfbcba10 Improve view for transactions. 2018-03-11 14:09:44 +01:00
James Cole
a9870b35be Remove some stuff, mark as deprecated. 2018-03-11 13:34:16 +01:00
James Cole
ed5cd2b9ca Add currency symbol. 2018-03-11 13:31:22 +01:00
James Cole
a9356ca1e2 Mark methods as deprecated. 2018-03-11 13:30:58 +01:00
James Cole
cfba11e9ca Code for #1244 2018-03-11 13:26:11 +01:00
James Cole
4304a3c916 Code for #1214 2018-03-11 13:22:34 +01:00
James Cole
9e6194bfdc Catch null pointer [skip ci] 2018-03-11 08:23:47 +01:00
James Cole
7d6c8aa9dc Fix null pointer. 2018-03-11 08:22:20 +01:00
James Cole
aad0864018 Various code cleanup [skip ci] 2018-03-10 22:38:20 +01:00
James Cole
a55d18709c More code to catch exceptions in #1238 2018-03-10 22:34:02 +01:00
James Cole
dd2f3c861b Optimize imports. 2018-03-10 20:30:09 +01:00
James Cole
da1dc67e1c Validation message. 2018-03-10 20:25:55 +01:00
James Cole
0c2b35e542 Improve bunq import. 2018-03-10 20:25:42 +01:00
James Cole
85dc1263ea Fix #1238 2018-03-10 20:25:11 +01:00
James Cole
c8ecb3e0ee Fix #1199 for web interface 2018-03-10 09:44:04 +01:00
James Cole
ce10036a27 Fix #1199 in API 2018-03-10 09:39:49 +01:00
James Cole
30e49846e0 First list existing devices, then try to get a new one. 2018-03-10 07:33:49 +01:00
James Cole
be97dd1c57 Expand various views. 2018-03-10 07:17:23 +01:00
James Cole
648a6dca42 Expand install routine. 2018-03-10 07:17:05 +01:00
James Cole
0566d0d198 Expand bunq import. 2018-03-10 07:16:38 +01:00
James Cole
dfc25722c9 Expand debug page with locale information. 2018-03-10 07:15:21 +01:00
James Cole
a436c55c50 Code for #1236 2018-03-10 06:49:03 +01:00
James Cole
0d58530f55 Fix #1237 2018-03-09 20:58:46 +01:00
James Cole
04b2eaf535 Fix tests that broke during Laravel 5.6 upgrade 2018-03-09 06:46:45 +01:00
James Cole
ace2ed8bd0 Fix #1213 2018-03-09 05:52:52 +01:00
James Cole
dff2d716a1 Move 2FA to profile #1153 2018-03-09 05:45:22 +01:00
James Cole
ad18b9b81b Remove optional chart (always enabled) 2018-03-09 05:44:35 +01:00
James Cole
eabfe0769b Update explanation for new PW hash check. 2018-03-09 04:48:17 +01:00
James Cole
19f7027718 Fix #1198 2018-03-09 04:47:43 +01:00
James Cole
f537945351 Fix #1236 2018-03-09 04:04:42 +01:00
James Cole
d02372ab90 Fix debug controller for Laravel 5.6 2018-03-08 21:08:26 +01:00
James Cole
1b020c522f Fix currency test. 2018-03-08 21:02:46 +01:00
James Cole
79d0450c77 Implement new password verifier #1187 2018-03-08 20:44:56 +01:00
James Cole
bc32bc8831 Stop Travis from optimising. 2018-03-08 06:13:06 +01:00
James Cole
f68a307eeb Fix file names, ignore installer in test env 2018-03-07 21:04:10 +01:00
James Cole
82e7479cfe Force fresh config var [skip ci] 2018-03-07 21:01:46 +01:00
James Cole
462fe5d89f Force migration [skip ci]Middleware log. [skip ci] 2018-03-07 20:59:32 +01:00
James Cole
b0d8ac83ae Middleware log. [skip ci] 2018-03-07 20:58:54 +01:00
James Cole
d8ac817c91 Middleware log. [skip ci] 2018-03-07 20:56:52 +01:00
James Cole
5105bc6f64 Add more debug logging to output. 2018-03-07 20:55:11 +01:00
James Cole
47c9f1e9b8 Update logging for Laravel 5.6 #1221 2018-03-07 20:47:39 +01:00
James Cole
49d0ed0c1b Fix null pointer. 2018-03-07 20:41:17 +01:00
James Cole
99f5151aab Remove coverage for methods that do not exist. 2018-03-07 20:39:33 +01:00
James Cole
0a056ad02d Upgrade to Laravel 5.6 #1221 2018-03-07 20:37:00 +01:00
James Cole
c76b634d0b Fix #1189 2018-03-07 20:27:10 +01:00
James Cole
a81698d50f Code for #1219 2018-03-07 20:25:58 +01:00
James Cole
bae79063e1 Code to fix #1234 2018-03-07 20:21:51 +01:00
James Cole
fb5323c283 Code to facilitate #1123 2018-03-07 20:21:36 +01:00
James Cole
e2d1de94b7 Fix tests to catch use of repositories 2018-03-07 10:18:50 +01:00
James Cole
7109fd8196 Correct reference to journal description 2018-03-07 10:18:36 +01:00
James Cole
a5fd821e0c Code to implement #1168 and #1197. 2018-03-07 10:18:22 +01:00
James Cole
6c63583e49 Fix test to always select correct journal. 2018-03-07 05:52:45 +01:00
James Cole
dd16e1b784 Expand list of bills for #1102 2018-03-07 05:52:34 +01:00
James Cole
d52d8d7970 Expand exception code and fix demo user redirect. 2018-03-07 05:51:51 +01:00
James Cole
f349aa47ce Merge pull request #1232 from benyanke/patch-1
Allow user to specify port
2018-03-06 05:22:46 +01:00
James Cole
ef4018934c Merge branch 'release/4.7.1.4' 2018-03-06 05:15:04 +01:00
Ben Yanke
951aa9535e Allow user to specify port 2018-03-05 20:49:21 -06:00
James Cole
de1fe36226 Fix #1226 2018-03-05 19:56:50 +01:00
James Cole
64fd36d437 Fix #1227 2018-03-05 19:39:41 +01:00
James Cole
6f9ecc0ffa Update version. [skip ci] 2018-03-05 19:37:06 +01:00
James Cole
a97bfc92e1 Add newlines and strict types 2018-03-05 19:35:58 +01:00
James Cole
0d72fcdf02 Fix #1225 2018-03-05 19:35:39 +01:00
James Cole
0e84ca1df5 Merge branch 'release/4.7.1.3' 2018-03-04 20:57:12 +01:00
James Cole
b28bdda510 Move base href to top of page. 2018-03-04 20:40:49 +01:00
James Cole
72314e2d9f Expand tests for updated triggers / actions. 2018-03-04 17:10:36 +01:00
James Cole
d22fb9f438 Improve tests for transaction rules. 2018-03-04 16:42:29 +01:00
James Cole
04b8552d27 Implement tests. 2018-03-04 16:30:20 +01:00
James Cole
5d6f44cd91 Fix test that could select a deposit or transfer. 2018-03-04 16:07:03 +01:00
James Cole
afc8ad7ff5 Clean test. 2018-03-04 15:57:19 +01:00
James Cole
ae039bf1c7 Update composer file for failed passport thing and update version. 2018-03-04 15:36:06 +01:00
James Cole
8fa25e9d37 Update read me file. 2018-03-04 15:25:43 +01:00
James Cole
0daab491ec Remove unused file [skip ci] 2018-03-04 15:16:37 +01:00
James Cole
4f825bac1a Add newlines to files [skip ci] 2018-03-04 15:16:18 +01:00
James Cole
39c8b79ebb Add newlines to files [skip ci] 2018-03-04 15:14:29 +01:00
James Cole
7d66c90beb Make sure that the API returns all entries of a split transaction. 2018-03-04 14:20:23 +01:00
James Cole
1b8b65582a Merge branch 'release/4.7.1.2' 2018-03-04 13:27:21 +01:00
James Cole
d25971cb44 Actually upgrade version. 2018-03-04 13:26:35 +01:00
James Cole
89a56e661d Merge branch 'hotfix/4.7.1.1' into develop 2018-03-04 13:24:07 +01:00
847 changed files with 20356 additions and 13277 deletions

View File

@@ -0,0 +1,82 @@
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: mysql-pv-export-claim
labels:
app: firefly-local
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 20Gi
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: mysql-pv-upload-claim
labels:
app: firefly-local
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 20Gi
---
apiVersion: apps/v1beta1
kind: Deployment
metadata:
name: firefly-local
namespace: firefly
labels:
app: firefly-local
spec:
selector:
matchLabels:
app: firefly-local
template:
metadata:
labels:
app: firefly-local
spec:
containers:
- image: firefly-local
name: firefly-local
env:
- name: FF_APP_ENV
value: "local"
- name: FF_APP_KEY
value: "S0m3R@nd0mString0f32Ch@rsEx@ct1y"
- name: FF_DB_HOST
value: "172.17.0.9"
- name: FF_DB_NAME
value: "firefly_db"
- name: FF_DB_USER
value: "firefly_db"
- name: FF_DB_PASSWORD
value: "password"
volumeMounts:
- mountPath: "/var/www/firefly-iii/storage/export"
name: mysql-persistent-export
- mountPath: "/var/www/firefly-iii/storage/upload"
name: mysql-persistent-upload
imagePullPolicy: IfNotPresent
volumes:
- name: mysql-persistent-export
persistentVolumeClaim:
claimName: mysql-pv-export-claim
- name: mysql-persistent-upload
persistentVolumeClaim:
claimName: mysql-pv-upload-claim
---
apiVersion: v1
kind: Service
metadata:
name: firefly-local
spec:
ports:
- port: 80
type: NodePort
selector:
app: firefly-local

View File

@@ -0,0 +1,49 @@
apiVersion: v1
kind: Secret
metadata:
name: sql-pass
type: Opaque
data:
password: cGFzc3dvcmQ=
---
apiVersion: apps/v1beta1
kind: Deployment
metadata:
name: mysql
namespace: firefly
labels:
app: mysql
spec:
selector:
matchLabels:
app: mysql
template:
metadata:
labels:
app: mysql
spec:
containers:
- image: mysql
imagePullPolicy: IfNotPresent
name: mysql
env:
- name: MYSQL_ROOT_PASSWORD
valueFrom:
secretKeyRef:
name: sql-pass
key: password
ports:
- containerPort: 3306
name: mysql
---
apiVersion: v1
kind: Service
metadata:
name: mysql
spec:
ports:
- port: 3306
type: NodePort
selector:
app: mysql

View File

@@ -17,11 +17,14 @@ APP_KEY=${FF_APP_KEY}
APP_URL=${APP_URL} APP_URL=${APP_URL}
TRUSTED_PROXIES=${TRUSTED_PROXIES} TRUSTED_PROXIES=${TRUSTED_PROXIES}
# The log channel defines where your log entries go to.
LOG_CHANNEL=${LOG_CHANNEL}
# Database credentials. Make sure the database exists. I recommend a dedicated user for Firefly III # Database credentials. Make sure the database exists. I recommend a dedicated user for Firefly III
# If you use SQLite, set connection to `sqlite` and remove the database, username and password settings. # If you use SQLite, set connection to `sqlite` and remove the database, username and password settings.
DB_CONNECTION=mysql DB_CONNECTION=mysql
DB_HOST=${FF_DB_HOST} DB_HOST=${FF_DB_HOST}
DB_PORT=3306 DB_PORT=${FF_DB_PORT}
DB_DATABASE=${FF_DB_NAME} DB_DATABASE=${FF_DB_NAME}
DB_USERNAME=${FF_DB_USER} DB_USERNAME=${FF_DB_USER}
DB_PASSWORD=${FF_DB_PASSWORD} DB_PASSWORD=${FF_DB_PASSWORD}
@@ -62,6 +65,11 @@ SEND_ERROR_MESSAGE=false
# Set a Mapbox API key here (see mapbox.com) so there might be a map available at various places. # Set a Mapbox API key here (see mapbox.com) so there might be a map available at various places.
MAPBOX_API_KEY=${MAPBOX_API_KEY} MAPBOX_API_KEY=${MAPBOX_API_KEY}
# Set a Fixer IO API key here (see https://fixer.io) to enable live currency exchange rates.
# Please note that this will only work for paid fixer.io accounts because they severly limited
# the free API up to the point where you might as well offer nothing.
FIXER_API_KEY=${FIXER_API_KEY}
# If you wish to track your own behavior over Firefly III, set a valid analytics tracker ID here. # If you wish to track your own behavior over Firefly III, set a valid analytics tracker ID here.
ANALYTICS_ID=${ANALYTICS_ID} ANALYTICS_ID=${ANALYTICS_ID}
@@ -79,7 +87,6 @@ REDIS_PASSWORD=null
REDIS_PORT=6379 REDIS_PORT=6379
CACHE_PREFIX=firefly CACHE_PREFIX=firefly
SEARCH_RESULT_LIMIT=50 SEARCH_RESULT_LIMIT=50
EXCHANGE_RATE_SERVICE=fixerio
PUSHER_KEY= PUSHER_KEY=
PUSHER_SECRET= PUSHER_SECRET=
PUSHER_ID= PUSHER_ID=
@@ -88,3 +95,4 @@ DEMO_PASSWORD=
IS_DOCKER=true IS_DOCKER=true
IS_SANDSTORM=false IS_SANDSTORM=false
IS_HEROKU=false IS_HEROKU=false
TZ=${TZ}

View File

@@ -13,12 +13,19 @@ SITE_OWNER=mail@example.com
# Change it to a string of exactly 32 chars or use command `php artisan key:generate` to generate it # Change it to a string of exactly 32 chars or use command `php artisan key:generate` to generate it
APP_KEY=SomeRandomStringOf32CharsExactly APP_KEY=SomeRandomStringOf32CharsExactly
# Change this value to your preferred time zone.
# Example: Europe/Amsterdam
TZ=UTC
# APP_URL and TRUSTED_PROXIES are useful when using Docker and/or a reverse proxy. # APP_URL and TRUSTED_PROXIES are useful when using Docker and/or a reverse proxy.
APP_URL=http://localhost APP_URL=http://localhost
TRUSTED_PROXIES= TRUSTED_PROXIES=
# The log channel defines where your log entries go to.
LOG_CHANNEL=daily
# Database credentials. Make sure the database exists. I recommend a dedicated user for Firefly III # Database credentials. Make sure the database exists. I recommend a dedicated user for Firefly III
# If you use SQLite, set connection to `sqlite` and remove the database, username and password settings. # For other database types, please see the FAQ: http://firefly-iii.readthedocs.io/en/latest/support/faq.html
DB_CONNECTION=mysql DB_CONNECTION=mysql
DB_HOST=127.0.0.1 DB_HOST=127.0.0.1
DB_PORT=3306 DB_PORT=3306
@@ -62,6 +69,11 @@ SEND_ERROR_MESSAGE=true
# Set a Mapbox API key here (see mapbox.com) so there might be a map available at various places. # Set a Mapbox API key here (see mapbox.com) so there might be a map available at various places.
MAPBOX_API_KEY= MAPBOX_API_KEY=
# Set a Fixer IO API key here (see https://fixer.io) to enable live currency exchange rates.
# Please note that this will only work for paid fixer.io accounts because they severly limited
# the free API up to the point where you might as well offer nothing.
FIXER_API_KEY=
# If you wish to track your own behavior over Firefly III, set a valid analytics tracker ID here. # If you wish to track your own behavior over Firefly III, set a valid analytics tracker ID here.
ANALYTICS_ID= ANALYTICS_ID=
@@ -79,7 +91,6 @@ REDIS_PASSWORD=null
REDIS_PORT=6379 REDIS_PORT=6379
CACHE_PREFIX=firefly CACHE_PREFIX=firefly
SEARCH_RESULT_LIMIT=50 SEARCH_RESULT_LIMIT=50
EXCHANGE_RATE_SERVICE=fixerio
PUSHER_KEY= PUSHER_KEY=
PUSHER_SECRET= PUSHER_SECRET=
PUSHER_ID= PUSHER_ID=

View File

@@ -13,10 +13,17 @@ SITE_OWNER=heroku@example.com
# Change it to a string of exactly 32 chars or use command `php artisan key:generate` to generate it # Change it to a string of exactly 32 chars or use command `php artisan key:generate` to generate it
APP_KEY=7ahyYVPVsmxjdhsweWCauGeJfwc92NP2 APP_KEY=7ahyYVPVsmxjdhsweWCauGeJfwc92NP2
# Change this value to your preferred time zone.
# Example: Europe/Amsterdam
TZ=UTC
# APP_URL and TRUSTED_PROXIES are useful when using Docker and/or a reverse proxy. # APP_URL and TRUSTED_PROXIES are useful when using Docker and/or a reverse proxy.
APP_URL=http://localhost APP_URL=http://localhost
TRUSTED_PROXIES= TRUSTED_PROXIES=
# The log channel defines where your log entries go to.
LOG_CHANNEL=syslog
# Database credentials. Make sure the database exists. I recommend a dedicated user for Firefly III # Database credentials. Make sure the database exists. I recommend a dedicated user for Firefly III
# If you use SQLite, set connection to `sqlite` and remove the database, username and password settings. # If you use SQLite, set connection to `sqlite` and remove the database, username and password settings.
DB_CONNECTION=pgsql DB_CONNECTION=pgsql
@@ -62,6 +69,11 @@ SEND_ERROR_MESSAGE=true
# Set a Mapbox API key here (see mapbox.com) so there might be a map available at various places. # Set a Mapbox API key here (see mapbox.com) so there might be a map available at various places.
MAPBOX_API_KEY= MAPBOX_API_KEY=
# Set a Fixer IO API key here (see https://fixer.io) to enable live currency exchange rates.
# Please note that this will only work for paid fixer.io accounts because they severly limited
# the free API up to the point where you might as well offer nothing.
FIXER_API_KEY=
# If you wish to track your own behavior over Firefly III, set a valid analytics tracker ID here. # If you wish to track your own behavior over Firefly III, set a valid analytics tracker ID here.
ANALYTICS_ID= ANALYTICS_ID=
@@ -79,7 +91,6 @@ REDIS_PASSWORD=null
REDIS_PORT=6379 REDIS_PORT=6379
CACHE_PREFIX=firefly CACHE_PREFIX=firefly
SEARCH_RESULT_LIMIT=50 SEARCH_RESULT_LIMIT=50
EXCHANGE_RATE_SERVICE=fixerio
PUSHER_KEY= PUSHER_KEY=
PUSHER_SECRET= PUSHER_SECRET=
PUSHER_ID= PUSHER_ID=

View File

@@ -13,10 +13,17 @@ SITE_OWNER=sandstorm@example.com
# Change it to a string of exactly 32 chars or use command `php artisan key:generate` to generate it # Change it to a string of exactly 32 chars or use command `php artisan key:generate` to generate it
APP_KEY=SomeRandomStringOf32CharsExactly APP_KEY=SomeRandomStringOf32CharsExactly
# Change this value to your preferred time zone.
# Example: Europe/Amsterdam
TZ=UTC
# APP_URL and TRUSTED_PROXIES are useful when using Docker and/or a reverse proxy. # APP_URL and TRUSTED_PROXIES are useful when using Docker and/or a reverse proxy.
APP_URL=http://localhost APP_URL=http://localhost
TRUSTED_PROXIES= TRUSTED_PROXIES=
# The log channel defines where your log entries go to.
LOG_CHANNEL=syslog
# Database credentials. Make sure the database exists. I recommend a dedicated user for Firefly III # Database credentials. Make sure the database exists. I recommend a dedicated user for Firefly III
# If you use SQLite, set connection to `sqlite` and remove the database, username and password settings. # If you use SQLite, set connection to `sqlite` and remove the database, username and password settings.
DB_CONNECTION=mysql DB_CONNECTION=mysql
@@ -62,6 +69,11 @@ SEND_ERROR_MESSAGE=true
# Set a Mapbox API key here (see mapbox.com) so there might be a map available at various places. # Set a Mapbox API key here (see mapbox.com) so there might be a map available at various places.
MAPBOX_API_KEY= MAPBOX_API_KEY=
# Set a Fixer IO API key here (see https://fixer.io) to enable live currency exchange rates.
# Please note that this will only work for paid fixer.io accounts because they severly limited
# the free API up to the point where you might as well offer nothing.
FIXER_API_KEY=
# If you wish to track your own behavior over Firefly III, set a valid analytics tracker ID here. # If you wish to track your own behavior over Firefly III, set a valid analytics tracker ID here.
ANALYTICS_ID= ANALYTICS_ID=
@@ -79,7 +91,6 @@ REDIS_PASSWORD=null
REDIS_PORT=6379 REDIS_PORT=6379
CACHE_PREFIX=firefly CACHE_PREFIX=firefly
SEARCH_RESULT_LIMIT=50 SEARCH_RESULT_LIMIT=50
EXCHANGE_RATE_SERVICE=fixerio
PUSHER_KEY= PUSHER_KEY=
PUSHER_SECRET= PUSHER_SECRET=
PUSHER_ID= PUSHER_ID=

View File

@@ -1,32 +1,54 @@
# You can leave this on "local". If you change it to production most console commands will ask for extra confirmation.
# Never set it to "testing".
APP_ENV=testing APP_ENV=testing
# Set to true if you want to see debug information in error screens.
APP_DEBUG=true APP_DEBUG=true
APP_NAME=FireflyIII
# This should be your email address
SITE_OWNER=thegrumpydictator+testing@gmail.com
# The encryption key for your database and sessions. Keep this very secure.
# If you generate a new one all existing data must be considered LOST.
# Change it to a string of exactly 32 chars or use command `php artisan key:generate` to generate it
APP_KEY=TestTestTestTestTestTestTestTest APP_KEY=TestTestTestTestTestTestTestTest
APP_LOG=daily
APP_LOG_LEVEL=debug # Change this value to your preferred time zone.
# Example: Europe/Amsterdam
TZ=Europe/Amsterdam
# APP_URL and TRUSTED_PROXIES are useful when using Docker and/or a reverse proxy.
APP_URL=http://localhost APP_URL=http://localhost
TRUSTED_PROXIES= TRUSTED_PROXIES=
DB_CONNECTION=sqlite # The log channel defines where your log entries go to.
DB_HOST=127.0.0.1 LOG_CHANNEL=dailytest
DB_PORT=3306
#DB_DATABASE=firefly
DB_USERNAME=homestead
DB_PASSWORD=
BROADCAST_DRIVER=log # Database credentials. Make sure the database exists. I recommend a dedicated user for Firefly III
# For other database types, please see the FAQ: http://firefly-iii.readthedocs.io/en/latest/support/faq.html
DB_CONNECTION=sqlite
# 'daily' is the default logging mode giving you 5 daily rotated log files in /storage/logs/.
# Several other options exist. You can use 'single' for one big fat error log (not recommended).
# Also available are 'syslog' and 'errorlog' which will log to the system itself.
APP_LOG=daily
# Log level. You can set this from least severe to most severe:
# debug, info, notice, warning, error, critical, alert, emergency
# If you set it to debug your logs will grow large, and fast. If you set it to emergency probably
# nothing will get logged, ever.
APP_LOG_LEVEL=debug
# If you're looking for performance improvements, you could install memcached.
CACHE_DRIVER=file CACHE_DRIVER=file
SESSION_DRIVER=file SESSION_DRIVER=file
QUEUE_DRIVER=sync
# Cookie settings. Should not be necessary to change these.
COOKIE_PATH="/" COOKIE_PATH="/"
COOKIE_DOMAIN= COOKIE_DOMAIN=
COOKIE_SECURE=false COOKIE_SECURE=false
REDIS_HOST=127.0.0.1 # If you want Firefly III to mail you, update these settings
REDIS_PASSWORD=null
REDIS_PORT=6379
MAIL_DRIVER=log MAIL_DRIVER=log
MAIL_HOST=smtp.mailtrap.io MAIL_HOST=smtp.mailtrap.io
MAIL_PORT=2525 MAIL_PORT=2525
@@ -35,26 +57,41 @@ MAIL_USERNAME=null
MAIL_PASSWORD=null MAIL_PASSWORD=null
MAIL_ENCRYPTION=null MAIL_ENCRYPTION=null
# Firefly III can send you the following messages
SEND_REGISTRATION_MAIL=true SEND_REGISTRATION_MAIL=true
SEND_ERROR_MESSAGE=false SEND_ERROR_MESSAGE=false
CACHE_PREFIX=firefly
SEARCH_RESULT_LIMIT=50
EXCHANGE_RATE_SERVICE=fixerio
# Set a Mapbox API key here (see mapbox.com) so there might be a map available at various places.
MAPBOX_API_KEY= MAPBOX_API_KEY=
ANALYTICS_ID=
SITE_OWNER=mail@example.com
USE_ENCRYPTION=true
# Set a Fixer IO API key here (see https://fixer.io) to enable live currency exchange rates.
# Please note that this will only work for paid fixer.io accounts because they severly limited
# the free API up to the point where you might as well offer nothing.
FIXER_API_KEY=
# If you wish to track your own behavior over Firefly III, set a valid analytics tracker ID here.
ANALYTICS_ID=
# Most parts of the database are encrypted by default, but you can turn this off if you want to.
# This makes it easier to migrate your database. Not that some fields will never be decrypted.
USE_ENCRYPTION=false
# Leave the following configuration vars as is.
# Unless you like to tinker and know what you're doing.
APP_NAME=FireflyIII
BROADCAST_DRIVER=log
QUEUE_DRIVER=sync
REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379
CACHE_PREFIX=firefly_tst
SEARCH_RESULT_LIMIT=50
PUSHER_KEY= PUSHER_KEY=
PUSHER_SECRET= PUSHER_SECRET=
PUSHER_ID= PUSHER_ID=
DEMO_USERNAME= DEMO_USERNAME=
DEMO_PASSWORD= DEMO_PASSWORD=
IS_DOCKER=false IS_DOCKER=false
IS_SANDSTORM=false IS_SANDSTORM=false
IS_HEROKU=false IS_HEROKU=false

View File

@@ -1,3 +1,49 @@
# 4.7.2
- [Issue 1123](https://github.com/firefly-iii/firefly-iii/issues/1123) First browser based update routine.
- Add support for Italian.
- [Issue 1232](https://github.com/firefly-iii/firefly-iii/issues/1232) Allow user to specify Docker database port.
- [Issue 1197](https://github.com/firefly-iii/firefly-iii/issues/1197) Beter account list overview
- [Issue 1202](https://github.com/firefly-iii/firefly-iii/issues/1202) Some budgetary warnings
- [Issue 1284](https://github.com/firefly-iii/firefly-iii/issues/1284) Experimental support for bunq import
- [Issue 1248](https://github.com/firefly-iii/firefly-iii/issues/1248) Ability to import BIC, ability to import SEPA fields.
- [Issue 1102](https://github.com/firefly-iii/firefly-iii/issues/1102) Summary line for bills
- More info to debug page.
- [Issue 1186](https://github.com/firefly-iii/firefly-iii/issues/1186) You can see the latest account balance in CRUD forms
- Add Kubernetes YAML files, kindly created by a FF3 user.
- [Issue 1244](https://github.com/firefly-iii/firefly-iii/issues/1244) Better line for "today" marker and add it to other chart as well ([issue 1214](https://github.com/firefly-iii/firefly-iii/issues/1214))
- [Issue 1219](https://github.com/firefly-iii/firefly-iii/issues/1219) Languages in dropdown
- [Issue 1189](https://github.com/firefly-iii/firefly-iii/issues/1189) Inactive accounts get removed from net worth
- [Issue 1220](https://github.com/firefly-iii/firefly-iii/issues/1220) Attachment description and notes migrated to just "notes".
- [Issue 1236](https://github.com/firefly-iii/firefly-iii/issues/1236) Multi currency balance box
- [Issue 1240](https://github.com/firefly-iii/firefly-iii/issues/1240) Better overview for accounts.
- [Issue 1292](https://github.com/firefly-iii/firefly-iii/issues/1292) Removed some charts from the "all"-overview of budgets and categories
- [Issue 1245](https://github.com/firefly-iii/firefly-iii/issues/1245) Improved recognition of IBANs
- Improved import routine.
- Update notifier will wait three days before notifying users.
- [Issue 1300](https://github.com/firefly-iii/firefly-iii/issues/1300) Virtual balance of credit cards does not count for net worth
- [Issue 1247](https://github.com/firefly-iii/firefly-iii/issues/1247) Can now see overspent amount
- [Issue 1221](https://github.com/firefly-iii/firefly-iii/issues/1221) Upgrade to Laravel 5.6
- [Issue 1187](https://github.com/firefly-iii/firefly-iii/issues/1187) Updated the password verifier to use Troy Hunt's new API
- Revenue chart is now on frontpage permanently
- [Issue 1153](https://github.com/firefly-iii/firefly-iii/issues/1153) 2FA settings are in your profile now
- [Issue 1227](https://github.com/firefly-iii/firefly-iii/issues/1227) Can set the timezone in config or in Docker
- [Issue 1294](https://github.com/firefly-iii/firefly-iii/issues/1294) Ability to link a transaction to itself
- Correct reference to journal description in split form.
- [Issue 1234](https://github.com/firefly-iii/firefly-iii/issues/1234) Fix budget page issues in SQLite
- [Issue 1262](https://github.com/firefly-iii/firefly-iii/issues/1262) Can now use double and epty headers in CSV files
- [Issue 1258](https://github.com/firefly-iii/firefly-iii/issues/1258) Fixed a possible date mismatch in piggy banks
- [Issue 1283](https://github.com/firefly-iii/firefly-iii/issues/1283) Bulk delete was broken
- [Issue 1293](https://github.com/firefly-iii/firefly-iii/issues/1293) Layout problem with notes
- [Issue 1257](https://github.com/firefly-iii/firefly-iii/issues/1257) Improve transaction lists query count
- [Issue 1291](https://github.com/firefly-iii/firefly-iii/issues/1291) Fixer IO problems
- [Issue 1239](https://github.com/firefly-iii/firefly-iii/issues/1239) Could not edit expense or revenue accounts ([issue 1298](https://github.com/firefly-iii/firefly-iii/issues/1298))
- [Issue 1297](https://github.com/firefly-iii/firefly-iii/issues/1297) Could not convert to withdrawal
- [Issue 1226](https://github.com/firefly-iii/firefly-iii/issues/1226) Category overview in default report shows no income.
- Various other bugs and problems ([issue 1198](https://github.com/firefly-iii/firefly-iii/issues/1198), [issue 1213](https://github.com/firefly-iii/firefly-iii/issues/1213), [issue 1237](https://github.com/firefly-iii/firefly-iii/issues/1237), [issue 1238](https://github.com/firefly-iii/firefly-iii/issues/1238), [issue 1199](https://github.com/firefly-iii/firefly-iii/issues/1199), [issue 1200](https://github.com/firefly-iii/firefly-iii/issues/1200))
### Security
- Fixed an issue with token validation on the command line.
# 4.7.1 # 4.7.1
- A brand new API. Read about it in the [documentation](http://firefly-iii.readthedocs.io/en/latest/). - A brand new API. Read about it in the [documentation](http://firefly-iii.readthedocs.io/en/latest/).
- Add support for Spanish. [issue 1194](https://github.com/firefly-iii/firefly-iii/issues/1194) - Add support for Spanish. [issue 1194](https://github.com/firefly-iii/firefly-iii/issues/1194)

View File

@@ -15,8 +15,8 @@ const pkgdef :Spk.PackageDefinition = (
manifest = ( manifest = (
appTitle = (defaultText = "Firefly III"), appTitle = (defaultText = "Firefly III"),
appVersion = 9, appVersion = 10,
appMarketingVersion = (defaultText = "4.7.1"), appMarketingVersion = (defaultText = "4.7.2"),
actions = [ actions = [
# Define your "new document" handlers here. # Define your "new document" handlers here.

View File

@@ -14,12 +14,17 @@ apt-get install -y python-software-properties software-properties-common
# install all languages # install all languages
sed -i 's/# de_DE.UTF-8 UTF-8/de_DE.UTF-8 UTF-8/g' /etc/locale.gen sed -i 's/# de_DE.UTF-8 UTF-8/de_DE.UTF-8 UTF-8/g' /etc/locale.gen
sed -i 's/# es_ES.UTF-8 UTF-8/es_ES.UTF-8 UTF-8/g' /etc/locale.gen
sed -i 's/# fr_FR.UTF-8 UTF-8/fr_FR.UTF-8 UTF-8/g' /etc/locale.gen sed -i 's/# fr_FR.UTF-8 UTF-8/fr_FR.UTF-8 UTF-8/g' /etc/locale.gen
sed -i 's/# id_ID.UTF-8 UTF-8/id_ID.UTF-8 UTF-8/g' /etc/locale.gen sed -i 's/# id_ID.UTF-8 UTF-8/id_ID.UTF-8 UTF-8/g' /etc/locale.gen
sed -i 's/# it_IT.UTF-8 UTF-8/it_IT.UTF-8 UTF-8/g' /etc/locale.gen
sed -i 's/# nl_NL.UTF-8 UTF-8/nl_NL.UTF-8 UTF-8/g' /etc/locale.gen sed -i 's/# nl_NL.UTF-8 UTF-8/nl_NL.UTF-8 UTF-8/g' /etc/locale.gen
sed -i 's/# pl_PL.UTF-8 UTF-8/pl_PL.UTF-8 UTF-8/g' /etc/locale.gen sed -i 's/# pl_PL.UTF-8 UTF-8/pl_PL.UTF-8 UTF-8/g' /etc/locale.gen
sed -i 's/# pt_BR.UTF-8 UTF-8/pt_BR.UTF-8 UTF-8/g' /etc/locale.gen
sed -i 's/# ru_RU.UTF-8 UTF-8/ru_RU.UTF-8 UTF-8/g' /etc/locale.gen sed -i 's/# ru_RU.UTF-8 UTF-8/ru_RU.UTF-8 UTF-8/g' /etc/locale.gen
sed -i 's/# tr_TR.UTF-8 UTF-8/tr_TR.UTF-8 UTF-8/g' /etc/locale.gen sed -i 's/# tr_TR.UTF-8 UTF-8/tr_TR.UTF-8 UTF-8/g' /etc/locale.gen
dpkg-reconfigure --frontend=noninteractive locales dpkg-reconfigure --frontend=noninteractive locales

View File

@@ -12,21 +12,19 @@ install:
- composer update --no-scripts - composer update --no-scripts
- cp .env.testing .env - cp .env.testing .env
- php artisan clear-compiled - php artisan clear-compiled
- php artisan optimize
- php artisan env - php artisan env
- cp .env.testing .env - cp .env.testing .env
- wget -q https://github.com/firefly-iii/test-data/raw/master/storage/database.sqlite -O storage/database/database.sqlite - wget -q https://github.com/firefly-iii/test-data/raw/master/storage/database.sqlite -O storage/database/database.sqlite
- mkdir -p build/logs - mkdir -p build/logs
script: script:
- phpunit -c phpunit.coverage.xml - ./vendor/bin/phpunit -c phpunit.coverage.xml
after_success: after_success:
- travis_retry php vendor/bin/php-coveralls -x storage/build/clover-all.xml - travis_retry php vendor/bin/php-coveralls -x storage/build/clover-all.xml
- bash <(curl -s https://codecov.io/bash) -f storage/build/clover-all.xml
# safelist # safelist
branches: branches:
only: only:
- develop - develop
- master - master

View File

@@ -31,7 +31,7 @@ RUN docker-php-ext-install -j$(nproc) curl gd intl json readline tidy zip bcmath
RUN echo "de_DE.UTF-8 UTF-8\nen_US.UTF-8 UTF-8\nfr_FR.UTF-8 UTF-8\nid_ID.UTF-8 UTF-8\nnl_NL.UTF-8 UTF-8\npl_PL.UTF-8 UTF-8" > /etc/locale.gen && locale-gen RUN echo "de_DE.UTF-8 UTF-8\nen_US.UTF-8 UTF-8\nfr_FR.UTF-8 UTF-8\nid_ID.UTF-8 UTF-8\nnl_NL.UTF-8 UTF-8\npl_PL.UTF-8 UTF-8" > /etc/locale.gen && locale-gen
# copy Apache config to correct spot. # copy Apache config to correct spot.
COPY ./docker/apache2.conf /etc/apache2/apache2.conf COPY ./.deploy/docker/apache2.conf /etc/apache2/apache2.conf
# Enable apache mod rewrite.. # Enable apache mod rewrite..
RUN a2enmod rewrite RUN a2enmod rewrite
@@ -46,7 +46,7 @@ VOLUME $FIREFLY_PATH/storage/export $FIREFLY_PATH/storage/upload
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
# Enable default site (Firefly III) # Enable default site (Firefly III)
COPY ./docker/apache-firefly.conf /etc/apache2/sites-available/000-default.conf COPY ./.deploy/docker/apache-firefly.conf /etc/apache2/sites-available/000-default.conf
# Make sure we own Firefly III directory # Make sure we own Firefly III directory
RUN chown -R www-data:www-data /var/www && chmod -R 775 $FIREFLY_PATH/storage RUN chown -R www-data:www-data /var/www && chmod -R 775 $FIREFLY_PATH/storage
@@ -58,4 +58,4 @@ RUN composer install --prefer-dist --no-dev --no-scripts --no-suggest
EXPOSE 80 EXPOSE 80
# Run entrypoint thing # Run entrypoint thing
ENTRYPOINT ["docker/entrypoint.sh"] ENTRYPOINT [".deploy/docker/entrypoint.sh"]

View File

@@ -1,4 +1,5 @@
<?php <?php
declare(strict_types=1);
/** /**
* AboutController.php * AboutController.php
* Copyright (c) 2018 thegrumpydictator@gmail.com * Copyright (c) 2018 thegrumpydictator@gmail.com
@@ -19,7 +20,6 @@
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>. * along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/ */
declare(strict_types=1);
namespace FireflyIII\Api\V1\Controllers; namespace FireflyIII\Api\V1\Controllers;
@@ -30,23 +30,11 @@ use League\Fractal\Manager;
use League\Fractal\Resource\Item; use League\Fractal\Resource\Item;
use League\Fractal\Serializer\JsonApiSerializer; use League\Fractal\Serializer\JsonApiSerializer;
/** /**
* Class AboutController * Class AboutController
*/ */
class AboutController extends Controller class AboutController extends Controller
{ {
/**
* AccountController constructor.
*
* @throws \FireflyIII\Exceptions\FireflyException
*/
public function __construct()
{
parent::__construct();
}
/** /**
* @return \Illuminate\Http\JsonResponse * @return \Illuminate\Http\JsonResponse
*/ */
@@ -55,7 +43,7 @@ class AboutController extends Controller
$search = ['~', '#']; $search = ['~', '#'];
$replace = ['\~', '# ']; $replace = ['\~', '# '];
$phpVersion = str_replace($search, $replace, PHP_VERSION); $phpVersion = str_replace($search, $replace, PHP_VERSION);
$phpOs = str_replace($search, $replace, php_uname()); $phpOs = str_replace($search, $replace, PHP_OS);
$currentDriver = DB::getDriverName(); $currentDriver = DB::getDriverName();
$data $data
= [ = [
@@ -64,7 +52,6 @@ class AboutController extends Controller
'php_version' => $phpVersion, 'php_version' => $phpVersion,
'os' => $phpOs, 'os' => $phpOs,
'driver' => $currentDriver, 'driver' => $currentDriver,
]; ];
return response()->json(['data' => $data], 200)->header('Content-Type', 'application/vnd.api+json'); return response()->json(['data' => $data], 200)->header('Content-Type', 'application/vnd.api+json');
@@ -84,5 +71,4 @@ class AboutController extends Controller
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', 'application/vnd.api+json'); return response()->json($manager->createData($resource)->toArray())->header('Content-Type', 'application/vnd.api+json');
} }
}
}

View File

@@ -1,4 +1,5 @@
<?php <?php
declare(strict_types=1);
/** /**
* AccountController.php * AccountController.php
* Copyright (c) 2018 thegrumpydictator@gmail.com * Copyright (c) 2018 thegrumpydictator@gmail.com
@@ -19,7 +20,6 @@
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>. * along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/ */
declare(strict_types=1);
namespace FireflyIII\Api\V1\Controllers; namespace FireflyIII\Api\V1\Controllers;
@@ -43,7 +43,6 @@ use Preferences;
*/ */
class AccountController extends Controller class AccountController extends Controller
{ {
/** @var CurrencyRepositoryInterface */ /** @var CurrencyRepositoryInterface */
private $currencyRepository; private $currencyRepository;
/** @var AccountRepositoryInterface */ /** @var AccountRepositoryInterface */
@@ -59,7 +58,7 @@ class AccountController extends Controller
parent::__construct(); parent::__construct();
$this->middleware( $this->middleware(
function ($request, $next) { function ($request, $next) {
/** @var AccountRepositoryInterface repository */ // @var AccountRepositoryInterface repository
$this->repository = app(AccountRepositoryInterface::class); $this->repository = app(AccountRepositoryInterface::class);
$this->repository->setUser(auth()->user()); $this->repository->setUser(auth()->user());
@@ -74,7 +73,7 @@ class AccountController extends Controller
/** /**
* Remove the specified resource from storage. * Remove the specified resource from storage.
* *
* @param \FireflyIII\Models\Account $account * @param \FireflyIII\Models\Account $account
* *
* @return \Illuminate\Http\Response * @return \Illuminate\Http\Response
*/ */
@@ -95,16 +94,16 @@ class AccountController extends Controller
public function index(Request $request) public function index(Request $request)
{ {
// create some objects: // create some objects:
$manager = new Manager(); $manager = new Manager();
$baseUrl = $request->getSchemeAndHttpHost() . '/api/v1'; $baseUrl = $request->getSchemeAndHttpHost() . '/api/v1';
// read type from URI // read type from URI
$type = $request->get('type') ?? 'all'; $type = $request->get('type') ?? 'all';
$this->parameters->set('type', $type); $this->parameters->set('type', $type);
// types to get, page size: // types to get, page size:
$types = $this->mapTypes($this->parameters->get('type')); $types = $this->mapTypes($this->parameters->get('type'));
$pageSize = intval(Preferences::getForUser(auth()->user(), 'listPageSize', 50)->data); $pageSize = (int)Preferences::getForUser(auth()->user(), 'listPageSize', 50)->data;
// get list of accounts. Count it and split it. // get list of accounts. Count it and split it.
$collection = $this->repository->getAccountsByType($types); $collection = $this->repository->getAccountsByType($types);
@@ -153,9 +152,9 @@ class AccountController extends Controller
{ {
$data = $request->getAll(); $data = $request->getAll();
// if currency ID is 0, find the currency by the code: // if currency ID is 0, find the currency by the code:
if ($data['currency_id'] === 0) { if (0 === $data['currency_id']) {
$currency = $this->currencyRepository->findByCodeNull($data['currency_code']); $currency = $this->currencyRepository->findByCodeNull($data['currency_code']);
$data['currency_id'] = is_null($currency) ? 0 : $currency->id; $data['currency_id'] = null === $currency ? 0 : $currency->id;
} }
$account = $this->repository->store($data); $account = $this->repository->store($data);
$manager = new Manager(); $manager = new Manager();
@@ -165,7 +164,6 @@ class AccountController extends Controller
$resource = new Item($account, new AccountTransformer($this->parameters), 'accounts'); $resource = new Item($account, new AccountTransformer($this->parameters), 'accounts');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', 'application/vnd.api+json'); return response()->json($manager->createData($resource)->toArray())->header('Content-Type', 'application/vnd.api+json');
} }
/** /**
@@ -180,9 +178,9 @@ class AccountController extends Controller
{ {
$data = $request->getAll(); $data = $request->getAll();
// if currency ID is 0, find the currency by the code: // if currency ID is 0, find the currency by the code:
if ($data['currency_id'] === 0) { if (0 === $data['currency_id']) {
$currency = $this->currencyRepository->findByCodeNull($data['currency_code']); $currency = $this->currencyRepository->findByCodeNull($data['currency_code']);
$data['currency_id'] = is_null($currency) ? 0 : $currency->id; $data['currency_id'] = null === $currency ? 0 : $currency->id;
} }
// set correct type: // set correct type:
$data['type'] = config('firefly.shortNamesByFullName.' . $account->accountType->type); $data['type'] = config('firefly.shortNamesByFullName.' . $account->accountType->type);
@@ -260,4 +258,4 @@ class AccountController extends Controller
return $types['all']; // @codeCoverageIgnore return $types['all']; // @codeCoverageIgnore
} }
} }

View File

@@ -1,4 +1,5 @@
<?php <?php
declare(strict_types=1);
/** /**
* BillController.php * BillController.php
* Copyright (c) 2018 thegrumpydictator@gmail.com * Copyright (c) 2018 thegrumpydictator@gmail.com
@@ -18,7 +19,6 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>. * along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/ */
declare(strict_types=1);
namespace FireflyIII\Api\V1\Controllers; namespace FireflyIII\Api\V1\Controllers;
@@ -86,7 +86,7 @@ class BillController extends Controller
*/ */
public function index(Request $request) public function index(Request $request)
{ {
$pageSize = intval(Preferences::getForUser(auth()->user(), 'listPageSize', 50)->data); $pageSize = (int)Preferences::getForUser(auth()->user(), 'listPageSize', 50)->data;
$paginator = $this->repository->getPaginator($pageSize); $paginator = $this->repository->getPaginator($pageSize);
/** @var Collection $bills */ /** @var Collection $bills */
$bills = $paginator->getCollection(); $bills = $paginator->getCollection();
@@ -127,10 +127,12 @@ class BillController extends Controller
* @param BillRequest $request * @param BillRequest $request
* *
* @return \Illuminate\Http\JsonResponse * @return \Illuminate\Http\JsonResponse
* @throws FireflyException
*/ */
public function store(BillRequest $request) public function store(BillRequest $request)
{ {
$bill = $this->repository->store($request->getAll()); $bill = $this->repository->store($request->getAll());
if(null !== $bill) {
$manager = new Manager(); $manager = new Manager();
$baseUrl = $request->getSchemeAndHttpHost() . '/api/v1'; $baseUrl = $request->getSchemeAndHttpHost() . '/api/v1';
$manager->setSerializer(new JsonApiSerializer($baseUrl)); $manager->setSerializer(new JsonApiSerializer($baseUrl));
@@ -138,6 +140,8 @@ class BillController extends Controller
$resource = new Item($bill, new BillTransformer($this->parameters), 'bills'); $resource = new Item($bill, new BillTransformer($this->parameters), 'bills');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', 'application/vnd.api+json'); return response()->json($manager->createData($resource)->toArray())->header('Content-Type', 'application/vnd.api+json');
}
throw new FireflyException('Could not store new bill.');
} }

View File

@@ -1,4 +1,5 @@
<?php <?php
declare(strict_types=1);
/** /**
* Controller.php * Controller.php
* Copyright (c) 2018 thegrumpydictator@gmail.com * Copyright (c) 2018 thegrumpydictator@gmail.com
@@ -18,7 +19,6 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>. * along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/ */
declare(strict_types=1);
namespace FireflyIII\Api\V1\Controllers; namespace FireflyIII\Api\V1\Controllers;
@@ -30,10 +30,12 @@ use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
use Illuminate\Foundation\Bus\DispatchesJobs; use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Foundation\Validation\ValidatesRequests; use Illuminate\Foundation\Validation\ValidatesRequests;
use Illuminate\Routing\Controller as BaseController; use Illuminate\Routing\Controller as BaseController;
use Log;
use Symfony\Component\HttpFoundation\ParameterBag; use Symfony\Component\HttpFoundation\ParameterBag;
/** /**
* Class Controller. * Class Controller.
*
* @codeCoverageIgnore * @codeCoverageIgnore
*/ */
class Controller extends BaseController class Controller extends BaseController
@@ -70,7 +72,7 @@ class Controller extends BaseController
$return = '?'; $return = '?';
$params = []; $params = [];
foreach ($this->parameters as $key => $value) { foreach ($this->parameters as $key => $value) {
if($key === 'page') { if ($key === 'page') {
continue; continue;
} }
if ($value instanceof Carbon) { if ($value instanceof Carbon) {
@@ -105,11 +107,12 @@ class Controller extends BaseController
foreach ($dates as $field) { foreach ($dates as $field) {
$date = request()->get($field); $date = request()->get($field);
$obj = null; $obj = null;
if (!is_null($date)) { if (null !== $date) {
try { try {
$obj = new Carbon($date); $obj = new Carbon($date);
} catch (InvalidDateException $e) { } catch (InvalidDateException $e) {
// don't care // don't care
Log::error(sprintf('Invalid date exception in API controller: %s', $e->getMessage()));
} }
} }
$bag->set($field, $obj); $bag->set($field, $obj);

View File

@@ -1,4 +1,5 @@
<?php <?php
declare(strict_types=1);
/** /**
* TransactionController.php * TransactionController.php
* Copyright (c) 2018 thegrumpydictator@gmail.com * Copyright (c) 2018 thegrumpydictator@gmail.com
@@ -19,7 +20,6 @@
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>. * along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/ */
declare(strict_types=1);
namespace FireflyIII\Api\V1\Controllers; namespace FireflyIII\Api\V1\Controllers;
@@ -37,7 +37,6 @@ use Illuminate\Support\Collection;
use League\Fractal\Manager; use League\Fractal\Manager;
use League\Fractal\Pagination\IlluminatePaginatorAdapter; use League\Fractal\Pagination\IlluminatePaginatorAdapter;
use League\Fractal\Resource\Collection as FractalCollection; use League\Fractal\Resource\Collection as FractalCollection;
use League\Fractal\Resource\Item;
use League\Fractal\Serializer\JsonApiSerializer; use League\Fractal\Serializer\JsonApiSerializer;
use Log; use Log;
use Preferences; use Preferences;
@@ -92,7 +91,7 @@ class TransactionController extends Controller
*/ */
public function index(Request $request) public function index(Request $request)
{ {
$pageSize = intval(Preferences::getForUser(auth()->user(), 'listPageSize', 50)->data); $pageSize = (int)Preferences::getForUser(auth()->user(), 'listPageSize', 50)->data;
// read type from URI // read type from URI
$type = $request->get('type') ?? 'default'; $type = $request->get('type') ?? 'default';
@@ -116,7 +115,7 @@ class TransactionController extends Controller
$collector->removeFilter(InternalTransferFilter::class); $collector->removeFilter(InternalTransferFilter::class);
} }
if (!is_null($this->parameters->get('start')) && !is_null($this->parameters->get('end'))) { if (null !== $this->parameters->get('start') && null !== $this->parameters->get('end')) {
$collector->setRange($this->parameters->get('start'), $this->parameters->get('end')); $collector->setRange($this->parameters->get('start'), $this->parameters->get('end'));
} }
$collector->setLimit($pageSize)->setPage($this->parameters->get('page')); $collector->setLimit($pageSize)->setPage($this->parameters->get('page'));
@@ -166,13 +165,15 @@ class TransactionController extends Controller
} }
$transactions = $collector->getJournals(); $transactions = $collector->getJournals();
$resource = new Item($transactions->first(), new TransactionTransformer($this->parameters), 'transactions'); $resource = new FractalCollection($transactions, new TransactionTransformer($this->parameters), 'transactions');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', 'application/vnd.api+json'); return response()->json($manager->createData($resource)->toArray())->header('Content-Type', 'application/vnd.api+json');
} }
/** /**
* @param TransactionRequest $request * @param TransactionRequest $request
*
* @param JournalRepositoryInterface $repository
* *
* @return \Illuminate\Http\JsonResponse * @return \Illuminate\Http\JsonResponse
*/ */
@@ -330,4 +331,4 @@ class TransactionController extends Controller
return $types['default']; // @codeCoverageIgnore return $types['default']; // @codeCoverageIgnore
} }
} }

View File

@@ -1,4 +1,5 @@
<?php <?php
declare(strict_types=1);
/** /**
* UserController.php * UserController.php
* Copyright (c) 2018 thegrumpydictator@gmail.com * Copyright (c) 2018 thegrumpydictator@gmail.com
@@ -19,7 +20,6 @@
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>. * along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/ */
declare(strict_types=1);
namespace FireflyIII\Api\V1\Controllers; namespace FireflyIII\Api\V1\Controllers;
@@ -70,6 +70,7 @@ class UserController extends Controller
* @param \FireflyIII\User $user * @param \FireflyIII\User $user
* *
* @return \Illuminate\Http\Response * @return \Illuminate\Http\Response
* @throws \Symfony\Component\HttpFoundation\File\Exception\AccessDeniedException
*/ */
public function delete(User $user) public function delete(User $user)
{ {
@@ -91,7 +92,7 @@ class UserController extends Controller
public function index(Request $request) public function index(Request $request)
{ {
// user preferences // user preferences
$pageSize = intval(Preferences::getForUser(auth()->user(), 'listPageSize', 50)->data); $pageSize = (int)Preferences::getForUser(auth()->user(), 'listPageSize', 50)->data;
// make manager // make manager
$manager = new Manager(); $manager = new Manager();
@@ -189,4 +190,4 @@ class UserController extends Controller
} }
} }

View File

@@ -1,4 +1,5 @@
<?php <?php
declare(strict_types=1);
/** /**
* AccountRequest.php * AccountRequest.php
* Copyright (c) 2018 thegrumpydictator@gmail.com * Copyright (c) 2018 thegrumpydictator@gmail.com
@@ -19,7 +20,6 @@
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>. * along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/ */
declare(strict_types=1);
namespace FireflyIII\Api\V1\Requests; namespace FireflyIII\Api\V1\Requests;
@@ -70,9 +70,9 @@ class AccountRequest extends Request
*/ */
public function rules(): array public function rules(): array
{ {
$accountRoles = join(',', config('firefly.accountRoles')); $accountRoles = implode(',', config('firefly.accountRoles'));
$types = join(',', array_keys(config('firefly.subTitlesByIdentifier'))); $types = implode(',', array_keys(config('firefly.subTitlesByIdentifier')));
$ccPaymentTypes = join(',', array_keys(config('firefly.ccTypes'))); $ccPaymentTypes = implode(',', array_keys(config('firefly.ccTypes')));
$rules = [ $rules = [
'name' => 'required|min:1|uniqueAccountForUser', 'name' => 'required|min:1|uniqueAccountForUser',
'opening_balance' => 'numeric|required_with:opening_balance_date|nullable', 'opening_balance' => 'numeric|required_with:opening_balance_date|nullable',
@@ -104,4 +104,4 @@ class AccountRequest extends Request
return $rules; return $rules;
} }
} }

View File

@@ -1,4 +1,5 @@
<?php <?php
declare(strict_types=1);
/** /**
* BillRequest.php * BillRequest.php
* Copyright (c) 2018 thegrumpydictator@gmail.com * Copyright (c) 2018 thegrumpydictator@gmail.com
@@ -19,7 +20,6 @@
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>. * along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/ */
declare(strict_types=1);
namespace FireflyIII\Api\V1\Requests; namespace FireflyIII\Api\V1\Requests;
@@ -108,12 +108,12 @@ class BillRequest extends Request
$validator->after( $validator->after(
function (Validator $validator) { function (Validator $validator) {
$data = $validator->getData(); $data = $validator->getData();
$min = floatval($data['amount_min'] ?? 0); $min = (float)($data['amount_min'] ?? 0);
$max = floatval($data['amount_max'] ?? 0); $max = (float)($data['amount_max'] ?? 0);
if ($min > $max) { if ($min > $max) {
$validator->errors()->add('amount_min', trans('validation.amount_min_over_max')); $validator->errors()->add('amount_min', trans('validation.amount_min_over_max'));
} }
} }
); );
} }
} }

View File

@@ -1,4 +1,5 @@
<?php <?php
declare(strict_types=1);
/** /**
* Request.php * Request.php
* Copyright (c) 2018 thegrumpydictator@gmail.com * Copyright (c) 2018 thegrumpydictator@gmail.com
@@ -18,11 +19,11 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>. * along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/ */
declare(strict_types=1);
namespace FireflyIII\Api\V1\Requests; namespace FireflyIII\Api\V1\Requests;
use FireflyIII\Http\Requests\Request as FireflyIIIRequest; use FireflyIII\Http\Requests\Request as FireflyIIIRequest;
/** /**
* Class Request. * Class Request.
*/ */

View File

@@ -1,4 +1,5 @@
<?php <?php
declare(strict_types=1);
/** /**
* TransactionRequest.php * TransactionRequest.php
* Copyright (c) 2018 thegrumpydictator@gmail.com * Copyright (c) 2018 thegrumpydictator@gmail.com
@@ -19,7 +20,6 @@
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>. * along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/ */
declare(strict_types=1);
namespace FireflyIII\Api\V1\Requests; namespace FireflyIII\Api\V1\Requests;
@@ -80,19 +80,19 @@ class TransactionRequest extends Request
$array = [ $array = [
'description' => $transaction['description'] ?? null, 'description' => $transaction['description'] ?? null,
'amount' => $transaction['amount'], 'amount' => $transaction['amount'],
'currency_id' => isset($transaction['currency_id']) ? intval($transaction['currency_id']) : null, 'currency_id' => isset($transaction['currency_id']) ? (int)$transaction['currency_id'] : null,
'currency_code' => isset($transaction['currency_code']) ? $transaction['currency_code'] : null, 'currency_code' => $transaction['currency_code'] ?? null,
'foreign_amount' => $transaction['foreign_amount'] ?? null, 'foreign_amount' => $transaction['foreign_amount'] ?? null,
'foreign_currency_id' => isset($transaction['foreign_currency_id']) ? intval($transaction['foreign_currency_id']) : null, 'foreign_currency_id' => isset($transaction['foreign_currency_id']) ? (int)$transaction['foreign_currency_id'] : null,
'foreign_currency_code' => $transaction['foreign_currency_code'] ?? null, 'foreign_currency_code' => $transaction['foreign_currency_code'] ?? null,
'budget_id' => isset($transaction['budget_id']) ? intval($transaction['budget_id']) : null, 'budget_id' => isset($transaction['budget_id']) ? (int)$transaction['budget_id'] : null,
'budget_name' => $transaction['budget_name'] ?? null, 'budget_name' => $transaction['budget_name'] ?? null,
'category_id' => isset($transaction['category_id']) ? intval($transaction['category_id']) : null, 'category_id' => isset($transaction['category_id']) ? (int)$transaction['category_id'] : null,
'category_name' => $transaction['category_name'] ?? null, 'category_name' => $transaction['category_name'] ?? null,
'source_id' => isset($transaction['source_id']) ? intval($transaction['source_id']) : null, 'source_id' => isset($transaction['source_id']) ? (int)$transaction['source_id'] : null,
'source_name' => isset($transaction['source_name']) ? strval($transaction['source_name']) : null, 'source_name' => isset($transaction['source_name']) ? (string)$transaction['source_name'] : null,
'destination_id' => isset($transaction['destination_id']) ? intval($transaction['destination_id']) : null, 'destination_id' => isset($transaction['destination_id']) ? (int)$transaction['destination_id'] : null,
'destination_name' => isset($transaction['destination_name']) ? strval($transaction['destination_name']) : null, 'destination_name' => isset($transaction['destination_name']) ? (string)$transaction['destination_name'] : null,
'reconciled' => $transaction['reconciled'] ?? false, 'reconciled' => $transaction['reconciled'] ?? false,
'identifier' => $index, 'identifier' => $index,
]; ];
@@ -168,6 +168,7 @@ class TransactionRequest extends Request
* @param Validator $validator * @param Validator $validator
* *
* @return void * @return void
* @throws \FireflyIII\Exceptions\FireflyException
*/ */
public function withValidator(Validator $validator): void public function withValidator(Validator $validator): void
{ {
@@ -192,17 +193,19 @@ class TransactionRequest extends Request
* @param null|string $accountName * @param null|string $accountName
* @param string $idField * @param string $idField
* @param string $nameField * @param string $nameField
*
* @return null|Account
*/ */
protected function assetAccountExists(Validator $validator, ?int $accountId, ?string $accountName, string $idField, string $nameField): void protected function assetAccountExists(Validator $validator, ?int $accountId, ?string $accountName, string $idField, string $nameField): ?Account
{ {
$accountId = intval($accountId); $accountId = (int)$accountId;
$accountName = strval($accountName); $accountName = (string)$accountName;
// both empty? hard exit. // both empty? hard exit.
if ($accountId < 1 && strlen($accountName) === 0) { if ($accountId < 1 && strlen($accountName) === 0) {
$validator->errors()->add($idField, trans('validation.filled', ['attribute' => $idField])); $validator->errors()->add($idField, trans('validation.filled', ['attribute' => $idField]));
return; return null;
} }
// ID belongs to user and is asset account: // ID belongs to user and is asset account:
/** @var AccountRepositoryInterface $repository */ /** @var AccountRepositoryInterface $repository */
@@ -215,19 +218,21 @@ class TransactionRequest extends Request
if ($first->accountType->type !== AccountType::ASSET) { if ($first->accountType->type !== AccountType::ASSET) {
$validator->errors()->add($idField, trans('validation.belongs_user')); $validator->errors()->add($idField, trans('validation.belongs_user'));
return; return null;
} }
// we ignore the account name at this point. // we ignore the account name at this point.
return; return $first;
} }
$account = $repository->findByName($accountName, [AccountType::ASSET]); $account = $repository->findByNameNull($accountName, [AccountType::ASSET]);
if (is_null($account)) { if (null === $account) {
$validator->errors()->add($nameField, trans('validation.belongs_user')); $validator->errors()->add($nameField, trans('validation.belongs_user'));
return null;
} }
return; return $account;
} }
/** /**
@@ -255,10 +260,10 @@ class TransactionRequest extends Request
{ {
$data = $validator->getData(); $data = $validator->getData();
$transactions = $data['transactions'] ?? []; $transactions = $data['transactions'] ?? [];
$journalDescription = strval($data['description'] ?? ''); $journalDescription = (string)($data['description'] ?? '');
$validDescriptions = 0; $validDescriptions = 0;
foreach ($transactions as $index => $transaction) { foreach ($transactions as $index => $transaction) {
if (strlen(strval($transaction['description'] ?? '')) > 0) { if (strlen((string)($transaction['description'] ?? '')) > 0) {
$validDescriptions++; $validDescriptions++;
} }
} }
@@ -281,7 +286,7 @@ class TransactionRequest extends Request
$data = $validator->getData(); $data = $validator->getData();
$transactions = $data['transactions'] ?? []; $transactions = $data['transactions'] ?? [];
foreach ($transactions as $index => $transaction) { foreach ($transactions as $index => $transaction) {
$description = strval($transaction['description'] ?? ''); $description = (string)($transaction['description'] ?? '');
// filled description is mandatory for split transactions. // filled description is mandatory for split transactions.
if (count($transactions) > 1 && strlen($description) === 0) { if (count($transactions) > 1 && strlen($description) === 0) {
$validator->errors()->add( $validator->errors()->add(
@@ -301,9 +306,9 @@ class TransactionRequest extends Request
{ {
$data = $validator->getData(); $data = $validator->getData();
$transactions = $data['transactions'] ?? []; $transactions = $data['transactions'] ?? [];
$journalDescription = strval($data['description'] ?? ''); $journalDescription = (string)($data['description'] ?? '');
foreach ($transactions as $index => $transaction) { foreach ($transactions as $index => $transaction) {
$description = strval($transaction['description'] ?? ''); $description = (string)($transaction['description'] ?? '');
// description cannot be equal to journal description. // description cannot be equal to journal description.
if ($description === $journalDescription) { if ($description === $journalDescription) {
$validator->errors()->add('transactions.' . $index . '.description', trans('validation.equal_description')); $validator->errors()->add('transactions.' . $index . '.description', trans('validation.equal_description'));
@@ -342,13 +347,16 @@ class TransactionRequest extends Request
* @param int|null $accountId * @param int|null $accountId
* @param null|string $accountName * @param null|string $accountName
* @param string $idField * @param string $idField
*
* @return null|Account
*/ */
protected function opposingAccountExists(Validator $validator, string $type, ?int $accountId, ?string $accountName, string $idField): void { protected function opposingAccountExists(Validator $validator, string $type, ?int $accountId, ?string $accountName, string $idField): ?Account
$accountId = intval($accountId); {
$accountName = strval($accountName); $accountId = (int)$accountId;
$accountName = (string)$accountName;
// both empty? done! // both empty? done!
if ($accountId < 1 && strlen($accountName) === 0) { if ($accountId < 1 && strlen($accountName) === 0) {
return; return null;
} }
if ($accountId !== 0) { if ($accountId !== 0) {
// ID belongs to user and is $type account: // ID belongs to user and is $type account:
@@ -362,16 +370,16 @@ class TransactionRequest extends Request
if ($first->accountType->type !== $type) { if ($first->accountType->type !== $type) {
$validator->errors()->add($idField, trans('validation.belongs_user')); $validator->errors()->add($idField, trans('validation.belongs_user'));
return; return null;
} }
// we ignore the account name at this point. // we ignore the account name at this point.
return; return $first;
} }
} }
// not having an opposing account by this name is NOT a problem. // not having an opposing account by this name is NOT a problem.
return; return null;
} }
/** /**
@@ -389,47 +397,55 @@ class TransactionRequest extends Request
// the journal may exist in the request: // the journal may exist in the request:
/** @var Transaction $transaction */ /** @var Transaction $transaction */
$transaction = $this->route()->parameter('transaction'); $transaction = $this->route()->parameter('transaction');
if (is_null($transaction)) { if (null === $transaction) {
return; // @codeCoverageIgnore return; // @codeCoverageIgnore
} }
$data['type'] = strtolower($transaction->transactionJournal->transactionType->type); $data['type'] = strtolower($transaction->transactionJournal->transactionType->type);
} }
foreach ($transactions as $index => $transaction) { foreach ($transactions as $index => $transaction) {
$sourceId = isset($transaction['source_id']) ? intval($transaction['source_id']) : null; $sourceId = isset($transaction['source_id']) ? (int)$transaction['source_id'] : null;
$sourceName = $transaction['source_name'] ?? null; $sourceName = $transaction['source_name'] ?? null;
$destinationId = isset($transaction['destination_id']) ? intval($transaction['destination_id']) : null; $destinationId = isset($transaction['destination_id']) ? (int)$transaction['destination_id'] : null;
$destinationName = $transaction['destination_name'] ?? null; $destinationName = $transaction['destination_name'] ?? null;
$sourceAccount = null;
$destinationAccount = null;
switch ($data['type']) { switch ($data['type']) {
case 'withdrawal': case 'withdrawal':
$idField = 'transactions.' . $index . '.source_id'; $idField = 'transactions.' . $index . '.source_id';
$nameField = 'transactions.' . $index . '.source_name'; $nameField = 'transactions.' . $index . '.source_name';
$this->assetAccountExists($validator, $sourceId, $sourceName, $idField, $nameField); $sourceAccount = $this->assetAccountExists($validator, $sourceId, $sourceName, $idField, $nameField);
$idField = 'transactions.' . $index . '.destination_id';
$idField = 'transactions.' . $index . '.destination_id'; $destinationAccount = $this->opposingAccountExists($validator, AccountType::EXPENSE, $destinationId, $destinationName, $idField);
$this->opposingAccountExists($validator, AccountType::EXPENSE, $destinationId, $destinationName, $idField);
break; break;
case 'deposit': case 'deposit':
$idField = 'transactions.' . $index . '.source_id'; $idField = 'transactions.' . $index . '.source_id';
$this->opposingAccountExists($validator, AccountType::REVENUE, $sourceId, $sourceName, $idField); $sourceAccount = $this->opposingAccountExists($validator, AccountType::REVENUE, $sourceId, $sourceName, $idField);
$idField = 'transactions.' . $index . '.destination_id'; $idField = 'transactions.' . $index . '.destination_id';
$nameField = 'transactions.' . $index . '.destination_name'; $nameField = 'transactions.' . $index . '.destination_name';
$this->assetAccountExists($validator, $destinationId, $destinationName, $idField, $nameField); $destinationAccount = $this->assetAccountExists($validator, $destinationId, $destinationName, $idField, $nameField);
break; break;
case 'transfer': case 'transfer':
$idField = 'transactions.' . $index . '.source_id'; $idField = 'transactions.' . $index . '.source_id';
$nameField = 'transactions.' . $index . '.source_name'; $nameField = 'transactions.' . $index . '.source_name';
$this->assetAccountExists($validator, $sourceId, $sourceName, $idField, $nameField); $sourceAccount = $this->assetAccountExists($validator, $sourceId, $sourceName, $idField, $nameField);
$idField = 'transactions.' . $index . '.destination_id'; $idField = 'transactions.' . $index . '.destination_id';
$nameField = 'transactions.' . $index . '.destination_name'; $nameField = 'transactions.' . $index . '.destination_name';
$this->assetAccountExists($validator, $destinationId, $destinationName, $idField, $nameField); $destinationAccount = $this->assetAccountExists($validator, $destinationId, $destinationName, $idField, $nameField);
break; break;
default: default:
throw new FireflyException(sprintf('The validator cannot handle transaction type "%s" in validateAccountInformation().', $data['type'])); // @codeCoverageIgnoreStart
throw new FireflyException(
sprintf('The validator cannot handle transaction type "%s" in validateAccountInformation().', $data['type'])
);
// @codeCoverageIgnoreEnd
} }
// add some errors in case of same account submitted:
if (null !== $sourceAccount && null !== $destinationAccount && $sourceAccount->id === $destinationAccount->id) {
$validator->errors()->add($idField, trans('validation.source_equals_destination'));
}
} }
} }
@@ -451,7 +467,7 @@ class TransactionRequest extends Request
// the journal may exist in the request: // the journal may exist in the request:
/** @var Transaction $transaction */ /** @var Transaction $transaction */
$transaction = $this->route()->parameter('transaction'); $transaction = $this->route()->parameter('transaction');
if (is_null($transaction)) { if (null === $transaction) {
return; return;
} }
$data['type'] = strtolower($transaction->transactionJournal->transactionType->type); $data['type'] = strtolower($transaction->transactionJournal->transactionType->type);
@@ -463,8 +479,8 @@ class TransactionRequest extends Request
$destinations = []; $destinations = [];
foreach ($data['transactions'] as $transaction) { foreach ($data['transactions'] as $transaction) {
$sources[] = isset($transaction['source_id']) ? intval($transaction['source_id']) : 0; $sources[] = isset($transaction['source_id']) ? (int)$transaction['source_id'] : 0;
$destinations[] = isset($transaction['destination_id']) ? intval($transaction['destination_id']) : 0; $destinations[] = isset($transaction['destination_id']) ? (int)$transaction['destination_id'] : 0;
} }
$destinations = array_unique($destinations); $destinations = array_unique($destinations);
$sources = array_unique($sources); $sources = array_unique($sources);
@@ -493,8 +509,6 @@ class TransactionRequest extends Request
); );
// @codeCoverageIgnoreEnd // @codeCoverageIgnoreEnd
} }
return;
} }
} }

View File

@@ -1,4 +1,5 @@
<?php <?php
declare(strict_types=1);
/** /**
* UserRequest.php * UserRequest.php
* Copyright (c) 2018 thegrumpydictator@gmail.com * Copyright (c) 2018 thegrumpydictator@gmail.com
@@ -19,7 +20,6 @@
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>. * along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/ */
declare(strict_types=1);
namespace FireflyIII\Api\V1\Requests; namespace FireflyIII\Api\V1\Requests;
@@ -86,4 +86,4 @@ class UserRequest extends Request
return $rules; return $rules;
} }
} }

View File

@@ -1,4 +1,5 @@
<?php <?php
declare(strict_types=1);
/** /**
* CreateExport.php * CreateExport.php
* Copyright (c) 2017 thegrumpydictator@gmail.com * Copyright (c) 2017 thegrumpydictator@gmail.com
@@ -18,7 +19,6 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>. * along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/ */
declare(strict_types=1);
namespace FireflyIII\Console\Commands; namespace FireflyIII\Console\Commands;
@@ -60,17 +60,6 @@ class CreateExport extends Command
{--with_uploads : Include user\'s uploads?}'; {--with_uploads : Include user\'s uploads?}';
/** /**
* Create a new command instance.
*/
public function __construct()
{
parent::__construct();
}
/**
* @SuppressWarnings(PHPMD.CyclomaticComplexity) // it's five its fine.
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
*
* Execute the console command. * Execute the console command.
* *
* @return mixed * @return mixed
@@ -80,7 +69,7 @@ class CreateExport extends Command
if (!$this->verifyAccessToken()) { if (!$this->verifyAccessToken()) {
$this->error('Invalid access token.'); $this->error('Invalid access token.');
return; return 1;
} }
$this->line('Full export is running...'); $this->line('Full export is running...');
// make repositories // make repositories
@@ -94,7 +83,7 @@ class CreateExport extends Command
$journalRepository = app(JournalRepositoryInterface::class); $journalRepository = app(JournalRepositoryInterface::class);
// set user // set user
$user = $userRepository->find(intval($this->option('user'))); $user = $userRepository->findNull((int)$this->option('user'));
$jobRepository->setUser($user); $jobRepository->setUser($user);
$journalRepository->setUser($user); $journalRepository->setUser($user);
$accountRepository->setUser($user); $accountRepository->setUser($user);
@@ -141,6 +130,6 @@ class CreateExport extends Command
$this->line('The export has finished! You can find the ZIP file in this location:'); $this->line('The export has finished! You can find the ZIP file in this location:');
$this->line(storage_path(sprintf('export/%s', $fileName))); $this->line(storage_path(sprintf('export/%s', $fileName)));
return; return 0;
} }
} }

View File

@@ -1,4 +1,5 @@
<?php <?php
declare(strict_types=1);
/** /**
* CreateImport.php * CreateImport.php
* Copyright (c) 2017 thegrumpydictator@gmail.com * Copyright (c) 2017 thegrumpydictator@gmail.com
@@ -18,20 +19,17 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>. * along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/ */
declare(strict_types=1);
namespace FireflyIII\Console\Commands; namespace FireflyIII\Console\Commands;
use Artisan;
use FireflyIII\Exceptions\FireflyException; use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Import\Logging\CommandHandler;
use FireflyIII\Import\Routine\RoutineInterface; use FireflyIII\Import\Routine\RoutineInterface;
use FireflyIII\Repositories\ImportJob\ImportJobRepositoryInterface; use FireflyIII\Repositories\ImportJob\ImportJobRepositoryInterface;
use FireflyIII\Repositories\User\UserRepositoryInterface; use FireflyIII\Repositories\User\UserRepositoryInterface;
use FireflyIII\Services\Internal\File\EncryptService;
use Illuminate\Console\Command; use Illuminate\Console\Command;
use Illuminate\Support\MessageBag; use Illuminate\Support\MessageBag;
use Log; use Log;
use Monolog\Formatter\LineFormatter;
use Preferences; use Preferences;
/** /**
@@ -61,76 +59,67 @@ class CreateImport extends Command
{--token= : The user\'s access token.} {--token= : The user\'s access token.}
{--start : Starts the job immediately.}'; {--start : Starts the job immediately.}';
/**
* Create a new command instance.
*/
public function __construct()
{
parent::__construct();
}
/** /**
* Run the command. * Run the command.
* *
* @SuppressWarnings(PHPMD.ExcessiveMethodLength) // cannot be helped * @noinspection MultipleReturnStatementsInspection
* @SuppressWarnings(PHPMD.CyclomaticComplexity) // it's five exactly.
* *
* @throws FireflyException * @throws FireflyException
*/ */
public function handle() public function handle(): int
{ {
if (!$this->verifyAccessToken()) { if (!$this->verifyAccessToken()) {
$this->error('Invalid access token.'); $this->errorLine('Invalid access token.');
return; return 1;
} }
/** @var UserRepositoryInterface $userRepository */ /** @var UserRepositoryInterface $userRepository */
$userRepository = app(UserRepositoryInterface::class); $userRepository = app(UserRepositoryInterface::class);
$file = $this->argument('file'); $file = $this->argument('file');
$configuration = $this->argument('configuration'); $configuration = $this->argument('configuration');
$user = $userRepository->find(intval($this->option('user'))); $user = $userRepository->findNull((int)$this->option('user'));
$cwd = getcwd(); $cwd = getcwd();
$type = strtolower($this->option('type')); $type = strtolower($this->option('type'));
if (!$this->validArguments()) { if (!$this->validArguments()) {
return; $this->errorLine('Invalid arguments.');
return 1;
} }
$configurationData = json_decode(file_get_contents($configuration), true); $configurationData = json_decode(file_get_contents($configuration), true);
if (null === $configurationData) { if (null === $configurationData) {
$this->error(sprintf('Firefly III cannot read the contents of configuration file "%s" (working directory: "%s").', $configuration, $cwd)); $this->errorLine(sprintf('Firefly III cannot read the contents of configuration file "%s" (working directory: "%s").', $configuration, $cwd));
return; return 1;
} }
$this->line(sprintf('Going to create a job to import file: %s', $file)); $this->infoLine(sprintf('Going to create a job to import file: %s', $file));
$this->line(sprintf('Using configuration file: %s', $configuration)); $this->infoLine(sprintf('Using configuration file: %s', $configuration));
$this->line(sprintf('Import into user: #%d (%s)', $user->id, $user->email)); $this->infoLine(sprintf('Import into user: #%d (%s)', $user->id, $user->email));
$this->line(sprintf('Type of import: %s', $type)); $this->infoLine(sprintf('Type of import: %s', $type));
/** @var ImportJobRepositoryInterface $jobRepository */ /** @var ImportJobRepositoryInterface $jobRepository */
$jobRepository = app(ImportJobRepositoryInterface::class); $jobRepository = app(ImportJobRepositoryInterface::class);
$jobRepository->setUser($user); $jobRepository->setUser($user);
$job = $jobRepository->create($type); $job = $jobRepository->create($type);
$this->line(sprintf('Created job "%s"', $job->key)); $this->infoLine(sprintf('Created job "%s"', $job->key));
Artisan::call('firefly:encrypt-file', ['file' => $file, 'key' => $job->key]); /** @var EncryptService $service */
$this->line('Stored import data...'); $service = app(EncryptService::class);
$service->encrypt($file, $job->key);
$this->infoLine('Stored import data...');
$jobRepository->setConfiguration($job, $configurationData); $jobRepository->setConfiguration($job, $configurationData);
$jobRepository->updateStatus($job, 'configured'); $jobRepository->updateStatus($job, 'configured');
$this->line('Stored configuration...'); $this->infoLine('Stored configuration...');
if (true === $this->option('start')) { if (true === $this->option('start')) {
$this->line('The import will start in a moment. This process is not visible...'); $this->infoLine('The import will start in a moment. This process is not visible...');
Log::debug('Go for import!'); Log::debug('Go for import!');
// normally would refer to other firefly:start-import but that doesn't seem to work all to well... // normally would refer to other firefly:start-import but that doesn't seem to work all to well...
$monolog = Log::getMonolog();
$handler = new CommandHandler($this);
$formatter = new LineFormatter(null, null, false, true);
$handler->setFormatter($formatter);
$monolog->pushHandler($handler);
// start the actual routine: // start the actual routine:
$type = 'csv' === $job->file_type ? 'file' : $job->file_type; $type = 'csv' === $job->file_type ? 'file' : $job->file_type;
@@ -147,9 +136,9 @@ class CreateImport extends Command
// give feedback. // give feedback.
/** @var MessageBag $error */ /** @var MessageBag $error */
foreach ($routine->getErrors() as $index => $error) { foreach ($routine->getErrors() as $index => $error) {
$this->error(sprintf('Error importing line #%d: %s', $index, $error)); $this->errorLine(sprintf('Error importing line #%d: %s', $index, $error));
} }
$this->line( $this->infoLine(
sprintf( sprintf(
'The import has finished. %d transactions have been imported out of %d records.', $routine->getJournals()->count(), $routine->getLines() 'The import has finished. %d transactions have been imported out of %d records.', $routine->getJournals()->count(), $routine->getLines()
) )
@@ -159,45 +148,58 @@ class CreateImport extends Command
// clear cache for user: // clear cache for user:
Preferences::setForUser($user, 'lastActivity', microtime()); Preferences::setForUser($user, 'lastActivity', microtime());
return; return 0;
}
/**
* @param string $message
* @param array|null $data
*/
private function errorLine(string $message, array $data = null): void
{
Log::error($message, $data ?? []);
$this->error($message);
}
/**
* @param string $message
* @param array $data
*/
private function infoLine(string $message, array $data = null): void
{
Log::info($message, $data ?? []);
$this->line($message);
} }
/** /**
* Verify user inserts correct arguments. * Verify user inserts correct arguments.
* *
* @noinspection MultipleReturnStatementsInspection
* @return bool * @return bool
* @SuppressWarnings(PHPMD.CyclomaticComplexity) // it's five exactly.
*/ */
private function validArguments(): bool private function validArguments(): bool
{ {
/** @var UserRepositoryInterface $userRepository */ $file = $this->argument('file');
$userRepository = app(UserRepositoryInterface::class); $configuration = $this->argument('configuration');
$file = $this->argument('file'); $cwd = getcwd();
$configuration = $this->argument('configuration'); $validTypes = config('import.options.file.import_formats');
$user = $userRepository->find(intval($this->option('user'))); $type = strtolower($this->option('type'));
$cwd = getcwd();
$validTypes = config('import.options.file.import_formats');
$type = strtolower($this->option('type'));
if (null === $user) {
$this->error(sprintf('There is no user with ID %d.', $this->option('user')));
return false; if (!\in_array($type, $validTypes, true)) {
} $this->errorLine(sprintf('Cannot import file of type "%s"', $type));
if (!in_array($type, $validTypes)) {
$this->error(sprintf('Cannot import file of type "%s"', $type));
return false; return false;
} }
if (!file_exists($file)) { if (!file_exists($file)) {
$this->error(sprintf('Firefly III cannot find file "%s" (working directory: "%s").', $file, $cwd)); $this->errorLine(sprintf('Firefly III cannot find file "%s" (working directory: "%s").', $file, $cwd));
return false; return false;
} }
if (!file_exists($configuration)) { if (!file_exists($configuration)) {
$this->error(sprintf('Firefly III cannot find configuration file "%s" (working directory: "%s").', $configuration, $cwd)); $this->errorLine(sprintf('Firefly III cannot find configuration file "%s" (working directory: "%s").', $configuration, $cwd));
return false; return false;
} }

View File

@@ -1,4 +1,5 @@
<?php <?php
declare(strict_types=1);
/** /**
* DecryptAttachment.php * DecryptAttachment.php
* Copyright (c) 2017 thegrumpydictator@gmail.com * Copyright (c) 2017 thegrumpydictator@gmail.com
@@ -18,7 +19,6 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>. * along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/ */
declare(strict_types=1);
namespace FireflyIII\Console\Commands; namespace FireflyIII\Console\Commands;
@@ -47,14 +47,6 @@ class DecryptAttachment extends Command
= 'firefly:decrypt-attachment {id:The ID of the attachment.} {name:The file name of the attachment.} = 'firefly:decrypt-attachment {id:The ID of the attachment.} {name:The file name of the attachment.}
{directory:Where the file must be stored.}'; {directory:Where the file must be stored.}';
/**
* Create a new command instance.
*/
public function __construct()
{
parent::__construct();
}
/** /**
* Execute the console command. * Execute the console command.
* *
@@ -65,7 +57,7 @@ class DecryptAttachment extends Command
{ {
/** @var AttachmentRepositoryInterface $repository */ /** @var AttachmentRepositoryInterface $repository */
$repository = app(AttachmentRepositoryInterface::class); $repository = app(AttachmentRepositoryInterface::class);
$attachmentId = intval($this->argument('id')); $attachmentId = (int)$this->argument('id');
$attachment = $repository->findWithoutUser($attachmentId); $attachment = $repository->findWithoutUser($attachmentId);
$attachmentName = trim($this->argument('name')); $attachmentName = trim($this->argument('name'));
$storagePath = realpath(trim($this->argument('directory'))); $storagePath = realpath(trim($this->argument('directory')));

View File

@@ -1,4 +1,5 @@
<?php <?php
declare(strict_types=1);
/** /**
* EncryptFile.php * EncryptFile.php
* Copyright (c) 2017 thegrumpydictator@gmail.com * Copyright (c) 2017 thegrumpydictator@gmail.com
@@ -18,11 +19,11 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>. * along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/ */
declare(strict_types=1);
namespace FireflyIII\Console\Commands; namespace FireflyIII\Console\Commands;
use Crypt; use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Services\Internal\File\EncryptService;
use Illuminate\Console\Command; use Illuminate\Console\Command;
/** /**
@@ -44,31 +45,26 @@ class EncryptFile extends Command
*/ */
protected $signature = 'firefly:encrypt-file {file} {key}'; protected $signature = 'firefly:encrypt-file {file} {key}';
/**
* Create a new command instance.
*/
public function __construct()
{
parent::__construct();
}
/** /**
* Execute the console command. * Execute the console command.
*
* @throws \Illuminate\Contracts\Encryption\EncryptException
*/ */
public function handle() public function handle(): int
{ {
$file = e(strval($this->argument('file'))); $code = 0;
if (!file_exists($file)) { $file = (string)$this->argument('file');
$this->error(sprintf('File "%s" does not seem to exist.', $file)); $key = (string)$this->argument('key');
/** @var EncryptService $service */
$service = app(EncryptService::class);
return; try {
$service->encrypt($file, $key);
} catch (FireflyException $e) {
$this->error($e->getMessage());
$code = 1;
} }
$content = file_get_contents($file);
$content = Crypt::encrypt($content);
$newName = e(strval($this->argument('key'))) . '.upload';
$path = storage_path('upload') . '/' . $newName; return $code;
file_put_contents($path, $content);
$this->line(sprintf('Encrypted "%s" and put it in "%s"', $file, $path));
} }
} }

View File

@@ -1,4 +1,5 @@
<?php <?php
declare(strict_types=1);
/** /**
* Import.php * Import.php
* Copyright (c) 2017 thegrumpydictator@gmail.com * Copyright (c) 2017 thegrumpydictator@gmail.com
@@ -18,12 +19,10 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>. * along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/ */
declare(strict_types=1);
namespace FireflyIII\Console\Commands; namespace FireflyIII\Console\Commands;
use FireflyIII\Exceptions\FireflyException; use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Import\Logging\CommandHandler;
use FireflyIII\Import\Routine\RoutineInterface; use FireflyIII\Import\Routine\RoutineInterface;
use FireflyIII\Models\ImportJob; use FireflyIII\Models\ImportJob;
use Illuminate\Console\Command; use Illuminate\Console\Command;
@@ -49,14 +48,6 @@ class Import extends Command
*/ */
protected $signature = 'firefly:start-import {key}'; protected $signature = 'firefly:start-import {key}';
/**
* Create a new command instance.
*/
public function __construct()
{
parent::__construct();
}
/** /**
* Run the import routine. * Run the import routine.
* *
@@ -68,21 +59,17 @@ class Import extends Command
$jobKey = $this->argument('key'); $jobKey = $this->argument('key');
$job = ImportJob::where('key', $jobKey)->first(); $job = ImportJob::where('key', $jobKey)->first();
if (null === $job) { if (null === $job) {
$this->error(sprintf('No job found with key "%s"', $jobKey)); $this->errorLine(sprintf('No job found with key "%s"', $jobKey));
return; return;
} }
if (!$this->isValid($job)) { if (!$this->isValid($job)) {
Log::error('Job is not valid for some reason. Exit.'); $this->errorLine('Job is not valid for some reason. Exit.');
return; return;
} }
$this->line(sprintf('Going to import job with key "%s" of type "%s"', $job->key, $job->file_type)); $this->infoLine(sprintf('Going to import job with key "%s" of type "%s"', $job->key, $job->file_type));
$monolog = Log::getMonolog();
$handler = new CommandHandler($this);
$monolog->pushHandler($handler);
// actually start job: // actually start job:
$type = 'csv' === $job->file_type ? 'file' : $job->file_type; $type = 'csv' === $job->file_type ? 'file' : $job->file_type;
@@ -99,16 +86,37 @@ class Import extends Command
/** @var MessageBag $error */ /** @var MessageBag $error */
foreach ($routine->getErrors() as $index => $error) { foreach ($routine->getErrors() as $index => $error) {
$this->error(sprintf('Error importing line #%d: %s', $index, $error)); $this->errorLine(sprintf('Error importing line #%d: %s', $index, $error));
} }
$this->line( $this->infoLine(
sprintf('The import has finished. %d transactions have been imported out of %d records.', $routine->getJournals()->count(), $routine->getLines()) sprintf('The import has finished. %d transactions have been imported out of %d records.', $routine->getJournals()->count(), $routine->getLines())
); );
return; return;
} }
/**
* @param string $message
* @param array|null $data
*/
private function errorLine(string $message, array $data = null): void
{
Log::error($message, $data ?? []);
$this->error($message);
}
/**
* @param string $message
* @param array $data
*/
private function infoLine(string $message, array $data = null): void
{
Log::info($message, $data ?? []);
$this->line($message);
}
/** /**
* Check if job is valid to be imported. * Check if job is valid to be imported.
* *
@@ -119,15 +127,14 @@ class Import extends Command
private function isValid(ImportJob $job): bool private function isValid(ImportJob $job): bool
{ {
if (null === $job) { if (null === $job) {
Log::error('This job does not seem to exist.'); $this->errorLine('This job does not seem to exist.');
$this->error('This job does not seem to exist.');
return false; return false;
} }
if ('configured' !== $job->status) { if ('configured' !== $job->status) {
Log::error(sprintf('This job is not ready to be imported (status is %s).', $job->status)); Log::error(sprintf('This job is not ready to be imported (status is %s).', $job->status));
$this->error('This job is not ready to be imported.'); $this->errorLine('This job is not ready to be imported.');
return false; return false;
} }

View File

@@ -1,4 +1,5 @@
<?php <?php
declare(strict_types=1);
/** /**
* ScanAttachments.php * ScanAttachments.php
* Copyright (c) 2017 thegrumpydictator@gmail.com * Copyright (c) 2017 thegrumpydictator@gmail.com
@@ -18,7 +19,6 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>. * along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/ */
declare(strict_types=1);
namespace FireflyIII\Console\Commands; namespace FireflyIII\Console\Commands;
@@ -48,14 +48,6 @@ class ScanAttachments extends Command
*/ */
protected $signature = 'firefly:scan-attachments'; protected $signature = 'firefly:scan-attachments';
/**
* Create a new command instance.
*/
public function __construct()
{
parent::__construct();
}
/** /**
* Execute the console command. * Execute the console command.
*/ */

View File

@@ -1,4 +1,5 @@
<?php <?php
declare(strict_types=1);
/** /**
* UpgradeDatabase.php * UpgradeDatabase.php
* Copyright (c) 2017 thegrumpydictator@gmail.com * Copyright (c) 2017 thegrumpydictator@gmail.com
@@ -18,14 +19,15 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>. * along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/ */
declare(strict_types=1);
namespace FireflyIII\Console\Commands; namespace FireflyIII\Console\Commands;
use DB; use DB;
use Exception;
use FireflyIII\Models\Account; use FireflyIII\Models\Account;
use FireflyIII\Models\AccountMeta; use FireflyIII\Models\AccountMeta;
use FireflyIII\Models\AccountType; use FireflyIII\Models\AccountType;
use FireflyIII\Models\Attachment;
use FireflyIII\Models\Note; use FireflyIII\Models\Note;
use FireflyIII\Models\Transaction; use FireflyIII\Models\Transaction;
use FireflyIII\Models\TransactionCurrency; use FireflyIII\Models\TransactionCurrency;
@@ -63,18 +65,8 @@ class UpgradeDatabase extends Command
*/ */
protected $signature = 'firefly:upgrade-database'; protected $signature = 'firefly:upgrade-database';
/**
* Create a new command instance.
*/
public function __construct()
{
parent::__construct();
}
/** /**
* Execute the console command. * Execute the console command.
*
* @throws \Exception
*/ */
public function handle() public function handle()
{ {
@@ -86,6 +78,7 @@ class UpgradeDatabase extends Command
$this->updateOtherCurrencies(); $this->updateOtherCurrencies();
$this->line('Done updating currency information..'); $this->line('Done updating currency information..');
$this->migrateNotes(); $this->migrateNotes();
$this->migrateAttachmentData();
$this->info('Firefly III database is up to date.'); $this->info('Firefly III database is up to date.');
return; return;
@@ -118,7 +111,7 @@ class UpgradeDatabase extends Command
$journalIds = array_unique($result->pluck('id')->toArray()); $journalIds = array_unique($result->pluck('id')->toArray());
foreach ($journalIds as $journalId) { foreach ($journalIds as $journalId) {
$this->updateJournalidentifiers(intval($journalId)); $this->updateJournalidentifiers((int)$journalId);
} }
return; return;
@@ -140,9 +133,9 @@ class UpgradeDatabase extends Command
// get users preference, fall back to system pref. // get users preference, fall back to system pref.
$defaultCurrencyCode = Preferences::getForUser($account->user, 'currencyPreference', config('firefly.default_currency', 'EUR'))->data; $defaultCurrencyCode = Preferences::getForUser($account->user, 'currencyPreference', config('firefly.default_currency', 'EUR'))->data;
$defaultCurrency = TransactionCurrency::where('code', $defaultCurrencyCode)->first(); $defaultCurrency = TransactionCurrency::where('code', $defaultCurrencyCode)->first();
$accountCurrency = intval($account->getMeta('currency_id')); $accountCurrency = (int)$account->getMeta('currency_id');
$openingBalance = $account->getOpeningBalance(); $openingBalance = $account->getOpeningBalance();
$obCurrency = intval($openingBalance->transaction_currency_id); $obCurrency = (int)$openingBalance->transaction_currency_id;
// both 0? set to default currency: // both 0? set to default currency:
if (0 === $accountCurrency && 0 === $obCurrency) { if (0 === $accountCurrency && 0 === $obCurrency) {
@@ -209,7 +202,7 @@ class UpgradeDatabase extends Command
} }
/** @var Account $account */ /** @var Account $account */
$account = $transaction->account; $account = $transaction->account;
$currency = $repository->find(intval($account->getMeta('currency_id'))); $currency = $repository->find((int)$account->getMeta('currency_id'));
$transactions = $journal->transactions()->get(); $transactions = $journal->transactions()->get();
$transactions->each( $transactions->each(
function (Transaction $transaction) use ($currency) { function (Transaction $transaction) use ($currency) {
@@ -219,8 +212,8 @@ class UpgradeDatabase extends Command
} }
// when mismatch in transaction: // when mismatch in transaction:
if (!(intval($transaction->transaction_currency_id) === intval($currency->id))) { if (!((int)$transaction->transaction_currency_id === (int)$currency->id)) {
$transaction->foreign_currency_id = intval($transaction->transaction_currency_id); $transaction->foreign_currency_id = (int)$transaction->transaction_currency_id;
$transaction->foreign_amount = $transaction->amount; $transaction->foreign_amount = $transaction->amount;
$transaction->transaction_currency_id = $currency->id; $transaction->transaction_currency_id = $currency->id;
$transaction->save(); $transaction->save();
@@ -272,19 +265,49 @@ class UpgradeDatabase extends Command
{ {
// create transaction type "Reconciliation". // create transaction type "Reconciliation".
$type = TransactionType::where('type', TransactionType::RECONCILIATION)->first(); $type = TransactionType::where('type', TransactionType::RECONCILIATION)->first();
if (is_null($type)) { if (null === $type) {
TransactionType::create(['type' => TransactionType::RECONCILIATION]); TransactionType::create(['type' => TransactionType::RECONCILIATION]);
} }
$account = AccountType::where('type', AccountType::RECONCILIATION)->first(); $account = AccountType::where('type', AccountType::RECONCILIATION)->first();
if (is_null($account)) { if (null === $account) {
AccountType::create(['type' => AccountType::RECONCILIATION]); AccountType::create(['type' => AccountType::RECONCILIATION]);
} }
} }
/**
* Move the description of each attachment (when not NULL) to the notes or to a new note object
* for all attachments.
*/
private function migrateAttachmentData(): void
{
$attachments = Attachment::get();
/** @var Attachment $att */
foreach ($attachments as $att) {
// move description:
$description = (string)$att->description;
if (strlen($description) > 0) {
// find or create note:
$note = $att->notes()->first();
if (null === $note) {
$note = new Note;
$note->noteable()->associate($att);
}
$note->text = $description;
$note->save();
// clear description:
$att->description = '';
$att->save();
Log::debug(sprintf('Migrated attachment #%s description to note #%d', $att->id, $note->id));
}
}
}
/** /**
* Move all the journal_meta notes to their note object counter parts. * Move all the journal_meta notes to their note object counter parts.
*
* @throws \Exception
*/ */
private function migrateNotes(): void private function migrateNotes(): void
{ {
@@ -301,7 +324,11 @@ class UpgradeDatabase extends Command
$note->text = $meta->data; $note->text = $meta->data;
$note->save(); $note->save();
Log::debug(sprintf('Migrated meta note #%d to Note #%d', $meta->id, $note->id)); Log::debug(sprintf('Migrated meta note #%d to Note #%d', $meta->id, $note->id));
$meta->delete(); try {
$meta->delete();
} catch (Exception $e) {
Log::error(sprintf('Could not delete old meta entry #%d: %s', $meta->id, $e->getMessage()));
}
} }
} }
@@ -314,10 +341,10 @@ class UpgradeDatabase extends Command
{ {
/** @var CurrencyRepositoryInterface $repository */ /** @var CurrencyRepositoryInterface $repository */
$repository = app(CurrencyRepositoryInterface::class); $repository = app(CurrencyRepositoryInterface::class);
$currency = $repository->find(intval($transaction->account->getMeta('currency_id'))); $currency = $repository->find((int)$transaction->account->getMeta('currency_id'));
$journal = $transaction->transactionJournal; $journal = $transaction->transactionJournal;
if (!(intval($currency->id) === intval($journal->transaction_currency_id))) { if (!((int)$currency->id === (int)$journal->transaction_currency_id)) {
$this->line( $this->line(
sprintf( sprintf(
'Transfer #%d ("%s") has been updated to use %s instead of %s.', 'Transfer #%d ("%s") has been updated to use %s instead of %s.',
@@ -348,7 +375,7 @@ class UpgradeDatabase extends Command
/** @var Transaction $transaction */ /** @var Transaction $transaction */
foreach ($transactions as $transaction) { foreach ($transactions as $transaction) {
// find opposing: // find opposing:
$amount = bcmul(strval($transaction->amount), '-1'); $amount = bcmul((string)$transaction->amount, '-1');
try { try {
/** @var Transaction $opposing */ /** @var Transaction $opposing */
@@ -398,18 +425,18 @@ class UpgradeDatabase extends Command
{ {
/** @var CurrencyRepositoryInterface $repository */ /** @var CurrencyRepositoryInterface $repository */
$repository = app(CurrencyRepositoryInterface::class); $repository = app(CurrencyRepositoryInterface::class);
$currency = $repository->find(intval($transaction->account->getMeta('currency_id'))); $currency = $repository->find((int)$transaction->account->getMeta('currency_id'));
// has no currency ID? Must have, so fill in using account preference: // has no currency ID? Must have, so fill in using account preference:
if (null === $transaction->transaction_currency_id) { if (null === $transaction->transaction_currency_id) {
$transaction->transaction_currency_id = intval($currency->id); $transaction->transaction_currency_id = (int)$currency->id;
Log::debug(sprintf('Transaction #%d has no currency setting, now set to %s', $transaction->id, $currency->code)); Log::debug(sprintf('Transaction #%d has no currency setting, now set to %s', $transaction->id, $currency->code));
$transaction->save(); $transaction->save();
} }
// does not match the source account (see above)? Can be fixed // does not match the source account (see above)? Can be fixed
// when mismatch in transaction and NO foreign amount is set: // when mismatch in transaction and NO foreign amount is set:
if (!(intval($transaction->transaction_currency_id) === intval($currency->id)) && null === $transaction->foreign_amount) { if (!((int)$transaction->transaction_currency_id === (int)$currency->id) && null === $transaction->foreign_amount) {
Log::debug( Log::debug(
sprintf( sprintf(
'Transaction #%d has a currency setting #%d that should be #%d. Amount remains %s, currency is changed.', 'Transaction #%d has a currency setting #%d that should be #%d. Amount remains %s, currency is changed.',
@@ -419,7 +446,7 @@ class UpgradeDatabase extends Command
$transaction->amount $transaction->amount
) )
); );
$transaction->transaction_currency_id = intval($currency->id); $transaction->transaction_currency_id = (int)$currency->id;
$transaction->save(); $transaction->save();
} }
@@ -428,7 +455,7 @@ class UpgradeDatabase extends Command
$journal = $transaction->transactionJournal; $journal = $transaction->transactionJournal;
/** @var Transaction $opposing */ /** @var Transaction $opposing */
$opposing = $journal->transactions()->where('amount', '>', 0)->where('identifier', $transaction->identifier)->first(); $opposing = $journal->transactions()->where('amount', '>', 0)->where('identifier', $transaction->identifier)->first();
$opposingCurrency = $repository->find(intval($opposing->account->getMeta('currency_id'))); $opposingCurrency = $repository->find((int)$opposing->account->getMeta('currency_id'));
if (null === $opposingCurrency->id) { if (null === $opposingCurrency->id) {
Log::error(sprintf('Account #%d ("%s") must have currency preference but has none.', $opposing->account->id, $opposing->account->name)); Log::error(sprintf('Account #%d ("%s") must have currency preference but has none.', $opposing->account->id, $opposing->account->name));
@@ -437,7 +464,7 @@ class UpgradeDatabase extends Command
} }
// if the destination account currency is the same, both foreign_amount and foreign_currency_id must be NULL for both transactions: // if the destination account currency is the same, both foreign_amount and foreign_currency_id must be NULL for both transactions:
if (intval($opposingCurrency->id) === intval($currency->id)) { if ((int)$opposingCurrency->id === (int)$currency->id) {
// update both transactions to match: // update both transactions to match:
$transaction->foreign_amount = null; $transaction->foreign_amount = null;
$transaction->foreign_currency_id = null; $transaction->foreign_currency_id = null;
@@ -451,7 +478,7 @@ class UpgradeDatabase extends Command
return; return;
} }
// if destination account currency is different, both transactions must have this currency as foreign currency id. // if destination account currency is different, both transactions must have this currency as foreign currency id.
if (!(intval($opposingCurrency->id) === intval($currency->id))) { if (!((int)$opposingCurrency->id === (int)$currency->id)) {
$transaction->foreign_currency_id = $opposingCurrency->id; $transaction->foreign_currency_id = $opposingCurrency->id;
$opposing->foreign_currency_id = $opposingCurrency->id; $opposing->foreign_currency_id = $opposingCurrency->id;
$transaction->save(); $transaction->save();
@@ -461,14 +488,14 @@ class UpgradeDatabase extends Command
// if foreign amount of one is null and the other is not, use this to restore: // if foreign amount of one is null and the other is not, use this to restore:
if (null === $transaction->foreign_amount && null !== $opposing->foreign_amount) { if (null === $transaction->foreign_amount && null !== $opposing->foreign_amount) {
$transaction->foreign_amount = bcmul(strval($opposing->foreign_amount), '-1'); $transaction->foreign_amount = bcmul((string)$opposing->foreign_amount, '-1');
$transaction->save(); $transaction->save();
Log::debug(sprintf('Restored foreign amount of transaction (1) #%d to %s', $transaction->id, $transaction->foreign_amount)); Log::debug(sprintf('Restored foreign amount of transaction (1) #%d to %s', $transaction->id, $transaction->foreign_amount));
} }
// if foreign amount of one is null and the other is not, use this to restore (other way around) // if foreign amount of one is null and the other is not, use this to restore (other way around)
if (null === $opposing->foreign_amount && null !== $transaction->foreign_amount) { if (null === $opposing->foreign_amount && null !== $transaction->foreign_amount) {
$opposing->foreign_amount = bcmul(strval($transaction->foreign_amount), '-1'); $opposing->foreign_amount = bcmul((string)$transaction->foreign_amount, '-1');
$opposing->save(); $opposing->save();
Log::debug(sprintf('Restored foreign amount of transaction (2) #%d to %s', $opposing->id, $opposing->foreign_amount)); Log::debug(sprintf('Restored foreign amount of transaction (2) #%d to %s', $opposing->id, $opposing->foreign_amount));
} }
@@ -478,14 +505,14 @@ class UpgradeDatabase extends Command
$foreignAmount = $journal->getMeta('foreign_amount'); $foreignAmount = $journal->getMeta('foreign_amount');
if (null === $foreignAmount) { if (null === $foreignAmount) {
Log::debug(sprintf('Journal #%d has missing foreign currency data, forced to do 1:1 conversion :(.', $transaction->transaction_journal_id)); Log::debug(sprintf('Journal #%d has missing foreign currency data, forced to do 1:1 conversion :(.', $transaction->transaction_journal_id));
$transaction->foreign_amount = bcmul(strval($transaction->amount), '-1'); $transaction->foreign_amount = bcmul((string)$transaction->amount, '-1');
$opposing->foreign_amount = bcmul(strval($opposing->amount), '-1'); $opposing->foreign_amount = bcmul((string)$opposing->amount, '-1');
$transaction->save(); $transaction->save();
$opposing->save(); $opposing->save();
return; return;
} }
$foreignPositive = app('steam')->positive(strval($foreignAmount)); $foreignPositive = app('steam')->positive((string)$foreignAmount);
Log::debug( Log::debug(
sprintf( sprintf(
'Journal #%d has missing foreign currency info, try to restore from meta-data ("%s").', 'Journal #%d has missing foreign currency info, try to restore from meta-data ("%s").',

View File

@@ -1,4 +1,5 @@
<?php <?php
declare(strict_types=1);
/** /**
* UpgradeFireflyInstructions.php * UpgradeFireflyInstructions.php
* Copyright (c) 2017 thegrumpydictator@gmail.com * Copyright (c) 2017 thegrumpydictator@gmail.com
@@ -18,7 +19,6 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>. * along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/ */
declare(strict_types=1);
namespace FireflyIII\Console\Commands; namespace FireflyIII\Console\Commands;
@@ -42,14 +42,6 @@ class UpgradeFireflyInstructions extends Command
*/ */
protected $signature = 'firefly:instructions {task}'; protected $signature = 'firefly:instructions {task}';
/**
* Create a new command instance.
*/
public function __construct()
{
parent::__construct();
}
/** /**
* Execute the console command. * Execute the console command.
*/ */

View File

@@ -1,4 +1,5 @@
<?php <?php
declare(strict_types=1);
/** /**
* UseEncryption.php * UseEncryption.php
@@ -19,7 +20,6 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>. * along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/ */
declare(strict_types=1);
namespace FireflyIII\Console\Commands; namespace FireflyIII\Console\Commands;
@@ -44,14 +44,6 @@ class UseEncryption extends Command
*/ */
protected $signature = 'firefly:use-encryption'; protected $signature = 'firefly:use-encryption';
/**
* Create a new command instance.
*/
public function __construct()
{
parent::__construct();
}
/** /**
* Execute the console command. * Execute the console command.
*/ */

View File

@@ -1,4 +1,5 @@
<?php <?php
declare(strict_types=1);
/** /**
* VerifiesAccessToken.php * VerifiesAccessToken.php
* Copyright (c) 2017 thegrumpydictator@gmail.com * Copyright (c) 2017 thegrumpydictator@gmail.com
@@ -18,7 +19,6 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>. * along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/ */
declare(strict_types=1);
namespace FireflyIII\Console\Commands; namespace FireflyIII\Console\Commands;
@@ -49,11 +49,11 @@ trait VerifiesAccessToken
*/ */
protected function verifyAccessToken(): bool protected function verifyAccessToken(): bool
{ {
$userId = intval($this->option('user')); $userId = (int)$this->option('user');
$token = strval($this->option('token')); $token = (string)$this->option('token');
/** @var UserRepositoryInterface $repository */ /** @var UserRepositoryInterface $repository */
$repository = app(UserRepositoryInterface::class); $repository = app(UserRepositoryInterface::class);
$user = $repository->find($userId); $user = $repository->findNull($userId);
if (null === $user) { if (null === $user) {
Log::error(sprintf('verifyAccessToken(): no such user for input "%d"', $userId)); Log::error(sprintf('verifyAccessToken(): no such user for input "%d"', $userId));
@@ -68,7 +68,7 @@ trait VerifiesAccessToken
} }
if (!($accessToken->data === $token)) { if (!($accessToken->data === $token)) {
Log::error(sprintf('Invalid access token for user #%d.', $userId)); Log::error(sprintf('Invalid access token for user #%d.', $userId));
Log::error(sprintf('Token given is "%s", expected "%s".', $token, $accessToken->data)); Log::error(sprintf('Token given is "%s", expected something else.', $token));
return false; return false;
} }

View File

@@ -1,4 +1,5 @@
<?php <?php
declare(strict_types=1);
/** /**
* VerifyDatabase.php * VerifyDatabase.php
* Copyright (c) 2017 thegrumpydictator@gmail.com * Copyright (c) 2017 thegrumpydictator@gmail.com
@@ -18,7 +19,6 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>. * along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/ */
declare(strict_types=1);
namespace FireflyIII\Console\Commands; namespace FireflyIII\Console\Commands;
@@ -61,14 +61,6 @@ class VerifyDatabase extends Command
*/ */
protected $signature = 'firefly:verify'; protected $signature = 'firefly:verify';
/**
* Create a new command instance.
*/
public function __construct()
{
parent::__construct();
}
/** /**
* Execute the console command. * Execute the console command.
*/ */
@@ -158,7 +150,7 @@ class VerifyDatabase extends Command
->get(['transaction_journal_id', DB::raw('SUM(amount) AS the_sum')]); ->get(['transaction_journal_id', DB::raw('SUM(amount) AS the_sum')]);
/** @var stdClass $entry */ /** @var stdClass $entry */
foreach ($journals as $entry) { foreach ($journals as $entry) {
if (0 !== bccomp(strval($entry->the_sum), '0')) { if (0 !== bccomp((string)$entry->the_sum, '0')) {
$errored[] = $entry->transaction_journal_id; $errored[] = $entry->transaction_journal_id;
} }
} }
@@ -171,7 +163,7 @@ class VerifyDatabase extends Command
// report about it // report about it
/** @var TransactionJournal $journal */ /** @var TransactionJournal $journal */
$journal = TransactionJournal::find($journalId); $journal = TransactionJournal::find($journalId);
if (is_null($journal)) { if (null === $journal) {
continue; continue;
} }
if (TransactionType::OPENING_BALANCE === $journal->transactionType->type) { if (TransactionType::OPENING_BALANCE === $journal->transactionType->type) {
@@ -297,7 +289,7 @@ class VerifyDatabase extends Command
); );
/** @var stdClass $entry */ /** @var stdClass $entry */
foreach ($set as $entry) { foreach ($set as $entry) {
$date = null === $entry->transaction_deleted_at ? $entry->journal_deleted_at : $entry->transaction_deleted_at; $date = $entry->transaction_deleted_at ?? $entry->journal_deleted_at;
$this->error( $this->error(
'Error: Account #' . $entry->account_id . ' should have been deleted, but has not.' . '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 . '"' ' Find it in the table called "accounts" and change the "deleted_at" field to: "' . $date . '"'
@@ -448,7 +440,7 @@ class VerifyDatabase extends Command
/** @var User $user */ /** @var User $user */
foreach ($userRepository->all() as $user) { foreach ($userRepository->all() as $user) {
$sum = strval($user->transactions()->sum('amount')); $sum = (string)$user->transactions()->sum('amount');
if (0 !== bccomp($sum, '0')) { if (0 !== bccomp($sum, '0')) {
$this->error('Error: Transactions for user #' . $user->id . ' (' . $user->email . ') are off by ' . $sum . '!'); $this->error('Error: Transactions for user #' . $user->id . ' (' . $user->email . ') are off by ' . $sum . '!');
} else { } else {

View File

@@ -1,4 +1,5 @@
<?php <?php
declare(strict_types=1);
/** /**
* Kernel.php * Kernel.php
* Copyright (c) 2017 thegrumpydictator@gmail.com * Copyright (c) 2017 thegrumpydictator@gmail.com
@@ -18,7 +19,6 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>. * along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/ */
declare(strict_types=1);
namespace FireflyIII\Console; namespace FireflyIII\Console;

View File

@@ -1,4 +1,5 @@
<?php <?php
declare(strict_types=1);
/** /**
* AdminRequestedTestMessage.php * AdminRequestedTestMessage.php
* Copyright (c) 2017 thegrumpydictator@gmail.com * Copyright (c) 2017 thegrumpydictator@gmail.com
@@ -18,7 +19,6 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>. * along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/ */
declare(strict_types=1);
namespace FireflyIII\Events; namespace FireflyIII\Events;

View File

@@ -1,4 +1,5 @@
<?php <?php
declare(strict_types=1);
/** /**
* Event.php * Event.php
* Copyright (c) 2017 thegrumpydictator@gmail.com * Copyright (c) 2017 thegrumpydictator@gmail.com
@@ -18,7 +19,6 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>. * along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/ */
declare(strict_types=1);
namespace FireflyIII\Events; namespace FireflyIII\Events;

View File

@@ -1,4 +1,5 @@
<?php <?php
declare(strict_types=1);
/** /**
* RegisteredUser.php * RegisteredUser.php
* Copyright (c) 2017 thegrumpydictator@gmail.com * Copyright (c) 2017 thegrumpydictator@gmail.com
@@ -18,7 +19,6 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>. * along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/ */
declare(strict_types=1);
namespace FireflyIII\Events; namespace FireflyIII\Events;

View File

@@ -1,4 +1,5 @@
<?php <?php
declare(strict_types=1);
/** /**
* RequestedNewPassword.php * RequestedNewPassword.php
* Copyright (c) 2017 thegrumpydictator@gmail.com * Copyright (c) 2017 thegrumpydictator@gmail.com
@@ -18,7 +19,6 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>. * along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/ */
declare(strict_types=1);
namespace FireflyIII\Events; namespace FireflyIII\Events;

View File

@@ -1,4 +1,5 @@
<?php <?php
declare(strict_types=1);
/** /**
* RequestedVersionCheckStatus.php * RequestedVersionCheckStatus.php
* Copyright (c) 2017 thegrumpydictator@gmail.com * Copyright (c) 2017 thegrumpydictator@gmail.com
@@ -19,7 +20,6 @@
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>. * along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/ */
declare(strict_types=1);
namespace FireflyIII\Events; namespace FireflyIII\Events;
@@ -49,4 +49,4 @@ class RequestedVersionCheckStatus extends Event
{ {
$this->user = $user; $this->user = $user;
} }
} }

View File

@@ -1,4 +1,5 @@
<?php <?php
declare(strict_types=1);
/** /**
* StoredTransactionJournal.php * StoredTransactionJournal.php
* Copyright (c) 2017 thegrumpydictator@gmail.com * Copyright (c) 2017 thegrumpydictator@gmail.com
@@ -18,7 +19,6 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>. * along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/ */
declare(strict_types=1);
namespace FireflyIII\Events; namespace FireflyIII\Events;
@@ -26,6 +26,7 @@ use FireflyIII\Models\TransactionJournal;
use Illuminate\Queue\SerializesModels; use Illuminate\Queue\SerializesModels;
/** /**
* @codeCoverageIgnore
* Class StoredTransactionJournal. * Class StoredTransactionJournal.
*/ */
class StoredTransactionJournal extends Event class StoredTransactionJournal extends Event

View File

@@ -1,4 +1,5 @@
<?php <?php
declare(strict_types=1);
/** /**
* UpdatedTransactionJournal.php * UpdatedTransactionJournal.php
* Copyright (c) 2017 thegrumpydictator@gmail.com * Copyright (c) 2017 thegrumpydictator@gmail.com
@@ -18,7 +19,6 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>. * along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/ */
declare(strict_types=1);
namespace FireflyIII\Events; namespace FireflyIII\Events;
@@ -27,6 +27,9 @@ use Illuminate\Queue\SerializesModels;
/** /**
* Class UpdatedTransactionJournal. * Class UpdatedTransactionJournal.
*
* @codeCoverageIgnore
*
*/ */
class UpdatedTransactionJournal extends Event class UpdatedTransactionJournal extends Event
{ {

View File

@@ -1,4 +1,5 @@
<?php <?php
declare(strict_types=1);
/** /**
* UserChangedEmail.php * UserChangedEmail.php
* Copyright (c) 2017 thegrumpydictator@gmail.com * Copyright (c) 2017 thegrumpydictator@gmail.com
@@ -18,7 +19,6 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>. * along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/ */
declare(strict_types=1);
namespace FireflyIII\Events; namespace FireflyIII\Events;

View File

@@ -1,4 +1,5 @@
<?php <?php
declare(strict_types=1);
/** /**
* FireflyException.php * FireflyException.php
* Copyright (c) 2017 thegrumpydictator@gmail.com * Copyright (c) 2017 thegrumpydictator@gmail.com
@@ -18,13 +19,14 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>. * along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/ */
declare(strict_types=1);
namespace FireflyIII\Exceptions; namespace FireflyIII\Exceptions;
use Exception;
/** /**
* Class FireflyException. * Class FireflyException.
*/ */
class FireflyException extends \Exception class FireflyException extends Exception
{ {
} }

View File

@@ -1,4 +1,5 @@
<?php <?php
declare(strict_types=1);
/** /**
* Handler.php * Handler.php
* Copyright (c) 2017 thegrumpydictator@gmail.com * Copyright (c) 2017 thegrumpydictator@gmail.com
@@ -18,7 +19,6 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>. * along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/ */
declare(strict_types=1);
namespace FireflyIII\Exceptions; namespace FireflyIII\Exceptions;
@@ -70,14 +70,15 @@ class Handler extends ExceptionHandler
return parent::render($request, $exception); return parent::render($request, $exception);
} }
if ($exception instanceof NotFoundHttpException && $request->expectsJson()) { if ($exception instanceof NotFoundHttpException && $request->expectsJson()) {
// JSON error:
return response()->json(['message' => 'Resource not found', 'exception' => 'NotFoundHttpException'], 404); return response()->json(['message' => 'Resource not found', 'exception' => 'NotFoundHttpException'], 404);
} }
if ($exception instanceof AuthenticationException && $request->expectsJson()) { if ($exception instanceof AuthenticationException && $request->expectsJson()) {
// somehow Laravel handler does not catch this:
return response()->json(['message' => 'Unauthenticated', 'exception' => 'AuthenticationException'], 401); return response()->json(['message' => 'Unauthenticated', 'exception' => 'AuthenticationException'], 401);
} }
if ($request->expectsJson()) { if ($request->expectsJson()) {
$isDebug = config('app.debug', false); $isDebug = config('app.debug', false);
if ($isDebug) { if ($isDebug) {

View File

@@ -1,4 +1,5 @@
<?php <?php
declare(strict_types=1);
/** /**
* NotImplementedException.php * NotImplementedException.php
* Copyright (c) 2017 thegrumpydictator@gmail.com * Copyright (c) 2017 thegrumpydictator@gmail.com
@@ -18,7 +19,6 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>. * along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/ */
declare(strict_types=1);
namespace FireflyIII\Exceptions; namespace FireflyIII\Exceptions;

View File

@@ -1,4 +1,5 @@
<?php <?php
declare(strict_types=1);
/** /**
* ValidationException.php * ValidationException.php
* Copyright (c) 2017 thegrumpydictator@gmail.com * Copyright (c) 2017 thegrumpydictator@gmail.com
@@ -18,7 +19,6 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>. * along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/ */
declare(strict_types=1);
namespace FireflyIII\Exceptions; namespace FireflyIII\Exceptions;

View File

@@ -1,4 +1,5 @@
<?php <?php
declare(strict_types=1);
/** /**
* AttachmentCollector.php * AttachmentCollector.php
* Copyright (c) 2017 thegrumpydictator@gmail.com * Copyright (c) 2017 thegrumpydictator@gmail.com
@@ -18,7 +19,6 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>. * along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/ */
declare(strict_types=1);
namespace FireflyIII\Export\Collector; namespace FireflyIII\Export\Collector;
@@ -118,7 +118,7 @@ class AttachmentCollector extends BasicCollector implements CollectorInterface
*/ */
private function exportFileName($attachment): string private function exportFileName($attachment): string
{ {
return sprintf('%s-Attachment nr. %s - %s', $this->job->key, strval($attachment->id), $attachment->filename); return sprintf('%s-Attachment nr. %s - %s', $this->job->key, (string)$attachment->id, $attachment->filename);
} }
/** /**
@@ -127,8 +127,7 @@ class AttachmentCollector extends BasicCollector implements CollectorInterface
private function getAttachments(): Collection private function getAttachments(): Collection
{ {
$this->repository->setUser($this->user); $this->repository->setUser($this->user);
$attachments = $this->repository->getBetween($this->start, $this->end);
return $attachments; return $this->repository->getBetween($this->start, $this->end);
} }
} }

View File

@@ -1,4 +1,5 @@
<?php <?php
declare(strict_types=1);
/** /**
* BasicCollector.php * BasicCollector.php
* Copyright (c) 2017 thegrumpydictator@gmail.com * Copyright (c) 2017 thegrumpydictator@gmail.com
@@ -18,7 +19,6 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>. * along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/ */
declare(strict_types=1);
namespace FireflyIII\Export\Collector; namespace FireflyIII\Export\Collector;

View File

@@ -1,4 +1,5 @@
<?php <?php
declare(strict_types=1);
/** /**
* CollectorInterface.php * CollectorInterface.php
* Copyright (c) 2017 thegrumpydictator@gmail.com * Copyright (c) 2017 thegrumpydictator@gmail.com
@@ -18,7 +19,6 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>. * along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/ */
declare(strict_types=1);
namespace FireflyIII\Export\Collector; namespace FireflyIII\Export\Collector;

View File

@@ -1,4 +1,5 @@
<?php <?php
declare(strict_types=1);
/** /**
* UploadCollector.php * UploadCollector.php
* Copyright (c) 2017 thegrumpydictator@gmail.com * Copyright (c) 2017 thegrumpydictator@gmail.com
@@ -18,13 +19,12 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>. * along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/ */
declare(strict_types=1);
namespace FireflyIII\Export\Collector; namespace FireflyIII\Export\Collector;
use Crypt; use Crypt;
use Exception;
use Illuminate\Contracts\Encryption\DecryptException; use Illuminate\Contracts\Encryption\DecryptException;
use Illuminate\Contracts\Filesystem\FileNotFoundException;
use Log; use Log;
use Storage; use Storage;
@@ -99,7 +99,7 @@ class UploadCollector extends BasicCollector implements CollectorInterface
$content = ''; $content = '';
try { try {
$content = Crypt::decrypt($this->uploadDisk->get(sprintf('%s.upload', $key))); $content = Crypt::decrypt($this->uploadDisk->get(sprintf('%s.upload', $key)));
} catch (FileNotFoundException | DecryptException $e) { } catch (Exception | DecryptException $e) {
Log::error(sprintf('Could not decrypt old import file "%s". Skipped because: %s', $key, $e->getMessage())); Log::error(sprintf('Could not decrypt old import file "%s". Skipped because: %s', $key, $e->getMessage()));
} }

View File

@@ -1,4 +1,5 @@
<?php <?php
declare(strict_types=1);
/** /**
* Entry.php * Entry.php
* Copyright (c) 2017 thegrumpydictator@gmail.com * Copyright (c) 2017 thegrumpydictator@gmail.com
@@ -18,7 +19,6 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>. * along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/ */
declare(strict_types=1);
namespace FireflyIII\Export\Entry; namespace FireflyIII\Export\Entry;
@@ -199,31 +199,29 @@ final class Entry
$entry->transaction_id = $transaction->id; $entry->transaction_id = $transaction->id;
$entry->date = $transaction->date->format('Ymd'); $entry->date = $transaction->date->format('Ymd');
$entry->description = $transaction->description; $entry->description = $transaction->description;
if (strlen(strval($transaction->transaction_description)) > 0) { if (strlen((string)$transaction->transaction_description) > 0) {
$entry->description = $transaction->transaction_description . '(' . $transaction->description . ')'; $entry->description = $transaction->transaction_description . '(' . $transaction->description . ')';
} }
$entry->currency_code = $transaction->transactionCurrency->code; $entry->currency_code = $transaction->transactionCurrency->code;
$entry->amount = strval(round($transaction->transaction_amount, $transaction->transactionCurrency->decimal_places)); $entry->amount = (string)round($transaction->transaction_amount, $transaction->transactionCurrency->decimal_places);
$entry->foreign_currency_code = null === $transaction->foreign_currency_id ? null : $transaction->foreignCurrency->code; $entry->foreign_currency_code = null === $transaction->foreign_currency_id ? null : $transaction->foreignCurrency->code;
$entry->foreign_amount = null === $transaction->foreign_currency_id $entry->foreign_amount = null === $transaction->foreign_currency_id
? null ? null
: strval( : (string)round(
round( $transaction->transaction_foreign_amount,
$transaction->transaction_foreign_amount, $transaction->foreignCurrency->decimal_places
$transaction->foreignCurrency->decimal_places
)
); );
$entry->transaction_type = $transaction->transaction_type_type; $entry->transaction_type = $transaction->transaction_type_type;
$entry->asset_account_id = strval($transaction->account_id); $entry->asset_account_id = (string)$transaction->account_id;
$entry->asset_account_name = app('steam')->tryDecrypt($transaction->account_name); $entry->asset_account_name = app('steam')->tryDecrypt($transaction->account_name);
$entry->asset_account_iban = $transaction->account_iban; $entry->asset_account_iban = $transaction->account_iban;
$entry->asset_account_number = $transaction->account_number; $entry->asset_account_number = $transaction->account_number;
$entry->asset_account_bic = $transaction->account_bic; $entry->asset_account_bic = $transaction->account_bic;
$entry->asset_currency_code = $transaction->account_currency_code; $entry->asset_currency_code = $transaction->account_currency_code;
$entry->opposing_account_id = strval($transaction->opposing_account_id); $entry->opposing_account_id = (string)$transaction->opposing_account_id;
$entry->opposing_account_name = app('steam')->tryDecrypt($transaction->opposing_account_name); $entry->opposing_account_name = app('steam')->tryDecrypt($transaction->opposing_account_name);
$entry->opposing_account_iban = $transaction->opposing_account_iban; $entry->opposing_account_iban = $transaction->opposing_account_iban;
$entry->opposing_account_number = $transaction->opposing_account_number; $entry->opposing_account_number = $transaction->opposing_account_number;
@@ -231,7 +229,7 @@ final class Entry
$entry->opposing_currency_code = $transaction->opposing_currency_code; $entry->opposing_currency_code = $transaction->opposing_currency_code;
// budget // budget
$entry->budget_id = strval($transaction->transaction_budget_id); $entry->budget_id = (string)$transaction->transaction_budget_id;
$entry->budget_name = app('steam')->tryDecrypt($transaction->transaction_budget_name); $entry->budget_name = app('steam')->tryDecrypt($transaction->transaction_budget_name);
if (null === $transaction->transaction_budget_id) { if (null === $transaction->transaction_budget_id) {
$entry->budget_id = $transaction->transaction_journal_budget_id; $entry->budget_id = $transaction->transaction_journal_budget_id;
@@ -239,7 +237,7 @@ final class Entry
} }
// category // category
$entry->category_id = strval($transaction->transaction_category_id); $entry->category_id = (string)$transaction->transaction_category_id;
$entry->category_name = app('steam')->tryDecrypt($transaction->transaction_category_name); $entry->category_name = app('steam')->tryDecrypt($transaction->transaction_category_name);
if (null === $transaction->transaction_category_id) { if (null === $transaction->transaction_category_id) {
$entry->category_id = $transaction->transaction_journal_category_id; $entry->category_id = $transaction->transaction_journal_category_id;
@@ -247,7 +245,7 @@ final class Entry
} }
// budget // budget
$entry->bill_id = strval($transaction->bill_id); $entry->bill_id = (string)$transaction->bill_id;
$entry->bill_name = app('steam')->tryDecrypt($transaction->bill_name); $entry->bill_name = app('steam')->tryDecrypt($transaction->bill_name);
$entry->tags = $transaction->tags; $entry->tags = $transaction->tags;

View File

@@ -1,4 +1,5 @@
<?php <?php
declare(strict_types=1);
/** /**
* ExpandedProcessor.php * ExpandedProcessor.php
* Copyright (c) 2017 thegrumpydictator@gmail.com * Copyright (c) 2017 thegrumpydictator@gmail.com
@@ -18,7 +19,6 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>. * along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/ */
declare(strict_types=1);
namespace FireflyIII\Export; namespace FireflyIII\Export;
@@ -118,13 +118,13 @@ class ExpandedProcessor implements ProcessorInterface
$currencies = $this->getAccountCurrencies($ibans); $currencies = $this->getAccountCurrencies($ibans);
$transactions->each( $transactions->each(
function (Transaction $transaction) use ($notes, $tags, $ibans, $currencies) { function (Transaction $transaction) use ($notes, $tags, $ibans, $currencies) {
$journalId = intval($transaction->journal_id); $journalId = (int)$transaction->journal_id;
$accountId = intval($transaction->account_id); $accountId = (int)$transaction->account_id;
$opposingId = intval($transaction->opposing_account_id); $opposingId = (int)$transaction->opposing_account_id;
$currencyId = $ibans[$accountId]['currency_id'] ?? 0; $currencyId = (int)($ibans[$accountId]['currency_id'] ?? 0.0);
$opposingCurrencyId = $ibans[$opposingId]['currency_id'] ?? 0; $opposingCurrencyId = (int)($ibans[$opposingId]['currency_id'] ?? 0.0);
$transaction->notes = $notes[$journalId] ?? ''; $transaction->notes = $notes[$journalId] ?? '';
$transaction->tags = join(',', $tags[$journalId] ?? []); $transaction->tags = implode(',', $tags[$journalId] ?? []);
$transaction->account_number = $ibans[$accountId]['accountNumber'] ?? ''; $transaction->account_number = $ibans[$accountId]['accountNumber'] ?? '';
$transaction->account_bic = $ibans[$accountId]['BIC'] ?? ''; $transaction->account_bic = $ibans[$accountId]['BIC'] ?? '';
$transaction->account_currency_code = $currencies[$currencyId] ?? ''; $transaction->account_currency_code = $currencies[$currencyId] ?? '';
@@ -263,7 +263,7 @@ class ExpandedProcessor implements ProcessorInterface
$ids = []; $ids = [];
$repository->setUser($this->job->user); $repository->setUser($this->job->user);
foreach ($array as $value) { foreach ($array as $value) {
$ids[] = $value['currency_id'] ?? 0; $ids[] = (int)($value['currency_id'] ?? 0.0);
} }
$ids = array_unique($ids); $ids = array_unique($ids);
$result = $repository->getByIds($ids); $result = $repository->getByIds($ids);
@@ -293,7 +293,7 @@ class ExpandedProcessor implements ProcessorInterface
->get(['account_meta.id', 'account_meta.account_id', 'account_meta.name', 'account_meta.data']); ->get(['account_meta.id', 'account_meta.account_id', 'account_meta.name', 'account_meta.data']);
/** @var AccountMeta $meta */ /** @var AccountMeta $meta */
foreach ($set as $meta) { foreach ($set as $meta) {
$id = intval($meta->account_id); $id = (int)$meta->account_id;
$return[$id][$meta->name] = $meta->data; $return[$id][$meta->name] = $meta->data;
} }
@@ -316,8 +316,8 @@ class ExpandedProcessor implements ProcessorInterface
$return = []; $return = [];
/** @var Note $note */ /** @var Note $note */
foreach ($notes as $note) { foreach ($notes as $note) {
if (strlen(trim(strval($note->text))) > 0) { if (strlen(trim((string)$note->text)) > 0) {
$id = intval($note->noteable_id); $id = (int)$note->noteable_id;
$return[$id] = $note->text; $return[$id] = $note->text;
} }
} }
@@ -331,6 +331,7 @@ class ExpandedProcessor implements ProcessorInterface
* @param array $array * @param array $array
* *
* @return array * @return array
* @throws \Illuminate\Contracts\Encryption\DecryptException
*/ */
private function getTags(array $array): array private function getTags(array $array): array
{ {
@@ -342,8 +343,8 @@ class ExpandedProcessor implements ProcessorInterface
->get(['tag_transaction_journal.transaction_journal_id', 'tags.tag']); ->get(['tag_transaction_journal.transaction_journal_id', 'tags.tag']);
$result = []; $result = [];
foreach ($set as $entry) { foreach ($set as $entry) {
$id = intval($entry->transaction_journal_id); $id = (int)$entry->transaction_journal_id;
$result[$id] = isset($result[$id]) ? $result[$id] : []; $result[$id] = $result[$id] ?? [];
$result[$id][] = Crypt::decrypt($entry->tag); $result[$id][] = Crypt::decrypt($entry->tag);
} }

View File

@@ -1,4 +1,5 @@
<?php <?php
declare(strict_types=1);
/** /**
* BasicExporter.php * BasicExporter.php
* Copyright (c) 2017 thegrumpydictator@gmail.com * Copyright (c) 2017 thegrumpydictator@gmail.com
@@ -18,7 +19,6 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>. * along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/ */
declare(strict_types=1);
namespace FireflyIII\Export\Exporter; namespace FireflyIII\Export\Exporter;

View File

@@ -1,4 +1,5 @@
<?php <?php
declare(strict_types=1);
/** /**
* CsvExporter.php * CsvExporter.php
* Copyright (c) 2017 thegrumpydictator@gmail.com * Copyright (c) 2017 thegrumpydictator@gmail.com
@@ -18,7 +19,6 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>. * along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/ */
declare(strict_types=1);
namespace FireflyIII\Export\Exporter; namespace FireflyIII\Export\Exporter;
@@ -34,14 +34,6 @@ class CsvExporter extends BasicExporter implements ExporterInterface
/** @var string */ /** @var string */
private $fileName; private $fileName;
/**
* CsvExporter constructor.
*/
public function __construct()
{
parent::__construct();
}
/** /**
* @return string * @return string
*/ */
@@ -53,7 +45,6 @@ class CsvExporter extends BasicExporter implements ExporterInterface
/** /**
* @return bool * @return bool
* *
* @throws \TypeError
*/ */
public function run(): bool public function run(): bool
{ {

View File

@@ -1,4 +1,5 @@
<?php <?php
declare(strict_types=1);
/** /**
* ExporterInterface.php * ExporterInterface.php
* Copyright (c) 2017 thegrumpydictator@gmail.com * Copyright (c) 2017 thegrumpydictator@gmail.com
@@ -18,7 +19,6 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>. * along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/ */
declare(strict_types=1);
namespace FireflyIII\Export\Exporter; namespace FireflyIII\Export\Exporter;

View File

@@ -1,4 +1,5 @@
<?php <?php
declare(strict_types=1);
/** /**
* ProcessorInterface.php * ProcessorInterface.php
* Copyright (c) 2017 thegrumpydictator@gmail.com * Copyright (c) 2017 thegrumpydictator@gmail.com
@@ -18,7 +19,6 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>. * along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/ */
declare(strict_types=1);
namespace FireflyIII\Export; namespace FireflyIII\Export;

View File

@@ -1,4 +1,5 @@
<?php <?php
declare(strict_types=1);
/** /**
* AccountFactory.php * AccountFactory.php
* Copyright (c) 2018 thegrumpydictator@gmail.com * Copyright (c) 2018 thegrumpydictator@gmail.com
@@ -19,7 +20,6 @@
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>. * along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/ */
declare(strict_types=1);
namespace FireflyIII\Factory; namespace FireflyIII\Factory;
@@ -63,8 +63,8 @@ class AccountFactory
'user_id' => $this->user->id, 'user_id' => $this->user->id,
'account_type_id' => $type->id, 'account_type_id' => $type->id,
'name' => $data['name'], 'name' => $data['name'],
'virtual_balance' => strlen(strval($data['virtualBalance'])) === 0 ? '0' : $data['virtualBalance'], 'virtual_balance' => $data['virtualBalance'] ?? '0',
'active' => true === $data['active'] ? true : false, 'active' => true === $data['active'],
'iban' => $data['iban'], 'iban' => $data['iban'],
]; ];
@@ -73,8 +73,13 @@ class AccountFactory
$databaseData['virtual_balance'] = '0'; $databaseData['virtual_balance'] = '0';
} }
// fix virtual balance when it's empty
if ($databaseData['virtual_balance'] === '') {
$databaseData['virtual_balance'] = '0';
}
$newAccount = Account::create($databaseData); $newAccount = Account::create($databaseData);
$this->updateMetadata($newAccount, $data); $this->updateMetaData($newAccount, $data);
if ($this->validIBData($data) && $type->type === AccountType::ASSET) { if ($this->validIBData($data) && $type->type === AccountType::ASSET) {
$this->updateIB($newAccount, $data); $this->updateIB($newAccount, $data);
@@ -158,14 +163,19 @@ class AccountFactory
*/ */
protected function getAccountType(?int $accountTypeId, ?string $accountType): ?AccountType protected function getAccountType(?int $accountTypeId, ?string $accountType): ?AccountType
{ {
$accountTypeId = intval($accountTypeId); $accountTypeId = (int)$accountTypeId;
if ($accountTypeId > 0) { if ($accountTypeId > 0) {
return AccountType::find($accountTypeId); return AccountType::find($accountTypeId);
} }
$type = config('firefly.accountTypeByIdentifier.' . strval($accountType)); $type = config('firefly.accountTypeByIdentifier.' . (string)$accountType);
$result = AccountType::whereType($type)->first();
if (null === $result && null !== $accountType) {
// try as full name:
$result = AccountType::whereType($accountType)->first();
}
return AccountType::whereType($type)->first(); return $result;
} }
} }

View File

@@ -1,4 +1,5 @@
<?php <?php
declare(strict_types=1);
/** /**
* AccountMetaFactory.php * AccountMetaFactory.php
* Copyright (c) 2018 thegrumpydictator@gmail.com * Copyright (c) 2018 thegrumpydictator@gmail.com
@@ -19,7 +20,6 @@
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>. * along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/ */
declare(strict_types=1);
namespace FireflyIII\Factory; namespace FireflyIII\Factory;
@@ -40,4 +40,4 @@ class AccountMetaFactory
return AccountMeta::create($data); return AccountMeta::create($data);
} }
} }

View File

@@ -1,4 +1,5 @@
<?php <?php
declare(strict_types=1);
/** /**
* BillFactory.php * BillFactory.php
* Copyright (c) 2018 thegrumpydictator@gmail.com * Copyright (c) 2018 thegrumpydictator@gmail.com
@@ -19,7 +20,6 @@
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>. * along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/ */
declare(strict_types=1);
namespace FireflyIII\Factory; namespace FireflyIII\Factory;
@@ -47,7 +47,7 @@ class BillFactory
{ {
$matchArray = explode(',', $data['match']); $matchArray = explode(',', $data['match']);
$matchArray = array_unique($matchArray); $matchArray = array_unique($matchArray);
$match = join(',', $matchArray); $match = implode(',', $matchArray);
/** @var Bill $bill */ /** @var Bill $bill */
$bill = Bill::create( $bill = Bill::create(
@@ -81,14 +81,14 @@ class BillFactory
*/ */
public function find(?int $billId, ?string $billName): ?Bill public function find(?int $billId, ?string $billName): ?Bill
{ {
$billId = intval($billId); $billId = (int)$billId;
$billName = strval($billName); $billName = (string)$billName;
// first find by ID: // first find by ID:
if ($billId > 0) { if ($billId > 0) {
/** @var Bill $bill */ /** @var Bill $bill */
$bill = $this->user->bills()->find($billId); $bill = $this->user->bills()->find($billId);
if (!is_null($bill)) { if (null !== $bill) {
return $bill; return $bill;
} }
} }
@@ -96,7 +96,7 @@ class BillFactory
// then find by name: // then find by name:
if (strlen($billName) > 0) { if (strlen($billName) > 0) {
$bill = $this->findByName($billName); $bill = $this->findByName($billName);
if (!is_null($bill)) { if (null !== $bill) {
return $bill; return $bill;
} }
} }
@@ -134,4 +134,4 @@ class BillFactory
$this->user = $user; $this->user = $user;
} }
} }

View File

@@ -1,4 +1,5 @@
<?php <?php
declare(strict_types=1);
/** /**
* BudgetFactory.php * BudgetFactory.php
* Copyright (c) 2018 thegrumpydictator@gmail.com * Copyright (c) 2018 thegrumpydictator@gmail.com
@@ -19,7 +20,6 @@
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>. * along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/ */
declare(strict_types=1);
namespace FireflyIII\Factory; namespace FireflyIII\Factory;
@@ -44,8 +44,8 @@ class BudgetFactory
*/ */
public function find(?int $budgetId, ?string $budgetName): ?Budget public function find(?int $budgetId, ?string $budgetName): ?Budget
{ {
$budgetId = intval($budgetId); $budgetId = (int)$budgetId;
$budgetName = strval($budgetName); $budgetName = (string)$budgetName;
if (strlen($budgetName) === 0 && $budgetId === 0) { if (strlen($budgetName) === 0 && $budgetId === 0) {
return null; return null;
@@ -55,14 +55,14 @@ class BudgetFactory
if ($budgetId > 0) { if ($budgetId > 0) {
/** @var Budget $budget */ /** @var Budget $budget */
$budget = $this->user->budgets()->find($budgetId); $budget = $this->user->budgets()->find($budgetId);
if (!is_null($budget)) { if (null !== $budget) {
return $budget; return $budget;
} }
} }
if (strlen($budgetName) > 0) { if (strlen($budgetName) > 0) {
$budget = $this->findByName($budgetName); $budget = $this->findByName($budgetName);
if (!is_null($budget)) { if (null !== $budget) {
return $budget; return $budget;
} }
} }
@@ -97,4 +97,4 @@ class BudgetFactory
$this->user = $user; $this->user = $user;
} }
} }

View File

@@ -1,4 +1,5 @@
<?php <?php
declare(strict_types=1);
/** /**
* CategoryFactory.php * CategoryFactory.php
* Copyright (c) 2018 thegrumpydictator@gmail.com * Copyright (c) 2018 thegrumpydictator@gmail.com
@@ -19,7 +20,6 @@
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>. * along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/ */
declare(strict_types=1);
namespace FireflyIII\Factory; namespace FireflyIII\Factory;
@@ -44,16 +44,18 @@ class CategoryFactory
*/ */
public function findByName(string $name): ?Category public function findByName(string $name): ?Category
{ {
$result = null;
/** @var Collection $collection */ /** @var Collection $collection */
$collection = $this->user->categories()->get(); $collection = $this->user->categories()->get();
/** @var Category $category */ /** @var Category $category */
foreach ($collection as $category) { foreach ($collection as $category) {
if ($category->name === $name) { if ($category->name === $name) {
return $category; $result = $category;
break;
} }
} }
return null; return $result;
} }
/** /**
@@ -64,8 +66,8 @@ class CategoryFactory
*/ */
public function findOrCreate(?int $categoryId, ?string $categoryName): ?Category public function findOrCreate(?int $categoryId, ?string $categoryName): ?Category
{ {
$categoryId = intval($categoryId); $categoryId = (int)$categoryId;
$categoryName = strval($categoryName); $categoryName = (string)$categoryName;
Log::debug(sprintf('Going to find category with ID %d and name "%s"', $categoryId, $categoryName)); Log::debug(sprintf('Going to find category with ID %d and name "%s"', $categoryId, $categoryName));
@@ -76,14 +78,14 @@ class CategoryFactory
if ($categoryId > 0) { if ($categoryId > 0) {
/** @var Category $category */ /** @var Category $category */
$category = $this->user->categories()->find($categoryId); $category = $this->user->categories()->find($categoryId);
if (!is_null($category)) { if (null !== $category) {
return $category; return $category;
} }
} }
if (strlen($categoryName) > 0) { if (strlen($categoryName) > 0) {
$category = $this->findByName($categoryName); $category = $this->findByName($categoryName);
if (!is_null($category)) { if (null !== $category) {
return $category; return $category;
} }
@@ -106,4 +108,4 @@ class CategoryFactory
$this->user = $user; $this->user = $user;
} }
} }

View File

@@ -1,4 +1,5 @@
<?php <?php
declare(strict_types=1);
/** /**
* PiggyBankEventFactory.php * PiggyBankEventFactory.php
* Copyright (c) 2018 thegrumpydictator@gmail.com * Copyright (c) 2018 thegrumpydictator@gmail.com
@@ -19,7 +20,6 @@
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>. * along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/ */
declare(strict_types=1);
namespace FireflyIII\Factory; namespace FireflyIII\Factory;
@@ -46,7 +46,7 @@ class PiggyBankEventFactory
public function create(TransactionJournal $journal, ?PiggyBank $piggyBank): ?PiggyBankEvent public function create(TransactionJournal $journal, ?PiggyBank $piggyBank): ?PiggyBankEvent
{ {
Log::debug(sprintf('Now in PiggyBankEventCreate for a %s', $journal->transactionType->type)); Log::debug(sprintf('Now in PiggyBankEventCreate for a %s', $journal->transactionType->type));
if (is_null($piggyBank)) { if (null === $piggyBank) {
return null; return null;
} }
@@ -85,4 +85,4 @@ class PiggyBankEventFactory
return $event; return $event;
} }
} }

View File

@@ -1,4 +1,5 @@
<?php <?php
declare(strict_types=1);
/** /**
* PiggyBankFactory.php * PiggyBankFactory.php
* Copyright (c) 2018 thegrumpydictator@gmail.com * Copyright (c) 2018 thegrumpydictator@gmail.com
@@ -19,7 +20,6 @@
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>. * along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/ */
declare(strict_types=1);
namespace FireflyIII\Factory; namespace FireflyIII\Factory;
@@ -43,8 +43,8 @@ class PiggyBankFactory
*/ */
public function find(?int $piggyBankId, ?string $piggyBankName): ?PiggyBank public function find(?int $piggyBankId, ?string $piggyBankName): ?PiggyBank
{ {
$piggyBankId = intval($piggyBankId); $piggyBankId = (int)$piggyBankId;
$piggyBankName = strval($piggyBankName); $piggyBankName = (string)$piggyBankName;
if (strlen($piggyBankName) === 0 && $piggyBankId === 0) { if (strlen($piggyBankName) === 0 && $piggyBankId === 0) {
return null; return null;
} }
@@ -52,7 +52,7 @@ class PiggyBankFactory
if ($piggyBankId > 0) { if ($piggyBankId > 0) {
/** @var PiggyBank $piggyBank */ /** @var PiggyBank $piggyBank */
$piggyBank = $this->user->piggyBanks()->find($piggyBankId); $piggyBank = $this->user->piggyBanks()->find($piggyBankId);
if (!is_null($piggyBank)) { if (null !== $piggyBank) {
return $piggyBank; return $piggyBank;
} }
} }
@@ -61,7 +61,7 @@ class PiggyBankFactory
if (strlen($piggyBankName) > 0) { if (strlen($piggyBankName) > 0) {
/** @var PiggyBank $piggyBank */ /** @var PiggyBank $piggyBank */
$piggyBank = $this->findByName($piggyBankName); $piggyBank = $this->findByName($piggyBankName);
if (!is_null($piggyBank)) { if (null !== $piggyBank) {
return $piggyBank; return $piggyBank;
} }
} }
@@ -97,4 +97,4 @@ class PiggyBankFactory
} }
} }

View File

@@ -1,4 +1,5 @@
<?php <?php
declare(strict_types=1);
/** /**
* TagFactory.php * TagFactory.php
* Copyright (c) 2018 thegrumpydictator@gmail.com * Copyright (c) 2018 thegrumpydictator@gmail.com
@@ -19,7 +20,6 @@
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>. * along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/ */
declare(strict_types=1);
namespace FireflyIII\Factory; namespace FireflyIII\Factory;
@@ -65,7 +65,7 @@ class TagFactory
*/ */
public function findOrCreate(string $tag): ?Tag public function findOrCreate(string $tag): ?Tag
{ {
if (is_null($this->tags)) { if (null === $this->tags) {
$this->tags = $this->user->tags()->get(); $this->tags = $this->user->tags()->get();
} }
@@ -99,4 +99,4 @@ class TagFactory
$this->user = $user; $this->user = $user;
} }
} }

View File

@@ -1,4 +1,5 @@
<?php <?php
declare(strict_types=1);
/** /**
* TransactionCurrencyFactory.php * TransactionCurrencyFactory.php
* Copyright (c) 2018 thegrumpydictator@gmail.com * Copyright (c) 2018 thegrumpydictator@gmail.com
@@ -19,17 +20,43 @@
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>. * along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/ */
declare(strict_types=1);
namespace FireflyIII\Factory; namespace FireflyIII\Factory;
use FireflyIII\Models\TransactionCurrency; use FireflyIII\Models\TransactionCurrency;
use Illuminate\Database\QueryException;
use Log;
/** /**
* Class TransactionCurrencyFactory * Class TransactionCurrencyFactory
*/ */
class TransactionCurrencyFactory class TransactionCurrencyFactory
{ {
/**
* @param array $data
*
* @return TransactionCurrency|null
*/
public function create(array $data): ?TransactionCurrency
{
$result = null;
try {
/** @var TransactionCurrency $currency */
$result = TransactionCurrency::create(
[
'name' => $data['name'],
'code' => $data['code'],
'symbol' => $data['symbol'],
'decimal_places' => $data['decimal_places'],
]
);
} catch (QueryException $e) {
Log::error(sprintf('Could not create new currency: %s', $e->getMessage()));
}
return $result;
}
/** /**
* @param int|null $currencyId * @param int|null $currencyId
* @param null|string $currencyCode * @param null|string $currencyCode
@@ -38,24 +65,24 @@ class TransactionCurrencyFactory
*/ */
public function find(?int $currencyId, ?string $currencyCode): ?TransactionCurrency public function find(?int $currencyId, ?string $currencyCode): ?TransactionCurrency
{ {
$currencyCode = strval($currencyCode); $currencyCode = (string)$currencyCode;
$currencyId = intval($currencyId); $currencyId = (int)$currencyId;
if (strlen($currencyCode) === 0 && intval($currencyId) === 0) { if (strlen($currencyCode) === 0 && (int)$currencyId === 0) {
return null; return null;
} }
// first by ID: // first by ID:
if ($currencyId > 0) { if ($currencyId > 0) {
$currency = TransactionCurrency::find($currencyId); $currency = TransactionCurrency::find($currencyId);
if (!is_null($currency)) { if (null !== $currency) {
return $currency; return $currency;
} }
} }
// then by code: // then by code:
if (strlen($currencyCode) > 0) { if (strlen($currencyCode) > 0) {
$currency = TransactionCurrency::whereCode($currencyCode)->first(); $currency = TransactionCurrency::whereCode($currencyCode)->first();
if (!is_null($currency)) { if (null !== $currency) {
return $currency; return $currency;
} }
} }
@@ -64,4 +91,4 @@ class TransactionCurrencyFactory
} }
} }

View File

@@ -1,4 +1,5 @@
<?php <?php
declare(strict_types=1);
/** /**
* TransactionFactory.php * TransactionFactory.php
* Copyright (c) 2018 thegrumpydictator@gmail.com * Copyright (c) 2018 thegrumpydictator@gmail.com
@@ -19,13 +20,13 @@
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>. * along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/ */
declare(strict_types=1);
namespace FireflyIII\Factory; namespace FireflyIII\Factory;
use FireflyIII\Models\Transaction; use FireflyIII\Models\Transaction;
use FireflyIII\Models\TransactionJournal; use FireflyIII\Models\TransactionJournal;
use FireflyIII\Models\TransactionType;
use FireflyIII\Services\Internal\Support\TransactionServiceTrait; use FireflyIII\Services\Internal\Support\TransactionServiceTrait;
use FireflyIII\User; use FireflyIII\User;
use Illuminate\Support\Collection; use Illuminate\Support\Collection;
@@ -89,7 +90,7 @@ class TransactionFactory
$source = $this->create( $source = $this->create(
[ [
'description' => $description, 'description' => $description,
'amount' => app('steam')->negative(strval($data['amount'])), 'amount' => app('steam')->negative((string)$data['amount']),
'foreign_amount' => null, 'foreign_amount' => null,
'currency' => $currency, 'currency' => $currency,
'account' => $sourceAccount, 'account' => $sourceAccount,
@@ -102,7 +103,7 @@ class TransactionFactory
$dest = $this->create( $dest = $this->create(
[ [
'description' => $description, 'description' => $description,
'amount' => app('steam')->positive(strval($data['amount'])), 'amount' => app('steam')->positive((string)$data['amount']),
'foreign_amount' => null, 'foreign_amount' => null,
'currency' => $currency, 'currency' => $currency,
'account' => $destinationAccount, 'account' => $destinationAccount,
@@ -118,12 +119,17 @@ class TransactionFactory
$this->setForeignCurrency($dest, $foreign); $this->setForeignCurrency($dest, $foreign);
// set foreign amount: // set foreign amount:
if (!is_null($data['foreign_amount'])) { if (null !== $data['foreign_amount']) {
$this->setForeignAmount($source, app('steam')->negative(strval($data['foreign_amount']))); $this->setForeignAmount($source, app('steam')->negative((string)$data['foreign_amount']));
$this->setForeignAmount($dest, app('steam')->positive(strval($data['foreign_amount']))); $this->setForeignAmount($dest, app('steam')->positive((string)$data['foreign_amount']));
} }
// set budget: // set budget:
if ($journal->transactionType->type === TransactionType::TRANSFER) {
$data['budget_id'] = null;
$data['budget_name'] = null;
}
$budget = $this->findBudget($data['budget_id'], $data['budget_name']); $budget = $this->findBudget($data['budget_id'], $data['budget_name']);
$this->setBudget($source, $budget); $this->setBudget($source, $budget);
$this->setBudget($dest, $budget); $this->setBudget($dest, $budget);
@@ -145,4 +151,4 @@ class TransactionFactory
} }
} }

View File

@@ -1,4 +1,5 @@
<?php <?php
declare(strict_types=1);
/** /**
* TransactionJournalFactory.php * TransactionJournalFactory.php
* Copyright (c) 2018 thegrumpydictator@gmail.com * Copyright (c) 2018 thegrumpydictator@gmail.com
@@ -19,7 +20,6 @@
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>. * along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/ */
declare(strict_types=1);
namespace FireflyIII\Factory; namespace FireflyIII\Factory;
@@ -40,8 +40,6 @@ class TransactionJournalFactory
private $user; private $user;
/** /**
* Create a new transaction journal and associated transactions.
*
* @param array $data * @param array $data
* *
* @return TransactionJournal * @return TransactionJournal
@@ -68,6 +66,7 @@ class TransactionJournalFactory
); );
// store basic transactions: // store basic transactions:
/** @var TransactionFactory $factory */
$factory = app(TransactionFactory::class); $factory = app(TransactionFactory::class);
$factory->setUser($this->user); $factory->setUser($this->user);
@@ -88,16 +87,15 @@ class TransactionJournalFactory
$this->connectTags($journal, $data); $this->connectTags($journal, $data);
// store note: // store note:
$this->storeNote($journal, strval($data['notes'])); $this->storeNote($journal, (string)$data['notes']);
// store date meta fields (if present): // store date meta fields (if present):
$this->storeMeta($journal, $data, 'interest_date'); $fields = ['sepa-cc', 'sepa-ct-op', 'sepa-ct-id', 'sepa-db', 'sepa-country', 'sepa-ep', 'sepa-ci', 'interest_date', 'book_date', 'process_date',
$this->storeMeta($journal, $data, 'book_date'); 'due_date', 'payment_date', 'invoice_date', 'internal_reference', 'bunq_payment_id'];
$this->storeMeta($journal, $data, 'process_date');
$this->storeMeta($journal, $data, 'due_date'); foreach ($fields as $field) {
$this->storeMeta($journal, $data, 'payment_date'); $this->storeMeta($journal, $data, $field);
$this->storeMeta($journal, $data, 'invoice_date'); }
$this->storeMeta($journal, $data, 'internal_reference');
Log::debug('End of TransactionJournalFactory::create()'); Log::debug('End of TransactionJournalFactory::create()');
return $journal; return $journal;
@@ -124,7 +122,7 @@ class TransactionJournalFactory
$factory->setUser($this->user); $factory->setUser($this->user);
$piggyBank = $factory->find($data['piggy_bank_id'], $data['piggy_bank_name']); $piggyBank = $factory->find($data['piggy_bank_id'], $data['piggy_bank_name']);
if (!is_null($piggyBank)) { if (null !== $piggyBank) {
/** @var PiggyBankEventFactory $factory */ /** @var PiggyBankEventFactory $factory */
$factory = app(PiggyBankEventFactory::class); $factory = app(PiggyBankEventFactory::class);
$factory->create($journal, $piggyBank); $factory->create($journal, $piggyBank);
@@ -144,11 +142,12 @@ class TransactionJournalFactory
{ {
$factory = app(TransactionTypeFactory::class); $factory = app(TransactionTypeFactory::class);
$transactionType = $factory->find($type); $transactionType = $factory->find($type);
if (is_null($transactionType)) { if (null === $transactionType) {
Log::error(sprintf('Could not find transaction type for "%s"', $type)); // @codeCoverageIgnore
throw new FireflyException(sprintf('Could not find transaction type for "%s"', $type)); // @codeCoverageIgnore throw new FireflyException(sprintf('Could not find transaction type for "%s"', $type)); // @codeCoverageIgnore
} }
return $transactionType; return $transactionType;
} }
} }

View File

@@ -1,4 +1,5 @@
<?php <?php
declare(strict_types=1);
/** /**
* TransactionJournalMetaFactory.php * TransactionJournalMetaFactory.php
* Copyright (c) 2018 thegrumpydictator@gmail.com * Copyright (c) 2018 thegrumpydictator@gmail.com
@@ -19,7 +20,6 @@
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>. * along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/ */
declare(strict_types=1);
namespace FireflyIII\Factory; namespace FireflyIII\Factory;
@@ -43,7 +43,7 @@ class TransactionJournalMetaFactory
$value = $data['data']; $value = $data['data'];
/** @var TransactionJournalMeta $entry */ /** @var TransactionJournalMeta $entry */
$entry = $data['journal']->transactionJournalMeta()->where('name', $data['name'])->first(); $entry = $data['journal']->transactionJournalMeta()->where('name', $data['name'])->first();
if (is_null($value) && !is_null($entry)) { if (null === $value && null !== $entry) {
try { try {
$entry->delete(); $entry->delete();
} catch (Exception $e) { // @codeCoverageIgnore } catch (Exception $e) { // @codeCoverageIgnore
@@ -56,7 +56,18 @@ class TransactionJournalMetaFactory
if ($data['data'] instanceof Carbon) { if ($data['data'] instanceof Carbon) {
$value = $data['data']->toW3cString(); $value = $data['data']->toW3cString();
} }
if ((string)$value === '') {
// don't store blank strings.
if (null !== $entry) {
try {
$entry->delete();
} catch (Exception $e) { // @codeCoverageIgnore
Log::error(sprintf('Could not delete transaction journal meta: %s', $e->getMessage())); // @codeCoverageIgnore
}
}
return null;
}
if (null === $entry) { if (null === $entry) {
$entry = new TransactionJournalMeta(); $entry = new TransactionJournalMeta();
@@ -69,4 +80,4 @@ class TransactionJournalMetaFactory
return $entry; return $entry;
} }
} }

View File

@@ -1,4 +1,5 @@
<?php <?php
declare(strict_types=1);
/** /**
* TransactionTypeFactory.php * TransactionTypeFactory.php
* Copyright (c) 2018 thegrumpydictator@gmail.com * Copyright (c) 2018 thegrumpydictator@gmail.com
@@ -19,7 +20,6 @@
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>. * along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/ */
declare(strict_types=1);
namespace FireflyIII\Factory; namespace FireflyIII\Factory;
@@ -41,4 +41,4 @@ class TransactionTypeFactory
return TransactionType::whereType(ucfirst($type))->first(); return TransactionType::whereType(ucfirst($type))->first();
} }
} }

View File

@@ -128,7 +128,7 @@ class ChartJsGenerator implements GeneratorInterface
$index = 0; $index = 0;
foreach ($data as $key => $value) { foreach ($data as $key => $value) {
// make larger than 0 // make larger than 0
$chartData['datasets'][0]['data'][] = floatval(Steam::positive($value)); $chartData['datasets'][0]['data'][] = (float)Steam::positive($value);
$chartData['datasets'][0]['backgroundColor'][] = ChartColour::getColour($index); $chartData['datasets'][0]['backgroundColor'][] = ChartColour::getColour($index);
$chartData['labels'][] = $key; $chartData['labels'][] = $key;
++$index; ++$index;

View File

@@ -43,12 +43,11 @@ class MonthReportGenerator implements ReportGeneratorInterface
/** /**
* @return string * @return string
* *
* @throws \Throwable
*/ */
public function generate(): string public function generate(): string
{ {
$accountIds = join(',', $this->accounts->pluck('id')->toArray()); $accountIds = implode(',', $this->accounts->pluck('id')->toArray());
$expenseIds = join(',', $this->expense->pluck('id')->toArray()); $expenseIds = implode(',', $this->expense->pluck('id')->toArray());
$reportType = 'account'; $reportType = 'account';
$preferredPeriod = $this->preferredPeriod(); $preferredPeriod = $this->preferredPeriod();

View File

@@ -60,7 +60,7 @@ class MonthReportGenerator implements ReportGeneratorInterface
$defaultShow = ['icon', 'description', 'balance_before', 'amount', 'balance_after', 'date', 'to']; $defaultShow = ['icon', 'description', 'balance_before', 'amount', 'balance_after', 'date', 'to'];
$reportType = 'audit'; $reportType = 'audit';
$accountIds = join(',', $this->accounts->pluck('id')->toArray()); $accountIds = implode(',', $this->accounts->pluck('id')->toArray());
$hideable = ['buttons', 'icon', 'description', 'balance_before', 'amount', 'balance_after', 'date', $hideable = ['buttons', 'icon', 'description', 'balance_before', 'amount', 'balance_after', 'date',
'interest_date', 'book_date', 'process_date', 'interest_date', 'book_date', 'process_date',
// three new optional fields. // three new optional fields.
@@ -172,7 +172,7 @@ class MonthReportGenerator implements ReportGeneratorInterface
$journals = $journals->reverse(); $journals = $journals->reverse();
$dayBeforeBalance = Steam::balance($account, $date); $dayBeforeBalance = Steam::balance($account, $date);
$startBalance = $dayBeforeBalance; $startBalance = $dayBeforeBalance;
$currency = $currencyRepos->find(intval($account->getMeta('currency_id'))); $currency = $currencyRepos->find((int)$account->getMeta('currency_id'));
/** @var Transaction $transaction */ /** @var Transaction $transaction */
foreach ($journals as $transaction) { foreach ($journals as $transaction) {
@@ -192,9 +192,9 @@ class MonthReportGenerator implements ReportGeneratorInterface
$return = [ $return = [
'journals' => $journals->reverse(), 'journals' => $journals->reverse(),
'exists' => $journals->count() > 0, 'exists' => $journals->count() > 0,
'end' => $this->end->formatLocalized(strval(trans('config.month_and_day'))), 'end' => $this->end->formatLocalized((string)trans('config.month_and_day')),
'endBalance' => Steam::balance($account, $this->end), 'endBalance' => Steam::balance($account, $this->end),
'dayBefore' => $date->formatLocalized(strval(trans('config.month_and_day'))), 'dayBefore' => $date->formatLocalized((string)trans('config.month_and_day')),
'dayBeforeBalance' => $dayBeforeBalance, 'dayBeforeBalance' => $dayBeforeBalance,
]; ];

View File

@@ -66,8 +66,8 @@ class MonthReportGenerator extends Support implements ReportGeneratorInterface
*/ */
public function generate(): string public function generate(): string
{ {
$accountIds = join(',', $this->accounts->pluck('id')->toArray()); $accountIds = implode(',', $this->accounts->pluck('id')->toArray());
$budgetIds = join(',', $this->budgets->pluck('id')->toArray()); $budgetIds = implode(',', $this->budgets->pluck('id')->toArray());
$expenses = $this->getExpenses(); $expenses = $this->getExpenses();
$accountSummary = $this->summarizeByAccount($expenses); $accountSummary = $this->summarizeByAccount($expenses);
$budgetSummary = $this->summarizeByBudget($expenses); $budgetSummary = $this->summarizeByBudget($expenses);
@@ -199,8 +199,8 @@ class MonthReportGenerator extends Support implements ReportGeneratorInterface
]; ];
/** @var Transaction $transaction */ /** @var Transaction $transaction */
foreach ($collection as $transaction) { foreach ($collection as $transaction) {
$jrnlBudId = intval($transaction->transaction_journal_budget_id); $jrnlBudId = (int)$transaction->transaction_journal_budget_id;
$transBudId = intval($transaction->transaction_budget_id); $transBudId = (int)$transaction->transaction_budget_id;
$budgetId = max($jrnlBudId, $transBudId); $budgetId = max($jrnlBudId, $transBudId);
$result[$budgetId] = $result[$budgetId] ?? '0'; $result[$budgetId] = $result[$budgetId] ?? '0';
$result[$budgetId] = bcadd($transaction->transaction_amount, $result[$budgetId]); $result[$budgetId] = bcadd($transaction->transaction_amount, $result[$budgetId]);

View File

@@ -67,8 +67,8 @@ class MonthReportGenerator extends Support implements ReportGeneratorInterface
*/ */
public function generate(): string public function generate(): string
{ {
$accountIds = join(',', $this->accounts->pluck('id')->toArray()); $accountIds = implode(',', $this->accounts->pluck('id')->toArray());
$categoryIds = join(',', $this->categories->pluck('id')->toArray()); $categoryIds = implode(',', $this->categories->pluck('id')->toArray());
$reportType = 'category'; $reportType = 'category';
$expenses = $this->getExpenses(); $expenses = $this->getExpenses();
$income = $this->getIncome(); $income = $this->getIncome();
@@ -239,8 +239,8 @@ class MonthReportGenerator extends Support implements ReportGeneratorInterface
$result = []; $result = [];
/** @var Transaction $transaction */ /** @var Transaction $transaction */
foreach ($collection as $transaction) { foreach ($collection as $transaction) {
$jrnlCatId = intval($transaction->transaction_journal_category_id); $jrnlCatId = (int)$transaction->transaction_journal_category_id;
$transCatId = intval($transaction->transaction_category_id); $transCatId = (int)$transaction->transaction_category_id;
$categoryId = max($jrnlCatId, $transCatId); $categoryId = max($jrnlCatId, $transCatId);
$result[$categoryId] = $result[$categoryId] ?? '0'; $result[$categoryId] = $result[$categoryId] ?? '0';
$result[$categoryId] = bcadd($transaction->transaction_amount, $result[$categoryId]); $result[$categoryId] = bcadd($transaction->transaction_amount, $result[$categoryId]);

View File

@@ -42,14 +42,14 @@ class MonthReportGenerator implements ReportGeneratorInterface
/** /**
* @return string * @return string
* *
* @throws \Throwable
*/ */
public function generate(): string public function generate(): string
{ {
/** @var ReportHelperInterface $helper */ /** @var ReportHelperInterface $helper */
$helper = app(ReportHelperInterface::class); $helper = app(ReportHelperInterface::class);
$bills = $helper->getBillReport($this->start, $this->end, $this->accounts); $bills = $helper->getBillReport($this->start, $this->end, $this->accounts);
$accountIds = join(',', $this->accounts->pluck('id')->toArray()); $accountIds = implode(',', $this->accounts->pluck('id')->toArray());
$reportType = 'default'; $reportType = 'default';
// continue! // continue!

View File

@@ -41,12 +41,12 @@ class MultiYearReportGenerator implements ReportGeneratorInterface
/** /**
* @return string * @return string
* *
* @throws \Throwable
*/ */
public function generate(): string public function generate(): string
{ {
// and some id's, joined: // and some id's, joined:
$accountIds = join(',', $this->accounts->pluck('id')->toArray()); $accountIds = implode(',', $this->accounts->pluck('id')->toArray());
$reportType = 'default'; $reportType = 'default';
// continue! // continue!

View File

@@ -41,12 +41,12 @@ class YearReportGenerator implements ReportGeneratorInterface
/** /**
* @return string * @return string
* *
* @throws \Throwable
*/ */
public function generate(): string public function generate(): string
{ {
// and some id's, joined: // and some id's, joined:
$accountIds = join(',', $this->accounts->pluck('id')->toArray()); $accountIds = implode(',', $this->accounts->pluck('id')->toArray());
$reportType = 'default'; $reportType = 'default';
// continue! // continue!

View File

@@ -35,9 +35,7 @@ class Support
*/ */
public function getTopExpenses(): Collection public function getTopExpenses(): Collection
{ {
$transactions = $this->getExpenses()->sortBy('transaction_amount'); return $this->getExpenses()->sortBy('transaction_amount');
return $transactions;
} }
/** /**
@@ -45,9 +43,7 @@ class Support
*/ */
public function getTopIncome(): Collection public function getTopIncome(): Collection
{ {
$transactions = $this->getIncome()->sortByDesc('transaction_amount'); return $this->getIncome()->sortByDesc('transaction_amount');
return $transactions;
} }
/** /**
@@ -78,13 +74,13 @@ class Support
} }
++$result[$opposingId]['count']; ++$result[$opposingId]['count'];
$result[$opposingId]['sum'] = bcadd($result[$opposingId]['sum'], $transaction->transaction_amount); $result[$opposingId]['sum'] = bcadd($result[$opposingId]['sum'], $transaction->transaction_amount);
$result[$opposingId]['average'] = bcdiv($result[$opposingId]['sum'], strval($result[$opposingId]['count'])); $result[$opposingId]['average'] = bcdiv($result[$opposingId]['sum'], (string)$result[$opposingId]['count']);
} }
// sort result by average: // sort result by average:
$average = []; $average = [];
foreach ($result as $key => $row) { foreach ($result as $key => $row) {
$average[$key] = floatval($row['average']); $average[$key] = (float)$row['average'];
} }
array_multisort($average, $sortFlag, $result); array_multisort($average, $sortFlag, $result);
@@ -146,15 +142,12 @@ class Support
*/ */
protected function summarizeByAccount(Collection $collection): array protected function summarizeByAccount(Collection $collection): array
{ {
$result = [ $result = [];
'sum' => '0',
];
/** @var Transaction $transaction */ /** @var Transaction $transaction */
foreach ($collection as $transaction) { foreach ($collection as $transaction) {
$accountId = $transaction->account_id; $accountId = $transaction->account_id;
$result[$accountId] = $result[$accountId] ?? '0'; $result[$accountId] = $result[$accountId] ?? '0';
$result[$accountId] = bcadd($transaction->transaction_amount, $result[$accountId]); $result[$accountId] = bcadd($transaction->transaction_amount, $result[$accountId]);
$result['sum'] = bcadd($result['sum'], $transaction->transaction_amount);
} }
return $result; return $result;

View File

@@ -65,12 +65,11 @@ class MonthReportGenerator extends Support implements ReportGeneratorInterface
/** /**
* @return string * @return string
* @throws \Throwable
*/ */
public function generate(): string public function generate(): string
{ {
$accountIds = join(',', $this->accounts->pluck('id')->toArray()); $accountIds = implode(',', $this->accounts->pluck('id')->toArray());
$tagTags = join(',', $this->tags->pluck('tag')->toArray()); $tagTags = implode(',', $this->tags->pluck('tag')->toArray());
$reportType = 'tag'; $reportType = 'tag';
$expenses = $this->getExpenses(); $expenses = $this->getExpenses();
$income = $this->getIncome(); $income = $this->getIncome();

View File

@@ -22,12 +22,13 @@ declare(strict_types=1);
namespace FireflyIII\Handlers\Events; namespace FireflyIII\Handlers\Events;
use Exception;
use FireflyIII\Events\AdminRequestedTestMessage; use FireflyIII\Events\AdminRequestedTestMessage;
use FireflyIII\Mail\AdminTestMail; use FireflyIII\Mail\AdminTestMail;
use FireflyIII\Repositories\User\UserRepositoryInterface;
use Log; use Log;
use Mail; use Mail;
use Session; use Session;
use Swift_TransportException;
/** /**
* Class AdminEventHandler. * Class AdminEventHandler.
@@ -43,6 +44,15 @@ class AdminEventHandler
*/ */
public function sendTestMessage(AdminRequestedTestMessage $event): bool public function sendTestMessage(AdminRequestedTestMessage $event): bool
{ {
/** @var UserRepositoryInterface $repository */
$repository = app(UserRepositoryInterface::class);
// is user even admin?
if (!$repository->hasRole($event->user, 'owner')) {
return true;
}
$email = $event->user->email; $email = $event->user->email;
$ipAddress = $event->ipAddress; $ipAddress = $event->ipAddress;
@@ -51,7 +61,7 @@ class AdminEventHandler
Log::debug('Trying to send message...'); Log::debug('Trying to send message...');
Mail::to($email)->send(new AdminTestMail($email, $ipAddress)); Mail::to($email)->send(new AdminTestMail($email, $ipAddress));
// @codeCoverageIgnoreStart // @codeCoverageIgnoreStart
} catch (Swift_TransportException $e) { } catch (Exception $e) {
Log::debug('Send message failed! :('); Log::debug('Send message failed! :(');
Log::error($e->getMessage()); Log::error($e->getMessage());
Log::error($e->getTraceAsString()); Log::error($e->getTraceAsString());

View File

@@ -30,7 +30,6 @@ use FireflyIII\Repositories\PiggyBank\PiggyBankRepositoryInterface as PRI;
use FireflyIII\Repositories\RuleGroup\RuleGroupRepositoryInterface as RGRI; use FireflyIII\Repositories\RuleGroup\RuleGroupRepositoryInterface as RGRI;
use FireflyIII\Support\Events\BillScanner; use FireflyIII\Support\Events\BillScanner;
use FireflyIII\TransactionRules\Processor; use FireflyIII\TransactionRules\Processor;
use Log;
/** /**
* @codeCoverageIgnore * @codeCoverageIgnore
@@ -67,6 +66,7 @@ class StoredJournalEventHandler
* @param StoredTransactionJournal $storedJournalEvent * @param StoredTransactionJournal $storedJournalEvent
* *
* @return bool * @return bool
* @throws \FireflyIII\Exceptions\FireflyException
*/ */
public function processRules(StoredTransactionJournal $storedJournalEvent): bool public function processRules(StoredTransactionJournal $storedJournalEvent): bool
{ {

View File

@@ -51,11 +51,11 @@ class UpdatedJournalEventHandler
/** /**
* This method will check all the rules when a journal is updated. * This method will check all the rules when a journal is updated.
* TODO move to factory.
* *
* @param UpdatedTransactionJournal $updatedJournalEvent * @param UpdatedTransactionJournal $updatedJournalEvent
* *
* @return bool * @return bool
* @throws \FireflyIII\Exceptions\FireflyException
*/ */
public function processRules(UpdatedTransactionJournal $updatedJournalEvent): bool public function processRules(UpdatedTransactionJournal $updatedJournalEvent): bool
{ {
@@ -82,7 +82,6 @@ class UpdatedJournalEventHandler
/** /**
* This method calls a special bill scanner that will check if the updated journal is part of a bill. * This method calls a special bill scanner that will check if the updated journal is part of a bill.
* TODO move to factory.
* *
* @param UpdatedTransactionJournal $updatedJournalEvent * @param UpdatedTransactionJournal $updatedJournalEvent
* *

View File

@@ -22,6 +22,7 @@ declare(strict_types=1);
namespace FireflyIII\Handlers\Events; namespace FireflyIII\Handlers\Events;
use Exception;
use FireflyIII\Events\RegisteredUser; use FireflyIII\Events\RegisteredUser;
use FireflyIII\Events\RequestedNewPassword; use FireflyIII\Events\RequestedNewPassword;
use FireflyIII\Events\UserChangedEmail; use FireflyIII\Events\UserChangedEmail;
@@ -36,7 +37,6 @@ use Illuminate\Auth\Events\Login;
use Log; use Log;
use Mail; use Mail;
use Preferences; use Preferences;
use Swift_TransportException;
/** /**
* Class UserEventHandler. * Class UserEventHandler.
@@ -95,7 +95,7 @@ class UserEventHandler
} }
// user is the only user but does not have role "owner". // user is the only user but does not have role "owner".
$role = $repository->getRole('owner'); $role = $repository->getRole('owner');
if (is_null($role)) { if (null === $role) {
// create role, does not exist. Very strange situation so let's raise a big fuss about it. // create role, does not exist. Very strange situation so let's raise a big fuss about it.
$role = $repository->createRole('owner', 'Site Owner', 'User runs this instance of FF3'); $role = $repository->createRole('owner', 'Site Owner', 'User runs this instance of FF3');
Log::error('Could not find role "owner". This is weird.'); Log::error('Could not find role "owner". This is weird.');
@@ -124,7 +124,7 @@ class UserEventHandler
try { try {
Mail::to($newEmail)->send(new ConfirmEmailChangeMail($newEmail, $oldEmail, $uri, $ipAddress)); Mail::to($newEmail)->send(new ConfirmEmailChangeMail($newEmail, $oldEmail, $uri, $ipAddress));
// @codeCoverageIgnoreStart // @codeCoverageIgnoreStart
} catch (Swift_TransportException $e) { } catch (Exception $e) {
Log::error($e->getMessage()); Log::error($e->getMessage());
} }
@@ -148,7 +148,7 @@ class UserEventHandler
try { try {
Mail::to($oldEmail)->send(new UndoEmailChangeMail($newEmail, $oldEmail, $uri, $ipAddress)); Mail::to($oldEmail)->send(new UndoEmailChangeMail($newEmail, $oldEmail, $uri, $ipAddress));
// @codeCoverageIgnoreStart // @codeCoverageIgnoreStart
} catch (Swift_TransportException $e) { } catch (Exception $e) {
Log::error($e->getMessage()); Log::error($e->getMessage());
} }
@@ -173,7 +173,7 @@ class UserEventHandler
try { try {
Mail::to($email)->send(new RequestedNewPasswordMail($url, $ipAddress)); Mail::to($email)->send(new RequestedNewPasswordMail($url, $ipAddress));
// @codeCoverageIgnoreStart // @codeCoverageIgnoreStart
} catch (Swift_TransportException $e) { } catch (Exception $e) {
Log::error($e->getMessage()); Log::error($e->getMessage());
} }
@@ -205,7 +205,7 @@ class UserEventHandler
try { try {
Mail::to($email)->send(new RegisteredUserMail($uri, $ipAddress)); Mail::to($email)->send(new RegisteredUserMail($uri, $ipAddress));
// @codeCoverageIgnoreStart // @codeCoverageIgnoreStart
} catch (Swift_TransportException $e) { } catch (Exception $e) {
Log::error($e->getMessage()); Log::error($e->getMessage());
} }

View File

@@ -26,6 +26,7 @@ namespace FireflyIII\Handlers\Events;
use FireflyConfig; use FireflyConfig;
use FireflyIII\Events\RequestedVersionCheckStatus; use FireflyIII\Events\RequestedVersionCheckStatus;
use FireflyIII\Exceptions\FireflyException; use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Repositories\User\UserRepositoryInterface;
use FireflyIII\Services\Github\Object\Release; use FireflyIII\Services\Github\Object\Release;
use FireflyIII\Services\Github\Request\UpdateRequest; use FireflyIII\Services\Github\Request\UpdateRequest;
use FireflyIII\User; use FireflyIII\User;
@@ -43,22 +44,26 @@ class VersionCheckEventHandler
public function checkForUpdates(RequestedVersionCheckStatus $event) public function checkForUpdates(RequestedVersionCheckStatus $event)
{ {
// in Sandstorm, cannot check for updates: // in Sandstorm, cannot check for updates:
$sandstorm = 1 === intval(getenv('SANDSTORM')); $sandstorm = 1 === (int)getenv('SANDSTORM');
if ($sandstorm === true) { if ($sandstorm === true) {
return; return; // @codeCoverageIgnore
} }
/** @var UserRepositoryInterface $repository */
$repository = app(UserRepositoryInterface::class);
/** @var User $user */ /** @var User $user */
$user = $event->user; $user = $event->user;
if (!$user->hasRole('owner')) { if (!$repository->hasRole($user, 'owner')) {
return; return;
} }
$permission = FireflyConfig::get('permission_update_check', -1); $permission = FireflyConfig::get('permission_update_check', -1);
$lastCheckTime = FireflyConfig::get('last_update_check', time()); $lastCheckTime = FireflyConfig::get('last_update_check', time());
$now = time(); $now = time();
if ($now - $lastCheckTime->data < 604800) { $diff = $now - $lastCheckTime->data;
Log::debug(sprintf('Difference is %d seconds.', $diff));
if ($diff < 604800) {
Log::debug(sprintf('Checked for updates less than a week ago (on %s).', date('Y-m-d H:i:s', $lastCheckTime->data))); Log::debug(sprintf('Checked for updates less than a week ago (on %s).', date('Y-m-d H:i:s', $lastCheckTime->data)));
return; return;
@@ -70,7 +75,7 @@ class VersionCheckEventHandler
// have actual permission? // have actual permission?
if ($permission->data === -1) { if ($permission->data === -1) {
// never asked before. // never asked before.
session()->flash('info', strval(trans('firefly.check_for_updates_permission', ['link' => route('admin.update-check')]))); session()->flash('info', (string)trans('firefly.check_for_updates_permission', ['link' => route('admin.update-check')]));
return; return;
} }
@@ -79,7 +84,7 @@ class VersionCheckEventHandler
/** @var UpdateRequest $request */ /** @var UpdateRequest $request */
$request = app(UpdateRequest::class); $request = app(UpdateRequest::class);
$check = -2; $check = -2;
$first = new Release(['id' => '0', 'title' => '0', 'updated' => '2017-01-01', 'content' => '']); $first = new Release(['id' => '0', 'title' => '0.2', 'updated' => '2017-01-01', 'content' => '']);
try { try {
$request->call(); $request->call();
$releases = $request->getReleases(); $releases = $request->getReleases();
@@ -87,30 +92,31 @@ class VersionCheckEventHandler
/** @var Release $first */ /** @var Release $first */
$first = reset($releases); $first = reset($releases);
$check = version_compare($current, $first->getTitle()); $check = version_compare($current, $first->getTitle());
Log::debug(sprintf('Comparing %s with %s, result is %s', $current, $first->getTitle(), $check));
FireflyConfig::set('last_update_check', time()); FireflyConfig::set('last_update_check', time());
} catch (FireflyException $e) { } catch (FireflyException $e) {
Log::error(sprintf('Could not check for updates: %s', $e->getMessage())); Log::error(sprintf('Could not check for updates: %s', $e->getMessage()));
} }
$string = 'no result: ' . $check; $string = 'no result: ' . $check;
if ($check === -2) { if ($check === -2) {
$string = strval(trans('firefly.update_check_error')); $string = (string)trans('firefly.update_check_error');
} }
if ($check === -1) { if ($check === -1) {
// there is a new FF version! // there is a new FF version!
$monthAndDayFormat = (string)trans('config.month_and_day'); $monthAndDayFormat = (string)trans('config.month_and_day');
$string = strval( $string = (string)trans(
trans( 'firefly.update_new_version_alert',
'firefly.update_new_version_alert', [
['your_version' => $current, 'new_version' => $first->getTitle(), 'date' => $first->getUpdated()->formatLocalized($monthAndDayFormat)] 'your_version' => $current,
) 'new_version' => $first->getTitle(),
'date' => $first->getUpdated()->formatLocalized($monthAndDayFormat),
]
); );
} }
if ($check !== 0) { if ($check !== 0) {
// flash info // flash info
session()->flash('info', $string); session()->flash('info', $string);
} }
return;
} }
} }

View File

@@ -56,7 +56,7 @@ class AttachmentHelper implements AttachmentHelperInterface
*/ */
public function __construct() public function __construct()
{ {
$this->maxUploadSize = intval(config('firefly.maxUploadSize')); $this->maxUploadSize = (int)config('firefly.maxUploadSize');
$this->allowedMimes = (array)config('firefly.allowedMimes'); $this->allowedMimes = (array)config('firefly.allowedMimes');
$this->errors = new MessageBag; $this->errors = new MessageBag;
$this->messages = new MessageBag; $this->messages = new MessageBag;
@@ -71,7 +71,7 @@ class AttachmentHelper implements AttachmentHelperInterface
*/ */
public function getAttachmentLocation(Attachment $attachment): string public function getAttachmentLocation(Attachment $attachment): string
{ {
$path = sprintf('%s%sat-%d.data', storage_path('upload'), DIRECTORY_SEPARATOR, intval($attachment->id)); $path = sprintf('%s%sat-%d.data', storage_path('upload'), DIRECTORY_SEPARATOR, (int)$attachment->id);
return $path; return $path;
} }
@@ -155,6 +155,7 @@ class AttachmentHelper implements AttachmentHelperInterface
* @param Model $model * @param Model $model
* *
* @return Attachment * @return Attachment
* @throws \Illuminate\Contracts\Encryption\EncryptException
*/ */
protected function processFile(UploadedFile $file, Model $model): Attachment protected function processFile(UploadedFile $file, Model $model): Attachment
{ {
@@ -206,7 +207,7 @@ class AttachmentHelper implements AttachmentHelperInterface
Log::debug('Now in validMime()'); Log::debug('Now in validMime()');
$mime = e($file->getMimeType()); $mime = e($file->getMimeType());
$name = e($file->getClientOriginalName()); $name = e($file->getClientOriginalName());
Log::debug(sprintf('Name is %, and mime is %s', $name, $mime)); Log::debug(sprintf('Name is %s, and mime is %s', $name, $mime));
Log::debug('Valid mimes are', $this->allowedMimes); Log::debug('Valid mimes are', $this->allowedMimes);
if (!in_array($mime, $this->allowedMimes)) { if (!in_array($mime, $this->allowedMimes)) {

View File

@@ -103,7 +103,7 @@ class MetaPieChart implements MetaPieChartInterface
$transactions = $this->getTransactions($direction); $transactions = $this->getTransactions($direction);
$grouped = $this->groupByFields($transactions, $this->grouping[$group]); $grouped = $this->groupByFields($transactions, $this->grouping[$group]);
$chartData = $this->organizeByType($group, $grouped); $chartData = $this->organizeByType($group, $grouped);
$key = strval(trans('firefly.everything_else')); $key = (string)trans('firefly.everything_else');
// also collect all other transactions // also collect all other transactions
if ($this->collectOtherObjects && 'expense' === $direction) { if ($this->collectOtherObjects && 'expense' === $direction) {
@@ -113,7 +113,7 @@ class MetaPieChart implements MetaPieChartInterface
$collector->setAccounts($this->accounts)->setRange($this->start, $this->end)->setTypes([TransactionType::WITHDRAWAL]); $collector->setAccounts($this->accounts)->setRange($this->start, $this->end)->setTypes([TransactionType::WITHDRAWAL]);
$journals = $collector->getJournals(); $journals = $collector->getJournals();
$sum = strval($journals->sum('transaction_amount')); $sum = (string)$journals->sum('transaction_amount');
$sum = bcmul($sum, '-1'); $sum = bcmul($sum, '-1');
$sum = bcsub($sum, $this->total); $sum = bcsub($sum, $this->total);
$chartData[$key] = $sum; $chartData[$key] = $sum;
@@ -125,7 +125,7 @@ class MetaPieChart implements MetaPieChartInterface
$collector->setUser($this->user); $collector->setUser($this->user);
$collector->setAccounts($this->accounts)->setRange($this->start, $this->end)->setTypes([TransactionType::DEPOSIT]); $collector->setAccounts($this->accounts)->setRange($this->start, $this->end)->setTypes([TransactionType::DEPOSIT]);
$journals = $collector->getJournals(); $journals = $collector->getJournals();
$sum = strval($journals->sum('transaction_amount')); $sum = (string)$journals->sum('transaction_amount');
$sum = bcsub($sum, $this->total); $sum = bcsub($sum, $this->total);
$chartData[$key] = $sum; $chartData[$key] = $sum;
} }
@@ -282,6 +282,7 @@ class MetaPieChart implements MetaPieChartInterface
$collector->withCategoryInformation(); $collector->withCategoryInformation();
$collector->withBudgetInformation(); $collector->withBudgetInformation();
} }
// @codeCoverageIgnoreEnd // @codeCoverageIgnoreEnd
return $collector->getJournals(); return $collector->getJournals();
@@ -307,7 +308,7 @@ class MetaPieChart implements MetaPieChartInterface
foreach ($set as $transaction) { foreach ($set as $transaction) {
$values = []; $values = [];
foreach ($fields as $field) { foreach ($fields as $field) {
$values[] = intval($transaction->$field); $values[] = (int)$transaction->$field;
} }
$value = max($values); $value = max($values);
$grouped[$value] = $grouped[$value] ?? '0'; $grouped[$value] = $grouped[$value] ?? '0';
@@ -331,7 +332,7 @@ class MetaPieChart implements MetaPieChartInterface
$repository->setUser($this->user); $repository->setUser($this->user);
foreach ($array as $objectId => $amount) { foreach ($array as $objectId => $amount) {
if (!isset($names[$objectId])) { if (!isset($names[$objectId])) {
$object = $repository->find(intval($objectId)); $object = $repository->find((int)$objectId);
$names[$objectId] = $object->name ?? $object->tag; $names[$objectId] = $object->name ?? $object->tag;
} }
$amount = Steam::positive($amount); $amount = Steam::positive($amount);

View File

@@ -35,15 +35,15 @@ class BalanceLine
/** /**
* *
*/ */
const ROLE_DEFAULTROLE = 1; public const ROLE_DEFAULTROLE = 1;
/** /**
* *
*/ */
const ROLE_TAGROLE = 2; public const ROLE_TAGROLE = 2;
/** /**
* *
*/ */
const ROLE_DIFFROLE = 3; public const ROLE_DIFFROLE = 3;
/** @var Collection */ /** @var Collection */
protected $balanceEntries; protected $balanceEntries;
@@ -162,13 +162,13 @@ class BalanceLine
return $this->getBudget()->name; return $this->getBudget()->name;
} }
if (self::ROLE_DEFAULTROLE === $this->getRole()) { if (self::ROLE_DEFAULTROLE === $this->getRole()) {
return strval(trans('firefly.no_budget')); return (string)trans('firefly.no_budget');
} }
if (self::ROLE_TAGROLE === $this->getRole()) { if (self::ROLE_TAGROLE === $this->getRole()) {
return strval(trans('firefly.coveredWithTags')); return (string)trans('firefly.coveredWithTags');
} }
if (self::ROLE_DIFFROLE === $this->getRole()) { if (self::ROLE_DIFFROLE === $this->getRole()) {
return strval(trans('firefly.leftUnbalanced')); return (string)trans('firefly.leftUnbalanced');
} }
return ''; return '';

View File

@@ -101,7 +101,7 @@ class Bill
{ {
$set = $this->bills->sortBy( $set = $this->bills->sortBy(
function (BillLine $bill) { function (BillLine $bill) {
$active = 0 === intval($bill->getBill()->active) ? 1 : 0; $active = 0 === (int)$bill->getBill()->active ? 1 : 0;
$name = $bill->getBill()->name; $name = $bill->getBill()->name;
return $active . $name; return $active . $name;

View File

@@ -190,7 +190,7 @@ class BillLine
*/ */
public function isActive(): bool public function isActive(): bool
{ {
return 1 === intval($this->bill->active); return 1 === (int)$this->bill->active;
} }
/** /**

View File

@@ -25,11 +25,13 @@ namespace FireflyIII\Helpers\Collector;
use Carbon\Carbon; use Carbon\Carbon;
use DB; use DB;
use FireflyIII\Exceptions\FireflyException; use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Helpers\Filter\CountAttachmentsFilter;
use FireflyIII\Helpers\Filter\FilterInterface; use FireflyIII\Helpers\Filter\FilterInterface;
use FireflyIII\Helpers\Filter\InternalTransferFilter; use FireflyIII\Helpers\Filter\InternalTransferFilter;
use FireflyIII\Helpers\Filter\NegativeAmountFilter; use FireflyIII\Helpers\Filter\NegativeAmountFilter;
use FireflyIII\Helpers\Filter\OpposingAccountFilter; use FireflyIII\Helpers\Filter\OpposingAccountFilter;
use FireflyIII\Helpers\Filter\PositiveAmountFilter; use FireflyIII\Helpers\Filter\PositiveAmountFilter;
use FireflyIII\Helpers\Filter\SplitIndicatorFilter;
use FireflyIII\Helpers\Filter\TransferFilter; use FireflyIII\Helpers\Filter\TransferFilter;
use FireflyIII\Models\AccountType; use FireflyIII\Models\AccountType;
use FireflyIII\Models\Budget; use FireflyIII\Models\Budget;
@@ -235,7 +237,7 @@ class JournalCollector implements JournalCollectorInterface
$countQuery->getQuery()->groups = null; $countQuery->getQuery()->groups = null;
$countQuery->getQuery()->orders = null; $countQuery->getQuery()->orders = null;
$countQuery->groupBy('accounts.user_id'); $countQuery->groupBy('accounts.user_id');
$this->count = intval($countQuery->count()); $this->count = (int)$countQuery->count();
return $this->count; return $this->count;
} }
@@ -268,10 +270,10 @@ class JournalCollector implements JournalCollectorInterface
$set->each( $set->each(
function (Transaction $transaction) { function (Transaction $transaction) {
$transaction->date = new Carbon($transaction->date); $transaction->date = new Carbon($transaction->date);
$transaction->description = Steam::decrypt(intval($transaction->encrypted), $transaction->description); $transaction->description = Steam::decrypt((int)$transaction->encrypted, $transaction->description);
if (null !== $transaction->bill_name) { if (null !== $transaction->bill_name) {
$transaction->bill_name = Steam::decrypt(intval($transaction->bill_name_encrypted), $transaction->bill_name); $transaction->bill_name = Steam::decrypt((int)$transaction->bill_name_encrypted, $transaction->bill_name);
} }
$transaction->account_name = app('steam')->tryDecrypt($transaction->account_name); $transaction->account_name = app('steam')->tryDecrypt($transaction->account_name);
$transaction->opposing_account_name = app('steam')->tryDecrypt($transaction->opposing_account_name); $transaction->opposing_account_name = app('steam')->tryDecrypt($transaction->opposing_account_name);
@@ -336,7 +338,7 @@ class JournalCollector implements JournalCollectorInterface
if ($accounts->count() > 0) { if ($accounts->count() > 0) {
$accountIds = $accounts->pluck('id')->toArray(); $accountIds = $accounts->pluck('id')->toArray();
$this->query->whereIn('transactions.account_id', $accountIds); $this->query->whereIn('transactions.account_id', $accountIds);
Log::debug(sprintf('setAccounts: %s', join(', ', $accountIds))); Log::debug(sprintf('setAccounts: %s', implode(', ', $accountIds)));
$this->accountIds = $accountIds; $this->accountIds = $accountIds;
} }
@@ -760,6 +762,8 @@ class JournalCollector implements JournalCollectorInterface
TransferFilter::class => new TransferFilter, TransferFilter::class => new TransferFilter,
PositiveAmountFilter::class => new PositiveAmountFilter, PositiveAmountFilter::class => new PositiveAmountFilter,
NegativeAmountFilter::class => new NegativeAmountFilter, NegativeAmountFilter::class => new NegativeAmountFilter,
SplitIndicatorFilter::class => new SplitIndicatorFilter,
CountAttachmentsFilter::class => new CountAttachmentsFilter,
]; ];
Log::debug(sprintf('Will run %d filters on the set.', count($this->filters))); Log::debug(sprintf('Will run %d filters on the set.', count($this->filters)));
foreach ($this->filters as $enabled) { foreach ($this->filters as $enabled) {

View File

@@ -42,13 +42,6 @@ interface JournalCollectorInterface
*/ */
public function addFilter(string $filter): JournalCollectorInterface; public function addFilter(string $filter): JournalCollectorInterface;
/**
* @param Collection $journals
*
* @return JournalCollectorInterface
*/
public function setJournals(Collection $journals): JournalCollectorInterface;
/** /**
* @param string $amount * @param string $amount
* *
@@ -153,6 +146,13 @@ interface JournalCollectorInterface
*/ */
public function setCategory(Category $category): JournalCollectorInterface; public function setCategory(Category $category): JournalCollectorInterface;
/**
* @param Collection $journals
*
* @return JournalCollectorInterface
*/
public function setJournals(Collection $journals): JournalCollectorInterface;
/** /**
* @param int $limit * @param int $limit
* *

View File

@@ -35,7 +35,7 @@ use Log;
class AmountFilter implements FilterInterface class AmountFilter implements FilterInterface
{ {
/** @var int */ /** @var int */
private $modifier = 0; private $modifier;
/** /**
* AmountFilter constructor. * AmountFilter constructor.

View File

@@ -0,0 +1,67 @@
<?php
/**
* CountAttachmentsFilter.php
* Copyright (c) 2018 thegrumpydictator@gmail.com
*
* This file is part of Firefly III.
*
* Firefly III is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Firefly III is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/
declare(strict_types=1);
namespace FireflyIII\Helpers\Filter;
use DB;
use FireflyIII\Models\Transaction;
use FireflyIII\Models\TransactionJournal;
use Illuminate\Support\Collection;
/**
* Class CountAttachmentsFilter
*/
class CountAttachmentsFilter implements FilterInterface
{
/**
* @param Collection $set
*
* @return Collection
*/
public function filter(Collection $set): Collection
{
// grab journal ID's:
$ids = $set->pluck('journal_id')->toArray();
$result = DB::table('attachments')
->whereNull('deleted_at')
->whereIn('attachable_id', $ids)
->where('attachable_type', TransactionJournal::class)
->groupBy('attachable_id')->get(['attachable_id', DB::raw('COUNT(*) as number')]);
$counter = [];
foreach ($result as $row) {
$counter[$row->attachable_id] = $row->number;
}
$set->each(
function (Transaction $transaction) use ($counter) {
$id = (int)$transaction->journal_id;
$count = (int)($counter[$id] ?? 0.0);
$transaction->attachmentCount = $count;
}
);
return $set;
}
}

View File

@@ -36,7 +36,7 @@ use Log;
class InternalTransferFilter implements FilterInterface class InternalTransferFilter implements FilterInterface
{ {
/** @var array */ /** @var array */
private $accounts = []; private $accounts;
/** /**
* InternalTransferFilter constructor. * InternalTransferFilter constructor.

View File

@@ -35,7 +35,7 @@ use Log;
class OpposingAccountFilter implements FilterInterface class OpposingAccountFilter implements FilterInterface
{ {
/** @var array */ /** @var array */
private $accounts = []; private $accounts;
/** /**
* InternalTransferFilter constructor. * InternalTransferFilter constructor.

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