mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-12 15:35:15 +00:00
Merge branch 'release/4.7.2'
This commit is contained in:
82
.deploy/kubernetes/firefly.yaml
Normal file
82
.deploy/kubernetes/firefly.yaml
Normal 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
|
49
.deploy/kubernetes/sql.yaml
Normal file
49
.deploy/kubernetes/sql.yaml
Normal 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
|
||||
|
13
.env.docker
13
.env.docker
@@ -17,11 +17,14 @@ APP_KEY=${FF_APP_KEY}
|
||||
APP_URL=${APP_URL}
|
||||
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
|
||||
# If you use SQLite, set connection to `sqlite` and remove the database, username and password settings.
|
||||
DB_CONNECTION=mysql
|
||||
DB_HOST=${FF_DB_HOST}
|
||||
DB_PORT=3306
|
||||
DB_PORT=${FF_DB_PORT}
|
||||
DB_DATABASE=${FF_DB_NAME}
|
||||
DB_USERNAME=${FF_DB_USER}
|
||||
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.
|
||||
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.
|
||||
ANALYTICS_ID=${ANALYTICS_ID}
|
||||
|
||||
@@ -79,7 +87,6 @@ REDIS_PASSWORD=null
|
||||
REDIS_PORT=6379
|
||||
CACHE_PREFIX=firefly
|
||||
SEARCH_RESULT_LIMIT=50
|
||||
EXCHANGE_RATE_SERVICE=fixerio
|
||||
PUSHER_KEY=
|
||||
PUSHER_SECRET=
|
||||
PUSHER_ID=
|
||||
@@ -88,4 +95,4 @@ DEMO_PASSWORD=
|
||||
IS_DOCKER=true
|
||||
IS_SANDSTORM=false
|
||||
IS_HEROKU=false
|
||||
TZ=${TZ}
|
||||
TZ=${TZ}
|
||||
|
11
.env.example
11
.env.example
@@ -21,8 +21,11 @@ TZ=UTC
|
||||
APP_URL=http://localhost
|
||||
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
|
||||
# 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_HOST=127.0.0.1
|
||||
DB_PORT=3306
|
||||
@@ -66,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.
|
||||
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.
|
||||
ANALYTICS_ID=
|
||||
|
||||
@@ -83,7 +91,6 @@ REDIS_PASSWORD=null
|
||||
REDIS_PORT=6379
|
||||
CACHE_PREFIX=firefly
|
||||
SEARCH_RESULT_LIMIT=50
|
||||
EXCHANGE_RATE_SERVICE=fixerio
|
||||
PUSHER_KEY=
|
||||
PUSHER_SECRET=
|
||||
PUSHER_ID=
|
||||
|
@@ -21,6 +21,9 @@ TZ=UTC
|
||||
APP_URL=http://localhost
|
||||
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
|
||||
# If you use SQLite, set connection to `sqlite` and remove the database, username and password settings.
|
||||
DB_CONNECTION=pgsql
|
||||
@@ -66,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.
|
||||
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.
|
||||
ANALYTICS_ID=
|
||||
|
||||
@@ -83,7 +91,6 @@ REDIS_PASSWORD=null
|
||||
REDIS_PORT=6379
|
||||
CACHE_PREFIX=firefly
|
||||
SEARCH_RESULT_LIMIT=50
|
||||
EXCHANGE_RATE_SERVICE=fixerio
|
||||
PUSHER_KEY=
|
||||
PUSHER_SECRET=
|
||||
PUSHER_ID=
|
||||
|
@@ -21,6 +21,9 @@ TZ=UTC
|
||||
APP_URL=http://localhost
|
||||
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
|
||||
# If you use SQLite, set connection to `sqlite` and remove the database, username and password settings.
|
||||
DB_CONNECTION=mysql
|
||||
@@ -66,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.
|
||||
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.
|
||||
ANALYTICS_ID=
|
||||
|
||||
@@ -83,7 +91,6 @@ REDIS_PASSWORD=null
|
||||
REDIS_PORT=6379
|
||||
CACHE_PREFIX=firefly
|
||||
SEARCH_RESULT_LIMIT=50
|
||||
EXCHANGE_RATE_SERVICE=fixerio
|
||||
PUSHER_KEY=
|
||||
PUSHER_SECRET=
|
||||
PUSHER_ID=
|
||||
|
88
.env.testing
88
.env.testing
@@ -1,33 +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
|
||||
|
||||
# Set to true if you want to see debug information in error screens.
|
||||
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_LOG=daily
|
||||
APP_LOG_LEVEL=debug
|
||||
APP_URL=http://localhost
|
||||
TRUSTED_PROXIES=
|
||||
|
||||
# Change this value to your preferred time zone.
|
||||
# Example: Europe/Amsterdam
|
||||
TZ=Europe/Amsterdam
|
||||
|
||||
DB_CONNECTION=sqlite
|
||||
DB_HOST=127.0.0.1
|
||||
DB_PORT=3306
|
||||
#DB_DATABASE=firefly
|
||||
DB_USERNAME=homestead
|
||||
DB_PASSWORD=
|
||||
# APP_URL and TRUSTED_PROXIES are useful when using Docker and/or a reverse proxy.
|
||||
APP_URL=http://localhost
|
||||
TRUSTED_PROXIES=
|
||||
|
||||
BROADCAST_DRIVER=log
|
||||
# The log channel defines where your log entries go to.
|
||||
LOG_CHANNEL=dailytest
|
||||
|
||||
# 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
|
||||
SESSION_DRIVER=file
|
||||
QUEUE_DRIVER=sync
|
||||
|
||||
# Cookie settings. Should not be necessary to change these.
|
||||
COOKIE_PATH="/"
|
||||
COOKIE_DOMAIN=
|
||||
COOKIE_SECURE=false
|
||||
|
||||
REDIS_HOST=127.0.0.1
|
||||
REDIS_PASSWORD=null
|
||||
REDIS_PORT=6379
|
||||
|
||||
# If you want Firefly III to mail you, update these settings
|
||||
MAIL_DRIVER=log
|
||||
MAIL_HOST=smtp.mailtrap.io
|
||||
MAIL_PORT=2525
|
||||
@@ -36,26 +57,41 @@ MAIL_USERNAME=null
|
||||
MAIL_PASSWORD=null
|
||||
MAIL_ENCRYPTION=null
|
||||
|
||||
# Firefly III can send you the following messages
|
||||
SEND_REGISTRATION_MAIL=true
|
||||
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=
|
||||
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_SECRET=
|
||||
PUSHER_ID=
|
||||
|
||||
DEMO_USERNAME=
|
||||
DEMO_PASSWORD=
|
||||
|
||||
IS_DOCKER=false
|
||||
IS_SANDSTORM=false
|
||||
IS_HEROKU=false
|
||||
|
@@ -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
|
||||
- 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)
|
||||
|
@@ -15,8 +15,8 @@ const pkgdef :Spk.PackageDefinition = (
|
||||
|
||||
manifest = (
|
||||
appTitle = (defaultText = "Firefly III"),
|
||||
appVersion = 9,
|
||||
appMarketingVersion = (defaultText = "4.7.1"),
|
||||
appVersion = 10,
|
||||
appMarketingVersion = (defaultText = "4.7.2"),
|
||||
|
||||
actions = [
|
||||
# Define your "new document" handlers here.
|
||||
|
@@ -12,21 +12,19 @@ install:
|
||||
- composer update --no-scripts
|
||||
- cp .env.testing .env
|
||||
- php artisan clear-compiled
|
||||
- php artisan optimize
|
||||
- php artisan env
|
||||
- cp .env.testing .env
|
||||
- wget -q https://github.com/firefly-iii/test-data/raw/master/storage/database.sqlite -O storage/database/database.sqlite
|
||||
- mkdir -p build/logs
|
||||
|
||||
script:
|
||||
- phpunit -c phpunit.coverage.xml
|
||||
- ./vendor/bin/phpunit -c phpunit.coverage.xml
|
||||
|
||||
after_success:
|
||||
- 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
|
||||
branches:
|
||||
only:
|
||||
- develop
|
||||
- master
|
||||
- master
|
||||
|
@@ -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
|
||||
|
||||
# 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..
|
||||
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
|
||||
|
||||
# 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
|
||||
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
|
||||
|
||||
# Run entrypoint thing
|
||||
ENTRYPOINT ["docker/entrypoint.sh"]
|
||||
ENTRYPOINT [".deploy/docker/entrypoint.sh"]
|
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* AboutController.php
|
||||
* Copyright (c) 2018 thegrumpydictator@gmail.com
|
||||
@@ -19,7 +20,6 @@
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Api\V1\Controllers;
|
||||
|
||||
@@ -30,7 +30,6 @@ use League\Fractal\Manager;
|
||||
use League\Fractal\Resource\Item;
|
||||
use League\Fractal\Serializer\JsonApiSerializer;
|
||||
|
||||
|
||||
/**
|
||||
* Class AboutController
|
||||
*/
|
||||
@@ -44,7 +43,6 @@ class AboutController extends Controller
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -55,7 +53,7 @@ class AboutController extends Controller
|
||||
$search = ['~', '#'];
|
||||
$replace = ['\~', '# '];
|
||||
$phpVersion = str_replace($search, $replace, PHP_VERSION);
|
||||
$phpOs = str_replace($search, $replace, php_uname());
|
||||
$phpOs = str_replace($search, $replace, PHP_OS);
|
||||
$currentDriver = DB::getDriverName();
|
||||
$data
|
||||
= [
|
||||
@@ -64,7 +62,6 @@ class AboutController extends Controller
|
||||
'php_version' => $phpVersion,
|
||||
'os' => $phpOs,
|
||||
'driver' => $currentDriver,
|
||||
|
||||
];
|
||||
|
||||
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');
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* AccountController.php
|
||||
* Copyright (c) 2018 thegrumpydictator@gmail.com
|
||||
@@ -19,7 +20,6 @@
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Api\V1\Controllers;
|
||||
|
||||
@@ -43,7 +43,6 @@ use Preferences;
|
||||
*/
|
||||
class AccountController extends Controller
|
||||
{
|
||||
|
||||
/** @var CurrencyRepositoryInterface */
|
||||
private $currencyRepository;
|
||||
/** @var AccountRepositoryInterface */
|
||||
@@ -59,7 +58,7 @@ class AccountController extends Controller
|
||||
parent::__construct();
|
||||
$this->middleware(
|
||||
function ($request, $next) {
|
||||
/** @var AccountRepositoryInterface repository */
|
||||
// @var AccountRepositoryInterface repository
|
||||
$this->repository = app(AccountRepositoryInterface::class);
|
||||
$this->repository->setUser(auth()->user());
|
||||
|
||||
@@ -74,7 +73,7 @@ class AccountController extends Controller
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*
|
||||
* @param \FireflyIII\Models\Account $account
|
||||
* @param \FireflyIII\Models\Account $account
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
@@ -95,16 +94,16 @@ class AccountController extends Controller
|
||||
public function index(Request $request)
|
||||
{
|
||||
// create some objects:
|
||||
$manager = new Manager();
|
||||
$baseUrl = $request->getSchemeAndHttpHost() . '/api/v1';
|
||||
$manager = new Manager();
|
||||
$baseUrl = $request->getSchemeAndHttpHost() . '/api/v1';
|
||||
|
||||
// read type from URI
|
||||
$type = $request->get('type') ?? 'all';
|
||||
$this->parameters->set('type', $type);
|
||||
|
||||
// types to get, page size:
|
||||
$types = $this->mapTypes($this->parameters->get('type'));
|
||||
$pageSize = intval(Preferences::getForUser(auth()->user(), 'listPageSize', 50)->data);
|
||||
$types = $this->mapTypes($this->parameters->get('type'));
|
||||
$pageSize = intval(Preferences::getForUser(auth()->user(), 'listPageSize', 50)->data);
|
||||
|
||||
// get list of accounts. Count it and split it.
|
||||
$collection = $this->repository->getAccountsByType($types);
|
||||
@@ -153,7 +152,7 @@ class AccountController extends Controller
|
||||
{
|
||||
$data = $request->getAll();
|
||||
// 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']);
|
||||
$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');
|
||||
|
||||
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();
|
||||
// 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']);
|
||||
$data['currency_id'] = is_null($currency) ? 0 : $currency->id;
|
||||
}
|
||||
|
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* BillController.php
|
||||
* Copyright (c) 2018 thegrumpydictator@gmail.com
|
||||
@@ -18,12 +19,10 @@
|
||||
* 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\Api\V1\Controllers;
|
||||
|
||||
use FireflyIII\Api\V1\Requests\BillRequest;
|
||||
use FireflyIII\Exceptions\FireflyException;
|
||||
use FireflyIII\Models\Bill;
|
||||
use FireflyIII\Repositories\Bill\BillRepositoryInterface;
|
||||
use FireflyIII\Transformers\BillTransformer;
|
||||
|
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* Controller.php
|
||||
* Copyright (c) 2018 thegrumpydictator@gmail.com
|
||||
@@ -18,7 +19,6 @@
|
||||
* 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\Api\V1\Controllers;
|
||||
|
||||
@@ -30,10 +30,12 @@ use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
|
||||
use Illuminate\Foundation\Bus\DispatchesJobs;
|
||||
use Illuminate\Foundation\Validation\ValidatesRequests;
|
||||
use Illuminate\Routing\Controller as BaseController;
|
||||
use Log;
|
||||
use Symfony\Component\HttpFoundation\ParameterBag;
|
||||
|
||||
/**
|
||||
* Class Controller.
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
class Controller extends BaseController
|
||||
@@ -70,7 +72,7 @@ class Controller extends BaseController
|
||||
$return = '?';
|
||||
$params = [];
|
||||
foreach ($this->parameters as $key => $value) {
|
||||
if($key === 'page') {
|
||||
if ($key === 'page') {
|
||||
continue;
|
||||
}
|
||||
if ($value instanceof Carbon) {
|
||||
@@ -110,6 +112,7 @@ class Controller extends BaseController
|
||||
$obj = new Carbon($date);
|
||||
} catch (InvalidDateException $e) {
|
||||
// don't care
|
||||
Log::error(sprintf('Invalid date exception in API controller: %s', $e->getMessage()));
|
||||
}
|
||||
}
|
||||
$bag->set($field, $obj);
|
||||
|
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* TransactionController.php
|
||||
* Copyright (c) 2018 thegrumpydictator@gmail.com
|
||||
@@ -19,7 +20,6 @@
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Api\V1\Controllers;
|
||||
|
||||
@@ -37,7 +37,6 @@ use Illuminate\Support\Collection;
|
||||
use League\Fractal\Manager;
|
||||
use League\Fractal\Pagination\IlluminatePaginatorAdapter;
|
||||
use League\Fractal\Resource\Collection as FractalCollection;
|
||||
use League\Fractal\Resource\Item;
|
||||
use League\Fractal\Serializer\JsonApiSerializer;
|
||||
use Log;
|
||||
use Preferences;
|
||||
@@ -172,7 +171,9 @@ class TransactionController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* @param TransactionRequest $request
|
||||
* @param TransactionRequest $request
|
||||
*
|
||||
* @param JournalRepositoryInterface $repository
|
||||
*
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
|
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* UserController.php
|
||||
* Copyright (c) 2018 thegrumpydictator@gmail.com
|
||||
@@ -19,7 +20,6 @@
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Api\V1\Controllers;
|
||||
|
||||
@@ -70,6 +70,7 @@ class UserController extends Controller
|
||||
* @param \FireflyIII\User $user
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
* @throws \Symfony\Component\HttpFoundation\File\Exception\AccessDeniedException
|
||||
*/
|
||||
public function delete(User $user)
|
||||
{
|
||||
|
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* AccountRequest.php
|
||||
* Copyright (c) 2018 thegrumpydictator@gmail.com
|
||||
@@ -19,7 +20,6 @@
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Api\V1\Requests;
|
||||
|
||||
@@ -70,9 +70,9 @@ class AccountRequest extends Request
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
$accountRoles = join(',', config('firefly.accountRoles'));
|
||||
$types = join(',', array_keys(config('firefly.subTitlesByIdentifier')));
|
||||
$ccPaymentTypes = join(',', array_keys(config('firefly.ccTypes')));
|
||||
$accountRoles = implode(',', config('firefly.accountRoles'));
|
||||
$types = implode(',', array_keys(config('firefly.subTitlesByIdentifier')));
|
||||
$ccPaymentTypes = implode(',', array_keys(config('firefly.ccTypes')));
|
||||
$rules = [
|
||||
'name' => 'required|min:1|uniqueAccountForUser',
|
||||
'opening_balance' => 'numeric|required_with:opening_balance_date|nullable',
|
||||
|
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* BillRequest.php
|
||||
* Copyright (c) 2018 thegrumpydictator@gmail.com
|
||||
@@ -19,7 +20,6 @@
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Api\V1\Requests;
|
||||
|
||||
|
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* Request.php
|
||||
* Copyright (c) 2018 thegrumpydictator@gmail.com
|
||||
@@ -18,11 +19,11 @@
|
||||
* 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\Api\V1\Requests;
|
||||
|
||||
use FireflyIII\Http\Requests\Request as FireflyIIIRequest;
|
||||
|
||||
/**
|
||||
* Class Request.
|
||||
*/
|
||||
|
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* TransactionRequest.php
|
||||
* Copyright (c) 2018 thegrumpydictator@gmail.com
|
||||
@@ -19,7 +20,6 @@
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Api\V1\Requests;
|
||||
|
||||
@@ -168,6 +168,7 @@ class TransactionRequest extends Request
|
||||
* @param Validator $validator
|
||||
*
|
||||
* @return void
|
||||
* @throws \FireflyIII\Exceptions\FireflyException
|
||||
*/
|
||||
public function withValidator(Validator $validator): void
|
||||
{
|
||||
@@ -192,8 +193,10 @@ class TransactionRequest extends Request
|
||||
* @param null|string $accountName
|
||||
* @param string $idField
|
||||
* @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);
|
||||
@@ -202,7 +205,7 @@ class TransactionRequest extends Request
|
||||
if ($accountId < 1 && strlen($accountName) === 0) {
|
||||
$validator->errors()->add($idField, trans('validation.filled', ['attribute' => $idField]));
|
||||
|
||||
return;
|
||||
return null;
|
||||
}
|
||||
// ID belongs to user and is asset account:
|
||||
/** @var AccountRepositoryInterface $repository */
|
||||
@@ -215,19 +218,21 @@ class TransactionRequest extends Request
|
||||
if ($first->accountType->type !== AccountType::ASSET) {
|
||||
$validator->errors()->add($idField, trans('validation.belongs_user'));
|
||||
|
||||
return;
|
||||
return null;
|
||||
}
|
||||
|
||||
// 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)) {
|
||||
$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 null|string $accountName
|
||||
* @param string $idField
|
||||
*
|
||||
* @return null|Account
|
||||
*/
|
||||
protected function opposingAccountExists(Validator $validator, string $type, ?int $accountId, ?string $accountName, string $idField): void {
|
||||
protected function opposingAccountExists(Validator $validator, string $type, ?int $accountId, ?string $accountName, string $idField): ?Account
|
||||
{
|
||||
$accountId = intval($accountId);
|
||||
$accountName = strval($accountName);
|
||||
// both empty? done!
|
||||
if ($accountId < 1 && strlen($accountName) === 0) {
|
||||
return;
|
||||
return null;
|
||||
}
|
||||
if ($accountId !== 0) {
|
||||
// ID belongs to user and is $type account:
|
||||
@@ -362,16 +370,16 @@ class TransactionRequest extends Request
|
||||
if ($first->accountType->type !== $type) {
|
||||
$validator->errors()->add($idField, trans('validation.belongs_user'));
|
||||
|
||||
return;
|
||||
return null;
|
||||
}
|
||||
|
||||
// we ignore the account name at this point.
|
||||
return;
|
||||
return $first;
|
||||
}
|
||||
}
|
||||
|
||||
// not having an opposing account by this name is NOT a problem.
|
||||
return;
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -395,41 +403,49 @@ class TransactionRequest extends Request
|
||||
$data['type'] = strtolower($transaction->transactionJournal->transactionType->type);
|
||||
}
|
||||
foreach ($transactions as $index => $transaction) {
|
||||
$sourceId = isset($transaction['source_id']) ? intval($transaction['source_id']) : null;
|
||||
$sourceName = $transaction['source_name'] ?? null;
|
||||
$destinationId = isset($transaction['destination_id']) ? intval($transaction['destination_id']) : null;
|
||||
$destinationName = $transaction['destination_name'] ?? null;
|
||||
|
||||
$sourceId = isset($transaction['source_id']) ? intval($transaction['source_id']) : null;
|
||||
$sourceName = $transaction['source_name'] ?? null;
|
||||
$destinationId = isset($transaction['destination_id']) ? intval($transaction['destination_id']) : null;
|
||||
$destinationName = $transaction['destination_name'] ?? null;
|
||||
$sourceAccount = null;
|
||||
$destinationAccount = null;
|
||||
switch ($data['type']) {
|
||||
case 'withdrawal':
|
||||
$idField = 'transactions.' . $index . '.source_id';
|
||||
$nameField = 'transactions.' . $index . '.source_name';
|
||||
$this->assetAccountExists($validator, $sourceId, $sourceName, $idField, $nameField);
|
||||
|
||||
$idField = 'transactions.' . $index . '.destination_id';
|
||||
$this->opposingAccountExists($validator, AccountType::EXPENSE, $destinationId, $destinationName, $idField);
|
||||
$idField = 'transactions.' . $index . '.source_id';
|
||||
$nameField = 'transactions.' . $index . '.source_name';
|
||||
$sourceAccount = $this->assetAccountExists($validator, $sourceId, $sourceName, $idField, $nameField);
|
||||
$idField = 'transactions.' . $index . '.destination_id';
|
||||
$destinationAccount = $this->opposingAccountExists($validator, AccountType::EXPENSE, $destinationId, $destinationName, $idField);
|
||||
break;
|
||||
case 'deposit':
|
||||
$idField = 'transactions.' . $index . '.source_id';
|
||||
$this->opposingAccountExists($validator, AccountType::REVENUE, $sourceId, $sourceName, $idField);
|
||||
$idField = 'transactions.' . $index . '.source_id';
|
||||
$sourceAccount = $this->opposingAccountExists($validator, AccountType::REVENUE, $sourceId, $sourceName, $idField);
|
||||
|
||||
$idField = 'transactions.' . $index . '.destination_id';
|
||||
$nameField = 'transactions.' . $index . '.destination_name';
|
||||
$this->assetAccountExists($validator, $destinationId, $destinationName, $idField, $nameField);
|
||||
$idField = 'transactions.' . $index . '.destination_id';
|
||||
$nameField = 'transactions.' . $index . '.destination_name';
|
||||
$destinationAccount = $this->assetAccountExists($validator, $destinationId, $destinationName, $idField, $nameField);
|
||||
break;
|
||||
case 'transfer':
|
||||
$idField = 'transactions.' . $index . '.source_id';
|
||||
$nameField = 'transactions.' . $index . '.source_name';
|
||||
$this->assetAccountExists($validator, $sourceId, $sourceName, $idField, $nameField);
|
||||
$idField = 'transactions.' . $index . '.source_id';
|
||||
$nameField = 'transactions.' . $index . '.source_name';
|
||||
$sourceAccount = $this->assetAccountExists($validator, $sourceId, $sourceName, $idField, $nameField);
|
||||
|
||||
$idField = 'transactions.' . $index . '.destination_id';
|
||||
$nameField = 'transactions.' . $index . '.destination_name';
|
||||
$this->assetAccountExists($validator, $destinationId, $destinationName, $idField, $nameField);
|
||||
$idField = 'transactions.' . $index . '.destination_id';
|
||||
$nameField = 'transactions.' . $index . '.destination_name';
|
||||
$destinationAccount = $this->assetAccountExists($validator, $destinationId, $destinationName, $idField, $nameField);
|
||||
break;
|
||||
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:
|
||||
/** @var Transaction $transaction */
|
||||
$transaction = $this->route()->parameter('transaction');
|
||||
if (is_null($transaction)) {
|
||||
if (null === $transaction) {
|
||||
return;
|
||||
}
|
||||
$data['type'] = strtolower($transaction->transactionJournal->transactionType->type);
|
||||
@@ -493,8 +509,6 @@ class TransactionRequest extends Request
|
||||
);
|
||||
// @codeCoverageIgnoreEnd
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* UserRequest.php
|
||||
* Copyright (c) 2018 thegrumpydictator@gmail.com
|
||||
@@ -19,7 +20,6 @@
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Api\V1\Requests;
|
||||
|
||||
|
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* CreateExport.php
|
||||
* Copyright (c) 2017 thegrumpydictator@gmail.com
|
||||
@@ -18,7 +19,6 @@
|
||||
* 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\Console\Commands;
|
||||
|
||||
@@ -60,17 +60,6 @@ class CreateExport extends Command
|
||||
{--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.
|
||||
*
|
||||
* @return mixed
|
||||
@@ -80,7 +69,7 @@ class CreateExport extends Command
|
||||
if (!$this->verifyAccessToken()) {
|
||||
$this->error('Invalid access token.');
|
||||
|
||||
return;
|
||||
return 1;
|
||||
}
|
||||
$this->line('Full export is running...');
|
||||
// make repositories
|
||||
@@ -94,7 +83,7 @@ class CreateExport extends Command
|
||||
$journalRepository = app(JournalRepositoryInterface::class);
|
||||
|
||||
// set user
|
||||
$user = $userRepository->find(intval($this->option('user')));
|
||||
$user = $userRepository->findNull((int)$this->option('user'));
|
||||
$jobRepository->setUser($user);
|
||||
$journalRepository->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(storage_path(sprintf('export/%s', $fileName)));
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* CreateImport.php
|
||||
* Copyright (c) 2017 thegrumpydictator@gmail.com
|
||||
@@ -18,20 +19,17 @@
|
||||
* 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\Console\Commands;
|
||||
|
||||
use Artisan;
|
||||
use FireflyIII\Exceptions\FireflyException;
|
||||
use FireflyIII\Import\Logging\CommandHandler;
|
||||
use FireflyIII\Import\Routine\RoutineInterface;
|
||||
use FireflyIII\Repositories\ImportJob\ImportJobRepositoryInterface;
|
||||
use FireflyIII\Repositories\User\UserRepositoryInterface;
|
||||
use FireflyIII\Services\Internal\File\EncryptService;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\MessageBag;
|
||||
use Log;
|
||||
use Monolog\Formatter\LineFormatter;
|
||||
use Preferences;
|
||||
|
||||
/**
|
||||
@@ -61,76 +59,67 @@ class CreateImport extends Command
|
||||
{--token= : The user\'s access token.}
|
||||
{--start : Starts the job immediately.}';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Run the command.
|
||||
*
|
||||
* @SuppressWarnings(PHPMD.ExcessiveMethodLength) // cannot be helped
|
||||
* @SuppressWarnings(PHPMD.CyclomaticComplexity) // it's five exactly.
|
||||
* @noinspection MultipleReturnStatementsInspection
|
||||
*
|
||||
* @throws FireflyException
|
||||
*/
|
||||
public function handle()
|
||||
public function handle(): int
|
||||
{
|
||||
if (!$this->verifyAccessToken()) {
|
||||
$this->error('Invalid access token.');
|
||||
$this->errorLine('Invalid access token.');
|
||||
|
||||
return;
|
||||
return 1;
|
||||
}
|
||||
/** @var UserRepositoryInterface $userRepository */
|
||||
$userRepository = app(UserRepositoryInterface::class);
|
||||
$file = $this->argument('file');
|
||||
$configuration = $this->argument('configuration');
|
||||
$user = $userRepository->find(intval($this->option('user')));
|
||||
$user = $userRepository->findNull((int)$this->option('user'));
|
||||
$cwd = getcwd();
|
||||
$type = strtolower($this->option('type'));
|
||||
|
||||
if (!$this->validArguments()) {
|
||||
return;
|
||||
$this->errorLine('Invalid arguments.');
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
$configurationData = json_decode(file_get_contents($configuration), true);
|
||||
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->line(sprintf('Using configuration file: %s', $configuration));
|
||||
$this->line(sprintf('Import into user: #%d (%s)', $user->id, $user->email));
|
||||
$this->line(sprintf('Type of import: %s', $type));
|
||||
$this->infoLine(sprintf('Going to create a job to import file: %s', $file));
|
||||
$this->infoLine(sprintf('Using configuration file: %s', $configuration));
|
||||
$this->infoLine(sprintf('Import into user: #%d (%s)', $user->id, $user->email));
|
||||
$this->infoLine(sprintf('Type of import: %s', $type));
|
||||
|
||||
/** @var ImportJobRepositoryInterface $jobRepository */
|
||||
$jobRepository = app(ImportJobRepositoryInterface::class);
|
||||
$jobRepository->setUser($user);
|
||||
$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]);
|
||||
$this->line('Stored import data...');
|
||||
/** @var EncryptService $service */
|
||||
$service = app(EncryptService::class);
|
||||
$service->encrypt($file, $job->key);
|
||||
|
||||
$this->infoLine('Stored import data...');
|
||||
|
||||
$jobRepository->setConfiguration($job, $configurationData);
|
||||
$jobRepository->updateStatus($job, 'configured');
|
||||
$this->line('Stored configuration...');
|
||||
$this->infoLine('Stored configuration...');
|
||||
|
||||
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!');
|
||||
|
||||
// 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:
|
||||
$type = 'csv' === $job->file_type ? 'file' : $job->file_type;
|
||||
@@ -147,9 +136,9 @@ class CreateImport extends Command
|
||||
// give feedback.
|
||||
/** @var MessageBag $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()
|
||||
)
|
||||
@@ -159,45 +148,58 @@ class CreateImport extends Command
|
||||
// clear cache for user:
|
||||
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.
|
||||
*
|
||||
* @noinspection MultipleReturnStatementsInspection
|
||||
* @return bool
|
||||
* @SuppressWarnings(PHPMD.CyclomaticComplexity) // it's five exactly.
|
||||
*/
|
||||
private function validArguments(): bool
|
||||
{
|
||||
/** @var UserRepositoryInterface $userRepository */
|
||||
$userRepository = app(UserRepositoryInterface::class);
|
||||
$file = $this->argument('file');
|
||||
$configuration = $this->argument('configuration');
|
||||
$user = $userRepository->find(intval($this->option('user')));
|
||||
$cwd = getcwd();
|
||||
$validTypes = config('import.options.file.import_formats');
|
||||
$type = strtolower($this->option('type'));
|
||||
if (null === $user) {
|
||||
$this->error(sprintf('There is no user with ID %d.', $this->option('user')));
|
||||
$file = $this->argument('file');
|
||||
$configuration = $this->argument('configuration');
|
||||
$cwd = getcwd();
|
||||
$validTypes = config('import.options.file.import_formats');
|
||||
$type = strtolower($this->option('type'));
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!in_array($type, $validTypes)) {
|
||||
$this->error(sprintf('Cannot import file of type "%s"', $type));
|
||||
if (!\in_array($type, $validTypes, true)) {
|
||||
$this->errorLine(sprintf('Cannot import file of type "%s"', $type));
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* DecryptAttachment.php
|
||||
* Copyright (c) 2017 thegrumpydictator@gmail.com
|
||||
@@ -18,7 +19,6 @@
|
||||
* 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\Console\Commands;
|
||||
|
||||
|
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* EncryptFile.php
|
||||
* Copyright (c) 2017 thegrumpydictator@gmail.com
|
||||
@@ -18,11 +19,11 @@
|
||||
* 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\Console\Commands;
|
||||
|
||||
use Crypt;
|
||||
use FireflyIII\Exceptions\FireflyException;
|
||||
use FireflyIII\Services\Internal\File\EncryptService;
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
/**
|
||||
@@ -44,31 +45,26 @@ class EncryptFile extends Command
|
||||
*/
|
||||
protected $signature = 'firefly:encrypt-file {file} {key}';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @throws \Illuminate\Contracts\Encryption\EncryptException
|
||||
*/
|
||||
public function handle()
|
||||
public function handle(): int
|
||||
{
|
||||
$file = e(strval($this->argument('file')));
|
||||
if (!file_exists($file)) {
|
||||
$this->error(sprintf('File "%s" does not seem to exist.', $file));
|
||||
$code = 0;
|
||||
$file = (string)$this->argument('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;
|
||||
file_put_contents($path, $content);
|
||||
$this->line(sprintf('Encrypted "%s" and put it in "%s"', $file, $path));
|
||||
return $code;
|
||||
}
|
||||
}
|
||||
|
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* Import.php
|
||||
* Copyright (c) 2017 thegrumpydictator@gmail.com
|
||||
@@ -18,12 +19,10 @@
|
||||
* 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\Console\Commands;
|
||||
|
||||
use FireflyIII\Exceptions\FireflyException;
|
||||
use FireflyIII\Import\Logging\CommandHandler;
|
||||
use FireflyIII\Import\Routine\RoutineInterface;
|
||||
use FireflyIII\Models\ImportJob;
|
||||
use Illuminate\Console\Command;
|
||||
@@ -68,21 +67,17 @@ class Import extends Command
|
||||
$jobKey = $this->argument('key');
|
||||
$job = ImportJob::where('key', $jobKey)->first();
|
||||
if (null === $job) {
|
||||
$this->error(sprintf('No job found with key "%s"', $jobKey));
|
||||
$this->errorLine(sprintf('No job found with key "%s"', $jobKey));
|
||||
|
||||
return;
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
||||
$this->line(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);
|
||||
$this->infoLine(sprintf('Going to import job with key "%s" of type "%s"', $job->key, $job->file_type));
|
||||
|
||||
// actually start job:
|
||||
$type = 'csv' === $job->file_type ? 'file' : $job->file_type;
|
||||
@@ -99,16 +94,37 @@ class Import extends Command
|
||||
|
||||
/** @var MessageBag $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())
|
||||
);
|
||||
|
||||
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.
|
||||
*
|
||||
@@ -119,15 +135,14 @@ class Import extends Command
|
||||
private function isValid(ImportJob $job): bool
|
||||
{
|
||||
if (null === $job) {
|
||||
Log::error('This job does not seem to exist.');
|
||||
$this->error('This job does not seem to exist.');
|
||||
$this->errorLine('This job does not seem to exist.');
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if ('configured' !== $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;
|
||||
}
|
||||
|
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* ScanAttachments.php
|
||||
* Copyright (c) 2017 thegrumpydictator@gmail.com
|
||||
@@ -18,7 +19,6 @@
|
||||
* 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\Console\Commands;
|
||||
|
||||
|
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* UpgradeDatabase.php
|
||||
* Copyright (c) 2017 thegrumpydictator@gmail.com
|
||||
@@ -18,7 +19,6 @@
|
||||
* 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\Console\Commands;
|
||||
|
||||
@@ -26,6 +26,7 @@ use DB;
|
||||
use FireflyIII\Models\Account;
|
||||
use FireflyIII\Models\AccountMeta;
|
||||
use FireflyIII\Models\AccountType;
|
||||
use FireflyIII\Models\Attachment;
|
||||
use FireflyIII\Models\Note;
|
||||
use FireflyIII\Models\Transaction;
|
||||
use FireflyIII\Models\TransactionCurrency;
|
||||
@@ -86,6 +87,7 @@ class UpgradeDatabase extends Command
|
||||
$this->updateOtherCurrencies();
|
||||
$this->line('Done updating currency information..');
|
||||
$this->migrateNotes();
|
||||
$this->migrateAttachmentData();
|
||||
$this->info('Firefly III database is up to date.');
|
||||
|
||||
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.
|
||||
*
|
||||
|
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* UpgradeFireflyInstructions.php
|
||||
* Copyright (c) 2017 thegrumpydictator@gmail.com
|
||||
@@ -18,7 +19,6 @@
|
||||
* 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\Console\Commands;
|
||||
|
||||
|
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* UseEncryption.php
|
||||
@@ -19,7 +20,6 @@
|
||||
* 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\Console\Commands;
|
||||
|
||||
|
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* VerifiesAccessToken.php
|
||||
* Copyright (c) 2017 thegrumpydictator@gmail.com
|
||||
@@ -18,7 +19,6 @@
|
||||
* 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\Console\Commands;
|
||||
|
||||
@@ -49,11 +49,11 @@ trait VerifiesAccessToken
|
||||
*/
|
||||
protected function verifyAccessToken(): bool
|
||||
{
|
||||
$userId = intval($this->option('user'));
|
||||
$token = strval($this->option('token'));
|
||||
$userId = (int)$this->option('user');
|
||||
$token = (string)$this->option('token');
|
||||
/** @var UserRepositoryInterface $repository */
|
||||
$repository = app(UserRepositoryInterface::class);
|
||||
$user = $repository->find($userId);
|
||||
$user = $repository->findNull($userId);
|
||||
|
||||
if (null === $user) {
|
||||
Log::error(sprintf('verifyAccessToken(): no such user for input "%d"', $userId));
|
||||
@@ -68,7 +68,7 @@ trait VerifiesAccessToken
|
||||
}
|
||||
if (!($accessToken->data === $token)) {
|
||||
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;
|
||||
}
|
||||
|
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* VerifyDatabase.php
|
||||
* Copyright (c) 2017 thegrumpydictator@gmail.com
|
||||
@@ -18,7 +19,6 @@
|
||||
* 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\Console\Commands;
|
||||
|
||||
|
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* Kernel.php
|
||||
* Copyright (c) 2017 thegrumpydictator@gmail.com
|
||||
@@ -18,7 +19,6 @@
|
||||
* 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\Console;
|
||||
|
||||
|
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* AdminRequestedTestMessage.php
|
||||
* Copyright (c) 2017 thegrumpydictator@gmail.com
|
||||
@@ -18,7 +19,6 @@
|
||||
* 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\Events;
|
||||
|
||||
|
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* Event.php
|
||||
* Copyright (c) 2017 thegrumpydictator@gmail.com
|
||||
@@ -18,7 +19,6 @@
|
||||
* 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\Events;
|
||||
|
||||
|
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* RegisteredUser.php
|
||||
* Copyright (c) 2017 thegrumpydictator@gmail.com
|
||||
@@ -18,7 +19,6 @@
|
||||
* 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\Events;
|
||||
|
||||
|
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* RequestedNewPassword.php
|
||||
* Copyright (c) 2017 thegrumpydictator@gmail.com
|
||||
@@ -18,7 +19,6 @@
|
||||
* 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\Events;
|
||||
|
||||
|
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* RequestedVersionCheckStatus.php
|
||||
* Copyright (c) 2017 thegrumpydictator@gmail.com
|
||||
@@ -19,7 +20,6 @@
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Events;
|
||||
|
||||
|
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* StoredTransactionJournal.php
|
||||
* Copyright (c) 2017 thegrumpydictator@gmail.com
|
||||
@@ -18,7 +19,6 @@
|
||||
* 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\Events;
|
||||
|
||||
@@ -26,6 +26,7 @@ use FireflyIII\Models\TransactionJournal;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
/**
|
||||
* @codeCoverageIgnore
|
||||
* Class StoredTransactionJournal.
|
||||
*/
|
||||
class StoredTransactionJournal extends Event
|
||||
|
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* UpdatedTransactionJournal.php
|
||||
* Copyright (c) 2017 thegrumpydictator@gmail.com
|
||||
@@ -18,7 +19,6 @@
|
||||
* 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\Events;
|
||||
|
||||
@@ -27,6 +27,9 @@ use Illuminate\Queue\SerializesModels;
|
||||
|
||||
/**
|
||||
* Class UpdatedTransactionJournal.
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
*
|
||||
*/
|
||||
class UpdatedTransactionJournal extends Event
|
||||
{
|
||||
|
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* UserChangedEmail.php
|
||||
* Copyright (c) 2017 thegrumpydictator@gmail.com
|
||||
@@ -18,7 +19,6 @@
|
||||
* 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\Events;
|
||||
|
||||
|
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* FireflyException.php
|
||||
* Copyright (c) 2017 thegrumpydictator@gmail.com
|
||||
@@ -18,13 +19,14 @@
|
||||
* 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\Exceptions;
|
||||
|
||||
use Exception;
|
||||
|
||||
/**
|
||||
* Class FireflyException.
|
||||
*/
|
||||
class FireflyException extends \Exception
|
||||
class FireflyException extends Exception
|
||||
{
|
||||
}
|
||||
|
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* Handler.php
|
||||
* Copyright (c) 2017 thegrumpydictator@gmail.com
|
||||
@@ -18,7 +19,6 @@
|
||||
* 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\Exceptions;
|
||||
|
||||
@@ -70,14 +70,15 @@ class Handler extends ExceptionHandler
|
||||
return parent::render($request, $exception);
|
||||
}
|
||||
if ($exception instanceof NotFoundHttpException && $request->expectsJson()) {
|
||||
// JSON error:
|
||||
return response()->json(['message' => 'Resource not found', 'exception' => 'NotFoundHttpException'], 404);
|
||||
}
|
||||
|
||||
if ($exception instanceof AuthenticationException && $request->expectsJson()) {
|
||||
// somehow Laravel handler does not catch this:
|
||||
return response()->json(['message' => 'Unauthenticated', 'exception' => 'AuthenticationException'], 401);
|
||||
}
|
||||
|
||||
|
||||
if ($request->expectsJson()) {
|
||||
$isDebug = config('app.debug', false);
|
||||
if ($isDebug) {
|
||||
|
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* NotImplementedException.php
|
||||
* Copyright (c) 2017 thegrumpydictator@gmail.com
|
||||
@@ -18,7 +19,6 @@
|
||||
* 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\Exceptions;
|
||||
|
||||
|
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* ValidationException.php
|
||||
* Copyright (c) 2017 thegrumpydictator@gmail.com
|
||||
@@ -18,7 +19,6 @@
|
||||
* 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\Exceptions;
|
||||
|
||||
|
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* AttachmentCollector.php
|
||||
* Copyright (c) 2017 thegrumpydictator@gmail.com
|
||||
@@ -18,7 +19,6 @@
|
||||
* 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\Export\Collector;
|
||||
|
||||
|
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* BasicCollector.php
|
||||
* Copyright (c) 2017 thegrumpydictator@gmail.com
|
||||
@@ -18,7 +19,6 @@
|
||||
* 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\Export\Collector;
|
||||
|
||||
|
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* CollectorInterface.php
|
||||
* Copyright (c) 2017 thegrumpydictator@gmail.com
|
||||
@@ -18,7 +19,6 @@
|
||||
* 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\Export\Collector;
|
||||
|
||||
|
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* UploadCollector.php
|
||||
* Copyright (c) 2017 thegrumpydictator@gmail.com
|
||||
@@ -18,13 +19,12 @@
|
||||
* 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\Export\Collector;
|
||||
|
||||
use Crypt;
|
||||
use Exception;
|
||||
use Illuminate\Contracts\Encryption\DecryptException;
|
||||
use Illuminate\Contracts\Filesystem\FileNotFoundException;
|
||||
use Log;
|
||||
use Storage;
|
||||
|
||||
@@ -99,7 +99,7 @@ class UploadCollector extends BasicCollector implements CollectorInterface
|
||||
$content = '';
|
||||
try {
|
||||
$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()));
|
||||
}
|
||||
|
||||
|
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* Entry.php
|
||||
* Copyright (c) 2017 thegrumpydictator@gmail.com
|
||||
@@ -18,7 +19,6 @@
|
||||
* 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\Export\Entry;
|
||||
|
||||
|
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* ExpandedProcessor.php
|
||||
* Copyright (c) 2017 thegrumpydictator@gmail.com
|
||||
@@ -18,7 +19,6 @@
|
||||
* 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\Export;
|
||||
|
||||
@@ -124,7 +124,7 @@ class ExpandedProcessor implements ProcessorInterface
|
||||
$currencyId = $ibans[$accountId]['currency_id'] ?? 0;
|
||||
$opposingCurrencyId = $ibans[$opposingId]['currency_id'] ?? 0;
|
||||
$transaction->notes = $notes[$journalId] ?? '';
|
||||
$transaction->tags = join(',', $tags[$journalId] ?? []);
|
||||
$transaction->tags = implode(',', $tags[$journalId] ?? []);
|
||||
$transaction->account_number = $ibans[$accountId]['accountNumber'] ?? '';
|
||||
$transaction->account_bic = $ibans[$accountId]['BIC'] ?? '';
|
||||
$transaction->account_currency_code = $currencies[$currencyId] ?? '';
|
||||
@@ -331,6 +331,7 @@ class ExpandedProcessor implements ProcessorInterface
|
||||
* @param array $array
|
||||
*
|
||||
* @return array
|
||||
* @throws \Illuminate\Contracts\Encryption\DecryptException
|
||||
*/
|
||||
private function getTags(array $array): array
|
||||
{
|
||||
|
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* BasicExporter.php
|
||||
* Copyright (c) 2017 thegrumpydictator@gmail.com
|
||||
@@ -18,7 +19,6 @@
|
||||
* 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\Export\Exporter;
|
||||
|
||||
|
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* CsvExporter.php
|
||||
* Copyright (c) 2017 thegrumpydictator@gmail.com
|
||||
@@ -18,7 +19,6 @@
|
||||
* 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\Export\Exporter;
|
||||
|
||||
|
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* ExporterInterface.php
|
||||
* Copyright (c) 2017 thegrumpydictator@gmail.com
|
||||
@@ -18,7 +19,6 @@
|
||||
* 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\Export\Exporter;
|
||||
|
||||
|
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* ProcessorInterface.php
|
||||
* Copyright (c) 2017 thegrumpydictator@gmail.com
|
||||
@@ -18,7 +19,6 @@
|
||||
* 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\Export;
|
||||
|
||||
|
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* AccountFactory.php
|
||||
* Copyright (c) 2018 thegrumpydictator@gmail.com
|
||||
@@ -19,7 +20,6 @@
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Factory;
|
||||
|
||||
@@ -43,6 +43,7 @@ class AccountFactory
|
||||
* @param array $data
|
||||
*
|
||||
* @return Account
|
||||
* @throws \FireflyIII\Exceptions\FireflyException
|
||||
*/
|
||||
public function create(array $data): Account
|
||||
{
|
||||
@@ -74,7 +75,7 @@ class AccountFactory
|
||||
}
|
||||
|
||||
$newAccount = Account::create($databaseData);
|
||||
$this->updateMetadata($newAccount, $data);
|
||||
$this->updateMetaData($newAccount, $data);
|
||||
|
||||
if ($this->validIBData($data) && $type->type === AccountType::ASSET) {
|
||||
$this->updateIB($newAccount, $data);
|
||||
@@ -116,6 +117,8 @@ class AccountFactory
|
||||
* @param string $accountType
|
||||
*
|
||||
* @return Account
|
||||
* @throws \FireflyIII\Exceptions\FireflyException
|
||||
* @throws \FireflyIII\Exceptions\FireflyException
|
||||
*/
|
||||
public function findOrCreate(string $accountName, string $accountType): Account
|
||||
{
|
||||
@@ -162,9 +165,14 @@ class AccountFactory
|
||||
if ($accountTypeId > 0) {
|
||||
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;
|
||||
|
||||
}
|
||||
|
||||
|
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* AccountMetaFactory.php
|
||||
* Copyright (c) 2018 thegrumpydictator@gmail.com
|
||||
@@ -19,7 +20,6 @@
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Factory;
|
||||
|
||||
|
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* BillFactory.php
|
||||
* Copyright (c) 2018 thegrumpydictator@gmail.com
|
||||
@@ -19,7 +20,6 @@
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Factory;
|
||||
|
||||
|
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* BudgetFactory.php
|
||||
* Copyright (c) 2018 thegrumpydictator@gmail.com
|
||||
@@ -19,7 +20,6 @@
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Factory;
|
||||
|
||||
|
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* CategoryFactory.php
|
||||
* Copyright (c) 2018 thegrumpydictator@gmail.com
|
||||
@@ -19,7 +20,6 @@
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Factory;
|
||||
|
||||
|
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* PiggyBankEventFactory.php
|
||||
* Copyright (c) 2018 thegrumpydictator@gmail.com
|
||||
@@ -19,7 +20,6 @@
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Factory;
|
||||
|
||||
|
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* PiggyBankFactory.php
|
||||
* Copyright (c) 2018 thegrumpydictator@gmail.com
|
||||
@@ -19,7 +20,6 @@
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Factory;
|
||||
|
||||
|
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* TagFactory.php
|
||||
* Copyright (c) 2018 thegrumpydictator@gmail.com
|
||||
@@ -19,7 +20,6 @@
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Factory;
|
||||
|
||||
|
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* TransactionCurrencyFactory.php
|
||||
* Copyright (c) 2018 thegrumpydictator@gmail.com
|
||||
@@ -19,17 +20,43 @@
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Factory;
|
||||
|
||||
use FireflyIII\Models\TransactionCurrency;
|
||||
use Illuminate\Database\QueryException;
|
||||
use Log;
|
||||
|
||||
/**
|
||||
* 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 null|string $currencyCode
|
||||
|
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* TransactionFactory.php
|
||||
* Copyright (c) 2018 thegrumpydictator@gmail.com
|
||||
@@ -19,13 +20,13 @@
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Factory;
|
||||
|
||||
|
||||
use FireflyIII\Models\Transaction;
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
use FireflyIII\Models\TransactionType;
|
||||
use FireflyIII\Services\Internal\Support\TransactionServiceTrait;
|
||||
use FireflyIII\User;
|
||||
use Illuminate\Support\Collection;
|
||||
@@ -124,6 +125,11 @@ class TransactionFactory
|
||||
}
|
||||
|
||||
// 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']);
|
||||
$this->setBudget($source, $budget);
|
||||
$this->setBudget($dest, $budget);
|
||||
|
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* TransactionJournalFactory.php
|
||||
* Copyright (c) 2018 thegrumpydictator@gmail.com
|
||||
@@ -19,7 +20,6 @@
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Factory;
|
||||
|
||||
@@ -68,6 +68,7 @@ class TransactionJournalFactory
|
||||
);
|
||||
|
||||
// store basic transactions:
|
||||
/** @var TransactionFactory $factory */
|
||||
$factory = app(TransactionFactory::class);
|
||||
$factory->setUser($this->user);
|
||||
|
||||
@@ -91,13 +92,12 @@ class TransactionJournalFactory
|
||||
$this->storeNote($journal, strval($data['notes']));
|
||||
|
||||
// store date meta fields (if present):
|
||||
$this->storeMeta($journal, $data, 'interest_date');
|
||||
$this->storeMeta($journal, $data, 'book_date');
|
||||
$this->storeMeta($journal, $data, 'process_date');
|
||||
$this->storeMeta($journal, $data, 'due_date');
|
||||
$this->storeMeta($journal, $data, 'payment_date');
|
||||
$this->storeMeta($journal, $data, 'invoice_date');
|
||||
$this->storeMeta($journal, $data, 'internal_reference');
|
||||
$fields = ['sepa-cc', 'sepa-ct-op', 'sepa-ct-id', 'sepa-db', 'sepa-country', 'sepa-ep', 'sepa-ci', 'interest_date', 'book_date', 'process_date',
|
||||
'due_date', 'payment_date', 'invoice_date', 'internal_reference','bunq_payment_id'];
|
||||
|
||||
foreach ($fields as $field) {
|
||||
$this->storeMeta($journal, $data, $field);
|
||||
}
|
||||
Log::debug('End of TransactionJournalFactory::create()');
|
||||
|
||||
return $journal;
|
||||
|
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* TransactionJournalMetaFactory.php
|
||||
* Copyright (c) 2018 thegrumpydictator@gmail.com
|
||||
@@ -19,7 +20,6 @@
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Factory;
|
||||
|
||||
@@ -43,7 +43,7 @@ class TransactionJournalMetaFactory
|
||||
$value = $data['data'];
|
||||
/** @var TransactionJournalMeta $entry */
|
||||
$entry = $data['journal']->transactionJournalMeta()->where('name', $data['name'])->first();
|
||||
if (is_null($value) && !is_null($entry)) {
|
||||
if (null === $value && null !== $entry) {
|
||||
try {
|
||||
$entry->delete();
|
||||
} catch (Exception $e) { // @codeCoverageIgnore
|
||||
@@ -56,7 +56,18 @@ class TransactionJournalMetaFactory
|
||||
if ($data['data'] instanceof Carbon) {
|
||||
$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) {
|
||||
$entry = new TransactionJournalMeta();
|
||||
|
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* TransactionTypeFactory.php
|
||||
* Copyright (c) 2018 thegrumpydictator@gmail.com
|
||||
@@ -19,7 +20,6 @@
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Factory;
|
||||
|
||||
|
@@ -45,6 +45,7 @@ class MonthReportGenerator implements ReportGeneratorInterface
|
||||
|
||||
/**
|
||||
* @return string
|
||||
* @throws \Throwable
|
||||
*/
|
||||
public function generate(): string
|
||||
{
|
||||
|
@@ -63,6 +63,7 @@ class MonthReportGenerator extends Support implements ReportGeneratorInterface
|
||||
|
||||
/**
|
||||
* @return string
|
||||
* @throws \Throwable
|
||||
*/
|
||||
public function generate(): string
|
||||
{
|
||||
|
@@ -64,6 +64,7 @@ class MonthReportGenerator extends Support implements ReportGeneratorInterface
|
||||
|
||||
/**
|
||||
* @return string
|
||||
* @throws \Throwable
|
||||
*/
|
||||
public function generate(): string
|
||||
{
|
||||
|
@@ -146,15 +146,12 @@ class Support
|
||||
*/
|
||||
protected function summarizeByAccount(Collection $collection): array
|
||||
{
|
||||
$result = [
|
||||
'sum' => '0',
|
||||
];
|
||||
$result = [];
|
||||
/** @var Transaction $transaction */
|
||||
foreach ($collection as $transaction) {
|
||||
$accountId = $transaction->account_id;
|
||||
$result[$accountId] = $result[$accountId] ?? '0';
|
||||
$result[$accountId] = bcadd($transaction->transaction_amount, $result[$accountId]);
|
||||
$result['sum'] = bcadd($result['sum'], $transaction->transaction_amount);
|
||||
}
|
||||
|
||||
return $result;
|
||||
|
@@ -24,6 +24,7 @@ namespace FireflyIII\Handlers\Events;
|
||||
|
||||
use FireflyIII\Events\AdminRequestedTestMessage;
|
||||
use FireflyIII\Mail\AdminTestMail;
|
||||
use FireflyIII\Repositories\User\UserRepositoryInterface;
|
||||
use Log;
|
||||
use Mail;
|
||||
use Session;
|
||||
@@ -43,6 +44,15 @@ class AdminEventHandler
|
||||
*/
|
||||
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;
|
||||
$ipAddress = $event->ipAddress;
|
||||
|
||||
|
@@ -30,7 +30,6 @@ use FireflyIII\Repositories\PiggyBank\PiggyBankRepositoryInterface as PRI;
|
||||
use FireflyIII\Repositories\RuleGroup\RuleGroupRepositoryInterface as RGRI;
|
||||
use FireflyIII\Support\Events\BillScanner;
|
||||
use FireflyIII\TransactionRules\Processor;
|
||||
use Log;
|
||||
|
||||
/**
|
||||
* @codeCoverageIgnore
|
||||
@@ -67,6 +66,7 @@ class StoredJournalEventHandler
|
||||
* @param StoredTransactionJournal $storedJournalEvent
|
||||
*
|
||||
* @return bool
|
||||
* @throws \FireflyIII\Exceptions\FireflyException
|
||||
*/
|
||||
public function processRules(StoredTransactionJournal $storedJournalEvent): bool
|
||||
{
|
||||
|
@@ -51,11 +51,11 @@ class UpdatedJournalEventHandler
|
||||
|
||||
/**
|
||||
* This method will check all the rules when a journal is updated.
|
||||
* TODO move to factory.
|
||||
*
|
||||
* @param UpdatedTransactionJournal $updatedJournalEvent
|
||||
*
|
||||
* @return bool
|
||||
* @throws \FireflyIII\Exceptions\FireflyException
|
||||
*/
|
||||
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.
|
||||
* TODO move to factory.
|
||||
*
|
||||
* @param UpdatedTransactionJournal $updatedJournalEvent
|
||||
*
|
||||
|
@@ -26,6 +26,7 @@ namespace FireflyIII\Handlers\Events;
|
||||
use FireflyConfig;
|
||||
use FireflyIII\Events\RequestedVersionCheckStatus;
|
||||
use FireflyIII\Exceptions\FireflyException;
|
||||
use FireflyIII\Repositories\User\UserRepositoryInterface;
|
||||
use FireflyIII\Services\Github\Object\Release;
|
||||
use FireflyIII\Services\Github\Request\UpdateRequest;
|
||||
use FireflyIII\User;
|
||||
@@ -43,22 +44,26 @@ class VersionCheckEventHandler
|
||||
public function checkForUpdates(RequestedVersionCheckStatus $event)
|
||||
{
|
||||
// in Sandstorm, cannot check for updates:
|
||||
$sandstorm = 1 === intval(getenv('SANDSTORM'));
|
||||
$sandstorm = 1 === (int)getenv('SANDSTORM');
|
||||
if ($sandstorm === true) {
|
||||
return;
|
||||
return; // @codeCoverageIgnore
|
||||
}
|
||||
|
||||
/** @var UserRepositoryInterface $repository */
|
||||
$repository = app(UserRepositoryInterface::class);
|
||||
|
||||
/** @var User $user */
|
||||
$user = $event->user;
|
||||
if (!$user->hasRole('owner')) {
|
||||
if (!$repository->hasRole($user, 'owner')) {
|
||||
return;
|
||||
}
|
||||
|
||||
$permission = FireflyConfig::get('permission_update_check', -1);
|
||||
$lastCheckTime = FireflyConfig::get('last_update_check', 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)));
|
||||
|
||||
return;
|
||||
@@ -70,7 +75,7 @@ class VersionCheckEventHandler
|
||||
// have actual permission?
|
||||
if ($permission->data === -1) {
|
||||
// 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;
|
||||
}
|
||||
@@ -79,7 +84,7 @@ class VersionCheckEventHandler
|
||||
/** @var UpdateRequest $request */
|
||||
$request = app(UpdateRequest::class);
|
||||
$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 {
|
||||
$request->call();
|
||||
$releases = $request->getReleases();
|
||||
@@ -87,6 +92,7 @@ class VersionCheckEventHandler
|
||||
/** @var Release $first */
|
||||
$first = reset($releases);
|
||||
$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());
|
||||
} catch (FireflyException $e) {
|
||||
Log::error(sprintf('Could not check for updates: %s', $e->getMessage()));
|
||||
@@ -98,19 +104,19 @@ class VersionCheckEventHandler
|
||||
if ($check === -1) {
|
||||
// there is a new FF version!
|
||||
$monthAndDayFormat = (string)trans('config.month_and_day');
|
||||
$string = strval(
|
||||
trans(
|
||||
'firefly.update_new_version_alert',
|
||||
['your_version' => $current, 'new_version' => $first->getTitle(), 'date' => $first->getUpdated()->formatLocalized($monthAndDayFormat)]
|
||||
)
|
||||
$string = (string)trans(
|
||||
'firefly.update_new_version_alert',
|
||||
[
|
||||
'your_version' => $current,
|
||||
'new_version' => $first->getTitle(),
|
||||
'date' => $first->getUpdated()->formatLocalized($monthAndDayFormat),
|
||||
]
|
||||
);
|
||||
}
|
||||
if ($check !== 0) {
|
||||
// flash info
|
||||
session()->flash('info', $string);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -155,6 +155,7 @@ class AttachmentHelper implements AttachmentHelperInterface
|
||||
* @param Model $model
|
||||
*
|
||||
* @return Attachment
|
||||
* @throws \Illuminate\Contracts\Encryption\EncryptException
|
||||
*/
|
||||
protected function processFile(UploadedFile $file, Model $model): Attachment
|
||||
{
|
||||
@@ -206,7 +207,7 @@ class AttachmentHelper implements AttachmentHelperInterface
|
||||
Log::debug('Now in validMime()');
|
||||
$mime = e($file->getMimeType());
|
||||
$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);
|
||||
|
||||
if (!in_array($mime, $this->allowedMimes)) {
|
||||
|
@@ -282,6 +282,7 @@ class MetaPieChart implements MetaPieChartInterface
|
||||
$collector->withCategoryInformation();
|
||||
$collector->withBudgetInformation();
|
||||
}
|
||||
|
||||
// @codeCoverageIgnoreEnd
|
||||
|
||||
return $collector->getJournals();
|
||||
|
@@ -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 */
|
||||
protected $balanceEntries;
|
||||
|
@@ -25,11 +25,13 @@ namespace FireflyIII\Helpers\Collector;
|
||||
use Carbon\Carbon;
|
||||
use DB;
|
||||
use FireflyIII\Exceptions\FireflyException;
|
||||
use FireflyIII\Helpers\Filter\CountAttachmentsFilter;
|
||||
use FireflyIII\Helpers\Filter\FilterInterface;
|
||||
use FireflyIII\Helpers\Filter\InternalTransferFilter;
|
||||
use FireflyIII\Helpers\Filter\NegativeAmountFilter;
|
||||
use FireflyIII\Helpers\Filter\OpposingAccountFilter;
|
||||
use FireflyIII\Helpers\Filter\PositiveAmountFilter;
|
||||
use FireflyIII\Helpers\Filter\SplitIndicatorFilter;
|
||||
use FireflyIII\Helpers\Filter\TransferFilter;
|
||||
use FireflyIII\Models\AccountType;
|
||||
use FireflyIII\Models\Budget;
|
||||
@@ -760,6 +762,8 @@ class JournalCollector implements JournalCollectorInterface
|
||||
TransferFilter::class => new TransferFilter,
|
||||
PositiveAmountFilter::class => new PositiveAmountFilter,
|
||||
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)));
|
||||
foreach ($this->filters as $enabled) {
|
||||
@@ -830,6 +834,7 @@ class JournalCollector implements JournalCollectorInterface
|
||||
|
||||
/**
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
*/
|
||||
private function joinOpposingTables()
|
||||
{
|
||||
|
@@ -42,13 +42,6 @@ interface JournalCollectorInterface
|
||||
*/
|
||||
public function addFilter(string $filter): JournalCollectorInterface;
|
||||
|
||||
/**
|
||||
* @param Collection $journals
|
||||
*
|
||||
* @return JournalCollectorInterface
|
||||
*/
|
||||
public function setJournals(Collection $journals): JournalCollectorInterface;
|
||||
|
||||
/**
|
||||
* @param string $amount
|
||||
*
|
||||
@@ -153,6 +146,13 @@ interface JournalCollectorInterface
|
||||
*/
|
||||
public function setCategory(Category $category): JournalCollectorInterface;
|
||||
|
||||
/**
|
||||
* @param Collection $journals
|
||||
*
|
||||
* @return JournalCollectorInterface
|
||||
*/
|
||||
public function setJournals(Collection $journals): JournalCollectorInterface;
|
||||
|
||||
/**
|
||||
* @param int $limit
|
||||
*
|
||||
|
67
app/Helpers/Filter/CountAttachmentsFilter.php
Normal file
67
app/Helpers/Filter/CountAttachmentsFilter.php
Normal 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;
|
||||
}
|
||||
}
|
67
app/Helpers/Filter/SplitIndicatorFilter.php
Normal file
67
app/Helpers/Filter/SplitIndicatorFilter.php
Normal 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;
|
||||
}
|
||||
}
|
@@ -37,7 +37,7 @@ class Help implements HelpInterface
|
||||
/**
|
||||
*
|
||||
*/
|
||||
const CACHEKEY = 'help_%s_%s';
|
||||
public const CACHEKEY = 'help_%s_%s';
|
||||
/** @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';
|
||||
|
||||
|
@@ -57,11 +57,8 @@ class PopupReport implements PopupReportInterface
|
||||
return $journals->filter(
|
||||
function (Transaction $transaction) {
|
||||
$tags = $transaction->transactionJournal->tags()->where('tagMode', 'balancingAct')->count();
|
||||
if (0 === $tags) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
return 0 === $tags;
|
||||
}
|
||||
);
|
||||
}
|
||||
|
@@ -119,6 +119,7 @@ class ReportHelper implements ReportHelperInterface
|
||||
* @param Carbon $date
|
||||
*
|
||||
* @return array
|
||||
* @throws \InvalidArgumentException
|
||||
*/
|
||||
public function listOfMonths(Carbon $date): array
|
||||
{
|
||||
|
@@ -24,7 +24,6 @@ namespace FireflyIII\Http\Controllers\Account;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use FireflyIII\Exceptions\FireflyException;
|
||||
use FireflyIII\Factory\TransactionJournalFactory;
|
||||
use FireflyIII\Helpers\Collector\JournalCollectorInterface;
|
||||
use FireflyIII\Http\Controllers\Controller;
|
||||
use FireflyIII\Http\Requests\ReconciliationStoreRequest;
|
||||
@@ -37,12 +36,11 @@ use FireflyIII\Models\TransactionType;
|
||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||
use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;
|
||||
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
|
||||
use FireflyIII\Services\Internal\Update\TransactionUpdateService;
|
||||
use FireflyIII\Services\Internal\Update\CurrencyUpdateService;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Collection;
|
||||
use Log;
|
||||
use Preferences;
|
||||
use Response;
|
||||
use Session;
|
||||
|
||||
/**
|
||||
@@ -52,6 +50,10 @@ use Session;
|
||||
*/
|
||||
class ReconcileController extends Controller
|
||||
{
|
||||
/** @var CurrencyUpdateService */
|
||||
private $accountRepos;
|
||||
/** @var AccountRepositoryInterface */
|
||||
private $currencyRepos;
|
||||
/** @var JournalRepositoryInterface */
|
||||
private $repository;
|
||||
|
||||
@@ -67,7 +69,9 @@ class ReconcileController extends Controller
|
||||
function ($request, $next) {
|
||||
app('view')->share('mainTitleIcon', 'fa-credit-card');
|
||||
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);
|
||||
}
|
||||
@@ -92,7 +96,7 @@ class ReconcileController extends Controller
|
||||
$preFilled = [
|
||||
'date' => $this->repository->getJournalDate($journal, null),
|
||||
'category' => $this->repository->getJournalCategoryName($journal),
|
||||
'tags' => join(',', $journal->tags->pluck('tag')->toArray()),
|
||||
'tags' => implode(',', $journal->tags->pluck('tag')->toArray()),
|
||||
'amount' => $pTransaction->amount,
|
||||
];
|
||||
|
||||
@@ -163,7 +167,7 @@ class ReconcileController extends Controller
|
||||
)->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)]));
|
||||
}
|
||||
/** @var CurrencyRepositoryInterface $currencyRepos */
|
||||
$currencyRepos = app(CurrencyRepositoryInterface::class);
|
||||
$currencyId = intval($account->getMeta('currency_id'));
|
||||
$currency = $currencyRepos->findNull($currencyId);
|
||||
$currencyId = intval($this->accountRepos->getMetaValue($account, 'currency_id'));
|
||||
$currency = $this->currencyRepos->findNull($currencyId);
|
||||
if (0 === $currencyId) {
|
||||
$currency = app('amount')->getDefaultCurrency(); // @codeCoverageIgnore
|
||||
}
|
||||
@@ -247,12 +249,12 @@ class ReconcileController extends Controller
|
||||
|
||||
/**
|
||||
* @param ReconciliationStoreRequest $request
|
||||
* @param JournalRepositoryInterface $repository
|
||||
* @param Account $account
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
*
|
||||
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
|
||||
* @throws FireflyException
|
||||
*/
|
||||
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):
|
||||
if ('create' === $data['reconcile']) {
|
||||
// get "opposing" account.
|
||||
/** @var AccountRepositoryInterface $accountRepos */
|
||||
$accountRepos = app(AccountRepositoryInterface::class);
|
||||
$reconciliation = $accountRepos->getReconciliation($account);
|
||||
$reconciliation = $this->accountRepos->getReconciliation($account);
|
||||
|
||||
|
||||
$difference = $data['difference'];
|
||||
@@ -300,7 +300,7 @@ class ReconcileController extends Controller
|
||||
'tags' => null,
|
||||
'interest_date' => null,
|
||||
'transactions' => [[
|
||||
'currency_id' => intval($account->getMeta('currency_id')),
|
||||
'currency_id' => intval($this->accountRepos->getMetaValue($account, 'currency_id')),
|
||||
'currency_code' => null,
|
||||
'description' => null,
|
||||
'amount' => app('steam')->positive($difference),
|
||||
@@ -319,7 +319,7 @@ class ReconcileController extends Controller
|
||||
'category_name' => null,
|
||||
],
|
||||
],
|
||||
'notes' => join(', ', $data['transactions']),
|
||||
'notes' => implode(', ', $data['transactions']),
|
||||
];
|
||||
|
||||
$journal = $repository->store($journalData);
|
||||
@@ -350,10 +350,8 @@ class ReconcileController extends Controller
|
||||
$startDate = clone $start;
|
||||
$startDate->subDays(1);
|
||||
|
||||
/** @var CurrencyRepositoryInterface $currencyRepos */
|
||||
$currencyRepos = app(CurrencyRepositoryInterface::class);
|
||||
$currencyId = intval($account->getMeta('currency_id'));
|
||||
$currency = $currencyRepos->findNull($currencyId);
|
||||
$currencyId = intval($this->accountRepos->getMetaValue($account, 'currency_id'));
|
||||
$currency = $this->currencyRepos->findNull($currencyId);
|
||||
if (0 === $currencyId) {
|
||||
$currency = app('amount')->getDefaultCurrency(); // @codeCoverageIgnore
|
||||
}
|
||||
@@ -375,7 +373,7 @@ class ReconcileController extends Controller
|
||||
$transactions = $collector->getJournals();
|
||||
$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]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -84,6 +84,7 @@ class AccountController extends Controller
|
||||
* @param string $what
|
||||
*
|
||||
* @return View
|
||||
* @throws \RuntimeException
|
||||
*/
|
||||
public function create(Request $request, string $what = 'asset')
|
||||
{
|
||||
@@ -94,7 +95,7 @@ class AccountController extends Controller
|
||||
$subTitle = trans('firefly.make_new_' . $what . '_account');
|
||||
$roles = [];
|
||||
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
|
||||
@@ -128,11 +129,11 @@ class AccountController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @param AccountRepositoryInterface $repository
|
||||
* @param Account $account
|
||||
* @param Request $request
|
||||
* @param Account $account
|
||||
*
|
||||
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
|
||||
* @throws \RuntimeException
|
||||
*/
|
||||
public function destroy(Request $request, Account $account)
|
||||
{
|
||||
@@ -152,15 +153,17 @@ class AccountController extends Controller
|
||||
/**
|
||||
* Edit an account.
|
||||
*
|
||||
* @param Request $request
|
||||
* @param Account $account
|
||||
* @param Request $request
|
||||
* @param Account $account
|
||||
*
|
||||
* @param AccountRepositoryInterface $repository
|
||||
*
|
||||
* @return View
|
||||
*
|
||||
* @SuppressWarnings(PHPMD.CyclomaticComplexity) // long and complex but not that excessively so.
|
||||
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
|
||||
*
|
||||
* @return View
|
||||
*
|
||||
* @throws FireflyException
|
||||
* @throws \RuntimeException
|
||||
*/
|
||||
public function edit(Request $request, Account $account, AccountRepositoryInterface $repository)
|
||||
{
|
||||
@@ -185,14 +188,18 @@ class AccountController extends Controller
|
||||
// the opening balance is tricky:
|
||||
$openingBalanceAmount = strval($repository->getOpeningBalanceAmount($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 = [
|
||||
'accountNumber' => $account->getMeta('accountNumber'),
|
||||
'accountRole' => $account->getMeta('accountRole'),
|
||||
'ccType' => $account->getMeta('ccType'),
|
||||
'ccMonthlyPaymentDate' => $account->getMeta('ccMonthlyPaymentDate'),
|
||||
'BIC' => $account->getMeta('BIC'),
|
||||
'accountNumber' => $repository->getMetaValue($account, 'accountNumber'),
|
||||
'accountRole' => $repository->getMetaValue($account, 'accountRole'),
|
||||
'ccType' => $repository->getMetaValue($account, 'ccType'),
|
||||
'ccMonthlyPaymentDate' => $repository->getMetaValue($account, 'ccMonthlyPaymentDate'),
|
||||
'BIC' => $repository->getMetaValue($account, 'BIC'),
|
||||
'openingBalanceDate' => $openingBalanceDate,
|
||||
'openingBalance' => $openingBalanceAmount,
|
||||
'virtualBalance' => $account->virtual_balance,
|
||||
@@ -273,37 +280,36 @@ class AccountController extends Controller
|
||||
/**
|
||||
* Show an account.
|
||||
*
|
||||
* @param Request $request
|
||||
* @param Account $account
|
||||
* @param string $moment
|
||||
* @param Request $request
|
||||
* @param Account $account
|
||||
* @param Carbon|null $start
|
||||
* @param Carbon|null $end
|
||||
*
|
||||
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector|View
|
||||
*
|
||||
* @SuppressWarnings(PHPMD.CyclomaticComplexity) // long and complex but not that excessively so.
|
||||
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
|
||||
*
|
||||
* @throws FireflyException
|
||||
*
|
||||
*/
|
||||
public function show(Request $request, Account $account, Carbon $start = null, Carbon $end = null)
|
||||
{
|
||||
if (AccountType::INITIAL_BALANCE === $account->accountType->type) {
|
||||
return $this->redirectToOriginalAccount($account);
|
||||
}
|
||||
$range = Preferences::get('viewRange', '1M')->data;
|
||||
if (null === $start) {
|
||||
$start = session('start');
|
||||
}
|
||||
if (null === $end) {
|
||||
$end = app('navigation')->endOfPeriod($start, $range);
|
||||
$end = session('end');
|
||||
}
|
||||
if ($end < $start) {
|
||||
throw new FireflyException('End is after start!'); // @codeCoverageIgnore
|
||||
}
|
||||
|
||||
$today = new Carbon;
|
||||
$subTitleIcon = config('firefly.subIconsByIdentifier.' . $account->accountType->type);
|
||||
$page = intval($request->get('page'));
|
||||
$pageSize = intval(Preferences::get('listPageSize', 50)->data);
|
||||
$currencyId = intval($account->getMeta('currency_id'));
|
||||
$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
|
||||
@@ -315,15 +321,56 @@ class AccountController extends Controller
|
||||
$periods = $this->getPeriodOverview($account, $end);
|
||||
$collector = app(JournalCollectorInterface::class);
|
||||
$collector->setAccounts(new Collection([$account]))->setLimit($pageSize)->setPage($page);
|
||||
if (null !== $start) {
|
||||
$collector->setRange($start, $end);
|
||||
}
|
||||
$collector->setRange($start, $end);
|
||||
$transactions = $collector->getPaginatedJournals();
|
||||
$transactions->setPath(route('accounts.show', [$account->id, $start->format('Y-m-d'), $end->format('Y-m-d')]));
|
||||
$showAll = false;
|
||||
|
||||
return view(
|
||||
'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
|
||||
*
|
||||
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
|
||||
* @throws \RuntimeException
|
||||
*/
|
||||
public function store(AccountFormRequest $request)
|
||||
{
|
||||
$data = $request->getAccountData();
|
||||
$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();
|
||||
|
||||
// update preferences if necessary:
|
||||
@@ -360,11 +408,11 @@ class AccountController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* @param AccountFormRequest $request
|
||||
* @param AccountRepositoryInterface $repository
|
||||
* @param Account $account
|
||||
* @param AccountFormRequest $request
|
||||
* @param Account $account
|
||||
*
|
||||
* @return $this|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
|
||||
* @throws \RuntimeException
|
||||
*/
|
||||
public function update(AccountFormRequest $request, Account $account)
|
||||
{
|
||||
@@ -405,7 +453,9 @@ class AccountController extends Controller
|
||||
* and for each period, the amount of money spent and earned. This is a complex operation which is cached for
|
||||
* performance reasons.
|
||||
*
|
||||
* @param Account $account the account involved
|
||||
* @param Account $account the account involved
|
||||
*
|
||||
* @param Carbon|null $date
|
||||
*
|
||||
* @return Collection
|
||||
*
|
||||
@@ -429,33 +479,34 @@ class AccountController extends Controller
|
||||
if ($cache->has()) {
|
||||
return $cache->get(); // @codeCoverageIgnore
|
||||
}
|
||||
/** @var array $dates */
|
||||
$dates = app('navigation')->blockPeriods($start, $end, $range);
|
||||
$entries = new Collection;
|
||||
// loop dates
|
||||
foreach ($dates as $date) {
|
||||
foreach ($dates as $currentDate) {
|
||||
|
||||
// try a collector for income:
|
||||
/** @var JournalCollectorInterface $collector */
|
||||
$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();
|
||||
$earned = strval($collector->getJournals()->sum('transaction_amount'));
|
||||
$earned = (string)$collector->getJournals()->sum('transaction_amount');
|
||||
|
||||
// try a collector for expenses:
|
||||
/** @var JournalCollectorInterface $collector */
|
||||
$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();
|
||||
$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(
|
||||
[
|
||||
'name' => $dateName,
|
||||
'spent' => $spent,
|
||||
'earned' => $earned,
|
||||
'start' => $date['start']->format('Y-m-d'),
|
||||
'end' => $date['end']->format('Y-m-d'),
|
||||
'start' => $currentDate['start']->format('Y-m-d'),
|
||||
'end' => $currentDate['end']->format('Y-m-d'),
|
||||
]
|
||||
);
|
||||
}
|
||||
|
@@ -76,6 +76,7 @@ class LinkController extends Controller
|
||||
* @param LinkType $linkType
|
||||
*
|
||||
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector|View
|
||||
* @throws \RuntimeException
|
||||
*/
|
||||
public function delete(Request $request, LinkTypeRepositoryInterface $repository, LinkType $linkType)
|
||||
{
|
||||
@@ -108,6 +109,7 @@ class LinkController extends Controller
|
||||
* @param LinkType $linkType
|
||||
*
|
||||
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
|
||||
* @throws \RuntimeException
|
||||
*/
|
||||
public function destroy(Request $request, LinkTypeRepositoryInterface $repository, LinkType $linkType)
|
||||
{
|
||||
@@ -126,6 +128,7 @@ class LinkController extends Controller
|
||||
* @param LinkType $linkType
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\Factory|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector|\Illuminate\View\View
|
||||
* @throws \RuntimeException
|
||||
*/
|
||||
public function edit(Request $request, LinkType $linkType)
|
||||
{
|
||||
@@ -184,6 +187,7 @@ class LinkController extends Controller
|
||||
* @param LinkTypeRepositoryInterface $repository
|
||||
*
|
||||
* @return $this|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
|
||||
* @throws \RuntimeException
|
||||
*/
|
||||
public function store(LinkTypeFormRequest $request, LinkTypeRepositoryInterface $repository)
|
||||
{
|
||||
@@ -212,6 +216,7 @@ class LinkController extends Controller
|
||||
* @param LinkType $linkType
|
||||
*
|
||||
* @return $this|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
|
||||
* @throws \RuntimeException
|
||||
*/
|
||||
public function update(LinkTypeFormRequest $request, LinkTypeRepositoryInterface $repository, LinkType $linkType)
|
||||
{
|
||||
|
@@ -22,6 +22,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Http\Controllers\Admin;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use FireflyConfig;
|
||||
use FireflyIII\Exceptions\FireflyException;
|
||||
use FireflyIII\Http\Controllers\Controller;
|
||||
@@ -31,7 +32,6 @@ use FireflyIII\Services\Github\Object\Release;
|
||||
use FireflyIII\Services\Github\Request\UpdateRequest;
|
||||
use Illuminate\Http\Request;
|
||||
use Log;
|
||||
use Response;
|
||||
use Session;
|
||||
|
||||
/**
|
||||
@@ -61,6 +61,8 @@ class UpdateController extends Controller
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
||||
* @throws \Psr\Container\NotFoundExceptionInterface
|
||||
* @throws \Psr\Container\ContainerExceptionInterface
|
||||
* @throws \Illuminate\Container\EntryNotFoundException
|
||||
*/
|
||||
public function index()
|
||||
@@ -121,12 +123,20 @@ class UpdateController extends Controller
|
||||
|
||||
if ($check === -1) {
|
||||
// there is a new FF version!
|
||||
$string = strval(
|
||||
trans(
|
||||
'firefly.update_new_version_alert',
|
||||
['your_version' => $current, 'new_version' => $first->getTitle(), 'date' => $first->getUpdated()->formatLocalized($this->monthAndDayFormat)]
|
||||
)
|
||||
);
|
||||
// has it been released for more than three days?
|
||||
$today = new Carbon;
|
||||
if ($today->diffInDays($first->getUpdated(), true) > 3) {
|
||||
$string = strval(
|
||||
trans(
|
||||
'firefly.update_new_version_alert',
|
||||
[
|
||||
'your_version' => $current,
|
||||
'new_version' => $first->getTitle(),
|
||||
'date' => $first->getUpdated()->formatLocalized($this->monthAndDayFormat),
|
||||
]
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
if ($check === 0) {
|
||||
// you are running the current version!
|
||||
@@ -137,6 +147,6 @@ class UpdateController extends Controller
|
||||
$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]);
|
||||
}
|
||||
}
|
||||
|
@@ -29,7 +29,6 @@ use FireflyIII\Repositories\Attachment\AttachmentRepositoryInterface;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Response as LaravelResponse;
|
||||
use Preferences;
|
||||
use Response;
|
||||
use View;
|
||||
|
||||
/**
|
||||
@@ -81,6 +80,7 @@ class AttachmentController extends Controller
|
||||
* @param Attachment $attachment
|
||||
*
|
||||
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
|
||||
* @throws \RuntimeException
|
||||
*/
|
||||
public function destroy(Request $request, Attachment $attachment)
|
||||
{
|
||||
@@ -130,6 +130,7 @@ class AttachmentController extends Controller
|
||||
* @param Attachment $attachment
|
||||
*
|
||||
* @return View
|
||||
* @throws \RuntimeException
|
||||
*/
|
||||
public function edit(Request $request, Attachment $attachment)
|
||||
{
|
||||
@@ -142,6 +143,9 @@ class AttachmentController extends Controller
|
||||
}
|
||||
$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'));
|
||||
}
|
||||
|
||||
@@ -150,6 +154,7 @@ class AttachmentController extends Controller
|
||||
* @param Attachment $attachment
|
||||
*
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
* @throws \RuntimeException
|
||||
*/
|
||||
public function update(AttachmentFormRequest $request, Attachment $attachment)
|
||||
{
|
||||
@@ -182,7 +187,7 @@ class AttachmentController extends Controller
|
||||
if ($this->repository->exists($attachment)) {
|
||||
$content = $this->repository->getContent($attachment);
|
||||
|
||||
return Response::make(
|
||||
return response()->make(
|
||||
$content, 200, [
|
||||
'Content-Type' => $attachment->mime,
|
||||
'Content-Disposition' => 'inline; filename="' . $attachment->filename . '"',
|
||||
|
@@ -22,14 +22,13 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Http\Controllers\Auth;
|
||||
|
||||
use DB;
|
||||
use FireflyConfig;
|
||||
use FireflyIII\Http\Controllers\Controller;
|
||||
use FireflyIII\Models\TransactionCurrency;
|
||||
use FireflyIII\User;
|
||||
use Illuminate\Cookie\CookieJar;
|
||||
use Illuminate\Foundation\Auth\AuthenticatesUsers;
|
||||
use Illuminate\Http\Request;
|
||||
use Schema;
|
||||
|
||||
/**
|
||||
* @codeCoverageIgnore
|
||||
@@ -66,6 +65,7 @@ class LoginController extends Controller
|
||||
*
|
||||
* @return \Illuminate\Http\Response|\Symfony\Component\HttpFoundation\Response
|
||||
*
|
||||
* @throws \RuntimeException
|
||||
* @throws \Illuminate\Validation\ValidationException
|
||||
*/
|
||||
public function login(Request $request)
|
||||
@@ -103,6 +103,7 @@ class LoginController extends Controller
|
||||
* @param CookieJar $cookieJar
|
||||
*
|
||||
* @return $this|\Illuminate\Http\RedirectResponse
|
||||
* @throws \RuntimeException
|
||||
*/
|
||||
public function logout(Request $request, CookieJar $cookieJar)
|
||||
{
|
||||
@@ -120,26 +121,13 @@ class LoginController extends Controller
|
||||
* @param Request $request
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
||||
* @throws \RuntimeException
|
||||
*/
|
||||
public function showLoginForm(Request $request)
|
||||
{
|
||||
// check for presence of tables:
|
||||
$hasTable = Schema::hasTable('users');
|
||||
|
||||
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'));
|
||||
$count = DB::table('users')->count();
|
||||
if ($count === 0) {
|
||||
return redirect(route('register')); // @codeCoverageIgnore
|
||||
}
|
||||
|
||||
// forget 2fa session thing.
|
||||
|
@@ -40,6 +40,7 @@ class TwoFactorController extends Controller
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\Factory|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector|\Illuminate\View\View
|
||||
*
|
||||
* @throws \RuntimeException
|
||||
* @throws FireflyException
|
||||
*
|
||||
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
|
||||
@@ -91,6 +92,7 @@ class TwoFactorController extends Controller
|
||||
*
|
||||
* @return mixed
|
||||
* @SuppressWarnings(PHPMD.UnusedFormalParameter) // it's unused but the class does some validation.
|
||||
* @throws \RuntimeException
|
||||
*/
|
||||
public function postIndex(TokenFormRequest $request, CookieJar $cookieJar)
|
||||
{
|
||||
|
@@ -22,7 +22,6 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Http\Controllers;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use FireflyIII\Helpers\Attachments\AttachmentHelperInterface;
|
||||
use FireflyIII\Helpers\Collector\JournalCollectorInterface;
|
||||
use FireflyIII\Http\Requests\BillFormRequest;
|
||||
@@ -76,6 +75,7 @@ class BillController extends Controller
|
||||
* @param Request $request
|
||||
*
|
||||
* @return View
|
||||
* @throws \RuntimeException
|
||||
*/
|
||||
public function create(Request $request)
|
||||
{
|
||||
@@ -114,6 +114,7 @@ class BillController extends Controller
|
||||
* @param Bill $bill
|
||||
*
|
||||
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
|
||||
* @throws \RuntimeException
|
||||
*/
|
||||
public function destroy(Request $request, BillRepositoryInterface $repository, Bill $bill)
|
||||
{
|
||||
@@ -131,6 +132,7 @@ class BillController extends Controller
|
||||
* @param Bill $bill
|
||||
*
|
||||
* @return View
|
||||
* @throws \RuntimeException
|
||||
*/
|
||||
public function edit(Request $request, Bill $bill)
|
||||
{
|
||||
@@ -199,6 +201,7 @@ class BillController extends Controller
|
||||
* @param Bill $bill
|
||||
*
|
||||
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
|
||||
* @throws \RuntimeException
|
||||
*/
|
||||
public function rescan(Request $request, BillRepositoryInterface $repository, Bill $bill)
|
||||
{
|
||||
@@ -265,6 +268,7 @@ class BillController extends Controller
|
||||
* @param BillRepositoryInterface $repository
|
||||
*
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
* @throws \RuntimeException
|
||||
*/
|
||||
public function store(BillFormRequest $request, BillRepositoryInterface $repository)
|
||||
{
|
||||
@@ -300,6 +304,7 @@ class BillController extends Controller
|
||||
* @param Bill $bill
|
||||
*
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
* @throws \RuntimeException
|
||||
*/
|
||||
public function update(BillFormRequest $request, BillRepositoryInterface $repository, Bill $bill)
|
||||
{
|
||||
|
@@ -39,7 +39,6 @@ use Illuminate\Pagination\LengthAwarePaginator;
|
||||
use Illuminate\Support\Collection;
|
||||
use Log;
|
||||
use Preferences;
|
||||
use Response;
|
||||
use View;
|
||||
|
||||
/**
|
||||
@@ -79,13 +78,18 @@ class BudgetController extends Controller
|
||||
* @param Budget $budget
|
||||
*
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
* @throws \InvalidArgumentException
|
||||
*/
|
||||
public function amount(Request $request, BudgetRepositoryInterface $repository, Budget $budget)
|
||||
{
|
||||
$amount = strval($request->get('amount'));
|
||||
$start = Carbon::createFromFormat('Y-m-d', $request->get('start'));
|
||||
$end = Carbon::createFromFormat('Y-m-d', $request->get('end'));
|
||||
$amount = strval($request->get('amount'));
|
||||
$start = Carbon::createFromFormat('Y-m-d', $request->get('start'));
|
||||
$end = Carbon::createFromFormat('Y-m-d', $request->get('end'));
|
||||
$budgetLimit = $this->repository->updateLimitAmount($budget, $start, $end, $amount);
|
||||
$largeDiff = false;
|
||||
$warnText = '';
|
||||
$average = '0';
|
||||
$current = '0';
|
||||
if (0 === bccomp($amount, '0')) {
|
||||
$budgetLimit = null;
|
||||
}
|
||||
@@ -95,15 +99,50 @@ class BudgetController extends Controller
|
||||
$currency = app('amount')->getDefaultCurrency();
|
||||
$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();
|
||||
|
||||
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
|
||||
*
|
||||
* @return View
|
||||
* @throws \RuntimeException
|
||||
*/
|
||||
public function create(Request $request)
|
||||
{
|
||||
@@ -137,6 +176,7 @@ class BudgetController extends Controller
|
||||
* @param Budget $budget
|
||||
*
|
||||
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
|
||||
* @throws \RuntimeException
|
||||
*/
|
||||
public function destroy(Request $request, Budget $budget)
|
||||
{
|
||||
@@ -153,6 +193,7 @@ class BudgetController extends Controller
|
||||
* @param Budget $budget
|
||||
*
|
||||
* @return View
|
||||
* @throws \RuntimeException
|
||||
*/
|
||||
public function edit(Request $request, Budget $budget)
|
||||
{
|
||||
@@ -168,6 +209,7 @@ class BudgetController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @param string|null $moment
|
||||
*
|
||||
* @return View
|
||||
@@ -184,12 +226,13 @@ class BudgetController extends Controller
|
||||
$pageSize = intval(Preferences::get('listPageSize', 50)->data);
|
||||
|
||||
// make date if present:
|
||||
if (null !== $moment || 0 !== strlen(strval($moment))) {
|
||||
if (null !== $moment || '' !== (string)$moment) {
|
||||
try {
|
||||
$start = new Carbon($moment);
|
||||
$end = app('navigation')->endOfPeriod($start, $range);
|
||||
} catch (Exception $e) {
|
||||
// start and end are already defined.
|
||||
Log::debug('start and end are already defined.');
|
||||
}
|
||||
}
|
||||
$next = clone $end;
|
||||
@@ -292,7 +335,7 @@ class BudgetController extends Controller
|
||||
// @codeCoverageIgnoreStart
|
||||
$result = $cache->get();
|
||||
|
||||
return view('budgets.info', compact('result', 'begin', 'currentEnd'));
|
||||
return view('budgets.info', compact('result'));
|
||||
// @codeCoverageIgnoreEnd
|
||||
}
|
||||
$result = [
|
||||
@@ -413,6 +456,7 @@ class BudgetController extends Controller
|
||||
* @param BudgetIncomeRequest $request
|
||||
*
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
* @throws \InvalidArgumentException
|
||||
*/
|
||||
public function postUpdateIncome(BudgetIncomeRequest $request)
|
||||
{
|
||||
@@ -433,16 +477,18 @@ class BudgetController extends Controller
|
||||
* @param Budget $budget
|
||||
*
|
||||
* @return View
|
||||
* @throws \InvalidArgumentException
|
||||
*/
|
||||
public function show(Request $request, Budget $budget)
|
||||
{
|
||||
/** @var Carbon $start */
|
||||
$start = session('first', Carbon::create()->startOfYear());
|
||||
$end = new Carbon;
|
||||
$page = intval($request->get('page'));
|
||||
$pageSize = intval(Preferences::get('listPageSize', 50)->data);
|
||||
$page = (int)$request->get('page');
|
||||
$pageSize = (int)Preferences::get('listPageSize', 50)->data;
|
||||
$limits = $this->getLimits($budget, $start, $end);
|
||||
$repetition = null;
|
||||
|
||||
// collector:
|
||||
/** @var JournalCollectorInterface $collector */
|
||||
$collector = app(JournalCollectorInterface::class);
|
||||
@@ -462,6 +508,7 @@ class BudgetController extends Controller
|
||||
*
|
||||
* @return View
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
* @throws FireflyException
|
||||
*/
|
||||
public function showByBudgetLimit(Request $request, Budget $budget, BudgetLimit $budgetLimit)
|
||||
@@ -499,6 +546,7 @@ class BudgetController extends Controller
|
||||
* @param BudgetFormRequest $request
|
||||
*
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
* @throws \RuntimeException
|
||||
*/
|
||||
public function store(BudgetFormRequest $request)
|
||||
{
|
||||
@@ -524,6 +572,7 @@ class BudgetController extends Controller
|
||||
* @param Budget $budget
|
||||
*
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
* @throws \RuntimeException
|
||||
*/
|
||||
public function update(BudgetFormRequest $request, Budget $budget)
|
||||
{
|
||||
@@ -546,8 +595,9 @@ class BudgetController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
* @param Request $request
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
||||
*/
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user