mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-08-21 12:54:32 +00:00
Compare commits
180 Commits
account-re
...
3.8.4
Author | SHA1 | Date | |
---|---|---|---|
|
3f6c19dec4 | ||
|
93421b50f9 | ||
|
54e829173a | ||
|
4fe38bd31b | ||
|
fb0638e824 | ||
|
108794a6b6 | ||
|
9c16fc1380 | ||
|
99c219ed97 | ||
|
ec12238ea1 | ||
|
bdbd22f98b | ||
|
b8e1944d20 | ||
|
8883d185fe | ||
|
19e40e9976 | ||
|
fa85b2b5b2 | ||
|
5cf0131d75 | ||
|
3948cb8e6c | ||
|
f43938726a | ||
|
8c8bb7a930 | ||
|
3972882a33 | ||
|
0ef5eeeb55 | ||
|
ef48a79d0c | ||
|
2bb883219c | ||
|
23c0bb49c4 | ||
|
13e59105ec | ||
|
98c057c516 | ||
|
e293d69798 | ||
|
b097e29104 | ||
|
29fbd46e33 | ||
|
6a15afc723 | ||
|
c56a39a726 | ||
|
4b80e46d26 | ||
|
a6f3e61520 | ||
|
cce4ef19e5 | ||
|
1951491c04 | ||
|
87b72e4bcd | ||
|
2c6643d691 | ||
|
d02df46517 | ||
|
0c0cc417ee | ||
|
f0c03e8a3b | ||
|
345766f387 | ||
|
3fa659632c | ||
|
95b92b7d1e | ||
|
466e988627 | ||
|
dc3c967c9f | ||
|
1fc31b4d8f | ||
|
e4a4b0a4eb | ||
|
a9c026884d | ||
|
e893000ce9 | ||
|
32eeb3424d | ||
|
ab523b6102 | ||
|
b062222c45 | ||
|
2dddc843ce | ||
|
b74c1c8cf9 | ||
|
d5d4bb2c4b | ||
|
89ac27ad10 | ||
|
48b169c026 | ||
|
0715b7406e | ||
|
6e4991a34b | ||
|
8730af59bc | ||
|
bdcc2c6c9f | ||
|
6f0f6e86a1 | ||
|
3962d9da92 | ||
|
5ed53d5f04 | ||
|
ddb28b78c3 | ||
|
7699b6b4ea | ||
|
d783d05462 | ||
|
33bf373151 | ||
|
8116644526 | ||
|
dc4665e82a | ||
|
732a85e51d | ||
|
32190db8bb | ||
|
25d3a115e0 | ||
|
30e3ed6410 | ||
|
8b5a775dc5 | ||
|
2942c3a4be | ||
|
768d3bb3e8 | ||
|
250b2c2f53 | ||
|
c8440af9a5 | ||
|
37fe2d22b0 | ||
|
b0b5d90976 | ||
|
27b0c7f425 | ||
|
7c23571806 | ||
|
ea378c8d82 | ||
|
0fb45974ef | ||
|
6490f9c128 | ||
|
2d7f1af52c | ||
|
ac27659a59 | ||
|
11d59c8bd1 | ||
|
a6936cbd02 | ||
|
3be84d76ef | ||
|
9aed1f344f | ||
|
4fff264630 | ||
|
2e444da2a3 | ||
|
7a216f95ca | ||
|
f22a9799a1 | ||
|
90bdc40393 | ||
|
622a97c8d8 | ||
|
03691c81c2 | ||
|
885b56c465 | ||
|
23cc7be231 | ||
|
bb82b0eb79 | ||
|
2e05f640b8 | ||
|
697a02ffee | ||
|
ad402021ed | ||
|
67caf6ef1f | ||
|
3277858c5a | ||
|
3fbedf323f | ||
|
144a6130f2 | ||
|
fa38c975b6 | ||
|
c14fa1021c | ||
|
5e78cc02bd | ||
|
429ef80fb9 | ||
|
e4d93cad27 | ||
|
d9a4840e37 | ||
|
a93070b98d | ||
|
c05a942862 | ||
|
f9a7879c1e | ||
|
bdfbc6d6a7 | ||
|
21181d8d8e | ||
|
1c7a27b816 | ||
|
e953f58c74 | ||
|
9250cee9e7 | ||
|
bb075d15ff | ||
|
a31f16bba7 | ||
|
88a41c37f3 | ||
|
d21885ca98 | ||
|
d774f8e870 | ||
|
08b5e66628 | ||
|
6fdfec3967 | ||
|
ab4616a3ad | ||
|
cb34ff4c83 | ||
|
bdbead256c | ||
|
f200086d01 | ||
|
ef97c3b42d | ||
|
ed8b41e8ec | ||
|
aada3371b7 | ||
|
38a9782bdf | ||
|
c6ac81dcf6 | ||
|
2d3f3f0fde | ||
|
993a2c7823 | ||
|
87b36cf7e3 | ||
|
742f2c8d9f | ||
|
0d7ac5f1d8 | ||
|
3adccff611 | ||
|
08b8bd27f9 | ||
|
1059c7e2be | ||
|
3ebcd5f738 | ||
|
4627ea1dec | ||
|
7ed24e78d5 | ||
|
ae02e3fd8d | ||
|
cc88d5962e | ||
|
70c8a524cd | ||
|
9a8efc8a58 | ||
|
f0f67b87c4 | ||
|
1a3ec98896 | ||
|
efff44cba9 | ||
|
7227418c4c | ||
|
29f93a9b73 | ||
|
532aa2acd0 | ||
|
6aca410f37 | ||
|
f20656b516 | ||
|
bcd7866e10 | ||
|
c1b8d44209 | ||
|
50e947fbbe | ||
|
189d969ee6 | ||
|
201790ff8d | ||
|
cc26ce4143 | ||
|
745e0aa525 | ||
|
6602b1587a | ||
|
6698b57f52 | ||
|
628268d47c | ||
|
56a635212a | ||
|
7e67eb17e0 | ||
|
935d72d672 | ||
|
fccb510186 | ||
|
e7ea0dc842 | ||
|
a40d6b0649 | ||
|
b7429a358f | ||
|
cf8b4e2f76 | ||
|
48c865e57a |
@@ -1,7 +1,7 @@
|
||||
APP_ENV=production
|
||||
APP_DEBUG=false
|
||||
APP_KEY=SomeRandomStringOf32CharsExactly
|
||||
|
||||
LOG_LEVEL=warning
|
||||
|
||||
DB_CONNECTION=mysql
|
||||
DB_HOST=localhost
|
||||
@@ -13,6 +13,10 @@ CACHE_DRIVER=file
|
||||
SESSION_DRIVER=file
|
||||
QUEUE_DRIVER=sync
|
||||
|
||||
COOKIE_PATH="/"
|
||||
COOKIE_DOMAIN=
|
||||
COOKIE_SECURE=false
|
||||
|
||||
DEFAULT_CURRENCY=EUR
|
||||
DEFAULT_LANGUAGE=en_US
|
||||
|
||||
@@ -28,6 +32,9 @@ MAIL_USERNAME=null
|
||||
MAIL_PASSWORD=null
|
||||
MAIL_ENCRYPTION=null
|
||||
|
||||
SEND_REGISTRATION_MAIL=true
|
||||
MUST_CONFIRM_ACCOUNT=false
|
||||
|
||||
SHOW_INCOMPLETE_TRANSLATIONS=false
|
||||
|
||||
ANALYTICS_ID=
|
||||
|
@@ -1,7 +1,7 @@
|
||||
APP_ENV=testing
|
||||
APP_DEBUG=true
|
||||
APP_KEY=SomeRandomStringOf32CharsExactly
|
||||
|
||||
LOG_LEVEL=debug
|
||||
|
||||
DB_CONNECTION=sqlite
|
||||
DB_HOST=localhost
|
||||
|
@@ -4,6 +4,7 @@ php:
|
||||
- 7
|
||||
|
||||
install:
|
||||
- cp _development/phpunit.xml ./phpunit.xml
|
||||
- phpenv config-rm xdebug.ini
|
||||
- composer selfupdate
|
||||
- rm composer.lock
|
||||
|
58
CHANGELOG.md
58
CHANGELOG.md
@@ -5,6 +5,64 @@ This project adheres to [Semantic Versioning](http://semver.org/).
|
||||
## [Unreleased]
|
||||
- No unreleased changes yet.
|
||||
|
||||
|
||||
## [3.8.4] - 2016-04-24
|
||||
### Added
|
||||
- Lots of new translations.
|
||||
- Can now set page size.
|
||||
- Can now mass edit transactions.
|
||||
- Can now mass delete transactions.
|
||||
- Firefly will now attempt to verify the integrity of your database when updating.
|
||||
|
||||
### Changed
|
||||
- New version of Charts library.
|
||||
|
||||
### Fixed
|
||||
- Several CSV related bugs.
|
||||
- Several other bugs.
|
||||
- Bugs fixed by @Bonno.
|
||||
|
||||
## [3.8.3] - 2016-04-17
|
||||
### Added
|
||||
- New audit report to see what happened.
|
||||
|
||||
### Changed
|
||||
- New Chart JS release used.
|
||||
- Help function is more reliable.
|
||||
|
||||
### Fixed
|
||||
- Expected bill amount is now correct.
|
||||
- Upgrade will now invalidate cache.
|
||||
- Search was broken.
|
||||
- Queries run better
|
||||
|
||||
## [3.8.2] - 2016-04-03
|
||||
### Added
|
||||
- Small user administration at /admin.
|
||||
- Informational popups are working in reports.
|
||||
|
||||
### Changed
|
||||
- User activation emails are better
|
||||
|
||||
### Fixed
|
||||
- Some bugs related to accounts and rules.
|
||||
|
||||
|
||||
## [3.8.1] - 2016-03-29
|
||||
### Added
|
||||
- More translations
|
||||
- Extended cookie control.
|
||||
- User accounts can now be activated (disabled by default).
|
||||
- Bills can now take the source and destination account name into account.
|
||||
|
||||
### Changed
|
||||
- The pages related to rules have new URL's.
|
||||
|
||||
### Fixed
|
||||
- Spelling errors.
|
||||
- Problems related to the "account repository".
|
||||
- Some views showed empty (0.0) amounts.
|
||||
|
||||
## [3.8.0] - 2016-03-20
|
||||
### Added
|
||||
- Two factor authentication, thanks to the excellent work of [zjean](https://github.com/zjean).
|
||||
|
2
LICENSE
2
LICENSE
@@ -1,4 +1,4 @@
|
||||
Copyright (C) 2016 Sander Dorigo
|
||||
Copyright (C) 2016 thegrumpydictator@gmail.com
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
|
@@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
~ phpunit.cover.xml
|
||||
~ Copyright (C) 2016 Sander Dorigo
|
||||
~ Copyright (C) 2016 thegrumpydictator@gmail.com
|
||||
~
|
||||
~ This software may be modified and distributed under the terms
|
||||
~ of the MIT license. See the LICENSE file for details.
|
43
app/Bootstrap/ConfigureLogging.php
Normal file
43
app/Bootstrap/ConfigureLogging.php
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
/**
|
||||
* ConfigureLogging.php
|
||||
* Copyright (C) 2016 thegrumpydictator@gmail.com
|
||||
*
|
||||
* This software may be modified and distributed under the terms
|
||||
* of the MIT license. See the LICENSE file for details.
|
||||
*/
|
||||
|
||||
namespace FireflyIII\Bootstrap;
|
||||
|
||||
use Illuminate\Log\Writer;
|
||||
use Illuminate\Contracts\Foundation\Application;
|
||||
use Illuminate\Foundation\Bootstrap\ConfigureLogging as IlluminateConfigureLogging;
|
||||
|
||||
/**
|
||||
* Class ConfigureLogging
|
||||
*
|
||||
* @package FireflyIII\Bootstrap
|
||||
*/
|
||||
class ConfigureLogging extends IlluminateConfigureLogging
|
||||
{
|
||||
/**
|
||||
* @param Application $app
|
||||
* @param Writer $log
|
||||
*/
|
||||
protected function configureSingleHandler(Application $app, Writer $log)
|
||||
{
|
||||
$log->useFiles($app->storagePath().'/logs/firefly-iii.log');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Application $app
|
||||
* @param Writer $log
|
||||
*/
|
||||
protected function configureDailyHandler(Application $app, Writer $log)
|
||||
{
|
||||
$log->useDailyFiles(
|
||||
$app->storagePath().'/logs/firefly-iii.log',
|
||||
$app->make('config')->get('app.log_max_files', 5)
|
||||
);
|
||||
}
|
||||
}
|
272
app/Console/Commands/VerifyDatabase.php
Normal file
272
app/Console/Commands/VerifyDatabase.php
Normal file
@@ -0,0 +1,272 @@
|
||||
<?php
|
||||
|
||||
namespace FireflyIII\Console\Commands;
|
||||
|
||||
use Crypt;
|
||||
use DB;
|
||||
use FireflyIII\Models\Account;
|
||||
use FireflyIII\Models\Budget;
|
||||
use FireflyIII\Models\Category;
|
||||
use FireflyIII\Models\Tag;
|
||||
use FireflyIII\Models\Transaction;
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||
use FireflyIII\Repositories\User\UserRepositoryInterface;
|
||||
use FireflyIII\User;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use stdClass;
|
||||
|
||||
/**
|
||||
* Class VerifyDatabase
|
||||
*
|
||||
* @package FireflyIII\Console\Commands
|
||||
*/
|
||||
class VerifyDatabase extends Command
|
||||
{
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Will verify your database.';
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'firefly:verify';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
// accounts with no transactions.
|
||||
$this->reportAccounts();
|
||||
// budgets with no limits
|
||||
$this->reportBudgetLimits();
|
||||
// budgets with no transactions
|
||||
$this->reportBudgets();
|
||||
// categories with no transactions
|
||||
$this->reportCategories();
|
||||
// tags with no transactions
|
||||
$this->reportTags();
|
||||
// sum of transactions is not zero.
|
||||
$this->reportSum();
|
||||
// any deleted transaction journals that have transactions that are NOT deleted:
|
||||
$this->reportJournals();
|
||||
// deleted transactions that are connected to a not deleted journal.
|
||||
$this->reportTransactions();
|
||||
// deleted accounts that still have not deleted transactions or journals attached to them.
|
||||
$this->reportDeletedAccounts();
|
||||
}
|
||||
|
||||
/**
|
||||
* Reports on accounts with no transactions.
|
||||
*/
|
||||
private function reportAccounts()
|
||||
{
|
||||
$set = Account
|
||||
::leftJoin('transactions', 'transactions.account_id', '=', 'accounts.id')
|
||||
->leftJoin('users', 'accounts.user_id', '=', 'users.id')
|
||||
->groupBy('accounts.id')
|
||||
->having('transaction_count', '=', 0)
|
||||
->get(['accounts.id', 'accounts.name', 'accounts.user_id', 'users.email', DB::raw('COUNT(`transactions`.`id`) AS `transaction_count`')]);
|
||||
|
||||
/** @var stdClass $entry */
|
||||
foreach ($set as $entry) {
|
||||
$line = 'User #' . $entry->user_id . ' (' . $entry->email . ') has account #' . $entry->id . ' ("' . Crypt::decrypt($entry->name)
|
||||
. '") which has no transactions.';
|
||||
$this->line($line);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reports on budgets with no budget limits (which makes them pointless).
|
||||
*/
|
||||
private function reportBudgetLimits()
|
||||
{
|
||||
$set = Budget
|
||||
::leftJoin('budget_limits', 'budget_limits.budget_id', '=', 'budgets.id')
|
||||
->leftJoin('users', 'budgets.user_id', '=', 'users.id')
|
||||
->groupBy('budgets.id')
|
||||
->having('budget_limit_count', '=', 0)
|
||||
->get(['budgets.id', 'budgets.name', 'budgets.user_id', 'users.email', DB::raw('COUNT(`budget_limits`.`id`) AS `budget_limit_count`')]);
|
||||
|
||||
/** @var stdClass $entry */
|
||||
foreach ($set as $entry) {
|
||||
$line = 'Notice: User #' . $entry->user_id . ' (' . $entry->email . ') has budget #' . $entry->id . ' ("' . Crypt::decrypt($entry->name)
|
||||
. '") which has no budget limits.';
|
||||
$this->line($line);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reports on budgets without any transactions.
|
||||
*/
|
||||
private function reportBudgets()
|
||||
{
|
||||
$set = Budget
|
||||
::leftJoin('budget_transaction_journal', 'budgets.id', '=', 'budget_transaction_journal.budget_id')
|
||||
->leftJoin('users', 'budgets.user_id', '=', 'users.id')
|
||||
->distinct()
|
||||
->get(['budgets.id', 'budgets.name', 'budget_transaction_journal.budget_id', 'budgets.user_id', 'users.email']);
|
||||
|
||||
/** @var stdClass $entry */
|
||||
foreach ($set as $entry) {
|
||||
$line = 'Notice: User #' . $entry->user_id . ' (' . $entry->email . ') has budget #' . $entry->id . ' ("' . Crypt::decrypt($entry->name)
|
||||
. '") which has no transactions.';
|
||||
$this->line($line);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reports on categories without any transactions.
|
||||
*/
|
||||
private function reportCategories()
|
||||
{
|
||||
$set = Category
|
||||
::leftJoin('category_transaction_journal', 'categories.id', '=', 'category_transaction_journal.category_id')
|
||||
->leftJoin('users', 'categories.user_id', '=', 'users.id')
|
||||
->distinct()
|
||||
->get(['categories.id', 'categories.name', 'category_transaction_journal.category_id', 'categories.user_id', 'users.email']);
|
||||
|
||||
/** @var stdClass $entry */
|
||||
foreach ($set as $entry) {
|
||||
$line = 'Notice: User #' . $entry->user_id . ' (' . $entry->email . ') has category #' . $entry->id . ' ("' . Crypt::decrypt($entry->name)
|
||||
. '") which has no transactions.';
|
||||
$this->line($line);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reports on deleted accounts that still have not deleted transactions or journals attached to them.
|
||||
*/
|
||||
private function reportDeletedAccounts()
|
||||
{
|
||||
$set = Account
|
||||
::leftJoin('transactions', 'transactions.account_id', '=', 'accounts.id')
|
||||
->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id')
|
||||
->whereNotNull('accounts.deleted_at')
|
||||
->whereNotNull('transactions.id')
|
||||
->where(
|
||||
function (Builder $q) {
|
||||
$q->whereNull('transactions.deleted_at');
|
||||
$q->orWhereNull('transaction_journals.deleted_at');
|
||||
}
|
||||
)
|
||||
->get(
|
||||
['accounts.id as account_id', 'accounts.deleted_at as account_deleted_at', 'transactions.id as transaction_id',
|
||||
'transactions.deleted_at as transaction_deleted_at', 'transaction_journals.id as journal_id',
|
||||
'transaction_journals.deleted_at as journal_deleted_at']
|
||||
);
|
||||
/** @var stdClass $entry */
|
||||
foreach ($set as $entry) {
|
||||
$date = is_null($entry->transaction_deleted_at) ? $entry->journal_deleted_at : $entry->transaction_deleted_at;
|
||||
$this->error(
|
||||
'Error: Account #' . $entry->account_id . ' should have been deleted, but has not.' .
|
||||
' Find it in the table called `accounts` and change the `deleted_at` field to: "' . $date . '"'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Any deleted transaction journals that have transactions that are NOT deleted:
|
||||
*/
|
||||
private function reportJournals()
|
||||
{
|
||||
$set = TransactionJournal
|
||||
::leftJoin('transactions', 'transactions.transaction_journal_id', '=', 'transaction_journals.id')
|
||||
->whereNotNull('transaction_journals.deleted_at')// USE THIS
|
||||
->whereNull('transactions.deleted_at')
|
||||
->whereNotNull('transactions.id')
|
||||
->get(
|
||||
[
|
||||
'transaction_journals.id as journal_id',
|
||||
'transaction_journals.description',
|
||||
'transaction_journals.deleted_at as journal_deleted',
|
||||
'transactions.id as transaction_id',
|
||||
'transactions.deleted_at as transaction_deleted_at']
|
||||
);
|
||||
/** @var stdClass $entry */
|
||||
foreach ($set as $entry) {
|
||||
$this->error(
|
||||
'Error: Transaction #' . $entry->transaction_id . ' should have been deleted, but has not.' .
|
||||
' Find it in the table called `transactions` and change the `deleted_at` field to: "' . $entry->journal_deleted . '"'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reports for each user when the sum of their transactions is not zero.
|
||||
*/
|
||||
private function reportSum()
|
||||
{
|
||||
/** @var UserRepositoryInterface $userRepository */
|
||||
$userRepository = app('FireflyIII\Repositories\User\UserRepositoryInterface');
|
||||
|
||||
/** @var User $user */
|
||||
foreach ($userRepository->all() as $user) {
|
||||
/** @var AccountRepositoryInterface $repository */
|
||||
$repository = app('FireflyIII\Repositories\Account\AccountRepositoryInterface', [$user]);
|
||||
$sum = $repository->sumOfEverything();
|
||||
if (bccomp($sum, '0') !== 0) {
|
||||
$this->error('Error: Transactions for user #' . $user->id . ' (' . $user->email . ') are off by ' . $sum . '!');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reports on tags without any transactions.
|
||||
*/
|
||||
private function reportTags()
|
||||
{
|
||||
$set = Tag
|
||||
::leftJoin('tag_transaction_journal', 'tags.id', '=', 'tag_transaction_journal.tag_id')
|
||||
->leftJoin('users', 'tags.user_id', '=', 'users.id')
|
||||
->distinct()
|
||||
->get(['tags.id', 'tags.tag', 'tag_transaction_journal.tag_id', 'tags.user_id', 'users.email']);
|
||||
|
||||
/** @var stdClass $entry */
|
||||
foreach ($set as $entry) {
|
||||
$line = 'Notice: User #' . $entry->user_id . ' (' . $entry->email . ') has tag #' . $entry->id . ' ("' . $entry->tag
|
||||
. '") which has no transactions.';
|
||||
$this->line($line);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reports on deleted transactions that are connected to a not deleted journal.
|
||||
*/
|
||||
private function reportTransactions()
|
||||
{
|
||||
$set = Transaction
|
||||
::leftJoin('transaction_journals', 'transactions.transaction_journal_id', '=', 'transaction_journals.id')
|
||||
->whereNotNull('transactions.deleted_at')
|
||||
->whereNull('transaction_journals.deleted_at')
|
||||
->get(
|
||||
['transactions.id as transaction_id', 'transactions.deleted_at as transaction_deleted', 'transaction_journals.id as journal_id',
|
||||
'transaction_journals.deleted_at']
|
||||
);
|
||||
/** @var stdClass $entry */
|
||||
foreach ($set as $entry) {
|
||||
$this->error(
|
||||
'Error: Transaction journal #' . $entry->journal_id . ' should have been deleted, but has not.' .
|
||||
' Find it in the table called `transaction_journals` and change the `deleted_at` field to: "' . $entry->transaction_deleted . '"'
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
@@ -3,7 +3,7 @@ declare(strict_types = 1);
|
||||
|
||||
/**
|
||||
* Kernel.php
|
||||
* Copyright (C) 2016 Sander Dorigo
|
||||
* Copyright (C) 2016 thegrumpydictator@gmail.com
|
||||
*
|
||||
* This software may be modified and distributed under the terms
|
||||
* of the MIT license. See the LICENSE file for details.
|
||||
@@ -12,6 +12,7 @@ declare(strict_types = 1);
|
||||
namespace FireflyIII\Console;
|
||||
|
||||
use FireflyIII\Console\Commands\UpgradeFireflyInstructions;
|
||||
use FireflyIII\Console\Commands\VerifyDatabase;
|
||||
use Illuminate\Console\Scheduling\Schedule;
|
||||
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
|
||||
|
||||
@@ -22,6 +23,26 @@ use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
|
||||
*/
|
||||
class Kernel extends ConsoleKernel
|
||||
{
|
||||
|
||||
/**
|
||||
* The bootstrap classes for the application.
|
||||
*
|
||||
* This needs to be for with the next upgrade.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $bootstrappers
|
||||
= [
|
||||
'Illuminate\Foundation\Bootstrap\DetectEnvironment',
|
||||
'Illuminate\Foundation\Bootstrap\LoadConfiguration',
|
||||
'FireflyIII\Bootstrap\ConfigureLogging',
|
||||
'Illuminate\Foundation\Bootstrap\HandleExceptions',
|
||||
'Illuminate\Foundation\Bootstrap\RegisterFacades',
|
||||
'Illuminate\Foundation\Bootstrap\SetRequestForConsole',
|
||||
'Illuminate\Foundation\Bootstrap\RegisterProviders',
|
||||
'Illuminate\Foundation\Bootstrap\BootProviders',
|
||||
];
|
||||
|
||||
/**
|
||||
* The Artisan commands provided by your application.
|
||||
*
|
||||
@@ -30,6 +51,7 @@ class Kernel extends ConsoleKernel
|
||||
protected $commands
|
||||
= [
|
||||
UpgradeFireflyInstructions::class,
|
||||
VerifyDatabase::class,
|
||||
];
|
||||
|
||||
/**
|
||||
|
39
app/Events/ResendConfirmation.php
Normal file
39
app/Events/ResendConfirmation.php
Normal file
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
declare(strict_types = 1);
|
||||
/**
|
||||
* ResendConfirmation.php
|
||||
* Copyright (C) 2016 thegrumpydictator@gmail.com
|
||||
*
|
||||
* This software may be modified and distributed under the terms
|
||||
* of the MIT license. See the LICENSE file for details.
|
||||
*/
|
||||
|
||||
namespace FireflyIII\Events;
|
||||
|
||||
use FireflyIII\User;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
/**
|
||||
* Class ResendConfirmation
|
||||
*
|
||||
* @package FireflyIII\Events
|
||||
*/
|
||||
class ResendConfirmation extends Event
|
||||
{
|
||||
use SerializesModels;
|
||||
|
||||
public $ipAddress;
|
||||
public $user;
|
||||
|
||||
/**
|
||||
* Create a new event instance.
|
||||
*
|
||||
* @param User $user
|
||||
* @param string $ipAddress
|
||||
*/
|
||||
public function __construct(User $user, string $ipAddress)
|
||||
{
|
||||
$this->user = $user;
|
||||
$this->ipAddress = $ipAddress;
|
||||
}
|
||||
}
|
@@ -2,7 +2,7 @@
|
||||
declare(strict_types = 1);
|
||||
/**
|
||||
* TransactionJournalStored.php
|
||||
* Copyright (C) 2016 Sander Dorigo
|
||||
* Copyright (C) 2016 thegrumpydictator@gmail.com
|
||||
*
|
||||
* This software may be modified and distributed under the terms
|
||||
* of the MIT license. See the LICENSE file for details.
|
||||
@@ -12,11 +12,11 @@ namespace FireflyIII\Events;
|
||||
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Log;
|
||||
|
||||
/**
|
||||
* Class TransactionJournalStored
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
* @package FireflyIII\Events
|
||||
*/
|
||||
class TransactionJournalStored extends Event
|
||||
@@ -35,6 +35,7 @@ class TransactionJournalStored extends Event
|
||||
*/
|
||||
public function __construct(TransactionJournal $journal, int $piggyBankId)
|
||||
{
|
||||
Log::debug('Created new TransactionJournalStored.');
|
||||
//
|
||||
$this->journal = $journal;
|
||||
$this->piggyBankId = $piggyBankId;
|
||||
|
@@ -5,11 +5,11 @@ namespace FireflyIII\Events;
|
||||
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Log;
|
||||
|
||||
/**
|
||||
* Class TransactionJournalUpdated
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
* @package FireflyIII\Events
|
||||
*/
|
||||
class TransactionJournalUpdated extends Event
|
||||
@@ -26,6 +26,7 @@ class TransactionJournalUpdated extends Event
|
||||
*/
|
||||
public function __construct(TransactionJournal $journal)
|
||||
{
|
||||
Log::debug('Created new TransactionJournalUpdated');
|
||||
//
|
||||
$this->journal = $journal;
|
||||
}
|
||||
|
39
app/Events/UserRegistration.php
Normal file
39
app/Events/UserRegistration.php
Normal file
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
declare(strict_types = 1);
|
||||
/**
|
||||
* UserRegistration.php
|
||||
* Copyright (C) 2016 thegrumpydictator@gmail.com
|
||||
*
|
||||
* This software may be modified and distributed under the terms
|
||||
* of the MIT license. See the LICENSE file for details.
|
||||
*/
|
||||
|
||||
namespace FireflyIII\Events;
|
||||
|
||||
use FireflyIII\User;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
/**
|
||||
* Class UserRegistration
|
||||
*
|
||||
* @package FireflyIII\Events
|
||||
*/
|
||||
class UserRegistration extends Event
|
||||
{
|
||||
use SerializesModels;
|
||||
|
||||
public $ipAddress;
|
||||
public $user;
|
||||
|
||||
/**
|
||||
* Create a new event instance.
|
||||
*
|
||||
* @param User $user
|
||||
* @param string $ipAddress
|
||||
*/
|
||||
public function __construct(User $user, string $ipAddress)
|
||||
{
|
||||
$this->user = $user;
|
||||
$this->ipAddress = $ipAddress;
|
||||
}
|
||||
}
|
@@ -6,7 +6,6 @@ namespace FireflyIII\Exceptions;
|
||||
/**
|
||||
* Class FireflyException
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
* @package FireflyIII\Exceptions
|
||||
*/
|
||||
class FireflyException extends \Exception
|
||||
|
@@ -6,7 +6,6 @@ namespace FireflyIII\Exceptions;
|
||||
/**
|
||||
* Class NotImplementedException
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
* @package FireflyIII\Exceptions
|
||||
*/
|
||||
class NotImplementedException extends \Exception
|
||||
|
@@ -5,7 +5,6 @@ namespace FireflyIII\Exceptions;
|
||||
/**
|
||||
* Class ValidationExceptions
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
* @package FireflyIII\Exception
|
||||
*/
|
||||
class ValidationException extends \Exception
|
||||
|
@@ -2,7 +2,7 @@
|
||||
declare(strict_types = 1);
|
||||
/**
|
||||
* AttachmentCollector.php
|
||||
* Copyright (C) 2016 Sander Dorigo
|
||||
* Copyright (C) 2016 thegrumpydictator@gmail.com
|
||||
*
|
||||
* This software may be modified and distributed under the terms
|
||||
* of the MIT license. See the LICENSE file for details.
|
||||
@@ -53,9 +53,9 @@ class AttachmentCollector extends BasicCollector implements CollectorInterface
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function run()
|
||||
public function run(): bool
|
||||
{
|
||||
// grab all the users attachments:
|
||||
$attachments = $this->getAttachments();
|
||||
@@ -70,6 +70,7 @@ class AttachmentCollector extends BasicCollector implements CollectorInterface
|
||||
$this->exportDisk->put($file, $this->explanationString);
|
||||
Log::debug('Also put explanation file "' . $file . '" in the zip.');
|
||||
$this->getFiles()->push($file);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -2,7 +2,7 @@
|
||||
declare(strict_types = 1);
|
||||
/**
|
||||
* BasicCollector.php
|
||||
* Copyright (C) 2016 Sander Dorigo
|
||||
* Copyright (C) 2016 thegrumpydictator@gmail.com
|
||||
*
|
||||
* This software may be modified and distributed under the terms
|
||||
* of the MIT license. See the LICENSE file for details.
|
||||
@@ -40,7 +40,7 @@ class BasicCollector
|
||||
/**
|
||||
* @return Collection
|
||||
*/
|
||||
public function getFiles()
|
||||
public function getFiles(): Collection
|
||||
{
|
||||
return $this->files;
|
||||
}
|
||||
|
@@ -2,7 +2,7 @@
|
||||
declare(strict_types = 1);
|
||||
/**
|
||||
* CollectorInterface.php
|
||||
* Copyright (C) 2016 Sander Dorigo
|
||||
* Copyright (C) 2016 thegrumpydictator@gmail.com
|
||||
*
|
||||
* This software may be modified and distributed under the terms
|
||||
* of the MIT license. See the LICENSE file for details.
|
||||
@@ -22,12 +22,12 @@ interface CollectorInterface
|
||||
/**
|
||||
* @return Collection
|
||||
*/
|
||||
public function getFiles();
|
||||
public function getFiles(): Collection;
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function run();
|
||||
public function run(): bool;
|
||||
|
||||
/**
|
||||
* @param Collection $files
|
||||
|
@@ -2,7 +2,7 @@
|
||||
declare(strict_types = 1);
|
||||
/**
|
||||
* UploadCollector.php
|
||||
* Copyright (C) 2016 Sander Dorigo
|
||||
* Copyright (C) 2016 thegrumpydictator@gmail.com
|
||||
*
|
||||
* This software may be modified and distributed under the terms
|
||||
* of the MIT license. See the LICENSE file for details.
|
||||
@@ -47,9 +47,9 @@ class UploadCollector extends BasicCollector implements CollectorInterface
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function run()
|
||||
public function run(): bool
|
||||
{
|
||||
// grab upload directory.
|
||||
$files = $this->uploadDisk->files();
|
||||
@@ -58,6 +58,7 @@ class UploadCollector extends BasicCollector implements CollectorInterface
|
||||
foreach ($files as $entry) {
|
||||
$this->processOldUpload($entry);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -2,7 +2,7 @@
|
||||
declare(strict_types = 1);
|
||||
/**
|
||||
* ConfigurationFile.php
|
||||
* Copyright (C) 2016 Sander Dorigo
|
||||
* Copyright (C) 2016 thegrumpydictator@gmail.com
|
||||
*
|
||||
* This software may be modified and distributed under the terms
|
||||
* of the MIT license. See the LICENSE file for details.
|
||||
@@ -38,9 +38,9 @@ class ConfigurationFile
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
* @return string
|
||||
*/
|
||||
public function make()
|
||||
public function make(): string
|
||||
{
|
||||
$fields = array_keys(get_class_vars(Entry::class));
|
||||
$types = Entry::getTypes();
|
||||
|
@@ -2,7 +2,7 @@
|
||||
declare(strict_types = 1);
|
||||
/**
|
||||
* Entry.php
|
||||
* Copyright (C) 2016 Sander Dorigo
|
||||
* Copyright (C) 2016 thegrumpydictator@gmail.com
|
||||
*
|
||||
* This software may be modified and distributed under the terms
|
||||
* of the MIT license. See the LICENSE file for details.
|
||||
@@ -58,6 +58,7 @@ class Entry
|
||||
public $fromAccountId;
|
||||
/** @var string */
|
||||
public $fromAccountName;
|
||||
/** @var int */
|
||||
public $fromAccountNumber;
|
||||
/** @var string */
|
||||
public $fromAccountType;
|
||||
@@ -132,23 +133,25 @@ class Entry
|
||||
// key = field name (see top of class)
|
||||
// value = field type (see csv.php under 'roles')
|
||||
return [
|
||||
'amount' => 'amount',
|
||||
'date' => 'date-transaction',
|
||||
'description' => 'description',
|
||||
'billId' => 'bill-id',
|
||||
'billName' => 'bill-name',
|
||||
'budgetId' => 'budget-id',
|
||||
'budgetName' => 'budget-name',
|
||||
'categoryId' => 'category-id',
|
||||
'categoryName' => 'category-name',
|
||||
'fromAccountId' => 'account-id',
|
||||
'fromAccountName' => 'account-name',
|
||||
'fromAccountIban' => 'account-iban',
|
||||
'fromAccountType' => '_ignore', // no, Firefly cannot import what it exports. I know :D
|
||||
'toAccountId' => 'opposing-id',
|
||||
'toAccountName' => 'opposing-name',
|
||||
'toAccountIban' => 'opposing-iban',
|
||||
'toAccountType' => '_ignore',
|
||||
'amount' => 'amount',
|
||||
'date' => 'date-transaction',
|
||||
'description' => 'description',
|
||||
'billId' => 'bill-id',
|
||||
'billName' => 'bill-name',
|
||||
'budgetId' => 'budget-id',
|
||||
'budgetName' => 'budget-name',
|
||||
'categoryId' => 'category-id',
|
||||
'categoryName' => 'category-name',
|
||||
'fromAccountId' => 'account-id',
|
||||
'fromAccountNumber' => 'account-number',
|
||||
'fromAccountName' => 'account-name',
|
||||
'fromAccountIban' => 'account-iban',
|
||||
'fromAccountType' => '_ignore', // no, Firefly cannot import what it exports. I know :D
|
||||
'toAccountId' => 'opposing-id',
|
||||
'toAccountNumber' => 'account-number',
|
||||
'toAccountName' => 'opposing-name',
|
||||
'toAccountIban' => 'opposing-iban',
|
||||
'toAccountType' => '_ignore',
|
||||
];
|
||||
}
|
||||
|
||||
@@ -171,7 +174,7 @@ class Entry
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getBillId()
|
||||
public function getBillId(): int
|
||||
{
|
||||
return $this->billId;
|
||||
}
|
||||
@@ -179,7 +182,7 @@ class Entry
|
||||
/**
|
||||
* @param int $billId
|
||||
*/
|
||||
public function setBillId($billId)
|
||||
public function setBillId(int $billId)
|
||||
{
|
||||
$this->billId = $billId;
|
||||
}
|
||||
@@ -187,7 +190,7 @@ class Entry
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getBillName()
|
||||
public function getBillName(): string
|
||||
{
|
||||
return $this->billName;
|
||||
}
|
||||
@@ -195,7 +198,7 @@ class Entry
|
||||
/**
|
||||
* @param string $billName
|
||||
*/
|
||||
public function setBillName($billName)
|
||||
public function setBillName(string $billName)
|
||||
{
|
||||
$this->billName = $billName;
|
||||
}
|
||||
@@ -203,7 +206,7 @@ class Entry
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getBudgetId()
|
||||
public function getBudgetId(): int
|
||||
{
|
||||
return $this->budgetId;
|
||||
}
|
||||
@@ -211,7 +214,7 @@ class Entry
|
||||
/**
|
||||
* @param int $budgetId
|
||||
*/
|
||||
public function setBudgetId($budgetId)
|
||||
public function setBudgetId(int $budgetId)
|
||||
{
|
||||
$this->budgetId = $budgetId;
|
||||
}
|
||||
@@ -219,7 +222,7 @@ class Entry
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getBudgetName()
|
||||
public function getBudgetName(): string
|
||||
{
|
||||
return $this->budgetName;
|
||||
}
|
||||
@@ -227,7 +230,7 @@ class Entry
|
||||
/**
|
||||
* @param string $budgetName
|
||||
*/
|
||||
public function setBudgetName($budgetName)
|
||||
public function setBudgetName(string $budgetName)
|
||||
{
|
||||
$this->budgetName = $budgetName;
|
||||
}
|
||||
@@ -235,7 +238,7 @@ class Entry
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getCategoryId()
|
||||
public function getCategoryId(): int
|
||||
{
|
||||
return $this->categoryId;
|
||||
}
|
||||
@@ -243,7 +246,7 @@ class Entry
|
||||
/**
|
||||
* @param int $categoryId
|
||||
*/
|
||||
public function setCategoryId($categoryId)
|
||||
public function setCategoryId(int $categoryId)
|
||||
{
|
||||
$this->categoryId = $categoryId;
|
||||
}
|
||||
@@ -251,7 +254,7 @@ class Entry
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getCategoryName()
|
||||
public function getCategoryName(): string
|
||||
{
|
||||
return $this->categoryName;
|
||||
}
|
||||
@@ -259,7 +262,7 @@ class Entry
|
||||
/**
|
||||
* @param string $categoryName
|
||||
*/
|
||||
public function setCategoryName($categoryName)
|
||||
public function setCategoryName(string $categoryName)
|
||||
{
|
||||
$this->categoryName = $categoryName;
|
||||
}
|
||||
@@ -267,7 +270,7 @@ class Entry
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getDate()
|
||||
public function getDate(): string
|
||||
{
|
||||
return $this->date;
|
||||
}
|
||||
@@ -283,7 +286,7 @@ class Entry
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getDescription()
|
||||
public function getDescription(): string
|
||||
{
|
||||
return $this->description;
|
||||
}
|
||||
@@ -299,7 +302,7 @@ class Entry
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getFromAccountIban()
|
||||
public function getFromAccountIban(): string
|
||||
{
|
||||
return $this->fromAccountIban;
|
||||
}
|
||||
@@ -307,7 +310,7 @@ class Entry
|
||||
/**
|
||||
* @param string $fromAccountIban
|
||||
*/
|
||||
public function setFromAccountIban($fromAccountIban)
|
||||
public function setFromAccountIban(string $fromAccountIban)
|
||||
{
|
||||
$this->fromAccountIban = $fromAccountIban;
|
||||
}
|
||||
@@ -315,7 +318,7 @@ class Entry
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getFromAccountId()
|
||||
public function getFromAccountId():int
|
||||
{
|
||||
return $this->fromAccountId;
|
||||
}
|
||||
@@ -323,7 +326,7 @@ class Entry
|
||||
/**
|
||||
* @param int $fromAccountId
|
||||
*/
|
||||
public function setFromAccountId($fromAccountId)
|
||||
public function setFromAccountId(int $fromAccountId)
|
||||
{
|
||||
$this->fromAccountId = $fromAccountId;
|
||||
}
|
||||
@@ -331,7 +334,7 @@ class Entry
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getFromAccountName()
|
||||
public function getFromAccountName(): string
|
||||
{
|
||||
return $this->fromAccountName;
|
||||
}
|
||||
@@ -339,23 +342,23 @@ class Entry
|
||||
/**
|
||||
* @param string $fromAccountName
|
||||
*/
|
||||
public function setFromAccountName($fromAccountName)
|
||||
public function setFromAccountName(string $fromAccountName)
|
||||
{
|
||||
$this->fromAccountName = $fromAccountName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
* @return string
|
||||
*/
|
||||
public function getFromAccountNumber()
|
||||
public function getFromAccountNumber(): string
|
||||
{
|
||||
return $this->fromAccountNumber;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $fromAccountNumber
|
||||
* @param string $fromAccountNumber
|
||||
*/
|
||||
public function setFromAccountNumber($fromAccountNumber)
|
||||
public function setFromAccountNumber(string $fromAccountNumber)
|
||||
{
|
||||
$this->fromAccountNumber = $fromAccountNumber;
|
||||
}
|
||||
@@ -363,7 +366,7 @@ class Entry
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getFromAccountType()
|
||||
public function getFromAccountType(): string
|
||||
{
|
||||
return $this->fromAccountType;
|
||||
}
|
||||
@@ -371,7 +374,7 @@ class Entry
|
||||
/**
|
||||
* @param string $fromAccountType
|
||||
*/
|
||||
public function setFromAccountType($fromAccountType)
|
||||
public function setFromAccountType(string $fromAccountType)
|
||||
{
|
||||
$this->fromAccountType = $fromAccountType;
|
||||
}
|
||||
@@ -379,7 +382,7 @@ class Entry
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getToAccountIban()
|
||||
public function getToAccountIban(): string
|
||||
{
|
||||
return $this->toAccountIban;
|
||||
}
|
||||
@@ -387,7 +390,7 @@ class Entry
|
||||
/**
|
||||
* @param string $toAccountIban
|
||||
*/
|
||||
public function setToAccountIban($toAccountIban)
|
||||
public function setToAccountIban(string $toAccountIban)
|
||||
{
|
||||
$this->toAccountIban = $toAccountIban;
|
||||
}
|
||||
@@ -395,7 +398,7 @@ class Entry
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getToAccountId()
|
||||
public function getToAccountId(): int
|
||||
{
|
||||
return $this->toAccountId;
|
||||
}
|
||||
@@ -403,7 +406,7 @@ class Entry
|
||||
/**
|
||||
* @param int $toAccountId
|
||||
*/
|
||||
public function setToAccountId($toAccountId)
|
||||
public function setToAccountId(int $toAccountId)
|
||||
{
|
||||
$this->toAccountId = $toAccountId;
|
||||
}
|
||||
@@ -411,7 +414,7 @@ class Entry
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getToAccountName()
|
||||
public function getToAccountName(): string
|
||||
{
|
||||
return $this->toAccountName;
|
||||
}
|
||||
@@ -419,23 +422,23 @@ class Entry
|
||||
/**
|
||||
* @param string $toAccountName
|
||||
*/
|
||||
public function setToAccountName($toAccountName)
|
||||
public function setToAccountName(string $toAccountName)
|
||||
{
|
||||
$this->toAccountName = $toAccountName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
* @return string
|
||||
*/
|
||||
public function getToAccountNumber()
|
||||
public function getToAccountNumber(): string
|
||||
{
|
||||
return $this->toAccountNumber;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $toAccountNumber
|
||||
* @param string $toAccountNumber
|
||||
*/
|
||||
public function setToAccountNumber($toAccountNumber)
|
||||
public function setToAccountNumber(string $toAccountNumber)
|
||||
{
|
||||
$this->toAccountNumber = $toAccountNumber;
|
||||
}
|
||||
@@ -443,7 +446,7 @@ class Entry
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getToAccountType()
|
||||
public function getToAccountType(): string
|
||||
{
|
||||
return $this->toAccountType;
|
||||
}
|
||||
@@ -451,7 +454,7 @@ class Entry
|
||||
/**
|
||||
* @param string $toAccountType
|
||||
*/
|
||||
public function setToAccountType($toAccountType)
|
||||
public function setToAccountType(string $toAccountType)
|
||||
{
|
||||
$this->toAccountType = $toAccountType;
|
||||
}
|
||||
|
@@ -2,7 +2,7 @@
|
||||
declare(strict_types = 1);
|
||||
/**
|
||||
* BasicExporter.php
|
||||
* Copyright (C) 2016 Sander Dorigo
|
||||
* Copyright (C) 2016 thegrumpydictator@gmail.com
|
||||
*
|
||||
* This software may be modified and distributed under the terms
|
||||
* of the MIT license. See the LICENSE file for details.
|
||||
@@ -39,7 +39,7 @@ class BasicExporter
|
||||
/**
|
||||
* @return Collection
|
||||
*/
|
||||
public function getEntries()
|
||||
public function getEntries(): Collection
|
||||
{
|
||||
return $this->entries;
|
||||
}
|
||||
|
@@ -2,7 +2,7 @@
|
||||
declare(strict_types = 1);
|
||||
/**
|
||||
* CsvExporter.php
|
||||
* Copyright (C) 2016 Sander Dorigo
|
||||
* Copyright (C) 2016 thegrumpydictator@gmail.com
|
||||
*
|
||||
* This software may be modified and distributed under the terms
|
||||
* of the MIT license. See the LICENSE file for details.
|
||||
@@ -39,15 +39,15 @@ class CsvExporter extends BasicExporter implements ExporterInterface
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getFileName()
|
||||
public function getFileName(): string
|
||||
{
|
||||
return $this->fileName;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function run()
|
||||
public function run(): bool
|
||||
{
|
||||
// create temporary file:
|
||||
$this->tempFile();
|
||||
@@ -72,6 +72,7 @@ class CsvExporter extends BasicExporter implements ExporterInterface
|
||||
|
||||
}
|
||||
$writer->insertAll($rows);
|
||||
return true;
|
||||
}
|
||||
|
||||
private function tempFile()
|
||||
|
@@ -2,7 +2,7 @@
|
||||
declare(strict_types = 1);
|
||||
/**
|
||||
* ExporterInterface.php
|
||||
* Copyright (C) 2016 Sander Dorigo
|
||||
* Copyright (C) 2016 thegrumpydictator@gmail.com
|
||||
*
|
||||
* This software may be modified and distributed under the terms
|
||||
* of the MIT license. See the LICENSE file for details.
|
||||
@@ -22,17 +22,17 @@ interface ExporterInterface
|
||||
/**
|
||||
* @return Collection
|
||||
*/
|
||||
public function getEntries();
|
||||
public function getEntries(): Collection;
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getFileName();
|
||||
public function getFileName(): string;
|
||||
|
||||
/**
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function run();
|
||||
public function run(): bool;
|
||||
|
||||
/**
|
||||
* @param Collection $entries
|
||||
|
@@ -2,7 +2,7 @@
|
||||
declare(strict_types = 1);
|
||||
/**
|
||||
* Processor.php
|
||||
* Copyright (C) 2016 Sander Dorigo
|
||||
* Copyright (C) 2016 thegrumpydictator@gmail.com
|
||||
*
|
||||
* This software may be modified and distributed under the terms
|
||||
* of the MIT license. See the LICENSE file for details.
|
||||
@@ -15,6 +15,7 @@ use Config;
|
||||
use FireflyIII\Exceptions\FireflyException;
|
||||
use FireflyIII\Models\ExportJob;
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
use FireflyIII\Repositories\Journal\JournalCollector;
|
||||
use Illuminate\Support\Collection;
|
||||
use Log;
|
||||
use Storage;
|
||||
@@ -73,21 +74,23 @@ class Processor
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function collectAttachments()
|
||||
public function collectAttachments(): bool
|
||||
{
|
||||
$attachmentCollector = app('FireflyIII\Export\Collector\AttachmentCollector', [$this->job]);
|
||||
$attachmentCollector->run();
|
||||
$this->files = $this->files->merge($attachmentCollector->getFiles());
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function collectJournals()
|
||||
public function collectJournals(): bool
|
||||
{
|
||||
$args = [$this->accounts, Auth::user(), $this->settings['startDate'], $this->settings['endDate']];
|
||||
/** @var JournalCollector $journalCollector */
|
||||
$journalCollector = app('FireflyIII\Repositories\Journal\JournalCollector', $args);
|
||||
$this->journals = $journalCollector->collect();
|
||||
Log::debug(
|
||||
@@ -97,20 +100,25 @@ class Processor
|
||||
$this->settings['endDate']->format('Y-m-d')
|
||||
. ').'
|
||||
);
|
||||
return true;
|
||||
}
|
||||
|
||||
public function collectOldUploads()
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function collectOldUploads(): bool
|
||||
{
|
||||
$uploadCollector = app('FireflyIII\Export\Collector\UploadCollector', [$this->job]);
|
||||
$uploadCollector->run();
|
||||
|
||||
$this->files = $this->files->merge($uploadCollector->getFiles());
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function convertJournals()
|
||||
public function convertJournals(): bool
|
||||
{
|
||||
$count = 0;
|
||||
/** @var TransactionJournal $journal */
|
||||
@@ -119,15 +127,24 @@ class Processor
|
||||
$count++;
|
||||
}
|
||||
Log::debug('Converted ' . $count . ' journals to "Entry" objects.');
|
||||
return true;
|
||||
}
|
||||
|
||||
public function createConfigFile()
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function createConfigFile(): bool
|
||||
{
|
||||
$this->configurationMaker = app('FireflyIII\Export\ConfigurationFile', [$this->job]);
|
||||
$this->files->push($this->configurationMaker->make());
|
||||
return true;
|
||||
}
|
||||
|
||||
public function createZipFile()
|
||||
/**
|
||||
* @return bool
|
||||
* @throws FireflyException
|
||||
*/
|
||||
public function createZipFile(): bool
|
||||
{
|
||||
$zip = new ZipArchive;
|
||||
$file = $this->job->key . '.zip';
|
||||
@@ -156,12 +173,13 @@ class Processor
|
||||
$disk->delete($file);
|
||||
}
|
||||
Log::debug('Done!');
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function exportJournals()
|
||||
public function exportJournals(): bool
|
||||
{
|
||||
$exporterClass = Config::get('firefly.export_formats.' . $this->exportFormat);
|
||||
$exporter = app($exporterClass, [$this->job]);
|
||||
@@ -170,12 +188,13 @@ class Processor
|
||||
$exporter->run();
|
||||
$this->files->push($exporter->getFileName());
|
||||
Log::debug('Added "' . $exporter->getFileName() . '" to the list of files to include in the zip.');
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection
|
||||
*/
|
||||
public function getFiles()
|
||||
public function getFiles(): Collection
|
||||
{
|
||||
return $this->files;
|
||||
}
|
||||
|
@@ -2,7 +2,7 @@
|
||||
declare(strict_types = 1);
|
||||
/**
|
||||
* AccountChartGeneratorInterface.php
|
||||
* Copyright (C) 2016 Sander Dorigo
|
||||
* Copyright (C) 2016 thegrumpydictator@gmail.com
|
||||
*
|
||||
* This software may be modified and distributed under the terms
|
||||
* of the MIT license. See the LICENSE file for details.
|
||||
|
@@ -2,7 +2,7 @@
|
||||
declare(strict_types = 1);
|
||||
/**
|
||||
* BillChartGeneratorInterface.php
|
||||
* Copyright (C) 2016 Sander Dorigo
|
||||
* Copyright (C) 2016 thegrumpydictator@gmail.com
|
||||
*
|
||||
* This software may be modified and distributed under the terms
|
||||
* of the MIT license. See the LICENSE file for details.
|
||||
|
@@ -2,7 +2,7 @@
|
||||
declare(strict_types = 1);
|
||||
/**
|
||||
* ChartJsBillChartGenerator.php
|
||||
* Copyright (C) 2016 Sander Dorigo
|
||||
* Copyright (C) 2016 thegrumpydictator@gmail.com
|
||||
*
|
||||
* This software may be modified and distributed under the terms
|
||||
* of the MIT license. See the LICENSE file for details.
|
||||
@@ -31,18 +31,15 @@ class ChartJsBillChartGenerator implements BillChartGeneratorInterface
|
||||
public function frontpage(string $paid, string $unpaid): array
|
||||
{
|
||||
$data = [
|
||||
[
|
||||
'value' => round($unpaid, 2),
|
||||
'color' => 'rgba(53, 124, 165,0.7)',
|
||||
'highlight' => 'rgba(53, 124, 165,0.9)',
|
||||
'label' => trans('firefly.unpaid'),
|
||||
],
|
||||
[
|
||||
'value' => round(bcmul($paid, '-1'), 2), // paid is negative, must be positive.
|
||||
'color' => 'rgba(0, 141, 76, 0.7)',
|
||||
'highlight' => 'rgba(0, 141, 76, 0.9)',
|
||||
'label' => trans('firefly.paid'),
|
||||
'datasets' => [
|
||||
[
|
||||
'data' => [round($unpaid, 2), round(bcmul($paid, '-1'), 2)],
|
||||
'backgroundColor' => ['rgba(53, 124, 165,0.7)', 'rgba(0, 141, 76, 0.7)',],
|
||||
],
|
||||
|
||||
],
|
||||
'labels' => [strval(trans('firefly.unpaid')), strval(trans('firefly.paid'))],
|
||||
|
||||
];
|
||||
|
||||
return $data;
|
||||
@@ -77,14 +74,17 @@ class ChartJsBillChartGenerator implements BillChartGeneratorInterface
|
||||
}
|
||||
|
||||
$data['datasets'][] = [
|
||||
'type' => 'bar',
|
||||
'label' => trans('firefly.minAmount'),
|
||||
'data' => $minAmount,
|
||||
];
|
||||
$data['datasets'][] = [
|
||||
'type' => 'line',
|
||||
'label' => trans('firefly.billEntry'),
|
||||
'data' => $actualAmount,
|
||||
];
|
||||
$data['datasets'][] = [
|
||||
'type' => 'bar',
|
||||
'label' => trans('firefly.maxAmount'),
|
||||
'data' => $maxAmount,
|
||||
];
|
||||
|
@@ -2,7 +2,7 @@
|
||||
declare(strict_types = 1);
|
||||
/**
|
||||
* BudgetChartGeneratorInterface.php
|
||||
* Copyright (C) 2016 Sander Dorigo
|
||||
* Copyright (C) 2016 thegrumpydictator@gmail.com
|
||||
*
|
||||
* This software may be modified and distributed under the terms
|
||||
* of the MIT license. See the LICENSE file for details.
|
||||
|
@@ -50,7 +50,6 @@ class ChartJsBudgetChartGenerator implements BudgetChartGeneratorInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* @codeCoverageIgnore
|
||||
*
|
||||
* @param Collection $entries
|
||||
*
|
||||
@@ -88,6 +87,10 @@ class ChartJsBudgetChartGenerator implements BudgetChartGeneratorInterface
|
||||
$overspent[] = round(bcmul($entry[3], '-1'), 2); // same
|
||||
}
|
||||
|
||||
$data['datasets'][] = [
|
||||
'label' => trans('firefly.overspent'),
|
||||
'data' => $overspent,
|
||||
];
|
||||
$data['datasets'][] = [
|
||||
'label' => trans('firefly.left'),
|
||||
'data' => $left,
|
||||
@@ -96,12 +99,8 @@ class ChartJsBudgetChartGenerator implements BudgetChartGeneratorInterface
|
||||
'label' => trans('firefly.spent'),
|
||||
'data' => $spent,
|
||||
];
|
||||
$data['datasets'][] = [
|
||||
'label' => trans('firefly.overspent'),
|
||||
'data' => $overspent,
|
||||
];
|
||||
|
||||
$data['count'] = count($data['datasets']);
|
||||
$data['count'] = 3;
|
||||
|
||||
return $data;
|
||||
}
|
||||
@@ -159,6 +158,9 @@ class ChartJsBudgetChartGenerator implements BudgetChartGeneratorInterface
|
||||
foreach ($budgets as $budget) {
|
||||
$data['labels'][] = $budget->name;
|
||||
}
|
||||
// also add "no budget"
|
||||
$data['labels'][] = strval(trans('firefly.no_budget'));
|
||||
|
||||
/** @var array $entry */
|
||||
foreach ($entries as $entry) {
|
||||
$array = [
|
||||
|
@@ -2,7 +2,7 @@
|
||||
declare(strict_types = 1);
|
||||
/**
|
||||
* CategoryChartGeneratorInterface.php
|
||||
* Copyright (C) 2016 Sander Dorigo
|
||||
* Copyright (C) 2016 thegrumpydictator@gmail.com
|
||||
*
|
||||
* This software may be modified and distributed under the terms
|
||||
* of the MIT license. See the LICENSE file for details.
|
||||
@@ -25,7 +25,7 @@ interface CategoryChartGeneratorInterface
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function all(Collection $entries);
|
||||
public function all(Collection $entries): array;
|
||||
|
||||
/**
|
||||
* @param Collection $categories
|
||||
|
@@ -148,7 +148,6 @@ class ChartJsCategoryChartGenerator implements CategoryChartGeneratorInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* @codeCoverageIgnore
|
||||
*
|
||||
* @param Collection $entries
|
||||
*
|
||||
|
@@ -2,7 +2,7 @@
|
||||
declare(strict_types = 1);
|
||||
/**
|
||||
* PiggyBankChartGenerator.php
|
||||
* Copyright (C) 2016 Sander Dorigo
|
||||
* Copyright (C) 2016 thegrumpydictator@gmail.com
|
||||
*
|
||||
* This software may be modified and distributed under the terms
|
||||
* of the MIT license. See the LICENSE file for details.
|
||||
|
@@ -89,7 +89,7 @@ class ChartJsReportChartGenerator implements ReportChartGeneratorInterface
|
||||
'labels' => [],
|
||||
'datasets' => [
|
||||
[
|
||||
'label' => trans('firefly.net-worth'),
|
||||
'label' => trans('firefly.net_worth'),
|
||||
'data' => [],
|
||||
],
|
||||
],
|
||||
|
@@ -2,7 +2,7 @@
|
||||
declare(strict_types = 1);
|
||||
/**
|
||||
* ReportChartGenerator.php
|
||||
* Copyright (C) 2016 Sander Dorigo
|
||||
* Copyright (C) 2016 thegrumpydictator@gmail.com
|
||||
*
|
||||
* This software may be modified and distributed under the terms
|
||||
* of the MIT license. See the LICENSE file for details.
|
||||
|
52
app/Handlers/Events/AttachUserRole.php
Normal file
52
app/Handlers/Events/AttachUserRole.php
Normal file
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
declare(strict_types = 1);
|
||||
/**
|
||||
* AttachUserRole.php
|
||||
* Copyright (C) 2016 thegrumpydictator@gmail.com
|
||||
*
|
||||
* This software may be modified and distributed under the terms
|
||||
* of the MIT license. See the LICENSE file for details.
|
||||
*/
|
||||
|
||||
namespace FireflyIII\Handlers\Events;
|
||||
|
||||
|
||||
use FireflyIII\Events\UserRegistration;
|
||||
use FireflyIII\Repositories\User\UserRepositoryInterface;
|
||||
use Log;
|
||||
|
||||
/**
|
||||
* Class AttachUserRole
|
||||
*
|
||||
* @package FireflyIII\Handlers\Events
|
||||
*/
|
||||
class AttachUserRole
|
||||
{
|
||||
/**
|
||||
* Create the event listener.
|
||||
*
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the event.
|
||||
*
|
||||
* @param UserRegistration $event
|
||||
*/
|
||||
public function handle(UserRegistration $event)
|
||||
{
|
||||
Log::debug('Trigger attachuserrole');
|
||||
/** @var UserRepositoryInterface $repository */
|
||||
$repository = app('FireflyIII\Repositories\User\UserRepositoryInterface');
|
||||
|
||||
// first user ever?
|
||||
if ($repository->count() == 1) {
|
||||
Log::debug('Will attach role.');
|
||||
$repository->attachRole($event->user, 'owner');
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@@ -2,7 +2,7 @@
|
||||
declare(strict_types = 1);
|
||||
/**
|
||||
* FireRulesForStore.php
|
||||
* Copyright (C) 2016 Sander Dorigo
|
||||
* Copyright (C) 2016 thegrumpydictator@gmail.com
|
||||
*
|
||||
* This software may be modified and distributed under the terms
|
||||
* of the MIT license. See the LICENSE file for details.
|
||||
@@ -36,6 +36,7 @@ class FireRulesForStore
|
||||
*/
|
||||
public function handle(TransactionJournalStored $event): bool
|
||||
{
|
||||
Log::debug('Now running FireRulesForStore because TransactionJournalStored fired.');
|
||||
// get all the user's rule groups, with the rules, order by 'order'.
|
||||
/** @var User $user */
|
||||
$user = Auth::user();
|
||||
|
@@ -2,7 +2,7 @@
|
||||
declare(strict_types = 1);
|
||||
/**
|
||||
* FireRulesForUpdate.php
|
||||
* Copyright (C) 2016 Sander Dorigo
|
||||
* Copyright (C) 2016 thegrumpydictator@gmail.com
|
||||
*
|
||||
* This software may be modified and distributed under the terms
|
||||
* of the MIT license. See the LICENSE file for details.
|
||||
@@ -34,6 +34,7 @@ class FireRulesForUpdate
|
||||
*/
|
||||
public function handle(TransactionJournalUpdated $event): bool
|
||||
{
|
||||
Log::debug('Now running FireRulesForUpdate because TransactionJournalUpdated fired.');
|
||||
// get all the user's rule groups, with the rules, order by 'order'.
|
||||
/** @var User $user */
|
||||
$user = Auth::user();
|
||||
|
@@ -2,7 +2,7 @@
|
||||
declare(strict_types = 1);
|
||||
/**
|
||||
* RescanJournalAfterStore.php
|
||||
* Copyright (C) 2016 Sander Dorigo
|
||||
* Copyright (C) 2016 thegrumpydictator@gmail.com
|
||||
*
|
||||
* This software may be modified and distributed under the terms
|
||||
* of the MIT license. See the LICENSE file for details.
|
||||
@@ -16,7 +16,6 @@ use FireflyIII\Support\Events\BillScanner;
|
||||
/**
|
||||
* Class RescanJournal
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
* @package FireflyIII\Handlers\Events
|
||||
*/
|
||||
class ScanForBillsAfterStore
|
||||
|
@@ -2,7 +2,7 @@
|
||||
declare(strict_types = 1);
|
||||
/**
|
||||
* ScanForBillsAfterUpdate.php
|
||||
* Copyright (C) 2016 Sander Dorigo
|
||||
* Copyright (C) 2016 thegrumpydictator@gmail.com
|
||||
*
|
||||
* This software may be modified and distributed under the terms
|
||||
* of the MIT license. See the LICENSE file for details.
|
||||
@@ -16,7 +16,6 @@ use FireflyIII\Support\Events\BillScanner;
|
||||
/**
|
||||
* Class RescanJournal
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
* @package FireflyIII\Handlers\Events
|
||||
*/
|
||||
class ScanForBillsAfterUpdate
|
||||
|
65
app/Handlers/Events/SendRegistrationMail.php
Normal file
65
app/Handlers/Events/SendRegistrationMail.php
Normal file
@@ -0,0 +1,65 @@
|
||||
<?php
|
||||
declare(strict_types = 1);
|
||||
/**
|
||||
* SendRegistrationMail.php
|
||||
* Copyright (C) 2016 thegrumpydictator@gmail.com
|
||||
*
|
||||
* This software may be modified and distributed under the terms
|
||||
* of the MIT license. See the LICENSE file for details.
|
||||
*/
|
||||
|
||||
namespace FireflyIII\Handlers\Events;
|
||||
|
||||
|
||||
use FireflyIII\Events\UserRegistration;
|
||||
use Illuminate\Mail\Message;
|
||||
use Log;
|
||||
use Mail;
|
||||
use Swift_TransportException;
|
||||
|
||||
/**
|
||||
* Class SendRegistrationMail
|
||||
*
|
||||
* @package FireflyIII\Handlers\Events
|
||||
*/
|
||||
class SendRegistrationMail
|
||||
{
|
||||
/**
|
||||
* Create the event listener.
|
||||
*
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the event.
|
||||
*
|
||||
* @param UserRegistration $event
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function handle(UserRegistration $event): bool
|
||||
{
|
||||
$sendMail = env('SEND_REGISTRATION_MAIL', true);
|
||||
if (!$sendMail) {
|
||||
return true;
|
||||
}
|
||||
// get the email address
|
||||
$email = $event->user->email;
|
||||
$address = route('index');
|
||||
$ipAddress = $event->ipAddress;
|
||||
// send email.
|
||||
try {
|
||||
Mail::send(
|
||||
['emails.registered-html', 'emails.registered'], ['address' => $address, 'ip' => $ipAddress], function (Message $message) use ($email) {
|
||||
$message->to($email, $email)->subject('Welcome to Firefly III! ');
|
||||
}
|
||||
);
|
||||
} catch (Swift_TransportException $e) {
|
||||
Log::error($e->getMessage());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
@@ -10,7 +10,6 @@ use FireflyIII\Models\TransactionJournal;
|
||||
/**
|
||||
* Class UpdateJournalConnection
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
* @package FireflyIII\Handlers\Events
|
||||
*/
|
||||
class UpdateJournalConnection
|
||||
|
121
app/Handlers/Events/UserConfirmation.php
Normal file
121
app/Handlers/Events/UserConfirmation.php
Normal file
@@ -0,0 +1,121 @@
|
||||
<?php
|
||||
declare(strict_types = 1);
|
||||
/**
|
||||
* UserConfirmation.php
|
||||
* Copyright (C) 2016 thegrumpydictator@gmail.com
|
||||
*
|
||||
* This software may be modified and distributed under the terms
|
||||
* of the MIT license. See the LICENSE file for details.
|
||||
*/
|
||||
|
||||
namespace FireflyIII\Handlers\Events;
|
||||
|
||||
|
||||
use Exception;
|
||||
use FireflyIII\Events\ResendConfirmation;
|
||||
use FireflyIII\Events\UserRegistration;
|
||||
use FireflyIII\User;
|
||||
use Illuminate\Mail\Message;
|
||||
use Log;
|
||||
use Mail;
|
||||
use Preferences;
|
||||
use Swift_TransportException;
|
||||
|
||||
/**
|
||||
* Class UserConfirmation
|
||||
*
|
||||
* @package FireflyIII\Handlers\Events
|
||||
*/
|
||||
class UserConfirmation
|
||||
{
|
||||
/**
|
||||
* Create the event listener.
|
||||
*
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ResendConfirmation $event
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function resendConfirmation(ResendConfirmation $event): bool
|
||||
{
|
||||
$user = $event->user;
|
||||
$ipAddress = $event->ipAddress;
|
||||
$this->doConfirm($user, $ipAddress);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the event.
|
||||
*
|
||||
* @param UserRegistration $event
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function sendConfirmation(UserRegistration $event): bool
|
||||
{
|
||||
$user = $event->user;
|
||||
$ipAddress = $event->ipAddress;
|
||||
$this->doConfirm($user, $ipAddress);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param User $user
|
||||
* @param string $ipAddress
|
||||
*/
|
||||
private function doConfirm(User $user, string $ipAddress)
|
||||
{
|
||||
Log::debug('Trigger UserConfirmation::doConfirm');
|
||||
|
||||
// if user must confirm account, send email
|
||||
$confirmAccount = env('MUST_CONFIRM_ACCOUNT', false);
|
||||
|
||||
// otherwise, auto-confirm:
|
||||
if ($confirmAccount === false) {
|
||||
Log::debug('Confirm account is false, so user will be auto-confirmed.');
|
||||
Preferences::setForUser($user, 'user_confirmed', true);
|
||||
Preferences::setForUser($user, 'user_confirmed_last_mail', 0);
|
||||
Preferences::mark();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// send email message:
|
||||
$email = $user->email;
|
||||
$code = str_random(16);
|
||||
$route = route('do_confirm_account', [$code]);
|
||||
|
||||
// set preferences:
|
||||
Preferences::setForUser($user, 'user_confirmed', false);
|
||||
Preferences::setForUser($user, 'user_confirmed_last_mail', time());
|
||||
Preferences::setForUser($user, 'user_confirmed_code', $code);
|
||||
Log::debug('Set preferences for user.');
|
||||
|
||||
// send email.
|
||||
try {
|
||||
Log::debug('Now in try block for user email message thing to ' . $email . '.');
|
||||
Mail::send(
|
||||
['emails.confirm-account-html', 'emails.confirm-account'], ['route' => $route, 'ip' => $ipAddress],
|
||||
function (Message $message) use ($email) {
|
||||
$message->to($email, $email)->subject('Please confirm your Firefly III account');
|
||||
}
|
||||
);
|
||||
} catch (Swift_TransportException $e) {
|
||||
|
||||
Log::error($e->getMessage());
|
||||
} catch (Exception $e) {
|
||||
Log::debug('Caught general exception.');
|
||||
Log::error($e->getMessage());
|
||||
}
|
||||
Log::debug('Finished mail handling for activation.');
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
@@ -1,7 +1,8 @@
|
||||
<?php
|
||||
declare(strict_types = 1);
|
||||
/**
|
||||
* UserEventListener.php
|
||||
* Copyright (C) 2016 Sander Dorigo
|
||||
* Copyright (C) 2016 thegrumpydictator@gmail.com
|
||||
*
|
||||
* This software may be modified and distributed under the terms
|
||||
* of the MIT license. See the LICENSE file for details.
|
||||
@@ -20,8 +21,10 @@ class UserEventListener
|
||||
{
|
||||
/**
|
||||
* Handle user logout events.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function onUserLogout($event)
|
||||
public function onUserLogout(): bool
|
||||
{
|
||||
// dump stuff from the session:
|
||||
Session::forget('twofactor-authenticated');
|
||||
@@ -29,4 +32,4 @@ class UserEventListener
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -5,7 +5,6 @@ namespace FireflyIII\Helpers\Collection;
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
/**
|
||||
* @codeCoverageIgnore
|
||||
* Class Account
|
||||
*
|
||||
* @package FireflyIII\Helpers\Collection
|
||||
|
@@ -5,7 +5,6 @@ namespace FireflyIII\Helpers\Collection;
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
/**
|
||||
* @codeCoverageIgnore
|
||||
*
|
||||
* Class Balance
|
||||
*
|
||||
|
@@ -5,7 +5,6 @@ namespace FireflyIII\Helpers\Collection;
|
||||
use FireflyIII\Models\Account as AccountModel;
|
||||
|
||||
/**
|
||||
* @codeCoverageIgnore
|
||||
*
|
||||
* Class BalanceEntry
|
||||
*
|
||||
|
@@ -6,7 +6,6 @@ use FireflyIII\Models\Account as AccountModel;
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
/**
|
||||
* @codeCoverageIgnore
|
||||
*
|
||||
* Class BalanceHeader
|
||||
*
|
||||
|
@@ -6,7 +6,6 @@ use FireflyIII\Models\Budget as BudgetModel;
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
/**
|
||||
* @codeCoverageIgnore
|
||||
*
|
||||
* Class BalanceLine
|
||||
*
|
||||
@@ -102,7 +101,7 @@ class BalanceLine
|
||||
return $this->getBudget()->name;
|
||||
}
|
||||
if ($this->getRole() == self::ROLE_DEFAULTROLE) {
|
||||
return trans('firefly.noBudget');
|
||||
return trans('firefly.no_budget');
|
||||
}
|
||||
if ($this->getRole() == self::ROLE_TAGROLE) {
|
||||
return trans('firefly.coveredWithTags');
|
||||
|
@@ -6,7 +6,6 @@ namespace FireflyIII\Helpers\Collection;
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
/**
|
||||
* @codeCoverageIgnore
|
||||
* Class Bill
|
||||
*
|
||||
* @package FireflyIII\Helpers\Collection
|
||||
|
@@ -5,7 +5,6 @@ namespace FireflyIII\Helpers\Collection;
|
||||
use FireflyIII\Models\Bill as BillModel;
|
||||
|
||||
/**
|
||||
* @codeCoverageIgnore
|
||||
*
|
||||
* Class BillLine
|
||||
*
|
||||
@@ -111,7 +110,7 @@ class BillLine
|
||||
}
|
||||
|
||||
/**
|
||||
* @return boolean
|
||||
* @return bool
|
||||
*/
|
||||
public function isActive(): bool
|
||||
{
|
||||
@@ -127,7 +126,7 @@ class BillLine
|
||||
}
|
||||
|
||||
/**
|
||||
* @return boolean
|
||||
* @return bool
|
||||
*/
|
||||
public function isHit(): bool
|
||||
{
|
||||
|
@@ -5,7 +5,6 @@ namespace FireflyIII\Helpers\Collection;
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
/**
|
||||
* @codeCoverageIgnore
|
||||
*
|
||||
* Class Budget
|
||||
*
|
||||
|
@@ -6,7 +6,6 @@ use FireflyIII\Models\Budget as BudgetModel;
|
||||
use FireflyIII\Models\LimitRepetition;
|
||||
|
||||
/**
|
||||
* @codeCoverageIgnore
|
||||
*
|
||||
* Class BudgetLine
|
||||
*
|
||||
|
@@ -7,7 +7,6 @@ use Illuminate\Support\Collection;
|
||||
|
||||
|
||||
/**
|
||||
* @codeCoverageIgnore
|
||||
*
|
||||
* Class Category
|
||||
*
|
||||
|
@@ -8,7 +8,6 @@ use Illuminate\Support\Collection;
|
||||
use stdClass;
|
||||
|
||||
/**
|
||||
* @codeCoverageIgnore
|
||||
*
|
||||
* Class Expense
|
||||
*
|
||||
|
@@ -8,7 +8,6 @@ use Illuminate\Support\Collection;
|
||||
use stdClass;
|
||||
|
||||
/**
|
||||
* @codeCoverageIgnore
|
||||
*
|
||||
* Class Income
|
||||
*
|
||||
|
@@ -2,9 +2,8 @@
|
||||
declare(strict_types = 1);
|
||||
namespace FireflyIII\Helpers\Csv\Converter;
|
||||
|
||||
use Auth;
|
||||
use FireflyIII\Models\Account;
|
||||
use Log;
|
||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||
|
||||
/**
|
||||
* Class AccountId
|
||||
@@ -19,22 +18,16 @@ class AccountId extends BasicConverter implements ConverterInterface
|
||||
*/
|
||||
public function convert(): Account
|
||||
{
|
||||
/** @var AccountRepositoryInterface $repository */
|
||||
$repository = app('FireflyIII\Repositories\Account\AccountRepositoryInterface');
|
||||
|
||||
// is mapped? Then it's easy!
|
||||
if (isset($this->mapped[$this->index][$this->value])) {
|
||||
|
||||
/** @var Account $account */
|
||||
$account = Auth::user()->accounts()->find($this->mapped[$this->index][$this->value]);
|
||||
$account = $repository->find($this->mapped[$this->index][$this->value]);
|
||||
} else {
|
||||
|
||||
/** @var Account $account */
|
||||
$account = Auth::user()->accounts()->find($this->value);
|
||||
|
||||
if (!is_null($account)) {
|
||||
Log::debug('Found ' . $account->accountType->type . ' named "******" with ID: ' . $this->value . ' (not mapped) ');
|
||||
} else {
|
||||
// new account to prevent TypeErrors.
|
||||
$account = new Account;
|
||||
}
|
||||
$account = $repository->find($this->value);
|
||||
}
|
||||
|
||||
return $account;
|
||||
|
@@ -15,7 +15,7 @@ class AmountComma extends BasicConverter implements ConverterInterface
|
||||
/**
|
||||
* @return float|int
|
||||
*/
|
||||
public function convert()
|
||||
public function convert(): string
|
||||
{
|
||||
$value = str_replace(',', '.', strval($this->value));
|
||||
|
||||
|
@@ -5,6 +5,8 @@ namespace FireflyIII\Helpers\Csv\Converter;
|
||||
use Auth;
|
||||
use Carbon\Carbon;
|
||||
use FireflyIII\Models\Account;
|
||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||
use Log;
|
||||
|
||||
/**
|
||||
* Class AssetAccountIban
|
||||
@@ -19,60 +21,52 @@ class AssetAccountIban extends BasicConverter implements ConverterInterface
|
||||
*/
|
||||
public function convert(): Account
|
||||
{
|
||||
/** @var AccountRepositoryInterface $repository */
|
||||
$repository = app('FireflyIII\Repositories\Account\AccountRepositoryInterface');
|
||||
|
||||
// is mapped? Then it's easy!
|
||||
if (isset($this->mapped[$this->index][$this->value])) {
|
||||
$account = Auth::user()->accounts()->find($this->mapped[$this->index][$this->value]);
|
||||
$account = $repository->find(intval($this->mapped[$this->index][$this->value]));
|
||||
Log::debug('Found mapped account for value "' . $this->value . '". It is account #' . $account->id);
|
||||
|
||||
return $account;
|
||||
}
|
||||
|
||||
if (strlen($this->value) > 0) {
|
||||
// find or create new account:
|
||||
$account = $this->findAccount();
|
||||
$set = $repository->getAccounts(['Default account', 'Asset account']);
|
||||
/** @var Account $entry */
|
||||
foreach ($set as $entry) {
|
||||
if ($entry->iban == $this->value) {
|
||||
Log::debug('Found an account with the same IBAN ("' . $this->value . '"). It is account #' . $entry->id);
|
||||
|
||||
if (is_null($account->id)) {
|
||||
// create it if doesn't exist.
|
||||
|
||||
$repository = app('FireflyIII\Repositories\Account\AccountRepositoryInterface');
|
||||
$accountData = [
|
||||
'name' => $this->value,
|
||||
'accountType' => 'asset',
|
||||
'virtualBalance' => 0,
|
||||
'virtualBalanceCurrency' => 1, // hard coded.
|
||||
'active' => true,
|
||||
'user' => Auth::user()->id,
|
||||
'iban' => null,
|
||||
'accountNumber' => $this->value,
|
||||
'accountRole' => null,
|
||||
'openingBalance' => 0,
|
||||
'openingBalanceDate' => new Carbon,
|
||||
'openingBalanceCurrency' => 1, // hard coded.
|
||||
|
||||
];
|
||||
|
||||
$account = $repository->store($accountData);
|
||||
return $entry;
|
||||
}
|
||||
}
|
||||
|
||||
Log::debug('Found no account with the same IBAN ("' . $this->value . '"), so will create a new one.');
|
||||
|
||||
// create it if doesn't exist.
|
||||
$accountData = [
|
||||
'name' => $this->value,
|
||||
'accountType' => 'asset',
|
||||
'virtualBalance' => 0,
|
||||
'virtualBalanceCurrency' => 1, // hard coded.
|
||||
'active' => true,
|
||||
'user' => Auth::user()->id,
|
||||
'iban' => $this->value,
|
||||
'accountNumber' => $this->value,
|
||||
'accountRole' => null,
|
||||
'openingBalance' => 0,
|
||||
'openingBalanceDate' => new Carbon,
|
||||
'openingBalanceCurrency' => 1, // hard coded.
|
||||
];
|
||||
|
||||
$account = $repository->store($accountData);
|
||||
|
||||
return $account;
|
||||
}
|
||||
|
||||
return new Account;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Account
|
||||
*/
|
||||
protected function findAccount(): Account
|
||||
{
|
||||
$set = Auth::user()->accounts()->accountTypeIn(['Default account', 'Asset account'])->get(['accounts.*']);
|
||||
/** @var Account $entry */
|
||||
foreach ($set as $entry) {
|
||||
if ($entry->iban == $this->value) {
|
||||
|
||||
return $entry;
|
||||
}
|
||||
}
|
||||
|
||||
return new Account;
|
||||
}
|
||||
}
|
||||
|
@@ -5,6 +5,7 @@ namespace FireflyIII\Helpers\Csv\Converter;
|
||||
use Auth;
|
||||
use Carbon\Carbon;
|
||||
use FireflyIII\Models\Account;
|
||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||
|
||||
/**
|
||||
* Class AssetAccountName
|
||||
@@ -17,16 +18,21 @@ class AssetAccountName extends BasicConverter implements ConverterInterface
|
||||
/**
|
||||
* @return Account|null
|
||||
*/
|
||||
public function convert()
|
||||
public function convert(): Account
|
||||
{
|
||||
/** @var AccountRepositoryInterface $repository */
|
||||
$repository = app('FireflyIII\Repositories\Account\AccountRepositoryInterface');
|
||||
|
||||
// is mapped? Then it's easy!
|
||||
if (isset($this->mapped[$this->index][$this->value])) {
|
||||
$account = Auth::user()->accounts()->find($this->mapped[$this->index][$this->value]);
|
||||
$account = $repository->find(intval($this->mapped[$this->index][$this->value]));
|
||||
|
||||
return $account;
|
||||
}
|
||||
|
||||
|
||||
// find or create new account:
|
||||
$set = Auth::user()->accounts()->accountTypeIn(['Asset account', 'Default account'])->get();
|
||||
$set = $repository->getAccounts(['Default account', 'Asset account']);
|
||||
/** @var Account $entry */
|
||||
foreach ($set as $entry) {
|
||||
if ($entry->name == $this->value) {
|
||||
@@ -35,8 +41,6 @@ class AssetAccountName extends BasicConverter implements ConverterInterface
|
||||
}
|
||||
|
||||
// create it if doesnt exist.
|
||||
|
||||
$repository = app('FireflyIII\Repositories\Account\AccountRepositoryInterface');
|
||||
$accountData = [
|
||||
'name' => $this->value,
|
||||
'accountType' => 'asset',
|
||||
|
@@ -1,7 +1,8 @@
|
||||
<?php
|
||||
declare(strict_types = 1);
|
||||
/**
|
||||
* AssetAccountNumber.php
|
||||
* Copyright (C) 2016 Sander Dorigo
|
||||
* Copyright (C) 2016 thegrumpydictator@gmail.com
|
||||
*
|
||||
* This software may be modified and distributed under the terms
|
||||
* of the MIT license. See the LICENSE file for details.
|
||||
@@ -13,6 +14,7 @@ namespace FireflyIII\Helpers\Csv\Converter;
|
||||
use Auth;
|
||||
use Carbon\Carbon;
|
||||
use FireflyIII\Models\Account;
|
||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||
|
||||
/**
|
||||
* Class AssetAccountNumber
|
||||
@@ -25,11 +27,14 @@ class AssetAccountNumber extends BasicConverter implements ConverterInterface
|
||||
/**
|
||||
* @return Account|null
|
||||
*/
|
||||
public function convert()
|
||||
public function convert(): Account
|
||||
{
|
||||
/** @var AccountRepositoryInterface $repository */
|
||||
$repository = app('FireflyIII\Repositories\Account\AccountRepositoryInterface');
|
||||
|
||||
// is mapped? Then it's easy!
|
||||
if (isset($this->mapped[$this->index][$this->value])) {
|
||||
$account = Auth::user()->accounts()->find($this->mapped[$this->index][$this->value]);
|
||||
$account = $repository->find(intval($this->mapped[$this->index][$this->value]));
|
||||
|
||||
return $account;
|
||||
}
|
||||
@@ -37,53 +42,38 @@ class AssetAccountNumber extends BasicConverter implements ConverterInterface
|
||||
$value = $this->value ?? '';
|
||||
if (strlen($value) > 0) {
|
||||
// find or create new account:
|
||||
$account = $this->findAccount();
|
||||
$set = $repository->getAccounts(['Default account', 'Asset account']);
|
||||
/** @var Account $entry */
|
||||
foreach ($set as $entry) {
|
||||
$accountNumber = $entry->getMeta('accountNumber');
|
||||
if ($accountNumber == $this->value) {
|
||||
|
||||
if (is_null($account->id)) {
|
||||
// create it if doesn't exist.
|
||||
$repository = app('FireflyIII\Repositories\Account\AccountRepositoryInterface');
|
||||
|
||||
|
||||
$accountData = [
|
||||
'name' => $this->value,
|
||||
'accountType' => 'asset',
|
||||
'virtualBalance' => 0,
|
||||
'virtualBalanceCurrency' => 1, // hard coded.
|
||||
'active' => true,
|
||||
'user' => Auth::user()->id,
|
||||
'iban' => null,
|
||||
'accountNumber' => $this->value,
|
||||
'accountRole' => null,
|
||||
'openingBalance' => 0,
|
||||
'openingBalanceDate' => new Carbon,
|
||||
'openingBalanceCurrency' => 1, // hard coded.
|
||||
|
||||
];
|
||||
|
||||
$account = $repository->store($accountData);
|
||||
return $entry;
|
||||
}
|
||||
}
|
||||
|
||||
$accountData = [
|
||||
'name' => $this->value,
|
||||
'accountType' => 'asset',
|
||||
'virtualBalance' => 0,
|
||||
'virtualBalanceCurrency' => 1, // hard coded.
|
||||
'active' => true,
|
||||
'user' => Auth::user()->id,
|
||||
'iban' => null,
|
||||
'accountNumber' => $this->value,
|
||||
'accountRole' => null,
|
||||
'openingBalance' => 0,
|
||||
'openingBalanceDate' => new Carbon,
|
||||
'openingBalanceCurrency' => 1, // hard coded.
|
||||
|
||||
];
|
||||
|
||||
$account = $repository->store($accountData);
|
||||
|
||||
return $account;
|
||||
}
|
||||
|
||||
return null;
|
||||
return null; // is this accepted?
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Account
|
||||
*/
|
||||
protected function findAccount(): Account
|
||||
{
|
||||
$set = Auth::user()->accounts()->with(['accountmeta'])->accountTypeIn(['Default account', 'Asset account'])->get(['accounts.*']);
|
||||
/** @var Account $entry */
|
||||
foreach ($set as $entry) {
|
||||
$accountNumber = $entry->getMeta('accountNumber');
|
||||
if ($accountNumber == $this->value) {
|
||||
|
||||
return $entry;
|
||||
}
|
||||
}
|
||||
|
||||
return new Account;
|
||||
}
|
||||
}
|
||||
|
@@ -23,7 +23,7 @@ class BasicConverter
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getData()
|
||||
public function getData(): array
|
||||
{
|
||||
return $this->data;
|
||||
}
|
||||
@@ -39,7 +39,7 @@ class BasicConverter
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getField()
|
||||
public function getField(): string
|
||||
{
|
||||
return $this->field;
|
||||
}
|
||||
@@ -47,7 +47,7 @@ class BasicConverter
|
||||
/**
|
||||
* @param string $field
|
||||
*/
|
||||
public function setField($field)
|
||||
public function setField(string $field)
|
||||
{
|
||||
$this->field = $field;
|
||||
}
|
||||
@@ -55,7 +55,7 @@ class BasicConverter
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getIndex()
|
||||
public function getIndex(): int
|
||||
{
|
||||
return $this->index;
|
||||
}
|
||||
@@ -63,7 +63,7 @@ class BasicConverter
|
||||
/**
|
||||
* @param int $index
|
||||
*/
|
||||
public function setIndex($index)
|
||||
public function setIndex(int $index)
|
||||
{
|
||||
$this->index = $index;
|
||||
}
|
||||
@@ -71,7 +71,7 @@ class BasicConverter
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getMapped()
|
||||
public function getMapped(): array
|
||||
{
|
||||
return $this->mapped;
|
||||
}
|
||||
@@ -79,7 +79,7 @@ class BasicConverter
|
||||
/**
|
||||
* @param array $mapped
|
||||
*/
|
||||
public function setMapped($mapped)
|
||||
public function setMapped(array $mapped)
|
||||
{
|
||||
$this->mapped = $mapped;
|
||||
}
|
||||
@@ -87,7 +87,7 @@ class BasicConverter
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getValue()
|
||||
public function getValue(): string
|
||||
{
|
||||
return $this->value;
|
||||
}
|
||||
@@ -95,7 +95,7 @@ class BasicConverter
|
||||
/**
|
||||
* @param string $value
|
||||
*/
|
||||
public function setValue($value)
|
||||
public function setValue(string $value)
|
||||
{
|
||||
$this->value = $value;
|
||||
}
|
||||
|
@@ -2,8 +2,8 @@
|
||||
declare(strict_types = 1);
|
||||
namespace FireflyIII\Helpers\Csv\Converter;
|
||||
|
||||
use Auth;
|
||||
use FireflyIII\Models\Bill;
|
||||
use FireflyIII\Repositories\Bill\BillRepositoryInterface;
|
||||
|
||||
/**
|
||||
* Class BillId
|
||||
@@ -16,13 +16,16 @@ class BillId extends BasicConverter implements ConverterInterface
|
||||
/**
|
||||
* @return Bill
|
||||
*/
|
||||
public function convert()
|
||||
public function convert(): Bill
|
||||
{
|
||||
/** @var BillRepositoryInterface $repository */
|
||||
$repository = app('FireflyIII\Repositories\Bill\BillRepositoryInterface');
|
||||
|
||||
// is mapped? Then it's easy!
|
||||
if (isset($this->mapped[$this->index][$this->value])) {
|
||||
$bill = Auth::user()->bills()->find($this->mapped[$this->index][$this->value]);
|
||||
$bill = $repository->find($this->mapped[$this->index][$this->value]);
|
||||
} else {
|
||||
$bill = Auth::user()->bills()->find($this->value);
|
||||
$bill = $repository->find($this->value);
|
||||
}
|
||||
|
||||
return $bill;
|
||||
|
@@ -2,8 +2,8 @@
|
||||
declare(strict_types = 1);
|
||||
namespace FireflyIII\Helpers\Csv\Converter;
|
||||
|
||||
use Auth;
|
||||
use FireflyIII\Models\Bill;
|
||||
use FireflyIII\Repositories\Bill\BillRepositoryInterface;
|
||||
|
||||
/**
|
||||
* Class BillName
|
||||
@@ -16,15 +16,17 @@ class BillName extends BasicConverter implements ConverterInterface
|
||||
/**
|
||||
* @return Bill
|
||||
*/
|
||||
public function convert()
|
||||
public function convert(): Bill
|
||||
{
|
||||
$bill = null;
|
||||
/** @var BillRepositoryInterface $repository */
|
||||
$repository = app('FireflyIII\Repositories\Bill\BillRepositoryInterface');
|
||||
|
||||
$bill = new Bill;
|
||||
// is mapped? Then it's easy!
|
||||
if (isset($this->mapped[$this->index][$this->value])) {
|
||||
$bill = Auth::user()->bills()->find($this->mapped[$this->index][$this->value]);
|
||||
$bill = $repository->find($this->mapped[$this->index][$this->value]);
|
||||
} else {
|
||||
|
||||
$bills = Auth::user()->bills()->get();
|
||||
$bills = $repository->getBills();
|
||||
/** @var Bill $bill */
|
||||
foreach ($bills as $bill) {
|
||||
if ($bill->name == $this->value) {
|
||||
|
@@ -2,8 +2,8 @@
|
||||
declare(strict_types = 1);
|
||||
namespace FireflyIII\Helpers\Csv\Converter;
|
||||
|
||||
use Auth;
|
||||
use FireflyIII\Models\Budget;
|
||||
use FireflyIII\Repositories\Budget\BudgetRepositoryInterface;
|
||||
|
||||
/**
|
||||
* Class BudgetId
|
||||
@@ -16,13 +16,17 @@ class BudgetId extends BasicConverter implements ConverterInterface
|
||||
/**
|
||||
* @return Budget
|
||||
*/
|
||||
public function convert()
|
||||
public function convert(): Budget
|
||||
{
|
||||
/** @var BudgetRepositoryInterface $repository */
|
||||
$repository = app('FireflyIII\Repositories\Budget\BudgetRepositoryInterface');
|
||||
|
||||
|
||||
// is mapped? Then it's easy!
|
||||
if (isset($this->mapped[$this->index][$this->value])) {
|
||||
$budget = Auth::user()->budgets()->find($this->mapped[$this->index][$this->value]);
|
||||
$budget = $repository->find($this->mapped[$this->index][$this->value]);
|
||||
} else {
|
||||
$budget = Auth::user()->budgets()->find($this->value);
|
||||
$budget = $repository->find($this->value);
|
||||
}
|
||||
|
||||
return $budget;
|
||||
|
@@ -4,6 +4,7 @@ namespace FireflyIII\Helpers\Csv\Converter;
|
||||
|
||||
use Auth;
|
||||
use FireflyIII\Models\Budget;
|
||||
use FireflyIII\Repositories\Budget\BudgetRepositoryInterface;
|
||||
|
||||
/**
|
||||
* Class BudgetName
|
||||
@@ -16,14 +17,16 @@ class BudgetName extends BasicConverter implements ConverterInterface
|
||||
/**
|
||||
* @return Budget
|
||||
*/
|
||||
public function convert()
|
||||
public function convert(): Budget
|
||||
{
|
||||
/** @var BudgetRepositoryInterface $repository */
|
||||
$repository = app('FireflyIII\Repositories\Budget\BudgetRepositoryInterface');
|
||||
|
||||
// is mapped? Then it's easy!
|
||||
if (isset($this->mapped[$this->index][$this->value])) {
|
||||
$budget = Auth::user()->budgets()->find($this->mapped[$this->index][$this->value]); // see issue #180
|
||||
$budget = $repository->find($this->mapped[$this->index][$this->value]);
|
||||
} else {
|
||||
$repository = app('FireflyIII\Repositories\Budget\BudgetRepositoryInterface');
|
||||
$budget = $repository->store(['name' => $this->value, 'user' => Auth::user()->id]);
|
||||
$budget = $repository->store(['name' => $this->value, 'user' => Auth::user()->id]);
|
||||
}
|
||||
|
||||
return $budget;
|
||||
|
@@ -2,8 +2,8 @@
|
||||
declare(strict_types = 1);
|
||||
namespace FireflyIII\Helpers\Csv\Converter;
|
||||
|
||||
use Auth;
|
||||
use FireflyIII\Models\Category;
|
||||
use FireflyIII\Repositories\Category\SingleCategoryRepositoryInterface;
|
||||
|
||||
/**
|
||||
* Class CategoryId
|
||||
@@ -16,13 +16,16 @@ class CategoryId extends BasicConverter implements ConverterInterface
|
||||
/**
|
||||
* @return Category
|
||||
*/
|
||||
public function convert()
|
||||
public function convert(): Category
|
||||
{
|
||||
/** @var SingleCategoryRepositoryInterface $repository */
|
||||
$repository = app('FireflyIII\Repositories\Category\SingleCategoryRepositoryInterface');
|
||||
|
||||
// is mapped? Then it's easy!
|
||||
if (isset($this->mapped[$this->index][$this->value])) {
|
||||
$category = Auth::user()->categories()->find($this->mapped[$this->index][$this->value]);
|
||||
$category = $repository->find($this->mapped[$this->index][$this->value]);
|
||||
} else {
|
||||
$category = Auth::user()->categories()->find($this->value);
|
||||
$category = $repository->find($this->value);
|
||||
}
|
||||
|
||||
return $category;
|
||||
|
@@ -4,6 +4,7 @@ namespace FireflyIII\Helpers\Csv\Converter;
|
||||
|
||||
use Auth;
|
||||
use FireflyIII\Models\Category;
|
||||
use FireflyIII\Repositories\Category\SingleCategoryRepositoryInterface;
|
||||
|
||||
/**
|
||||
* Class CategoryName
|
||||
@@ -16,18 +17,22 @@ class CategoryName extends BasicConverter implements ConverterInterface
|
||||
/**
|
||||
* @return Category
|
||||
*/
|
||||
public function convert()
|
||||
public function convert(): Category
|
||||
{
|
||||
/** @var SingleCategoryRepositoryInterface $repository */
|
||||
$repository = app('FireflyIII\Repositories\Category\SingleCategoryRepositoryInterface');
|
||||
|
||||
// is mapped? Then it's easy!
|
||||
if (isset($this->mapped[$this->index][$this->value])) {
|
||||
$category = Auth::user()->categories()->find($this->mapped[$this->index][$this->value]);
|
||||
$category = $repository->find($this->mapped[$this->index][$this->value]);
|
||||
} else {
|
||||
$category = Category::firstOrCreateEncrypted( // See issue #180
|
||||
[
|
||||
'name' => $this->value,
|
||||
'user_id' => Auth::user()->id,
|
||||
]
|
||||
);
|
||||
|
||||
$data = [
|
||||
'name' => $this->value,
|
||||
'user' => Auth::user()->id,
|
||||
];
|
||||
|
||||
$category = $repository->store($data);
|
||||
}
|
||||
|
||||
return $category;
|
||||
|
@@ -24,21 +24,21 @@ interface ConverterInterface
|
||||
* @param string $field
|
||||
*
|
||||
*/
|
||||
public function setField($field);
|
||||
public function setField(string $field);
|
||||
|
||||
/**
|
||||
* @param int $index
|
||||
*/
|
||||
public function setIndex($index);
|
||||
public function setIndex(int $index);
|
||||
|
||||
/**
|
||||
* @param array $mapped
|
||||
*/
|
||||
public function setMapped($mapped);
|
||||
public function setMapped(array $mapped);
|
||||
|
||||
/**
|
||||
* @param string $value
|
||||
*/
|
||||
public function setValue($value);
|
||||
public function setValue(string $value);
|
||||
|
||||
}
|
||||
|
@@ -3,6 +3,7 @@ declare(strict_types = 1);
|
||||
namespace FireflyIII\Helpers\Csv\Converter;
|
||||
|
||||
use FireflyIII\Models\TransactionCurrency;
|
||||
use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;
|
||||
|
||||
/**
|
||||
* Class CurrencyCode
|
||||
@@ -15,12 +16,16 @@ class CurrencyCode extends BasicConverter implements ConverterInterface
|
||||
/**
|
||||
* @return TransactionCurrency
|
||||
*/
|
||||
public function convert()
|
||||
public function convert(): TransactionCurrency
|
||||
{
|
||||
/** @var CurrencyRepositoryInterface $repository */
|
||||
$repository = app('FireflyIII\Repositories\Currency\CurrencyRepositoryInterface');
|
||||
|
||||
|
||||
if (isset($this->mapped[$this->index][$this->value])) {
|
||||
$currency = TransactionCurrency::find($this->mapped[$this->index][$this->value]);
|
||||
$currency = $repository->find($this->mapped[$this->index][$this->value]);
|
||||
} else {
|
||||
$currency = TransactionCurrency::whereCode($this->value)->first();
|
||||
$currency = $repository->findByCode($this->value);
|
||||
}
|
||||
|
||||
return $currency;
|
||||
|
@@ -3,6 +3,7 @@ declare(strict_types = 1);
|
||||
namespace FireflyIII\Helpers\Csv\Converter;
|
||||
|
||||
use FireflyIII\Models\TransactionCurrency;
|
||||
use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;
|
||||
|
||||
/**
|
||||
* Class CurrencyId
|
||||
@@ -15,12 +16,15 @@ class CurrencyId extends BasicConverter implements ConverterInterface
|
||||
/**
|
||||
* @return TransactionCurrency
|
||||
*/
|
||||
public function convert()
|
||||
public function convert(): TransactionCurrency
|
||||
{
|
||||
/** @var CurrencyRepositoryInterface $repository */
|
||||
$repository = app('FireflyIII\Repositories\Currency\CurrencyRepositoryInterface');
|
||||
|
||||
if (isset($this->mapped[$this->index][$this->value])) {
|
||||
$currency = TransactionCurrency::find($this->mapped[$this->index][$this->value]);
|
||||
$currency = $repository->find($this->mapped[$this->index][$this->value]);
|
||||
} else {
|
||||
$currency = TransactionCurrency::find($this->value);
|
||||
$currency = $repository->find($this->value);
|
||||
}
|
||||
|
||||
return $currency;
|
||||
|
@@ -3,6 +3,7 @@ declare(strict_types = 1);
|
||||
namespace FireflyIII\Helpers\Csv\Converter;
|
||||
|
||||
use FireflyIII\Models\TransactionCurrency;
|
||||
use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;
|
||||
|
||||
/**
|
||||
* Class CurrencyName
|
||||
@@ -15,12 +16,16 @@ class CurrencyName extends BasicConverter implements ConverterInterface
|
||||
/**
|
||||
* @return TransactionCurrency
|
||||
*/
|
||||
public function convert()
|
||||
public function convert(): TransactionCurrency
|
||||
{
|
||||
/** @var CurrencyRepositoryInterface $repository */
|
||||
$repository = app('FireflyIII\Repositories\Currency\CurrencyRepositoryInterface');
|
||||
|
||||
if (isset($this->mapped[$this->index][$this->value])) {
|
||||
$currency = TransactionCurrency::find($this->mapped[$this->index][$this->value]);
|
||||
|
||||
$currency = $repository->find($this->mapped[$this->index][$this->value]);
|
||||
} else {
|
||||
$currency = TransactionCurrency::whereName($this->value)->first();
|
||||
$currency = $repository->findByName($this->value);
|
||||
}
|
||||
|
||||
return $currency;
|
||||
|
@@ -3,6 +3,7 @@ declare(strict_types = 1);
|
||||
namespace FireflyIII\Helpers\Csv\Converter;
|
||||
|
||||
use FireflyIII\Models\TransactionCurrency;
|
||||
use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;
|
||||
|
||||
/**
|
||||
* Class CurrencySymbol
|
||||
@@ -15,12 +16,15 @@ class CurrencySymbol extends BasicConverter implements ConverterInterface
|
||||
/**
|
||||
* @return TransactionCurrency
|
||||
*/
|
||||
public function convert()
|
||||
public function convert(): TransactionCurrency
|
||||
{
|
||||
/** @var CurrencyRepositoryInterface $repository */
|
||||
$repository = app('FireflyIII\Repositories\Currency\CurrencyRepositoryInterface');
|
||||
|
||||
if (isset($this->mapped[$this->index][$this->value])) {
|
||||
$currency = TransactionCurrency::find($this->mapped[$this->index][$this->value]);
|
||||
$currency = $repository->find($this->mapped[$this->index][$this->value]);
|
||||
} else {
|
||||
$currency = TransactionCurrency::whereSymbol($this->value)->first();
|
||||
$currency = $repository->findBySymbol($this->value);
|
||||
}
|
||||
|
||||
return $currency;
|
||||
|
@@ -19,7 +19,7 @@ class Date extends BasicConverter implements ConverterInterface
|
||||
* @return Carbon
|
||||
* @throws FireflyException
|
||||
*/
|
||||
public function convert()
|
||||
public function convert(): Carbon
|
||||
{
|
||||
$format = session('csv-date-format');
|
||||
try {
|
||||
|
@@ -14,7 +14,7 @@ class Description extends BasicConverter implements ConverterInterface
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function convert()
|
||||
public function convert(): string
|
||||
{
|
||||
$description = $this->data['description'] ?? '';
|
||||
|
||||
|
@@ -1,7 +1,8 @@
|
||||
<?php
|
||||
declare(strict_types = 1);
|
||||
/**
|
||||
* INGDebetCredit.php
|
||||
* Copyright (C) 2016 Sander Dorigo
|
||||
* Copyright (C) 2016 thegrumpydictator@gmail.com
|
||||
*
|
||||
* This software may be modified and distributed under the terms
|
||||
* of the MIT license. See the LICENSE file for details.
|
||||
@@ -23,7 +24,7 @@ class INGDebetCredit extends BasicConverter implements ConverterInterface
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function convert()
|
||||
public function convert(): int
|
||||
{
|
||||
if ($this->value === 'Af') {
|
||||
return -1;
|
||||
|
@@ -2,9 +2,8 @@
|
||||
declare(strict_types = 1);
|
||||
namespace FireflyIII\Helpers\Csv\Converter;
|
||||
|
||||
use Auth;
|
||||
use FireflyIII\Models\Account;
|
||||
use Log;
|
||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||
|
||||
/**
|
||||
* Class OpposingAccountIban
|
||||
@@ -21,15 +20,23 @@ class OpposingAccountIban extends BasicConverter implements ConverterInterface
|
||||
*/
|
||||
public function convert()
|
||||
{
|
||||
/** @var AccountRepositoryInterface $repository */
|
||||
$repository = app('FireflyIII\Repositories\Account\AccountRepositoryInterface');
|
||||
|
||||
if (isset($this->mapped[$this->index][$this->value])) {
|
||||
$account = Auth::user()->accounts()->find($this->mapped[$this->index][$this->value]);
|
||||
$account = $repository->find($this->mapped[$this->index][$this->value]);
|
||||
|
||||
return $account;
|
||||
} else {
|
||||
if (strlen($this->value) > 0) {
|
||||
$account = $this->findAccount();
|
||||
if (!is_null($account)) {
|
||||
return $account;
|
||||
|
||||
$set = $repository->getAccounts([]);
|
||||
/** @var Account $account */
|
||||
foreach ($set as $account) {
|
||||
if ($account->iban == $this->value) {
|
||||
|
||||
return $account;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,21 +44,4 @@ class OpposingAccountIban extends BasicConverter implements ConverterInterface
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Account|null
|
||||
*/
|
||||
protected function findAccount()
|
||||
{
|
||||
$set = Auth::user()->accounts()->get();
|
||||
/** @var Account $account */
|
||||
foreach ($set as $account) {
|
||||
if ($account->iban == $this->value) {
|
||||
Log::debug('OpposingAccountIban::convert found an Account (#' . $account->id . ': ******) with IBAN ******');
|
||||
|
||||
return $account;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@@ -2,8 +2,8 @@
|
||||
declare(strict_types = 1);
|
||||
namespace FireflyIII\Helpers\Csv\Converter;
|
||||
|
||||
use Auth;
|
||||
use FireflyIII\Models\Account;
|
||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||
|
||||
/**
|
||||
* Class OpposingAccountId
|
||||
@@ -17,13 +17,16 @@ class OpposingAccountId extends BasicConverter implements ConverterInterface
|
||||
/**
|
||||
* @return Account
|
||||
*/
|
||||
public function convert()
|
||||
public function convert(): Account
|
||||
{
|
||||
/** @var AccountRepositoryInterface $repository */
|
||||
$repository = app('FireflyIII\Repositories\Account\AccountRepositoryInterface');
|
||||
|
||||
if (isset($this->mapped[$this->index][$this->value])) {
|
||||
$account = Auth::user()->accounts()->find($this->mapped[$this->index][$this->value]);
|
||||
$account = $repository->find($this->mapped[$this->index][$this->value]);
|
||||
|
||||
} else {
|
||||
$account = Auth::user()->accounts()->find($this->value);
|
||||
$account = $repository->find($this->value);
|
||||
}
|
||||
|
||||
return $account;
|
||||
|
@@ -2,8 +2,8 @@
|
||||
declare(strict_types = 1);
|
||||
namespace FireflyIII\Helpers\Csv\Converter;
|
||||
|
||||
use Auth;
|
||||
use FireflyIII\Models\Account;
|
||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||
|
||||
/**
|
||||
* Class OpposingAccountName
|
||||
@@ -20,8 +20,11 @@ class OpposingAccountName extends BasicConverter implements ConverterInterface
|
||||
*/
|
||||
public function convert()
|
||||
{
|
||||
/** @var AccountRepositoryInterface $repository */
|
||||
$repository = app('FireflyIII\Repositories\Account\AccountRepositoryInterface');
|
||||
|
||||
if (isset($this->mapped[$this->index][$this->value])) {
|
||||
$account = Auth::user()->accounts()->find($this->mapped[$this->index][$this->value]);
|
||||
$account = $repository->find($this->mapped[$this->index][$this->value]);
|
||||
|
||||
return $account;
|
||||
} else {
|
||||
|
@@ -15,7 +15,7 @@ class RabobankDebetCredit extends BasicConverter implements ConverterInterface
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function convert()
|
||||
public function convert(): int
|
||||
{
|
||||
if ($this->value == 'D') {
|
||||
return -1;
|
||||
|
@@ -2,8 +2,7 @@
|
||||
declare(strict_types = 1);
|
||||
namespace FireflyIII\Helpers\Csv\Converter;
|
||||
|
||||
use Auth;
|
||||
use FireflyIII\Models\Tag;
|
||||
use FireflyIII\Repositories\Tag\TagRepositoryInterface;
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
/**
|
||||
@@ -17,19 +16,24 @@ class TagsComma extends BasicConverter implements ConverterInterface
|
||||
/**
|
||||
* @return Collection
|
||||
*/
|
||||
public function convert()
|
||||
public function convert(): Collection
|
||||
{
|
||||
$tags = new Collection;
|
||||
/** @var TagRepositoryInterface $repository */
|
||||
$repository = app('FireflyIII\Repositories\Tag\TagRepositoryInterface');
|
||||
$tags = new Collection;
|
||||
|
||||
$strings = explode(',', $this->value);
|
||||
foreach ($strings as $string) {
|
||||
$tag = Tag::firstOrCreateEncrypted( // See issue #180
|
||||
[
|
||||
'tag' => $string,
|
||||
'tagMode' => 'nothing',
|
||||
'user_id' => Auth::user()->id,
|
||||
]
|
||||
);
|
||||
$data = [
|
||||
'tag' => $string,
|
||||
'date' => null,
|
||||
'description' => null,
|
||||
'latitude' => null,
|
||||
'longitude' => null,
|
||||
'zoomLevel' => null,
|
||||
'tagMode' => 'nothing',
|
||||
];
|
||||
$tag = $repository->store($data); // should validate first?
|
||||
$tags->push($tag);
|
||||
}
|
||||
$tags = $tags->merge($this->data['tags']);
|
||||
|
@@ -2,8 +2,7 @@
|
||||
declare(strict_types = 1);
|
||||
namespace FireflyIII\Helpers\Csv\Converter;
|
||||
|
||||
use Auth;
|
||||
use FireflyIII\Models\Tag;
|
||||
use FireflyIII\Repositories\Tag\TagRepositoryInterface;
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
/**
|
||||
@@ -17,19 +16,25 @@ class TagsSpace extends BasicConverter implements ConverterInterface
|
||||
/**
|
||||
* @return Collection
|
||||
*/
|
||||
public function convert()
|
||||
public function convert(): Collection
|
||||
{
|
||||
/** @var TagRepositoryInterface $repository */
|
||||
$repository = app('FireflyIII\Repositories\Tag\TagRepositoryInterface');
|
||||
|
||||
$tags = new Collection;
|
||||
|
||||
$strings = explode(' ', $this->value);
|
||||
foreach ($strings as $string) {
|
||||
$tag = Tag::firstOrCreateEncrypted( // See issue #180
|
||||
[
|
||||
'tag' => $string,
|
||||
'tagMode' => 'nothing',
|
||||
'user_id' => Auth::user()->id,
|
||||
]
|
||||
);
|
||||
$data = [
|
||||
'tag' => $string,
|
||||
'date' => null,
|
||||
'description' => null,
|
||||
'latitude' => null,
|
||||
'longitude' => null,
|
||||
'zoomLevel' => null,
|
||||
'tagMode' => 'nothing',
|
||||
];
|
||||
$tag = $repository->store($data); // should validate first?
|
||||
$tags->push($tag);
|
||||
}
|
||||
$tags = $tags->merge($this->data['tags']);
|
||||
|
@@ -57,7 +57,7 @@ class Data
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getCsvFileContent()
|
||||
public function getCsvFileContent(): string
|
||||
{
|
||||
return $this->csvFileContent ?? '';
|
||||
}
|
||||
@@ -72,10 +72,10 @@ class Data
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* FIXME may return null
|
||||
* @return string
|
||||
*/
|
||||
public function getCsvFileLocation()
|
||||
public function getCsvFileLocation(): string
|
||||
{
|
||||
return $this->csvFileLocation;
|
||||
}
|
||||
@@ -91,10 +91,10 @@ class Data
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* FIXME may return null
|
||||
* @return string
|
||||
*/
|
||||
public function getDateFormat()
|
||||
public function getDateFormat(): string
|
||||
{
|
||||
return $this->dateFormat;
|
||||
}
|
||||
@@ -110,10 +110,10 @@ class Data
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* FIXME may return null
|
||||
* @return string
|
||||
*/
|
||||
public function getDelimiter()
|
||||
public function getDelimiter(): string
|
||||
{
|
||||
return $this->delimiter;
|
||||
}
|
||||
@@ -132,7 +132,7 @@ class Data
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getMap()
|
||||
public function getMap(): array
|
||||
{
|
||||
return $this->map;
|
||||
}
|
||||
@@ -151,7 +151,7 @@ class Data
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getMapped()
|
||||
public function getMapped(): array
|
||||
{
|
||||
return $this->mapped;
|
||||
}
|
||||
@@ -170,7 +170,7 @@ class Data
|
||||
*
|
||||
* @return Reader
|
||||
*/
|
||||
public function getReader()
|
||||
public function getReader(): Reader
|
||||
{
|
||||
if (!is_null($this->csvFileContent) && strlen($this->csvFileContent) === 0) {
|
||||
$this->loadCsvFile();
|
||||
@@ -188,7 +188,7 @@ class Data
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getRoles()
|
||||
public function getRoles(): array
|
||||
{
|
||||
return $this->roles;
|
||||
}
|
||||
@@ -207,7 +207,7 @@ class Data
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getSpecifix()
|
||||
public function getSpecifix(): array
|
||||
{
|
||||
return is_array($this->specifix) ? $this->specifix : [];
|
||||
}
|
||||
@@ -226,7 +226,7 @@ class Data
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function hasHeaders()
|
||||
public function hasHeaders(): bool
|
||||
{
|
||||
return $this->hasHeaders;
|
||||
}
|
||||
|
@@ -4,19 +4,15 @@ namespace FireflyIII\Helpers\Csv;
|
||||
|
||||
use Auth;
|
||||
use Config;
|
||||
use FireflyIII\Events\TransactionJournalStored;
|
||||
use FireflyIII\Exceptions\FireflyException;
|
||||
use FireflyIII\Helpers\Csv\Converter\ConverterInterface;
|
||||
use FireflyIII\Helpers\Csv\PostProcessing\PostProcessorInterface;
|
||||
use FireflyIII\Helpers\Csv\Specifix\SpecifixInterface;
|
||||
use FireflyIII\Models\Account;
|
||||
use FireflyIII\Models\Rule;
|
||||
use FireflyIII\Models\RuleGroup;
|
||||
use FireflyIII\Models\Transaction;
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
use FireflyIII\Models\TransactionType;
|
||||
use FireflyIII\Rules\Processor;
|
||||
use FireflyIII\User;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\MessageBag;
|
||||
use Log;
|
||||
@@ -32,7 +28,7 @@ class Importer
|
||||
/** @var Data */
|
||||
protected $data;
|
||||
/** @var array */
|
||||
protected $errors;
|
||||
protected $errors = [];
|
||||
/** @var array */
|
||||
protected $importData;
|
||||
/** @var array */
|
||||
@@ -57,7 +53,7 @@ class Importer
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getErrors()
|
||||
public function getErrors(): array
|
||||
{
|
||||
return $this->errors;
|
||||
}
|
||||
@@ -67,7 +63,7 @@ class Importer
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getImported()
|
||||
public function getImported(): int
|
||||
{
|
||||
return $this->imported;
|
||||
}
|
||||
@@ -75,7 +71,7 @@ class Importer
|
||||
/**
|
||||
* @return Collection
|
||||
*/
|
||||
public function getJournals()
|
||||
public function getJournals(): Collection
|
||||
{
|
||||
return $this->journals;
|
||||
}
|
||||
@@ -85,7 +81,7 @@ class Importer
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getRows()
|
||||
public function getRows(): int
|
||||
{
|
||||
return $this->rows;
|
||||
}
|
||||
@@ -93,7 +89,7 @@ class Importer
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getSpecifix()
|
||||
public function getSpecifix(): array
|
||||
{
|
||||
return is_array($this->specifix) ? $this->specifix : [];
|
||||
}
|
||||
@@ -122,15 +118,11 @@ class Importer
|
||||
} else {
|
||||
$this->imported++;
|
||||
$this->journals->push($result);
|
||||
event(new TransactionJournalStored($result, 0));
|
||||
}
|
||||
Log::debug('---');
|
||||
}
|
||||
}
|
||||
|
||||
// once all journals have been imported (or not)
|
||||
// fire the rules.
|
||||
$this->fireRules();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -142,7 +134,6 @@ class Importer
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return TransactionJournal|string
|
||||
*/
|
||||
protected function createTransactionJournal()
|
||||
@@ -156,8 +147,15 @@ class Importer
|
||||
$transactionType = $this->getTransactionType(); // defaults to deposit
|
||||
$errors = new MessageBag;
|
||||
$journal = TransactionJournal::create(
|
||||
['user_id' => Auth::user()->id, 'transaction_type_id' => $transactionType->id, 'transaction_currency_id' => $this->importData['currency']->id,
|
||||
'description' => $this->importData['description'], 'completed' => 0, 'date' => $date, 'bill_id' => $this->importData['bill-id'],]
|
||||
[
|
||||
'user_id' => Auth::user()->id,
|
||||
'transaction_type_id' => $transactionType->id,
|
||||
'transaction_currency_id' => $this->importData['currency']->id,
|
||||
'description' => $this->importData['description'],
|
||||
'completed' => 0,
|
||||
'date' => $date,
|
||||
'bill_id' => $this->importData['bill-id'],
|
||||
]
|
||||
);
|
||||
if ($journal->getErrors()->count() == 0) {
|
||||
// first transaction
|
||||
@@ -359,55 +357,6 @@ class Importer
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Collection $groups
|
||||
* @param TransactionJournal $journal
|
||||
*/
|
||||
private function fireRule(Collection $groups, TransactionJournal $journal)
|
||||
{
|
||||
/** @var RuleGroup $group */
|
||||
foreach ($groups as $group) {
|
||||
|
||||
/** @var Rule $rule */
|
||||
foreach ($group->rules as $rule) {
|
||||
$processor = Processor::make($rule);
|
||||
$processor->handleTransactionJournal($journal);
|
||||
if ($rule->stop_processing) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function fireRules()
|
||||
{
|
||||
// get all users rules.
|
||||
/** @var User $user */
|
||||
$user = Auth::user();
|
||||
$groups = $user
|
||||
->ruleGroups()
|
||||
->where('rule_groups.active', 1)
|
||||
->orderBy('order', 'ASC')
|
||||
->with(
|
||||
[
|
||||
'rules' => function (HasMany $q) {
|
||||
$q->leftJoin('rule_triggers', 'rules.id', '=', 'rule_triggers.rule_id')
|
||||
->where('rule_triggers.trigger_type', 'user_action')
|
||||
->where('rule_triggers.trigger_value', 'store-journal')
|
||||
->where('rules.active', 1)
|
||||
->orderBy('rules.order', 'ASC');
|
||||
},
|
||||
]
|
||||
)
|
||||
->get();
|
||||
|
||||
/** @var TransactionJournal $journal */
|
||||
foreach ($this->journals as $journal) {
|
||||
$this->fireRule($groups, $journal);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
|
@@ -16,7 +16,7 @@ class AnyAccount implements MapperInterface
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getMap()
|
||||
public function getMap(): array
|
||||
{
|
||||
$result = Auth::user()->accounts()->with('accountType')->orderBy('accounts.name', 'ASC')->get(['accounts.*']);
|
||||
|
||||
|
@@ -17,7 +17,7 @@ class AssetAccount implements MapperInterface
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getMap()
|
||||
public function getMap(): array
|
||||
{
|
||||
$result = Auth::user()->accounts()->with(
|
||||
['accountmeta' => function (HasMany $query) {
|
||||
|
@@ -16,7 +16,7 @@ class Bill implements MapperInterface
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getMap()
|
||||
public function getMap(): array
|
||||
{
|
||||
$result = Auth::user()->bills()->get(['bills.*']);
|
||||
$list = [];
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user