mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Code clean up.
This commit is contained in:
parent
57dcdfa0c4
commit
ffca858b8d
@ -18,10 +18,8 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
|
||||
namespace FireflyIII\Console\Commands;
|
||||
|
||||
use Carbon\Carbon;
|
||||
@ -35,11 +33,9 @@ use Illuminate\Console\Command;
|
||||
use Storage;
|
||||
|
||||
/**
|
||||
* Class CreateExport
|
||||
* Class CreateExport.
|
||||
*
|
||||
* Generates export from the command line.
|
||||
*
|
||||
* @package FireflyIII\Console\Commands
|
||||
*/
|
||||
class CreateExport extends Command
|
||||
{
|
||||
@ -65,7 +61,6 @@ class CreateExport extends Command
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
@ -73,7 +68,6 @@ class CreateExport extends Command
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @SuppressWarnings(PHPMD.CyclomaticComplexity) // it's five its fine.
|
||||
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
|
||||
*
|
||||
@ -108,7 +102,7 @@ class CreateExport extends Command
|
||||
// first date
|
||||
$firstJournal = $journalRepository->first();
|
||||
$first = new Carbon;
|
||||
if (!is_null($firstJournal->id)) {
|
||||
if (null !== $firstJournal->id) {
|
||||
$first = $firstJournal->date;
|
||||
}
|
||||
|
||||
@ -124,7 +118,6 @@ class CreateExport extends Command
|
||||
'job' => $job,
|
||||
];
|
||||
|
||||
|
||||
/** @var ProcessorInterface $processor */
|
||||
$processor = app(ProcessorInterface::class);
|
||||
$processor->setSettings($settings);
|
||||
|
@ -18,7 +18,6 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Console\Commands;
|
||||
@ -35,9 +34,7 @@ use Monolog\Formatter\LineFormatter;
|
||||
use Preferences;
|
||||
|
||||
/**
|
||||
* Class CreateImport
|
||||
*
|
||||
* @package FireflyIII\Console\Commands
|
||||
* Class CreateImport.
|
||||
*/
|
||||
class CreateImport extends Command
|
||||
{
|
||||
@ -65,7 +62,6 @@ class CreateImport extends Command
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
@ -98,7 +94,7 @@ class CreateImport extends Command
|
||||
}
|
||||
|
||||
$configurationData = json_decode(file_get_contents($configuration));
|
||||
if (is_null($configurationData)) {
|
||||
if (null === $configurationData) {
|
||||
$this->error(sprintf('Firefly III cannot read the contents of configuration file "%s" (working directory: "%s").', $configuration, $cwd));
|
||||
|
||||
return;
|
||||
@ -109,25 +105,21 @@ class CreateImport extends Command
|
||||
$this->line(sprintf('Import into user: #%d (%s)', $user->id, $user->email));
|
||||
$this->line(sprintf('Type of import: %s', $type));
|
||||
|
||||
|
||||
/** @var ImportJobRepositoryInterface $jobRepository */
|
||||
$jobRepository = app(ImportJobRepositoryInterface::class);
|
||||
$jobRepository->setUser($user);
|
||||
$job = $jobRepository->create($type);
|
||||
$this->line(sprintf('Created job "%s"', $job->key));
|
||||
|
||||
|
||||
Artisan::call('firefly:encrypt-file', ['file' => $file, 'key' => $job->key]);
|
||||
$this->line('Stored import data...');
|
||||
|
||||
|
||||
$job->configuration = $configurationData;
|
||||
$job->status = 'configured';
|
||||
$job->save();
|
||||
$this->line('Stored configuration...');
|
||||
|
||||
|
||||
if ($this->option('start') === true) {
|
||||
if (true === $this->option('start')) {
|
||||
$this->line('The import will start in a moment. This process is not visible...');
|
||||
Log::debug('Go for import!');
|
||||
|
||||
@ -138,7 +130,6 @@ class CreateImport extends Command
|
||||
$handler->setFormatter($formatter);
|
||||
$monolog->pushHandler($handler);
|
||||
|
||||
|
||||
// start the actual routine:
|
||||
/** @var ImportRoutine $routine */
|
||||
$routine = app(ImportRoutine::class);
|
||||
@ -177,7 +168,7 @@ class CreateImport extends Command
|
||||
$cwd = getcwd();
|
||||
$validTypes = array_keys(config('firefly.import_formats'));
|
||||
$type = strtolower($this->option('type'));
|
||||
if (is_null($user->id)) {
|
||||
if (null === $user->id) {
|
||||
$this->error(sprintf('There is no user with ID %d.', $this->option('user')));
|
||||
|
||||
return false;
|
||||
|
@ -18,7 +18,6 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Console\Commands;
|
||||
@ -28,9 +27,7 @@ use Illuminate\Console\Command;
|
||||
use Log;
|
||||
|
||||
/**
|
||||
* Class DecryptAttachment
|
||||
*
|
||||
* @package FireflyIII\Console\Commands
|
||||
* Class DecryptAttachment.
|
||||
*/
|
||||
class DecryptAttachment extends Command
|
||||
{
|
||||
@ -50,10 +47,8 @@ class DecryptAttachment extends Command
|
||||
= 'firefly:decrypt-attachment {id:The ID of the attachment.} {name:The file name of the attachment.}
|
||||
{directory:Where the file must be stored.}';
|
||||
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
@ -65,7 +60,6 @@ class DecryptAttachment extends Command
|
||||
*
|
||||
* @SuppressWarnings(PHPMD.CyclomaticComplexity) // it's five its fine.
|
||||
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
|
||||
*
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
@ -75,7 +69,7 @@ class DecryptAttachment extends Command
|
||||
$attachment = $repository->findWithoutUser($attachmentId);
|
||||
$attachmentName = trim($this->argument('name'));
|
||||
$storagePath = realpath(trim($this->argument('directory')));
|
||||
if (is_null($attachment->id)) {
|
||||
if (null === $attachment->id) {
|
||||
$this->error(sprintf('No attachment with id #%d', $attachmentId));
|
||||
Log::error(sprintf('DecryptAttachment: No attachment with id #%d', $attachmentId));
|
||||
|
||||
@ -107,7 +101,7 @@ class DecryptAttachment extends Command
|
||||
$content = $repository->getContent($attachment);
|
||||
$this->line(sprintf('Going to write content for attachment #%d into file "%s"', $attachment->id, $fullPath));
|
||||
$result = file_put_contents($fullPath, $content);
|
||||
if ($result === false) {
|
||||
if (false === $result) {
|
||||
$this->error('Could not write to file.');
|
||||
|
||||
return;
|
||||
|
@ -18,7 +18,6 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Console\Commands;
|
||||
@ -27,9 +26,7 @@ use Crypt;
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
/**
|
||||
* Class EncryptFile
|
||||
*
|
||||
* @package FireflyIII\Console\Commands
|
||||
* Class EncryptFile.
|
||||
*/
|
||||
class EncryptFile extends Command
|
||||
{
|
||||
@ -49,7 +46,6 @@ class EncryptFile extends Command
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
|
@ -18,7 +18,6 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Console\Commands;
|
||||
@ -31,9 +30,7 @@ use Illuminate\Support\MessageBag;
|
||||
use Log;
|
||||
|
||||
/**
|
||||
* Class Import
|
||||
*
|
||||
* @package FireflyIII\Console\Commands
|
||||
* Class Import.
|
||||
*/
|
||||
class Import extends Command
|
||||
{
|
||||
@ -53,7 +50,6 @@ class Import extends Command
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
@ -68,7 +64,7 @@ class Import extends Command
|
||||
Log::debug('Start start-import command');
|
||||
$jobKey = $this->argument('key');
|
||||
$job = ImportJob::where('key', $jobKey)->first();
|
||||
if (is_null($job)) {
|
||||
if (null === $job) {
|
||||
$this->error(sprintf('No job found with key "%s"', $jobKey));
|
||||
|
||||
return;
|
||||
@ -109,14 +105,14 @@ class Import extends Command
|
||||
*/
|
||||
private function isValid(ImportJob $job): bool
|
||||
{
|
||||
if (is_null($job)) {
|
||||
if (null === $job) {
|
||||
Log::error('This job does not seem to exist.');
|
||||
$this->error('This job does not seem to exist.');
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($job->status !== 'configured') {
|
||||
if ('configured' !== $job->status) {
|
||||
Log::error(sprintf('This job is not ready to be imported (status is %s).', $job->status));
|
||||
$this->error('This job is not ready to be imported.');
|
||||
|
||||
|
@ -18,7 +18,6 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Console\Commands;
|
||||
@ -31,9 +30,7 @@ use Illuminate\Contracts\Filesystem\FileNotFoundException;
|
||||
use Storage;
|
||||
|
||||
/**
|
||||
* Class ScanAttachments
|
||||
*
|
||||
* @package FireflyIII\Console\Commands
|
||||
* Class ScanAttachments.
|
||||
*/
|
||||
class ScanAttachments extends Command
|
||||
{
|
||||
@ -53,7 +50,6 @@ class ScanAttachments extends Command
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
|
@ -18,7 +18,6 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Console\Commands;
|
||||
@ -44,17 +43,15 @@ use Preferences;
|
||||
use Schema;
|
||||
|
||||
/**
|
||||
* Class UpgradeDatabase
|
||||
* Class UpgradeDatabase.
|
||||
*
|
||||
* Upgrade user database.
|
||||
*
|
||||
*
|
||||
* @SuppressWarnings(PHPMD.CouplingBetweenObjects) // it just touches a lot of things.
|
||||
* @package FireflyIII\Console\Commands
|
||||
*/
|
||||
class UpgradeDatabase extends Command
|
||||
{
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
@ -105,7 +102,7 @@ class UpgradeDatabase extends Command
|
||||
foreach ($set as $budgetLimit) {
|
||||
/** @var LimitRepetition $repetition */
|
||||
$repetition = $budgetLimit->limitrepetitions()->first();
|
||||
if (!is_null($repetition)) {
|
||||
if (null !== $repetition) {
|
||||
$budgetLimit->end_date = $repetition->enddate;
|
||||
$budgetLimit->save();
|
||||
$this->line(sprintf('Updated budget limit #%d', $budgetLimit->id));
|
||||
@ -170,7 +167,7 @@ class UpgradeDatabase extends Command
|
||||
$obCurrency = intval($openingBalance->transaction_currency_id);
|
||||
|
||||
// both 0? set to default currency:
|
||||
if ($accountCurrency === 0 && $obCurrency === 0) {
|
||||
if (0 === $accountCurrency && 0 === $obCurrency) {
|
||||
AccountMeta::create(['account_id' => $account->id, 'name' => 'currency_id', 'data' => $defaultCurrency->id]);
|
||||
$this->line(sprintf('Account #%d ("%s") now has a currency setting (%s).', $account->id, $account->name, $defaultCurrencyCode));
|
||||
|
||||
@ -178,7 +175,7 @@ class UpgradeDatabase extends Command
|
||||
}
|
||||
|
||||
// account is set to 0, opening balance is not?
|
||||
if ($accountCurrency === 0 && $obCurrency > 0) {
|
||||
if (0 === $accountCurrency && $obCurrency > 0) {
|
||||
AccountMeta::create(['account_id' => $account->id, 'name' => 'currency_id', 'data' => $obCurrency]);
|
||||
$this->line(sprintf('Account #%d ("%s") now has a currency setting (%s).', $account->id, $account->name, $defaultCurrencyCode));
|
||||
|
||||
@ -228,7 +225,7 @@ class UpgradeDatabase extends Command
|
||||
->leftJoin('accounts', 'accounts.id', '=', 'transactions.account_id')
|
||||
->leftJoin('account_types', 'account_types.id', '=', 'accounts.account_type_id')
|
||||
->whereIn('account_types.type', [AccountType::DEFAULT, AccountType::ASSET])->first(['transactions.*']);
|
||||
if (is_null($transaction)) {
|
||||
if (null === $transaction) {
|
||||
return;
|
||||
}
|
||||
/** @var Account $account */
|
||||
@ -237,7 +234,7 @@ class UpgradeDatabase extends Command
|
||||
$transactions = $journal->transactions()->get();
|
||||
$transactions->each(
|
||||
function (Transaction $transaction) use ($currency) {
|
||||
if (is_null($transaction->transaction_currency_id)) {
|
||||
if (null === $transaction->transaction_currency_id) {
|
||||
$transaction->transaction_currency_id = $currency->id;
|
||||
$transaction->save();
|
||||
}
|
||||
@ -302,7 +299,7 @@ class UpgradeDatabase extends Command
|
||||
foreach ($set as $meta) {
|
||||
$journal = $meta->transactionJournal;
|
||||
$note = $journal->notes()->first();
|
||||
if (is_null($note)) {
|
||||
if (null === $note) {
|
||||
$note = new Note;
|
||||
$note->noteable()->associate($journal);
|
||||
}
|
||||
@ -314,7 +311,6 @@ class UpgradeDatabase extends Command
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This method makes sure that the transaction journal uses the currency given in the transaction.
|
||||
*
|
||||
@ -375,7 +371,7 @@ class UpgradeDatabase extends Command
|
||||
|
||||
return;
|
||||
}
|
||||
if (!is_null($opposing)) {
|
||||
if (null !== $opposing) {
|
||||
// give both a new identifier:
|
||||
$transaction->identifier = $identifier;
|
||||
$opposing->identifier = $identifier;
|
||||
@ -384,7 +380,7 @@ class UpgradeDatabase extends Command
|
||||
$processed[] = $transaction->id;
|
||||
$processed[] = $opposing->id;
|
||||
}
|
||||
$identifier++;
|
||||
++$identifier;
|
||||
}
|
||||
|
||||
return;
|
||||
@ -411,7 +407,7 @@ class UpgradeDatabase extends Command
|
||||
$currency = $repository->find(intval($transaction->account->getMeta('currency_id')));
|
||||
|
||||
// has no currency ID? Must have, so fill in using account preference:
|
||||
if (is_null($transaction->transaction_currency_id)) {
|
||||
if (null === $transaction->transaction_currency_id) {
|
||||
$transaction->transaction_currency_id = $currency->id;
|
||||
Log::debug(sprintf('Transaction #%d has no currency setting, now set to %s', $transaction->id, $currency->code));
|
||||
$transaction->save();
|
||||
@ -419,7 +415,7 @@ class UpgradeDatabase extends Command
|
||||
|
||||
// does not match the source account (see above)? Can be fixed
|
||||
// when mismatch in transaction and NO foreign amount is set:
|
||||
if ($transaction->transaction_currency_id !== $currency->id && is_null($transaction->foreign_amount)) {
|
||||
if ($transaction->transaction_currency_id !== $currency->id && null === $transaction->foreign_amount) {
|
||||
Log::debug(
|
||||
sprintf(
|
||||
'Transaction #%d has a currency setting (#%d) that should be #%d. Amount remains %s, currency is changed.',
|
||||
@ -440,7 +436,7 @@ class UpgradeDatabase extends Command
|
||||
$opposing = $journal->transactions()->where('amount', '>', 0)->where('identifier', $transaction->identifier)->first();
|
||||
$opposingCurrency = $repository->find(intval($opposing->account->getMeta('currency_id')));
|
||||
|
||||
if (is_null($opposingCurrency->id)) {
|
||||
if (null === $opposingCurrency->id) {
|
||||
Log::error(sprintf('Account #%d ("%s") must have currency preference but has none.', $opposing->account->id, $opposing->account->name));
|
||||
|
||||
return;
|
||||
@ -470,23 +466,23 @@ class UpgradeDatabase extends Command
|
||||
}
|
||||
|
||||
// if foreign amount of one is null and the other is not, use this to restore:
|
||||
if (is_null($transaction->foreign_amount) && !is_null($opposing->foreign_amount)) {
|
||||
if (null === $transaction->foreign_amount && null !== $opposing->foreign_amount) {
|
||||
$transaction->foreign_amount = bcmul(strval($opposing->foreign_amount), '-1');
|
||||
$transaction->save();
|
||||
Log::debug(sprintf('Restored foreign amount of transaction (1) #%d to %s', $transaction->id, $transaction->foreign_amount));
|
||||
}
|
||||
|
||||
// if foreign amount of one is null and the other is not, use this to restore (other way around)
|
||||
if (is_null($opposing->foreign_amount) && !is_null($transaction->foreign_amount)) {
|
||||
if (null === $opposing->foreign_amount && null !== $transaction->foreign_amount) {
|
||||
$opposing->foreign_amount = bcmul(strval($transaction->foreign_amount), '-1');
|
||||
$opposing->save();
|
||||
Log::debug(sprintf('Restored foreign amount of transaction (2) #%d to %s', $opposing->id, $opposing->foreign_amount));
|
||||
}
|
||||
|
||||
// when both are zero, try to grab it from journal:
|
||||
if (is_null($opposing->foreign_amount) && is_null($transaction->foreign_amount)) {
|
||||
if (null === $opposing->foreign_amount && null === $transaction->foreign_amount) {
|
||||
$foreignAmount = $journal->getMeta('foreign_amount');
|
||||
if (is_null($foreignAmount)) {
|
||||
if (null === $foreignAmount) {
|
||||
Log::debug(sprintf('Journal #%d has missing foreign currency data, forced to do 1:1 conversion :(.', $transaction->transaction_journal_id));
|
||||
$transaction->foreign_amount = bcmul(strval($transaction->amount), '-1');
|
||||
$opposing->foreign_amount = bcmul(strval($opposing->amount), '-1');
|
||||
@ -509,7 +505,6 @@ class UpgradeDatabase extends Command
|
||||
$opposing->save();
|
||||
}
|
||||
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -18,7 +18,6 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Console\Commands;
|
||||
@ -26,9 +25,7 @@ namespace FireflyIII\Console\Commands;
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
/**
|
||||
* Class UpgradeFireflyInstructions
|
||||
*
|
||||
* @package FireflyIII\Console\Commands
|
||||
* Class UpgradeFireflyInstructions.
|
||||
*/
|
||||
class UpgradeFireflyInstructions extends Command
|
||||
{
|
||||
@ -47,7 +44,6 @@ class UpgradeFireflyInstructions extends Command
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
@ -59,16 +55,16 @@ class UpgradeFireflyInstructions extends Command
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
if ($this->argument('task') === 'update') {
|
||||
if ('update' === $this->argument('task')) {
|
||||
$this->updateInstructions();
|
||||
}
|
||||
if ($this->argument('task') === 'install') {
|
||||
if ('install' === $this->argument('task')) {
|
||||
$this->installInstructions();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Show a nice box
|
||||
* Show a nice box.
|
||||
*
|
||||
* @param string $text
|
||||
*/
|
||||
@ -81,7 +77,7 @@ class UpgradeFireflyInstructions extends Command
|
||||
}
|
||||
|
||||
/**
|
||||
* Show a nice info box
|
||||
* Show a nice info box.
|
||||
*
|
||||
* @param string $text
|
||||
*/
|
||||
@ -111,7 +107,7 @@ class UpgradeFireflyInstructions extends Command
|
||||
}
|
||||
$this->showLine();
|
||||
$this->boxed('');
|
||||
if (is_null($text)) {
|
||||
if (null === $text) {
|
||||
$this->boxed(sprintf('Thank you for installing Firefly III, v%s!', $version));
|
||||
$this->boxedInfo('There are no extra installation instructions.');
|
||||
$this->boxed('Firefly III should be ready for use.');
|
||||
@ -128,12 +124,12 @@ class UpgradeFireflyInstructions extends Command
|
||||
}
|
||||
|
||||
/**
|
||||
* Show a line
|
||||
* Show a line.
|
||||
*/
|
||||
private function showLine()
|
||||
{
|
||||
$line = '+';
|
||||
for ($i = 0; $i < 78; $i++) {
|
||||
for ($i = 0; $i < 78; ++$i) {
|
||||
$line .= '-';
|
||||
}
|
||||
$line .= '+';
|
||||
@ -158,7 +154,7 @@ class UpgradeFireflyInstructions extends Command
|
||||
}
|
||||
$this->showLine();
|
||||
$this->boxed('');
|
||||
if (is_null($text)) {
|
||||
if (null === $text) {
|
||||
$this->boxed(sprintf('Thank you for updating to Firefly III, v%s', $version));
|
||||
$this->boxedInfo('There are no extra upgrade instructions.');
|
||||
$this->boxed('Firefly III should be ready for use.');
|
||||
|
@ -19,7 +19,6 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
@ -36,9 +35,7 @@ use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
/**
|
||||
* Class UseEncryption
|
||||
*
|
||||
* @package FireflyIII\Console\Commands
|
||||
* Class UseEncryption.
|
||||
*/
|
||||
class UseEncryption extends Command
|
||||
{
|
||||
@ -57,7 +54,6 @@ class UseEncryption extends Command
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
|
@ -18,7 +18,6 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Console\Commands;
|
||||
@ -28,11 +27,9 @@ use Log;
|
||||
use Preferences;
|
||||
|
||||
/**
|
||||
* Trait VerifiesAccessToken
|
||||
* Trait VerifiesAccessToken.
|
||||
*
|
||||
* Verifies user access token for sensitive commands.
|
||||
*
|
||||
* @package FireflyIII\Console\Commands
|
||||
*/
|
||||
trait VerifiesAccessToken
|
||||
{
|
||||
@ -58,13 +55,13 @@ trait VerifiesAccessToken
|
||||
$repository = app(UserRepositoryInterface::class);
|
||||
$user = $repository->find($userId);
|
||||
|
||||
if (is_null($user->id)) {
|
||||
if (null === $user->id) {
|
||||
Log::error(sprintf('verifyAccessToken(): no such user for input "%d"', $userId));
|
||||
|
||||
return false;
|
||||
}
|
||||
$accessToken = Preferences::getForUser($user, 'access_token', null);
|
||||
if (is_null($accessToken)) {
|
||||
if (null === $accessToken) {
|
||||
Log::error(sprintf('User #%d has no access token, so cannot access command line options.', $userId));
|
||||
|
||||
return false;
|
||||
|
@ -18,7 +18,6 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Console\Commands;
|
||||
@ -42,11 +41,9 @@ use Schema;
|
||||
use stdClass;
|
||||
|
||||
/**
|
||||
* Class VerifyDatabase
|
||||
* Class VerifyDatabase.
|
||||
*
|
||||
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
|
||||
*
|
||||
* @package FireflyIII\Console\Commands
|
||||
*/
|
||||
class VerifyDatabase extends Command
|
||||
{
|
||||
@ -107,7 +104,7 @@ class VerifyDatabase extends Command
|
||||
/** @var User $user */
|
||||
foreach ($users as $user) {
|
||||
$pref = Preferences::getForUser($user, 'access_token', null);
|
||||
if (is_null($pref)) {
|
||||
if (null === $pref) {
|
||||
$token = $user->generateAccessToken();
|
||||
Preferences::setForUser($user, 'access_token', $token);
|
||||
$this->line(sprintf('Generated access token for user %s', $user->email));
|
||||
@ -128,7 +125,7 @@ class VerifyDatabase extends Command
|
||||
];
|
||||
foreach ($set as $name => $values) {
|
||||
$link = LinkType::where('name', $name)->where('outward', $values[0])->where('inward', $values[1])->first();
|
||||
if (is_null($link)) {
|
||||
if (null === $link) {
|
||||
$link = new LinkType;
|
||||
$link->name = $name;
|
||||
$link->outward = $values[0];
|
||||
@ -147,17 +144,17 @@ class VerifyDatabase extends Command
|
||||
$set = PiggyBankEvent::with(['PiggyBank', 'TransactionJournal', 'TransactionJournal.TransactionType'])->get();
|
||||
$set->each(
|
||||
function (PiggyBankEvent $event) {
|
||||
if (is_null($event->transaction_journal_id)) {
|
||||
if (null === $event->transaction_journal_id) {
|
||||
return true;
|
||||
}
|
||||
/** @var TransactionJournal $journal */
|
||||
$journal = $event->transactionJournal()->first();
|
||||
if (is_null($journal)) {
|
||||
if (null === $journal) {
|
||||
return true;
|
||||
}
|
||||
|
||||
$type = $journal->transactionType->type;
|
||||
if ($type !== TransactionType::TRANSFER) {
|
||||
if (TransactionType::TRANSFER !== $type) {
|
||||
$event->transaction_journal_id = null;
|
||||
$event->save();
|
||||
$this->line(sprintf('Piggy bank #%d was referenced by an invalid event. This has been fixed.', $event->piggy_bank_id));
|
||||
@ -234,11 +231,11 @@ class VerifyDatabase extends Command
|
||||
->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']
|
||||
'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;
|
||||
$date = 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 . '"'
|
||||
@ -270,7 +267,7 @@ class VerifyDatabase extends Command
|
||||
->whereNull('transaction_journals.deleted_at')
|
||||
->get(
|
||||
['transaction_journals.id', 'transaction_journals.user_id', 'users.email', 'account_types.type as a_type',
|
||||
'transaction_types.type']
|
||||
'transaction_types.type',]
|
||||
);
|
||||
foreach ($set as $entry) {
|
||||
$this->error(
|
||||
@ -289,7 +286,7 @@ class VerifyDatabase extends Command
|
||||
}
|
||||
|
||||
/**
|
||||
* Any deleted transaction journals that have transactions that are NOT deleted:
|
||||
* Any deleted transaction journals that have transactions that are NOT deleted:.
|
||||
*/
|
||||
private function reportJournals()
|
||||
{
|
||||
@ -303,7 +300,7 @@ class VerifyDatabase extends Command
|
||||
'transaction_journals.description',
|
||||
'transaction_journals.deleted_at as journal_deleted',
|
||||
'transactions.id as transaction_id',
|
||||
'transactions.deleted_at as transaction_deleted_at']
|
||||
'transactions.deleted_at as transaction_deleted_at',]
|
||||
);
|
||||
/** @var stdClass $entry */
|
||||
foreach ($set as $entry) {
|
||||
@ -340,7 +337,7 @@ class VerifyDatabase extends Command
|
||||
{
|
||||
$plural = str_plural($name);
|
||||
$class = sprintf('FireflyIII\Models\%s', ucfirst($name));
|
||||
$field = $name === 'tag' ? 'tag' : 'name';
|
||||
$field = 'tag' === $name ? 'tag' : 'name';
|
||||
$set = $class::leftJoin($name . '_transaction_journal', $plural . '.id', '=', $name . '_transaction_journal.' . $name . '_id')
|
||||
->leftJoin('users', $plural . '.user_id', '=', 'users.id')
|
||||
->distinct()
|
||||
@ -380,7 +377,7 @@ class VerifyDatabase extends Command
|
||||
/** @var User $user */
|
||||
foreach ($userRepository->all() as $user) {
|
||||
$sum = strval($user->transactions()->sum('amount'));
|
||||
if (bccomp($sum, '0') !== 0) {
|
||||
if (0 !== bccomp($sum, '0')) {
|
||||
$this->error('Error: Transactions for user #' . $user->id . ' (' . $user->email . ') are off by ' . $sum . '!');
|
||||
}
|
||||
}
|
||||
@ -396,7 +393,7 @@ class VerifyDatabase extends Command
|
||||
->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']
|
||||
'transaction_journals.deleted_at',]
|
||||
);
|
||||
/** @var stdClass $entry */
|
||||
foreach ($set as $entry) {
|
||||
|
@ -18,10 +18,8 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
|
||||
/**
|
||||
* Kernel.php
|
||||
* Copyright (c) 2017 thegrumpydictator@gmail.com
|
||||
@ -48,13 +46,10 @@ class Kernel extends ConsoleKernel
|
||||
*/
|
||||
protected $commands
|
||||
= [
|
||||
//
|
||||
];
|
||||
|
||||
/**
|
||||
* Register the commands for the application.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function commands()
|
||||
{
|
||||
@ -66,9 +61,8 @@ class Kernel extends ConsoleKernel
|
||||
/**
|
||||
* Define the application's command schedule.
|
||||
*
|
||||
* @param \Illuminate\Console\Scheduling\Schedule $schedule
|
||||
* @param \Illuminate\Console\Scheduling\Schedule $schedule
|
||||
*
|
||||
* @return void
|
||||
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
|
||||
*/
|
||||
protected function schedule(Schedule $schedule)
|
||||
|
@ -18,7 +18,6 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Events;
|
||||
@ -28,9 +27,7 @@ use Illuminate\Queue\SerializesModels;
|
||||
use Log;
|
||||
|
||||
/**
|
||||
* Class AdminRequestedTestMessage
|
||||
*
|
||||
* @package FireflyIII\Events
|
||||
* Class AdminRequestedTestMessage.
|
||||
*/
|
||||
class AdminRequestedTestMessage extends Event
|
||||
{
|
||||
@ -42,7 +39,7 @@ class AdminRequestedTestMessage extends Event
|
||||
/**
|
||||
* Create a new event instance.
|
||||
*
|
||||
* @param User $user
|
||||
* @param User $user
|
||||
* @param string $ipAddress
|
||||
*/
|
||||
public function __construct(User $user, string $ipAddress)
|
||||
|
@ -18,17 +18,13 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Events;
|
||||
|
||||
/**
|
||||
* Class Event
|
||||
*
|
||||
* @package FireflyIII\Events
|
||||
* Class Event.
|
||||
*/
|
||||
abstract class Event
|
||||
{
|
||||
//
|
||||
}
|
||||
|
@ -18,7 +18,6 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Events;
|
||||
@ -27,9 +26,7 @@ use FireflyIII\User;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
/**
|
||||
* Class RegisteredUser
|
||||
*
|
||||
* @package FireflyIII\Events
|
||||
* Class RegisteredUser.
|
||||
*/
|
||||
class RegisteredUser extends Event
|
||||
{
|
||||
@ -41,7 +38,7 @@ class RegisteredUser extends Event
|
||||
/**
|
||||
* Create a new event instance. This event is triggered when a new user registers.
|
||||
*
|
||||
* @param User $user
|
||||
* @param User $user
|
||||
* @param string $ipAddress
|
||||
*/
|
||||
public function __construct(User $user, string $ipAddress)
|
||||
|
@ -18,7 +18,6 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Events;
|
||||
@ -27,9 +26,7 @@ use FireflyIII\User;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
/**
|
||||
* Class RequestedNewPassword
|
||||
*
|
||||
* @package FireflyIII\Events
|
||||
* Class RequestedNewPassword.
|
||||
*/
|
||||
class RequestedNewPassword extends Event
|
||||
{
|
||||
@ -42,7 +39,7 @@ class RequestedNewPassword extends Event
|
||||
/**
|
||||
* Create a new event instance. This event is triggered when a users tries to reset his or her password.
|
||||
*
|
||||
* @param User $user
|
||||
* @param User $user
|
||||
* @param string $token
|
||||
* @param string $ipAddress
|
||||
*/
|
||||
|
@ -18,7 +18,6 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Events;
|
||||
@ -27,9 +26,7 @@ use FireflyIII\Models\TransactionJournal;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
/**
|
||||
* Class StoredTransactionJournal
|
||||
*
|
||||
* @package FireflyIII\Events
|
||||
* Class StoredTransactionJournal.
|
||||
*/
|
||||
class StoredTransactionJournal extends Event
|
||||
{
|
||||
@ -48,7 +45,6 @@ class StoredTransactionJournal extends Event
|
||||
*/
|
||||
public function __construct(TransactionJournal $journal, int $piggyBankId)
|
||||
{
|
||||
//
|
||||
$this->journal = $journal;
|
||||
$this->piggyBankId = $piggyBankId;
|
||||
}
|
||||
|
@ -18,7 +18,6 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Events;
|
||||
@ -27,9 +26,7 @@ use FireflyIII\Models\TransactionJournal;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
/**
|
||||
* Class UpdatedTransactionJournal
|
||||
*
|
||||
* @package FireflyIII\Events
|
||||
* Class UpdatedTransactionJournal.
|
||||
*/
|
||||
class UpdatedTransactionJournal extends Event
|
||||
{
|
||||
@ -45,7 +42,6 @@ class UpdatedTransactionJournal extends Event
|
||||
*/
|
||||
public function __construct(TransactionJournal $journal)
|
||||
{
|
||||
//
|
||||
$this->journal = $journal;
|
||||
}
|
||||
}
|
||||
|
@ -18,7 +18,6 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Events;
|
||||
@ -27,19 +26,17 @@ use FireflyIII\User;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
/**
|
||||
* Class UserChangedEmail
|
||||
*
|
||||
* @package FireflyIII\Events
|
||||
* Class UserChangedEmail.
|
||||
*/
|
||||
class UserChangedEmail extends Event
|
||||
{
|
||||
use SerializesModels;
|
||||
|
||||
/** @var string */
|
||||
/** @var string */
|
||||
public $ipAddress;
|
||||
/** @var string */
|
||||
/** @var string */
|
||||
public $newEmail;
|
||||
/** @var string */
|
||||
/** @var string */
|
||||
public $oldEmail;
|
||||
/** @var User */
|
||||
public $user;
|
||||
|
@ -18,15 +18,12 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Exceptions;
|
||||
|
||||
/**
|
||||
* Class FireflyException
|
||||
*
|
||||
* @package FireflyIII\Exceptions
|
||||
* Class FireflyException.
|
||||
*/
|
||||
class FireflyException extends \Exception
|
||||
{
|
||||
|
@ -18,10 +18,8 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
|
||||
/**
|
||||
* Handler.php
|
||||
* Copyright (c) 2017 thegrumpydictator@gmail.com
|
||||
@ -58,14 +56,13 @@ class Handler extends ExceptionHandler
|
||||
*/
|
||||
protected $dontReport
|
||||
= [
|
||||
//
|
||||
];
|
||||
|
||||
/**
|
||||
* Render an exception into an HTTP response.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Exception $exception
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Exception $exception
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
@ -86,9 +83,8 @@ class Handler extends ExceptionHandler
|
||||
* This is a great spot to send exceptions to Sentry, Bugsnag, etc.
|
||||
*
|
||||
* @SuppressWarnings(PHPMD.CyclomaticComplexity) // it's five its fine.
|
||||
* @param \Exception $exception
|
||||
*
|
||||
* @return void
|
||||
* @param \Exception $exception
|
||||
*/
|
||||
public function report(Exception $exception)
|
||||
{
|
||||
@ -119,7 +115,6 @@ class Handler extends ExceptionHandler
|
||||
dispatch($job);
|
||||
}
|
||||
|
||||
|
||||
parent::report($exception);
|
||||
}
|
||||
}
|
||||
|
@ -18,15 +18,12 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Exceptions;
|
||||
|
||||
/**
|
||||
* Class NotImplementedException
|
||||
*
|
||||
* @package FireflyIII\Exceptions
|
||||
* Class NotImplementedException.
|
||||
*/
|
||||
class NotImplementedException extends \Exception
|
||||
{
|
||||
|
@ -18,15 +18,12 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Exceptions;
|
||||
|
||||
/**
|
||||
* Class ValidationExceptions
|
||||
*
|
||||
* @package FireflyIII\Exception
|
||||
* Class ValidationExceptions.
|
||||
*/
|
||||
class ValidationException extends \Exception
|
||||
{
|
||||
|
@ -18,7 +18,6 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Export\Collector;
|
||||
@ -33,19 +32,17 @@ use Log;
|
||||
use Storage;
|
||||
|
||||
/**
|
||||
* Class AttachmentCollector
|
||||
*
|
||||
* @package FireflyIII\Export\Collector
|
||||
* Class AttachmentCollector.
|
||||
*/
|
||||
class AttachmentCollector extends BasicCollector implements CollectorInterface
|
||||
{
|
||||
/** @var Carbon */
|
||||
/** @var Carbon */
|
||||
private $end;
|
||||
/** @var \Illuminate\Contracts\Filesystem\Filesystem */
|
||||
private $exportDisk;
|
||||
/** @var AttachmentRepositoryInterface */
|
||||
/** @var AttachmentRepositoryInterface */
|
||||
private $repository;
|
||||
/** @var Carbon */
|
||||
/** @var Carbon */
|
||||
private $start;
|
||||
/** @var \Illuminate\Contracts\Filesystem\Filesystem */
|
||||
private $uploadDisk;
|
||||
@ -55,7 +52,7 @@ class AttachmentCollector extends BasicCollector implements CollectorInterface
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
/** @var AttachmentRepositoryInterface repository */
|
||||
// @var AttachmentRepositoryInterface repository
|
||||
$this->repository = app(AttachmentRepositoryInterface::class);
|
||||
// make storage:
|
||||
$this->uploadDisk = Storage::disk('upload');
|
||||
|
@ -18,7 +18,6 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Export\Collector;
|
||||
@ -28,15 +27,13 @@ use FireflyIII\User;
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
/**
|
||||
* Class BasicCollector
|
||||
*
|
||||
* @package FireflyIII\Export\Collector
|
||||
* Class BasicCollector.
|
||||
*/
|
||||
class BasicCollector
|
||||
{
|
||||
/** @var ExportJob */
|
||||
protected $job;
|
||||
/** @var User */
|
||||
/** @var User */
|
||||
protected $user;
|
||||
/** @var Collection */
|
||||
private $entries;
|
||||
|
@ -18,7 +18,6 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Export\Collector;
|
||||
@ -27,9 +26,7 @@ use FireflyIII\Models\ExportJob;
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
/**
|
||||
* Interface CollectorInterface
|
||||
*
|
||||
* @package FireflyIII\Export\Collector
|
||||
* Interface CollectorInterface.
|
||||
*/
|
||||
interface CollectorInterface
|
||||
{
|
||||
@ -45,9 +42,6 @@ interface CollectorInterface
|
||||
|
||||
/**
|
||||
* @param Collection $entries
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
*/
|
||||
public function setEntries(Collection $entries);
|
||||
|
||||
|
@ -18,7 +18,6 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Export\Collector;
|
||||
@ -30,9 +29,7 @@ use Log;
|
||||
use Storage;
|
||||
|
||||
/**
|
||||
* Class UploadCollector
|
||||
*
|
||||
* @package FireflyIII\Export\Collector
|
||||
* Class UploadCollector.
|
||||
*/
|
||||
class UploadCollector extends BasicCollector implements CollectorInterface
|
||||
{
|
||||
@ -94,7 +91,7 @@ class UploadCollector extends BasicCollector implements CollectorInterface
|
||||
{
|
||||
// find job associated with import file:
|
||||
$job = $this->job->user->importJobs()->where('key', $key)->first();
|
||||
if (is_null($job)) {
|
||||
if (null === $job) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -18,7 +18,6 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Export\Entry;
|
||||
@ -27,7 +26,7 @@ use FireflyIII\Models\Transaction;
|
||||
|
||||
/**
|
||||
* To extend the exported object, in case of new features in Firefly III for example,
|
||||
* do the following:
|
||||
* do the following:.
|
||||
*
|
||||
* - Add the field(s) to this class. If you add more than one related field, add a new object.
|
||||
* - Make sure the "fromJournal"-routine fills these fields.
|
||||
@ -39,52 +38,42 @@ use FireflyIII\Models\Transaction;
|
||||
*
|
||||
*
|
||||
* Class Entry
|
||||
*
|
||||
* @SuppressWarnings(PHPMD.LongVariable)
|
||||
* @SuppressWarnings(PHPMD.TooManyFields)
|
||||
*
|
||||
* @package FireflyIII\Export\Entry
|
||||
*/
|
||||
final class Entry
|
||||
{
|
||||
// @formatter:off
|
||||
public $journal_id;
|
||||
public $transaction_id = 0;
|
||||
|
||||
public $date;
|
||||
public $description;
|
||||
|
||||
public $currency_code;
|
||||
public $amount;
|
||||
public $foreign_currency_code = '';
|
||||
public $foreign_amount = '0';
|
||||
|
||||
public $transaction_type;
|
||||
|
||||
public $asset_account_bic;
|
||||
public $asset_account_iban;
|
||||
public $asset_account_id;
|
||||
public $asset_account_name;
|
||||
public $asset_account_iban;
|
||||
public $asset_account_bic;
|
||||
public $asset_account_number;
|
||||
public $asset_currency_code;
|
||||
|
||||
public $opposing_account_id;
|
||||
public $opposing_account_name;
|
||||
public $opposing_account_iban;
|
||||
public $opposing_account_bic;
|
||||
public $opposing_account_number;
|
||||
public $opposing_currency_code;
|
||||
|
||||
public $budget_id;
|
||||
public $budget_name;
|
||||
|
||||
public $category_id;
|
||||
public $category_name;
|
||||
|
||||
public $bill_id;
|
||||
public $bill_name;
|
||||
|
||||
public $budget_id;
|
||||
public $budget_name;
|
||||
public $category_id;
|
||||
public $category_name;
|
||||
public $currency_code;
|
||||
public $date;
|
||||
public $description;
|
||||
public $foreign_amount = '0';
|
||||
public $foreign_currency_code = '';
|
||||
public $journal_id;
|
||||
public $notes;
|
||||
public $opposing_account_bic;
|
||||
public $opposing_account_iban;
|
||||
public $opposing_account_id;
|
||||
public $opposing_account_name;
|
||||
public $opposing_account_number;
|
||||
public $opposing_currency_code;
|
||||
public $tags;
|
||||
public $transaction_id = 0;
|
||||
public $transaction_type;
|
||||
// @formatter:on
|
||||
|
||||
/**
|
||||
@ -104,7 +93,7 @@ final class Entry
|
||||
*
|
||||
* @return Entry
|
||||
*/
|
||||
public static function fromTransaction(Transaction $transaction): Entry
|
||||
public static function fromTransaction(Transaction $transaction): self
|
||||
{
|
||||
$entry = new self;
|
||||
$entry->journal_id = $transaction->journal_id;
|
||||
@ -117,8 +106,8 @@ final class Entry
|
||||
$entry->currency_code = $transaction->transactionCurrency->code;
|
||||
$entry->amount = round($transaction->transaction_amount, $transaction->transactionCurrency->decimal_places);
|
||||
|
||||
$entry->foreign_currency_code = is_null($transaction->foreign_currency_id) ? null : $transaction->foreignCurrency->code;
|
||||
$entry->foreign_amount = is_null($transaction->foreign_currency_id)
|
||||
$entry->foreign_currency_code = null === $transaction->foreign_currency_id ? null : $transaction->foreignCurrency->code;
|
||||
$entry->foreign_amount = null === $transaction->foreign_currency_id
|
||||
? null
|
||||
: strval(
|
||||
round(
|
||||
@ -142,23 +131,23 @@ final class Entry
|
||||
$entry->opposing_account_bic = $transaction->opposing_account_bic;
|
||||
$entry->opposing_currency_code = $transaction->opposing_currency_code;
|
||||
|
||||
/** budget */
|
||||
// budget
|
||||
$entry->budget_id = $transaction->transaction_budget_id;
|
||||
$entry->budget_name = app('steam')->tryDecrypt($transaction->transaction_budget_name);
|
||||
if (is_null($transaction->transaction_budget_id)) {
|
||||
if (null === $transaction->transaction_budget_id) {
|
||||
$entry->budget_id = $transaction->transaction_journal_budget_id;
|
||||
$entry->budget_name = app('steam')->tryDecrypt($transaction->transaction_journal_budget_name);
|
||||
}
|
||||
|
||||
/** category */
|
||||
// category
|
||||
$entry->category_id = $transaction->transaction_category_id;
|
||||
$entry->category_name = app('steam')->tryDecrypt($transaction->transaction_category_name);
|
||||
if (is_null($transaction->transaction_category_id)) {
|
||||
if (null === $transaction->transaction_category_id) {
|
||||
$entry->category_id = $transaction->transaction_journal_category_id;
|
||||
$entry->category_name = app('steam')->tryDecrypt($transaction->transaction_journal_category_name);
|
||||
}
|
||||
|
||||
/** budget */
|
||||
// budget
|
||||
$entry->bill_id = $transaction->bill_id;
|
||||
$entry->bill_name = app('steam')->tryDecrypt($transaction->bill_name);
|
||||
|
||||
|
@ -18,7 +18,6 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Export;
|
||||
@ -42,32 +41,29 @@ use Storage;
|
||||
use ZipArchive;
|
||||
|
||||
/**
|
||||
* Class ExpandedProcessor
|
||||
* Class ExpandedProcessor.
|
||||
*
|
||||
* @SuppressWarnings(PHPMD.CouplingBetweenObjects) // its doing a lot.
|
||||
*
|
||||
* @package FireflyIII\Export
|
||||
*/
|
||||
class ExpandedProcessor implements ProcessorInterface
|
||||
{
|
||||
|
||||
/** @var Collection */
|
||||
public $accounts;
|
||||
/** @var string */
|
||||
/** @var string */
|
||||
public $exportFormat;
|
||||
/** @var bool */
|
||||
/** @var bool */
|
||||
public $includeAttachments;
|
||||
/** @var bool */
|
||||
/** @var bool */
|
||||
public $includeOldUploads;
|
||||
/** @var ExportJob */
|
||||
/** @var ExportJob */
|
||||
public $job;
|
||||
/** @var array */
|
||||
public $settings;
|
||||
/** @var Collection */
|
||||
/** @var Collection */
|
||||
private $exportEntries;
|
||||
/** @var Collection */
|
||||
/** @var Collection */
|
||||
private $files;
|
||||
/** @var Collection */
|
||||
/** @var Collection */
|
||||
private $journals;
|
||||
|
||||
/**
|
||||
@ -175,6 +171,7 @@ class ExpandedProcessor implements ProcessorInterface
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*
|
||||
* @throws FireflyException
|
||||
*/
|
||||
public function createZipFile(): bool
|
||||
@ -183,7 +180,7 @@ class ExpandedProcessor implements ProcessorInterface
|
||||
$file = $this->job->key . '.zip';
|
||||
$fullPath = storage_path('export') . '/' . $file;
|
||||
|
||||
if ($zip->open($fullPath, ZipArchive::CREATE) !== true) {
|
||||
if (true !== $zip->open($fullPath, ZipArchive::CREATE)) {
|
||||
throw new FireflyException('Cannot store zip file.');
|
||||
}
|
||||
// for each file in the collection, add it to the zip file.
|
||||
@ -278,7 +275,7 @@ class ExpandedProcessor implements ProcessorInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all IBAN / SWIFT / account numbers
|
||||
* Get all IBAN / SWIFT / account numbers.
|
||||
*
|
||||
* @param array $array
|
||||
*
|
||||
|
@ -18,7 +18,6 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Export\Exporter;
|
||||
@ -27,13 +26,11 @@ use FireflyIII\Models\ExportJob;
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
/**
|
||||
* Class BasicExporter
|
||||
*
|
||||
* @package FireflyIII\Export\Exporter
|
||||
* Class BasicExporter.
|
||||
*/
|
||||
class BasicExporter
|
||||
{
|
||||
/** @var ExportJob */
|
||||
/** @var ExportJob */
|
||||
protected $job;
|
||||
/** @var Collection */
|
||||
private $entries;
|
||||
|
@ -18,7 +18,6 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Export\Exporter;
|
||||
@ -28,13 +27,11 @@ use League\Csv\Writer;
|
||||
use SplFileObject;
|
||||
|
||||
/**
|
||||
* Class CsvExporter
|
||||
*
|
||||
* @package FireflyIII\Export\Exporter
|
||||
* Class CsvExporter.
|
||||
*/
|
||||
class CsvExporter extends BasicExporter implements ExporterInterface
|
||||
{
|
||||
/** @var string */
|
||||
/** @var string */
|
||||
private $fileName;
|
||||
|
||||
/**
|
||||
@ -69,7 +66,7 @@ class CsvExporter extends BasicExporter implements ExporterInterface
|
||||
// get field names for header row:
|
||||
$first = $this->getEntries()->first();
|
||||
$headers = [];
|
||||
if (!is_null($first)) {
|
||||
if (null !== $first) {
|
||||
$headers = array_keys(get_object_vars($first));
|
||||
}
|
||||
|
||||
@ -88,7 +85,6 @@ class CsvExporter extends BasicExporter implements ExporterInterface
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
private function tempFile()
|
||||
{
|
||||
$this->fileName = $this->job->key . '-records.csv';
|
||||
|
@ -18,7 +18,6 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Export\Exporter;
|
||||
@ -27,9 +26,7 @@ use FireflyIII\Models\ExportJob;
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
/**
|
||||
* Interface ExporterInterface
|
||||
*
|
||||
* @package FireflyIII\Export\Exporter
|
||||
* Interface ExporterInterface.
|
||||
*/
|
||||
interface ExporterInterface
|
||||
{
|
||||
@ -50,9 +47,6 @@ interface ExporterInterface
|
||||
|
||||
/**
|
||||
* @param Collection $entries
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
*/
|
||||
public function setEntries(Collection $entries);
|
||||
|
||||
|
@ -18,7 +18,6 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Export;
|
||||
@ -26,13 +25,10 @@ namespace FireflyIII\Export;
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
/**
|
||||
* Interface ProcessorInterface
|
||||
*
|
||||
* @package FireflyIII\Export
|
||||
* Interface ProcessorInterface.
|
||||
*/
|
||||
interface ProcessorInterface
|
||||
{
|
||||
|
||||
/**
|
||||
* Processor constructor.
|
||||
*/
|
||||
|
@ -18,7 +18,6 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Generator\Chart\Basic;
|
||||
@ -27,15 +26,12 @@ use FireflyIII\Support\ChartColour;
|
||||
use Steam;
|
||||
|
||||
/**
|
||||
* Class ChartJsGenerator
|
||||
*
|
||||
* @package FireflyIII\Generator\Chart\Basic
|
||||
* Class ChartJsGenerator.
|
||||
*/
|
||||
class ChartJsGenerator implements GeneratorInterface
|
||||
{
|
||||
|
||||
/**
|
||||
* Will generate a Chart JS compatible array from the given input. Expects this format
|
||||
* Will generate a Chart JS compatible array from the given input. Expects this format.
|
||||
*
|
||||
* Will take labels for all from first set.
|
||||
*
|
||||
@ -102,7 +98,7 @@ class ChartJsGenerator implements GeneratorInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* Expects data as:
|
||||
* Expects data as:.
|
||||
*
|
||||
* key => value
|
||||
*
|
||||
@ -123,7 +119,7 @@ class ChartJsGenerator implements GeneratorInterface
|
||||
// different sort when values are positive and when they're negative.
|
||||
asort($data);
|
||||
$next = next($data);
|
||||
if (!is_bool($next) && bccomp($next, '0') === 1) {
|
||||
if (!is_bool($next) && 1 === bccomp($next, '0')) {
|
||||
// next is positive, sort other way around.
|
||||
arsort($data);
|
||||
}
|
||||
@ -131,19 +127,18 @@ class ChartJsGenerator implements GeneratorInterface
|
||||
|
||||
$index = 0;
|
||||
foreach ($data as $key => $value) {
|
||||
|
||||
// make larger than 0
|
||||
$chartData['datasets'][0]['data'][] = floatval(Steam::positive($value));
|
||||
$chartData['datasets'][0]['backgroundColor'][] = ChartColour::getColour($index);
|
||||
$chartData['labels'][] = $key;
|
||||
$index++;
|
||||
++$index;
|
||||
}
|
||||
|
||||
return $chartData;
|
||||
}
|
||||
|
||||
/**
|
||||
* Will generate a (ChartJS) compatible array from the given input. Expects this format:
|
||||
* Will generate a (ChartJS) compatible array from the given input. Expects this format:.
|
||||
*
|
||||
* 'label-of-entry' => value
|
||||
* 'label-of-entry' => value
|
||||
|
@ -18,21 +18,17 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Generator\Chart\Basic;
|
||||
|
||||
/**
|
||||
* Interface GeneratorInterface
|
||||
*
|
||||
* @package FireflyIII\Generator\Chart\Basic
|
||||
* Interface GeneratorInterface.
|
||||
*/
|
||||
interface GeneratorInterface
|
||||
{
|
||||
|
||||
/**
|
||||
* Will generate a Chart JS compatible array from the given input. Expects this format
|
||||
* Will generate a Chart JS compatible array from the given input. Expects this format.
|
||||
*
|
||||
* Will take labels for all from first set.
|
||||
*
|
||||
@ -66,7 +62,7 @@ interface GeneratorInterface
|
||||
public function multiSet(array $data): array;
|
||||
|
||||
/**
|
||||
* Expects data as:
|
||||
* Expects data as:.
|
||||
*
|
||||
* key => value
|
||||
*
|
||||
@ -77,7 +73,7 @@ interface GeneratorInterface
|
||||
public function pieChart(array $data): array;
|
||||
|
||||
/**
|
||||
* Will generate a (ChartJS) compatible array from the given input. Expects this format:
|
||||
* Will generate a (ChartJS) compatible array from the given input. Expects this format:.
|
||||
*
|
||||
* 'label-of-entry' => value
|
||||
* 'label-of-entry' => value
|
||||
|
@ -18,7 +18,6 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Generator\Report\Audit;
|
||||
@ -27,23 +26,20 @@ use Carbon\Carbon;
|
||||
use FireflyIII\Generator\Report\ReportGeneratorInterface;
|
||||
use FireflyIII\Helpers\Collector\JournalCollectorInterface;
|
||||
use FireflyIII\Models\Account;
|
||||
use FireflyIII\Models\Transaction;
|
||||
use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;
|
||||
use Illuminate\Support\Collection;
|
||||
use Steam;
|
||||
|
||||
/**
|
||||
* Class MonthReportGenerator
|
||||
*
|
||||
* @package FireflyIII\Generator\Report\Audit
|
||||
* Class MonthReportGenerator.
|
||||
*/
|
||||
class MonthReportGenerator implements ReportGeneratorInterface
|
||||
{
|
||||
/** @var Collection */
|
||||
/** @var Collection */
|
||||
private $accounts;
|
||||
/** @var Carbon */
|
||||
/** @var Carbon */
|
||||
private $end;
|
||||
/** @var Carbon */
|
||||
/** @var Carbon */
|
||||
private $start;
|
||||
|
||||
/**
|
||||
@ -74,7 +70,6 @@ class MonthReportGenerator implements ReportGeneratorInterface
|
||||
'create_date', 'update_date',
|
||||
];
|
||||
|
||||
|
||||
return view('reports.audit.report', compact('reportType', 'accountIds', 'auditData', 'hideable', 'defaultShow'))
|
||||
->with('start', $this->start)->with('end', $this->end)->with('accounts', $this->accounts)
|
||||
->render();
|
||||
@ -153,7 +148,6 @@ class MonthReportGenerator implements ReportGeneratorInterface
|
||||
* @return array
|
||||
*
|
||||
* @SuppressWarnings(PHPMD.ExcessiveMethodLength) // not that long
|
||||
*
|
||||
*/
|
||||
private function getAuditReport(Account $account, Carbon $date): array
|
||||
{
|
||||
@ -169,7 +163,7 @@ class MonthReportGenerator implements ReportGeneratorInterface
|
||||
$startBalance = $dayBeforeBalance;
|
||||
$currency = $currencyRepos->find(intval($account->getMeta('currency_id')));
|
||||
|
||||
/** @var Transaction $journal */
|
||||
// @var Transaction $journal
|
||||
foreach ($journals as $transaction) {
|
||||
$transaction->before = $startBalance;
|
||||
$transactionAmount = $transaction->transaction_amount;
|
||||
|
@ -18,19 +18,14 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Generator\Report\Audit;
|
||||
|
||||
/**
|
||||
* Class MultiYearReportGenerator
|
||||
*
|
||||
* @package FireflyIII\Generator\Report\Audit
|
||||
* Class MultiYearReportGenerator.
|
||||
*/
|
||||
class MultiYearReportGenerator extends MonthReportGenerator
|
||||
{
|
||||
/**
|
||||
* Doesn't do anything different.
|
||||
*/
|
||||
// Doesn't do anything different.
|
||||
}
|
||||
|
@ -18,20 +18,14 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Generator\Report\Audit;
|
||||
|
||||
/**
|
||||
* Class YearReportGenerator
|
||||
*
|
||||
* @package FireflyIII\Generator\Report\Audit
|
||||
* Class YearReportGenerator.
|
||||
*/
|
||||
class YearReportGenerator extends MonthReportGenerator
|
||||
{
|
||||
|
||||
/**
|
||||
* Doesn't do anything different.
|
||||
*/
|
||||
// Doesn't do anything different.
|
||||
}
|
||||
|
@ -18,7 +18,6 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Generator\Report\Budget;
|
||||
@ -36,23 +35,21 @@ use Illuminate\Support\Collection;
|
||||
use Log;
|
||||
|
||||
/**
|
||||
* Class MonthReportGenerator
|
||||
*
|
||||
* @package FireflyIII\Generator\Report\Budget
|
||||
* Class MonthReportGenerator.
|
||||
*/
|
||||
class MonthReportGenerator extends Support implements ReportGeneratorInterface
|
||||
{
|
||||
/** @var Collection */
|
||||
/** @var Collection */
|
||||
private $accounts;
|
||||
/** @var Collection */
|
||||
/** @var Collection */
|
||||
private $budgets;
|
||||
/** @var Carbon */
|
||||
/** @var Carbon */
|
||||
private $end;
|
||||
/** @var Collection */
|
||||
private $expenses;
|
||||
/** @var Collection */
|
||||
private $income;
|
||||
/** @var Carbon */
|
||||
/** @var Carbon */
|
||||
private $start;
|
||||
|
||||
/**
|
||||
|
@ -18,19 +18,14 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Generator\Report\Budget;
|
||||
|
||||
/**
|
||||
* Class MultiYearReportGenerator
|
||||
*
|
||||
* @package FireflyIII\Generator\Report\Budget
|
||||
* Class MultiYearReportGenerator.
|
||||
*/
|
||||
class MultiYearReportGenerator extends MonthReportGenerator
|
||||
{
|
||||
/**
|
||||
* Doesn't do anything different.
|
||||
*/
|
||||
// Doesn't do anything different.
|
||||
}
|
||||
|
@ -18,20 +18,14 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Generator\Report\Budget;
|
||||
|
||||
/**
|
||||
* Class YearReportGenerator
|
||||
*
|
||||
* @package FireflyIII\Generator\Report\Budget
|
||||
* Class YearReportGenerator.
|
||||
*/
|
||||
class YearReportGenerator extends MonthReportGenerator
|
||||
{
|
||||
|
||||
/**
|
||||
* Doesn't do anything different.
|
||||
*/
|
||||
// Doesn't do anything different.
|
||||
}
|
||||
|
@ -18,7 +18,6 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Generator\Report\Category;
|
||||
@ -37,23 +36,21 @@ use Illuminate\Support\Collection;
|
||||
use Log;
|
||||
|
||||
/**
|
||||
* Class MonthReportGenerator
|
||||
*
|
||||
* @package FireflyIII\Generator\Report\Category
|
||||
* Class MonthReportGenerator.
|
||||
*/
|
||||
class MonthReportGenerator extends Support implements ReportGeneratorInterface
|
||||
{
|
||||
/** @var Collection */
|
||||
/** @var Collection */
|
||||
private $accounts;
|
||||
/** @var Collection */
|
||||
/** @var Collection */
|
||||
private $categories;
|
||||
/** @var Carbon */
|
||||
/** @var Carbon */
|
||||
private $end;
|
||||
/** @var Collection */
|
||||
private $expenses;
|
||||
/** @var Collection */
|
||||
private $income;
|
||||
/** @var Carbon */
|
||||
/** @var Carbon */
|
||||
private $start;
|
||||
|
||||
/**
|
||||
@ -82,7 +79,6 @@ class MonthReportGenerator extends Support implements ReportGeneratorInterface
|
||||
$topExpenses = $this->getTopExpenses();
|
||||
$topIncome = $this->getTopIncome();
|
||||
|
||||
|
||||
// render!
|
||||
return view(
|
||||
'reports.category.month',
|
||||
|
@ -18,19 +18,14 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Generator\Report\Category;
|
||||
|
||||
/**
|
||||
* Class MultiYearReportGenerator
|
||||
*
|
||||
* @package FireflyIII\Generator\Report\Category
|
||||
* Class MultiYearReportGenerator.
|
||||
*/
|
||||
class MultiYearReportGenerator extends MonthReportGenerator
|
||||
{
|
||||
/**
|
||||
* Doesn't do anything different.
|
||||
*/
|
||||
// Doesn't do anything different.
|
||||
}
|
||||
|
@ -18,20 +18,14 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Generator\Report\Category;
|
||||
|
||||
/**
|
||||
* Class YearReportGenerator
|
||||
*
|
||||
* @package FireflyIII\Generator\Report\Category
|
||||
* Class YearReportGenerator.
|
||||
*/
|
||||
class YearReportGenerator extends MonthReportGenerator
|
||||
{
|
||||
|
||||
/**
|
||||
* Doesn't do anything different.
|
||||
*/
|
||||
// Doesn't do anything different.
|
||||
}
|
||||
|
@ -18,7 +18,6 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Generator\Report;
|
||||
@ -27,19 +26,17 @@ use Carbon\Carbon;
|
||||
use FireflyIII\Exceptions\FireflyException;
|
||||
|
||||
/**
|
||||
* Class ReportGeneratorFactory
|
||||
*
|
||||
* @package FireflyIII\Generator\Report
|
||||
* Class ReportGeneratorFactory.
|
||||
*/
|
||||
class ReportGeneratorFactory
|
||||
{
|
||||
|
||||
/**
|
||||
* @param string $type
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
*
|
||||
* @return ReportGeneratorInterface
|
||||
*
|
||||
* @throws FireflyException
|
||||
*/
|
||||
public static function reportGenerator(string $type, Carbon $start, Carbon $end): ReportGeneratorInterface
|
||||
@ -55,7 +52,6 @@ class ReportGeneratorFactory
|
||||
$period = 'MultiYear';
|
||||
}
|
||||
|
||||
|
||||
$class = sprintf('FireflyIII\Generator\Report\%s\%sReportGenerator', $type, $period);
|
||||
if (class_exists($class)) {
|
||||
/** @var ReportGeneratorInterface $obj */
|
||||
|
@ -18,7 +18,6 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Generator\Report;
|
||||
@ -27,9 +26,7 @@ use Carbon\Carbon;
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
/**
|
||||
* Interface ReportGeneratorInterface
|
||||
*
|
||||
* @package FireflyIII\Generator\Report
|
||||
* Interface ReportGeneratorInterface.
|
||||
*/
|
||||
interface ReportGeneratorInterface
|
||||
{
|
||||
@ -43,40 +40,40 @@ interface ReportGeneratorInterface
|
||||
*
|
||||
* @return ReportGeneratorInterface
|
||||
*/
|
||||
public function setAccounts(Collection $accounts): ReportGeneratorInterface;
|
||||
public function setAccounts(Collection $accounts): self;
|
||||
|
||||
/**
|
||||
* @param Collection $budgets
|
||||
*
|
||||
* @return ReportGeneratorInterface
|
||||
*/
|
||||
public function setBudgets(Collection $budgets): ReportGeneratorInterface;
|
||||
public function setBudgets(Collection $budgets): self;
|
||||
|
||||
/**
|
||||
* @param Collection $categories
|
||||
*
|
||||
* @return ReportGeneratorInterface
|
||||
*/
|
||||
public function setCategories(Collection $categories): ReportGeneratorInterface;
|
||||
public function setCategories(Collection $categories): self;
|
||||
|
||||
/**
|
||||
* @param Carbon $date
|
||||
*
|
||||
* @return ReportGeneratorInterface
|
||||
*/
|
||||
public function setEndDate(Carbon $date): ReportGeneratorInterface;
|
||||
public function setEndDate(Carbon $date): self;
|
||||
|
||||
/**
|
||||
* @param Carbon $date
|
||||
*
|
||||
* @return ReportGeneratorInterface
|
||||
*/
|
||||
public function setStartDate(Carbon $date): ReportGeneratorInterface;
|
||||
public function setStartDate(Carbon $date): self;
|
||||
|
||||
/**
|
||||
* @param Collection $tags
|
||||
*
|
||||
* @return ReportGeneratorInterface
|
||||
*/
|
||||
public function setTags(Collection $tags): ReportGeneratorInterface;
|
||||
public function setTags(Collection $tags): self;
|
||||
}
|
||||
|
@ -18,7 +18,6 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Generator\Report\Standard;
|
||||
@ -29,17 +28,15 @@ use FireflyIII\Helpers\Report\ReportHelperInterface;
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
/**
|
||||
* Class MonthReportGenerator
|
||||
*
|
||||
* @package FireflyIII\Generator\Report\Standard
|
||||
* Class MonthReportGenerator.
|
||||
*/
|
||||
class MonthReportGenerator implements ReportGeneratorInterface
|
||||
{
|
||||
/** @var Collection */
|
||||
/** @var Collection */
|
||||
private $accounts;
|
||||
/** @var Carbon */
|
||||
/** @var Carbon */
|
||||
private $end;
|
||||
/** @var Carbon */
|
||||
/** @var Carbon */
|
||||
private $start;
|
||||
|
||||
/**
|
||||
|
@ -18,7 +18,6 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Generator\Report\Standard;
|
||||
@ -28,17 +27,15 @@ use FireflyIII\Generator\Report\ReportGeneratorInterface;
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
/**
|
||||
* Class MonthReportGenerator
|
||||
*
|
||||
* @package FireflyIII\Generator\Report\Standard
|
||||
* Class MonthReportGenerator.
|
||||
*/
|
||||
class MultiYearReportGenerator implements ReportGeneratorInterface
|
||||
{
|
||||
/** @var Collection */
|
||||
/** @var Collection */
|
||||
private $accounts;
|
||||
/** @var Carbon */
|
||||
/** @var Carbon */
|
||||
private $end;
|
||||
/** @var Carbon */
|
||||
/** @var Carbon */
|
||||
private $start;
|
||||
|
||||
/**
|
||||
|
@ -18,7 +18,6 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Generator\Report\Standard;
|
||||
@ -28,17 +27,15 @@ use FireflyIII\Generator\Report\ReportGeneratorInterface;
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
/**
|
||||
* Class MonthReportGenerator
|
||||
*
|
||||
* @package FireflyIII\Generator\Report\Standard
|
||||
* Class MonthReportGenerator.
|
||||
*/
|
||||
class YearReportGenerator implements ReportGeneratorInterface
|
||||
{
|
||||
/** @var Collection */
|
||||
/** @var Collection */
|
||||
private $accounts;
|
||||
/** @var Carbon */
|
||||
/** @var Carbon */
|
||||
private $end;
|
||||
/** @var Carbon */
|
||||
/** @var Carbon */
|
||||
private $start;
|
||||
|
||||
/**
|
||||
|
@ -18,7 +18,6 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Generator\Report;
|
||||
@ -27,9 +26,7 @@ use FireflyIII\Models\Transaction;
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
/**
|
||||
* Class Support
|
||||
*
|
||||
* @package FireflyIII\Generator\Report\Category
|
||||
* Class Support.
|
||||
*/
|
||||
class Support
|
||||
{
|
||||
@ -79,7 +76,7 @@ class Support
|
||||
];
|
||||
continue;
|
||||
}
|
||||
$result[$opposingId]['count']++;
|
||||
++$result[$opposingId]['count'];
|
||||
$result[$opposingId]['sum'] = bcadd($result[$opposingId]['sum'], $transaction->transaction_amount);
|
||||
$result[$opposingId]['average'] = bcdiv($result[$opposingId]['sum'], strval($result[$opposingId]['count']));
|
||||
}
|
||||
@ -97,6 +94,7 @@ class Support
|
||||
|
||||
/**
|
||||
* @SuppressWarnings(PHPMD.CyclomaticComplexity) // it's exactly five.
|
||||
*
|
||||
* @param array $spent
|
||||
* @param array $earned
|
||||
*
|
||||
@ -107,7 +105,7 @@ class Support
|
||||
$return = [];
|
||||
|
||||
/**
|
||||
* @var int $accountId
|
||||
* @var int
|
||||
* @var string $entry
|
||||
*/
|
||||
foreach ($spent as $objectId => $entry) {
|
||||
@ -120,7 +118,7 @@ class Support
|
||||
unset($entry);
|
||||
|
||||
/**
|
||||
* @var int $accountId
|
||||
* @var int
|
||||
* @var string $entry
|
||||
*/
|
||||
foreach ($earned as $objectId => $entry) {
|
||||
@ -131,7 +129,6 @@ class Support
|
||||
$return[$objectId]['earned'] = $entry;
|
||||
}
|
||||
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
|
@ -18,7 +18,6 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Generator\Report\Tag;
|
||||
@ -38,22 +37,19 @@ use Illuminate\Support\Collection;
|
||||
use Log;
|
||||
|
||||
/**
|
||||
* Class MonthReportGenerator
|
||||
*
|
||||
* @package FireflyIII\Generator\Report\Tag
|
||||
* Class MonthReportGenerator.
|
||||
*/
|
||||
class MonthReportGenerator extends Support implements ReportGeneratorInterface
|
||||
{
|
||||
|
||||
/** @var Collection */
|
||||
private $accounts;
|
||||
/** @var Carbon */
|
||||
/** @var Carbon */
|
||||
private $end;
|
||||
/** @var Collection */
|
||||
private $expenses;
|
||||
/** @var Collection */
|
||||
private $income;
|
||||
/** @var Carbon */
|
||||
/** @var Carbon */
|
||||
private $start;
|
||||
/** @var Collection */
|
||||
private $tags;
|
||||
@ -84,7 +80,6 @@ class MonthReportGenerator extends Support implements ReportGeneratorInterface
|
||||
$topExpenses = $this->getTopExpenses();
|
||||
$topIncome = $this->getTopIncome();
|
||||
|
||||
|
||||
// render!
|
||||
return view(
|
||||
'reports.tag.month',
|
||||
|
@ -18,19 +18,14 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Generator\Report\Tag;
|
||||
|
||||
/**
|
||||
* Class MultiYearReportGenerator
|
||||
*
|
||||
* @package FireflyIII\Generator\Report\Tag
|
||||
* Class MultiYearReportGenerator.
|
||||
*/
|
||||
class MultiYearReportGenerator extends MonthReportGenerator
|
||||
{
|
||||
/**
|
||||
* Doesn't do anything different.
|
||||
*/
|
||||
// Doesn't do anything different.
|
||||
}
|
||||
|
@ -18,20 +18,14 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Generator\Report\Tag;
|
||||
|
||||
/**
|
||||
* Class YearReportGenerator
|
||||
*
|
||||
* @package FireflyIII\Generator\Report\Tag
|
||||
* Class YearReportGenerator.
|
||||
*/
|
||||
class YearReportGenerator extends MonthReportGenerator
|
||||
{
|
||||
|
||||
/**
|
||||
* Doesn't do anything different.
|
||||
*/
|
||||
// Doesn't do anything different.
|
||||
}
|
||||
|
@ -18,7 +18,6 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Handlers\Events;
|
||||
@ -31,9 +30,7 @@ use Session;
|
||||
use Swift_TransportException;
|
||||
|
||||
/**
|
||||
* Class AdminEventHandler
|
||||
*
|
||||
* @package FireflyIII\Handlers\Events
|
||||
* Class AdminEventHandler.
|
||||
*/
|
||||
class AdminEventHandler
|
||||
{
|
||||
|
@ -18,7 +18,6 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Handlers\Events;
|
||||
@ -37,17 +36,15 @@ use Log;
|
||||
* @codeCoverageIgnore
|
||||
*
|
||||
* Class StoredJournalEventHandler
|
||||
*
|
||||
* @package FireflyIII\Handlers\Events
|
||||
*/
|
||||
class StoredJournalEventHandler
|
||||
{
|
||||
/** @var JRI */
|
||||
/** @var JRI */
|
||||
public $journalRepository;
|
||||
/** @var PRI */
|
||||
/** @var PRI */
|
||||
public $repository;
|
||||
|
||||
/** @var RGRI */
|
||||
/** @var RGRI */
|
||||
public $ruleGroupRepository;
|
||||
|
||||
/**
|
||||
@ -88,7 +85,7 @@ class StoredJournalEventHandler
|
||||
}
|
||||
|
||||
// piggy exists?
|
||||
if (is_null($piggyBank->id)) {
|
||||
if (null === $piggyBank->id) {
|
||||
Log::error(sprintf('There is no piggy bank with ID #%d', $piggyBankId));
|
||||
|
||||
return true;
|
||||
@ -96,7 +93,7 @@ class StoredJournalEventHandler
|
||||
|
||||
// repetition exists?
|
||||
$repetition = $this->repository->getRepetition($piggyBank, $journal->date);
|
||||
if (is_null($repetition->id)) {
|
||||
if (null === $repetition->id) {
|
||||
Log::error(sprintf('No piggy bank repetition on %s!', $journal->date->format('Y-m-d')));
|
||||
|
||||
return true;
|
||||
@ -104,7 +101,7 @@ class StoredJournalEventHandler
|
||||
|
||||
// get the amount
|
||||
$amount = $this->repository->getExactAmount($piggyBank, $repetition, $journal);
|
||||
if (bccomp($amount, '0') === 0) {
|
||||
if (0 === bccomp($amount, '0')) {
|
||||
Log::debug('Amount is zero, will not create event.');
|
||||
|
||||
return true;
|
||||
|
@ -18,7 +18,6 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Handlers\Events;
|
||||
@ -34,12 +33,10 @@ use FireflyIII\TransactionRules\Processor;
|
||||
* @codeCoverageIgnore
|
||||
*
|
||||
* Class UpdatedJournalEventHandler
|
||||
*
|
||||
* @package FireflyIII\Handlers\Events
|
||||
*/
|
||||
class UpdatedJournalEventHandler
|
||||
{
|
||||
/** @var RuleGroupRepositoryInterface */
|
||||
/** @var RuleGroupRepositoryInterface */
|
||||
public $repository;
|
||||
|
||||
/**
|
||||
|
@ -18,7 +18,6 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Handlers\Events;
|
||||
@ -37,17 +36,14 @@ use Preferences;
|
||||
use Swift_TransportException;
|
||||
|
||||
/**
|
||||
* Class UserEventHandler
|
||||
* Class UserEventHandler.
|
||||
*
|
||||
* This class responds to any events that have anything to do with the User object.
|
||||
*
|
||||
* The method name reflects what is being done. This is in the present tense.
|
||||
*
|
||||
* @package FireflyIII\Handlers\Events
|
||||
*/
|
||||
class UserEventHandler
|
||||
{
|
||||
|
||||
/**
|
||||
* This method will bestow upon a user the "owner" role if he is the first user in the system.
|
||||
*
|
||||
@ -61,7 +57,7 @@ class UserEventHandler
|
||||
$repository = app(UserRepositoryInterface::class);
|
||||
|
||||
// first user ever?
|
||||
if ($repository->count() === 1) {
|
||||
if (1 === $repository->count()) {
|
||||
$repository->attachRole($event->user, 'owner');
|
||||
}
|
||||
|
||||
|
@ -18,7 +18,6 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Helpers\Attachments;
|
||||
@ -33,14 +32,11 @@ use Storage;
|
||||
use Symfony\Component\HttpFoundation\File\UploadedFile;
|
||||
|
||||
/**
|
||||
* Class AttachmentHelper
|
||||
*
|
||||
* @package FireflyIII\Helpers\Attachments
|
||||
* Class AttachmentHelper.
|
||||
*/
|
||||
class AttachmentHelper implements AttachmentHelperInterface
|
||||
{
|
||||
|
||||
/** @var Collection */
|
||||
/** @var Collection */
|
||||
public $attachments;
|
||||
/** @var MessageBag */
|
||||
public $errors;
|
||||
@ -114,7 +110,7 @@ class AttachmentHelper implements AttachmentHelperInterface
|
||||
if (is_array($files)) {
|
||||
/** @var UploadedFile $entry */
|
||||
foreach ($files as $entry) {
|
||||
if (!is_null($entry)) {
|
||||
if (null !== $entry) {
|
||||
$this->processFile($entry, $model);
|
||||
}
|
||||
}
|
||||
@ -152,7 +148,6 @@ class AttachmentHelper implements AttachmentHelperInterface
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param UploadedFile $file
|
||||
* @param Model $model
|
||||
*
|
||||
@ -161,7 +156,7 @@ class AttachmentHelper implements AttachmentHelperInterface
|
||||
protected function processFile(UploadedFile $file, Model $model): Attachment
|
||||
{
|
||||
$validation = $this->validateUpload($file, $model);
|
||||
if ($validation === false) {
|
||||
if (false === $validation) {
|
||||
return new Attachment;
|
||||
}
|
||||
|
||||
|
@ -18,7 +18,6 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Helpers\Attachments;
|
||||
@ -29,13 +28,10 @@ use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\MessageBag;
|
||||
|
||||
/**
|
||||
* Interface AttachmentHelperInterface
|
||||
*
|
||||
* @package FireflyIII\Helpers\Attachments
|
||||
* Interface AttachmentHelperInterface.
|
||||
*/
|
||||
interface AttachmentHelperInterface
|
||||
{
|
||||
|
||||
/**
|
||||
* @param Attachment $attachment
|
||||
*
|
||||
@ -60,7 +56,6 @@ interface AttachmentHelperInterface
|
||||
|
||||
/**
|
||||
* @param Model $model
|
||||
*
|
||||
* @param null|array $files
|
||||
*
|
||||
* @return bool
|
||||
|
@ -18,7 +18,6 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Helpers\Chart;
|
||||
@ -41,23 +40,19 @@ use Illuminate\Support\Collection;
|
||||
use Steam;
|
||||
|
||||
/**
|
||||
* Class MetaPieChart
|
||||
*
|
||||
* @package FireflyIII\Helpers\Chart
|
||||
*
|
||||
*
|
||||
* Class MetaPieChart.
|
||||
*/
|
||||
class MetaPieChart implements MetaPieChartInterface
|
||||
{
|
||||
/** @var Collection */
|
||||
/** @var Collection */
|
||||
protected $accounts;
|
||||
/** @var Collection */
|
||||
/** @var Collection */
|
||||
protected $budgets;
|
||||
/** @var Collection */
|
||||
/** @var Collection */
|
||||
protected $categories;
|
||||
/** @var bool */
|
||||
protected $collectOtherObjects = false;
|
||||
/** @var Carbon */
|
||||
/** @var Carbon */
|
||||
protected $end;
|
||||
/** @var array */
|
||||
protected $grouping
|
||||
@ -75,13 +70,13 @@ class MetaPieChart implements MetaPieChartInterface
|
||||
'category' => CategoryRepositoryInterface::class,
|
||||
'tag' => TagRepositoryInterface::class,
|
||||
];
|
||||
/** @var Carbon */
|
||||
/** @var Carbon */
|
||||
protected $start;
|
||||
/** @var Collection */
|
||||
/** @var Collection */
|
||||
protected $tags;
|
||||
/** @var string */
|
||||
/** @var string */
|
||||
protected $total = '0';
|
||||
/** @var User */
|
||||
/** @var User */
|
||||
protected $user;
|
||||
|
||||
public function __construct()
|
||||
@ -108,7 +103,7 @@ class MetaPieChart implements MetaPieChartInterface
|
||||
$key = strval(trans('firefly.everything_else'));
|
||||
|
||||
// also collect all other transactions
|
||||
if ($this->collectOtherObjects && $direction === 'expense') {
|
||||
if ($this->collectOtherObjects && 'expense' === $direction) {
|
||||
/** @var JournalCollectorInterface $collector */
|
||||
$collector = app(JournalCollectorInterface::class);
|
||||
$collector->setUser($this->user);
|
||||
@ -121,7 +116,7 @@ class MetaPieChart implements MetaPieChartInterface
|
||||
$chartData[$key] = $sum;
|
||||
}
|
||||
|
||||
if ($this->collectOtherObjects && $direction === 'income') {
|
||||
if ($this->collectOtherObjects && 'income' === $direction) {
|
||||
/** @var JournalCollectorInterface $collector */
|
||||
$collector = app(JournalCollectorInterface::class);
|
||||
$collector->setUser($this->user);
|
||||
@ -258,7 +253,7 @@ class MetaPieChart implements MetaPieChartInterface
|
||||
$collector = app(JournalCollectorInterface::class);
|
||||
$types = [TransactionType::DEPOSIT, TransactionType::TRANSFER];
|
||||
$collector->addFilter(NegativeAmountFilter::class);
|
||||
if ($direction === 'expense') {
|
||||
if ('expense' === $direction) {
|
||||
$types = [TransactionType::WITHDRAWAL, TransactionType::TRANSFER];
|
||||
$collector->addFilter(PositiveAmountFilter::class);
|
||||
$collector->removeFilter(NegativeAmountFilter::class);
|
||||
@ -271,7 +266,7 @@ class MetaPieChart implements MetaPieChartInterface
|
||||
$collector->withOpposingAccount();
|
||||
$collector->addFilter(OpposingAccountFilter::class);
|
||||
|
||||
if ($direction === 'income') {
|
||||
if ('income' === $direction) {
|
||||
$collector->removeFilter(TransferFilter::class);
|
||||
}
|
||||
|
||||
@ -294,11 +289,10 @@ class MetaPieChart implements MetaPieChartInterface
|
||||
* @return array
|
||||
*
|
||||
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
|
||||
*
|
||||
*/
|
||||
protected function groupByFields(Collection $set, array $fields): array
|
||||
{
|
||||
if (count($fields) === 0 && $this->tags->count() > 0) {
|
||||
if (0 === count($fields) && $this->tags->count() > 0) {
|
||||
// do a special group on tags:
|
||||
return $this->groupByTag($set);
|
||||
}
|
||||
|
@ -18,7 +18,6 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Helpers\Chart;
|
||||
@ -28,9 +27,7 @@ use FireflyIII\User;
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
/**
|
||||
* Interface MetaPieChartInterface
|
||||
*
|
||||
* @package FireflyIII\Helpers\Chart
|
||||
* Interface MetaPieChartInterface.
|
||||
*/
|
||||
interface MetaPieChartInterface
|
||||
{
|
||||
@ -47,54 +44,54 @@ interface MetaPieChartInterface
|
||||
*
|
||||
* @return MetaPieChartInterface
|
||||
*/
|
||||
public function setAccounts(Collection $accounts): MetaPieChartInterface;
|
||||
public function setAccounts(Collection $accounts): self;
|
||||
|
||||
/**
|
||||
* @param Collection $budgets
|
||||
*
|
||||
* @return MetaPieChartInterface
|
||||
*/
|
||||
public function setBudgets(Collection $budgets): MetaPieChartInterface;
|
||||
public function setBudgets(Collection $budgets): self;
|
||||
|
||||
/**
|
||||
* @param Collection $categories
|
||||
*
|
||||
* @return MetaPieChartInterface
|
||||
*/
|
||||
public function setCategories(Collection $categories): MetaPieChartInterface;
|
||||
public function setCategories(Collection $categories): self;
|
||||
|
||||
/**
|
||||
* @param bool $collectOtherObjects
|
||||
*
|
||||
* @return MetaPieChartInterface
|
||||
*/
|
||||
public function setCollectOtherObjects(bool $collectOtherObjects): MetaPieChartInterface;
|
||||
public function setCollectOtherObjects(bool $collectOtherObjects): self;
|
||||
|
||||
/**
|
||||
* @param Carbon $end
|
||||
*
|
||||
* @return MetaPieChartInterface
|
||||
*/
|
||||
public function setEnd(Carbon $end): MetaPieChartInterface;
|
||||
public function setEnd(Carbon $end): self;
|
||||
|
||||
/**
|
||||
* @param Carbon $start
|
||||
*
|
||||
* @return MetaPieChartInterface
|
||||
*/
|
||||
public function setStart(Carbon $start): MetaPieChartInterface;
|
||||
public function setStart(Carbon $start): self;
|
||||
|
||||
/**
|
||||
* @param Collection $tags
|
||||
*
|
||||
* @return MetaPieChartInterface
|
||||
*/
|
||||
public function setTags(Collection $tags): MetaPieChartInterface;
|
||||
public function setTags(Collection $tags): self;
|
||||
|
||||
/**
|
||||
* @param User $user
|
||||
*
|
||||
* @return MetaPieChartInterface
|
||||
*/
|
||||
public function setUser(User $user): MetaPieChartInterface;
|
||||
public function setUser(User $user): self;
|
||||
}
|
||||
|
@ -18,7 +18,6 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Helpers\Collection;
|
||||
@ -26,18 +25,14 @@ namespace FireflyIII\Helpers\Collection;
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
/**
|
||||
*
|
||||
* Class Balance
|
||||
*
|
||||
* @package FireflyIII\Helpers\Collection
|
||||
* Class Balance.
|
||||
*/
|
||||
class Balance
|
||||
{
|
||||
|
||||
/** @var BalanceHeader */
|
||||
/** @var BalanceHeader */
|
||||
protected $balanceHeader;
|
||||
|
||||
/** @var Collection */
|
||||
/** @var Collection */
|
||||
protected $balanceLines;
|
||||
|
||||
/**
|
||||
|
@ -18,7 +18,6 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Helpers\Collection;
|
||||
@ -26,16 +25,11 @@ namespace FireflyIII\Helpers\Collection;
|
||||
use FireflyIII\Models\Account as AccountModel;
|
||||
|
||||
/**
|
||||
*
|
||||
* Class BalanceEntry
|
||||
*
|
||||
* @package FireflyIII\Helpers\Collection
|
||||
* Class BalanceEntry.
|
||||
*/
|
||||
class BalanceEntry
|
||||
{
|
||||
|
||||
|
||||
/** @var AccountModel */
|
||||
/** @var AccountModel */
|
||||
protected $account;
|
||||
/** @var string */
|
||||
protected $left = '0';
|
||||
|
@ -18,7 +18,6 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Helpers\Collection;
|
||||
@ -27,15 +26,11 @@ use FireflyIII\Models\Account as AccountModel;
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
/**
|
||||
*
|
||||
* Class BalanceHeader
|
||||
*
|
||||
* @package FireflyIII\Helpers\Collection
|
||||
* Class BalanceHeader.
|
||||
*/
|
||||
class BalanceHeader
|
||||
{
|
||||
|
||||
/** @var Collection */
|
||||
/** @var Collection */
|
||||
protected $accounts;
|
||||
|
||||
/**
|
||||
|
@ -18,7 +18,6 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Helpers\Collection;
|
||||
@ -29,10 +28,7 @@ use FireflyIII\Models\BudgetLimit;
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
/**
|
||||
*
|
||||
* Class BalanceLine
|
||||
*
|
||||
* @package FireflyIII\Helpers\Collection
|
||||
* Class BalanceLine.
|
||||
*/
|
||||
class BalanceLine
|
||||
{
|
||||
@ -40,12 +36,12 @@ class BalanceLine
|
||||
const ROLE_TAGROLE = 2;
|
||||
const ROLE_DIFFROLE = 3;
|
||||
|
||||
/** @var Collection */
|
||||
/** @var Collection */
|
||||
protected $balanceEntries;
|
||||
|
||||
/** @var BudgetModel */
|
||||
protected $budget;
|
||||
/** @var BudgetLimit */
|
||||
/** @var BudgetLimit */
|
||||
protected $budgetLimit;
|
||||
/** @var int */
|
||||
protected $role = self::ROLE_DEFAULTROLE;
|
||||
@ -148,20 +144,21 @@ class BalanceLine
|
||||
|
||||
/**
|
||||
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getTitle(): string
|
||||
{
|
||||
if ($this->getBudget() instanceof BudgetModel && !is_null($this->getBudget()->id)) {
|
||||
if ($this->getBudget() instanceof BudgetModel && null !== $this->getBudget()->id) {
|
||||
return $this->getBudget()->name;
|
||||
}
|
||||
if ($this->getRole() === self::ROLE_DEFAULTROLE) {
|
||||
if (self::ROLE_DEFAULTROLE === $this->getRole()) {
|
||||
return strval(trans('firefly.no_budget'));
|
||||
}
|
||||
if ($this->getRole() === self::ROLE_TAGROLE) {
|
||||
if (self::ROLE_TAGROLE === $this->getRole()) {
|
||||
return strval(trans('firefly.coveredWithTags'));
|
||||
}
|
||||
if ($this->getRole() === self::ROLE_DIFFROLE) {
|
||||
if (self::ROLE_DIFFROLE === $this->getRole()) {
|
||||
return strval(trans('firefly.leftUnbalanced'));
|
||||
}
|
||||
|
||||
@ -172,7 +169,7 @@ class BalanceLine
|
||||
* If a BalanceLine has a budget/repetition, each BalanceEntry in this BalanceLine
|
||||
* should have a "spent" value, which is the amount of money that has been spent
|
||||
* on the given budget/repetition. If you subtract all those amounts from the budget/repetition's
|
||||
* total amount, this is returned:
|
||||
* total amount, this is returned:.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
|
@ -18,7 +18,6 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Helpers\Collection;
|
||||
@ -29,20 +28,17 @@ use Illuminate\Support\Collection;
|
||||
use Log;
|
||||
|
||||
/**
|
||||
* Class Bill
|
||||
*
|
||||
* @package FireflyIII\Helpers\Collection
|
||||
* Class Bill.
|
||||
*/
|
||||
class Bill
|
||||
{
|
||||
|
||||
/**
|
||||
* @var Collection
|
||||
*/
|
||||
private $bills;
|
||||
/** @var Carbon */
|
||||
/** @var Carbon */
|
||||
private $endDate;
|
||||
/** @var Carbon */
|
||||
/** @var Carbon */
|
||||
private $startDate;
|
||||
|
||||
/**
|
||||
@ -105,14 +101,13 @@ class Bill
|
||||
{
|
||||
$set = $this->bills->sortBy(
|
||||
function (BillLine $bill) {
|
||||
$active = intval($bill->getBill()->active) === 0 ? 1 : 0;
|
||||
$active = 0 === intval($bill->getBill()->active) ? 1 : 0;
|
||||
$name = $bill->getBill()->name;
|
||||
|
||||
return $active . $name;
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
return $set;
|
||||
}
|
||||
|
||||
|
@ -18,7 +18,6 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Helpers\Collection;
|
||||
@ -27,27 +26,23 @@ use Carbon\Carbon;
|
||||
use FireflyIII\Models\Bill as BillModel;
|
||||
|
||||
/**
|
||||
*
|
||||
* Class BillLine
|
||||
*
|
||||
* @package FireflyIII\Helpers\Collection
|
||||
* Class BillLine.
|
||||
*/
|
||||
class BillLine
|
||||
{
|
||||
|
||||
/** @var string */
|
||||
/** @var string */
|
||||
protected $amount;
|
||||
/** @var BillModel */
|
||||
/** @var BillModel */
|
||||
protected $bill;
|
||||
/** @var bool */
|
||||
/** @var bool */
|
||||
protected $hit;
|
||||
/** @var string */
|
||||
/** @var string */
|
||||
protected $max;
|
||||
/** @var string */
|
||||
/** @var string */
|
||||
protected $min;
|
||||
/** @var Carbon */
|
||||
/** @var Carbon */
|
||||
private $lastHitDate;
|
||||
/** @var int */
|
||||
/** @var int */
|
||||
private $transactionJournalId;
|
||||
|
||||
/**
|
||||
@ -159,7 +154,7 @@ class BillLine
|
||||
*/
|
||||
public function isActive(): bool
|
||||
{
|
||||
return intval($this->bill->active) === 1;
|
||||
return 1 === intval($this->bill->active);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -18,7 +18,6 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Helpers\Collection;
|
||||
@ -27,15 +26,11 @@ use FireflyIII\Models\Category as CategoryModel;
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
/**
|
||||
*
|
||||
* Class Category
|
||||
*
|
||||
* @package FireflyIII\Helpers\Collection
|
||||
* Class Category.
|
||||
*/
|
||||
class Category
|
||||
{
|
||||
|
||||
/** @var Collection */
|
||||
/** @var Collection */
|
||||
protected $categories;
|
||||
/** @var string */
|
||||
protected $total = '0';
|
||||
@ -79,7 +74,6 @@ class Category
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
return $set;
|
||||
}
|
||||
|
||||
|
@ -18,7 +18,6 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Helpers\Collector;
|
||||
@ -51,7 +50,6 @@ use Steam;
|
||||
*
|
||||
* Class JournalCollector
|
||||
*
|
||||
* @package FireflyIII\Helpers\Collector
|
||||
*
|
||||
* @SuppressWarnings(PHPMD.ExcessiveClassComplexity)
|
||||
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
|
||||
@ -59,10 +57,9 @@ use Steam;
|
||||
*/
|
||||
class JournalCollector implements JournalCollectorInterface
|
||||
{
|
||||
|
||||
/** @var array */
|
||||
private $accountIds = [];
|
||||
/** @var int */
|
||||
/** @var int */
|
||||
private $count = 0;
|
||||
/** @var array */
|
||||
private $fields
|
||||
@ -101,22 +98,21 @@ class JournalCollector implements JournalCollectorInterface
|
||||
'accounts.encrypted as account_encrypted',
|
||||
'accounts.iban as account_iban',
|
||||
'account_types.type as account_type',
|
||||
|
||||
];
|
||||
/** @var array */
|
||||
private $filters = [InternalTransferFilter::class];
|
||||
|
||||
/** @var bool */
|
||||
/** @var bool */
|
||||
private $joinedBudget = false;
|
||||
/** @var bool */
|
||||
/** @var bool */
|
||||
private $joinedCategory = false;
|
||||
/** @var bool */
|
||||
private $joinedOpposing = false;
|
||||
/** @var bool */
|
||||
private $joinedTag = false;
|
||||
/** @var int */
|
||||
/** @var int */
|
||||
private $limit;
|
||||
/** @var int */
|
||||
/** @var int */
|
||||
private $offset;
|
||||
/** @var int */
|
||||
private $page = 1;
|
||||
@ -218,11 +214,12 @@ class JournalCollector implements JournalCollectorInterface
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*
|
||||
* @throws FireflyException
|
||||
*/
|
||||
public function count(): int
|
||||
{
|
||||
if ($this->run === true) {
|
||||
if (true === $this->run) {
|
||||
throw new FireflyException('Cannot count after run in JournalCollector.');
|
||||
}
|
||||
|
||||
@ -258,7 +255,7 @@ class JournalCollector implements JournalCollectorInterface
|
||||
$transaction->date = new Carbon($transaction->date);
|
||||
$transaction->description = Steam::decrypt(intval($transaction->encrypted), $transaction->description);
|
||||
|
||||
if (!is_null($transaction->bill_name)) {
|
||||
if (null !== $transaction->bill_name) {
|
||||
$transaction->bill_name = Steam::decrypt(intval($transaction->bill_name_encrypted), $transaction->bill_name);
|
||||
}
|
||||
$transaction->opposing_account_name = app('steam')->tryDecrypt($transaction->opposing_account_name);
|
||||
@ -272,11 +269,12 @@ class JournalCollector implements JournalCollectorInterface
|
||||
|
||||
/**
|
||||
* @return LengthAwarePaginator
|
||||
*
|
||||
* @throws FireflyException
|
||||
*/
|
||||
public function getPaginatedJournals(): LengthAwarePaginator
|
||||
{
|
||||
if ($this->run === true) {
|
||||
if (true === $this->run) {
|
||||
throw new FireflyException('Cannot getPaginatedJournals after run in JournalCollector.');
|
||||
}
|
||||
$this->count();
|
||||
@ -294,7 +292,7 @@ class JournalCollector implements JournalCollectorInterface
|
||||
public function removeFilter(string $filter): JournalCollectorInterface
|
||||
{
|
||||
$key = array_search($filter, $this->filters, true);
|
||||
if (!($key === false)) {
|
||||
if (!(false === $key)) {
|
||||
Log::debug(sprintf('Removed filter %s', $filter));
|
||||
unset($this->filters[$key]);
|
||||
}
|
||||
@ -320,7 +318,6 @@ class JournalCollector implements JournalCollectorInterface
|
||||
$this->addFilter(TransferFilter::class);
|
||||
}
|
||||
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
@ -416,7 +413,7 @@ class JournalCollector implements JournalCollectorInterface
|
||||
public function setBudgets(Collection $budgets): JournalCollectorInterface
|
||||
{
|
||||
$budgetIds = $budgets->pluck('id')->toArray();
|
||||
if (count($budgetIds) === 0) {
|
||||
if (0 === count($budgetIds)) {
|
||||
return $this;
|
||||
}
|
||||
$this->joinBudgetTables();
|
||||
@ -440,7 +437,7 @@ class JournalCollector implements JournalCollectorInterface
|
||||
public function setCategories(Collection $categories): JournalCollectorInterface
|
||||
{
|
||||
$categoryIds = $categories->pluck('id')->toArray();
|
||||
if (count($categoryIds) === 0) {
|
||||
if (0 === count($categoryIds)) {
|
||||
return $this;
|
||||
}
|
||||
$this->joinCategoryTables();
|
||||
@ -514,11 +511,11 @@ class JournalCollector implements JournalCollectorInterface
|
||||
$this->page = $page;
|
||||
|
||||
if ($page > 0) {
|
||||
$page--;
|
||||
--$page;
|
||||
}
|
||||
Log::debug(sprintf('Page is %d', $page));
|
||||
|
||||
if (!is_null($this->limit)) {
|
||||
if (null !== $this->limit) {
|
||||
$offset = ($this->limit * $page);
|
||||
$this->offset = $offset;
|
||||
$this->query->skip($offset);
|
||||
|
@ -18,7 +18,6 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Helpers\Collector;
|
||||
@ -32,9 +31,7 @@ use Illuminate\Pagination\LengthAwarePaginator;
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
/**
|
||||
* Interface JournalCollectorInterface
|
||||
*
|
||||
* @package FireflyIII\Helpers\Collector
|
||||
* Interface JournalCollectorInterface.
|
||||
*/
|
||||
interface JournalCollectorInterface
|
||||
{
|
||||
@ -43,28 +40,28 @@ interface JournalCollectorInterface
|
||||
*
|
||||
* @return JournalCollectorInterface
|
||||
*/
|
||||
public function addFilter(string $filter): JournalCollectorInterface;
|
||||
public function addFilter(string $filter): self;
|
||||
|
||||
/**
|
||||
* @param string $amount
|
||||
*
|
||||
* @return JournalCollectorInterface
|
||||
*/
|
||||
public function amountIs(string $amount): JournalCollectorInterface;
|
||||
public function amountIs(string $amount): self;
|
||||
|
||||
/**
|
||||
* @param string $amount
|
||||
*
|
||||
* @return JournalCollectorInterface
|
||||
*/
|
||||
public function amountLess(string $amount): JournalCollectorInterface;
|
||||
public function amountLess(string $amount): self;
|
||||
|
||||
/**
|
||||
* @param string $amount
|
||||
*
|
||||
* @return JournalCollectorInterface
|
||||
*/
|
||||
public function amountMore(string $amount): JournalCollectorInterface;
|
||||
public function amountMore(string $amount): self;
|
||||
|
||||
/**
|
||||
* @return int
|
||||
@ -86,89 +83,89 @@ interface JournalCollectorInterface
|
||||
*
|
||||
* @return JournalCollectorInterface
|
||||
*/
|
||||
public function removeFilter(string $filter): JournalCollectorInterface;
|
||||
public function removeFilter(string $filter): self;
|
||||
|
||||
/**
|
||||
* @param Collection $accounts
|
||||
*
|
||||
* @return JournalCollectorInterface
|
||||
*/
|
||||
public function setAccounts(Collection $accounts): JournalCollectorInterface;
|
||||
public function setAccounts(Collection $accounts): self;
|
||||
|
||||
/**
|
||||
* @param Carbon $after
|
||||
*
|
||||
* @return JournalCollectorInterface
|
||||
*/
|
||||
public function setAfter(Carbon $after): JournalCollectorInterface;
|
||||
public function setAfter(Carbon $after): self;
|
||||
|
||||
/**
|
||||
* @return JournalCollectorInterface
|
||||
*/
|
||||
public function setAllAssetAccounts(): JournalCollectorInterface;
|
||||
public function setAllAssetAccounts(): self;
|
||||
|
||||
/**
|
||||
* @param Carbon $before
|
||||
*
|
||||
* @return JournalCollectorInterface
|
||||
*/
|
||||
public function setBefore(Carbon $before): JournalCollectorInterface;
|
||||
public function setBefore(Carbon $before): self;
|
||||
|
||||
/**
|
||||
* @param Collection $bills
|
||||
*
|
||||
* @return JournalCollectorInterface
|
||||
*/
|
||||
public function setBills(Collection $bills): JournalCollectorInterface;
|
||||
public function setBills(Collection $bills): self;
|
||||
|
||||
/**
|
||||
* @param Budget $budget
|
||||
*
|
||||
* @return JournalCollectorInterface
|
||||
*/
|
||||
public function setBudget(Budget $budget): JournalCollectorInterface;
|
||||
public function setBudget(Budget $budget): self;
|
||||
|
||||
/**
|
||||
* @param Collection $budgets
|
||||
*
|
||||
* @return JournalCollectorInterface
|
||||
*/
|
||||
public function setBudgets(Collection $budgets): JournalCollectorInterface;
|
||||
public function setBudgets(Collection $budgets): self;
|
||||
|
||||
/**
|
||||
* @param Collection $categories
|
||||
*
|
||||
* @return JournalCollectorInterface
|
||||
*/
|
||||
public function setCategories(Collection $categories): JournalCollectorInterface;
|
||||
public function setCategories(Collection $categories): self;
|
||||
|
||||
/**
|
||||
* @param Category $category
|
||||
*
|
||||
* @return JournalCollectorInterface
|
||||
*/
|
||||
public function setCategory(Category $category): JournalCollectorInterface;
|
||||
public function setCategory(Category $category): self;
|
||||
|
||||
/**
|
||||
* @param int $limit
|
||||
*
|
||||
* @return JournalCollectorInterface
|
||||
*/
|
||||
public function setLimit(int $limit): JournalCollectorInterface;
|
||||
public function setLimit(int $limit): self;
|
||||
|
||||
/**
|
||||
* @param int $offset
|
||||
*
|
||||
* @return JournalCollectorInterface
|
||||
*/
|
||||
public function setOffset(int $offset): JournalCollectorInterface;
|
||||
public function setOffset(int $offset): self;
|
||||
|
||||
/**
|
||||
* @param int $page
|
||||
*
|
||||
* @return JournalCollectorInterface
|
||||
*/
|
||||
public function setPage(int $page): JournalCollectorInterface;
|
||||
public function setPage(int $page): self;
|
||||
|
||||
/**
|
||||
* @param Carbon $start
|
||||
@ -176,28 +173,28 @@ interface JournalCollectorInterface
|
||||
*
|
||||
* @return JournalCollectorInterface
|
||||
*/
|
||||
public function setRange(Carbon $start, Carbon $end): JournalCollectorInterface;
|
||||
public function setRange(Carbon $start, Carbon $end): self;
|
||||
|
||||
/**
|
||||
* @param Tag $tag
|
||||
*
|
||||
* @return JournalCollectorInterface
|
||||
*/
|
||||
public function setTag(Tag $tag): JournalCollectorInterface;
|
||||
public function setTag(Tag $tag): self;
|
||||
|
||||
/**
|
||||
* @param Collection $tags
|
||||
*
|
||||
* @return JournalCollectorInterface
|
||||
*/
|
||||
public function setTags(Collection $tags): JournalCollectorInterface;
|
||||
public function setTags(Collection $tags): self;
|
||||
|
||||
/**
|
||||
* @param array $types
|
||||
*
|
||||
* @return JournalCollectorInterface
|
||||
*/
|
||||
public function setTypes(array $types): JournalCollectorInterface;
|
||||
public function setTypes(array $types): self;
|
||||
|
||||
public function setUser(User $user);
|
||||
|
||||
@ -209,25 +206,25 @@ interface JournalCollectorInterface
|
||||
/**
|
||||
* @return JournalCollectorInterface
|
||||
*/
|
||||
public function withBudgetInformation(): JournalCollectorInterface;
|
||||
public function withBudgetInformation(): self;
|
||||
|
||||
/**
|
||||
* @return JournalCollectorInterface
|
||||
*/
|
||||
public function withCategoryInformation(): JournalCollectorInterface;
|
||||
public function withCategoryInformation(): self;
|
||||
|
||||
/**
|
||||
* @return JournalCollectorInterface
|
||||
*/
|
||||
public function withOpposingAccount(): JournalCollectorInterface;
|
||||
public function withOpposingAccount(): self;
|
||||
|
||||
/**
|
||||
* @return JournalCollectorInterface
|
||||
*/
|
||||
public function withoutBudget(): JournalCollectorInterface;
|
||||
public function withoutBudget(): self;
|
||||
|
||||
/**
|
||||
* @return JournalCollectorInterface
|
||||
*/
|
||||
public function withoutCategory(): JournalCollectorInterface;
|
||||
public function withoutCategory(): self;
|
||||
}
|
||||
|
@ -18,7 +18,6 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Helpers\Filter;
|
||||
@ -28,12 +27,10 @@ use Illuminate\Support\Collection;
|
||||
use Log;
|
||||
|
||||
/**
|
||||
* Class AmountFilter
|
||||
* Class AmountFilter.
|
||||
*
|
||||
* This filter removes transactions with either a positive amount ($parameters = 1) or a negative amount
|
||||
* ($parameter = -1). This is helpful when a Collection has you with both transactions in a journal.
|
||||
*
|
||||
* @package FireflyIII\Helpers\Filter
|
||||
*/
|
||||
class AmountFilter implements FilterInterface
|
||||
{
|
||||
|
@ -18,7 +18,6 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Helpers\Filter;
|
||||
@ -26,14 +25,10 @@ namespace FireflyIII\Helpers\Filter;
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
/**
|
||||
* Class EmptyFilter
|
||||
*
|
||||
* @package FireflyIII\Helpers\Filter
|
||||
* Class EmptyFilter.
|
||||
*/
|
||||
class EmptyFilter implements FilterInterface
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @param Collection $set
|
||||
*
|
||||
|
@ -18,7 +18,6 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Helpers\Filter;
|
||||
|
@ -18,7 +18,6 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Helpers\Filter;
|
||||
@ -28,13 +27,11 @@ use Illuminate\Support\Collection;
|
||||
use Log;
|
||||
|
||||
/**
|
||||
* Class InternalTransferFilter
|
||||
* Class InternalTransferFilter.
|
||||
*
|
||||
* This filter removes any filters that are from A to B or from B to A given a set of
|
||||
* account id's (in $parameters) where A and B are mentioned. So transfers between the mentioned
|
||||
* accounts will be removed.
|
||||
*
|
||||
* @package FireflyIII\Helpers\Filter
|
||||
*/
|
||||
class InternalTransferFilter implements FilterInterface
|
||||
{
|
||||
@ -60,7 +57,7 @@ class InternalTransferFilter implements FilterInterface
|
||||
{
|
||||
return $set->filter(
|
||||
function (Transaction $transaction) {
|
||||
if (is_null($transaction->opposing_account_id)) {
|
||||
if (null === $transaction->opposing_account_id) {
|
||||
return $transaction;
|
||||
}
|
||||
// both id's in $parameters?
|
||||
|
@ -18,7 +18,6 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Helpers\Filter;
|
||||
@ -28,11 +27,9 @@ use Illuminate\Support\Collection;
|
||||
use Log;
|
||||
|
||||
/**
|
||||
* Class NegativeAmountFilter
|
||||
* Class NegativeAmountFilter.
|
||||
*
|
||||
* This filter removes entries with a negative amount (the original modifier is -1).
|
||||
*
|
||||
* @package FireflyIII\Helpers\Filter
|
||||
*/
|
||||
class NegativeAmountFilter implements FilterInterface
|
||||
{
|
||||
|
@ -18,7 +18,6 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Helpers\Filter;
|
||||
@ -28,12 +27,10 @@ use Illuminate\Support\Collection;
|
||||
use Log;
|
||||
|
||||
/**
|
||||
* Class OpposingAccountFilter
|
||||
* Class OpposingAccountFilter.
|
||||
*
|
||||
* This filter is similar to the internal transfer filter but only removes transactions when the opposing account is
|
||||
* amongst $parameters (list of account ID's).
|
||||
*
|
||||
* @package FireflyIII\Helpers\Filter
|
||||
*/
|
||||
class OpposingAccountFilter implements FilterInterface
|
||||
{
|
||||
|
@ -18,7 +18,6 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Helpers\Filter;
|
||||
@ -28,14 +27,12 @@ use Illuminate\Support\Collection;
|
||||
use Log;
|
||||
|
||||
/**
|
||||
* Class PositiveAmountFilter
|
||||
* Class PositiveAmountFilter.
|
||||
*
|
||||
* This filter removes entries with a negative amount (the original modifier is -1).
|
||||
*
|
||||
* This filter removes transactions with either a positive amount ($parameters = 1) or a negative amount
|
||||
* ($parameter = -1). This is helpful when a Collection has you with both transactions in a journal.
|
||||
*
|
||||
* @package FireflyIII\Helpers\Filter
|
||||
*/
|
||||
class PositiveAmountFilter implements FilterInterface
|
||||
{
|
||||
@ -49,7 +46,7 @@ class PositiveAmountFilter implements FilterInterface
|
||||
return $set->filter(
|
||||
function (Transaction $transaction) {
|
||||
// remove by amount
|
||||
if (bccomp($transaction->transaction_amount, '0') === 1) {
|
||||
if (1 === bccomp($transaction->transaction_amount, '0')) {
|
||||
Log::debug(sprintf('Filtered #%d because amount is %f.', $transaction->id, $transaction->transaction_amount));
|
||||
|
||||
return null;
|
||||
|
@ -18,7 +18,6 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Helpers\Filter;
|
||||
@ -29,11 +28,9 @@ use Illuminate\Support\Collection;
|
||||
use Steam;
|
||||
|
||||
/**
|
||||
* Class TransferFilter
|
||||
* Class TransferFilter.
|
||||
*
|
||||
* This filter removes any transfers that are in the collection twice (from A to B and from B to A).
|
||||
*
|
||||
* @package FireflyIII\Helpers\Filter
|
||||
*/
|
||||
class TransferFilter implements FilterInterface
|
||||
{
|
||||
@ -48,7 +45,7 @@ class TransferFilter implements FilterInterface
|
||||
$new = new Collection;
|
||||
/** @var Transaction $transaction */
|
||||
foreach ($set as $transaction) {
|
||||
if ($transaction->transaction_type_type !== TransactionType::TRANSFER) {
|
||||
if (TransactionType::TRANSFER !== $transaction->transaction_type_type) {
|
||||
$new->push($transaction);
|
||||
continue;
|
||||
}
|
||||
|
@ -18,7 +18,6 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Helpers;
|
||||
@ -27,20 +26,15 @@ use Carbon\Carbon;
|
||||
use Preferences;
|
||||
|
||||
/**
|
||||
* Class FiscalHelper
|
||||
*
|
||||
* @package FireflyIII\Helpers
|
||||
* Class FiscalHelper.
|
||||
*/
|
||||
class FiscalHelper implements FiscalHelperInterface
|
||||
{
|
||||
|
||||
/** @var bool */
|
||||
protected $useCustomFiscalYear;
|
||||
|
||||
/**
|
||||
* FiscalHelper constructor.
|
||||
*
|
||||
*
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
@ -56,7 +50,7 @@ class FiscalHelper implements FiscalHelperInterface
|
||||
{
|
||||
// get start of fiscal year for passed date
|
||||
$endDate = $this->startOfFiscalYear($date);
|
||||
if ($this->useCustomFiscalYear === true) {
|
||||
if (true === $this->useCustomFiscalYear) {
|
||||
// add 1 year and sub 1 day
|
||||
$endDate->addYear();
|
||||
$endDate->subDay();
|
||||
@ -65,7 +59,6 @@ class FiscalHelper implements FiscalHelperInterface
|
||||
}
|
||||
$endDate->endOfYear();
|
||||
|
||||
|
||||
return $endDate;
|
||||
}
|
||||
|
||||
@ -78,7 +71,7 @@ class FiscalHelper implements FiscalHelperInterface
|
||||
{
|
||||
// get start mm-dd. Then create a start date in the year passed.
|
||||
$startDate = clone $date;
|
||||
if ($this->useCustomFiscalYear === true) {
|
||||
if (true === $this->useCustomFiscalYear) {
|
||||
$prefStartStr = Preferences::get('fiscalYearStart', '01-01')->data;
|
||||
list($mth, $day) = explode('-', $prefStartStr);
|
||||
$startDate->month(intval($mth))->day(intval($day));
|
||||
|
@ -18,7 +18,6 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Helpers;
|
||||
@ -26,13 +25,10 @@ namespace FireflyIII\Helpers;
|
||||
use Carbon\Carbon;
|
||||
|
||||
/**
|
||||
* Interface FiscalHelperInterface
|
||||
*
|
||||
* @package FireflyIII\Helpers
|
||||
* Interface FiscalHelperInterface.
|
||||
*/
|
||||
interface FiscalHelperInterface
|
||||
{
|
||||
|
||||
/**
|
||||
* This method produces a clone of the Carbon date object passed, checks preferences
|
||||
* and calculates the last day of the fiscal year.
|
||||
|
@ -18,7 +18,6 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Helpers\Help;
|
||||
@ -31,9 +30,7 @@ use Requests_Exception;
|
||||
use Route;
|
||||
|
||||
/**
|
||||
* Class Help
|
||||
*
|
||||
* @package FireflyIII\Helpers\Help
|
||||
* Class Help.
|
||||
*/
|
||||
class Help implements HelpInterface
|
||||
{
|
||||
@ -76,7 +73,7 @@ class Help implements HelpInterface
|
||||
|
||||
Log::debug(sprintf('Status code is %d', $result->status_code));
|
||||
|
||||
if ($result->status_code === 200) {
|
||||
if (200 === $result->status_code) {
|
||||
$content = trim($result->body);
|
||||
}
|
||||
|
||||
@ -90,7 +87,6 @@ class Help implements HelpInterface
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param string $route
|
||||
*
|
||||
* @return bool
|
||||
@ -121,11 +117,9 @@ class Help implements HelpInterface
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param string $route
|
||||
* @param string $language
|
||||
* @param string $content
|
||||
*
|
||||
*/
|
||||
public function putInCache(string $route, string $language, string $content)
|
||||
{
|
||||
|
@ -18,19 +18,15 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Helpers\Help;
|
||||
|
||||
/**
|
||||
* Interface HelpInterface
|
||||
*
|
||||
* @package FireflyIII\Helpers\Help
|
||||
* Interface HelpInterface.
|
||||
*/
|
||||
interface HelpInterface
|
||||
{
|
||||
|
||||
/**
|
||||
* @param string $route
|
||||
* @param string $language
|
||||
|
@ -18,7 +18,6 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Helpers\Report;
|
||||
@ -34,15 +33,13 @@ use Illuminate\Support\Collection;
|
||||
use Log;
|
||||
|
||||
/**
|
||||
* Class BalanceReportHelper
|
||||
* Class BalanceReportHelper.
|
||||
*
|
||||
* @SuppressWarnings(PHPMD.CouplingBetweenObjects) // I can't really help it.
|
||||
* @package FireflyIII\Helpers\Report
|
||||
*/
|
||||
class BalanceReportHelper implements BalanceReportHelperInterface
|
||||
{
|
||||
|
||||
/** @var BudgetRepositoryInterface */
|
||||
/** @var BudgetRepositoryInterface */
|
||||
protected $budgetRepository;
|
||||
|
||||
/**
|
||||
@ -56,7 +53,6 @@ class BalanceReportHelper implements BalanceReportHelperInterface
|
||||
$this->budgetRepository = $budgetRepository;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param Collection $accounts
|
||||
* @param Carbon $start
|
||||
@ -77,7 +73,7 @@ class BalanceReportHelper implements BalanceReportHelperInterface
|
||||
|
||||
/** @var BudgetLimit $budgetLimit */
|
||||
foreach ($budgetLimits as $budgetLimit) {
|
||||
if (!is_null($budgetLimit->budget)) {
|
||||
if (null !== $budgetLimit->budget) {
|
||||
$line = $this->createBalanceLine($budgetLimit, $accounts);
|
||||
$balance->addBalanceLine($line);
|
||||
}
|
||||
@ -96,7 +92,6 @@ class BalanceReportHelper implements BalanceReportHelperInterface
|
||||
return $balance;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param BudgetLimit $budgetLimit
|
||||
* @param Collection $accounts
|
||||
@ -126,7 +121,6 @@ class BalanceReportHelper implements BalanceReportHelperInterface
|
||||
return $line;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param Collection $accounts
|
||||
* @param Carbon $start
|
||||
@ -150,7 +144,6 @@ class BalanceReportHelper implements BalanceReportHelperInterface
|
||||
return $empty;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param Balance $balance
|
||||
* @SuppressWarnings(PHPMD.CyclomaticComplexity) // it's exactly 5.
|
||||
@ -162,7 +155,7 @@ class BalanceReportHelper implements BalanceReportHelperInterface
|
||||
$set = $balance->getBalanceLines();
|
||||
$newSet = new Collection;
|
||||
foreach ($set as $entry) {
|
||||
if (!is_null($entry->getBudget()->id)) {
|
||||
if (null !== $entry->getBudget()->id) {
|
||||
$sum = '0';
|
||||
foreach ($entry->getBalanceEntries() as $balanceEntry) {
|
||||
$sum = bcadd($sum, $balanceEntry->getSpent());
|
||||
|
@ -18,7 +18,6 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Helpers\Report;
|
||||
@ -28,9 +27,7 @@ use FireflyIII\Helpers\Collection\Balance;
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
/**
|
||||
* Interface BalanceReportHelperInterface
|
||||
*
|
||||
* @package FireflyIII\Helpers\Report
|
||||
* Interface BalanceReportHelperInterface.
|
||||
*/
|
||||
interface BalanceReportHelperInterface
|
||||
{
|
||||
|
@ -18,7 +18,6 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Helpers\Report;
|
||||
@ -30,9 +29,7 @@ use FireflyIII\Repositories\Budget\BudgetRepositoryInterface;
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
/**
|
||||
* Class BudgetReportHelper
|
||||
*
|
||||
* @package FireflyIII\Helpers\Report
|
||||
* Class BudgetReportHelper.
|
||||
*/
|
||||
class BudgetReportHelper implements BudgetReportHelperInterface
|
||||
{
|
||||
@ -52,6 +49,7 @@ class BudgetReportHelper implements BudgetReportHelperInterface
|
||||
/**
|
||||
* @SuppressWarnings(PHPMD.CyclomaticComplexity) // it's exactly 5.
|
||||
* @SuppressWarnings(PHPMD.ExcessiveMethodLength) // all the arrays make it long.
|
||||
*
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
* @param Collection $accounts
|
||||
@ -66,9 +64,8 @@ class BudgetReportHelper implements BudgetReportHelperInterface
|
||||
/** @var Budget $budget */
|
||||
foreach ($set as $budget) {
|
||||
$budgetLimits = $this->repository->getBudgetLimits($budget, $start, $end);
|
||||
if ($budgetLimits->count() === 0) { // no budget limit(s) for this budget
|
||||
|
||||
$spent = $this->repository->spentInPeriod(new Collection([$budget]), $accounts, $start, $end);// spent for budget in time range
|
||||
if (0 === $budgetLimits->count()) { // no budget limit(s) for this budget
|
||||
$spent = $this->repository->spentInPeriod(new Collection([$budget]), $accounts, $start, $end); // spent for budget in time range
|
||||
if (bccomp($spent, '0') === -1) {
|
||||
$line = [
|
||||
'type' => 'budget',
|
||||
@ -156,9 +153,9 @@ class BudgetReportHelper implements BudgetReportHelperInterface
|
||||
{
|
||||
$array = [];
|
||||
$expenses = $this->repository->spentInPeriod(new Collection([$budget]), $accounts, $budgetLimit->start_date, $budgetLimit->end_date);
|
||||
$array['left'] = bccomp(bcadd($budgetLimit->amount, $expenses), '0') === 1 ? bcadd($budgetLimit->amount, $expenses) : '0';
|
||||
$array['spent'] = bccomp(bcadd($budgetLimit->amount, $expenses), '0') === 1 ? $expenses : '0';
|
||||
$array['overspent'] = bccomp(bcadd($budgetLimit->amount, $expenses), '0') === 1 ? '0' : bcadd($expenses, $budgetLimit->amount);
|
||||
$array['left'] = 1 === bccomp(bcadd($budgetLimit->amount, $expenses), '0') ? bcadd($budgetLimit->amount, $expenses) : '0';
|
||||
$array['spent'] = 1 === bccomp(bcadd($budgetLimit->amount, $expenses), '0') ? $expenses : '0';
|
||||
$array['overspent'] = 1 === bccomp(bcadd($budgetLimit->amount, $expenses), '0') ? '0' : bcadd($expenses, $budgetLimit->amount);
|
||||
$array['expenses'] = $expenses;
|
||||
|
||||
return $array;
|
||||
|
@ -18,7 +18,6 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Helpers\Report;
|
||||
@ -27,13 +26,10 @@ use Carbon\Carbon;
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
/**
|
||||
* Interface BudgetReportHelperInterface
|
||||
*
|
||||
* @package FireflyIII\Helpers\Report
|
||||
* Interface BudgetReportHelperInterface.
|
||||
*/
|
||||
interface BudgetReportHelperInterface
|
||||
{
|
||||
|
||||
/**
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
|
@ -18,7 +18,6 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Helpers\Report;
|
||||
@ -32,14 +31,10 @@ use FireflyIII\Models\TransactionType;
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
/**
|
||||
* Class PopupReport
|
||||
*
|
||||
* @package FireflyIII\Helpers\Report
|
||||
* Class PopupReport.
|
||||
*/
|
||||
class PopupReport implements PopupReportInterface
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @param $account
|
||||
* @param $attributes
|
||||
@ -58,11 +53,10 @@ class PopupReport implements PopupReportInterface
|
||||
->withoutBudget();
|
||||
$journals = $collector->getJournals();
|
||||
|
||||
|
||||
return $journals->filter(
|
||||
function (Transaction $transaction) {
|
||||
$tags = $transaction->transactionJournal->tags()->where('tagMode', 'balancingAct')->count();
|
||||
if ($tags === 0) {
|
||||
if (0 === $tags) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -120,10 +114,10 @@ class PopupReport implements PopupReportInterface
|
||||
|
||||
$collector->setAccounts($attributes['accounts'])->setRange($attributes['startDate'], $attributes['endDate']);
|
||||
|
||||
if (is_null($budget->id)) {
|
||||
if (null === $budget->id) {
|
||||
$collector->setTypes([TransactionType::WITHDRAWAL])->withoutBudget();
|
||||
}
|
||||
if (!is_null($budget->id)) {
|
||||
if (null !== $budget->id) {
|
||||
$collector->setBudget($budget);
|
||||
}
|
||||
$journals = $collector->getJournals();
|
||||
|
@ -18,7 +18,6 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Helpers\Report;
|
||||
@ -29,13 +28,10 @@ use FireflyIII\Models\Category;
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
/**
|
||||
* Interface PopupReportInterface
|
||||
*
|
||||
* @package FireflyIII\Helpers\Report
|
||||
* Interface PopupReportInterface.
|
||||
*/
|
||||
interface PopupReportInterface
|
||||
{
|
||||
|
||||
/**
|
||||
* @param $account
|
||||
* @param $attributes
|
||||
|
@ -18,7 +18,6 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Helpers\Report;
|
||||
@ -35,14 +34,11 @@ use FireflyIII\Repositories\Budget\BudgetRepositoryInterface;
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
/**
|
||||
* Class ReportHelper
|
||||
*
|
||||
* @package FireflyIII\Helpers\Report
|
||||
* Class ReportHelper.
|
||||
*/
|
||||
class ReportHelper implements ReportHelperInterface
|
||||
{
|
||||
|
||||
/** @var BudgetRepositoryInterface */
|
||||
/** @var BudgetRepositoryInterface */
|
||||
protected $budgetRepository;
|
||||
|
||||
/**
|
||||
@ -95,7 +91,7 @@ class ReportHelper implements ReportHelperInterface
|
||||
}
|
||||
);
|
||||
$first = $entry->first();
|
||||
if (!is_null($first)) {
|
||||
if (null !== $first) {
|
||||
$billLine->setTransactionJournalId($first->id);
|
||||
$billLine->setAmount($first->transaction_amount);
|
||||
$billLine->setLastHitDate($first->date);
|
||||
|
@ -18,25 +18,19 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Helpers\Report;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use FireflyIII\Helpers\Collection\Bill as BillCollection;
|
||||
use FireflyIII\Helpers\Collection\Expense;
|
||||
use FireflyIII\Helpers\Collection\Income;
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
/**
|
||||
* Interface ReportHelperInterface
|
||||
*
|
||||
* @package FireflyIII\Helpers\Report
|
||||
* Interface ReportHelperInterface.
|
||||
*/
|
||||
interface ReportHelperInterface
|
||||
{
|
||||
|
||||
/**
|
||||
* This method generates a full report for the given period on all
|
||||
* the users bills and their payments.
|
||||
|
@ -18,7 +18,6 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Http\Controllers\Account;
|
||||
@ -37,9 +36,7 @@ use Response;
|
||||
use View;
|
||||
|
||||
/**
|
||||
* Class ReconcileController
|
||||
*
|
||||
* @package FireflyIII\Http\Controllers\Account
|
||||
* Class ReconcileController.
|
||||
*/
|
||||
class ReconcileController extends Controller
|
||||
{
|
||||
@ -94,14 +91,14 @@ class ReconcileController extends Controller
|
||||
*/
|
||||
public function reconcile(Account $account, Carbon $start = null, Carbon $end = null)
|
||||
{
|
||||
if ($account->accountType->type === AccountType::INITIAL_BALANCE) {
|
||||
if (AccountType::INITIAL_BALANCE === $account->accountType->type) {
|
||||
return $this->redirectToOriginalAccount($account);
|
||||
}
|
||||
/** @var CurrencyRepositoryInterface $currencyRepos */
|
||||
$currencyRepos = app(CurrencyRepositoryInterface::class);
|
||||
$currencyId = intval($account->getMeta('currency_id'));
|
||||
$currency = $currencyRepos->find($currencyId);
|
||||
if ($currencyId === 0) {
|
||||
if (0 === $currencyId) {
|
||||
$currency = app('amount')->getDefaultCurrency();
|
||||
}
|
||||
|
||||
@ -109,11 +106,11 @@ class ReconcileController extends Controller
|
||||
$range = Preferences::get('viewRange', '1M')->data;
|
||||
|
||||
// get start and end
|
||||
if (is_null($start) && is_null($end)) {
|
||||
if (null === $start && null === $end) {
|
||||
$start = clone session('start', Navigation::startOfPeriod(new Carbon, $range));
|
||||
$end = clone session('end', Navigation::endOfPeriod(new Carbon, $range));
|
||||
}
|
||||
if (is_null($end)) {
|
||||
if (null === $end) {
|
||||
$end = Navigation::endOfPeriod($start, $range);
|
||||
}
|
||||
|
||||
@ -158,7 +155,7 @@ class ReconcileController extends Controller
|
||||
*/
|
||||
public function transactions(Account $account, Carbon $start, Carbon $end)
|
||||
{
|
||||
if ($account->accountType->type === AccountType::INITIAL_BALANCE) {
|
||||
if (AccountType::INITIAL_BALANCE === $account->accountType->type) {
|
||||
return $this->redirectToOriginalAccount($account);
|
||||
}
|
||||
|
||||
@ -168,7 +165,6 @@ class ReconcileController extends Controller
|
||||
$selectionEnd = clone $end;
|
||||
$selectionEnd->addDays(3);
|
||||
|
||||
|
||||
// grab transactions:
|
||||
/** @var JournalCollectorInterface $collector */
|
||||
$collector = app(JournalCollectorInterface::class);
|
||||
|
@ -18,7 +18,6 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Http\Controllers;
|
||||
@ -45,9 +44,8 @@ use Steam;
|
||||
use View;
|
||||
|
||||
/**
|
||||
* Class AccountController
|
||||
* Class AccountController.
|
||||
*
|
||||
* @package FireflyIII\Http\Controllers
|
||||
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
|
||||
*/
|
||||
class AccountController extends Controller
|
||||
@ -90,12 +88,11 @@ class AccountController extends Controller
|
||||
$roles[$role] = strval(trans('firefly.account_role_' . $role));
|
||||
}
|
||||
|
||||
|
||||
// pre fill some data
|
||||
$request->session()->flash('preFilled', ['currency_id' => $defaultCurrency->id,]);
|
||||
$request->session()->flash('preFilled', ['currency_id' => $defaultCurrency->id]);
|
||||
|
||||
// put previous url in session if not redirect from store (not "create another").
|
||||
if (session('accounts.create.fromStore') !== true) {
|
||||
if (true !== session('accounts.create.fromStore')) {
|
||||
$this->rememberPreviousUri('accounts.create.uri');
|
||||
}
|
||||
$request->session()->forget('accounts.create.fromStore');
|
||||
@ -174,9 +171,8 @@ class AccountController extends Controller
|
||||
$roles[$role] = strval(trans('firefly.account_role_' . $role));
|
||||
}
|
||||
|
||||
|
||||
// put previous url in session if not redirect from store (not "return_to_edit").
|
||||
if (session('accounts.edit.fromUpdate') !== true) {
|
||||
if (true !== session('accounts.edit.fromUpdate')) {
|
||||
$this->rememberPreviousUri('accounts.edit.uri');
|
||||
}
|
||||
$request->session()->forget('accounts.edit.fromUpdate');
|
||||
@ -185,9 +181,9 @@ class AccountController extends Controller
|
||||
|
||||
// the opening balance is tricky:
|
||||
$openingBalanceAmount = $account->getOpeningBalanceAmount();
|
||||
$openingBalanceAmount = $account->getOpeningBalanceAmount() === '0' ? '' : $openingBalanceAmount;
|
||||
$openingBalanceAmount = '0' === $account->getOpeningBalanceAmount() ? '' : $openingBalanceAmount;
|
||||
$openingBalanceDate = $account->getOpeningBalanceDate();
|
||||
$openingBalanceDate = $openingBalanceDate->year === 1900 ? null : $openingBalanceDate->format('Y-m-d');
|
||||
$openingBalanceDate = 1900 === $openingBalanceDate->year ? null : $openingBalanceDate->format('Y-m-d');
|
||||
$currency = $repository->find(intval($account->getMeta('currency_id')));
|
||||
|
||||
$preFilled = [
|
||||
@ -200,7 +196,6 @@ class AccountController extends Controller
|
||||
'openingBalance' => $openingBalanceAmount,
|
||||
'virtualBalance' => $account->virtual_balance,
|
||||
'currency_id' => $currency->id,
|
||||
|
||||
];
|
||||
$request->session()->flash('preFilled', $preFilled);
|
||||
$request->session()->flash('gaEventCategory', 'accounts');
|
||||
@ -273,7 +268,7 @@ class AccountController extends Controller
|
||||
*/
|
||||
public function show(Request $request, JournalRepositoryInterface $repository, Account $account, string $moment = '')
|
||||
{
|
||||
if ($account->accountType->type === AccountType::INITIAL_BALANCE) {
|
||||
if (AccountType::INITIAL_BALANCE === $account->accountType->type) {
|
||||
return $this->redirectToOriginalAccount($account);
|
||||
}
|
||||
/** @var CurrencyRepositoryInterface $currencyRepos */
|
||||
@ -288,13 +283,12 @@ class AccountController extends Controller
|
||||
$periods = new Collection;
|
||||
$currencyId = intval($account->getMeta('currency_id'));
|
||||
$currency = $currencyRepos->find($currencyId);
|
||||
if ($currencyId === 0) {
|
||||
if (0 === $currencyId) {
|
||||
$currency = app('amount')->getDefaultCurrency();
|
||||
}
|
||||
|
||||
|
||||
// prep for "all" view.
|
||||
if ($moment === 'all') {
|
||||
if ('all' === $moment) {
|
||||
$subTitle = trans('firefly.all_journals_for_account', ['name' => $account->name]);
|
||||
$chartUri = route('chart.account.all', [$account->id]);
|
||||
$first = $repository->first();
|
||||
@ -303,7 +297,7 @@ class AccountController extends Controller
|
||||
}
|
||||
|
||||
// prep for "specific date" view.
|
||||
if (strlen($moment) > 0 && $moment !== 'all') {
|
||||
if (strlen($moment) > 0 && 'all' !== $moment) {
|
||||
$start = new Carbon($moment);
|
||||
$end = Navigation::endOfPeriod($start, $range);
|
||||
$fStart = $start->formatLocalized($this->monthAndDayFormat);
|
||||
@ -314,7 +308,7 @@ class AccountController extends Controller
|
||||
}
|
||||
|
||||
// prep for current period view
|
||||
if (strlen($moment) === 0) {
|
||||
if (0 === strlen($moment)) {
|
||||
$start = clone session('start', Navigation::startOfPeriod(new Carbon, $range));
|
||||
$end = clone session('end', Navigation::endOfPeriod(new Carbon, $range));
|
||||
$fStart = $start->formatLocalized($this->monthAndDayFormat);
|
||||
@ -326,7 +320,7 @@ class AccountController extends Controller
|
||||
// grab journals:
|
||||
$collector = app(JournalCollectorInterface::class);
|
||||
$collector->setAccounts(new Collection([$account]))->setLimit($pageSize)->setPage($page);
|
||||
if (!is_null($start)) {
|
||||
if (null !== $start) {
|
||||
$collector->setRange($start, $end);
|
||||
}
|
||||
$transactions = $collector->getPaginatedJournals();
|
||||
@ -343,7 +337,6 @@ class AccountController extends Controller
|
||||
* @param AccountRepositoryInterface $repository
|
||||
*
|
||||
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
|
||||
*
|
||||
*/
|
||||
public function store(AccountFormRequest $request, AccountRepositoryInterface $repository)
|
||||
{
|
||||
@ -354,12 +347,12 @@ class AccountController extends Controller
|
||||
|
||||
// update preferences if necessary:
|
||||
$frontPage = Preferences::get('frontPageAccounts', [])->data;
|
||||
if (count($frontPage) > 0 && $account->accountType->type === AccountType::ASSET) {
|
||||
if (count($frontPage) > 0 && AccountType::ASSET === $account->accountType->type) {
|
||||
$frontPage[] = $account->id;
|
||||
Preferences::set('frontPageAccounts', $frontPage);
|
||||
}
|
||||
|
||||
if (intval($request->get('create_another')) === 1) {
|
||||
if (1 === intval($request->get('create_another'))) {
|
||||
// set value so create routine will not overwrite URL:
|
||||
$request->session()->put('accounts.create.fromStore', true);
|
||||
|
||||
@ -385,7 +378,7 @@ class AccountController extends Controller
|
||||
$request->session()->flash('success', strval(trans('firefly.updated_account', ['name' => $account->name])));
|
||||
Preferences::mark();
|
||||
|
||||
if (intval($request->get('return_to_edit')) === 1) {
|
||||
if (1 === intval($request->get('return_to_edit'))) {
|
||||
// set value so edit routine will not overwrite URL:
|
||||
$request->session()->put('accounts.edit.fromUpdate', true);
|
||||
|
||||
@ -396,7 +389,6 @@ class AccountController extends Controller
|
||||
return redirect($this->getPreviousUri('accounts.edit.uri'));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param array $array
|
||||
* @param int $entryId
|
||||
@ -468,10 +460,10 @@ class AccountController extends Controller
|
||||
'name' => $dateName,
|
||||
'spent' => $spent,
|
||||
'earned' => $earned,
|
||||
'date' => clone $end]
|
||||
'date' => clone $end,]
|
||||
);
|
||||
$end = Navigation::subtractPeriod($end, $range, 1);
|
||||
$count++;
|
||||
++$count;
|
||||
}
|
||||
$cache->store($entries);
|
||||
|
||||
@ -482,13 +474,14 @@ class AccountController extends Controller
|
||||
* @param Account $account
|
||||
*
|
||||
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
|
||||
*
|
||||
* @throws FireflyException
|
||||
*/
|
||||
private function redirectToOriginalAccount(Account $account)
|
||||
{
|
||||
/** @var Transaction $transaction */
|
||||
$transaction = $account->transactions()->first();
|
||||
if (is_null($transaction)) {
|
||||
if (null === $transaction) {
|
||||
throw new FireflyException('Expected a transaction. This account has none. BEEP, error.');
|
||||
}
|
||||
|
||||
@ -496,7 +489,7 @@ class AccountController extends Controller
|
||||
/** @var Transaction $opposingTransaction */
|
||||
$opposingTransaction = $journal->transactions()->where('transactions.id', '!=', $transaction->id)->first();
|
||||
|
||||
if (is_null($opposingTransaction)) {
|
||||
if (null === $opposingTransaction) {
|
||||
throw new FireflyException('Expected an opposing transaction. This account has none. BEEP, error.'); // @codeCoverageIgnore
|
||||
}
|
||||
|
||||
|
@ -18,7 +18,6 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Http\Controllers\Admin;
|
||||
@ -32,9 +31,7 @@ use Session;
|
||||
use View;
|
||||
|
||||
/**
|
||||
* Class ConfigurationController
|
||||
*
|
||||
* @package FireflyIII\Http\Controllers\Admin
|
||||
* Class ConfigurationController.
|
||||
*/
|
||||
class ConfigurationController extends Controller
|
||||
{
|
||||
@ -45,7 +42,6 @@ class ConfigurationController extends Controller
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
|
||||
$this->middleware(
|
||||
function ($request, $next) {
|
||||
View::share('title', strval(trans('firefly.administration')));
|
||||
|
@ -18,7 +18,6 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Http\Controllers\Admin;
|
||||
@ -30,9 +29,7 @@ use Log;
|
||||
use Session;
|
||||
|
||||
/**
|
||||
* Class HomeController
|
||||
*
|
||||
* @package FireflyIII\Http\Controllers\Admin
|
||||
* Class HomeController.
|
||||
*/
|
||||
class HomeController extends Controller
|
||||
{
|
||||
|
@ -18,7 +18,6 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Http\Controllers\Admin;
|
||||
@ -32,9 +31,7 @@ use Preferences;
|
||||
use View;
|
||||
|
||||
/**
|
||||
* Class LinkController
|
||||
*
|
||||
* @package FireflyIII\Http\Controllers\Admin
|
||||
* Class LinkController.
|
||||
*/
|
||||
class LinkController extends Controller
|
||||
{
|
||||
@ -64,7 +61,7 @@ class LinkController extends Controller
|
||||
$subTitleIcon = 'fa-link';
|
||||
|
||||
// put previous url in session if not redirect from store (not "create another").
|
||||
if (session('link_types.create.fromStore') !== true) {
|
||||
if (true !== session('link_types.create.fromStore')) {
|
||||
$this->rememberPreviousUri('link_types.create.uri');
|
||||
}
|
||||
|
||||
@ -139,7 +136,7 @@ class LinkController extends Controller
|
||||
$subTitleIcon = 'fa-link';
|
||||
|
||||
// put previous url in session if not redirect from store (not "return_to_edit").
|
||||
if (session('link_types.edit.fromUpdate') !== true) {
|
||||
if (true !== session('link_types.edit.fromUpdate')) {
|
||||
$this->rememberPreviousUri('link_types.edit.uri');
|
||||
}
|
||||
$request->session()->forget('link_types.edit.fromUpdate');
|
||||
@ -196,7 +193,7 @@ class LinkController extends Controller
|
||||
$linkType = $repository->store($data);
|
||||
$request->session()->flash('success', strval(trans('firefly.stored_new_link_type', ['name' => $linkType->name])));
|
||||
|
||||
if (intval($request->get('create_another')) === 1) {
|
||||
if (1 === intval($request->get('create_another'))) {
|
||||
// set value so create routine will not overwrite URL:
|
||||
$request->session()->put('link_types.create.fromStore', true);
|
||||
|
||||
@ -225,7 +222,7 @@ class LinkController extends Controller
|
||||
$request->session()->flash('success', strval(trans('firefly.updated_link_type', ['name' => $linkType->name])));
|
||||
Preferences::mark();
|
||||
|
||||
if (intval($request->get('return_to_edit')) === 1) {
|
||||
if (1 === intval($request->get('return_to_edit'))) {
|
||||
// set value so edit routine will not overwrite URL:
|
||||
$request->session()->put('link_types.edit.fromUpdate', true);
|
||||
|
||||
|
@ -18,7 +18,6 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Http\Controllers\Admin;
|
||||
@ -33,9 +32,7 @@ use Session;
|
||||
use View;
|
||||
|
||||
/**
|
||||
* Class UserController
|
||||
*
|
||||
* @package FireflyIII\Http\Controllers\Admin
|
||||
* Class UserController.
|
||||
*/
|
||||
class UserController extends Controller
|
||||
{
|
||||
@ -46,7 +43,6 @@ class UserController extends Controller
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
|
||||
$this->middleware(
|
||||
function ($request, $next) {
|
||||
View::share('title', strval(trans('firefly.administration')));
|
||||
@ -91,7 +87,7 @@ class UserController extends Controller
|
||||
public function edit(User $user)
|
||||
{
|
||||
// put previous url in session if not redirect from store (not "return_to_edit").
|
||||
if (session('users.edit.fromUpdate') !== true) {
|
||||
if (true !== session('users.edit.fromUpdate')) {
|
||||
$this->rememberPreviousUri('users.edit.uri');
|
||||
}
|
||||
Session::forget('users.edit.fromUpdate');
|
||||
@ -125,14 +121,13 @@ class UserController extends Controller
|
||||
$list = ['twoFactorAuthEnabled', 'twoFactorAuthSecret'];
|
||||
$preferences = Preferences::getArrayForUser($user, $list);
|
||||
$user->isAdmin = $user->hasRole('owner');
|
||||
$is2faEnabled = $preferences['twoFactorAuthEnabled'] === true;
|
||||
$has2faSecret = !is_null($preferences['twoFactorAuthSecret']);
|
||||
$is2faEnabled = true === $preferences['twoFactorAuthEnabled'];
|
||||
$has2faSecret = null !== $preferences['twoFactorAuthSecret'];
|
||||
$user->has2FA = ($is2faEnabled && $has2faSecret) ? true : false;
|
||||
$user->prefs = $preferences;
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
return view('admin.users.index', compact('subTitle', 'subTitleIcon', 'users'));
|
||||
}
|
||||
|
||||
@ -166,7 +161,6 @@ class UserController extends Controller
|
||||
/**
|
||||
* @param UserFormRequest $request
|
||||
* @param User $user
|
||||
*
|
||||
* @param UserRepositoryInterface $repository
|
||||
*
|
||||
* @return $this|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
|
||||
@ -187,7 +181,7 @@ class UserController extends Controller
|
||||
Session::flash('success', strval(trans('firefly.updated_user', ['email' => $user->email])));
|
||||
Preferences::mark();
|
||||
|
||||
if (intval($request->get('return_to_edit')) === 1) {
|
||||
if (1 === intval($request->get('return_to_edit'))) {
|
||||
// @codeCoverageIgnoreStart
|
||||
Session::put('users.edit.fromUpdate', true);
|
||||
|
||||
|
@ -18,7 +18,6 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Http\Controllers;
|
||||
@ -35,15 +34,12 @@ use Response;
|
||||
use View;
|
||||
|
||||
/**
|
||||
* Class AttachmentController
|
||||
* Class AttachmentController.
|
||||
*
|
||||
* @SuppressWarnings(PHPMD.CouplingBetweenObjects) // it's 13.
|
||||
*
|
||||
* @package FireflyIII\Http\Controllers
|
||||
*/
|
||||
class AttachmentController extends Controller
|
||||
{
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@ -104,6 +100,7 @@ class AttachmentController extends Controller
|
||||
* @param Attachment $attachment
|
||||
*
|
||||
* @return mixed
|
||||
*
|
||||
* @throws FireflyException
|
||||
*/
|
||||
public function download(AttachmentRepositoryInterface $repository, Attachment $attachment)
|
||||
@ -112,7 +109,6 @@ class AttachmentController extends Controller
|
||||
$content = $repository->getContent($attachment);
|
||||
$quoted = sprintf('"%s"', addcslashes(basename($attachment->filename), '"\\'));
|
||||
|
||||
|
||||
/** @var LaravelResponse $response */
|
||||
$response = response($content, 200);
|
||||
$response
|
||||
@ -143,7 +139,7 @@ class AttachmentController extends Controller
|
||||
$subTitle = trans('firefly.edit_attachment', ['name' => $attachment->filename]);
|
||||
|
||||
// put previous url in session if not redirect from store (not "return_to_edit").
|
||||
if (session('attachments.edit.fromUpdate') !== true) {
|
||||
if (true !== session('attachments.edit.fromUpdate')) {
|
||||
$this->rememberPreviousUri('attachments.edit.uri');
|
||||
}
|
||||
$request->session()->forget('attachments.edit.fromUpdate');
|
||||
@ -160,8 +156,7 @@ class AttachmentController extends Controller
|
||||
{
|
||||
$image = 'images/page_green.png';
|
||||
|
||||
|
||||
if ($attachment->mime === 'application/pdf') {
|
||||
if ('application/pdf' === $attachment->mime) {
|
||||
$image = 'images/page_white_acrobat.png';
|
||||
}
|
||||
$file = public_path($image);
|
||||
@ -171,7 +166,6 @@ class AttachmentController extends Controller
|
||||
return $response;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param AttachmentFormRequest $request
|
||||
* @param AttachmentRepositoryInterface $repository
|
||||
@ -187,7 +181,7 @@ class AttachmentController extends Controller
|
||||
$request->session()->flash('success', strval(trans('firefly.attachment_updated', ['name' => $attachment->filename])));
|
||||
Preferences::mark();
|
||||
|
||||
if (intval($request->get('return_to_edit')) === 1) {
|
||||
if (1 === intval($request->get('return_to_edit'))) {
|
||||
// @codeCoverageIgnoreStart
|
||||
$request->session()->put('attachments.edit.fromUpdate', true);
|
||||
|
||||
|
@ -18,10 +18,8 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
|
||||
/**
|
||||
* ForgotPasswordController.php
|
||||
* Copyright (c) 2017 thegrumpydictator@gmail.com
|
||||
@ -53,7 +51,6 @@ class ForgotPasswordController extends Controller
|
||||
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
|
@ -18,10 +18,8 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
|
||||
/**
|
||||
* LoginController.php
|
||||
* Copyright (c) 2017 thegrumpydictator@gmail.com
|
||||
@ -66,7 +64,6 @@ class LoginController extends Controller
|
||||
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
@ -93,7 +90,7 @@ class LoginController extends Controller
|
||||
|
||||
// check for presence of currency:
|
||||
$currency = TransactionCurrency::where('code', 'EUR')->first();
|
||||
if (is_null($currency)) {
|
||||
if (null === $currency) {
|
||||
$message
|
||||
= 'Firefly III could not find the EURO currency. This is a strong indication the database has not been initialized correctly. Did you follow the installation instructions?';
|
||||
|
||||
@ -107,7 +104,7 @@ class LoginController extends Controller
|
||||
$singleUserMode = FireflyConfig::get('single_user_mode', config('firefly.configuration.single_user_mode'))->data;
|
||||
$userCount = User::count();
|
||||
$allowRegistration = true;
|
||||
if ($singleUserMode === true && $userCount > 0) {
|
||||
if (true === $singleUserMode && $userCount > 0) {
|
||||
$allowRegistration = false;
|
||||
}
|
||||
|
||||
|
@ -18,10 +18,8 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
|
||||
/**
|
||||
* RegisterController.php
|
||||
* Copyright (c) 2017 thegrumpydictator@gmail.com
|
||||
@ -66,7 +64,6 @@ class RegisterController extends Controller
|
||||
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
@ -77,7 +74,7 @@ class RegisterController extends Controller
|
||||
/**
|
||||
* Handle a registration request for the application.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Illuminate\Http\Request $request
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
@ -86,7 +83,7 @@ class RegisterController extends Controller
|
||||
// is allowed to?
|
||||
$singleUserMode = FireflyConfig::get('single_user_mode', config('firefly.configuration.single_user_mode'))->data;
|
||||
$userCount = User::count();
|
||||
if ($singleUserMode === true && $userCount > 0) {
|
||||
if (true === $singleUserMode && $userCount > 0) {
|
||||
$message = 'Registration is currently not available.';
|
||||
|
||||
return view('error', compact('message'));
|
||||
@ -119,7 +116,7 @@ class RegisterController extends Controller
|
||||
// is allowed to?
|
||||
$singleUserMode = FireflyConfig::get('single_user_mode', config('firefly.configuration.single_user_mode'))->data;
|
||||
$userCount = User::count();
|
||||
if ($singleUserMode === true && $userCount > 0) {
|
||||
if (true === $singleUserMode && $userCount > 0) {
|
||||
$message = 'Registration is currently not available.';
|
||||
|
||||
return view('error', compact('message'));
|
||||
@ -127,14 +124,13 @@ class RegisterController extends Controller
|
||||
|
||||
$email = $request->old('email');
|
||||
|
||||
|
||||
return view('auth.register', compact('isDemoSite', 'email'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new user instance after a valid registration.
|
||||
*
|
||||
* @param array $data
|
||||
* @param array $data
|
||||
*
|
||||
* @return \FireflyIII\User
|
||||
*/
|
||||
@ -151,7 +147,7 @@ class RegisterController extends Controller
|
||||
/**
|
||||
* Get a validator for an incoming registration request.
|
||||
*
|
||||
* @param array $data
|
||||
* @param array $data
|
||||
*
|
||||
* @return \Illuminate\Contracts\Validation\Validator
|
||||
*/
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user