Compare commits

..

160 Commits
4.7.1 ... 4.7.2

Author SHA1 Message Date
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
James Cole
3482746d7c Merge branch 'hotfix/4.7.1.1' 2018-03-04 13:24:06 +01:00
James Cole
d5aeca6222 Fix import problem in 4.7.1 2018-03-04 13:23:44 +01:00
762 changed files with 18711 additions and 11454 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

@@ -12,18 +12,16 @@ 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:

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,7 +30,6 @@ 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
*/ */
@@ -44,7 +43,6 @@ class AboutController extends Controller
public function __construct() public function __construct()
{ {
parent::__construct(); parent::__construct();
} }
/** /**
@@ -55,7 +53,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 +62,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 +81,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());
@@ -153,7 +152,7 @@ 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'] = is_null($currency) ? 0 : $currency->id;
} }
@@ -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,7 +178,7 @@ 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'] = is_null($currency) ? 0 : $currency->id;
} }

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,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\Api\V1\Controllers; namespace FireflyIII\Api\V1\Controllers;
use FireflyIII\Api\V1\Requests\BillRequest; use FireflyIII\Api\V1\Requests\BillRequest;
use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Models\Bill; use FireflyIII\Models\Bill;
use FireflyIII\Repositories\Bill\BillRepositoryInterface; use FireflyIII\Repositories\Bill\BillRepositoryInterface;
use FireflyIII\Transformers\BillTransformer; use FireflyIII\Transformers\BillTransformer;

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
@@ -110,6 +112,7 @@ class Controller extends BaseController
$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;
@@ -166,7 +165,7 @@ 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');
} }
@@ -174,6 +173,8 @@ class TransactionController extends Controller
/** /**
* @param TransactionRequest $request * @param TransactionRequest $request
* *
* @param JournalRepositoryInterface $repository
*
* @return \Illuminate\Http\JsonResponse * @return \Illuminate\Http\JsonResponse
*/ */
public function store(TransactionRequest $request, JournalRepositoryInterface $repository) public function store(TransactionRequest $request, JournalRepositoryInterface $repository)

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)
{ {

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',

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;

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;
@@ -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,8 +193,10 @@ 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 = intval($accountId);
@@ -202,7 +205,7 @@ class TransactionRequest extends Request
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 (is_null($account)) {
$validator->errors()->add($nameField, trans('validation.belongs_user')); $validator->errors()->add($nameField, trans('validation.belongs_user'));
return null;
} }
return; return $account;
} }
/** /**
@@ -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); $accountId = intval($accountId);
$accountName = strval($accountName); $accountName = strval($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;
} }
/** /**
@@ -399,37 +407,45 @@ class TransactionRequest extends Request
$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']) ? intval($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';
$this->opposingAccountExists($validator, AccountType::EXPENSE, $destinationId, $destinationName, $idField); $destinationAccount = $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);
@@ -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;

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);
@@ -140,7 +129,5 @@ 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;
} }
} }

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 */
$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')));
$cwd = getcwd(); $cwd = getcwd();
$validTypes = config('import.options.file.import_formats'); $validTypes = config('import.options.file.import_formats');
$type = strtolower($this->option('type')); $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;

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;
@@ -68,21 +67,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 +94,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 +135,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;

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,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;
@@ -26,6 +26,7 @@ use DB;
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;
@@ -86,6 +87,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;
@@ -281,6 +283,38 @@ class UpgradeDatabase extends Command
} }
} }
/**
* 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 = strval($att->description);
if (strlen($description) > 0) {
// find or create note:
$note = $att->notes()->first();
if (is_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.
* *

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;

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;

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;

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;

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;

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;

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;
@@ -124,7 +124,7 @@ class ExpandedProcessor implements ProcessorInterface
$currencyId = $ibans[$accountId]['currency_id'] ?? 0; $currencyId = $ibans[$accountId]['currency_id'] ?? 0;
$opposingCurrencyId = $ibans[$opposingId]['currency_id'] ?? 0; $opposingCurrencyId = $ibans[$opposingId]['currency_id'] ?? 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] ?? '';
@@ -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
{ {

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;

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;
@@ -43,6 +43,7 @@ class AccountFactory
* @param array $data * @param array $data
* *
* @return Account * @return Account
* @throws \FireflyIII\Exceptions\FireflyException
*/ */
public function create(array $data): Account public function create(array $data): Account
{ {
@@ -74,7 +75,7 @@ class AccountFactory
} }
$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);
@@ -116,6 +117,8 @@ class AccountFactory
* @param string $accountType * @param string $accountType
* *
* @return Account * @return Account
* @throws \FireflyIII\Exceptions\FireflyException
* @throws \FireflyIII\Exceptions\FireflyException
*/ */
public function findOrCreate(string $accountName, string $accountType): Account public function findOrCreate(string $accountName, string $accountType): Account
{ {
@@ -163,8 +166,13 @@ class AccountFactory
return AccountType::find($accountTypeId); return AccountType::find($accountTypeId);
} }
$type = config('firefly.accountTypeByIdentifier.' . strval($accountType)); $type = config('firefly.accountTypeByIdentifier.' . strval($accountType));
$result = AccountType::whereType($type)->first();
if (is_null($result) && !is_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;

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;

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;

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;

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;

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;

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;

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

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;
@@ -124,6 +125,11 @@ class TransactionFactory
} }
// 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);

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;
@@ -68,6 +68,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);
@@ -91,13 +92,12 @@ class TransactionJournalFactory
$this->storeNote($journal, strval($data['notes'])); $this->storeNote($journal, strval($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;

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();

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;

View File

@@ -45,6 +45,7 @@ class MonthReportGenerator implements ReportGeneratorInterface
/** /**
* @return string * @return string
* @throws \Throwable
*/ */
public function generate(): string public function generate(): string
{ {

View File

@@ -63,6 +63,7 @@ class MonthReportGenerator extends Support implements ReportGeneratorInterface
/** /**
* @return string * @return string
* @throws \Throwable
*/ */
public function generate(): string public function generate(): string
{ {

View File

@@ -64,6 +64,7 @@ class MonthReportGenerator extends Support implements ReportGeneratorInterface
/** /**
* @return string * @return string
* @throws \Throwable
*/ */
public function generate(): string public function generate(): string
{ {

View File

@@ -146,15 +146,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

@@ -24,6 +24,7 @@ namespace FireflyIII\Handlers\Events;
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;
@@ -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;

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

@@ -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,6 +92,7 @@ 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()));
@@ -98,19 +104,19 @@ class VersionCheckEventHandler
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

@@ -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

@@ -282,6 +282,7 @@ class MetaPieChart implements MetaPieChartInterface
$collector->withCategoryInformation(); $collector->withCategoryInformation();
$collector->withBudgetInformation(); $collector->withBudgetInformation();
} }
// @codeCoverageIgnoreEnd // @codeCoverageIgnoreEnd
return $collector->getJournals(); return $collector->getJournals();

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;

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;
@@ -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) {
@@ -830,6 +834,7 @@ class JournalCollector implements JournalCollectorInterface
/** /**
* *
* @throws \InvalidArgumentException
*/ */
private function joinOpposingTables() private function joinOpposingTables()
{ {

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

@@ -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 = $counter[$id] ?? 0;
$transaction->attachmentCount = $count;
}
);
return $set;
}
}

View File

@@ -0,0 +1,67 @@
<?php
/**
* SplitIndicatorFilter.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 Illuminate\Support\Collection;
/**
* Class SplitIndicatorFilter
*/
class SplitIndicatorFilter 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('transactions')
->whereNull('deleted_at')->whereIn('transaction_journal_id', $ids)
->groupBy('transaction_journal_id')->get(['transaction_journal_id', DB::raw('COUNT(*) as number')]);
$counter = [];
foreach ($result as $row) {
$counter[$row->transaction_journal_id] = $row->number;
}
$set->each(
function (Transaction $transaction) use ($counter) {
$id = (int)$transaction->journal_id;
$count = $counter[$id] ?? 0;
$transaction->is_split = false;
if ($count > 2) {
$transaction->is_split = true;
}
}
);
return $set;
}
}

View File

@@ -37,7 +37,7 @@ class Help implements HelpInterface
/** /**
* *
*/ */
const CACHEKEY = 'help_%s_%s'; public const CACHEKEY = 'help_%s_%s';
/** @var string */ /** @var string */
protected $userAgent = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.71 Safari/537.36'; protected $userAgent = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.71 Safari/537.36';

View File

@@ -57,11 +57,8 @@ class PopupReport implements PopupReportInterface
return $journals->filter( return $journals->filter(
function (Transaction $transaction) { function (Transaction $transaction) {
$tags = $transaction->transactionJournal->tags()->where('tagMode', 'balancingAct')->count(); $tags = $transaction->transactionJournal->tags()->where('tagMode', 'balancingAct')->count();
if (0 === $tags) {
return true;
}
return false; return 0 === $tags;
} }
); );
} }

View File

@@ -119,6 +119,7 @@ class ReportHelper implements ReportHelperInterface
* @param Carbon $date * @param Carbon $date
* *
* @return array * @return array
* @throws \InvalidArgumentException
*/ */
public function listOfMonths(Carbon $date): array public function listOfMonths(Carbon $date): array
{ {

View File

@@ -24,7 +24,6 @@ namespace FireflyIII\Http\Controllers\Account;
use Carbon\Carbon; use Carbon\Carbon;
use FireflyIII\Exceptions\FireflyException; use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Factory\TransactionJournalFactory;
use FireflyIII\Helpers\Collector\JournalCollectorInterface; use FireflyIII\Helpers\Collector\JournalCollectorInterface;
use FireflyIII\Http\Controllers\Controller; use FireflyIII\Http\Controllers\Controller;
use FireflyIII\Http\Requests\ReconciliationStoreRequest; use FireflyIII\Http\Requests\ReconciliationStoreRequest;
@@ -37,12 +36,11 @@ use FireflyIII\Models\TransactionType;
use FireflyIII\Repositories\Account\AccountRepositoryInterface; use FireflyIII\Repositories\Account\AccountRepositoryInterface;
use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface; use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;
use FireflyIII\Repositories\Journal\JournalRepositoryInterface; use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
use FireflyIII\Services\Internal\Update\TransactionUpdateService; use FireflyIII\Services\Internal\Update\CurrencyUpdateService;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Illuminate\Support\Collection; use Illuminate\Support\Collection;
use Log; use Log;
use Preferences; use Preferences;
use Response;
use Session; use Session;
/** /**
@@ -52,6 +50,10 @@ use Session;
*/ */
class ReconcileController extends Controller class ReconcileController extends Controller
{ {
/** @var CurrencyUpdateService */
private $accountRepos;
/** @var AccountRepositoryInterface */
private $currencyRepos;
/** @var JournalRepositoryInterface */ /** @var JournalRepositoryInterface */
private $repository; private $repository;
@@ -68,6 +70,8 @@ class ReconcileController extends Controller
app('view')->share('mainTitleIcon', 'fa-credit-card'); app('view')->share('mainTitleIcon', 'fa-credit-card');
app('view')->share('title', trans('firefly.accounts')); app('view')->share('title', trans('firefly.accounts'));
$this->repository = app(JournalRepositoryInterface::class); $this->repository = app(JournalRepositoryInterface::class);
$this->accountRepos = app(AccountRepositoryInterface::class);
$this->currencyRepos = app(CurrencyRepositoryInterface::class);
return $next($request); return $next($request);
} }
@@ -92,7 +96,7 @@ class ReconcileController extends Controller
$preFilled = [ $preFilled = [
'date' => $this->repository->getJournalDate($journal, null), 'date' => $this->repository->getJournalDate($journal, null),
'category' => $this->repository->getJournalCategoryName($journal), 'category' => $this->repository->getJournalCategoryName($journal),
'tags' => join(',', $journal->tags->pluck('tag')->toArray()), 'tags' => implode(',', $journal->tags->pluck('tag')->toArray()),
'amount' => $pTransaction->amount, 'amount' => $pTransaction->amount,
]; ];
@@ -163,7 +167,7 @@ class ReconcileController extends Controller
)->render(), )->render(),
]; ];
return Response::json($return); return response()->json($return);
} }
/** /**
@@ -185,10 +189,8 @@ class ReconcileController extends Controller
return redirect(route('accounts.index', [config('firefly.shortNamesByFullName.' . $account->accountType->type)])); return redirect(route('accounts.index', [config('firefly.shortNamesByFullName.' . $account->accountType->type)]));
} }
/** @var CurrencyRepositoryInterface $currencyRepos */ $currencyId = intval($this->accountRepos->getMetaValue($account, 'currency_id'));
$currencyRepos = app(CurrencyRepositoryInterface::class); $currency = $this->currencyRepos->findNull($currencyId);
$currencyId = intval($account->getMeta('currency_id'));
$currency = $currencyRepos->findNull($currencyId);
if (0 === $currencyId) { if (0 === $currencyId) {
$currency = app('amount')->getDefaultCurrency(); // @codeCoverageIgnore $currency = app('amount')->getDefaultCurrency(); // @codeCoverageIgnore
} }
@@ -247,12 +249,12 @@ class ReconcileController extends Controller
/** /**
* @param ReconciliationStoreRequest $request * @param ReconciliationStoreRequest $request
* @param JournalRepositoryInterface $repository
* @param Account $account * @param Account $account
* @param Carbon $start * @param Carbon $start
* @param Carbon $end * @param Carbon $end
* *
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
* @throws FireflyException
*/ */
public function submit(ReconciliationStoreRequest $request, JournalRepositoryInterface $repository, Account $account, Carbon $start, Carbon $end) public function submit(ReconciliationStoreRequest $request, JournalRepositoryInterface $repository, Account $account, Carbon $start, Carbon $end)
{ {
@@ -268,9 +270,7 @@ class ReconcileController extends Controller
// create reconciliation transaction (if necessary): // create reconciliation transaction (if necessary):
if ('create' === $data['reconcile']) { if ('create' === $data['reconcile']) {
// get "opposing" account. // get "opposing" account.
/** @var AccountRepositoryInterface $accountRepos */ $reconciliation = $this->accountRepos->getReconciliation($account);
$accountRepos = app(AccountRepositoryInterface::class);
$reconciliation = $accountRepos->getReconciliation($account);
$difference = $data['difference']; $difference = $data['difference'];
@@ -300,7 +300,7 @@ class ReconcileController extends Controller
'tags' => null, 'tags' => null,
'interest_date' => null, 'interest_date' => null,
'transactions' => [[ 'transactions' => [[
'currency_id' => intval($account->getMeta('currency_id')), 'currency_id' => intval($this->accountRepos->getMetaValue($account, 'currency_id')),
'currency_code' => null, 'currency_code' => null,
'description' => null, 'description' => null,
'amount' => app('steam')->positive($difference), 'amount' => app('steam')->positive($difference),
@@ -319,7 +319,7 @@ class ReconcileController extends Controller
'category_name' => null, 'category_name' => null,
], ],
], ],
'notes' => join(', ', $data['transactions']), 'notes' => implode(', ', $data['transactions']),
]; ];
$journal = $repository->store($journalData); $journal = $repository->store($journalData);
@@ -350,10 +350,8 @@ class ReconcileController extends Controller
$startDate = clone $start; $startDate = clone $start;
$startDate->subDays(1); $startDate->subDays(1);
/** @var CurrencyRepositoryInterface $currencyRepos */ $currencyId = intval($this->accountRepos->getMetaValue($account, 'currency_id'));
$currencyRepos = app(CurrencyRepositoryInterface::class); $currency = $this->currencyRepos->findNull($currencyId);
$currencyId = intval($account->getMeta('currency_id'));
$currency = $currencyRepos->findNull($currencyId);
if (0 === $currencyId) { if (0 === $currencyId) {
$currency = app('amount')->getDefaultCurrency(); // @codeCoverageIgnore $currency = app('amount')->getDefaultCurrency(); // @codeCoverageIgnore
} }
@@ -375,7 +373,7 @@ class ReconcileController extends Controller
$transactions = $collector->getJournals(); $transactions = $collector->getJournals();
$html = view('accounts.reconcile.transactions', compact('account', 'transactions', 'start', 'end', 'selectionStart', 'selectionEnd'))->render(); $html = view('accounts.reconcile.transactions', compact('account', 'transactions', 'start', 'end', 'selectionStart', 'selectionEnd'))->render();
return Response::json(['html' => $html, 'startBalance' => $startBalance, 'endBalance' => $endBalance]); return response()->json(['html' => $html, 'startBalance' => $startBalance, 'endBalance' => $endBalance]);
} }
/** /**

View File

@@ -84,6 +84,7 @@ class AccountController extends Controller
* @param string $what * @param string $what
* *
* @return View * @return View
* @throws \RuntimeException
*/ */
public function create(Request $request, string $what = 'asset') public function create(Request $request, string $what = 'asset')
{ {
@@ -94,7 +95,7 @@ class AccountController extends Controller
$subTitle = trans('firefly.make_new_' . $what . '_account'); $subTitle = trans('firefly.make_new_' . $what . '_account');
$roles = []; $roles = [];
foreach (config('firefly.accountRoles') as $role) { foreach (config('firefly.accountRoles') as $role) {
$roles[$role] = strval(trans('firefly.account_role_' . $role)); $roles[$role] = (string)trans('firefly.account_role_' . $role);
} }
// pre fill some data // pre fill some data
@@ -129,10 +130,10 @@ class AccountController extends Controller
/** /**
* @param Request $request * @param Request $request
* @param AccountRepositoryInterface $repository
* @param Account $account * @param Account $account
* *
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
* @throws \RuntimeException
*/ */
public function destroy(Request $request, Account $account) public function destroy(Request $request, Account $account)
{ {
@@ -155,12 +156,14 @@ class AccountController extends Controller
* @param Request $request * @param Request $request
* @param Account $account * @param Account $account
* *
* @SuppressWarnings(PHPMD.CyclomaticComplexity) // long and complex but not that excessively so. * @param AccountRepositoryInterface $repository
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
* *
* @return View * @return View
* *
* @throws FireflyException * @SuppressWarnings(PHPMD.CyclomaticComplexity) // long and complex but not that excessively so.
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
*
* @throws \RuntimeException
*/ */
public function edit(Request $request, Account $account, AccountRepositoryInterface $repository) public function edit(Request $request, Account $account, AccountRepositoryInterface $repository)
{ {
@@ -185,14 +188,18 @@ class AccountController extends Controller
// the opening balance is tricky: // the opening balance is tricky:
$openingBalanceAmount = strval($repository->getOpeningBalanceAmount($account)); $openingBalanceAmount = strval($repository->getOpeningBalanceAmount($account));
$openingBalanceDate = $repository->getOpeningBalanceDate($account); $openingBalanceDate = $repository->getOpeningBalanceDate($account);
$currency = $this->currencyRepos->findNull(intval($account->getMeta('currency_id'))); $default = app('amount')->getDefaultCurrency();
$currency = $this->currencyRepos->findNull(intval($repository->getMetaValue($account, 'currency_id')));
if (is_null($currency)) {
$currency = $default;
}
$preFilled = [ $preFilled = [
'accountNumber' => $account->getMeta('accountNumber'), 'accountNumber' => $repository->getMetaValue($account, 'accountNumber'),
'accountRole' => $account->getMeta('accountRole'), 'accountRole' => $repository->getMetaValue($account, 'accountRole'),
'ccType' => $account->getMeta('ccType'), 'ccType' => $repository->getMetaValue($account, 'ccType'),
'ccMonthlyPaymentDate' => $account->getMeta('ccMonthlyPaymentDate'), 'ccMonthlyPaymentDate' => $repository->getMetaValue($account, 'ccMonthlyPaymentDate'),
'BIC' => $account->getMeta('BIC'), 'BIC' => $repository->getMetaValue($account, 'BIC'),
'openingBalanceDate' => $openingBalanceDate, 'openingBalanceDate' => $openingBalanceDate,
'openingBalance' => $openingBalanceAmount, 'openingBalance' => $openingBalanceAmount,
'virtualBalance' => $account->virtual_balance, 'virtualBalance' => $account->virtual_balance,
@@ -275,35 +282,34 @@ class AccountController extends Controller
* *
* @param Request $request * @param Request $request
* @param Account $account * @param Account $account
* @param string $moment * @param Carbon|null $start
* @param Carbon|null $end
* *
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector|View * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector|View
* *
* @SuppressWarnings(PHPMD.CyclomaticComplexity) // long and complex but not that excessively so.
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
*
* @throws FireflyException * @throws FireflyException
*
*/ */
public function show(Request $request, Account $account, Carbon $start = null, Carbon $end = null) public function show(Request $request, Account $account, Carbon $start = null, Carbon $end = null)
{ {
if (AccountType::INITIAL_BALANCE === $account->accountType->type) { if (AccountType::INITIAL_BALANCE === $account->accountType->type) {
return $this->redirectToOriginalAccount($account); return $this->redirectToOriginalAccount($account);
} }
$range = Preferences::get('viewRange', '1M')->data;
if (null === $start) { if (null === $start) {
$start = session('start'); $start = session('start');
} }
if (null === $end) { if (null === $end) {
$end = app('navigation')->endOfPeriod($start, $range); $end = session('end');
} }
if ($end < $start) { if ($end < $start) {
throw new FireflyException('End is after start!'); // @codeCoverageIgnore throw new FireflyException('End is after start!'); // @codeCoverageIgnore
} }
$today = new Carbon;
$subTitleIcon = config('firefly.subIconsByIdentifier.' . $account->accountType->type); $subTitleIcon = config('firefly.subIconsByIdentifier.' . $account->accountType->type);
$page = intval($request->get('page')); $page = (int)$request->get('page');
$pageSize = intval(Preferences::get('listPageSize', 50)->data); $pageSize = (int)Preferences::get('listPageSize', 50)->data;
$currencyId = intval($account->getMeta('currency_id')); $currencyId = (int)$this->repository->getMetaValue($account, 'currency_id');
$currency = $this->currencyRepos->findNull($currencyId); $currency = $this->currencyRepos->findNull($currencyId);
if (0 === $currencyId) { if (0 === $currencyId) {
$currency = app('amount')->getDefaultCurrency(); // @codeCoverageIgnore $currency = app('amount')->getDefaultCurrency(); // @codeCoverageIgnore
@@ -315,15 +321,56 @@ class AccountController extends Controller
$periods = $this->getPeriodOverview($account, $end); $periods = $this->getPeriodOverview($account, $end);
$collector = app(JournalCollectorInterface::class); $collector = app(JournalCollectorInterface::class);
$collector->setAccounts(new Collection([$account]))->setLimit($pageSize)->setPage($page); $collector->setAccounts(new Collection([$account]))->setLimit($pageSize)->setPage($page);
if (null !== $start) {
$collector->setRange($start, $end); $collector->setRange($start, $end);
}
$transactions = $collector->getPaginatedJournals(); $transactions = $collector->getPaginatedJournals();
$transactions->setPath(route('accounts.show', [$account->id, $start->format('Y-m-d'), $end->format('Y-m-d')])); $transactions->setPath(route('accounts.show', [$account->id, $start->format('Y-m-d'), $end->format('Y-m-d')]));
$showAll = false;
return view( return view(
'accounts.show', 'accounts.show',
compact('account', 'currency', 'periods', 'subTitleIcon', 'transactions', 'subTitle', 'start', 'end', 'chartUri') compact('account', 'showAll', 'currency', 'today', 'periods', 'subTitleIcon', 'transactions', 'subTitle', 'start', 'end', 'chartUri')
);
}
/**
* Show an account.
*
* @param Request $request
* @param Account $account
*
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector|View
*
* @throws FireflyException
*
*/
public function showAll(Request $request, Account $account)
{
if (AccountType::INITIAL_BALANCE === $account->accountType->type) {
return $this->redirectToOriginalAccount($account);
}
$end = new Carbon;
$today = new Carbon;
$start = $this->repository->oldestJournalDate($account);
$subTitleIcon = config('firefly.subIconsByIdentifier.' . $account->accountType->type);
$page = (int)$request->get('page');
$pageSize = (int)Preferences::get('listPageSize', 50)->data;
$currencyId = (int)$this->repository->getMetaValue($account, 'currency_id');
$currency = $this->currencyRepos->findNull($currencyId);
if (0 === $currencyId) {
$currency = app('amount')->getDefaultCurrency(); // @codeCoverageIgnore
}
$subTitle = trans('firefly.all_journals_for_account', ['name' => $account->name]);
$periods = new Collection;
$collector = app(JournalCollectorInterface::class);
$collector->setAccounts(new Collection([$account]))->setLimit($pageSize)->setPage($page);
$transactions = $collector->getPaginatedJournals();
$transactions->setPath(route('accounts.show.all', [$account->id]));
$chartUri = route('chart.account.period', [$account->id, $start->format('Y-m-d'), $end->format('Y-m-d')]);
$showAll = true;
return view(
'accounts.show',
compact('account', 'showAll', 'currency', 'today', 'chartUri', 'periods', 'subTitleIcon', 'transactions', 'subTitle', 'start', 'end')
); );
} }
@@ -331,12 +378,13 @@ class AccountController extends Controller
* @param AccountFormRequest $request * @param AccountFormRequest $request
* *
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
* @throws \RuntimeException
*/ */
public function store(AccountFormRequest $request) public function store(AccountFormRequest $request)
{ {
$data = $request->getAccountData(); $data = $request->getAccountData();
$account = $this->repository->store($data); $account = $this->repository->store($data);
$request->session()->flash('success', strval(trans('firefly.stored_new_account', ['name' => $account->name]))); $request->session()->flash('success', (string)trans('firefly.stored_new_account', ['name' => $account->name]));
Preferences::mark(); Preferences::mark();
// update preferences if necessary: // update preferences if necessary:
@@ -361,10 +409,10 @@ class AccountController extends Controller
/** /**
* @param AccountFormRequest $request * @param AccountFormRequest $request
* @param AccountRepositoryInterface $repository
* @param Account $account * @param Account $account
* *
* @return $this|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector * @return $this|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
* @throws \RuntimeException
*/ */
public function update(AccountFormRequest $request, Account $account) public function update(AccountFormRequest $request, Account $account)
{ {
@@ -407,6 +455,8 @@ class AccountController extends Controller
* *
* @param Account $account the account involved * @param Account $account the account involved
* *
* @param Carbon|null $date
*
* @return Collection * @return Collection
* *
* @SuppressWarnings(PHPMD.ExcessiveMethodLength) * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
@@ -429,33 +479,34 @@ class AccountController extends Controller
if ($cache->has()) { if ($cache->has()) {
return $cache->get(); // @codeCoverageIgnore return $cache->get(); // @codeCoverageIgnore
} }
/** @var array $dates */
$dates = app('navigation')->blockPeriods($start, $end, $range); $dates = app('navigation')->blockPeriods($start, $end, $range);
$entries = new Collection; $entries = new Collection;
// loop dates // loop dates
foreach ($dates as $date) { foreach ($dates as $currentDate) {
// try a collector for income: // try a collector for income:
/** @var JournalCollectorInterface $collector */ /** @var JournalCollectorInterface $collector */
$collector = app(JournalCollectorInterface::class); $collector = app(JournalCollectorInterface::class);
$collector->setAccounts(new Collection([$account]))->setRange($date['start'], $date['end'])->setTypes([TransactionType::DEPOSIT]) $collector->setAccounts(new Collection([$account]))->setRange($currentDate['start'], $currentDate['end'])->setTypes([TransactionType::DEPOSIT])
->withOpposingAccount(); ->withOpposingAccount();
$earned = strval($collector->getJournals()->sum('transaction_amount')); $earned = (string)$collector->getJournals()->sum('transaction_amount');
// try a collector for expenses: // try a collector for expenses:
/** @var JournalCollectorInterface $collector */ /** @var JournalCollectorInterface $collector */
$collector = app(JournalCollectorInterface::class); $collector = app(JournalCollectorInterface::class);
$collector->setAccounts(new Collection([$account]))->setRange($date['start'], $date['end'])->setTypes([TransactionType::WITHDRAWAL]) $collector->setAccounts(new Collection([$account]))->setRange($currentDate['start'], $currentDate['end'])->setTypes([TransactionType::WITHDRAWAL])
->withOpposingAccount(); ->withOpposingAccount();
$spent = strval($collector->getJournals()->sum('transaction_amount')); $spent = (string)$collector->getJournals()->sum('transaction_amount');
$dateName = app('navigation')->periodShow($date['start'], $date['period']); $dateName = app('navigation')->periodShow($currentDate['start'], $currentDate['period']);
$entries->push( $entries->push(
[ [
'name' => $dateName, 'name' => $dateName,
'spent' => $spent, 'spent' => $spent,
'earned' => $earned, 'earned' => $earned,
'start' => $date['start']->format('Y-m-d'), 'start' => $currentDate['start']->format('Y-m-d'),
'end' => $date['end']->format('Y-m-d'), 'end' => $currentDate['end']->format('Y-m-d'),
] ]
); );
} }

View File

@@ -76,6 +76,7 @@ class LinkController extends Controller
* @param LinkType $linkType * @param LinkType $linkType
* *
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector|View * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector|View
* @throws \RuntimeException
*/ */
public function delete(Request $request, LinkTypeRepositoryInterface $repository, LinkType $linkType) public function delete(Request $request, LinkTypeRepositoryInterface $repository, LinkType $linkType)
{ {
@@ -108,6 +109,7 @@ class LinkController extends Controller
* @param LinkType $linkType * @param LinkType $linkType
* *
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
* @throws \RuntimeException
*/ */
public function destroy(Request $request, LinkTypeRepositoryInterface $repository, LinkType $linkType) public function destroy(Request $request, LinkTypeRepositoryInterface $repository, LinkType $linkType)
{ {
@@ -126,6 +128,7 @@ class LinkController extends Controller
* @param LinkType $linkType * @param LinkType $linkType
* *
* @return \Illuminate\Contracts\View\Factory|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector|\Illuminate\View\View * @return \Illuminate\Contracts\View\Factory|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector|\Illuminate\View\View
* @throws \RuntimeException
*/ */
public function edit(Request $request, LinkType $linkType) public function edit(Request $request, LinkType $linkType)
{ {
@@ -184,6 +187,7 @@ class LinkController extends Controller
* @param LinkTypeRepositoryInterface $repository * @param LinkTypeRepositoryInterface $repository
* *
* @return $this|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector * @return $this|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
* @throws \RuntimeException
*/ */
public function store(LinkTypeFormRequest $request, LinkTypeRepositoryInterface $repository) public function store(LinkTypeFormRequest $request, LinkTypeRepositoryInterface $repository)
{ {
@@ -212,6 +216,7 @@ class LinkController extends Controller
* @param LinkType $linkType * @param LinkType $linkType
* *
* @return $this|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector * @return $this|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
* @throws \RuntimeException
*/ */
public function update(LinkTypeFormRequest $request, LinkTypeRepositoryInterface $repository, LinkType $linkType) public function update(LinkTypeFormRequest $request, LinkTypeRepositoryInterface $repository, LinkType $linkType)
{ {

View File

@@ -22,6 +22,7 @@ declare(strict_types=1);
namespace FireflyIII\Http\Controllers\Admin; namespace FireflyIII\Http\Controllers\Admin;
use Carbon\Carbon;
use FireflyConfig; use FireflyConfig;
use FireflyIII\Exceptions\FireflyException; use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Http\Controllers\Controller; use FireflyIII\Http\Controllers\Controller;
@@ -31,7 +32,6 @@ use FireflyIII\Services\Github\Object\Release;
use FireflyIII\Services\Github\Request\UpdateRequest; use FireflyIII\Services\Github\Request\UpdateRequest;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Log; use Log;
use Response;
use Session; use Session;
/** /**
@@ -61,6 +61,8 @@ class UpdateController extends Controller
/** /**
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
* @throws \Psr\Container\NotFoundExceptionInterface
* @throws \Psr\Container\ContainerExceptionInterface
* @throws \Illuminate\Container\EntryNotFoundException * @throws \Illuminate\Container\EntryNotFoundException
*/ */
public function index() public function index()
@@ -121,13 +123,21 @@ class UpdateController extends Controller
if ($check === -1) { if ($check === -1) {
// there is a new FF version! // there is a new FF version!
// has it been released for more than three days?
$today = new Carbon;
if ($today->diffInDays($first->getUpdated(), true) > 3) {
$string = strval( $string = strval(
trans( trans(
'firefly.update_new_version_alert', 'firefly.update_new_version_alert',
['your_version' => $current, 'new_version' => $first->getTitle(), 'date' => $first->getUpdated()->formatLocalized($this->monthAndDayFormat)] [
'your_version' => $current,
'new_version' => $first->getTitle(),
'date' => $first->getUpdated()->formatLocalized($this->monthAndDayFormat),
]
) )
); );
} }
}
if ($check === 0) { if ($check === 0) {
// you are running the current version! // you are running the current version!
$string = strval(trans('firefly.update_current_version_alert', ['version' => $current])); $string = strval(trans('firefly.update_current_version_alert', ['version' => $current]));
@@ -137,6 +147,6 @@ class UpdateController extends Controller
$string = strval(trans('firefly.update_newer_version_alert', ['your_version' => $current, 'new_version' => $first->getTitle()])); $string = strval(trans('firefly.update_newer_version_alert', ['your_version' => $current, 'new_version' => $first->getTitle()]));
} }
return Response::json(['result' => $string]); return response()->json(['result' => $string]);
} }
} }

View File

@@ -29,7 +29,6 @@ use FireflyIII\Repositories\Attachment\AttachmentRepositoryInterface;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Illuminate\Http\Response as LaravelResponse; use Illuminate\Http\Response as LaravelResponse;
use Preferences; use Preferences;
use Response;
use View; use View;
/** /**
@@ -81,6 +80,7 @@ class AttachmentController extends Controller
* @param Attachment $attachment * @param Attachment $attachment
* *
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
* @throws \RuntimeException
*/ */
public function destroy(Request $request, Attachment $attachment) public function destroy(Request $request, Attachment $attachment)
{ {
@@ -130,6 +130,7 @@ class AttachmentController extends Controller
* @param Attachment $attachment * @param Attachment $attachment
* *
* @return View * @return View
* @throws \RuntimeException
*/ */
public function edit(Request $request, Attachment $attachment) public function edit(Request $request, Attachment $attachment)
{ {
@@ -142,6 +143,9 @@ class AttachmentController extends Controller
} }
$request->session()->forget('attachments.edit.fromUpdate'); $request->session()->forget('attachments.edit.fromUpdate');
$preFilled['notes'] = $this->repository->getNoteText($attachment);
$request->session()->flash('preFilled', $preFilled);
return view('attachments.edit', compact('attachment', 'subTitleIcon', 'subTitle')); return view('attachments.edit', compact('attachment', 'subTitleIcon', 'subTitle'));
} }
@@ -150,6 +154,7 @@ class AttachmentController extends Controller
* @param Attachment $attachment * @param Attachment $attachment
* *
* @return \Illuminate\Http\RedirectResponse * @return \Illuminate\Http\RedirectResponse
* @throws \RuntimeException
*/ */
public function update(AttachmentFormRequest $request, Attachment $attachment) public function update(AttachmentFormRequest $request, Attachment $attachment)
{ {
@@ -182,7 +187,7 @@ class AttachmentController extends Controller
if ($this->repository->exists($attachment)) { if ($this->repository->exists($attachment)) {
$content = $this->repository->getContent($attachment); $content = $this->repository->getContent($attachment);
return Response::make( return response()->make(
$content, 200, [ $content, 200, [
'Content-Type' => $attachment->mime, 'Content-Type' => $attachment->mime,
'Content-Disposition' => 'inline; filename="' . $attachment->filename . '"', 'Content-Disposition' => 'inline; filename="' . $attachment->filename . '"',

View File

@@ -22,14 +22,13 @@ declare(strict_types=1);
namespace FireflyIII\Http\Controllers\Auth; namespace FireflyIII\Http\Controllers\Auth;
use DB;
use FireflyConfig; use FireflyConfig;
use FireflyIII\Http\Controllers\Controller; use FireflyIII\Http\Controllers\Controller;
use FireflyIII\Models\TransactionCurrency;
use FireflyIII\User; use FireflyIII\User;
use Illuminate\Cookie\CookieJar; use Illuminate\Cookie\CookieJar;
use Illuminate\Foundation\Auth\AuthenticatesUsers; use Illuminate\Foundation\Auth\AuthenticatesUsers;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Schema;
/** /**
* @codeCoverageIgnore * @codeCoverageIgnore
@@ -66,6 +65,7 @@ class LoginController extends Controller
* *
* @return \Illuminate\Http\Response|\Symfony\Component\HttpFoundation\Response * @return \Illuminate\Http\Response|\Symfony\Component\HttpFoundation\Response
* *
* @throws \RuntimeException
* @throws \Illuminate\Validation\ValidationException * @throws \Illuminate\Validation\ValidationException
*/ */
public function login(Request $request) public function login(Request $request)
@@ -103,6 +103,7 @@ class LoginController extends Controller
* @param CookieJar $cookieJar * @param CookieJar $cookieJar
* *
* @return $this|\Illuminate\Http\RedirectResponse * @return $this|\Illuminate\Http\RedirectResponse
* @throws \RuntimeException
*/ */
public function logout(Request $request, CookieJar $cookieJar) public function logout(Request $request, CookieJar $cookieJar)
{ {
@@ -120,26 +121,13 @@ class LoginController extends Controller
* @param Request $request * @param Request $request
* *
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
* @throws \RuntimeException
*/ */
public function showLoginForm(Request $request) public function showLoginForm(Request $request)
{ {
// check for presence of tables: $count = DB::table('users')->count();
$hasTable = Schema::hasTable('users'); if ($count === 0) {
return redirect(route('register')); // @codeCoverageIgnore
if (!$hasTable) {
$message
= 'Firefly III could not find the "users" table. This is a strong indication your database credentials are wrong or the database has not been initialized. Did you follow the installation instructions correctly?';
return view('error', compact('message'));
}
// check for presence of currency:
$currency = TransactionCurrency::where('code', 'EUR')->first();
if (null === $currency) {
$message
= 'Firefly III could not find the EURO currency. This is a strong indication the database has not been initialized correctly. Did you follow the installation instructions?';
return view('error', compact('message'));
} }
// forget 2fa session thing. // forget 2fa session thing.

View File

@@ -40,6 +40,7 @@ class TwoFactorController extends Controller
* *
* @return \Illuminate\Contracts\View\Factory|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector|\Illuminate\View\View * @return \Illuminate\Contracts\View\Factory|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector|\Illuminate\View\View
* *
* @throws \RuntimeException
* @throws FireflyException * @throws FireflyException
* *
* @SuppressWarnings(PHPMD.CyclomaticComplexity) * @SuppressWarnings(PHPMD.CyclomaticComplexity)
@@ -91,6 +92,7 @@ class TwoFactorController extends Controller
* *
* @return mixed * @return mixed
* @SuppressWarnings(PHPMD.UnusedFormalParameter) // it's unused but the class does some validation. * @SuppressWarnings(PHPMD.UnusedFormalParameter) // it's unused but the class does some validation.
* @throws \RuntimeException
*/ */
public function postIndex(TokenFormRequest $request, CookieJar $cookieJar) public function postIndex(TokenFormRequest $request, CookieJar $cookieJar)
{ {

View File

@@ -22,7 +22,6 @@ declare(strict_types=1);
namespace FireflyIII\Http\Controllers; namespace FireflyIII\Http\Controllers;
use Carbon\Carbon;
use FireflyIII\Helpers\Attachments\AttachmentHelperInterface; use FireflyIII\Helpers\Attachments\AttachmentHelperInterface;
use FireflyIII\Helpers\Collector\JournalCollectorInterface; use FireflyIII\Helpers\Collector\JournalCollectorInterface;
use FireflyIII\Http\Requests\BillFormRequest; use FireflyIII\Http\Requests\BillFormRequest;
@@ -76,6 +75,7 @@ class BillController extends Controller
* @param Request $request * @param Request $request
* *
* @return View * @return View
* @throws \RuntimeException
*/ */
public function create(Request $request) public function create(Request $request)
{ {
@@ -114,6 +114,7 @@ class BillController extends Controller
* @param Bill $bill * @param Bill $bill
* *
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
* @throws \RuntimeException
*/ */
public function destroy(Request $request, BillRepositoryInterface $repository, Bill $bill) public function destroy(Request $request, BillRepositoryInterface $repository, Bill $bill)
{ {
@@ -131,6 +132,7 @@ class BillController extends Controller
* @param Bill $bill * @param Bill $bill
* *
* @return View * @return View
* @throws \RuntimeException
*/ */
public function edit(Request $request, Bill $bill) public function edit(Request $request, Bill $bill)
{ {
@@ -199,6 +201,7 @@ class BillController extends Controller
* @param Bill $bill * @param Bill $bill
* *
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
* @throws \RuntimeException
*/ */
public function rescan(Request $request, BillRepositoryInterface $repository, Bill $bill) public function rescan(Request $request, BillRepositoryInterface $repository, Bill $bill)
{ {
@@ -265,6 +268,7 @@ class BillController extends Controller
* @param BillRepositoryInterface $repository * @param BillRepositoryInterface $repository
* *
* @return \Illuminate\Http\RedirectResponse * @return \Illuminate\Http\RedirectResponse
* @throws \RuntimeException
*/ */
public function store(BillFormRequest $request, BillRepositoryInterface $repository) public function store(BillFormRequest $request, BillRepositoryInterface $repository)
{ {
@@ -300,6 +304,7 @@ class BillController extends Controller
* @param Bill $bill * @param Bill $bill
* *
* @return \Illuminate\Http\RedirectResponse * @return \Illuminate\Http\RedirectResponse
* @throws \RuntimeException
*/ */
public function update(BillFormRequest $request, BillRepositoryInterface $repository, Bill $bill) public function update(BillFormRequest $request, BillRepositoryInterface $repository, Bill $bill)
{ {

View File

@@ -39,7 +39,6 @@ use Illuminate\Pagination\LengthAwarePaginator;
use Illuminate\Support\Collection; use Illuminate\Support\Collection;
use Log; use Log;
use Preferences; use Preferences;
use Response;
use View; use View;
/** /**
@@ -79,6 +78,7 @@ class BudgetController extends Controller
* @param Budget $budget * @param Budget $budget
* *
* @return \Illuminate\Http\JsonResponse * @return \Illuminate\Http\JsonResponse
* @throws \InvalidArgumentException
*/ */
public function amount(Request $request, BudgetRepositoryInterface $repository, Budget $budget) public function amount(Request $request, BudgetRepositoryInterface $repository, Budget $budget)
{ {
@@ -86,6 +86,10 @@ class BudgetController extends Controller
$start = Carbon::createFromFormat('Y-m-d', $request->get('start')); $start = Carbon::createFromFormat('Y-m-d', $request->get('start'));
$end = Carbon::createFromFormat('Y-m-d', $request->get('end')); $end = Carbon::createFromFormat('Y-m-d', $request->get('end'));
$budgetLimit = $this->repository->updateLimitAmount($budget, $start, $end, $amount); $budgetLimit = $this->repository->updateLimitAmount($budget, $start, $end, $amount);
$largeDiff = false;
$warnText = '';
$average = '0';
$current = '0';
if (0 === bccomp($amount, '0')) { if (0 === bccomp($amount, '0')) {
$budgetLimit = null; $budgetLimit = null;
} }
@@ -95,15 +99,50 @@ class BudgetController extends Controller
$currency = app('amount')->getDefaultCurrency(); $currency = app('amount')->getDefaultCurrency();
$left = app('amount')->formatAnything($currency, bcadd($amount, $spent), true); $left = app('amount')->formatAnything($currency, bcadd($amount, $spent), true);
// over or under budgeting, compared to previous budgets?
$average = $this->repository->budgetedPerDay($budget);
// current average per day:
$diff = $start->diffInDays($end);
$current = $amount;
if ($diff > 0) {
$current = bcdiv($amount, strval($diff));
}
if (bccomp(bcmul('1.1', $average), $current) === -1) {
$largeDiff = true;
$warnText = strval(
trans(
'firefly.over_budget_warn',
[
'amount' => app('amount')->formatAnything($currency, $average, false),
'over_amount' => app('amount')->formatAnything($currency, $current, false),
]
)
);
}
Preferences::mark(); Preferences::mark();
return Response::json(['left' => $left, 'name' => $budget->name, 'limit' => $budgetLimit ? $budgetLimit->id : 0, 'amount' => $amount]); return response()->json(
[
'left' => $left,
'name' => $budget->name,
'limit' => $budgetLimit ? $budgetLimit->id : 0,
'amount' => $amount,
'current' => $current,
'average' => $average,
'large_diff' => $largeDiff,
'warn_text' => $warnText,
]
);
} }
/** /**
* @param Request $request * @param Request $request
* *
* @return View * @return View
* @throws \RuntimeException
*/ */
public function create(Request $request) public function create(Request $request)
{ {
@@ -137,6 +176,7 @@ class BudgetController extends Controller
* @param Budget $budget * @param Budget $budget
* *
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
* @throws \RuntimeException
*/ */
public function destroy(Request $request, Budget $budget) public function destroy(Request $request, Budget $budget)
{ {
@@ -153,6 +193,7 @@ class BudgetController extends Controller
* @param Budget $budget * @param Budget $budget
* *
* @return View * @return View
* @throws \RuntimeException
*/ */
public function edit(Request $request, Budget $budget) public function edit(Request $request, Budget $budget)
{ {
@@ -168,6 +209,7 @@ class BudgetController extends Controller
} }
/** /**
* @param Request $request
* @param string|null $moment * @param string|null $moment
* *
* @return View * @return View
@@ -184,12 +226,13 @@ class BudgetController extends Controller
$pageSize = intval(Preferences::get('listPageSize', 50)->data); $pageSize = intval(Preferences::get('listPageSize', 50)->data);
// make date if present: // make date if present:
if (null !== $moment || 0 !== strlen(strval($moment))) { if (null !== $moment || '' !== (string)$moment) {
try { try {
$start = new Carbon($moment); $start = new Carbon($moment);
$end = app('navigation')->endOfPeriod($start, $range); $end = app('navigation')->endOfPeriod($start, $range);
} catch (Exception $e) { } catch (Exception $e) {
// start and end are already defined. // start and end are already defined.
Log::debug('start and end are already defined.');
} }
} }
$next = clone $end; $next = clone $end;
@@ -292,7 +335,7 @@ class BudgetController extends Controller
// @codeCoverageIgnoreStart // @codeCoverageIgnoreStart
$result = $cache->get(); $result = $cache->get();
return view('budgets.info', compact('result', 'begin', 'currentEnd')); return view('budgets.info', compact('result'));
// @codeCoverageIgnoreEnd // @codeCoverageIgnoreEnd
} }
$result = [ $result = [
@@ -413,6 +456,7 @@ class BudgetController extends Controller
* @param BudgetIncomeRequest $request * @param BudgetIncomeRequest $request
* *
* @return \Illuminate\Http\RedirectResponse * @return \Illuminate\Http\RedirectResponse
* @throws \InvalidArgumentException
*/ */
public function postUpdateIncome(BudgetIncomeRequest $request) public function postUpdateIncome(BudgetIncomeRequest $request)
{ {
@@ -433,16 +477,18 @@ class BudgetController extends Controller
* @param Budget $budget * @param Budget $budget
* *
* @return View * @return View
* @throws \InvalidArgumentException
*/ */
public function show(Request $request, Budget $budget) public function show(Request $request, Budget $budget)
{ {
/** @var Carbon $start */ /** @var Carbon $start */
$start = session('first', Carbon::create()->startOfYear()); $start = session('first', Carbon::create()->startOfYear());
$end = new Carbon; $end = new Carbon;
$page = intval($request->get('page')); $page = (int)$request->get('page');
$pageSize = intval(Preferences::get('listPageSize', 50)->data); $pageSize = (int)Preferences::get('listPageSize', 50)->data;
$limits = $this->getLimits($budget, $start, $end); $limits = $this->getLimits($budget, $start, $end);
$repetition = null; $repetition = null;
// collector: // collector:
/** @var JournalCollectorInterface $collector */ /** @var JournalCollectorInterface $collector */
$collector = app(JournalCollectorInterface::class); $collector = app(JournalCollectorInterface::class);
@@ -462,6 +508,7 @@ class BudgetController extends Controller
* *
* @return View * @return View
* *
* @throws \InvalidArgumentException
* @throws FireflyException * @throws FireflyException
*/ */
public function showByBudgetLimit(Request $request, Budget $budget, BudgetLimit $budgetLimit) public function showByBudgetLimit(Request $request, Budget $budget, BudgetLimit $budgetLimit)
@@ -499,6 +546,7 @@ class BudgetController extends Controller
* @param BudgetFormRequest $request * @param BudgetFormRequest $request
* *
* @return \Illuminate\Http\RedirectResponse * @return \Illuminate\Http\RedirectResponse
* @throws \RuntimeException
*/ */
public function store(BudgetFormRequest $request) public function store(BudgetFormRequest $request)
{ {
@@ -524,6 +572,7 @@ class BudgetController extends Controller
* @param Budget $budget * @param Budget $budget
* *
* @return \Illuminate\Http\RedirectResponse * @return \Illuminate\Http\RedirectResponse
* @throws \RuntimeException
*/ */
public function update(BudgetFormRequest $request, Budget $budget) public function update(BudgetFormRequest $request, Budget $budget)
{ {
@@ -546,6 +595,7 @@ class BudgetController extends Controller
} }
/** /**
* @param Request $request
* @param Carbon $start * @param Carbon $start
* @param Carbon $end * @param Carbon $end
* *

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