mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-19 02:52:44 +00:00
Compare commits
119 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
f090a9534f | ||
|
ad289bc8cd | ||
|
6f5b6e536d | ||
|
c810bad97c | ||
|
a172c51495 | ||
|
633c776ebf | ||
|
19bd295c71 | ||
|
3b39fb93e7 | ||
|
e3a338db0e | ||
|
02df24bbc9 | ||
|
4f6ba1e706 | ||
|
a1f57a0949 | ||
|
3d444eb833 | ||
|
57b2a8d459 | ||
|
8a06507003 | ||
|
04d7137dff | ||
|
a2be71499f | ||
|
effba42ac2 | ||
|
aea8603ca1 | ||
|
fdb2abdf92 | ||
|
4b1d66bcf6 | ||
|
248e393405 | ||
|
967ea6a181 | ||
|
a11f876c49 | ||
|
2a4051fe92 | ||
|
10737d10a5 | ||
|
6f75e0df3c | ||
|
24a2238134 | ||
|
c7931f2b72 | ||
|
852584b6a8 | ||
|
21a9e981a2 | ||
|
ecc37b2ed3 | ||
|
c0935e192d | ||
|
92a2404b61 | ||
|
d9a2bd3e5f | ||
|
22f110df8d | ||
|
c76337926b | ||
|
bf57dec07c | ||
|
10d760a614 | ||
|
7b813065da | ||
|
c218a12af7 | ||
|
98ae0efb16 | ||
|
98cff18efa | ||
|
a7b2fbbf10 | ||
|
ccc12171d6 | ||
|
525f69cf63 | ||
|
4d2c5c1b58 | ||
|
450d07580e | ||
|
246100f2b7 | ||
|
9974e0229d | ||
|
ad44f99dbf | ||
|
12a64fefc8 | ||
|
2ee8cbbae4 | ||
|
34c19b145c | ||
|
c5e047ea02 | ||
|
fc78c32fca | ||
|
b53cbbe469 | ||
|
1d4434698e | ||
|
6d1bfd3956 | ||
|
1974d5f1e3 | ||
|
c235e42d6c | ||
|
342985d52a | ||
|
c2296c3ad5 | ||
|
23479790fe | ||
|
44823c6fec | ||
|
acfdf7dc90 | ||
|
6038a68ba9 | ||
|
79cf61b653 | ||
|
b97d3d3627 | ||
|
7f887e294a | ||
|
6f78735bc5 | ||
|
3e242aaca6 | ||
|
0796e422d4 | ||
|
fbd7c9ae07 | ||
|
5cfb1b63dc | ||
|
f09d0e87e4 | ||
|
820358af73 | ||
|
5a2998c80e | ||
|
a32df0066e | ||
|
02db333d46 | ||
|
070f46c755 | ||
|
b4a732bf77 | ||
|
d8eb59736e | ||
|
41c15b0cf8 | ||
|
fdf99400bc | ||
|
1ba45afeab | ||
|
1819ece55d | ||
|
78335210db | ||
|
ca23bb6272 | ||
|
eed84e18bb | ||
|
12641f96b1 | ||
|
1b97c4d58f | ||
|
ee3a2ef41c | ||
|
084ceb0c4e | ||
|
2497c4ee5c | ||
|
757a118f87 | ||
|
97908932e6 | ||
|
4c73ad8306 | ||
|
10a2078661 | ||
|
3fb09136cf | ||
|
843cced454 | ||
|
71a501868f | ||
|
0a0ad8200a | ||
|
a9baf54b12 | ||
|
ed565136fc | ||
|
4719b87314 | ||
|
24b30af018 | ||
|
e9f4695355 | ||
|
5b969fa014 | ||
|
499e713683 | ||
|
5eadb51b78 | ||
|
713a962005 | ||
|
d96e77a3ec | ||
|
bc68c367c8 | ||
|
33e241d39a | ||
|
e67812bf64 | ||
|
1090ce6597 | ||
|
e358f19548 | ||
|
eac406d62d |
@@ -70,7 +70,7 @@ php artisan firefly-iii:cc-liabilities
|
|||||||
php artisan firefly-iii:back-to-journals
|
php artisan firefly-iii:back-to-journals
|
||||||
php artisan firefly-iii:rename-account-meta
|
php artisan firefly-iii:rename-account-meta
|
||||||
|
|
||||||
# there are 13 verify commands
|
# there are 14 verify commands
|
||||||
php artisan firefly-iii:fix-piggies
|
php artisan firefly-iii:fix-piggies
|
||||||
php artisan firefly-iii:create-link-types
|
php artisan firefly-iii:create-link-types
|
||||||
php artisan firefly-iii:create-access-tokens
|
php artisan firefly-iii:create-access-tokens
|
||||||
@@ -80,10 +80,11 @@ php artisan firefly-iii:fix-transfer-budgets
|
|||||||
php artisan firefly-iii:fix-uneven-amount
|
php artisan firefly-iii:fix-uneven-amount
|
||||||
php artisan firefly-iii:delete-zero-amount
|
php artisan firefly-iii:delete-zero-amount
|
||||||
php artisan firefly-iii:delete-orphaned-transactions
|
php artisan firefly-iii:delete-orphaned-transactions
|
||||||
php artisan firefly-iii:delete-empty-journals
|
php artisan firefly-iii:delete-empty-journals
|
||||||
php artisan firefly-iii:delete-empty-groups
|
php artisan firefly-iii:delete-empty-groups
|
||||||
php artisan firefly-iii:fix-account-types
|
php artisan firefly-iii:fix-account-types
|
||||||
php artisan firefly-iii:rename-meta-fields
|
php artisan firefly-iii:rename-meta-fields
|
||||||
|
php artisan firefly-iii:fix-ob-currencies
|
||||||
|
|
||||||
# report commands
|
# report commands
|
||||||
php artisan firefly-iii:report-empty-objects
|
php artisan firefly-iii:report-empty-objects
|
||||||
|
@@ -40,6 +40,7 @@ APP_LOG_LEVEL=notice
|
|||||||
# Database credentials. Make sure the database exists. I recommend a dedicated user for Firefly III
|
# Database credentials. Make sure the database exists. I recommend a dedicated user for Firefly III
|
||||||
# For other database types, please see the FAQ: http://firefly-iii.readthedocs.io/en/latest/support/faq.html
|
# For other database types, please see the FAQ: http://firefly-iii.readthedocs.io/en/latest/support/faq.html
|
||||||
DB_CONNECTION=mysql
|
DB_CONNECTION=mysql
|
||||||
|
# If you use DOCKER COMPOSE, change this variable to "firefly_iii_db"
|
||||||
DB_HOST=127.0.0.1
|
DB_HOST=127.0.0.1
|
||||||
DB_PORT=3306
|
DB_PORT=3306
|
||||||
DB_DATABASE=homestead
|
DB_DATABASE=homestead
|
||||||
|
@@ -1,3 +1,48 @@
|
|||||||
|
# 4.8.0.3 (API 0.10.1)
|
||||||
|
|
||||||
|
- #2438 Some balance issues when working with multiple currencies (a known issue)
|
||||||
|
- #2425 Transaction edit/create form is weird with the enter button
|
||||||
|
- #2424 auto complete tab doesn't work.
|
||||||
|
- #2441 Inconsistent character limit for currencies.
|
||||||
|
- #2443 500 error when submitting budgets
|
||||||
|
- #2446 Can't update current amount for piggy bank
|
||||||
|
- #2440 Errors when interacting with recurring transactions
|
||||||
|
- #2439 SQL error in API post new user
|
||||||
|
- Transaction report (after import, over email) is mostly empty
|
||||||
|
- Mass edit checkboxes doesn't work in a tag overview
|
||||||
|
- #2437 CPU issues when viewing accounts, probably run-away queries.
|
||||||
|
- #2432 Can't disable all currencies except one / can't disable EUR and switch to something else.
|
||||||
|
- Option to edit the budget is gone from edit transaction form.
|
||||||
|
- #2453 Search view things
|
||||||
|
- #2449 Can't add invoice date.
|
||||||
|
- #2448 Bad link in transaction overview
|
||||||
|
- #2447 Bad link in bill overview
|
||||||
|
- Improvements to various API end-points. Docs are updated.
|
||||||
|
|
||||||
|
# 4.8.0.2 (API 0.10.0)
|
||||||
|
|
||||||
|
- [Issue 2203](https://github.com/firefly-iii/firefly-iii/issues/2203) Reconciliation inconsistencies.
|
||||||
|
- [Issue 2392](https://github.com/firefly-iii/firefly-iii/issues/2392) Bad namespace leads to installation errors.
|
||||||
|
- [Issue 2393](https://github.com/firefly-iii/firefly-iii/issues/2393) Missing budget selector.
|
||||||
|
- [Issue 2402](https://github.com/firefly-iii/firefly-iii/issues/2402) bad amounts in default report
|
||||||
|
- [Issue 2405](https://github.com/firefly-iii/firefly-iii/issues/2405) Due date can't be edited.
|
||||||
|
- [Issue 2404](https://github.com/firefly-iii/firefly-iii/issues/2404) bad page indicator in the "no category" transaction overview.
|
||||||
|
- [Issue 2407](https://github.com/firefly-iii/firefly-iii/issues/2407) Fix recurring transaction dates
|
||||||
|
- [Issue 2410](https://github.com/firefly-iii/firefly-iii/issues/2410) Transaction links inconsistent
|
||||||
|
- [Issue 2414](https://github.com/firefly-iii/firefly-iii/issues/2414) Can't edit recurring transactions
|
||||||
|
- [Issue 2415](https://github.com/firefly-iii/firefly-iii/issues/2415) Return here + reset form results in empty transaction form
|
||||||
|
- [Issue 2416](https://github.com/firefly-iii/firefly-iii/issues/2416) Some form inconsistencies.
|
||||||
|
- [Issue 2418](https://github.com/firefly-iii/firefly-iii/issues/2418) Reports are inaccurate or broken.
|
||||||
|
- [Issue 2422](https://github.com/firefly-iii/firefly-iii/issues/2422) PHP error when matching transactions.
|
||||||
|
- [Issue 2423](https://github.com/firefly-iii/firefly-iii/issues/2423) Reports are inaccurate or broken.
|
||||||
|
- [Issue 2426](https://github.com/firefly-iii/firefly-iii/issues/2426) Inconsistent documentation and instructions.
|
||||||
|
- [Issue 2427](https://github.com/firefly-iii/firefly-iii/issues/2427) Deleted account and "initial balance" accounts may appear in dropdowns.
|
||||||
|
- [Issue 2428](https://github.com/firefly-iii/firefly-iii/issues/2428) Reports are inaccurate or broken.
|
||||||
|
- [Issue 2429](https://github.com/firefly-iii/firefly-iii/issues/2429) Typo leads to SQL errors in available budgets API
|
||||||
|
- [Issue 2431](https://github.com/firefly-iii/firefly-iii/issues/2431) Issues creating new recurring transactions.
|
||||||
|
- [Issue 2434](https://github.com/firefly-iii/firefly-iii/issues/2434) You can edit the initial balance transaction but it fails to save.
|
||||||
|
- ARM build should work now.
|
||||||
|
|
||||||
# 4.8.0.1 (API 0.10.0)
|
# 4.8.0.1 (API 0.10.0)
|
||||||
|
|
||||||
- The balance box on the dashboard shows only negative numbers, skewing the results.
|
- The balance box on the dashboard shows only negative numbers, skewing the results.
|
||||||
|
@@ -15,8 +15,8 @@ const pkgdef :Spk.PackageDefinition = (
|
|||||||
|
|
||||||
manifest = (
|
manifest = (
|
||||||
appTitle = (defaultText = "Firefly III"),
|
appTitle = (defaultText = "Firefly III"),
|
||||||
appVersion = 33,
|
appVersion = 35,
|
||||||
appMarketingVersion = (defaultText = "4.8.0.1"),
|
appMarketingVersion = (defaultText = "4.8.0.3"),
|
||||||
|
|
||||||
actions = [
|
actions = [
|
||||||
# Define your "new document" handlers here.
|
# Define your "new document" handlers here.
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
sudo: required
|
sudo: required
|
||||||
language: bash
|
language: bash
|
||||||
env:
|
env:
|
||||||
- VERSION=4.8.0.1
|
- VERSION=4.8.0.3
|
||||||
|
|
||||||
dist: xenial
|
dist: xenial
|
||||||
|
|
||||||
@@ -26,4 +26,4 @@ script:
|
|||||||
# build everything
|
# build everything
|
||||||
- .deploy/docker/build-amd64.sh
|
- .deploy/docker/build-amd64.sh
|
||||||
- .deploy/docker/build-arm.sh
|
- .deploy/docker/build-arm.sh
|
||||||
- .deploy/docker/manifest.sh
|
- .deploy/docker/manifest.sh
|
||||||
|
29
Dockerfile
29
Dockerfile
@@ -1,28 +1,10 @@
|
|||||||
FROM php:7.2-apache
|
FROM jc5x/firefly-iii-base-image:latest
|
||||||
ENV FIREFLY_PATH=/var/www/firefly-iii COMPOSER_ALLOW_SUPERUSER=1
|
ENV FIREFLY_PATH=/var/www/firefly-iii COMPOSER_ALLOW_SUPERUSER=1
|
||||||
LABEL version="1.5" maintainer="thegrumpydictator@gmail.com"
|
LABEL version="1.5" maintainer="thegrumpydictator@gmail.com"
|
||||||
|
|
||||||
# Create volumes
|
# Create volumes
|
||||||
VOLUME $FIREFLY_PATH/storage/export $FIREFLY_PATH/storage/upload
|
VOLUME $FIREFLY_PATH/storage/export $FIREFLY_PATH/storage/upload
|
||||||
|
|
||||||
# Install stuff Firefly III runs with & depends on: php extensions, locales, dev headers and composer
|
|
||||||
RUN apt-get update && apt-get install -y locales unzip && apt-get clean && rm -rf /var/lib/apt/lists/*
|
|
||||||
|
|
||||||
ADD https://raw.githubusercontent.com/mlocati/docker-php-extension-installer/master/install-php-extensions /usr/local/bin/
|
|
||||||
|
|
||||||
RUN chmod uga+x /usr/local/bin/install-php-extensions && sync && \
|
|
||||||
install-php-extensions --cleanup bcmath ldap gd pdo_pgsql pdo_sqlite pdo_mysql intl opcache memcached
|
|
||||||
|
|
||||||
RUN a2enmod rewrite && a2enmod ssl
|
|
||||||
RUN echo "hu_HU.UTF-8 UTF-8\nro_RO.UTF-8 UTF-8\nnb_NO.UTF-8 UTF-8\nde_DE.UTF-8 UTF-8\ncs_CZ.UTF-8 UTF-8\nen_US.UTF-8 UTF-8\nes_ES.UTF-8 UTF-8\nfr_FR.UTF-8 UTF-8\nid_ID.UTF-8 UTF-8\nit_IT.UTF-8 UTF-8\nnl_NL.UTF-8 UTF-8\npl_PL.UTF-8 UTF-8\npt_BR.UTF-8 UTF-8\nru_RU.UTF-8 UTF-8\ntr_TR.UTF-8 UTF-8\nzh_TW.UTF-8 UTF-8\nzh_CN.UTF-8 UTF-8\n\n" > /etc/locale.gen
|
|
||||||
RUN locale-gen
|
|
||||||
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
|
|
||||||
|
|
||||||
# configure PHP
|
|
||||||
RUN cp /usr/local/etc/php/php.ini-production /usr/local/etc/php/php.ini && \
|
|
||||||
sed -i 's/max_execution_time = 30/max_execution_time = 600/' /usr/local/etc/php/php.ini && \
|
|
||||||
sed -i 's/memory_limit = 128M/memory_limit = 512M/' /usr/local/etc/php/php.ini
|
|
||||||
|
|
||||||
# Copy in Firefly III source
|
# Copy in Firefly III source
|
||||||
WORKDIR $FIREFLY_PATH
|
WORKDIR $FIREFLY_PATH
|
||||||
ADD . $FIREFLY_PATH
|
ADD . $FIREFLY_PATH
|
||||||
@@ -32,15 +14,6 @@ RUN chown -R www-data:www-data /var/www && \
|
|||||||
chmod -R 775 $FIREFLY_PATH/storage && \
|
chmod -R 775 $FIREFLY_PATH/storage && \
|
||||||
composer install --prefer-dist --no-dev --no-scripts --no-suggest
|
composer install --prefer-dist --no-dev --no-scripts --no-suggest
|
||||||
|
|
||||||
# copy ca certs to correct location
|
|
||||||
COPY ./.deploy/docker/cacert.pem /usr/local/ssl/cert.pem
|
|
||||||
|
|
||||||
# copy Apache config to correct spot.
|
|
||||||
COPY ./.deploy/docker/apache2.conf /etc/apache2/apache2.conf
|
|
||||||
|
|
||||||
# Enable default site (Firefly III)
|
|
||||||
COPY ./.deploy/docker/apache-firefly.conf /etc/apache2/sites-available/000-default.conf
|
|
||||||
|
|
||||||
# Expose port 80
|
# Expose port 80
|
||||||
EXPOSE 80
|
EXPOSE 80
|
||||||
|
|
||||||
|
@@ -1,29 +1,10 @@
|
|||||||
FROM php:7.2-apache
|
FROM jc5x/firefly-iii-base-image:latest
|
||||||
ARG ARCH
|
|
||||||
ENV FIREFLY_PATH=/var/www/firefly-iii COMPOSER_ALLOW_SUPERUSER=1
|
ENV FIREFLY_PATH=/var/www/firefly-iii COMPOSER_ALLOW_SUPERUSER=1
|
||||||
LABEL version="1.5" maintainer="thegrumpydictator@gmail.com"
|
LABEL version="1.5" maintainer="thegrumpydictator@gmail.com"
|
||||||
|
|
||||||
# Create volumes
|
# Create volumes
|
||||||
VOLUME $FIREFLY_PATH/storage/export $FIREFLY_PATH/storage/upload
|
VOLUME $FIREFLY_PATH/storage/export $FIREFLY_PATH/storage/upload
|
||||||
|
|
||||||
# Install stuff Firefly III runs with & depends on: php extensions, locales, dev headers and composer
|
|
||||||
RUN apt-get update && apt-get install -y locales unzip && apt-get clean && rm -rf /var/lib/apt/lists/*
|
|
||||||
|
|
||||||
ADD https://raw.githubusercontent.com/mlocati/docker-php-extension-installer/master/install-php-extensions /usr/local/bin/
|
|
||||||
|
|
||||||
RUN chmod uga+x /usr/local/bin/install-php-extensions && sync && \
|
|
||||||
install-php-extensions --cleanup bcmath ldap gd pdo_pgsql pdo_sqlite pdo_mysql intl opcache memcached
|
|
||||||
|
|
||||||
RUN a2enmod rewrite && a2enmod ssl
|
|
||||||
RUN echo "hu_HU.UTF-8 UTF-8\nro_RO.UTF-8 UTF-8\nnb_NO.UTF-8 UTF-8\nde_DE.UTF-8 UTF-8\ncs_CZ.UTF-8 UTF-8\nen_US.UTF-8 UTF-8\nes_ES.UTF-8 UTF-8\nfr_FR.UTF-8 UTF-8\nid_ID.UTF-8 UTF-8\nit_IT.UTF-8 UTF-8\nnl_NL.UTF-8 UTF-8\npl_PL.UTF-8 UTF-8\npt_BR.UTF-8 UTF-8\nru_RU.UTF-8 UTF-8\ntr_TR.UTF-8 UTF-8\nzh_TW.UTF-8 UTF-8\nzh_CN.UTF-8 UTF-8\n\n" > /etc/locale.gen
|
|
||||||
RUN locale-gen
|
|
||||||
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
|
|
||||||
|
|
||||||
# configure PHP
|
|
||||||
RUN cp /usr/local/etc/php/php.ini-production /usr/local/etc/php/php.ini && \
|
|
||||||
sed -i 's/max_execution_time = 30/max_execution_time = 600/' /usr/local/etc/php/php.ini && \
|
|
||||||
sed -i 's/memory_limit = 128M/memory_limit = 512M/' /usr/local/etc/php/php.ini
|
|
||||||
|
|
||||||
# Copy in Firefly III source
|
# Copy in Firefly III source
|
||||||
WORKDIR $FIREFLY_PATH
|
WORKDIR $FIREFLY_PATH
|
||||||
ADD . $FIREFLY_PATH
|
ADD . $FIREFLY_PATH
|
||||||
@@ -33,15 +14,6 @@ RUN chown -R www-data:www-data /var/www && \
|
|||||||
chmod -R 775 $FIREFLY_PATH/storage && \
|
chmod -R 775 $FIREFLY_PATH/storage && \
|
||||||
composer install --prefer-dist --no-dev --no-scripts --no-suggest
|
composer install --prefer-dist --no-dev --no-scripts --no-suggest
|
||||||
|
|
||||||
# copy ca certs to correct location
|
|
||||||
COPY ./.deploy/docker/cacert.pem /usr/local/ssl/cert.pem
|
|
||||||
|
|
||||||
# copy Apache config to correct spot.
|
|
||||||
COPY ./.deploy/docker/apache2.conf /etc/apache2/apache2.conf
|
|
||||||
|
|
||||||
# Enable default site (Firefly III)
|
|
||||||
COPY ./.deploy/docker/apache-firefly.conf /etc/apache2/sites-available/000-default.conf
|
|
||||||
|
|
||||||
# Expose port 80
|
# Expose port 80
|
||||||
EXPOSE 80
|
EXPOSE 80
|
||||||
|
|
||||||
|
@@ -1,25 +1,10 @@
|
|||||||
FROM arm32v7/php:7.2-apache-stretch
|
FROM jc5x/firefly-iii-base-image:latest
|
||||||
ARG ARCH
|
|
||||||
COPY tmp/qemu-arm-static /usr/bin/qemu-arm-static
|
|
||||||
ENV FIREFLY_PATH=/var/www/firefly-iii COMPOSER_ALLOW_SUPERUSER=1
|
ENV FIREFLY_PATH=/var/www/firefly-iii COMPOSER_ALLOW_SUPERUSER=1
|
||||||
LABEL version="1.5" maintainer="thegrumpydictator@gmail.com"
|
LABEL version="1.5" maintainer="thegrumpydictator@gmail.com"
|
||||||
|
|
||||||
# Create volumes
|
# Create volumes
|
||||||
VOLUME $FIREFLY_PATH/storage/export $FIREFLY_PATH/storage/upload
|
VOLUME $FIREFLY_PATH/storage/export $FIREFLY_PATH/storage/upload
|
||||||
|
|
||||||
# Install stuff Firefly III runs with & depends on: php extensions, locales, dev headers and composer
|
|
||||||
RUN apt-get update && apt-get install -y locales unzip && apt-get clean && rm -rf /var/lib/apt/lists/*
|
|
||||||
|
|
||||||
ADD https://raw.githubusercontent.com/mlocati/docker-php-extension-installer/master/install-php-extensions /usr/local/bin/
|
|
||||||
|
|
||||||
RUN chmod uga+x /usr/local/bin/install-php-extensions && sync && \
|
|
||||||
install-php-extensions --cleanup bcmath ldap gd pdo_pgsql pdo_sqlite pdo_mysql intl opcache memcached
|
|
||||||
|
|
||||||
RUN a2enmod rewrite && a2enmod ssl
|
|
||||||
RUN echo "hu_HU.UTF-8 UTF-8\nro_RO.UTF-8 UTF-8\nnb_NO.UTF-8 UTF-8\nde_DE.UTF-8 UTF-8\ncs_CZ.UTF-8 UTF-8\nen_US.UTF-8 UTF-8\nes_ES.UTF-8 UTF-8\nfr_FR.UTF-8 UTF-8\nid_ID.UTF-8 UTF-8\nit_IT.UTF-8 UTF-8\nnl_NL.UTF-8 UTF-8\npl_PL.UTF-8 UTF-8\npt_BR.UTF-8 UTF-8\nru_RU.UTF-8 UTF-8\ntr_TR.UTF-8 UTF-8\nzh_TW.UTF-8 UTF-8\nzh_CN.UTF-8 UTF-8\n\n" > /etc/locale.gen
|
|
||||||
RUN locale-gen
|
|
||||||
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
|
|
||||||
|
|
||||||
# Copy in Firefly III source
|
# Copy in Firefly III source
|
||||||
WORKDIR $FIREFLY_PATH
|
WORKDIR $FIREFLY_PATH
|
||||||
ADD . $FIREFLY_PATH
|
ADD . $FIREFLY_PATH
|
||||||
@@ -29,15 +14,6 @@ RUN chown -R www-data:www-data /var/www && \
|
|||||||
chmod -R 775 $FIREFLY_PATH/storage && \
|
chmod -R 775 $FIREFLY_PATH/storage && \
|
||||||
composer install --prefer-dist --no-dev --no-scripts --no-suggest
|
composer install --prefer-dist --no-dev --no-scripts --no-suggest
|
||||||
|
|
||||||
# copy ca certs to correct location
|
|
||||||
COPY ./.deploy/docker/cacert.pem /usr/local/ssl/cert.pem
|
|
||||||
|
|
||||||
# copy Apache config to correct spot.
|
|
||||||
COPY ./.deploy/docker/apache2.conf /etc/apache2/apache2.conf
|
|
||||||
|
|
||||||
# Enable default site (Firefly III)
|
|
||||||
COPY ./.deploy/docker/apache-firefly.conf /etc/apache2/sites-available/000-default.conf
|
|
||||||
|
|
||||||
# Expose port 80
|
# Expose port 80
|
||||||
EXPOSE 80
|
EXPOSE 80
|
||||||
|
|
||||||
|
@@ -47,7 +47,7 @@ use League\Fractal\Serializer\JsonApiSerializer;
|
|||||||
/**
|
/**
|
||||||
* Class AccountController.
|
* Class AccountController.
|
||||||
*
|
*
|
||||||
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
|
*
|
||||||
*/
|
*/
|
||||||
class AccountController extends Controller
|
class AccountController extends Controller
|
||||||
{
|
{
|
||||||
@@ -234,8 +234,6 @@ class AccountController extends Controller
|
|||||||
*
|
*
|
||||||
* @return JsonResponse
|
* @return JsonResponse
|
||||||
*
|
*
|
||||||
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
|
|
||||||
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
|
|
||||||
*/
|
*/
|
||||||
public function transactions(Request $request, Account $account): JsonResponse
|
public function transactions(Request $request, Account $account): JsonResponse
|
||||||
{
|
{
|
||||||
|
@@ -45,7 +45,7 @@ use function strlen;
|
|||||||
/**
|
/**
|
||||||
* Class AttachmentController.
|
* Class AttachmentController.
|
||||||
*
|
*
|
||||||
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
|
*
|
||||||
*/
|
*/
|
||||||
class AttachmentController extends Controller
|
class AttachmentController extends Controller
|
||||||
{
|
{
|
||||||
|
@@ -42,7 +42,7 @@ use League\Fractal\Serializer\JsonApiSerializer;
|
|||||||
/**
|
/**
|
||||||
* Class AvailableBudgetController.
|
* Class AvailableBudgetController.
|
||||||
*
|
*
|
||||||
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
|
*
|
||||||
*/
|
*/
|
||||||
class AvailableBudgetController extends Controller
|
class AvailableBudgetController extends Controller
|
||||||
{
|
{
|
||||||
|
@@ -48,7 +48,7 @@ use League\Fractal\Serializer\JsonApiSerializer;
|
|||||||
/**
|
/**
|
||||||
* Class BillController.
|
* Class BillController.
|
||||||
*
|
*
|
||||||
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
|
*
|
||||||
*/
|
*/
|
||||||
class BillController extends Controller
|
class BillController extends Controller
|
||||||
{
|
{
|
||||||
|
@@ -47,7 +47,7 @@ use League\Fractal\Serializer\JsonApiSerializer;
|
|||||||
/**
|
/**
|
||||||
* Class BudgetController.
|
* Class BudgetController.
|
||||||
*
|
*
|
||||||
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
|
*
|
||||||
*/
|
*/
|
||||||
class BudgetController extends Controller
|
class BudgetController extends Controller
|
||||||
{
|
{
|
||||||
@@ -79,8 +79,6 @@ class BudgetController extends Controller
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Display a listing of the resource.
|
* Display a listing of the resource.
|
||||||
*
|
|
||||||
*
|
|
||||||
* @param Request $request
|
* @param Request $request
|
||||||
* @param Budget $budget
|
* @param Budget $budget
|
||||||
*
|
*
|
||||||
|
@@ -46,7 +46,7 @@ use League\Fractal\Serializer\JsonApiSerializer;
|
|||||||
/**
|
/**
|
||||||
* Class BudgetLimitController.
|
* Class BudgetLimitController.
|
||||||
*
|
*
|
||||||
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
|
*
|
||||||
*/
|
*/
|
||||||
class BudgetLimitController extends Controller
|
class BudgetLimitController extends Controller
|
||||||
{
|
{
|
||||||
|
@@ -44,7 +44,7 @@ use League\Fractal\Serializer\JsonApiSerializer;
|
|||||||
/**
|
/**
|
||||||
* Class CategoryController.
|
* Class CategoryController.
|
||||||
*
|
*
|
||||||
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
|
*
|
||||||
*/
|
*/
|
||||||
class CategoryController extends Controller
|
class CategoryController extends Controller
|
||||||
{
|
{
|
||||||
|
@@ -37,7 +37,7 @@ use Symfony\Component\HttpFoundation\ParameterBag;
|
|||||||
* Class Controller.
|
* Class Controller.
|
||||||
*
|
*
|
||||||
* @codeCoverageIgnore
|
* @codeCoverageIgnore
|
||||||
* @SuppressWarnings(PHPMD.NumberOfChildren)
|
*
|
||||||
*/
|
*/
|
||||||
class Controller extends BaseController
|
class Controller extends BaseController
|
||||||
{
|
{
|
||||||
|
@@ -66,7 +66,7 @@ use League\Fractal\Serializer\JsonApiSerializer;
|
|||||||
/**
|
/**
|
||||||
* Class CurrencyController.
|
* Class CurrencyController.
|
||||||
*
|
*
|
||||||
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
|
*
|
||||||
*/
|
*/
|
||||||
class CurrencyController extends Controller
|
class CurrencyController extends Controller
|
||||||
{
|
{
|
||||||
|
@@ -45,7 +45,7 @@ use League\Fractal\Serializer\JsonApiSerializer;
|
|||||||
/**
|
/**
|
||||||
* Class LinkTypeController.
|
* Class LinkTypeController.
|
||||||
*
|
*
|
||||||
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
|
*
|
||||||
*/
|
*/
|
||||||
class LinkTypeController extends Controller
|
class LinkTypeController extends Controller
|
||||||
{
|
{
|
||||||
|
@@ -42,7 +42,7 @@ use League\Fractal\Serializer\JsonApiSerializer;
|
|||||||
/**
|
/**
|
||||||
* Class PiggyBankController.
|
* Class PiggyBankController.
|
||||||
*
|
*
|
||||||
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
|
*
|
||||||
*/
|
*/
|
||||||
class PiggyBankController extends Controller
|
class PiggyBankController extends Controller
|
||||||
{
|
{
|
||||||
@@ -226,7 +226,14 @@ class PiggyBankController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function update(PiggyBankRequest $request, PiggyBank $piggyBank): JsonResponse
|
public function update(PiggyBankRequest $request, PiggyBank $piggyBank): JsonResponse
|
||||||
{
|
{
|
||||||
$piggyBank = $this->repository->update($piggyBank, $request->getAll());
|
$data = $request->getAll();
|
||||||
|
$piggyBank = $this->repository->update($piggyBank, $data);
|
||||||
|
|
||||||
|
if ('' !== $data['current_amount']) {
|
||||||
|
$this->repository->setCurrentAmount($piggyBank, $data['current_amount']);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
$manager = new Manager();
|
$manager = new Manager();
|
||||||
$baseUrl = $request->getSchemeAndHttpHost() . '/api/v1';
|
$baseUrl = $request->getSchemeAndHttpHost() . '/api/v1';
|
||||||
$manager->setSerializer(new JsonApiSerializer($baseUrl));
|
$manager->setSerializer(new JsonApiSerializer($baseUrl));
|
||||||
|
@@ -48,7 +48,7 @@ use Log;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Class RuleController
|
* Class RuleController
|
||||||
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
|
*
|
||||||
*/
|
*/
|
||||||
class RuleController extends Controller
|
class RuleController extends Controller
|
||||||
{
|
{
|
||||||
|
@@ -231,7 +231,7 @@ class RuleGroupController extends Controller
|
|||||||
*
|
*
|
||||||
* @return JsonResponse
|
* @return JsonResponse
|
||||||
* @throws FireflyException
|
* @throws FireflyException
|
||||||
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
|
*
|
||||||
*/
|
*/
|
||||||
public function testGroup(RuleGroupTestRequest $request, RuleGroup $group): JsonResponse
|
public function testGroup(RuleGroupTestRequest $request, RuleGroup $group): JsonResponse
|
||||||
{
|
{
|
||||||
|
@@ -24,7 +24,8 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace FireflyIII\Api\V1\Controllers;
|
namespace FireflyIII\Api\V1\Controllers;
|
||||||
|
|
||||||
use FireflyIII\Api\V1\Requests\UserRequest;
|
use FireflyIII\Api\V1\Requests\UserStoreRequest;
|
||||||
|
use FireflyIII\Api\V1\Requests\UserUpdateRequest;
|
||||||
use FireflyIII\Exceptions\FireflyException;
|
use FireflyIII\Exceptions\FireflyException;
|
||||||
use FireflyIII\Repositories\User\UserRepositoryInterface;
|
use FireflyIII\Repositories\User\UserRepositoryInterface;
|
||||||
use FireflyIII\Transformers\UserTransformer;
|
use FireflyIII\Transformers\UserTransformer;
|
||||||
@@ -42,7 +43,7 @@ use League\Fractal\Serializer\JsonApiSerializer;
|
|||||||
/**
|
/**
|
||||||
* Class UserController.
|
* Class UserController.
|
||||||
*
|
*
|
||||||
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
|
*
|
||||||
*/
|
*/
|
||||||
class UserController extends Controller
|
class UserController extends Controller
|
||||||
{
|
{
|
||||||
@@ -155,11 +156,11 @@ class UserController extends Controller
|
|||||||
/**
|
/**
|
||||||
* Store a new user.
|
* Store a new user.
|
||||||
*
|
*
|
||||||
* @param UserRequest $request
|
* @param UserStoreRequest $request
|
||||||
*
|
*
|
||||||
* @return JsonResponse
|
* @return JsonResponse
|
||||||
*/
|
*/
|
||||||
public function store(UserRequest $request): JsonResponse
|
public function store(UserStoreRequest $request): JsonResponse
|
||||||
{
|
{
|
||||||
$data = $request->getAll();
|
$data = $request->getAll();
|
||||||
$user = $this->repository->store($data);
|
$user = $this->repository->store($data);
|
||||||
@@ -183,12 +184,12 @@ class UserController extends Controller
|
|||||||
/**
|
/**
|
||||||
* Update a user.
|
* Update a user.
|
||||||
*
|
*
|
||||||
* @param UserRequest $request
|
* @param UserUpdateRequest $request
|
||||||
* @param User $user
|
* @param User $user
|
||||||
*
|
*
|
||||||
* @return JsonResponse
|
* @return JsonResponse
|
||||||
*/
|
*/
|
||||||
public function update(UserRequest $request, User $user): JsonResponse
|
public function update(UserUpdateRequest $request, User $user): JsonResponse
|
||||||
{
|
{
|
||||||
$data = $request->getAll();
|
$data = $request->getAll();
|
||||||
$user = $this->repository->update($user, $data);
|
$user = $this->repository->update($user, $data);
|
||||||
|
@@ -80,7 +80,7 @@ class CurrencyRequest extends Request
|
|||||||
$rules = [
|
$rules = [
|
||||||
'name' => 'required|between:1,255|unique:transaction_currencies,name',
|
'name' => 'required|between:1,255|unique:transaction_currencies,name',
|
||||||
'code' => 'required|between:3,3|unique:transaction_currencies,code',
|
'code' => 'required|between:3,3|unique:transaction_currencies,code',
|
||||||
'symbol' => 'required|between:1,5|unique:transaction_currencies,symbol',
|
'symbol' => 'required|between:1,8|unique:transaction_currencies,symbol',
|
||||||
'decimal_places' => 'between:0,20|numeric|min:0|max:20',
|
'decimal_places' => 'between:0,20|numeric|min:0|max:20',
|
||||||
'enabled' => [new IsBoolean()],
|
'enabled' => [new IsBoolean()],
|
||||||
'default' => [new IsBoolean()],
|
'default' => [new IsBoolean()],
|
||||||
@@ -94,8 +94,8 @@ class CurrencyRequest extends Request
|
|||||||
case 'PATCH':
|
case 'PATCH':
|
||||||
$currency = $this->route()->parameter('currency_code');
|
$currency = $this->route()->parameter('currency_code');
|
||||||
$rules['name'] = 'required|between:1,255|unique:transaction_currencies,name,' . $currency->id;
|
$rules['name'] = 'required|between:1,255|unique:transaction_currencies,name,' . $currency->id;
|
||||||
$rules['code'] = 'required|between:1,255|unique:transaction_currencies,code,' . $currency->id;
|
$rules['code'] = 'required|between:3,3|unique:transaction_currencies,code,' . $currency->id;
|
||||||
$rules['symbol'] = 'required|between:1,255|unique:transaction_currencies,symbol,' . $currency->id;
|
$rules['symbol'] = 'required|between:1,8|unique:transaction_currencies,symbol,' . $currency->id;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* DateRequest.php
|
* DateRequest.php
|
||||||
* Copyright (c) 2019 thegrumpydictator@gmail.com
|
* Copyright (c) 2019 thegrumpydictator@gmail.com
|
||||||
@@ -19,6 +20,8 @@
|
|||||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace FireflyIII\Api\V1\Requests;
|
namespace FireflyIII\Api\V1\Requests;
|
||||||
|
|
||||||
|
|
||||||
@@ -65,4 +68,4 @@ class DateRequest extends Request
|
|||||||
'end' => 'required|date|after:start',
|
'end' => 'required|date|after:start',
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -25,6 +25,7 @@ namespace FireflyIII\Api\V1\Requests;
|
|||||||
|
|
||||||
use FireflyIII\Models\PiggyBank;
|
use FireflyIII\Models\PiggyBank;
|
||||||
use FireflyIII\Rules\IsAssetAccountId;
|
use FireflyIII\Rules\IsAssetAccountId;
|
||||||
|
use FireflyIII\Rules\LessThanPiggyTarget;
|
||||||
use FireflyIII\Rules\ZeroOrMore;
|
use FireflyIII\Rules\ZeroOrMore;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -53,14 +54,11 @@ class PiggyBankRequest extends Request
|
|||||||
*/
|
*/
|
||||||
public function getAll(): array
|
public function getAll(): array
|
||||||
{
|
{
|
||||||
$current = $this->string('current_amount');
|
|
||||||
$current = '' === $current ? '0' : $current;
|
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'name' => $this->string('name'),
|
'name' => $this->string('name'),
|
||||||
'account_id' => $this->integer('account_id'),
|
'account_id' => $this->integer('account_id'),
|
||||||
'targetamount' => $this->string('target_amount'),
|
'targetamount' => $this->string('target_amount'),
|
||||||
'current_amount' => $current,
|
'current_amount' => $this->string('current_amount'),
|
||||||
'startdate' => $this->date('start_date'),
|
'startdate' => $this->date('start_date'),
|
||||||
'targetdate' => $this->date('target_date'),
|
'targetdate' => $this->date('target_date'),
|
||||||
'notes' => $this->string('notes'),
|
'notes' => $this->string('notes'),
|
||||||
@@ -76,8 +74,6 @@ class PiggyBankRequest extends Request
|
|||||||
{
|
{
|
||||||
$rules = [
|
$rules = [
|
||||||
'name' => 'required|between:1,255|uniquePiggyBankForUser',
|
'name' => 'required|between:1,255|uniquePiggyBankForUser',
|
||||||
'account_id' => ['required', 'belongsToUser:accounts', new IsAssetAccountId],
|
|
||||||
'target_amount' => 'required|numeric|more:0',
|
|
||||||
'current_amount' => ['numeric', new ZeroOrMore, 'lte:target_amount'],
|
'current_amount' => ['numeric', new ZeroOrMore, 'lte:target_amount'],
|
||||||
'start_date' => 'date|nullable',
|
'start_date' => 'date|nullable',
|
||||||
'target_date' => 'date|nullable|after:start_date',
|
'target_date' => 'date|nullable|after:start_date',
|
||||||
@@ -90,8 +86,11 @@ class PiggyBankRequest extends Request
|
|||||||
case 'PUT':
|
case 'PUT':
|
||||||
case 'PATCH':
|
case 'PATCH':
|
||||||
/** @var PiggyBank $piggyBank */
|
/** @var PiggyBank $piggyBank */
|
||||||
$piggyBank = $this->route()->parameter('piggyBank');
|
$piggyBank = $this->route()->parameter('piggyBank');
|
||||||
$rules['name'] = 'required|between:1,255|uniquePiggyBankForUser:' . $piggyBank->id;
|
$rules['name'] = 'between:1,255|uniquePiggyBankForUser:' . $piggyBank->id;
|
||||||
|
$rules['account_id'] = ['belongsToUser:accounts', new IsAssetAccountId];
|
||||||
|
$rules['target_amount'] = 'numeric|more:0';
|
||||||
|
$rules['current_amount'] = ['numeric', new ZeroOrMore, new LessThanPiggyTarget];
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -23,6 +23,9 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace FireflyIII\Api\V1\Requests;
|
namespace FireflyIII\Api\V1\Requests;
|
||||||
|
|
||||||
|
use Carbon\Carbon;
|
||||||
|
use FireflyIII\Rules\BelongsUser;
|
||||||
|
use FireflyIII\Rules\IsBoolean;
|
||||||
use FireflyIII\Validation\RecurrenceValidation;
|
use FireflyIII\Validation\RecurrenceValidation;
|
||||||
use FireflyIII\Validation\TransactionValidation;
|
use FireflyIII\Validation\TransactionValidation;
|
||||||
use Illuminate\Validation\Validator;
|
use Illuminate\Validation\Validator;
|
||||||
@@ -52,7 +55,37 @@ class RecurrenceStoreRequest extends Request
|
|||||||
*/
|
*/
|
||||||
public function rules(): array
|
public function rules(): array
|
||||||
{
|
{
|
||||||
return $this->rulesRecurrence();
|
$today = Carbon::now()->addDay();
|
||||||
|
|
||||||
|
return [
|
||||||
|
'type' => 'required|in:withdrawal,transfer,deposit',
|
||||||
|
'title' => 'required|between:1,255|uniqueObjectForUser:recurrences,title',
|
||||||
|
'description' => 'between:1,65000',
|
||||||
|
'first_date' => sprintf('required|date|after:%s', $today->format('Y-m-d')),
|
||||||
|
'apply_rules' => [new IsBoolean],
|
||||||
|
'active' => [new IsBoolean],
|
||||||
|
'repeat_until' => sprintf('date|after:%s', $today->format('Y-m-d')),
|
||||||
|
'nr_of_repetitions' => 'numeric|between:1,31',
|
||||||
|
'tags' => 'between:1,64000',
|
||||||
|
'piggy_bank_id' => 'numeric',
|
||||||
|
'repetitions.*.type' => 'required|in:daily,weekly,ndom,monthly,yearly',
|
||||||
|
'repetitions.*.moment' => 'between:0,10',
|
||||||
|
'repetitions.*.skip' => 'required|numeric|between:0,31',
|
||||||
|
'repetitions.*.weekend' => 'required|numeric|min:1|max:4',
|
||||||
|
'transactions.*.description' => 'required|between:1,255',
|
||||||
|
'transactions.*.amount' => 'required|numeric|more:0',
|
||||||
|
'transactions.*.foreign_amount' => 'numeric|more:0',
|
||||||
|
'transactions.*.currency_id' => 'numeric|exists:transaction_currencies,id',
|
||||||
|
'transactions.*.currency_code' => 'min:3|max:3|exists:transaction_currencies,code',
|
||||||
|
'transactions.*.foreign_currency_id' => 'numeric|exists:transaction_currencies,id',
|
||||||
|
'transactions.*.foreign_currency_code' => 'min:3|max:3|exists:transaction_currencies,code',
|
||||||
|
'transactions.*.budget_id' => ['mustExist:budgets,id', new BelongsUser],
|
||||||
|
'transactions.*.category_name' => 'between:1,255|nullable',
|
||||||
|
'transactions.*.source_id' => ['numeric', 'nullable', new BelongsUser],
|
||||||
|
'transactions.*.source_name' => 'between:1,255|nullable',
|
||||||
|
'transactions.*.destination_id' => ['numeric', 'nullable', new BelongsUser],
|
||||||
|
'transactions.*.destination_name' => 'between:1,255|nullable',
|
||||||
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -23,6 +23,10 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace FireflyIII\Api\V1\Requests;
|
namespace FireflyIII\Api\V1\Requests;
|
||||||
|
|
||||||
|
use Carbon\Carbon;
|
||||||
|
use FireflyIII\Models\Recurrence;
|
||||||
|
use FireflyIII\Rules\BelongsUser;
|
||||||
|
use FireflyIII\Rules\IsBoolean;
|
||||||
use FireflyIII\Validation\RecurrenceValidation;
|
use FireflyIII\Validation\RecurrenceValidation;
|
||||||
use FireflyIII\Validation\TransactionValidation;
|
use FireflyIII\Validation\TransactionValidation;
|
||||||
use Illuminate\Validation\Validator;
|
use Illuminate\Validation\Validator;
|
||||||
@@ -52,7 +56,40 @@ class RecurrenceUpdateRequest extends Request
|
|||||||
*/
|
*/
|
||||||
public function rules(): array
|
public function rules(): array
|
||||||
{
|
{
|
||||||
return $this->rulesRecurrence();
|
/** @var Recurrence $recurrence */
|
||||||
|
$recurrence = $this->route()->parameter('recurrence');
|
||||||
|
$first = clone $recurrence->first_date;
|
||||||
|
$first->subDay();
|
||||||
|
|
||||||
|
return [
|
||||||
|
'type' => 'required|in:withdrawal,transfer,deposit',
|
||||||
|
'title' => sprintf('required|between:1,255|uniqueObjectForUser:recurrences,title,%d', $recurrence->id),
|
||||||
|
'description' => 'between:1,65000',
|
||||||
|
'first_date' => sprintf('required|date|after:%s', $first->format('Y-m-d')),
|
||||||
|
'apply_rules' => [new IsBoolean],
|
||||||
|
'active' => [new IsBoolean],
|
||||||
|
'repeat_until' => sprintf('date|after:%s', $first->format('Y-m-d')),
|
||||||
|
'nr_of_repetitions' => 'numeric|between:1,31',
|
||||||
|
'tags' => 'between:1,64000',
|
||||||
|
'piggy_bank_id' => 'numeric',
|
||||||
|
'repetitions.*.type' => 'required|in:daily,weekly,ndom,monthly,yearly',
|
||||||
|
'repetitions.*.moment' => 'between:0,10',
|
||||||
|
'repetitions.*.skip' => 'required|numeric|between:0,31',
|
||||||
|
'repetitions.*.weekend' => 'required|numeric|min:1|max:4',
|
||||||
|
'transactions.*.description' => 'required|between:1,255',
|
||||||
|
'transactions.*.amount' => 'required|numeric|more:0',
|
||||||
|
'transactions.*.foreign_amount' => 'numeric|more:0',
|
||||||
|
'transactions.*.currency_id' => 'numeric|exists:transaction_currencies,id',
|
||||||
|
'transactions.*.currency_code' => 'min:3|max:3|exists:transaction_currencies,code',
|
||||||
|
'transactions.*.foreign_currency_id' => 'numeric|exists:transaction_currencies,id',
|
||||||
|
'transactions.*.foreign_currency_code' => 'min:3|max:3|exists:transaction_currencies,code',
|
||||||
|
'transactions.*.budget_id' => ['mustExist:budgets,id', new BelongsUser],
|
||||||
|
'transactions.*.category_name' => 'between:1,255|nullable',
|
||||||
|
'transactions.*.source_id' => ['numeric', 'nullable', new BelongsUser],
|
||||||
|
'transactions.*.source_name' => 'between:1,255|nullable',
|
||||||
|
'transactions.*.destination_id' => ['numeric', 'nullable', new BelongsUser],
|
||||||
|
'transactions.*.destination_name' => 'between:1,255|nullable',
|
||||||
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -121,48 +121,6 @@ class Request extends FireflyIIIRequest
|
|||||||
return $return;
|
return $return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* The rules that the incoming request must be matched against.
|
|
||||||
*
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
protected function rulesRecurrence(): array
|
|
||||||
{
|
|
||||||
$today = Carbon::now()->addDay();
|
|
||||||
|
|
||||||
return [
|
|
||||||
'type' => 'required|in:withdrawal,transfer,deposit',
|
|
||||||
'title' => 'required|between:1,255|uniqueObjectForUser:recurrences,title',
|
|
||||||
'description' => 'between:1,65000',
|
|
||||||
'first_date' => sprintf('required|date|after:%s', $today->format('Y-m-d')),
|
|
||||||
'apply_rules' => [new IsBoolean],
|
|
||||||
'active' => [new IsBoolean],
|
|
||||||
'repeat_until' => sprintf('date|after:%s', $today->format('Y-m-d')),
|
|
||||||
'nr_of_repetitions' => 'numeric|between:1,31',
|
|
||||||
'tags' => 'between:1,64000',
|
|
||||||
'piggy_bank_id' => 'numeric',
|
|
||||||
'repetitions.*.type' => 'required|in:daily,weekly,ndom,monthly,yearly',
|
|
||||||
'repetitions.*.moment' => 'between:0,10',
|
|
||||||
'repetitions.*.skip' => 'required|numeric|between:0,31',
|
|
||||||
'repetitions.*.weekend' => 'required|numeric|min:1|max:4',
|
|
||||||
'transactions.*.description' => 'required|between:1,255',
|
|
||||||
'transactions.*.amount' => 'required|numeric|more:0',
|
|
||||||
'transactions.*.foreign_amount' => 'numeric|more:0',
|
|
||||||
'transactions.*.currency_id' => 'numeric|exists:transaction_currencies,id',
|
|
||||||
'transactions.*.currency_code' => 'min:3|max:3|exists:transaction_currencies,code',
|
|
||||||
'transactions.*.foreign_currency_id' => 'numeric|exists:transaction_currencies,id',
|
|
||||||
'transactions.*.foreign_currency_code' => 'min:3|max:3|exists:transaction_currencies,code',
|
|
||||||
'transactions.*.budget_id' => ['mustExist:budgets,id', new BelongsUser],
|
|
||||||
'transactions.*.category_name' => 'between:1,255|nullable',
|
|
||||||
'transactions.*.source_id' => ['numeric', 'nullable', new BelongsUser],
|
|
||||||
'transactions.*.source_name' => 'between:1,255|nullable',
|
|
||||||
'transactions.*.destination_id' => ['numeric', 'nullable', new BelongsUser],
|
|
||||||
'transactions.*.destination_name' => 'between:1,255|nullable',
|
|
||||||
|
|
||||||
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the repetition data as it is found in the submitted data.
|
* Returns the repetition data as it is found in the submitted data.
|
||||||
*
|
*
|
||||||
|
@@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* RuleGroupTestRequest.php
|
* RuleGroupTestRequest.php
|
||||||
* Copyright (c) 2019 thegrumpydictator@gmail.com
|
* Copyright (c) 2019 thegrumpydictator@gmail.com
|
||||||
@@ -19,6 +20,9 @@
|
|||||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
|
||||||
namespace FireflyIII\Api\V1\Requests;
|
namespace FireflyIII\Api\V1\Requests;
|
||||||
|
|
||||||
|
|
||||||
@@ -141,4 +145,4 @@ class RuleGroupTestRequest extends Request
|
|||||||
return null !== $account && AccountType::ASSET === $account->accountType->type;
|
return null !== $account && AccountType::ASSET === $account->accountType->type;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* RuleGroupTriggerRequest.php
|
* RuleGroupTriggerRequest.php
|
||||||
* Copyright (c) 2019 thegrumpydictator@gmail.com
|
* Copyright (c) 2019 thegrumpydictator@gmail.com
|
||||||
@@ -19,6 +20,9 @@
|
|||||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
|
||||||
namespace FireflyIII\Api\V1\Requests;
|
namespace FireflyIII\Api\V1\Requests;
|
||||||
|
|
||||||
|
|
||||||
@@ -116,4 +120,4 @@ class RuleGroupTriggerRequest extends Request
|
|||||||
return null !== $account && AccountType::ASSET === $account->accountType->type;
|
return null !== $account && AccountType::ASSET === $account->accountType->type;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* RuleTestRequest.php
|
* RuleTestRequest.php
|
||||||
* Copyright (c) 2019 thegrumpydictator@gmail.com
|
* Copyright (c) 2019 thegrumpydictator@gmail.com
|
||||||
@@ -19,6 +20,9 @@
|
|||||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
|
||||||
namespace FireflyIII\Api\V1\Requests;
|
namespace FireflyIII\Api\V1\Requests;
|
||||||
|
|
||||||
|
|
||||||
@@ -141,4 +145,4 @@ class RuleTestRequest extends Request
|
|||||||
return null !== $account && AccountType::ASSET === $account->accountType->type;
|
return null !== $account && AccountType::ASSET === $account->accountType->type;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* RuleTriggerRequest.php
|
* RuleTriggerRequest.php
|
||||||
* Copyright (c) 2019 thegrumpydictator@gmail.com
|
* Copyright (c) 2019 thegrumpydictator@gmail.com
|
||||||
@@ -19,6 +20,8 @@
|
|||||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace FireflyIII\Api\V1\Requests;
|
namespace FireflyIII\Api\V1\Requests;
|
||||||
|
|
||||||
|
|
||||||
@@ -116,4 +119,4 @@ class RuleTriggerRequest extends Request
|
|||||||
return null !== $account && AccountType::ASSET === $account->accountType->type;
|
return null !== $account && AccountType::ASSET === $account->accountType->type;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* UserRequest.php
|
* UserStoreRequest.php
|
||||||
* Copyright (c) 2018 thegrumpydictator@gmail.com
|
* Copyright (c) 2018 thegrumpydictator@gmail.com
|
||||||
*
|
*
|
||||||
* This file is part of Firefly III.
|
* This file is part of Firefly III.
|
||||||
@@ -30,11 +30,9 @@ use FireflyIII\User;
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class UserRequest
|
* Class UserStoreRequest
|
||||||
* @codeCoverageIgnore
|
|
||||||
* TODO AFTER 4.8,0: split this into two request classes.
|
|
||||||
*/
|
*/
|
||||||
class UserRequest extends Request
|
class UserStoreRequest extends Request
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Authorize logged in users.
|
* Authorize logged in users.
|
||||||
@@ -68,7 +66,7 @@ class UserRequest extends Request
|
|||||||
public function getAll(): array
|
public function getAll(): array
|
||||||
{
|
{
|
||||||
$blocked = false;
|
$blocked = false;
|
||||||
if (null === $this->get('blocked')) {
|
if (null !== $this->get('blocked')) {
|
||||||
$blocked = $this->boolean('blocked');
|
$blocked = $this->boolean('blocked');
|
||||||
}
|
}
|
||||||
$data = [
|
$data = [
|
||||||
@@ -88,23 +86,12 @@ class UserRequest extends Request
|
|||||||
*/
|
*/
|
||||||
public function rules(): array
|
public function rules(): array
|
||||||
{
|
{
|
||||||
$rules = [
|
return [
|
||||||
'email' => 'required|email|unique:users,email,',
|
'email' => 'required|email|unique:users,email,',
|
||||||
'blocked' => [new IsBoolean],
|
'blocked' => [new IsBoolean],
|
||||||
'blocked_code' => 'in:email_changed',
|
'blocked_code' => 'in:email_changed',
|
||||||
'role' => 'in:owner,demo',
|
'role' => 'in:owner,demo',
|
||||||
];
|
];
|
||||||
switch ($this->method()) {
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
case 'PUT':
|
|
||||||
case 'PATCH':
|
|
||||||
$user = $this->route()->parameter('user');
|
|
||||||
$rules['email'] = 'required|email|unique:users,email,' . $user->id;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return $rules;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
100
app/Api/V1/Requests/UserUpdateRequest.php
Normal file
100
app/Api/V1/Requests/UserUpdateRequest.php
Normal file
@@ -0,0 +1,100 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* UserUpdateRequest.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\Api\V1\Requests;
|
||||||
|
|
||||||
|
use FireflyIII\Repositories\User\UserRepositoryInterface;
|
||||||
|
use FireflyIII\Rules\IsBoolean;
|
||||||
|
use FireflyIII\User;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class UserUpdateRequest
|
||||||
|
*/
|
||||||
|
class UserUpdateRequest extends Request
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Authorize logged in users.
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function authorize(): bool
|
||||||
|
{
|
||||||
|
$result = false;
|
||||||
|
// Only allow authenticated users
|
||||||
|
if (auth()->check()) {
|
||||||
|
/** @var User $user */
|
||||||
|
$user = auth()->user();
|
||||||
|
|
||||||
|
/** @var UserRepositoryInterface $repository */
|
||||||
|
$repository = app(UserRepositoryInterface::class);
|
||||||
|
|
||||||
|
if ($repository->hasRole($user, 'owner')) {
|
||||||
|
$result = true; // @codeCoverageIgnore
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get all data from the request.
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function getAll(): array
|
||||||
|
{
|
||||||
|
$blocked = false;
|
||||||
|
if (null !== $this->get('blocked')) {
|
||||||
|
$blocked = $this->boolean('blocked');
|
||||||
|
}
|
||||||
|
$data = [
|
||||||
|
'email' => $this->string('email'),
|
||||||
|
'blocked' => $blocked,
|
||||||
|
'blocked_code' => $this->string('blocked_code'),
|
||||||
|
'role' => $this->string('role'),
|
||||||
|
];
|
||||||
|
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The rules that the incoming request must be matched against.
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function rules(): array
|
||||||
|
{
|
||||||
|
$user = $this->route()->parameter('user');
|
||||||
|
$rules = [
|
||||||
|
'email' => sprintf('email|unique:users,email,%d', $user->id),
|
||||||
|
'blocked' => [new IsBoolean],
|
||||||
|
'blocked_code' => 'in:email_changed',
|
||||||
|
'role' => 'in:owner,demo,',
|
||||||
|
];
|
||||||
|
|
||||||
|
return $rules;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@@ -70,6 +70,7 @@ class CorrectDatabase extends Command
|
|||||||
'firefly-iii:delete-empty-groups',
|
'firefly-iii:delete-empty-groups',
|
||||||
'firefly-iii:fix-account-types',
|
'firefly-iii:fix-account-types',
|
||||||
'firefly-iii:rename-meta-fields',
|
'firefly-iii:rename-meta-fields',
|
||||||
|
'firefly-iii:fix-ob-currencies'
|
||||||
];
|
];
|
||||||
foreach ($commands as $command) {
|
foreach ($commands as $command) {
|
||||||
$this->line(sprintf('Now executing %s', $command));
|
$this->line(sprintf('Now executing %s', $command));
|
||||||
@@ -80,4 +81,4 @@ class CorrectDatabase extends Command
|
|||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -0,0 +1,158 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* CorrectOpeningBalanceCurrencies.php
|
||||||
|
* Copyright (c) 2019 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/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace FireflyIII\Console\Commands\Correction;
|
||||||
|
|
||||||
|
use FireflyIII\Models\Account;
|
||||||
|
use FireflyIII\Models\AccountType;
|
||||||
|
use FireflyIII\Models\Transaction;
|
||||||
|
use FireflyIII\Models\TransactionCurrency;
|
||||||
|
use FireflyIII\Models\TransactionJournal;
|
||||||
|
use FireflyIII\Models\TransactionType;
|
||||||
|
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||||
|
use Illuminate\Console\Command;
|
||||||
|
use Log;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class CorrectOpeningBalanceCurrencies
|
||||||
|
*/
|
||||||
|
class CorrectOpeningBalanceCurrencies extends Command
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The console command description.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $description = 'Will make sure that opening balance transaction currencies match the account they\'re for.';
|
||||||
|
/**
|
||||||
|
* The name and signature of the console command.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $signature = 'firefly-iii:fix-ob-currencies';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Execute the console command.
|
||||||
|
*
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
public function handle(): int
|
||||||
|
{
|
||||||
|
// get all OB journals:
|
||||||
|
$set = TransactionJournal
|
||||||
|
::leftJoin('transaction_types', 'transaction_types.id', '=', 'transaction_journals.transaction_type_id')
|
||||||
|
->whereNull('transaction_journals.deleted_at')
|
||||||
|
->where('transaction_types.type', TransactionType::OPENING_BALANCE)->get(['transaction_journals.*']);
|
||||||
|
|
||||||
|
$this->line(sprintf('Going to verify %d opening balance transactions.', $set->count()));
|
||||||
|
$count = 0;
|
||||||
|
/** @var TransactionJournal $journal */
|
||||||
|
foreach ($set as $journal) {
|
||||||
|
$count += $this->correctJournal($journal);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($count > 0) {
|
||||||
|
$this->line(sprintf('Corrected %d opening balance transactions.', $count));
|
||||||
|
}
|
||||||
|
if (0 === $count) {
|
||||||
|
$this->info('There was nothing to fix in the opening balance transactions.');
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param TransactionJournal $journal
|
||||||
|
*
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
private function correctJournal(TransactionJournal $journal): int
|
||||||
|
{
|
||||||
|
Log::debug(sprintf('Going to correct journal #%d', $journal->id));
|
||||||
|
// get the asset account for this opening balance:
|
||||||
|
$account = $this->getAccount($journal);
|
||||||
|
if (null === $account) {
|
||||||
|
$this->warn(sprintf('Transaction journal #%d has no valid account. Cant fix this line.', $journal->id));
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
Log::debug(sprintf('Found %s #%d "%s".', $account->accountType->type, $account->id, $account->name));
|
||||||
|
$currency = $this->getCurrency($account);
|
||||||
|
Log::debug(sprintf('Found currency #%d (%s)', $currency->id, $currency->code));
|
||||||
|
|
||||||
|
// update journal and all transactions:
|
||||||
|
$this->setCurrency($journal, $currency);
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param TransactionJournal $journal
|
||||||
|
*
|
||||||
|
* @return Account|null
|
||||||
|
*/
|
||||||
|
private function getAccount(TransactionJournal $journal): ?Account
|
||||||
|
{
|
||||||
|
$excluded = [];
|
||||||
|
$transactions = $journal->transactions()->with(['account', 'account.accountType'])->get();
|
||||||
|
/** @var Transaction $transaction */
|
||||||
|
foreach ($transactions as $transaction) {
|
||||||
|
$account = $transaction->account;
|
||||||
|
if (null !== $account) {
|
||||||
|
if (AccountType::INITIAL_BALANCE !== $account->accountType->type) {
|
||||||
|
return $account;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Account $account
|
||||||
|
*
|
||||||
|
* @return TransactionCurrency
|
||||||
|
*/
|
||||||
|
private function getCurrency(Account $account): TransactionCurrency
|
||||||
|
{
|
||||||
|
/** @var AccountRepositoryInterface $repos */
|
||||||
|
$repos = app(AccountRepositoryInterface::class);
|
||||||
|
$repos->setUser($account->user);
|
||||||
|
|
||||||
|
return $repos->getAccountCurrency($account) ?? app('amount')->getDefaultCurrencyByUser($account->user);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param TransactionJournal $journal
|
||||||
|
* @param TransactionCurrency $currency
|
||||||
|
*/
|
||||||
|
private function setCurrency(TransactionJournal $journal, TransactionCurrency $currency): void
|
||||||
|
{
|
||||||
|
$journal->transaction_currency_id = $currency->id;
|
||||||
|
$journal->save();
|
||||||
|
|
||||||
|
/** @var Transaction $transaction */
|
||||||
|
foreach ($journal->transactions as $transaction) {
|
||||||
|
$transaction->transaction_currency_id = $currency->id;
|
||||||
|
$transaction->save();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
declare(strict_types=1);
|
||||||
/**
|
/**
|
||||||
* CreateAccessTokens.php
|
* CreateAccessTokens.php
|
||||||
* Copyright (c) 2019 thegrumpydictator@gmail.com
|
* Copyright (c) 2019 thegrumpydictator@gmail.com
|
||||||
|
@@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
declare(strict_types=1);
|
||||||
/**
|
/**
|
||||||
* CreateLinkTypes.php
|
* CreateLinkTypes.php
|
||||||
* Copyright (c) 2019 thegrumpydictator@gmail.com
|
* Copyright (c) 2019 thegrumpydictator@gmail.com
|
||||||
|
@@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
declare(strict_types=1);
|
||||||
/**
|
/**
|
||||||
* DeleteEmptyGroups.php
|
* DeleteEmptyGroups.php
|
||||||
* Copyright (c) 2019 thegrumpydictator@gmail.com
|
* Copyright (c) 2019 thegrumpydictator@gmail.com
|
||||||
|
@@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
declare(strict_types=1);
|
||||||
/**
|
/**
|
||||||
* DeleteEmptyJournals.php
|
* DeleteEmptyJournals.php
|
||||||
* Copyright (c) 2019 thegrumpydictator@gmail.com
|
* Copyright (c) 2019 thegrumpydictator@gmail.com
|
||||||
|
@@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
declare(strict_types=1);
|
||||||
/**
|
/**
|
||||||
* DeleteOrphanedTransactions.php
|
* DeleteOrphanedTransactions.php
|
||||||
* Copyright (c) 2019 thegrumpydictator@gmail.com
|
* Copyright (c) 2019 thegrumpydictator@gmail.com
|
||||||
|
@@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
declare(strict_types=1);
|
||||||
/**
|
/**
|
||||||
* DeleteZeroAmount.php
|
* DeleteZeroAmount.php
|
||||||
* Copyright (c) 2019 thegrumpydictator@gmail.com
|
* Copyright (c) 2019 thegrumpydictator@gmail.com
|
||||||
|
@@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
declare(strict_types=1);
|
||||||
/**
|
/**
|
||||||
* EnableCurrencies.php
|
* EnableCurrencies.php
|
||||||
* Copyright (c) 2019 thegrumpydictator@gmail.com
|
* Copyright (c) 2019 thegrumpydictator@gmail.com
|
||||||
|
@@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
declare(strict_types=1);
|
||||||
/**
|
/**
|
||||||
* FixAccountTypes.php
|
* FixAccountTypes.php
|
||||||
* Copyright (c) 2019 thegrumpydictator@gmail.com
|
* Copyright (c) 2019 thegrumpydictator@gmail.com
|
||||||
|
@@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
declare(strict_types=1);
|
||||||
/**
|
/**
|
||||||
* FixPiggies.php
|
* FixPiggies.php
|
||||||
* Copyright (c) 2019 thegrumpydictator@gmail.com
|
* Copyright (c) 2019 thegrumpydictator@gmail.com
|
||||||
|
@@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
declare(strict_types=1);
|
||||||
/**
|
/**
|
||||||
* FixUnevenAmount.php
|
* FixUnevenAmount.php
|
||||||
* Copyright (c) 2019 thegrumpydictator@gmail.com
|
* Copyright (c) 2019 thegrumpydictator@gmail.com
|
||||||
|
@@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
declare(strict_types=1);
|
||||||
/**
|
/**
|
||||||
* RemoveBills.php
|
* RemoveBills.php
|
||||||
* Copyright (c) 2019 thegrumpydictator@gmail.com
|
* Copyright (c) 2019 thegrumpydictator@gmail.com
|
||||||
|
@@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
declare(strict_types=1);
|
||||||
/**
|
/**
|
||||||
* RenameMetaFields.php
|
* RenameMetaFields.php
|
||||||
* Copyright (c) 2019 thegrumpydictator@gmail.com
|
* Copyright (c) 2019 thegrumpydictator@gmail.com
|
||||||
|
@@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
declare(strict_types=1);
|
||||||
/**
|
/**
|
||||||
* TransferBudgets.php
|
* TransferBudgets.php
|
||||||
* Copyright (c) 2019 thegrumpydictator@gmail.com
|
* Copyright (c) 2019 thegrumpydictator@gmail.com
|
||||||
|
@@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
declare(strict_types=1);
|
||||||
/**
|
/**
|
||||||
* ReportEmptyObjects.php
|
* ReportEmptyObjects.php
|
||||||
* Copyright (c) 2019 thegrumpydictator@gmail.com
|
* Copyright (c) 2019 thegrumpydictator@gmail.com
|
||||||
|
@@ -70,4 +70,4 @@ class ReportIntegrity extends Command
|
|||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
declare(strict_types=1);
|
||||||
/**
|
/**
|
||||||
* ReportSum.php
|
* ReportSum.php
|
||||||
* Copyright (c) 2019 thegrumpydictator@gmail.com
|
* Copyright (c) 2019 thegrumpydictator@gmail.com
|
||||||
|
@@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
declare(strict_types=1);
|
||||||
/**
|
/**
|
||||||
* AccountCurrencies.php
|
* AccountCurrencies.php
|
||||||
* Copyright (c) 2019 thegrumpydictator@gmail.com
|
* Copyright (c) 2019 thegrumpydictator@gmail.com
|
||||||
|
@@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
declare(strict_types=1);
|
||||||
/**
|
/**
|
||||||
* BackToJournals.php
|
* BackToJournals.php
|
||||||
* Copyright (c) 2019 thegrumpydictator@gmail.com
|
* Copyright (c) 2019 thegrumpydictator@gmail.com
|
||||||
|
@@ -116,4 +116,4 @@ class BudgetLimitCurrency extends Command
|
|||||||
{
|
{
|
||||||
app('fireflyconfig')->set(self::CONFIG_NAME, true);
|
app('fireflyconfig')->set(self::CONFIG_NAME, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -115,4 +115,4 @@ class CCLiabilities extends Command
|
|||||||
{
|
{
|
||||||
app('fireflyconfig')->set(self::CONFIG_NAME, true);
|
app('fireflyconfig')->set(self::CONFIG_NAME, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -125,4 +125,4 @@ class MigrateAttachments extends Command
|
|||||||
{
|
{
|
||||||
app('fireflyconfig')->set(self::CONFIG_NAME, true);
|
app('fireflyconfig')->set(self::CONFIG_NAME, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -124,4 +124,4 @@ class MigrateJournalNotes extends Command
|
|||||||
{
|
{
|
||||||
app('fireflyconfig')->set(self::CONFIG_NAME, true);
|
app('fireflyconfig')->set(self::CONFIG_NAME, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
declare(strict_types=1);
|
||||||
/**
|
/**
|
||||||
* MigrateToGroups.php
|
* MigrateToGroups.php
|
||||||
* Copyright (c) 2019 thegrumpydictator@gmail.com
|
* Copyright (c) 2019 thegrumpydictator@gmail.com
|
||||||
@@ -236,7 +237,7 @@ class MigrateToGroups extends Command
|
|||||||
* @param TransactionJournal $journal
|
* @param TransactionJournal $journal
|
||||||
*
|
*
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
|
*
|
||||||
*/
|
*/
|
||||||
private function makeMultiGroup(TransactionJournal $journal): void
|
private function makeMultiGroup(TransactionJournal $journal): void
|
||||||
{
|
{
|
||||||
|
@@ -246,4 +246,4 @@ class MigrateToRules extends Command
|
|||||||
$this->billRepository->update($bill, $newBillData);
|
$this->billRepository->update($bill, $newBillData);
|
||||||
$this->count++;
|
$this->count++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -125,6 +125,7 @@ class OtherCurrenciesCorrections extends Command
|
|||||||
if (isset($this->accountCurrencies[$accountId]) && $this->accountCurrencies[$accountId] instanceof TransactionCurrency) {
|
if (isset($this->accountCurrencies[$accountId]) && $this->accountCurrencies[$accountId] instanceof TransactionCurrency) {
|
||||||
return $this->accountCurrencies[$accountId]; // @codeCoverageIgnore
|
return $this->accountCurrencies[$accountId]; // @codeCoverageIgnore
|
||||||
}
|
}
|
||||||
|
// TODO we can use getAccountCurrency() instead
|
||||||
$currencyId = (int)$this->accountRepos->getMetaValue($account, 'currency_id');
|
$currencyId = (int)$this->accountRepos->getMetaValue($account, 'currency_id');
|
||||||
$result = $this->currencyRepos->findNull($currencyId);
|
$result = $this->currencyRepos->findNull($currencyId);
|
||||||
if (null === $result) {
|
if (null === $result) {
|
||||||
@@ -247,8 +248,8 @@ class OtherCurrenciesCorrections extends Command
|
|||||||
* Gets the transaction that determines the transaction that "leads" and will determine
|
* Gets the transaction that determines the transaction that "leads" and will determine
|
||||||
* the currency to be used by all transactions, and the journal itself.
|
* the currency to be used by all transactions, and the journal itself.
|
||||||
*
|
*
|
||||||
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
|
|
||||||
* @param TransactionJournal $journal
|
* @param TransactionJournal $journal
|
||||||
|
*
|
||||||
* @return Transaction|null
|
* @return Transaction|null
|
||||||
*/
|
*/
|
||||||
private function getLeadTransaction(TransactionJournal $journal): ?Transaction
|
private function getLeadTransaction(TransactionJournal $journal): ?Transaction
|
||||||
@@ -282,4 +283,4 @@ class OtherCurrenciesCorrections extends Command
|
|||||||
|
|
||||||
return $lead;
|
return $lead;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
declare(strict_types=1);
|
||||||
/**
|
/**
|
||||||
* RenameAccountMeta.php
|
* RenameAccountMeta.php
|
||||||
* Copyright (c) 2019 thegrumpydictator@gmail.com
|
* Copyright (c) 2019 thegrumpydictator@gmail.com
|
||||||
|
@@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
declare(strict_types=1);
|
||||||
/**
|
/**
|
||||||
* TransactionIdentifier.php
|
* TransactionIdentifier.php
|
||||||
* Copyright (c) 2019 thegrumpydictator@gmail.com
|
* Copyright (c) 2019 thegrumpydictator@gmail.com
|
||||||
|
@@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
declare(strict_types=1);
|
||||||
/**
|
/**
|
||||||
* TransferCurrenciesCorrections.php
|
* TransferCurrenciesCorrections.php
|
||||||
* Copyright (c) 2019 thegrumpydictator@gmail.com
|
* Copyright (c) 2019 thegrumpydictator@gmail.com
|
||||||
@@ -147,6 +148,7 @@ class TransferCurrenciesCorrections extends Command
|
|||||||
if (isset($this->accountCurrencies[$accountId]) && $this->accountCurrencies[$accountId] instanceof TransactionCurrency) {
|
if (isset($this->accountCurrencies[$accountId]) && $this->accountCurrencies[$accountId] instanceof TransactionCurrency) {
|
||||||
return $this->accountCurrencies[$accountId]; // @codeCoverageIgnore
|
return $this->accountCurrencies[$accountId]; // @codeCoverageIgnore
|
||||||
}
|
}
|
||||||
|
// TODO we can use getAccountCurrency() instead
|
||||||
$currencyId = (int)$this->accountRepos->getMetaValue($account, 'currency_id');
|
$currencyId = (int)$this->accountRepos->getMetaValue($account, 'currency_id');
|
||||||
$result = $this->currencyRepos->findNull($currencyId);
|
$result = $this->currencyRepos->findNull($currencyId);
|
||||||
if (null === $result) {
|
if (null === $result) {
|
||||||
@@ -290,8 +292,6 @@ class TransferCurrenciesCorrections extends Command
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
|
|
||||||
*
|
|
||||||
* @param TransactionJournal $transfer
|
* @param TransactionJournal $transfer
|
||||||
*/
|
*/
|
||||||
private function updateTransferCurrency(TransactionJournal $transfer): void
|
private function updateTransferCurrency(TransactionJournal $transfer): void
|
||||||
@@ -575,4 +575,4 @@ class TransferCurrenciesCorrections extends Command
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
declare(strict_types=1);
|
||||||
/**
|
/**
|
||||||
* UpgradeDatabase.php
|
* UpgradeDatabase.php
|
||||||
* Copyright (c) 2019 thegrumpydictator@gmail.com
|
* Copyright (c) 2019 thegrumpydictator@gmail.com
|
||||||
@@ -52,6 +53,7 @@ class UpgradeDatabase extends Command
|
|||||||
*/
|
*/
|
||||||
public function handle(): int
|
public function handle(): int
|
||||||
{
|
{
|
||||||
|
|
||||||
$this->callInitialCommands();
|
$this->callInitialCommands();
|
||||||
|
|
||||||
|
|
||||||
@@ -70,7 +72,7 @@ class UpgradeDatabase extends Command
|
|||||||
'firefly-iii:back-to-journals',
|
'firefly-iii:back-to-journals',
|
||||||
'firefly-iii:rename-account-meta',
|
'firefly-iii:rename-account-meta',
|
||||||
|
|
||||||
// there are 13 verify commands.
|
// there are 14 verify commands.
|
||||||
'firefly-iii:fix-piggies',
|
'firefly-iii:fix-piggies',
|
||||||
'firefly-iii:create-link-types',
|
'firefly-iii:create-link-types',
|
||||||
'firefly-iii:create-access-tokens',
|
'firefly-iii:create-access-tokens',
|
||||||
@@ -84,6 +86,7 @@ class UpgradeDatabase extends Command
|
|||||||
'firefly-iii:delete-empty-groups',
|
'firefly-iii:delete-empty-groups',
|
||||||
'firefly-iii:fix-account-types',
|
'firefly-iii:fix-account-types',
|
||||||
'firefly-iii:rename-meta-fields',
|
'firefly-iii:rename-meta-fields',
|
||||||
|
'firefly-iii:fix-ob-currencies',
|
||||||
|
|
||||||
// two report commands
|
// two report commands
|
||||||
'firefly-iii:report-empty-objects',
|
'firefly-iii:report-empty-objects',
|
||||||
@@ -102,8 +105,8 @@ class UpgradeDatabase extends Command
|
|||||||
$result = Artisan::output();
|
$result = Artisan::output();
|
||||||
echo $result;
|
echo $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
// set new DB version.
|
// set new DB version.
|
||||||
|
app('fireflyconfig')->set('db_version', (int)config('firefly.db_version'));
|
||||||
// index will set FF3 version.
|
// index will set FF3 version.
|
||||||
app('fireflyconfig')->set('ff3_version', (string)config('firefly.version'));
|
app('fireflyconfig')->set('ff3_version', (string)config('firefly.version'));
|
||||||
|
|
||||||
@@ -112,8 +115,21 @@ class UpgradeDatabase extends Command
|
|||||||
|
|
||||||
private function callInitialCommands(): void
|
private function callInitialCommands(): void
|
||||||
{
|
{
|
||||||
Artisan::call('migrate', ['--seed' => true]);
|
$this->line('Now seeding the database...');
|
||||||
|
Artisan::call('migrate', ['--seed' => true, '--force' => true]);
|
||||||
|
$result = Artisan::output();
|
||||||
|
echo $result;
|
||||||
|
|
||||||
|
$this->line('Now decrypting the database (if necessary)...');
|
||||||
Artisan::call('firefly-iii:decrypt-all');
|
Artisan::call('firefly-iii:decrypt-all');
|
||||||
|
$result = Artisan::output();
|
||||||
|
echo $result;
|
||||||
|
|
||||||
|
$this->line('Now installing OAuth2 keys...');
|
||||||
Artisan::call('passport:install');
|
Artisan::call('passport:install');
|
||||||
|
$result = Artisan::output();
|
||||||
|
echo $result;
|
||||||
|
|
||||||
|
$this->line('Done!');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -60,8 +60,8 @@ class RequestedReportOnJournals
|
|||||||
{
|
{
|
||||||
use Dispatchable, InteractsWithSockets, SerializesModels;
|
use Dispatchable, InteractsWithSockets, SerializesModels;
|
||||||
|
|
||||||
/** @var Collection The journals to report on. */
|
/** @var Collection The transaction groups to report on. */
|
||||||
public $journals;
|
public $groups;
|
||||||
/** @var int The ID of the user. */
|
/** @var int The ID of the user. */
|
||||||
public $userId;
|
public $userId;
|
||||||
|
|
||||||
@@ -69,13 +69,13 @@ class RequestedReportOnJournals
|
|||||||
* Create a new event instance.
|
* Create a new event instance.
|
||||||
*
|
*
|
||||||
* @param int $userId
|
* @param int $userId
|
||||||
* @param Collection $journals
|
* @param Collection $groups
|
||||||
*/
|
*/
|
||||||
public function __construct(int $userId, Collection $journals)
|
public function __construct(int $userId, Collection $groups)
|
||||||
{
|
{
|
||||||
Log::debug('In event RequestedReportOnJournals.');
|
Log::debug('In event RequestedReportOnJournals.');
|
||||||
$this->userId = $userId;
|
$this->userId = $userId;
|
||||||
$this->journals = $journals;
|
$this->groups = $groups;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -36,16 +36,15 @@ class StoredTransactionGroup extends Event
|
|||||||
{
|
{
|
||||||
use SerializesModels;
|
use SerializesModels;
|
||||||
|
|
||||||
|
public $applyRules;
|
||||||
/** @var TransactionGroup The group that was stored. */
|
/** @var TransactionGroup The group that was stored. */
|
||||||
public $transactionGroup;
|
public $transactionGroup;
|
||||||
|
|
||||||
public $applyRules;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new event instance.
|
* Create a new event instance.
|
||||||
*
|
*
|
||||||
* @param TransactionGroup $transactionGroup
|
* @param TransactionGroup $transactionGroup
|
||||||
* @param bool $applyRules
|
* @param bool $applyRules
|
||||||
*/
|
*/
|
||||||
public function __construct(TransactionGroup $transactionGroup, bool $applyRules = true)
|
public function __construct(TransactionGroup $transactionGroup, bool $applyRules = true)
|
||||||
{
|
{
|
||||||
|
@@ -29,6 +29,7 @@ use Illuminate\Queue\SerializesModels;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Class UpdatedTransactionGroup.
|
* Class UpdatedTransactionGroup.
|
||||||
|
*
|
||||||
* @codeCoverageIgnore
|
* @codeCoverageIgnore
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
@@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
declare(strict_types=1);
|
||||||
/**
|
/**
|
||||||
* GracefulNotFoundHandler.php
|
* GracefulNotFoundHandler.php
|
||||||
* Copyright (c) 2019 thegrumpydictator@gmail.com
|
* Copyright (c) 2019 thegrumpydictator@gmail.com
|
||||||
@@ -43,9 +44,7 @@ class GracefulNotFoundHandler extends ExceptionHandler
|
|||||||
*
|
*
|
||||||
* @param Request $request
|
* @param Request $request
|
||||||
* @param Exception $exception
|
* @param Exception $exception
|
||||||
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
|
*
|
||||||
* @SuppressWarnings(PHPMD.NPathComplexity)
|
|
||||||
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
|
|
||||||
*
|
*
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
@@ -225,4 +224,4 @@ class GracefulNotFoundHandler extends ExceptionHandler
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -48,9 +48,7 @@ class Handler extends ExceptionHandler
|
|||||||
*
|
*
|
||||||
* @param Request $request
|
* @param Request $request
|
||||||
* @param Exception $exception
|
* @param Exception $exception
|
||||||
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
|
*
|
||||||
* @SuppressWarnings(PHPMD.NPathComplexity)
|
|
||||||
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
|
|
||||||
*
|
*
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
@@ -112,7 +110,7 @@ class Handler extends ExceptionHandler
|
|||||||
*
|
*
|
||||||
* This is a great spot to send exceptions to Sentry etc.
|
* This is a great spot to send exceptions to Sentry etc.
|
||||||
*
|
*
|
||||||
* @SuppressWarnings(PHPMD.CyclomaticComplexity) // it's five its fine.
|
* // it's five its fine.
|
||||||
*
|
*
|
||||||
* @param Exception $exception
|
* @param Exception $exception
|
||||||
*
|
*
|
||||||
|
@@ -189,7 +189,7 @@ class AccountFactory
|
|||||||
* @param null|string $accountType
|
* @param null|string $accountType
|
||||||
*
|
*
|
||||||
* @return AccountType|null
|
* @return AccountType|null
|
||||||
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
|
*
|
||||||
*/
|
*/
|
||||||
protected function getAccountType(?int $accountTypeId, ?string $accountType): ?AccountType
|
protected function getAccountType(?int $accountTypeId, ?string $accountType): ?AccountType
|
||||||
{
|
{
|
||||||
|
@@ -26,7 +26,6 @@ namespace FireflyIII\Factory;
|
|||||||
|
|
||||||
use FireflyIII\Models\Budget;
|
use FireflyIII\Models\Budget;
|
||||||
use FireflyIII\User;
|
use FireflyIII\User;
|
||||||
use Illuminate\Support\Collection;
|
|
||||||
use Log;
|
use Log;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -53,7 +52,7 @@ class BudgetFactory
|
|||||||
* @param null|string $budgetName
|
* @param null|string $budgetName
|
||||||
*
|
*
|
||||||
* @return Budget|null
|
* @return Budget|null
|
||||||
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
|
*
|
||||||
*/
|
*/
|
||||||
public function find(?int $budgetId, ?string $budgetName): ?Budget
|
public function find(?int $budgetId, ?string $budgetName): ?Budget
|
||||||
{
|
{
|
||||||
|
@@ -26,7 +26,6 @@ namespace FireflyIII\Factory;
|
|||||||
|
|
||||||
use FireflyIII\Models\Category;
|
use FireflyIII\Models\Category;
|
||||||
use FireflyIII\User;
|
use FireflyIII\User;
|
||||||
use Illuminate\Support\Collection;
|
|
||||||
use Log;
|
use Log;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -63,7 +62,7 @@ class CategoryFactory
|
|||||||
* @param null|string $categoryName
|
* @param null|string $categoryName
|
||||||
*
|
*
|
||||||
* @return Category|null
|
* @return Category|null
|
||||||
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
|
*
|
||||||
*/
|
*/
|
||||||
public function findOrCreate(?int $categoryId, ?string $categoryName): ?Category
|
public function findOrCreate(?int $categoryId, ?string $categoryName): ?Category
|
||||||
{
|
{
|
||||||
|
@@ -53,7 +53,7 @@ class PiggyBankEventFactory
|
|||||||
* @param PiggyBank|null $piggyBank
|
* @param PiggyBank|null $piggyBank
|
||||||
*
|
*
|
||||||
* @return PiggyBankEvent|null
|
* @return PiggyBankEvent|null
|
||||||
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
|
*
|
||||||
*/
|
*/
|
||||||
public function create(TransactionJournal $journal, ?PiggyBank $piggyBank): ?PiggyBankEvent
|
public function create(TransactionJournal $journal, ?PiggyBank $piggyBank): ?PiggyBankEvent
|
||||||
{
|
{
|
||||||
|
@@ -52,7 +52,7 @@ class PiggyBankFactory
|
|||||||
* @param null|string $piggyBankName
|
* @param null|string $piggyBankName
|
||||||
*
|
*
|
||||||
* @return PiggyBank|null
|
* @return PiggyBank|null
|
||||||
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
|
*
|
||||||
*/
|
*/
|
||||||
public function find(?int $piggyBankId, ?string $piggyBankName): ?PiggyBank
|
public function find(?int $piggyBankId, ?string $piggyBankName): ?PiggyBank
|
||||||
{
|
{
|
||||||
|
@@ -79,7 +79,7 @@ class TransactionCurrencyFactory
|
|||||||
* @param null|string $currencyCode
|
* @param null|string $currencyCode
|
||||||
*
|
*
|
||||||
* @return TransactionCurrency|null
|
* @return TransactionCurrency|null
|
||||||
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
|
*
|
||||||
*/
|
*/
|
||||||
public function find(?int $currencyId, ?string $currencyCode): ?TransactionCurrency
|
public function find(?int $currencyId, ?string $currencyCode): ?TransactionCurrency
|
||||||
{
|
{
|
||||||
|
@@ -23,9 +23,7 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace FireflyIII\Factory;
|
namespace FireflyIII\Factory;
|
||||||
|
|
||||||
use FireflyIII\Exceptions\FireflyException;
|
|
||||||
use FireflyIII\Models\TransactionGroup;
|
use FireflyIII\Models\TransactionGroup;
|
||||||
use FireflyIII\Models\TransactionJournal;
|
|
||||||
use FireflyIII\User;
|
use FireflyIII\User;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -60,10 +58,8 @@ class TransactionGroupFactory
|
|||||||
$collection = $this->journalFactory->create($data);
|
$collection = $this->journalFactory->create($data);
|
||||||
$title = $data['group_title'] ?? null;
|
$title = $data['group_title'] ?? null;
|
||||||
$title = '' === $title ? null : $title;
|
$title = '' === $title ? null : $title;
|
||||||
/** @var TransactionJournal $first */
|
$group = new TransactionGroup;
|
||||||
$first = $collection->first();
|
$group->user()->associate($this->user);
|
||||||
$group = new TransactionGroup;
|
|
||||||
$group->user()->associate($first->user);
|
|
||||||
$group->title = $title;
|
$group->title = $title;
|
||||||
$group->save();
|
$group->save();
|
||||||
|
|
||||||
@@ -81,4 +77,4 @@ class TransactionGroupFactory
|
|||||||
{
|
{
|
||||||
$this->user = $user;
|
$this->user = $user;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -143,6 +143,9 @@ class TransactionJournalFactory
|
|||||||
if (null !== $journal) {
|
if (null !== $journal) {
|
||||||
$collection->push($journal);
|
$collection->push($journal);
|
||||||
}
|
}
|
||||||
|
if(null === $journal) {
|
||||||
|
Log::error('The createJournal() method returned NULL. This may indicate an error.');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $collection;
|
return $collection;
|
||||||
@@ -247,6 +250,7 @@ class TransactionJournalFactory
|
|||||||
$destinationAccount = $this->getAccount($type->type, 'destination', (int)$row['destination_id'], $row['destination_name']);
|
$destinationAccount = $this->getAccount($type->type, 'destination', (int)$row['destination_id'], $row['destination_name']);
|
||||||
// @codeCoverageIgnoreStart
|
// @codeCoverageIgnoreStart
|
||||||
} catch (FireflyException $e) {
|
} catch (FireflyException $e) {
|
||||||
|
Log::error('Could not validate source or destination.');
|
||||||
Log::error($e->getMessage());
|
Log::error($e->getMessage());
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
@@ -293,9 +297,9 @@ class TransactionJournalFactory
|
|||||||
$foreignCurrency = $this->getCurrency($foreignCurrency, $destinationAccount);
|
$foreignCurrency = $this->getCurrency($foreignCurrency, $destinationAccount);
|
||||||
|
|
||||||
$sourceCurrency = $currency;
|
$sourceCurrency = $currency;
|
||||||
$destCurrency = $foreignCurrency;
|
$destCurrency = $currency;
|
||||||
$sourceForeignCurrency = $foreignCurrency;
|
$sourceForeignCurrency = $foreignCurrency;
|
||||||
$destForeignCurrency = $currency;
|
$destForeignCurrency = $foreignCurrency;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Create a basic journal. */
|
/** Create a basic journal. */
|
||||||
|
@@ -49,8 +49,6 @@ class TransactionJournalMetaFactory
|
|||||||
* @param array $data
|
* @param array $data
|
||||||
*
|
*
|
||||||
* @return TransactionJournalMeta|null
|
* @return TransactionJournalMeta|null
|
||||||
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
|
|
||||||
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
|
|
||||||
*/
|
*/
|
||||||
public function updateOrCreate(array $data): ?TransactionJournalMeta
|
public function updateOrCreate(array $data): ?TransactionJournalMeta
|
||||||
{
|
{
|
||||||
|
@@ -109,7 +109,7 @@ class ChartJsGenerator implements GeneratorInterface
|
|||||||
* ]
|
* ]
|
||||||
* ]
|
* ]
|
||||||
*
|
*
|
||||||
* @SuppressWarnings(PHPMD.CyclomaticComplexity) // it's five.
|
* // it's five.
|
||||||
*
|
*
|
||||||
* @param array $data
|
* @param array $data
|
||||||
*
|
*
|
||||||
|
@@ -60,7 +60,7 @@ interface GeneratorInterface
|
|||||||
* ]
|
* ]
|
||||||
* ]
|
* ]
|
||||||
*
|
*
|
||||||
* @SuppressWarnings(PHPMD.CyclomaticComplexity) // it's five.
|
* // it's five.
|
||||||
*
|
*
|
||||||
* @param array $data
|
* @param array $data
|
||||||
*
|
*
|
||||||
|
@@ -24,7 +24,6 @@ namespace FireflyIII\Generator\Report\Standard;
|
|||||||
|
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use FireflyIII\Generator\Report\ReportGeneratorInterface;
|
use FireflyIII\Generator\Report\ReportGeneratorInterface;
|
||||||
use FireflyIII\Helpers\Report\ReportHelperInterface;
|
|
||||||
use Illuminate\Support\Collection;
|
use Illuminate\Support\Collection;
|
||||||
use Log;
|
use Log;
|
||||||
use Throwable;
|
use Throwable;
|
||||||
@@ -50,17 +49,11 @@ class MonthReportGenerator implements ReportGeneratorInterface
|
|||||||
*/
|
*/
|
||||||
public function generate(): string
|
public function generate(): string
|
||||||
{
|
{
|
||||||
/** @var ReportHelperInterface $helper */
|
|
||||||
$helper = app(ReportHelperInterface::class);
|
|
||||||
$bills = $helper->getBillReport($this->start, $this->end, $this->accounts);
|
|
||||||
$accountIds = implode(',', $this->accounts->pluck('id')->toArray());
|
$accountIds = implode(',', $this->accounts->pluck('id')->toArray());
|
||||||
$reportType = 'default';
|
$reportType = 'default';
|
||||||
|
|
||||||
try {
|
try {
|
||||||
return view(
|
return view('reports.default.month', compact('accountIds', 'reportType'))->with('start', $this->start)->with('end', $this->end)->render();
|
||||||
'reports.default.month',
|
|
||||||
compact('bills', 'accountIds', 'reportType')
|
|
||||||
)->with('start', $this->start)->with('end', $this->end)->render();
|
|
||||||
} catch (Throwable $e) {
|
} catch (Throwable $e) {
|
||||||
Log::error(sprintf('Cannot render reports.default.month: %s', $e->getMessage()));
|
Log::error(sprintf('Cannot render reports.default.month: %s', $e->getMessage()));
|
||||||
$result = 'Could not render report view.';
|
$result = 'Could not render report view.';
|
||||||
|
@@ -112,7 +112,7 @@ class Support
|
|||||||
/**
|
/**
|
||||||
* Summarize collection by earned and spent data.
|
* Summarize collection by earned and spent data.
|
||||||
*
|
*
|
||||||
* @SuppressWarnings(PHPMD.CyclomaticComplexity) // it's exactly five.
|
* // it's exactly five.
|
||||||
*
|
*
|
||||||
* @param array $spent
|
* @param array $spent
|
||||||
* @param array $earned
|
* @param array $earned
|
||||||
|
@@ -55,10 +55,10 @@ class AutomationHandler
|
|||||||
/** @var UserRepositoryInterface $repository */
|
/** @var UserRepositoryInterface $repository */
|
||||||
$repository = app(UserRepositoryInterface::class);
|
$repository = app(UserRepositoryInterface::class);
|
||||||
$user = $repository->findNull($event->userId);
|
$user = $repository->findNull($event->userId);
|
||||||
if (null !== $user && 0 !== $event->journals->count()) {
|
if (null !== $user && 0 !== $event->groups->count()) {
|
||||||
try {
|
try {
|
||||||
Log::debug('Trying to mail...');
|
Log::debug('Trying to mail...');
|
||||||
Mail::to($user->email)->send(new ReportNewJournalsMail($user->email, '127.0.0.1', $event->journals));
|
Mail::to($user->email)->send(new ReportNewJournalsMail($user->email, '127.0.0.1', $event->groups));
|
||||||
// @codeCoverageIgnoreStart
|
// @codeCoverageIgnoreStart
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
Log::debug('Send message failed! :(');
|
Log::debug('Send message failed! :(');
|
||||||
|
@@ -43,9 +43,7 @@ class VersionCheckEventHandler
|
|||||||
/**
|
/**
|
||||||
* Checks with GitHub to see if there is a new version.
|
* Checks with GitHub to see if there is a new version.
|
||||||
*
|
*
|
||||||
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
|
*
|
||||||
* @SuppressWarnings(PHPMD.NPathComplexity)
|
|
||||||
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
|
|
||||||
* @param RequestedVersionCheckStatus $event
|
* @param RequestedVersionCheckStatus $event
|
||||||
*/
|
*/
|
||||||
public function checkForUpdates(RequestedVersionCheckStatus $event): void
|
public function checkForUpdates(RequestedVersionCheckStatus $event): void
|
||||||
|
@@ -98,7 +98,7 @@ class MetaPieChart implements MetaPieChartInterface
|
|||||||
* @param string $group
|
* @param string $group
|
||||||
*
|
*
|
||||||
* @return array
|
* @return array
|
||||||
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
|
*
|
||||||
*/
|
*/
|
||||||
public function generate(string $direction, string $group): array
|
public function generate(string $direction, string $group): array
|
||||||
{
|
{
|
||||||
@@ -181,8 +181,6 @@ class MetaPieChart implements MetaPieChartInterface
|
|||||||
*
|
*
|
||||||
* @return array
|
* @return array
|
||||||
*
|
*
|
||||||
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
|
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
protected function groupByFields(array $array, array $fields): array
|
protected function groupByFields(array $array, array $fields): array
|
||||||
{
|
{
|
||||||
|
@@ -1,97 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* Balance.php
|
|
||||||
* Copyright (c) 2017 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\Collection;
|
|
||||||
|
|
||||||
use Illuminate\Support\Collection;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Class Balance.
|
|
||||||
*
|
|
||||||
* @codeCoverageIgnore
|
|
||||||
*/
|
|
||||||
class Balance
|
|
||||||
{
|
|
||||||
/** @var BalanceHeader Header row. */
|
|
||||||
protected $balanceHeader;
|
|
||||||
|
|
||||||
/** @var Collection Collection of lines. */
|
|
||||||
protected $balanceLines;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Balance constructor.
|
|
||||||
*/
|
|
||||||
public function __construct()
|
|
||||||
{
|
|
||||||
$this->balanceLines = new Collection;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Add a line.
|
|
||||||
*
|
|
||||||
* @param BalanceLine $line
|
|
||||||
*/
|
|
||||||
public function addBalanceLine(BalanceLine $line): void
|
|
||||||
{
|
|
||||||
$this->balanceLines->push($line);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the header.
|
|
||||||
*
|
|
||||||
* @return BalanceHeader
|
|
||||||
*/
|
|
||||||
public function getBalanceHeader(): BalanceHeader
|
|
||||||
{
|
|
||||||
return $this->balanceHeader ?? new BalanceHeader;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set the header.
|
|
||||||
*
|
|
||||||
* @param BalanceHeader $balanceHeader
|
|
||||||
*/
|
|
||||||
public function setBalanceHeader(BalanceHeader $balanceHeader): void
|
|
||||||
{
|
|
||||||
$this->balanceHeader = $balanceHeader;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get all lines.
|
|
||||||
*
|
|
||||||
* @return Collection
|
|
||||||
*/
|
|
||||||
public function getBalanceLines(): Collection
|
|
||||||
{
|
|
||||||
return $this->balanceLines;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set all lines.
|
|
||||||
*
|
|
||||||
* @param Collection $balanceLines
|
|
||||||
*/
|
|
||||||
public function setBalanceLines(Collection $balanceLines): void
|
|
||||||
{
|
|
||||||
$this->balanceLines = $balanceLines;
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,100 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* BalanceEntry.php
|
|
||||||
* Copyright (c) 2017 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\Collection;
|
|
||||||
|
|
||||||
use FireflyIII\Models\Account as AccountModel;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Class BalanceEntry.
|
|
||||||
*
|
|
||||||
* @codeCoverageIgnore
|
|
||||||
*/
|
|
||||||
class BalanceEntry
|
|
||||||
{
|
|
||||||
/** @var AccountModel The account. */
|
|
||||||
protected $account;
|
|
||||||
/** @var string The amount left. */
|
|
||||||
protected $left = '0';
|
|
||||||
/** @var string The amount spent. */
|
|
||||||
protected $spent = '0';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Account getter.
|
|
||||||
*
|
|
||||||
* @return AccountModel
|
|
||||||
*/
|
|
||||||
public function getAccount(): AccountModel
|
|
||||||
{
|
|
||||||
return $this->account;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Account setter.
|
|
||||||
*
|
|
||||||
* @param AccountModel $account
|
|
||||||
*/
|
|
||||||
public function setAccount(AccountModel $account): void
|
|
||||||
{
|
|
||||||
$this->account = $account;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get amount left.
|
|
||||||
*
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public function getLeft(): string
|
|
||||||
{
|
|
||||||
return $this->left;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set amount left.
|
|
||||||
*
|
|
||||||
* @param string $left
|
|
||||||
*/
|
|
||||||
public function setLeft(string $left): void
|
|
||||||
{
|
|
||||||
$this->left = $left;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get amount spent.
|
|
||||||
*
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public function getSpent(): string
|
|
||||||
{
|
|
||||||
return $this->spent;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set amount spent.
|
|
||||||
*
|
|
||||||
* @param string $spent
|
|
||||||
*/
|
|
||||||
public function setSpent(string $spent): void
|
|
||||||
{
|
|
||||||
$this->spent = $spent;
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,65 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* BalanceHeader.php
|
|
||||||
* Copyright (c) 2017 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\Collection;
|
|
||||||
|
|
||||||
use FireflyIII\Models\Account as AccountModel;
|
|
||||||
use Illuminate\Support\Collection;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Class BalanceHeader.
|
|
||||||
*
|
|
||||||
* @codeCoverageIgnore
|
|
||||||
*/
|
|
||||||
class BalanceHeader
|
|
||||||
{
|
|
||||||
/** @var Collection The accounts. */
|
|
||||||
protected $accounts;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* BalanceHeader constructor.
|
|
||||||
*/
|
|
||||||
public function __construct()
|
|
||||||
{
|
|
||||||
$this->accounts = new Collection;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Add an account.
|
|
||||||
*
|
|
||||||
* @param AccountModel $account
|
|
||||||
*/
|
|
||||||
public function addAccount(AccountModel $account): void
|
|
||||||
{
|
|
||||||
$this->accounts->push($account);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get them all.
|
|
||||||
*
|
|
||||||
* @return Collection
|
|
||||||
*/
|
|
||||||
public function getAccounts(): Collection
|
|
||||||
{
|
|
||||||
return $this->accounts;
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,189 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* BalanceLine.php
|
|
||||||
* Copyright (c) 2017 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\Collection;
|
|
||||||
|
|
||||||
use Carbon\Carbon;
|
|
||||||
use FireflyIII\Models\Budget as BudgetModel;
|
|
||||||
use FireflyIII\Models\BudgetLimit;
|
|
||||||
use Illuminate\Support\Collection;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Class BalanceLine.
|
|
||||||
*
|
|
||||||
* @codeCoverageIgnore
|
|
||||||
*/
|
|
||||||
class BalanceLine
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public const ROLE_DEFAULTROLE = 1;
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public const ROLE_TAGROLE = 2;
|
|
||||||
|
|
||||||
/** @var Collection */
|
|
||||||
protected $balanceEntries;
|
|
||||||
|
|
||||||
/** @var BudgetModel */
|
|
||||||
protected $budget;
|
|
||||||
/** @var BudgetLimit */
|
|
||||||
protected $budgetLimit;
|
|
||||||
/** @var int */
|
|
||||||
protected $role = self::ROLE_DEFAULTROLE;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public function __construct()
|
|
||||||
{
|
|
||||||
$this->balanceEntries = new Collection;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param BalanceEntry $balanceEntry
|
|
||||||
*/
|
|
||||||
public function addBalanceEntry(BalanceEntry $balanceEntry): void
|
|
||||||
{
|
|
||||||
$this->balanceEntries->push($balanceEntry);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return Collection
|
|
||||||
*/
|
|
||||||
public function getBalanceEntries(): Collection
|
|
||||||
{
|
|
||||||
return $this->balanceEntries;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param Collection $balanceEntries
|
|
||||||
*/
|
|
||||||
public function setBalanceEntries(Collection $balanceEntries): void
|
|
||||||
{
|
|
||||||
$this->balanceEntries = $balanceEntries;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return BudgetModel
|
|
||||||
*/
|
|
||||||
public function getBudget(): BudgetModel
|
|
||||||
{
|
|
||||||
return $this->budget ?? new BudgetModel;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param BudgetModel $budget
|
|
||||||
*/
|
|
||||||
public function setBudget(BudgetModel $budget): void
|
|
||||||
{
|
|
||||||
$this->budget = $budget;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return BudgetLimit
|
|
||||||
*/
|
|
||||||
public function getBudgetLimit(): BudgetLimit
|
|
||||||
{
|
|
||||||
return $this->budgetLimit;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param BudgetLimit $budgetLimit
|
|
||||||
*/
|
|
||||||
public function setBudgetLimit(BudgetLimit $budgetLimit): void
|
|
||||||
{
|
|
||||||
$this->budgetLimit = $budgetLimit;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return Carbon
|
|
||||||
*/
|
|
||||||
public function getEndDate(): Carbon
|
|
||||||
{
|
|
||||||
return $this->budgetLimit->end_date ?? new Carbon;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return int
|
|
||||||
*/
|
|
||||||
public function getRole(): int
|
|
||||||
{
|
|
||||||
return $this->role;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param int $role
|
|
||||||
*/
|
|
||||||
public function setRole(int $role): void
|
|
||||||
{
|
|
||||||
$this->role = $role;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return Carbon
|
|
||||||
*/
|
|
||||||
public function getStartDate(): Carbon
|
|
||||||
{
|
|
||||||
return $this->budgetLimit->start_date ?? new Carbon;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public function getTitle(): string
|
|
||||||
{
|
|
||||||
$title = '';
|
|
||||||
if ($this->getBudget() instanceof BudgetModel && null !== $this->getBudget()->id) {
|
|
||||||
$title = $this->getBudget()->name;
|
|
||||||
}
|
|
||||||
if ('' === $title && self::ROLE_DEFAULTROLE === $this->getRole()) {
|
|
||||||
$title = (string)trans('firefly.no_budget');
|
|
||||||
}
|
|
||||||
if ('' === $title && self::ROLE_TAGROLE === $this->getRole()) {
|
|
||||||
$title = (string)trans('firefly.coveredWithTags');
|
|
||||||
}
|
|
||||||
|
|
||||||
return $title;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* If a BalanceLine has a budget/repetition, each BalanceEntry in this BalanceLine
|
|
||||||
* should have a "spent" value, which is the amount of money that has been spent
|
|
||||||
* on the given budget/repetition. If you subtract all those amounts from the budget/repetition's
|
|
||||||
* total amount, this is returned:.
|
|
||||||
*
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public function leftOfRepetition(): string
|
|
||||||
{
|
|
||||||
$start = $this->budgetLimit->amount ?? '0';
|
|
||||||
/** @var BalanceEntry $balanceEntry */
|
|
||||||
foreach ($this->getBalanceEntries() as $balanceEntry) {
|
|
||||||
$start = bcadd($balanceEntry->getSpent(), $start);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $start;
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,128 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* Bill.php
|
|
||||||
* Copyright (c) 2017 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\Collection;
|
|
||||||
|
|
||||||
use Carbon\Carbon;
|
|
||||||
use FireflyIII\Repositories\Bill\BillRepositoryInterface;
|
|
||||||
use Illuminate\Support\Collection;
|
|
||||||
use Log;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Class Bill.
|
|
||||||
*
|
|
||||||
* @codeCoverageIgnore
|
|
||||||
*/
|
|
||||||
class Bill
|
|
||||||
{
|
|
||||||
/** @var Collection The bills. */
|
|
||||||
private $bills;
|
|
||||||
/** @var Carbon End date of the collection. */
|
|
||||||
private $endDate;
|
|
||||||
/** @var Carbon Start date of the collection. */
|
|
||||||
private $startDate;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Bill constructor.
|
|
||||||
*/
|
|
||||||
public function __construct()
|
|
||||||
{
|
|
||||||
$this->bills = new Collection;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Add a bill line.
|
|
||||||
*
|
|
||||||
* @param BillLine $bill
|
|
||||||
*/
|
|
||||||
public function addBill(BillLine $bill): void
|
|
||||||
{
|
|
||||||
$this->bills->push($bill);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Filter the bills (yes how very descriptive).
|
|
||||||
*/
|
|
||||||
public function filterBills(): void
|
|
||||||
{
|
|
||||||
Log::debug('Now in filterBills()');
|
|
||||||
/** @var BillRepositoryInterface $repository */
|
|
||||||
$repository = app(BillRepositoryInterface::class);
|
|
||||||
$start = $this->startDate;
|
|
||||||
$end = $this->endDate;
|
|
||||||
$lines = $this->bills->filter(
|
|
||||||
function (BillLine $line) use ($repository, $start, $end) {
|
|
||||||
// next expected match?
|
|
||||||
$date = $start;
|
|
||||||
Log::debug(sprintf('Now at bill line for bill "%s"', $line->getBill()->name));
|
|
||||||
Log::debug(sprintf('Default date to use is start date: %s', $date->format('Y-m-d')));
|
|
||||||
if ($line->isHit()) {
|
|
||||||
$date = $line->getLastHitDate();
|
|
||||||
Log::debug(sprintf('Line was hit, see date: %s. Always include it.', $date->format('Y-m-d')));
|
|
||||||
|
|
||||||
return $line;
|
|
||||||
}
|
|
||||||
$expected = $repository->nextExpectedMatch($line->getBill(), $date);
|
|
||||||
Log::debug(sprintf('Next expected match is %s', $expected->format('Y-m-d')));
|
|
||||||
if ($expected <= $end && $expected >= $start) {
|
|
||||||
Log::debug('This date is inside report limits');
|
|
||||||
|
|
||||||
return $line;
|
|
||||||
}
|
|
||||||
Log::debug('This date is OUTSIDE report limits');
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
);
|
|
||||||
$this->bills = $lines;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Bills getter.
|
|
||||||
*
|
|
||||||
* @return Collection
|
|
||||||
*/
|
|
||||||
public function getBills(): Collection
|
|
||||||
{
|
|
||||||
return $this->bills;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* End date setter.
|
|
||||||
*
|
|
||||||
* @param Carbon $endDate
|
|
||||||
*/
|
|
||||||
public function setEndDate(Carbon $endDate): void
|
|
||||||
{
|
|
||||||
$this->endDate = $endDate;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Start date setter.
|
|
||||||
*
|
|
||||||
* @param Carbon $startDate
|
|
||||||
*/
|
|
||||||
public function setStartDate(Carbon $startDate): void
|
|
||||||
{
|
|
||||||
$this->startDate = $startDate;
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,270 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* BillLine.php
|
|
||||||
* Copyright (c) 2017 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\Collection;
|
|
||||||
|
|
||||||
use Carbon\Carbon;
|
|
||||||
use FireflyIII\Models\Bill as BillModel;
|
|
||||||
use FireflyIII\Models\TransactionCurrency;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Class BillLine.
|
|
||||||
*
|
|
||||||
* @codeCoverageIgnore
|
|
||||||
*/
|
|
||||||
class BillLine
|
|
||||||
{
|
|
||||||
/** @var string The amount */
|
|
||||||
protected $amount;
|
|
||||||
/** @var BillModel The bill. */
|
|
||||||
protected $bill;
|
|
||||||
/** @var bool Is it hit this period */
|
|
||||||
protected $hit;
|
|
||||||
/** @var string What was the max amount. */
|
|
||||||
protected $max;
|
|
||||||
/** @var string What was the min amount. */
|
|
||||||
protected $min;
|
|
||||||
/** @var TransactionCurrency The transaction currency */
|
|
||||||
private $currency;
|
|
||||||
/** @var Carbon Latest date that payment is expected. */
|
|
||||||
private $endOfPayDate;
|
|
||||||
/** @var Carbon Date of last hit */
|
|
||||||
private $lastHitDate;
|
|
||||||
/** @var Carbon Date of last payment */
|
|
||||||
private $payDate;
|
|
||||||
/** @var int Journal */
|
|
||||||
private $transactionJournalId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* BillLine constructor.
|
|
||||||
*/
|
|
||||||
public function __construct()
|
|
||||||
{
|
|
||||||
$this->lastHitDate = new Carbon;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Amount getter.
|
|
||||||
*
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public function getAmount(): string
|
|
||||||
{
|
|
||||||
return $this->amount ?? '0';
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Amount setter.
|
|
||||||
*
|
|
||||||
* @param string $amount
|
|
||||||
*/
|
|
||||||
public function setAmount(string $amount): void
|
|
||||||
{
|
|
||||||
$this->amount = $amount;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Bill getter.
|
|
||||||
*
|
|
||||||
* @return BillModel
|
|
||||||
*/
|
|
||||||
public function getBill(): BillModel
|
|
||||||
{
|
|
||||||
return $this->bill;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Bill setter.
|
|
||||||
*
|
|
||||||
* @param BillModel $bill
|
|
||||||
*/
|
|
||||||
public function setBill(BillModel $bill): void
|
|
||||||
{
|
|
||||||
$this->bill = $bill;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return TransactionCurrency
|
|
||||||
*/
|
|
||||||
public function getCurrency(): TransactionCurrency
|
|
||||||
{
|
|
||||||
return $this->currency;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param TransactionCurrency $currency
|
|
||||||
*/
|
|
||||||
public function setCurrency(TransactionCurrency $currency): void
|
|
||||||
{
|
|
||||||
$this->currency = $currency;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* End of pay date getter.
|
|
||||||
*
|
|
||||||
* @return Carbon
|
|
||||||
*/
|
|
||||||
public function getEndOfPayDate(): Carbon
|
|
||||||
{
|
|
||||||
return $this->endOfPayDate;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* End of pay date setter.
|
|
||||||
*
|
|
||||||
* @param Carbon $endOfPayDate
|
|
||||||
*/
|
|
||||||
public function setEndOfPayDate(Carbon $endOfPayDate): void
|
|
||||||
{
|
|
||||||
$this->endOfPayDate = $endOfPayDate;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Last hit date getter.
|
|
||||||
*
|
|
||||||
* @return Carbon
|
|
||||||
*/
|
|
||||||
public function getLastHitDate(): Carbon
|
|
||||||
{
|
|
||||||
return $this->lastHitDate;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Last hit date setter.
|
|
||||||
*
|
|
||||||
* @param Carbon $lastHitDate
|
|
||||||
*/
|
|
||||||
public function setLastHitDate(Carbon $lastHitDate): void
|
|
||||||
{
|
|
||||||
$this->lastHitDate = $lastHitDate;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Max getter.
|
|
||||||
*
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public function getMax(): string
|
|
||||||
{
|
|
||||||
return $this->max;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Max setter.
|
|
||||||
*
|
|
||||||
* @param string $max
|
|
||||||
*/
|
|
||||||
public function setMax(string $max): void
|
|
||||||
{
|
|
||||||
$this->max = $max;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Min getter.
|
|
||||||
*
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public function getMin(): string
|
|
||||||
{
|
|
||||||
return $this->min;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Min setter.
|
|
||||||
*
|
|
||||||
* @param string $min
|
|
||||||
*/
|
|
||||||
public function setMin(string $min): void
|
|
||||||
{
|
|
||||||
$this->min = $min;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Pay date getter.
|
|
||||||
*
|
|
||||||
* @return Carbon
|
|
||||||
*/
|
|
||||||
public function getPayDate(): Carbon
|
|
||||||
{
|
|
||||||
return $this->payDate;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Pay date setter.
|
|
||||||
*
|
|
||||||
* @param Carbon $payDate
|
|
||||||
*/
|
|
||||||
public function setPayDate(Carbon $payDate): void
|
|
||||||
{
|
|
||||||
$this->payDate = $payDate;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Journal ID getter.
|
|
||||||
*
|
|
||||||
* @return int
|
|
||||||
*/
|
|
||||||
public function getTransactionJournalId(): int
|
|
||||||
{
|
|
||||||
return $this->transactionJournalId ?? 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Journal ID setter.
|
|
||||||
*
|
|
||||||
* @param int $transactionJournalId
|
|
||||||
*/
|
|
||||||
public function setTransactionJournalId(int $transactionJournalId): void
|
|
||||||
{
|
|
||||||
$this->transactionJournalId = $transactionJournalId;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Is active.
|
|
||||||
*
|
|
||||||
* @return bool
|
|
||||||
*/
|
|
||||||
public function isActive(): bool
|
|
||||||
{
|
|
||||||
return 1 === (int)$this->bill->active;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Is hit.
|
|
||||||
*
|
|
||||||
* @return bool
|
|
||||||
*/
|
|
||||||
public function isHit(): bool
|
|
||||||
{
|
|
||||||
return $this->hit;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set is hit.
|
|
||||||
*
|
|
||||||
* @param bool $hit
|
|
||||||
*/
|
|
||||||
public function setHit(bool $hit): void
|
|
||||||
{
|
|
||||||
$this->hit = $hit;
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,97 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* Category.php
|
|
||||||
* Copyright (c) 2017 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\Collection;
|
|
||||||
|
|
||||||
use FireflyIII\Models\Category as CategoryModel;
|
|
||||||
use Illuminate\Support\Collection;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Class Category.
|
|
||||||
*
|
|
||||||
* @codeCoverageIgnore
|
|
||||||
*/
|
|
||||||
class Category
|
|
||||||
{
|
|
||||||
/** @var Collection The categories */
|
|
||||||
protected $categories;
|
|
||||||
/** @var string Total amount */
|
|
||||||
protected $total = '0';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Category constructor.
|
|
||||||
*/
|
|
||||||
public function __construct()
|
|
||||||
{
|
|
||||||
$this->categories = new Collection;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Add a category.
|
|
||||||
*
|
|
||||||
* @param CategoryModel $category
|
|
||||||
*/
|
|
||||||
public function addCategory(CategoryModel $category): void
|
|
||||||
{
|
|
||||||
// spent is minus zero for an expense report:
|
|
||||||
if ($category->spent < 0) {
|
|
||||||
$this->categories->push($category);
|
|
||||||
$this->addTotal((string)$category->spent);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Add to the total amount.
|
|
||||||
*
|
|
||||||
* @param string $add
|
|
||||||
*/
|
|
||||||
public function addTotal(string $add): void
|
|
||||||
{
|
|
||||||
$this->total = bcadd($this->total, $add);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get all categories.
|
|
||||||
*
|
|
||||||
* @return Collection
|
|
||||||
*/
|
|
||||||
public function getCategories(): Collection
|
|
||||||
{
|
|
||||||
$set = $this->categories->sortBy(
|
|
||||||
static function (CategoryModel $category) {
|
|
||||||
return $category->spent;
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
return $set;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the total.
|
|
||||||
*
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public function getTotal(): string
|
|
||||||
{
|
|
||||||
return $this->total;
|
|
||||||
}
|
|
||||||
}
|
|
File diff suppressed because it is too large
Load Diff
@@ -46,6 +46,41 @@ interface GroupCollectorInterface
|
|||||||
*/
|
*/
|
||||||
public function getExtractedJournals(): array;
|
public function getExtractedJournals(): array;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set source accounts.
|
||||||
|
*
|
||||||
|
* @param Collection $accounts
|
||||||
|
*
|
||||||
|
* @return GroupCollectorInterface
|
||||||
|
*/
|
||||||
|
public function setSourceAccounts(Collection $accounts): GroupCollectorInterface;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* These accounts must not be source accounts.
|
||||||
|
*
|
||||||
|
* @param Collection $accounts
|
||||||
|
*
|
||||||
|
* @return GroupCollectorInterface
|
||||||
|
*/
|
||||||
|
public function excludeSourceAccounts(Collection $accounts): GroupCollectorInterface;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Exclude destination accounts.
|
||||||
|
* @param Collection $accounts
|
||||||
|
*
|
||||||
|
* @return GroupCollectorInterface
|
||||||
|
*/
|
||||||
|
public function excludeDestinationAccounts(Collection $accounts): GroupCollectorInterface;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set destination accounts.
|
||||||
|
*
|
||||||
|
* @param Collection $accounts
|
||||||
|
*
|
||||||
|
* @return GroupCollectorInterface
|
||||||
|
*/
|
||||||
|
public function setDestinationAccounts(Collection $accounts): GroupCollectorInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the sum of all journals.
|
* Return the sum of all journals.
|
||||||
*
|
*
|
||||||
@@ -341,4 +376,4 @@ interface GroupCollectorInterface
|
|||||||
*/
|
*/
|
||||||
public function withCategoryInformation(): GroupCollectorInterface;
|
public function withCategoryInformation(): GroupCollectorInterface;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -23,11 +23,10 @@ declare(strict_types=1);
|
|||||||
namespace FireflyIII\Helpers\Report;
|
namespace FireflyIII\Helpers\Report;
|
||||||
|
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use FireflyIII\Helpers\Collection\Balance;
|
use FireflyIII\Helpers\Collector\GroupCollectorInterface;
|
||||||
use FireflyIII\Helpers\Collection\BalanceEntry;
|
use FireflyIII\Models\Account;
|
||||||
use FireflyIII\Helpers\Collection\BalanceHeader;
|
use FireflyIII\Models\Budget;
|
||||||
use FireflyIII\Helpers\Collection\BalanceLine;
|
use FireflyIII\Models\TransactionType;
|
||||||
use FireflyIII\Models\BudgetLimit;
|
|
||||||
use FireflyIII\Repositories\Budget\BudgetRepositoryInterface;
|
use FireflyIII\Repositories\Budget\BudgetRepositoryInterface;
|
||||||
use Illuminate\Support\Collection;
|
use Illuminate\Support\Collection;
|
||||||
use Log;
|
use Log;
|
||||||
@@ -44,8 +43,6 @@ class BalanceReportHelper implements BalanceReportHelperInterface
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* ReportHelper constructor.
|
* ReportHelper constructor.
|
||||||
*
|
|
||||||
*
|
|
||||||
* @param BudgetRepositoryInterface $budgetRepository
|
* @param BudgetRepositoryInterface $budgetRepository
|
||||||
*/
|
*/
|
||||||
public function __construct(BudgetRepositoryInterface $budgetRepository)
|
public function __construct(BudgetRepositoryInterface $budgetRepository)
|
||||||
@@ -65,126 +62,78 @@ class BalanceReportHelper implements BalanceReportHelperInterface
|
|||||||
* @param Carbon $start
|
* @param Carbon $start
|
||||||
* @param Carbon $end
|
* @param Carbon $end
|
||||||
*
|
*
|
||||||
* @return Balance
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function getBalanceReport(Collection $accounts, Carbon $start, Carbon $end): Balance
|
public function getBalanceReport(Collection $accounts, Carbon $start, Carbon $end): array
|
||||||
{
|
{
|
||||||
Log::debug('Start of balance report');
|
Log::debug('Start of balance report');
|
||||||
$balance = new Balance;
|
$report = [
|
||||||
$header = new BalanceHeader;
|
'budgets' => [],
|
||||||
$budgetLimits = $this->budgetRepository->getAllBudgetLimits($start, $end);
|
'accounts' => [],
|
||||||
|
];
|
||||||
|
/** @var Account $account */
|
||||||
foreach ($accounts as $account) {
|
foreach ($accounts as $account) {
|
||||||
Log::debug(sprintf('Add account %s to headers.', $account->name));
|
$report['accounts'][$account->id] = [
|
||||||
$header->addAccount($account);
|
'id' => $account->id,
|
||||||
|
'name' => $account->name,
|
||||||
|
'iban' => $account->iban,
|
||||||
|
'sum' => '0',
|
||||||
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @var BudgetLimit $budgetLimit */
|
$budgets = $this->budgetRepository->getBudgets();
|
||||||
foreach ($budgetLimits as $budgetLimit) {
|
|
||||||
if (null !== $budgetLimit->budget) {
|
/** @var Budget $budget */
|
||||||
$line = $this->createBalanceLine($budgetLimit, $accounts);
|
foreach ($budgets as $budget) {
|
||||||
$balance->addBalanceLine($line);
|
$budgetId = $budget->id;
|
||||||
|
$report['budgets'][$budgetId] = [
|
||||||
|
'budget_id' => $budgetId,
|
||||||
|
'budget_name' => $budget->name,
|
||||||
|
'spent' => [], // per account
|
||||||
|
'sums' => [], // per currency
|
||||||
|
];
|
||||||
|
$spent = [];
|
||||||
|
/** @var GroupCollectorInterface $collector */
|
||||||
|
$collector = app(GroupCollectorInterface::class);
|
||||||
|
$journals = $collector->setRange($start, $end)->setSourceAccounts($accounts)->setTypes([TransactionType::WITHDRAWAL])->setBudget($budget)
|
||||||
|
->getExtractedJournals();
|
||||||
|
/** @var array $journal */
|
||||||
|
foreach ($journals as $journal) {
|
||||||
|
$sourceAccount = $journal['source_account_id'];
|
||||||
|
$currencyId = $journal['currency_id'];
|
||||||
|
$spent[$sourceAccount] = $spent[$sourceAccount] ?? [
|
||||||
|
'source_account_id' => $sourceAccount,
|
||||||
|
'currency_id' => $journal['currency_id'],
|
||||||
|
'currency_code' => $journal['currency_code'],
|
||||||
|
'currency_name' => $journal['currency_name'],
|
||||||
|
'currency_symbol' => $journal['currency_symbol'],
|
||||||
|
'currency_decimal_places' => $journal['currency_decimal_places'],
|
||||||
|
'spent' => '0',
|
||||||
|
];
|
||||||
|
$spent[$sourceAccount]['spent'] = bcadd($spent[$sourceAccount]['spent'], $journal['amount']);
|
||||||
|
|
||||||
|
// also fix sum:
|
||||||
|
$report['sums'][$budgetId][$currencyId] = $report['sums'][$budgetId][$currencyId] ?? [
|
||||||
|
'sum' => '0',
|
||||||
|
'currency_id' => $journal['currency_id'],
|
||||||
|
'currency_code' => $journal['currency_code'],
|
||||||
|
'currency_name' => $journal['currency_name'],
|
||||||
|
'currency_symbol' => $journal['currency_symbol'],
|
||||||
|
'currency_decimal_places' => $journal['currency_decimal_places'],
|
||||||
|
];
|
||||||
|
$report['sums'][$budgetId][$currencyId]['sum'] = bcadd($report['sums'][$budgetId][$currencyId]['sum'], $journal['amount']);
|
||||||
|
$report['accounts'][$sourceAccount]['sum'] = bcadd($report['accounts'][$sourceAccount]['sum'], $journal['amount']);
|
||||||
|
|
||||||
|
// add currency info for account sum
|
||||||
|
$report['accounts'][$sourceAccount]['currency_id'] = $journal['currency_id'];
|
||||||
|
$report['accounts'][$sourceAccount]['currency_code'] = $journal['currency_code'];
|
||||||
|
$report['accounts'][$sourceAccount]['currency_name'] = $journal['currency_name'];
|
||||||
|
$report['accounts'][$sourceAccount]['currency_symbol'] = $journal['currency_symbol'];
|
||||||
|
$report['accounts'][$sourceAccount]['currency_decimal_places'] = $journal['currency_decimal_places'];
|
||||||
}
|
}
|
||||||
|
$report['budgets'][$budgetId]['spent'] = $spent;
|
||||||
|
// get transactions in budget
|
||||||
}
|
}
|
||||||
$noBudgetLine = $this->createNoBudgetLine($accounts, $start, $end);
|
return $report;
|
||||||
|
|
||||||
$balance->addBalanceLine($noBudgetLine);
|
|
||||||
$balance->setBalanceHeader($header);
|
|
||||||
|
|
||||||
Log::debug('Clear unused budgets.');
|
|
||||||
// remove budgets without expenses from balance lines:
|
|
||||||
$balance = $this->removeUnusedBudgets($balance);
|
|
||||||
|
|
||||||
Log::debug('Return report.');
|
|
||||||
|
|
||||||
return $balance;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create one balance line.
|
|
||||||
*
|
|
||||||
* @param BudgetLimit $budgetLimit
|
|
||||||
* @param Collection $accounts
|
|
||||||
*
|
|
||||||
* @return BalanceLine
|
|
||||||
*/
|
|
||||||
private function createBalanceLine(BudgetLimit $budgetLimit, Collection $accounts): BalanceLine
|
|
||||||
{
|
|
||||||
$line = new BalanceLine;
|
|
||||||
$line->setBudget($budgetLimit->budget);
|
|
||||||
$line->setBudgetLimit($budgetLimit);
|
|
||||||
|
|
||||||
// loop accounts:
|
|
||||||
foreach ($accounts as $account) {
|
|
||||||
$balanceEntry = new BalanceEntry;
|
|
||||||
$balanceEntry->setAccount($account);
|
|
||||||
$spent = $this->budgetRepository->spentInPeriod(
|
|
||||||
new Collection([$budgetLimit->budget]),
|
|
||||||
new Collection([$account]),
|
|
||||||
$budgetLimit->start_date,
|
|
||||||
$budgetLimit->end_date
|
|
||||||
);
|
|
||||||
$balanceEntry->setSpent($spent);
|
|
||||||
$line->addBalanceEntry($balanceEntry);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $line;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create a line for transactions without a budget.
|
|
||||||
*
|
|
||||||
* @param Collection $accounts
|
|
||||||
* @param Carbon $start
|
|
||||||
* @param Carbon $end
|
|
||||||
*
|
|
||||||
* @return BalanceLine
|
|
||||||
*/
|
|
||||||
private function createNoBudgetLine(Collection $accounts, Carbon $start, Carbon $end): BalanceLine
|
|
||||||
{
|
|
||||||
$empty = new BalanceLine;
|
|
||||||
|
|
||||||
foreach ($accounts as $account) {
|
|
||||||
$spent = $this->budgetRepository->spentInPeriodWoBudget(new Collection([$account]), $start, $end);
|
|
||||||
// budget
|
|
||||||
$budgetEntry = new BalanceEntry;
|
|
||||||
$budgetEntry->setAccount($account);
|
|
||||||
$budgetEntry->setSpent($spent);
|
|
||||||
$empty->addBalanceEntry($budgetEntry);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $empty;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Remove unused budgets from the report.
|
|
||||||
*
|
|
||||||
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
|
|
||||||
* @param Balance $balance
|
|
||||||
*
|
|
||||||
* @return Balance
|
|
||||||
*/
|
|
||||||
private function removeUnusedBudgets(Balance $balance): Balance
|
|
||||||
{
|
|
||||||
$set = $balance->getBalanceLines();
|
|
||||||
$newSet = new Collection;
|
|
||||||
/** @var BalanceLine $entry */
|
|
||||||
foreach ($set as $entry) {
|
|
||||||
if (null !== $entry->getBudget()->id) {
|
|
||||||
$sum = '0';
|
|
||||||
/** @var BalanceEntry $balanceEntry */
|
|
||||||
foreach ($entry->getBalanceEntries() as $balanceEntry) {
|
|
||||||
$sum = bcadd($sum, $balanceEntry->getSpent());
|
|
||||||
}
|
|
||||||
if (bccomp($sum, '0') === -1) {
|
|
||||||
$newSet->push($entry);
|
|
||||||
}
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
$newSet->push($entry);
|
|
||||||
}
|
|
||||||
|
|
||||||
$balance->setBalanceLines($newSet);
|
|
||||||
|
|
||||||
return $balance;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -38,7 +38,7 @@ interface BalanceReportHelperInterface
|
|||||||
* @param Carbon $start
|
* @param Carbon $start
|
||||||
* @param Carbon $end
|
* @param Carbon $end
|
||||||
*
|
*
|
||||||
* @return Balance
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function getBalanceReport(Collection $accounts, Carbon $start, Carbon $end): Balance;
|
public function getBalanceReport(Collection $accounts, Carbon $start, Carbon $end): array;
|
||||||
}
|
}
|
||||||
|
@@ -57,8 +57,8 @@ class BudgetReportHelper implements BudgetReportHelperInterface
|
|||||||
/**
|
/**
|
||||||
* Get the full budget report.
|
* Get the full budget report.
|
||||||
*
|
*
|
||||||
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
|
* TODO one big method is very complex.
|
||||||
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
|
*
|
||||||
* @param Carbon $start
|
* @param Carbon $start
|
||||||
* @param Carbon $end
|
* @param Carbon $end
|
||||||
* @param Collection $accounts
|
* @param Collection $accounts
|
||||||
@@ -68,104 +68,147 @@ class BudgetReportHelper implements BudgetReportHelperInterface
|
|||||||
public function getBudgetReport(Carbon $start, Carbon $end, Collection $accounts): array
|
public function getBudgetReport(Carbon $start, Carbon $end, Collection $accounts): array
|
||||||
{
|
{
|
||||||
$set = $this->repository->getBudgets();
|
$set = $this->repository->getBudgets();
|
||||||
$array = [];
|
$array = [
|
||||||
|
'budgets' => [],
|
||||||
|
'sums' => [],
|
||||||
|
];
|
||||||
|
|
||||||
/** @var Budget $budget */
|
/** @var Budget $budget */
|
||||||
foreach ($set as $budget) {
|
foreach ($set as $budget) {
|
||||||
$budgetLimits = $this->repository->getBudgetLimits($budget, $start, $end);
|
$entry = [
|
||||||
if (0 === $budgetLimits->count()) { // no budget limit(s) for this budget
|
'budget_id' => $budget->id,
|
||||||
$spent = $this->repository->spentInPeriod(new Collection([$budget]), $accounts, $start, $end); // spent for budget in time range
|
'budget_name' => $budget->name,
|
||||||
if (bccomp($spent, '0') === -1) {
|
'no_budget' => false,
|
||||||
$line = [
|
'rows' => [],
|
||||||
'type' => 'budget',
|
];
|
||||||
'id' => $budget->id,
|
// get multi currency expenses first:
|
||||||
'name' => $budget->name,
|
$budgetLimits = $this->repository->getBudgetLimits($budget, $start, $end);
|
||||||
'budgeted' => '0',
|
$expenses = $this->repository->spentInPeriodMc(new Collection([$budget]), $accounts, $start, $end);
|
||||||
'spent' => $spent,
|
$defaultCurrency = app('amount')->getDefaultCurrencyByUser($budget->user);
|
||||||
'left' => '0',
|
Log::debug(sprintf('Default currency for getBudgetReport is %s', $defaultCurrency->code));
|
||||||
'overspent' => '0',
|
if (0 === count($expenses)) {
|
||||||
|
// list the budget limits, basic amounts.
|
||||||
|
/** @var BudgetLimit $limit */
|
||||||
|
foreach ($budgetLimits as $limit) {
|
||||||
|
$currency = $limit->transactionCurrency ?? $defaultCurrency;
|
||||||
|
Log::debug(sprintf('Default currency for limit #%d is %s', $limit->id, $currency->code));
|
||||||
|
$row = [
|
||||||
|
'limit_id' => $limit->id,
|
||||||
|
'start_date' => $limit->start_date,
|
||||||
|
'end_date' => $limit->end_date,
|
||||||
|
'budgeted' => $limit->amount,
|
||||||
|
'spent' => '0',
|
||||||
|
'left' => $limit->amount,
|
||||||
|
'overspent' => null,
|
||||||
|
'currency_id' => $currency->id,
|
||||||
|
'currency_code' => $currency->code,
|
||||||
|
'currency_name' => $currency->name,
|
||||||
|
'currency_symbol' => $currency->symbol,
|
||||||
|
'currency_decimal_places' => $currency->decimal_places,
|
||||||
];
|
];
|
||||||
$array[] = $line;
|
|
||||||
|
$entry['rows'][] = $row;
|
||||||
}
|
}
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
/** @var BudgetLimit $budgetLimit */
|
foreach ($expenses as $expense) {
|
||||||
foreach ($budgetLimits as $budgetLimit) { // one or more repetitions for budget
|
$limit = $this->budgetLimitInCurrency($expense['currency_id'], $budgetLimits);
|
||||||
$data = $this->calculateExpenses($budget, $budgetLimit, $accounts);
|
$row = [
|
||||||
$line = [
|
'limit_id' => null,
|
||||||
'type' => 'budget-line',
|
'start_date' => null,
|
||||||
'start' => $budgetLimit->start_date,
|
'end_date' => null,
|
||||||
'end' => $budgetLimit->end_date,
|
'budgeted' => null,
|
||||||
'limit' => $budgetLimit->id,
|
'spent' => $expense['amount'],
|
||||||
'id' => $budget->id,
|
'left' => null,
|
||||||
'name' => $budget->name,
|
'overspent' => null,
|
||||||
|
'currency_id' => $expense['currency_id'],
|
||||||
'budgeted' => (string)$budgetLimit->amount,
|
'currency_code' => $expense['currency_name'],
|
||||||
'spent' => $data['expenses'],
|
'currency_name' => $expense['currency_name'],
|
||||||
'left' => $data['left'],
|
'currency_symbol' => $expense['currency_symbol'],
|
||||||
'overspent' => $data['overspent'],
|
'currency_decimal_places' => $expense['currency_decimal_places'],
|
||||||
];
|
];
|
||||||
$array[] = $line;
|
if (null !== $limit) {
|
||||||
|
// yes
|
||||||
|
$row['start_date'] = $limit->start_date;
|
||||||
|
$row['end_date'] = $limit->end_date;
|
||||||
|
$row['budgeted'] = $limit->amount;
|
||||||
|
$row['limit_id'] = $limit->id;
|
||||||
|
|
||||||
|
// less than zero? Set to 0.0
|
||||||
|
$row['left'] = -1 === bccomp(bcadd($limit->amount, $row['spent']), '0') ? '0' : bcadd($limit->amount, $row['spent']);
|
||||||
|
|
||||||
|
// spent > budgeted? then sum, otherwise other sum
|
||||||
|
$row['overspent'] = 1 === bccomp($row['spent'], $row['budgeted']) ? bcadd($row['spent'], $row['budgeted']) : '0';
|
||||||
|
}
|
||||||
|
$entry['rows'][] = $row;
|
||||||
}
|
}
|
||||||
|
$array['budgets'][] = $entry;
|
||||||
}
|
}
|
||||||
$noBudget = $this->repository->spentInPeriodWoBudget($accounts, $start, $end); // stuff outside of budgets
|
$noBudget = $this->repository->spentInPeriodWoBudgetMc($accounts, $start, $end);
|
||||||
$line = [
|
$noBudgetEntry = [
|
||||||
'type' => 'no-budget',
|
'budget_id' => null,
|
||||||
'budgeted' => '0',
|
'budget_name' => null,
|
||||||
'spent' => $noBudget,
|
'no_budget' => true,
|
||||||
'left' => '0',
|
'rows' => [],
|
||||||
'overspent' => '0',
|
|
||||||
];
|
];
|
||||||
$array[] = $line;
|
foreach ($noBudget as $row) {
|
||||||
|
$noBudgetEntry['rows'][] = [
|
||||||
|
'limit_id' => null,
|
||||||
|
'start_date' => null,
|
||||||
|
'end_date' => null,
|
||||||
|
'budgeted' => null,
|
||||||
|
'spent' => $row['amount'],
|
||||||
|
'left' => null,
|
||||||
|
'overspent' => null,
|
||||||
|
'currency_id' => $row['currency_id'],
|
||||||
|
'currency_code' => $row['currency_code'],
|
||||||
|
'currency_name' => $row['currency_name'],
|
||||||
|
'currency_symbol' => $row['currency_symbol'],
|
||||||
|
'currency_decimal_places' => $row['currency_decimal_places'],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
$array['budgets'][] = $noBudgetEntry;
|
||||||
|
|
||||||
return $array;
|
// fill sums:
|
||||||
}
|
/** @var array $budget */
|
||||||
|
foreach ($array['budgets'] as $budget) {
|
||||||
/**
|
/** @var array $row */
|
||||||
* Get all budgets and the expenses in these budgets.
|
foreach ($budget['rows'] as $row) {
|
||||||
*
|
$currencyId = $row['currency_id'];
|
||||||
* @param Carbon $start
|
$array['sums'][$currencyId] = $array['sums'][$currencyId] ?? [
|
||||||
* @param Carbon $end
|
'currency_id' => $row['currency_id'],
|
||||||
* @param Collection $accounts
|
'currency_code' => $row['currency_code'],
|
||||||
*
|
'currency_name' => $row['currency_name'],
|
||||||
* @return Collection
|
'currency_symbol' => $row['currency_symbol'],
|
||||||
*/
|
'currency_decimal_places' => $row['currency_decimal_places'],
|
||||||
public function getBudgetsWithExpenses(Carbon $start, Carbon $end, Collection $accounts): Collection
|
'budgeted' => '0',
|
||||||
{
|
'spent' => '0',
|
||||||
/** @var BudgetRepositoryInterface $repository */
|
'left' => '0',
|
||||||
$repository = app(BudgetRepositoryInterface::class);
|
'overspent' => '0',
|
||||||
$budgets = $repository->getActiveBudgets();
|
];
|
||||||
|
$array['sums'][$currencyId]['budgeted'] = bcadd($array['sums'][$currencyId]['budgeted'], $row['budgeted'] ?? '0');
|
||||||
$set = new Collection;
|
$array['sums'][$currencyId]['spent'] = bcadd($array['sums'][$currencyId]['spent'], $row['spent'] ?? '0');
|
||||||
/** @var Budget $budget */
|
$array['sums'][$currencyId]['left'] = bcadd($array['sums'][$currencyId]['left'], $row['left'] ?? '0');
|
||||||
foreach ($budgets as $budget) {
|
$array['sums'][$currencyId]['overspent'] = bcadd($array['sums'][$currencyId]['overspent'], $row['overspent'] ?? '0');
|
||||||
$total = $repository->spentInPeriod(new Collection([$budget]), $accounts, $start, $end);
|
|
||||||
if (bccomp($total, '0') === -1) {
|
|
||||||
$set->push($budget);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $set;
|
return $array;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Calculate the expenses for a budget.
|
* Returns from the collection the budget limit with the indicated currency ID
|
||||||
*
|
*
|
||||||
* @param Budget $budget
|
* @param int $currencyId
|
||||||
* @param BudgetLimit $budgetLimit
|
* @param Collection $budgetLimits
|
||||||
* @param Collection $accounts
|
|
||||||
*
|
*
|
||||||
* @return array
|
* @return BudgetLimit|null
|
||||||
*/
|
*/
|
||||||
private function calculateExpenses(Budget $budget, BudgetLimit $budgetLimit, Collection $accounts): array
|
private function budgetLimitInCurrency(int $currencyId, Collection $budgetLimits): ?BudgetLimit
|
||||||
{
|
{
|
||||||
$array = [];
|
return $budgetLimits->first(
|
||||||
$expenses = $this->repository->spentInPeriod(new Collection([$budget]), $accounts, $budgetLimit->start_date, $budgetLimit->end_date);
|
static function (BudgetLimit $limit) use ($currencyId) {
|
||||||
$array['left'] = 1 === bccomp(bcadd($budgetLimit->amount, $expenses), '0') ? bcadd($budgetLimit->amount, $expenses) : '0';
|
return $limit->transaction_currency_id === $currencyId;
|
||||||
$array['spent'] = 1 === bccomp(bcadd($budgetLimit->amount, $expenses), '0') ? $expenses : '0';
|
}
|
||||||
$array['overspent'] = 1 === bccomp(bcadd($budgetLimit->amount, $expenses), '0') ? '0' : bcadd($expenses, $budgetLimit->amount);
|
);
|
||||||
$array['expenses'] = $expenses;
|
|
||||||
|
|
||||||
return $array;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -40,15 +40,4 @@ interface BudgetReportHelperInterface
|
|||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function getBudgetReport(Carbon $start, Carbon $end, Collection $accounts): array;
|
public function getBudgetReport(Carbon $start, Carbon $end, Collection $accounts): array;
|
||||||
|
|
||||||
/**
|
|
||||||
* Get budgets and the expenses in each budget.
|
|
||||||
*
|
|
||||||
* @param Carbon $start
|
|
||||||
* @param Carbon $end
|
|
||||||
* @param Collection $accounts
|
|
||||||
*
|
|
||||||
* @return Collection
|
|
||||||
*/
|
|
||||||
public function getBudgetsWithExpenses(Carbon $start, Carbon $end, Collection $accounts): Collection;
|
|
||||||
}
|
}
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user