Merge branch 'release/3.8.3'

This commit is contained in:
James Cole
2016-04-17 12:13:00 +02:00
356 changed files with 2267 additions and 1800 deletions

View File

@@ -1,7 +1,7 @@
APP_ENV=production APP_ENV=production
APP_DEBUG=false APP_DEBUG=false
APP_KEY=SomeRandomStringOf32CharsExactly APP_KEY=SomeRandomStringOf32CharsExactly
LOG_LEVEL=warning
DB_CONNECTION=mysql DB_CONNECTION=mysql
DB_HOST=localhost DB_HOST=localhost

View File

@@ -1,7 +1,7 @@
APP_ENV=testing APP_ENV=testing
APP_DEBUG=true APP_DEBUG=true
APP_KEY=SomeRandomStringOf32CharsExactly APP_KEY=SomeRandomStringOf32CharsExactly
LOG_LEVEL=debug
DB_CONNECTION=sqlite DB_CONNECTION=sqlite
DB_HOST=localhost DB_HOST=localhost

View File

@@ -4,6 +4,7 @@ php:
- 7 - 7
install: install:
- cp _development/phpunit.xml ./phpunit.xml
- phpenv config-rm xdebug.ini - phpenv config-rm xdebug.ini
- composer selfupdate - composer selfupdate
- rm composer.lock - rm composer.lock

View File

@@ -5,6 +5,20 @@ This project adheres to [Semantic Versioning](http://semver.org/).
## [Unreleased] ## [Unreleased]
- No unreleased changes yet. - No unreleased changes yet.
## [3.8.3] - 2016-04-17
### Added
- New audit report to see what happened.
### Changed
- New Chart JS release used.
- Help function is more reliable.
### Fixed
- Expected bill amount is now correct.
- Upgrade will now invalidate cache.
- Search was broken.
- Queries run better
## [3.8.2] - 2016-04-03 ## [3.8.2] - 2016-04-03
### Added ### Added
- Small user administration at /admin. - Small user administration at /admin.

View File

@@ -0,0 +1,43 @@
<?php
/**
* ConfigureLogging.php
* Copyright (C) 2016 thegrumpydictator@gmail.com
*
* This software may be modified and distributed under the terms
* of the MIT license. See the LICENSE file for details.
*/
namespace FireflyIII\Bootstrap;
use Illuminate\Log\Writer;
use Illuminate\Contracts\Foundation\Application;
use Illuminate\Foundation\Bootstrap\ConfigureLogging as IlluminateConfigureLogging;
/**
* Class ConfigureLogging
*
* @package FireflyIII\Bootstrap
*/
class ConfigureLogging extends IlluminateConfigureLogging
{
/**
* @param Application $app
* @param Writer $log
*/
protected function configureSingleHandler(Application $app, Writer $log)
{
$log->useFiles($app->storagePath().'/logs/firefly-iii.log');
}
/**
* @param Application $app
* @param Writer $log
*/
protected function configureDailyHandler(Application $app, Writer $log)
{
$log->useDailyFiles(
$app->storagePath().'/logs/firefly-iii.log',
$app->make('config')->get('app.log_max_files', 5)
);
}
}

View File

@@ -22,6 +22,25 @@ use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
*/ */
class Kernel extends ConsoleKernel class Kernel extends ConsoleKernel
{ {
/**
* The bootstrap classes for the application.
*
* This needs to be for with the next upgrade.
*
* @var array
*/
protected $bootstrappers = [
'Illuminate\Foundation\Bootstrap\DetectEnvironment',
'Illuminate\Foundation\Bootstrap\LoadConfiguration',
'FireflyIII\Bootstrap\ConfigureLogging',
'Illuminate\Foundation\Bootstrap\HandleExceptions',
'Illuminate\Foundation\Bootstrap\RegisterFacades',
'Illuminate\Foundation\Bootstrap\SetRequestForConsole',
'Illuminate\Foundation\Bootstrap\RegisterProviders',
'Illuminate\Foundation\Bootstrap\BootProviders',
];
/** /**
* The Artisan commands provided by your application. * The Artisan commands provided by your application.
* *

View File

@@ -12,11 +12,11 @@ namespace FireflyIII\Events;
use FireflyIII\Models\TransactionJournal; use FireflyIII\Models\TransactionJournal;
use Illuminate\Queue\SerializesModels; use Illuminate\Queue\SerializesModels;
use Log;
/** /**
* Class TransactionJournalStored * Class TransactionJournalStored
* *
* @codeCoverageIgnore
* @package FireflyIII\Events * @package FireflyIII\Events
*/ */
class TransactionJournalStored extends Event class TransactionJournalStored extends Event
@@ -35,6 +35,7 @@ class TransactionJournalStored extends Event
*/ */
public function __construct(TransactionJournal $journal, int $piggyBankId) public function __construct(TransactionJournal $journal, int $piggyBankId)
{ {
Log::debug('Created new TransactionJournalStored.');
// //
$this->journal = $journal; $this->journal = $journal;
$this->piggyBankId = $piggyBankId; $this->piggyBankId = $piggyBankId;

View File

@@ -5,11 +5,11 @@ namespace FireflyIII\Events;
use FireflyIII\Models\TransactionJournal; use FireflyIII\Models\TransactionJournal;
use Illuminate\Queue\SerializesModels; use Illuminate\Queue\SerializesModels;
use Log;
/** /**
* Class TransactionJournalUpdated * Class TransactionJournalUpdated
* *
* @codeCoverageIgnore
* @package FireflyIII\Events * @package FireflyIII\Events
*/ */
class TransactionJournalUpdated extends Event class TransactionJournalUpdated extends Event
@@ -26,6 +26,7 @@ class TransactionJournalUpdated extends Event
*/ */
public function __construct(TransactionJournal $journal) public function __construct(TransactionJournal $journal)
{ {
Log::debug('Created new TransactionJournalUpdated');
// //
$this->journal = $journal; $this->journal = $journal;
} }

View File

@@ -6,7 +6,6 @@ namespace FireflyIII\Exceptions;
/** /**
* Class FireflyException * Class FireflyException
* *
* @codeCoverageIgnore
* @package FireflyIII\Exceptions * @package FireflyIII\Exceptions
*/ */
class FireflyException extends \Exception class FireflyException extends \Exception

View File

@@ -6,7 +6,6 @@ namespace FireflyIII\Exceptions;
/** /**
* Class NotImplementedException * Class NotImplementedException
* *
* @codeCoverageIgnore
* @package FireflyIII\Exceptions * @package FireflyIII\Exceptions
*/ */
class NotImplementedException extends \Exception class NotImplementedException extends \Exception

View File

@@ -5,7 +5,6 @@ namespace FireflyIII\Exceptions;
/** /**
* Class ValidationExceptions * Class ValidationExceptions
* *
* @codeCoverageIgnore
* @package FireflyIII\Exception * @package FireflyIII\Exception
*/ */
class ValidationException extends \Exception class ValidationException extends \Exception

View File

@@ -53,9 +53,9 @@ class AttachmentCollector extends BasicCollector implements CollectorInterface
} }
/** /**
* * @return bool
*/ */
public function run() public function run(): bool
{ {
// grab all the users attachments: // grab all the users attachments:
$attachments = $this->getAttachments(); $attachments = $this->getAttachments();
@@ -70,6 +70,7 @@ class AttachmentCollector extends BasicCollector implements CollectorInterface
$this->exportDisk->put($file, $this->explanationString); $this->exportDisk->put($file, $this->explanationString);
Log::debug('Also put explanation file "' . $file . '" in the zip.'); Log::debug('Also put explanation file "' . $file . '" in the zip.');
$this->getFiles()->push($file); $this->getFiles()->push($file);
return true;
} }
/** /**

View File

@@ -40,7 +40,7 @@ class BasicCollector
/** /**
* @return Collection * @return Collection
*/ */
public function getFiles() public function getFiles(): Collection
{ {
return $this->files; return $this->files;
} }

View File

@@ -22,12 +22,12 @@ interface CollectorInterface
/** /**
* @return Collection * @return Collection
*/ */
public function getFiles(); public function getFiles(): Collection;
/** /**
* @return bool * @return bool
*/ */
public function run(); public function run(): bool;
/** /**
* @param Collection $files * @param Collection $files

View File

@@ -47,9 +47,9 @@ class UploadCollector extends BasicCollector implements CollectorInterface
} }
/** /**
* * @return bool
*/ */
public function run() public function run(): bool
{ {
// grab upload directory. // grab upload directory.
$files = $this->uploadDisk->files(); $files = $this->uploadDisk->files();
@@ -58,6 +58,7 @@ class UploadCollector extends BasicCollector implements CollectorInterface
foreach ($files as $entry) { foreach ($files as $entry) {
$this->processOldUpload($entry); $this->processOldUpload($entry);
} }
return true;
} }
/** /**

View File

@@ -38,9 +38,9 @@ class ConfigurationFile
} }
/** /**
* @return bool * @return string
*/ */
public function make() public function make(): string
{ {
$fields = array_keys(get_class_vars(Entry::class)); $fields = array_keys(get_class_vars(Entry::class));
$types = Entry::getTypes(); $types = Entry::getTypes();

View File

@@ -171,7 +171,7 @@ class Entry
/** /**
* @return int * @return int
*/ */
public function getBillId() public function getBillId(): int
{ {
return $this->billId; return $this->billId;
} }
@@ -179,7 +179,7 @@ class Entry
/** /**
* @param int $billId * @param int $billId
*/ */
public function setBillId($billId) public function setBillId(int $billId)
{ {
$this->billId = $billId; $this->billId = $billId;
} }
@@ -187,7 +187,7 @@ class Entry
/** /**
* @return string * @return string
*/ */
public function getBillName() public function getBillName(): string
{ {
return $this->billName; return $this->billName;
} }
@@ -195,7 +195,7 @@ class Entry
/** /**
* @param string $billName * @param string $billName
*/ */
public function setBillName($billName) public function setBillName(string $billName)
{ {
$this->billName = $billName; $this->billName = $billName;
} }
@@ -203,7 +203,7 @@ class Entry
/** /**
* @return int * @return int
*/ */
public function getBudgetId() public function getBudgetId(): int
{ {
return $this->budgetId; return $this->budgetId;
} }
@@ -211,7 +211,7 @@ class Entry
/** /**
* @param int $budgetId * @param int $budgetId
*/ */
public function setBudgetId($budgetId) public function setBudgetId(int $budgetId)
{ {
$this->budgetId = $budgetId; $this->budgetId = $budgetId;
} }
@@ -219,7 +219,7 @@ class Entry
/** /**
* @return string * @return string
*/ */
public function getBudgetName() public function getBudgetName(): string
{ {
return $this->budgetName; return $this->budgetName;
} }
@@ -227,7 +227,7 @@ class Entry
/** /**
* @param string $budgetName * @param string $budgetName
*/ */
public function setBudgetName($budgetName) public function setBudgetName(string $budgetName)
{ {
$this->budgetName = $budgetName; $this->budgetName = $budgetName;
} }
@@ -235,7 +235,7 @@ class Entry
/** /**
* @return int * @return int
*/ */
public function getCategoryId() public function getCategoryId(): int
{ {
return $this->categoryId; return $this->categoryId;
} }
@@ -243,7 +243,7 @@ class Entry
/** /**
* @param int $categoryId * @param int $categoryId
*/ */
public function setCategoryId($categoryId) public function setCategoryId(int $categoryId)
{ {
$this->categoryId = $categoryId; $this->categoryId = $categoryId;
} }
@@ -251,7 +251,7 @@ class Entry
/** /**
* @return string * @return string
*/ */
public function getCategoryName() public function getCategoryName(): string
{ {
return $this->categoryName; return $this->categoryName;
} }
@@ -259,7 +259,7 @@ class Entry
/** /**
* @param string $categoryName * @param string $categoryName
*/ */
public function setCategoryName($categoryName) public function setCategoryName(string $categoryName)
{ {
$this->categoryName = $categoryName; $this->categoryName = $categoryName;
} }
@@ -267,7 +267,7 @@ class Entry
/** /**
* @return string * @return string
*/ */
public function getDate() public function getDate(): string
{ {
return $this->date; return $this->date;
} }
@@ -283,7 +283,7 @@ class Entry
/** /**
* @return string * @return string
*/ */
public function getDescription() public function getDescription(): string
{ {
return $this->description; return $this->description;
} }
@@ -299,7 +299,7 @@ class Entry
/** /**
* @return string * @return string
*/ */
public function getFromAccountIban() public function getFromAccountIban(): string
{ {
return $this->fromAccountIban; return $this->fromAccountIban;
} }
@@ -307,7 +307,7 @@ class Entry
/** /**
* @param string $fromAccountIban * @param string $fromAccountIban
*/ */
public function setFromAccountIban($fromAccountIban) public function setFromAccountIban(string $fromAccountIban)
{ {
$this->fromAccountIban = $fromAccountIban; $this->fromAccountIban = $fromAccountIban;
} }
@@ -315,7 +315,7 @@ class Entry
/** /**
* @return int * @return int
*/ */
public function getFromAccountId() public function getFromAccountId():int
{ {
return $this->fromAccountId; return $this->fromAccountId;
} }
@@ -323,7 +323,7 @@ class Entry
/** /**
* @param int $fromAccountId * @param int $fromAccountId
*/ */
public function setFromAccountId($fromAccountId) public function setFromAccountId(int $fromAccountId)
{ {
$this->fromAccountId = $fromAccountId; $this->fromAccountId = $fromAccountId;
} }
@@ -331,7 +331,7 @@ class Entry
/** /**
* @return string * @return string
*/ */
public function getFromAccountName() public function getFromAccountName(): string
{ {
return $this->fromAccountName; return $this->fromAccountName;
} }
@@ -339,23 +339,23 @@ class Entry
/** /**
* @param string $fromAccountName * @param string $fromAccountName
*/ */
public function setFromAccountName($fromAccountName) public function setFromAccountName(string $fromAccountName)
{ {
$this->fromAccountName = $fromAccountName; $this->fromAccountName = $fromAccountName;
} }
/** /**
* @return mixed * @return string
*/ */
public function getFromAccountNumber() public function getFromAccountNumber(): string
{ {
return $this->fromAccountNumber; return $this->fromAccountNumber;
} }
/** /**
* @param mixed $fromAccountNumber * @param string $fromAccountNumber
*/ */
public function setFromAccountNumber($fromAccountNumber) public function setFromAccountNumber(string $fromAccountNumber)
{ {
$this->fromAccountNumber = $fromAccountNumber; $this->fromAccountNumber = $fromAccountNumber;
} }
@@ -363,7 +363,7 @@ class Entry
/** /**
* @return string * @return string
*/ */
public function getFromAccountType() public function getFromAccountType(): string
{ {
return $this->fromAccountType; return $this->fromAccountType;
} }
@@ -371,7 +371,7 @@ class Entry
/** /**
* @param string $fromAccountType * @param string $fromAccountType
*/ */
public function setFromAccountType($fromAccountType) public function setFromAccountType(string $fromAccountType)
{ {
$this->fromAccountType = $fromAccountType; $this->fromAccountType = $fromAccountType;
} }
@@ -379,7 +379,7 @@ class Entry
/** /**
* @return string * @return string
*/ */
public function getToAccountIban() public function getToAccountIban(): string
{ {
return $this->toAccountIban; return $this->toAccountIban;
} }
@@ -387,7 +387,7 @@ class Entry
/** /**
* @param string $toAccountIban * @param string $toAccountIban
*/ */
public function setToAccountIban($toAccountIban) public function setToAccountIban(string $toAccountIban)
{ {
$this->toAccountIban = $toAccountIban; $this->toAccountIban = $toAccountIban;
} }
@@ -395,7 +395,7 @@ class Entry
/** /**
* @return int * @return int
*/ */
public function getToAccountId() public function getToAccountId(): int
{ {
return $this->toAccountId; return $this->toAccountId;
} }
@@ -403,7 +403,7 @@ class Entry
/** /**
* @param int $toAccountId * @param int $toAccountId
*/ */
public function setToAccountId($toAccountId) public function setToAccountId(int $toAccountId)
{ {
$this->toAccountId = $toAccountId; $this->toAccountId = $toAccountId;
} }
@@ -411,7 +411,7 @@ class Entry
/** /**
* @return string * @return string
*/ */
public function getToAccountName() public function getToAccountName(): string
{ {
return $this->toAccountName; return $this->toAccountName;
} }
@@ -419,23 +419,23 @@ class Entry
/** /**
* @param string $toAccountName * @param string $toAccountName
*/ */
public function setToAccountName($toAccountName) public function setToAccountName(string $toAccountName)
{ {
$this->toAccountName = $toAccountName; $this->toAccountName = $toAccountName;
} }
/** /**
* @return mixed * @return string
*/ */
public function getToAccountNumber() public function getToAccountNumber(): string
{ {
return $this->toAccountNumber; return $this->toAccountNumber;
} }
/** /**
* @param mixed $toAccountNumber * @param string $toAccountNumber
*/ */
public function setToAccountNumber($toAccountNumber) public function setToAccountNumber(string $toAccountNumber)
{ {
$this->toAccountNumber = $toAccountNumber; $this->toAccountNumber = $toAccountNumber;
} }
@@ -443,7 +443,7 @@ class Entry
/** /**
* @return string * @return string
*/ */
public function getToAccountType() public function getToAccountType(): string
{ {
return $this->toAccountType; return $this->toAccountType;
} }
@@ -451,7 +451,7 @@ class Entry
/** /**
* @param string $toAccountType * @param string $toAccountType
*/ */
public function setToAccountType($toAccountType) public function setToAccountType(string $toAccountType)
{ {
$this->toAccountType = $toAccountType; $this->toAccountType = $toAccountType;
} }

View File

@@ -39,7 +39,7 @@ class BasicExporter
/** /**
* @return Collection * @return Collection
*/ */
public function getEntries() public function getEntries(): Collection
{ {
return $this->entries; return $this->entries;
} }

View File

@@ -39,15 +39,15 @@ class CsvExporter extends BasicExporter implements ExporterInterface
/** /**
* @return string * @return string
*/ */
public function getFileName() public function getFileName(): string
{ {
return $this->fileName; return $this->fileName;
} }
/** /**
* * @return bool
*/ */
public function run() public function run(): bool
{ {
// create temporary file: // create temporary file:
$this->tempFile(); $this->tempFile();
@@ -72,6 +72,7 @@ class CsvExporter extends BasicExporter implements ExporterInterface
} }
$writer->insertAll($rows); $writer->insertAll($rows);
return true;
} }
private function tempFile() private function tempFile()

View File

@@ -22,17 +22,17 @@ interface ExporterInterface
/** /**
* @return Collection * @return Collection
*/ */
public function getEntries(); public function getEntries(): Collection;
/** /**
* @return string * @return string
*/ */
public function getFileName(); public function getFileName(): string;
/** /**
* * @return bool
*/ */
public function run(); public function run(): bool;
/** /**
* @param Collection $entries * @param Collection $entries

View File

@@ -73,19 +73,20 @@ class Processor
} }
/** /**
* * @return bool
*/ */
public function collectAttachments() public function collectAttachments(): bool
{ {
$attachmentCollector = app('FireflyIII\Export\Collector\AttachmentCollector', [$this->job]); $attachmentCollector = app('FireflyIII\Export\Collector\AttachmentCollector', [$this->job]);
$attachmentCollector->run(); $attachmentCollector->run();
$this->files = $this->files->merge($attachmentCollector->getFiles()); $this->files = $this->files->merge($attachmentCollector->getFiles());
return true;
} }
/** /**
* * @return bool
*/ */
public function collectJournals() public function collectJournals(): bool
{ {
$args = [$this->accounts, Auth::user(), $this->settings['startDate'], $this->settings['endDate']]; $args = [$this->accounts, Auth::user(), $this->settings['startDate'], $this->settings['endDate']];
$journalCollector = app('FireflyIII\Repositories\Journal\JournalCollector', $args); $journalCollector = app('FireflyIII\Repositories\Journal\JournalCollector', $args);
@@ -97,20 +98,25 @@ class Processor
$this->settings['endDate']->format('Y-m-d') $this->settings['endDate']->format('Y-m-d')
. ').' . ').'
); );
return true;
} }
public function collectOldUploads() /**
* @return bool
*/
public function collectOldUploads(): bool
{ {
$uploadCollector = app('FireflyIII\Export\Collector\UploadCollector', [$this->job]); $uploadCollector = app('FireflyIII\Export\Collector\UploadCollector', [$this->job]);
$uploadCollector->run(); $uploadCollector->run();
$this->files = $this->files->merge($uploadCollector->getFiles()); $this->files = $this->files->merge($uploadCollector->getFiles());
return true;
} }
/** /**
* * @return bool
*/ */
public function convertJournals() public function convertJournals(): bool
{ {
$count = 0; $count = 0;
/** @var TransactionJournal $journal */ /** @var TransactionJournal $journal */
@@ -119,15 +125,24 @@ class Processor
$count++; $count++;
} }
Log::debug('Converted ' . $count . ' journals to "Entry" objects.'); Log::debug('Converted ' . $count . ' journals to "Entry" objects.');
return true;
} }
public function createConfigFile() /**
* @return bool
*/
public function createConfigFile(): bool
{ {
$this->configurationMaker = app('FireflyIII\Export\ConfigurationFile', [$this->job]); $this->configurationMaker = app('FireflyIII\Export\ConfigurationFile', [$this->job]);
$this->files->push($this->configurationMaker->make()); $this->files->push($this->configurationMaker->make());
return true;
} }
public function createZipFile() /**
* @return bool
* @throws FireflyException
*/
public function createZipFile(): bool
{ {
$zip = new ZipArchive; $zip = new ZipArchive;
$file = $this->job->key . '.zip'; $file = $this->job->key . '.zip';
@@ -156,12 +171,13 @@ class Processor
$disk->delete($file); $disk->delete($file);
} }
Log::debug('Done!'); Log::debug('Done!');
return true;
} }
/** /**
* * @return bool
*/ */
public function exportJournals() public function exportJournals(): bool
{ {
$exporterClass = Config::get('firefly.export_formats.' . $this->exportFormat); $exporterClass = Config::get('firefly.export_formats.' . $this->exportFormat);
$exporter = app($exporterClass, [$this->job]); $exporter = app($exporterClass, [$this->job]);
@@ -170,12 +186,13 @@ class Processor
$exporter->run(); $exporter->run();
$this->files->push($exporter->getFileName()); $this->files->push($exporter->getFileName());
Log::debug('Added "' . $exporter->getFileName() . '" to the list of files to include in the zip.'); Log::debug('Added "' . $exporter->getFileName() . '" to the list of files to include in the zip.');
return true;
} }
/** /**
* @return Collection * @return Collection
*/ */
public function getFiles() public function getFiles(): Collection
{ {
return $this->files; return $this->files;
} }

View File

@@ -31,18 +31,15 @@ class ChartJsBillChartGenerator implements BillChartGeneratorInterface
public function frontpage(string $paid, string $unpaid): array public function frontpage(string $paid, string $unpaid): array
{ {
$data = [ $data = [
[ 'datasets' => [
'value' => round($unpaid, 2), [
'color' => 'rgba(53, 124, 165,0.7)', 'data' => [round($unpaid, 2), round(bcmul($paid, '-1'), 2)],
'highlight' => 'rgba(53, 124, 165,0.9)', 'backgroundColor' => ['rgba(53, 124, 165,0.7)', 'rgba(0, 141, 76, 0.7)',],
'label' => trans('firefly.unpaid'), ],
],
[
'value' => round(bcmul($paid, '-1'), 2), // paid is negative, must be positive.
'color' => 'rgba(0, 141, 76, 0.7)',
'highlight' => 'rgba(0, 141, 76, 0.9)',
'label' => trans('firefly.paid'),
], ],
'labels' => [strval(trans('firefly.unpaid')), strval(trans('firefly.paid'))],
]; ];
return $data; return $data;
@@ -77,14 +74,17 @@ class ChartJsBillChartGenerator implements BillChartGeneratorInterface
} }
$data['datasets'][] = [ $data['datasets'][] = [
'type' => 'bar',
'label' => trans('firefly.minAmount'), 'label' => trans('firefly.minAmount'),
'data' => $minAmount, 'data' => $minAmount,
]; ];
$data['datasets'][] = [ $data['datasets'][] = [
'type' => 'line',
'label' => trans('firefly.billEntry'), 'label' => trans('firefly.billEntry'),
'data' => $actualAmount, 'data' => $actualAmount,
]; ];
$data['datasets'][] = [ $data['datasets'][] = [
'type' => 'bar',
'label' => trans('firefly.maxAmount'), 'label' => trans('firefly.maxAmount'),
'data' => $maxAmount, 'data' => $maxAmount,
]; ];

View File

@@ -50,7 +50,6 @@ class ChartJsBudgetChartGenerator implements BudgetChartGeneratorInterface
} }
/** /**
* @codeCoverageIgnore
* *
* @param Collection $entries * @param Collection $entries
* *

View File

@@ -25,7 +25,7 @@ interface CategoryChartGeneratorInterface
* *
* @return array * @return array
*/ */
public function all(Collection $entries); public function all(Collection $entries): array;
/** /**
* @param Collection $categories * @param Collection $categories

View File

@@ -148,7 +148,6 @@ class ChartJsCategoryChartGenerator implements CategoryChartGeneratorInterface
} }
/** /**
* @codeCoverageIgnore
* *
* @param Collection $entries * @param Collection $entries
* *

View File

@@ -89,7 +89,7 @@ class ChartJsReportChartGenerator implements ReportChartGeneratorInterface
'labels' => [], 'labels' => [],
'datasets' => [ 'datasets' => [
[ [
'label' => trans('firefly.net-worth'), 'label' => trans('firefly.net_worth'),
'data' => [], 'data' => [],
], ],
], ],

View File

@@ -36,6 +36,7 @@ class FireRulesForStore
*/ */
public function handle(TransactionJournalStored $event): bool public function handle(TransactionJournalStored $event): bool
{ {
Log::debug('Now running FireRulesForStore because TransactionJournalStored fired.');
// get all the user's rule groups, with the rules, order by 'order'. // get all the user's rule groups, with the rules, order by 'order'.
/** @var User $user */ /** @var User $user */
$user = Auth::user(); $user = Auth::user();

View File

@@ -34,6 +34,7 @@ class FireRulesForUpdate
*/ */
public function handle(TransactionJournalUpdated $event): bool public function handle(TransactionJournalUpdated $event): bool
{ {
Log::debug('Now running FireRulesForUpdate because TransactionJournalUpdated fired.');
// get all the user's rule groups, with the rules, order by 'order'. // get all the user's rule groups, with the rules, order by 'order'.
/** @var User $user */ /** @var User $user */
$user = Auth::user(); $user = Auth::user();

View File

@@ -16,7 +16,6 @@ use FireflyIII\Support\Events\BillScanner;
/** /**
* Class RescanJournal * Class RescanJournal
* *
* @codeCoverageIgnore
* @package FireflyIII\Handlers\Events * @package FireflyIII\Handlers\Events
*/ */
class ScanForBillsAfterStore class ScanForBillsAfterStore

View File

@@ -16,7 +16,6 @@ use FireflyIII\Support\Events\BillScanner;
/** /**
* Class RescanJournal * Class RescanJournal
* *
* @codeCoverageIgnore
* @package FireflyIII\Handlers\Events * @package FireflyIII\Handlers\Events
*/ */
class ScanForBillsAfterUpdate class ScanForBillsAfterUpdate

View File

@@ -38,13 +38,13 @@ class SendRegistrationMail
* *
* @param UserRegistration $event * @param UserRegistration $event
* *
* @return void * @return bool
*/ */
public function handle(UserRegistration $event) public function handle(UserRegistration $event): bool
{ {
$sendMail = env('SEND_REGISTRATION_MAIL', true); $sendMail = env('SEND_REGISTRATION_MAIL', true);
if (!$sendMail) { if (!$sendMail) {
return; return true;
} }
// get the email address // get the email address
$email = $event->user->email; $email = $event->user->email;
@@ -60,5 +60,6 @@ class SendRegistrationMail
} catch (Swift_TransportException $e) { } catch (Swift_TransportException $e) {
Log::error($e->getMessage()); Log::error($e->getMessage());
} }
return true;
} }
} }

View File

@@ -10,7 +10,6 @@ use FireflyIII\Models\TransactionJournal;
/** /**
* Class UpdateJournalConnection * Class UpdateJournalConnection
* *
* @codeCoverageIgnore
* @package FireflyIII\Handlers\Events * @package FireflyIII\Handlers\Events
*/ */
class UpdateJournalConnection class UpdateJournalConnection

View File

@@ -39,24 +39,30 @@ class UserConfirmation
/** /**
* @param ResendConfirmation $event * @param ResendConfirmation $event
*
* @return bool
*/ */
public function resendConfirmation(ResendConfirmation $event) public function resendConfirmation(ResendConfirmation $event): bool
{ {
$user = $event->user; $user = $event->user;
$ipAddress = $event->ipAddress; $ipAddress = $event->ipAddress;
$this->doConfirm($user, $ipAddress); $this->doConfirm($user, $ipAddress);
return true;
} }
/** /**
* Handle the event. * Handle the event.
* *
* @param UserRegistration $event * @param UserRegistration $event
*
* @return bool
*/ */
public function sendConfirmation(UserRegistration $event) public function sendConfirmation(UserRegistration $event): bool
{ {
$user = $event->user; $user = $event->user;
$ipAddress = $event->ipAddress; $ipAddress = $event->ipAddress;
$this->doConfirm($user, $ipAddress); $this->doConfirm($user, $ipAddress);
return true;
} }
/** /**

View File

@@ -21,8 +21,10 @@ class UserEventListener
{ {
/** /**
* Handle user logout events. * Handle user logout events.
*
* @return bool
*/ */
public function onUserLogout() public function onUserLogout(): bool
{ {
// dump stuff from the session: // dump stuff from the session:
Session::forget('twofactor-authenticated'); Session::forget('twofactor-authenticated');

View File

@@ -5,7 +5,6 @@ namespace FireflyIII\Helpers\Collection;
use Illuminate\Support\Collection; use Illuminate\Support\Collection;
/** /**
* @codeCoverageIgnore
* Class Account * Class Account
* *
* @package FireflyIII\Helpers\Collection * @package FireflyIII\Helpers\Collection

View File

@@ -5,7 +5,6 @@ namespace FireflyIII\Helpers\Collection;
use Illuminate\Support\Collection; use Illuminate\Support\Collection;
/** /**
* @codeCoverageIgnore
* *
* Class Balance * Class Balance
* *

View File

@@ -5,7 +5,6 @@ namespace FireflyIII\Helpers\Collection;
use FireflyIII\Models\Account as AccountModel; use FireflyIII\Models\Account as AccountModel;
/** /**
* @codeCoverageIgnore
* *
* Class BalanceEntry * Class BalanceEntry
* *

View File

@@ -6,7 +6,6 @@ use FireflyIII\Models\Account as AccountModel;
use Illuminate\Support\Collection; use Illuminate\Support\Collection;
/** /**
* @codeCoverageIgnore
* *
* Class BalanceHeader * Class BalanceHeader
* *

View File

@@ -6,7 +6,6 @@ use FireflyIII\Models\Budget as BudgetModel;
use Illuminate\Support\Collection; use Illuminate\Support\Collection;
/** /**
* @codeCoverageIgnore
* *
* Class BalanceLine * Class BalanceLine
* *

View File

@@ -6,7 +6,6 @@ namespace FireflyIII\Helpers\Collection;
use Illuminate\Support\Collection; use Illuminate\Support\Collection;
/** /**
* @codeCoverageIgnore
* Class Bill * Class Bill
* *
* @package FireflyIII\Helpers\Collection * @package FireflyIII\Helpers\Collection

View File

@@ -5,7 +5,6 @@ namespace FireflyIII\Helpers\Collection;
use FireflyIII\Models\Bill as BillModel; use FireflyIII\Models\Bill as BillModel;
/** /**
* @codeCoverageIgnore
* *
* Class BillLine * Class BillLine
* *
@@ -111,7 +110,7 @@ class BillLine
} }
/** /**
* @return boolean * @return bool
*/ */
public function isActive(): bool public function isActive(): bool
{ {
@@ -127,7 +126,7 @@ class BillLine
} }
/** /**
* @return boolean * @return bool
*/ */
public function isHit(): bool public function isHit(): bool
{ {

View File

@@ -5,7 +5,6 @@ namespace FireflyIII\Helpers\Collection;
use Illuminate\Support\Collection; use Illuminate\Support\Collection;
/** /**
* @codeCoverageIgnore
* *
* Class Budget * Class Budget
* *

View File

@@ -6,7 +6,6 @@ use FireflyIII\Models\Budget as BudgetModel;
use FireflyIII\Models\LimitRepetition; use FireflyIII\Models\LimitRepetition;
/** /**
* @codeCoverageIgnore
* *
* Class BudgetLine * Class BudgetLine
* *

View File

@@ -7,7 +7,6 @@ use Illuminate\Support\Collection;
/** /**
* @codeCoverageIgnore
* *
* Class Category * Class Category
* *

View File

@@ -8,7 +8,6 @@ use Illuminate\Support\Collection;
use stdClass; use stdClass;
/** /**
* @codeCoverageIgnore
* *
* Class Expense * Class Expense
* *

View File

@@ -8,7 +8,6 @@ use Illuminate\Support\Collection;
use stdClass; use stdClass;
/** /**
* @codeCoverageIgnore
* *
* Class Income * Class Income
* *

View File

@@ -15,7 +15,7 @@ class AmountComma extends BasicConverter implements ConverterInterface
/** /**
* @return float|int * @return float|int
*/ */
public function convert() public function convert(): string
{ {
$value = str_replace(',', '.', strval($this->value)); $value = str_replace(',', '.', strval($this->value));

View File

@@ -6,6 +6,7 @@ use Auth;
use Carbon\Carbon; use Carbon\Carbon;
use FireflyIII\Models\Account; use FireflyIII\Models\Account;
use FireflyIII\Repositories\Account\AccountRepositoryInterface; use FireflyIII\Repositories\Account\AccountRepositoryInterface;
use Log;
/** /**
* Class AssetAccountIban * Class AssetAccountIban
@@ -26,6 +27,7 @@ class AssetAccountIban extends BasicConverter implements ConverterInterface
// is mapped? Then it's easy! // is mapped? Then it's easy!
if (isset($this->mapped[$this->index][$this->value])) { if (isset($this->mapped[$this->index][$this->value])) {
$account = $repository->find($this->mapped[$this->index][$this->value]); $account = $repository->find($this->mapped[$this->index][$this->value]);
Log::debug('Found mapped account for value "' . $this->value . '". It is account #' . $account->id);
return $account; return $account;
} }
@@ -36,10 +38,14 @@ class AssetAccountIban extends BasicConverter implements ConverterInterface
/** @var Account $entry */ /** @var Account $entry */
foreach ($set as $entry) { foreach ($set as $entry) {
if ($entry->iban == $this->value) { if ($entry->iban == $this->value) {
Log::debug('Found an account with the same IBAN ("' . $this->value . '"). It is account #' . $entry->id);
return $entry; return $entry;
} }
} }
Log::debug('Found no account with the same IBAN ("' . $this->value . '"), so will create a new one.');
// create it if doesn't exist. // create it if doesn't exist.
$accountData = [ $accountData = [
'name' => $this->value, 'name' => $this->value,
@@ -48,13 +54,12 @@ class AssetAccountIban extends BasicConverter implements ConverterInterface
'virtualBalanceCurrency' => 1, // hard coded. 'virtualBalanceCurrency' => 1, // hard coded.
'active' => true, 'active' => true,
'user' => Auth::user()->id, 'user' => Auth::user()->id,
'iban' => null, 'iban' => $this->value,
'accountNumber' => $this->value, 'accountNumber' => $this->value,
'accountRole' => null, 'accountRole' => null,
'openingBalance' => 0, 'openingBalance' => 0,
'openingBalanceDate' => new Carbon, 'openingBalanceDate' => new Carbon,
'openingBalanceCurrency' => 1, // hard coded. 'openingBalanceCurrency' => 1, // hard coded.
]; ];
$account = $repository->store($accountData); $account = $repository->store($accountData);

View File

@@ -18,7 +18,7 @@ class AssetAccountName extends BasicConverter implements ConverterInterface
/** /**
* @return Account|null * @return Account|null
*/ */
public function convert() public function convert(): Account
{ {
/** @var AccountRepositoryInterface $repository */ /** @var AccountRepositoryInterface $repository */
$repository = app('FireflyIII\Repositories\Account\AccountRepositoryInterface'); $repository = app('FireflyIII\Repositories\Account\AccountRepositoryInterface');

View File

@@ -27,7 +27,7 @@ class AssetAccountNumber extends BasicConverter implements ConverterInterface
/** /**
* @return Account|null * @return Account|null
*/ */
public function convert() public function convert(): Account
{ {
/** @var AccountRepositoryInterface $repository */ /** @var AccountRepositoryInterface $repository */
$repository = app('FireflyIII\Repositories\Account\AccountRepositoryInterface'); $repository = app('FireflyIII\Repositories\Account\AccountRepositoryInterface');

View File

@@ -23,7 +23,7 @@ class BasicConverter
/** /**
* @return array * @return array
*/ */
public function getData() public function getData(): array
{ {
return $this->data; return $this->data;
} }
@@ -39,7 +39,7 @@ class BasicConverter
/** /**
* @return string * @return string
*/ */
public function getField() public function getField(): string
{ {
return $this->field; return $this->field;
} }
@@ -47,7 +47,7 @@ class BasicConverter
/** /**
* @param string $field * @param string $field
*/ */
public function setField($field) public function setField(string $field)
{ {
$this->field = $field; $this->field = $field;
} }
@@ -55,7 +55,7 @@ class BasicConverter
/** /**
* @return int * @return int
*/ */
public function getIndex() public function getIndex(): int
{ {
return $this->index; return $this->index;
} }
@@ -63,7 +63,7 @@ class BasicConverter
/** /**
* @param int $index * @param int $index
*/ */
public function setIndex($index) public function setIndex(int $index)
{ {
$this->index = $index; $this->index = $index;
} }
@@ -71,7 +71,7 @@ class BasicConverter
/** /**
* @return array * @return array
*/ */
public function getMapped() public function getMapped(): array
{ {
return $this->mapped; return $this->mapped;
} }
@@ -79,7 +79,7 @@ class BasicConverter
/** /**
* @param array $mapped * @param array $mapped
*/ */
public function setMapped($mapped) public function setMapped(array $mapped)
{ {
$this->mapped = $mapped; $this->mapped = $mapped;
} }
@@ -87,7 +87,7 @@ class BasicConverter
/** /**
* @return string * @return string
*/ */
public function getValue() public function getValue(): string
{ {
return $this->value; return $this->value;
} }
@@ -95,7 +95,7 @@ class BasicConverter
/** /**
* @param string $value * @param string $value
*/ */
public function setValue($value) public function setValue(string $value)
{ {
$this->value = $value; $this->value = $value;
} }

View File

@@ -16,7 +16,7 @@ class BillId extends BasicConverter implements ConverterInterface
/** /**
* @return Bill * @return Bill
*/ */
public function convert() public function convert(): Bill
{ {
/** @var BillRepositoryInterface $repository */ /** @var BillRepositoryInterface $repository */
$repository = app('FireflyIII\Repositories\Bill\BillRepositoryInterface'); $repository = app('FireflyIII\Repositories\Bill\BillRepositoryInterface');

View File

@@ -16,7 +16,7 @@ class BillName extends BasicConverter implements ConverterInterface
/** /**
* @return Bill * @return Bill
*/ */
public function convert() public function convert(): Bill
{ {
/** @var BillRepositoryInterface $repository */ /** @var BillRepositoryInterface $repository */
$repository = app('FireflyIII\Repositories\Bill\BillRepositoryInterface'); $repository = app('FireflyIII\Repositories\Bill\BillRepositoryInterface');

View File

@@ -16,7 +16,7 @@ class BudgetId extends BasicConverter implements ConverterInterface
/** /**
* @return Budget * @return Budget
*/ */
public function convert() public function convert(): Budget
{ {
/** @var BudgetRepositoryInterface $repository */ /** @var BudgetRepositoryInterface $repository */
$repository = app('FireflyIII\Repositories\Budget\BudgetRepositoryInterface'); $repository = app('FireflyIII\Repositories\Budget\BudgetRepositoryInterface');

View File

@@ -17,7 +17,7 @@ class BudgetName extends BasicConverter implements ConverterInterface
/** /**
* @return Budget * @return Budget
*/ */
public function convert() public function convert(): Budget
{ {
/** @var BudgetRepositoryInterface $repository */ /** @var BudgetRepositoryInterface $repository */
$repository = app('FireflyIII\Repositories\Budget\BudgetRepositoryInterface'); $repository = app('FireflyIII\Repositories\Budget\BudgetRepositoryInterface');

View File

@@ -16,7 +16,7 @@ class CategoryId extends BasicConverter implements ConverterInterface
/** /**
* @return Category * @return Category
*/ */
public function convert() public function convert(): Budget
{ {
/** @var SingleCategoryRepositoryInterface $repository */ /** @var SingleCategoryRepositoryInterface $repository */
$repository = app('FireflyIII\Repositories\Category\SingleCategoryRepositoryInterface'); $repository = app('FireflyIII\Repositories\Category\SingleCategoryRepositoryInterface');

View File

@@ -17,7 +17,7 @@ class CategoryName extends BasicConverter implements ConverterInterface
/** /**
* @return Category * @return Category
*/ */
public function convert() public function convert(): Budget
{ {
/** @var SingleCategoryRepositoryInterface $repository */ /** @var SingleCategoryRepositoryInterface $repository */
$repository = app('FireflyIII\Repositories\Category\SingleCategoryRepositoryInterface'); $repository = app('FireflyIII\Repositories\Category\SingleCategoryRepositoryInterface');

View File

@@ -24,21 +24,21 @@ interface ConverterInterface
* @param string $field * @param string $field
* *
*/ */
public function setField($field); public function setField(string $field);
/** /**
* @param int $index * @param int $index
*/ */
public function setIndex($index); public function setIndex(int $index);
/** /**
* @param array $mapped * @param array $mapped
*/ */
public function setMapped($mapped); public function setMapped(array $mapped);
/** /**
* @param string $value * @param string $value
*/ */
public function setValue($value); public function setValue(string $value);
} }

View File

@@ -16,7 +16,7 @@ class CurrencyCode extends BasicConverter implements ConverterInterface
/** /**
* @return TransactionCurrency * @return TransactionCurrency
*/ */
public function convert() public function convert(): TransactionCurrency
{ {
/** @var CurrencyRepositoryInterface $repository */ /** @var CurrencyRepositoryInterface $repository */
$repository = app('FireflyIII\Repositories\Currency\CurrencyRepositoryInterface'); $repository = app('FireflyIII\Repositories\Currency\CurrencyRepositoryInterface');

View File

@@ -16,7 +16,7 @@ class CurrencyId extends BasicConverter implements ConverterInterface
/** /**
* @return TransactionCurrency * @return TransactionCurrency
*/ */
public function convert() public function convert(): TransactionCurrency
{ {
/** @var CurrencyRepositoryInterface $repository */ /** @var CurrencyRepositoryInterface $repository */
$repository = app('FireflyIII\Repositories\Currency\CurrencyRepositoryInterface'); $repository = app('FireflyIII\Repositories\Currency\CurrencyRepositoryInterface');

View File

@@ -16,7 +16,7 @@ class CurrencyName extends BasicConverter implements ConverterInterface
/** /**
* @return TransactionCurrency * @return TransactionCurrency
*/ */
public function convert() public function convert(): TransactionCurrency
{ {
/** @var CurrencyRepositoryInterface $repository */ /** @var CurrencyRepositoryInterface $repository */
$repository = app('FireflyIII\Repositories\Currency\CurrencyRepositoryInterface'); $repository = app('FireflyIII\Repositories\Currency\CurrencyRepositoryInterface');

View File

@@ -16,7 +16,7 @@ class CurrencySymbol extends BasicConverter implements ConverterInterface
/** /**
* @return TransactionCurrency * @return TransactionCurrency
*/ */
public function convert() public function convert(): TransactionCurrency
{ {
/** @var CurrencyRepositoryInterface $repository */ /** @var CurrencyRepositoryInterface $repository */
$repository = app('FireflyIII\Repositories\Currency\CurrencyRepositoryInterface'); $repository = app('FireflyIII\Repositories\Currency\CurrencyRepositoryInterface');

View File

@@ -19,7 +19,7 @@ class Date extends BasicConverter implements ConverterInterface
* @return Carbon * @return Carbon
* @throws FireflyException * @throws FireflyException
*/ */
public function convert() public function convert(): Carbon
{ {
$format = session('csv-date-format'); $format = session('csv-date-format');
try { try {

View File

@@ -14,7 +14,7 @@ class Description extends BasicConverter implements ConverterInterface
/** /**
* @return string * @return string
*/ */
public function convert() public function convert(): string
{ {
$description = $this->data['description'] ?? ''; $description = $this->data['description'] ?? '';

View File

@@ -24,7 +24,7 @@ class INGDebetCredit extends BasicConverter implements ConverterInterface
/** /**
* @return int * @return int
*/ */
public function convert() public function convert(): int
{ {
if ($this->value === 'Af') { if ($this->value === 'Af') {
return -1; return -1;

View File

@@ -17,7 +17,7 @@ class OpposingAccountId extends BasicConverter implements ConverterInterface
/** /**
* @return Account * @return Account
*/ */
public function convert() public function convert(): Account
{ {
/** @var AccountRepositoryInterface $repository */ /** @var AccountRepositoryInterface $repository */
$repository = app('FireflyIII\Repositories\Account\AccountRepositoryInterface'); $repository = app('FireflyIII\Repositories\Account\AccountRepositoryInterface');

View File

@@ -15,7 +15,7 @@ class RabobankDebetCredit extends BasicConverter implements ConverterInterface
/** /**
* @return int * @return int
*/ */
public function convert() public function convert(): int
{ {
if ($this->value == 'D') { if ($this->value == 'D') {
return -1; return -1;

View File

@@ -16,7 +16,7 @@ class TagsComma extends BasicConverter implements ConverterInterface
/** /**
* @return Collection * @return Collection
*/ */
public function convert() public function convert(): Collection
{ {
/** @var TagRepositoryInterface $repository */ /** @var TagRepositoryInterface $repository */
$repository = app('FireflyIII\Repositories\Tag\TagRepositoryInterface'); $repository = app('FireflyIII\Repositories\Tag\TagRepositoryInterface');

View File

@@ -16,7 +16,7 @@ class TagsSpace extends BasicConverter implements ConverterInterface
/** /**
* @return Collection * @return Collection
*/ */
public function convert() public function convert(): Collection
{ {
/** @var TagRepositoryInterface $repository */ /** @var TagRepositoryInterface $repository */
$repository = app('FireflyIII\Repositories\Tag\TagRepositoryInterface'); $repository = app('FireflyIII\Repositories\Tag\TagRepositoryInterface');

View File

@@ -57,7 +57,7 @@ class Data
* *
* @return string * @return string
*/ */
public function getCsvFileContent() public function getCsvFileContent(): string
{ {
return $this->csvFileContent ?? ''; return $this->csvFileContent ?? '';
} }
@@ -72,10 +72,10 @@ class Data
} }
/** /**
* * FIXME may return null
* @return string * @return string
*/ */
public function getCsvFileLocation() public function getCsvFileLocation(): string
{ {
return $this->csvFileLocation; return $this->csvFileLocation;
} }
@@ -91,10 +91,10 @@ class Data
} }
/** /**
* * FIXME may return null
* @return string * @return string
*/ */
public function getDateFormat() public function getDateFormat(): string
{ {
return $this->dateFormat; return $this->dateFormat;
} }
@@ -110,10 +110,10 @@ class Data
} }
/** /**
* * FIXME may return null
* @return string * @return string
*/ */
public function getDelimiter() public function getDelimiter(): string
{ {
return $this->delimiter; return $this->delimiter;
} }
@@ -132,7 +132,7 @@ class Data
* *
* @return array * @return array
*/ */
public function getMap() public function getMap(): array
{ {
return $this->map; return $this->map;
} }
@@ -151,7 +151,7 @@ class Data
* *
* @return array * @return array
*/ */
public function getMapped() public function getMapped(): array
{ {
return $this->mapped; return $this->mapped;
} }
@@ -170,7 +170,7 @@ class Data
* *
* @return Reader * @return Reader
*/ */
public function getReader() public function getReader(): Reader
{ {
if (!is_null($this->csvFileContent) && strlen($this->csvFileContent) === 0) { if (!is_null($this->csvFileContent) && strlen($this->csvFileContent) === 0) {
$this->loadCsvFile(); $this->loadCsvFile();
@@ -188,7 +188,7 @@ class Data
* *
* @return array * @return array
*/ */
public function getRoles() public function getRoles(): array
{ {
return $this->roles; return $this->roles;
} }
@@ -207,7 +207,7 @@ class Data
* *
* @return array * @return array
*/ */
public function getSpecifix() public function getSpecifix(): array
{ {
return is_array($this->specifix) ? $this->specifix : []; return is_array($this->specifix) ? $this->specifix : [];
} }
@@ -226,7 +226,7 @@ class Data
* *
* @return bool * @return bool
*/ */
public function hasHeaders() public function hasHeaders(): bool
{ {
return $this->hasHeaders; return $this->hasHeaders;
} }

View File

@@ -4,19 +4,15 @@ namespace FireflyIII\Helpers\Csv;
use Auth; use Auth;
use Config; use Config;
use FireflyIII\Events\TransactionJournalStored;
use FireflyIII\Exceptions\FireflyException; use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Helpers\Csv\Converter\ConverterInterface; use FireflyIII\Helpers\Csv\Converter\ConverterInterface;
use FireflyIII\Helpers\Csv\PostProcessing\PostProcessorInterface; use FireflyIII\Helpers\Csv\PostProcessing\PostProcessorInterface;
use FireflyIII\Helpers\Csv\Specifix\SpecifixInterface; use FireflyIII\Helpers\Csv\Specifix\SpecifixInterface;
use FireflyIII\Models\Account; use FireflyIII\Models\Account;
use FireflyIII\Models\Rule;
use FireflyIII\Models\RuleGroup;
use FireflyIII\Models\Transaction; use FireflyIII\Models\Transaction;
use FireflyIII\Models\TransactionJournal; use FireflyIII\Models\TransactionJournal;
use FireflyIII\Models\TransactionType; use FireflyIII\Models\TransactionType;
use FireflyIII\Rules\Processor;
use FireflyIII\User;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Support\Collection; use Illuminate\Support\Collection;
use Illuminate\Support\MessageBag; use Illuminate\Support\MessageBag;
use Log; use Log;
@@ -57,7 +53,7 @@ class Importer
* *
* @return array * @return array
*/ */
public function getErrors() public function getErrors(): array
{ {
return $this->errors; return $this->errors;
} }
@@ -67,7 +63,7 @@ class Importer
* *
* @return int * @return int
*/ */
public function getImported() public function getImported(): int
{ {
return $this->imported; return $this->imported;
} }
@@ -75,7 +71,7 @@ class Importer
/** /**
* @return Collection * @return Collection
*/ */
public function getJournals() public function getJournals(): Collection
{ {
return $this->journals; return $this->journals;
} }
@@ -85,7 +81,7 @@ class Importer
* *
* @return int * @return int
*/ */
public function getRows() public function getRows(): int
{ {
return $this->rows; return $this->rows;
} }
@@ -93,7 +89,7 @@ class Importer
/** /**
* @return array * @return array
*/ */
public function getSpecifix() public function getSpecifix(): array
{ {
return is_array($this->specifix) ? $this->specifix : []; return is_array($this->specifix) ? $this->specifix : [];
} }
@@ -120,19 +116,13 @@ class Importer
Log::error('Caught error at row #' . $index . ': ' . $result); Log::error('Caught error at row #' . $index . ': ' . $result);
$this->errors[$index] = $result; $this->errors[$index] = $result;
} else { } else {
$this->imported++; $this->imported++;
$this->journals->push($result); $this->journals->push($result);
event(new TransactionJournalStored($result, 0));
} }
Log::debug('---'); Log::debug('---');
} }
} }
// once all journals have been imported (or not)
// fire the rules.
$this->fireRules();
} }
/** /**
@@ -144,7 +134,6 @@ class Importer
} }
/** /**
*
* @return TransactionJournal|string * @return TransactionJournal|string
*/ */
protected function createTransactionJournal() protected function createTransactionJournal()
@@ -361,55 +350,6 @@ class Importer
return true; return true;
} }
/**
* @param Collection $groups
* @param TransactionJournal $journal
*/
private function fireRule(Collection $groups, TransactionJournal $journal)
{
/** @var RuleGroup $group */
foreach ($groups as $group) {
/** @var Rule $rule */
foreach ($group->rules as $rule) {
$processor = Processor::make($rule);
$processor->handleTransactionJournal($journal);
if ($rule->stop_processing) {
break;
}
}
}
}
private function fireRules()
{
// get all users rules.
/** @var User $user */
$user = Auth::user();
$groups = $user
->ruleGroups()
->where('rule_groups.active', 1)
->orderBy('order', 'ASC')
->with(
[
'rules' => function (HasMany $q) {
$q->leftJoin('rule_triggers', 'rules.id', '=', 'rule_triggers.rule_id')
->where('rule_triggers.trigger_type', 'user_action')
->where('rule_triggers.trigger_value', 'store-journal')
->where('rules.active', 1)
->orderBy('rules.order', 'ASC');
},
]
)
->get();
/** @var TransactionJournal $journal */
foreach ($this->journals as $journal) {
$this->fireRule($groups, $journal);
}
}
/** /**
* @return array * @return array
*/ */

View File

@@ -16,7 +16,7 @@ class AnyAccount implements MapperInterface
/** /**
* @return array * @return array
*/ */
public function getMap() public function getMap(): array
{ {
$result = Auth::user()->accounts()->with('accountType')->orderBy('accounts.name', 'ASC')->get(['accounts.*']); $result = Auth::user()->accounts()->with('accountType')->orderBy('accounts.name', 'ASC')->get(['accounts.*']);

View File

@@ -17,7 +17,7 @@ class AssetAccount implements MapperInterface
/** /**
* @return array * @return array
*/ */
public function getMap() public function getMap(): array
{ {
$result = Auth::user()->accounts()->with( $result = Auth::user()->accounts()->with(
['accountmeta' => function (HasMany $query) { ['accountmeta' => function (HasMany $query) {

View File

@@ -16,7 +16,7 @@ class Bill implements MapperInterface
/** /**
* @return array * @return array
*/ */
public function getMap() public function getMap(): array
{ {
$result = Auth::user()->bills()->get(['bills.*']); $result = Auth::user()->bills()->get(['bills.*']);
$list = []; $list = [];

View File

@@ -16,7 +16,7 @@ class Budget implements MapperInterface
/** /**
* @return array * @return array
*/ */
public function getMap() public function getMap(): array
{ {
$result = Auth::user()->budgets()->get(['budgets.*']); $result = Auth::user()->budgets()->get(['budgets.*']);
$list = []; $list = [];

View File

@@ -16,7 +16,7 @@ class Category implements MapperInterface
/** /**
* @return array * @return array
*/ */
public function getMap() public function getMap(): array
{ {
$result = Auth::user()->categories()->get(['categories.*']); $result = Auth::user()->categories()->get(['categories.*']);
$list = []; $list = [];

View File

@@ -12,5 +12,5 @@ interface MapperInterface
/** /**
* @return array * @return array
*/ */
public function getMap(); public function getMap(): array;
} }

View File

@@ -16,7 +16,7 @@ class Tag implements MapperInterface
/** /**
* @return array * @return array
*/ */
public function getMap() public function getMap(): array
{ {
$result = Auth::user()->budgets()->get(['tags.*']); $result = Auth::user()->budgets()->get(['tags.*']);
$list = []; $list = [];

View File

@@ -15,7 +15,7 @@ class TransactionCurrency implements MapperInterface
/** /**
* @return array * @return array
*/ */
public function getMap() public function getMap(): array
{ {
$currencies = TC::get(); $currencies = TC::get();
$list = []; $list = [];

View File

@@ -17,7 +17,7 @@ class Amount implements PostProcessorInterface
/** /**
* @return array * @return array
*/ */
public function process() public function process(): array
{ {
$amount = $this->data['amount'] ?? '0'; $amount = $this->data['amount'] ?? '0';
$modifier = strval($this->data['amount-modifier']); $modifier = strval($this->data['amount-modifier']);

View File

@@ -23,7 +23,7 @@ class AssetAccount implements PostProcessorInterface
/** /**
* @return array * @return array
*/ */
public function process() public function process(): array
{ {
$result = $this->checkIdNameObject(); // has object in ID or Name? $result = $this->checkIdNameObject(); // has object in ID or Name?
if (!is_null($result)) { if (!is_null($result)) {

View File

@@ -16,7 +16,7 @@ class Bill implements PostProcessorInterface
/** /**
* @return array * @return array
*/ */
public function process() public function process(): array
{ {
// get bill id. // get bill id.

View File

@@ -19,7 +19,7 @@ class Currency implements PostProcessorInterface
/** /**
* @return array * @return array
*/ */
public function process() public function process(): array
{ {
// fix currency // fix currency

View File

@@ -16,7 +16,7 @@ class Description implements PostProcessorInterface
/** /**
* @return array * @return array
*/ */
public function process() public function process(): array
{ {
$description = $this->data['description'] ?? ''; $description = $this->data['description'] ?? '';
$this->data['description'] = trim($description); $this->data['description'] = trim($description);

View File

@@ -22,7 +22,7 @@ class OpposingAccount implements PostProcessorInterface
/** /**
* @return array * @return array
*/ */
public function process() public function process(): array
{ {
// three values: // three values:
// opposing-account-id, opposing-account-iban, opposing-account-name // opposing-account-id, opposing-account-iban, opposing-account-name

View File

@@ -14,7 +14,7 @@ interface PostProcessorInterface
/** /**
* @return array * @return array
*/ */
public function process(); public function process(): array;
/** /**
* @param array $data * @param array $data

View File

@@ -32,7 +32,7 @@ class AbnAmroDescription extends Specifix implements SpecifixInterface
/** /**
* @return array * @return array
*/ */
public function fix() public function fix(): array
{ {
// Try to parse the description in known formats. // Try to parse the description in known formats.
$parsed = $this->parseSepaDescription() || $this->parseTRTPDescription() || $this->parseGEABEADescription() || $this->parseABNAMRODescription(); $parsed = $this->parseSepaDescription() || $this->parseTRTPDescription() || $this->parseGEABEADescription() || $this->parseABNAMRODescription();
@@ -65,7 +65,7 @@ class AbnAmroDescription extends Specifix implements SpecifixInterface
/** /**
* Parses the current description with costs from ABN AMRO itself * Parses the current description with costs from ABN AMRO itself
* *
* @return boolean true if the description is GEA/BEA-format, false otherwise * @return bool true if the description is GEA/BEA-format, false otherwise
*/ */
protected function parseABNAMRODescription() protected function parseABNAMRODescription()
{ {
@@ -85,7 +85,7 @@ class AbnAmroDescription extends Specifix implements SpecifixInterface
/** /**
* Parses the current description in GEA/BEA format * Parses the current description in GEA/BEA format
* *
* @return boolean true if the description is GEA/BEAformat, false otherwise * @return bool true if the description is GEA/BEAformat, false otherwise
*/ */
protected function parseGEABEADescription() protected function parseGEABEADescription()
{ {
@@ -111,7 +111,7 @@ class AbnAmroDescription extends Specifix implements SpecifixInterface
/** /**
* Parses the current description in SEPA format * Parses the current description in SEPA format
* *
* @return boolean true if the description is SEPA format, false otherwise * @return bool true if the description is SEPA format, false otherwise
*/ */
protected function parseSepaDescription() protected function parseSepaDescription()
{ {
@@ -168,7 +168,7 @@ class AbnAmroDescription extends Specifix implements SpecifixInterface
/** /**
* Parses the current description in TRTP format * Parses the current description in TRTP format
* *
* @return boolean true if the description is TRTP format, false otherwise * @return bool true if the description is TRTP format, false otherwise
*/ */
protected function parseTRTPDescription() protected function parseTRTPDescription()
{ {

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