diff --git a/CHANGELOG.md b/CHANGELOG.md index 92c435ac85..62b2d83c85 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,14 @@ This project adheres to [Semantic Versioning](http://semver.org/). ## [Unreleased] - No unreleased changes yet. +## [3.10.4] - 2015-05-25 +### Fixed +- Migration fix by @sandermulders +- Tricky import bug fix thanks to @vissert +- Currency preference will be correctly pulled from user settings, thanks to @fuf +- Simplified code for upgrade instructions. + + ## [3.10.3] - 2016-08-29 ### Added - More fields for mass-edit, thanks to @Vissert (#282) @@ -74,13 +82,6 @@ This project adheres to [Semantic Versioning](http://semver.org/). - The date picker now supports more ranges and periods. - Rewrote all migrations. #272 - -### Deprecated -- Initial release. - -### Removed -- Initial release. - ### Fixed - Issue #264 - Issue #265 @@ -95,10 +96,6 @@ This project adheres to [Semantic Versioning](http://semver.org/). - Bulk update problems, #280, thanks @stickgrinder - Fixed various problems with amount reporting of split transactions. -### Security -- Initial release. - - [3.9.1] ### Fixed - Fixed a bug where removing money from a piggy bank would not work. See issue #265 and #269 diff --git a/app/Console/Commands/UpgradeFireflyInstructions.php b/app/Console/Commands/UpgradeFireflyInstructions.php index 561858ba9e..712438eefa 100644 --- a/app/Console/Commands/UpgradeFireflyInstructions.php +++ b/app/Console/Commands/UpgradeFireflyInstructions.php @@ -51,15 +51,22 @@ class UpgradeFireflyInstructions extends Command /** @var string $version */ $version = config('firefly.version'); $config = config('upgrade.text'); - $text = $config[$version] ?? null; + $text = null; + foreach (array_keys($config) as $compare) { + // if string starts with: + $len = strlen($compare); + if (substr($version, 0, $len) === $compare) { + $text = $config[$compare]; + } + + } $this->line('+------------------------------------------------------------------------------+'); $this->line(''); if (is_null($text)) { $this->line('Thank you for installing Firefly III, v' . $version); - $this->line('If you are upgrading from a previous version,'); - $this->info('there are no extra upgrade instructions.'); + $this->info('There are no extra upgrade instructions.'); $this->line('Firefly III should be ready for use.'); } else { $this->line('Thank you for installing Firefly III, v' . $version); diff --git a/app/Import/ImportValidator.php b/app/Import/ImportValidator.php index 0c148b0c20..0b916a053b 100644 --- a/app/Import/ImportValidator.php +++ b/app/Import/ImportValidator.php @@ -21,6 +21,7 @@ use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface; use FireflyIII\User; use Illuminate\Support\Collection; use Log; +use Preferences; /** * Class ImportValidator @@ -357,13 +358,16 @@ class ImportValidator { if (is_null($entry->fields['currency'])) { /** @var CurrencyRepositoryInterface $repository */ - $repository = app(CurrencyRepositoryInterface::class); - $entry->fields['currency'] = $repository->findByCode(env('DEFAULT_CURRENCY', 'EUR')); - Log::debug('Set currency to EUR'); + $repository = app(CurrencyRepositoryInterface::class, [$this->user]); + // is the default currency for the user or the system + $defaultCode = Preferences::getForUser($this->user, 'currencyPreference', env('DEFAULT_CURRENCY', 'EUR'))->data; + + $entry->fields['currency'] = $repository->findByCode($defaultCode); + Log::debug(sprintf('Set currency to %s', $defaultCode)); return $entry; } - Log::debug('Currency is OK'); + Log::debug(sprintf('Currency is OK: %s', $entry->fields['currency']->code)); return $entry; } diff --git a/app/Rules/Factory/TriggerFactory.php b/app/Rules/Factory/TriggerFactory.php index 6ada8ca347..65cbf1bcde 100644 --- a/app/Rules/Factory/TriggerFactory.php +++ b/app/Rules/Factory/TriggerFactory.php @@ -16,6 +16,7 @@ use FireflyIII\Models\RuleTrigger; use FireflyIII\Rules\Triggers\AbstractTrigger; use FireflyIII\Rules\Triggers\TriggerInterface; use FireflyIII\Support\Domain; +use Log; /** * Interface TriggerInterface @@ -68,6 +69,7 @@ class TriggerFactory /** @var AbstractTrigger $class */ $class = self::getTriggerClass($triggerType); $obj = $class::makeFromStrings($triggerValue, $stopProcessing); + Log::debug('Created trigger from string', ['type' => $triggerType, 'value' => $triggerValue, 'stopProcessing' => $stopProcessing, 'class' => $class]); return $obj; } diff --git a/app/Rules/Processor.php b/app/Rules/Processor.php index 25522aabf8..3d22ad7b05 100644 --- a/app/Rules/Processor.php +++ b/app/Rules/Processor.php @@ -20,6 +20,7 @@ use FireflyIII\Rules\Factory\ActionFactory; use FireflyIII\Rules\Factory\TriggerFactory; use FireflyIII\Rules\Triggers\AbstractTrigger; use Illuminate\Support\Collection; +use Log; /** * Class Processor @@ -37,6 +38,8 @@ final class Processor /** @var Collection */ public $triggers; + protected $foundTriggers = 0; + /** * Processor constructor. * @@ -57,9 +60,17 @@ final class Processor */ public static function make(Rule $rule) { + Log::debug(sprintf('Making new rule from Rule %d', $rule->id)); $self = new self; $self->rule = $rule; + /* + * The number of "found triggers" must start at -1, because the first + * trigger is "create-journal" or "update-journal" when this Processor + * is called from a Rule. + */ + $self->setFoundTriggers(-1); + $triggerSet = $rule->ruleTriggers()->orderBy('order', 'ASC')->get(); /** @var RuleTrigger $trigger */ foreach ($triggerSet as $trigger) { @@ -113,6 +124,22 @@ final class Processor return $self; } + /** + * @return int + */ + public function getFoundTriggers(): int + { + return $this->foundTriggers; + } + + /** + * @param int $foundTriggers + */ + public function setFoundTriggers(int $foundTriggers) + { + $this->foundTriggers = $foundTriggers; + } + /** * * @return \FireflyIII\Models\Rule @@ -176,25 +203,30 @@ final class Processor * * @return bool */ - private function triggered() + private function triggered(): bool { - $foundTriggers = 0; + Log::debug('start of Processor::triggered()'); + $foundTriggers = $this->getFoundTriggers(); $hitTriggers = 0; - /** @var RuleTrigger $trigger */ + /** @var AbstractTrigger $trigger */ foreach ($this->triggers as $trigger) { $foundTriggers++; - + Log::debug(sprintf('Now checking trigger %s with value %s', get_class($trigger), $trigger->getTriggerValue())); /** @var AbstractTrigger $trigger */ if ($trigger->triggered($this->journal)) { + Log::debug('Is a match!'); $hitTriggers++; } if ($trigger->stopProcessing) { + Log::debug('Stop processing this trigger and break.'); break; } } + $result = ($hitTriggers == $foundTriggers && $foundTriggers > 0); + Log::debug('Result of triggered()', ['hitTriggers' => $hitTriggers, 'foundTriggers' => $foundTriggers, 'result' => $result]); - return ($hitTriggers == $foundTriggers && $foundTriggers > 0); + return $result; } diff --git a/app/Rules/TransactionMatcher.php b/app/Rules/TransactionMatcher.php index 599a0932ba..4a6e4f6085 100644 --- a/app/Rules/TransactionMatcher.php +++ b/app/Rules/TransactionMatcher.php @@ -15,6 +15,7 @@ use FireflyIII\Models\TransactionJournal; use FireflyIII\Models\TransactionType; use FireflyIII\Repositories\Journal\JournalRepositoryInterface; use Illuminate\Support\Collection; +use Log; /** * Class TransactionMatcher is used to find a list of @@ -80,6 +81,8 @@ class TransactionMatcher // Filter transactions that match the given triggers. $filtered = $set->filter( function (TransactionJournal $journal) use ($processor) { + Log::debug(sprintf('Test these triggers on #%d', $journal->id)); + return $processor->handleTransactionJournal($journal); } ); diff --git a/app/Rules/Triggers/AbstractTrigger.php b/app/Rules/Triggers/AbstractTrigger.php index 96422a4387..45234606c8 100644 --- a/app/Rules/Triggers/AbstractTrigger.php +++ b/app/Rules/Triggers/AbstractTrigger.php @@ -98,5 +98,23 @@ class AbstractTrigger return $self; } + /** + * @return RuleTrigger + */ + public function getTrigger(): RuleTrigger + { + return $this->trigger; + } + + /** + * @return string + */ + public function getTriggerValue(): string + { + return $this->triggerValue; + } + + + } diff --git a/app/Support/Amount.php b/app/Support/Amount.php index 0b3620d1e5..7aa23d6324 100644 --- a/app/Support/Amount.php +++ b/app/Support/Amount.php @@ -171,7 +171,7 @@ class Amount } /** - * @return TransactionCurrency + * @return \FireflyIII\Models\TransactionCurrency */ public function getDefaultCurrency(): TransactionCurrency { @@ -180,7 +180,7 @@ class Amount if ($cache->has()) { return $cache->get(); } - $currencyPreference = Prefs::get('currencyPreference', 'EUR'); + $currencyPreference = Prefs::get('currencyPreference', env('DEFAULT_CURRENCY', 'EUR')); $currency = TransactionCurrency::whereCode($currencyPreference->data)->first(); $cache->store($currency); diff --git a/app/Support/Preferences.php b/app/Support/Preferences.php index 46a93ad058..d505c4fd77 100644 --- a/app/Support/Preferences.php +++ b/app/Support/Preferences.php @@ -57,11 +57,11 @@ class Preferences } /** - * @param User $user - * @param string $name - * @param string $default + * @param \FireflyIII\User $user + * @param string $name + * @param string $default * - * @return Preference|null + * @return \FireflyIII\Models\Preference|null */ public function getForUser(User $user, $name, $default = null) { diff --git a/composer.lock b/composer.lock index f444feca18..9e47e00679 100644 --- a/composer.lock +++ b/composer.lock @@ -518,16 +518,16 @@ }, { "name": "doctrine/dbal", - "version": "v2.5.4", + "version": "v2.5.5", "source": { "type": "git", "url": "https://github.com/doctrine/dbal.git", - "reference": "abbdfd1cff43a7b99d027af3be709bc8fc7d4769" + "reference": "9f8c05cd5225a320d56d4bfdb4772f10d045a0c9" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/dbal/zipball/abbdfd1cff43a7b99d027af3be709bc8fc7d4769", - "reference": "abbdfd1cff43a7b99d027af3be709bc8fc7d4769", + "url": "https://api.github.com/repos/doctrine/dbal/zipball/9f8c05cd5225a320d56d4bfdb4772f10d045a0c9", + "reference": "9f8c05cd5225a320d56d4bfdb4772f10d045a0c9", "shasum": "" }, "require": { @@ -536,7 +536,7 @@ }, "require-dev": { "phpunit/phpunit": "4.*", - "symfony/console": "2.*" + "symfony/console": "2.*||^3.0" }, "suggest": { "symfony/console": "For helpful console commands such as SQL execution and import of files." @@ -585,7 +585,7 @@ "persistence", "queryobject" ], - "time": "2016-01-05 22:11:12" + "time": "2016-09-09 19:13:33" }, { "name": "doctrine/inflector", @@ -1039,16 +1039,16 @@ }, { "name": "league/commonmark", - "version": "0.14.0", + "version": "0.15.0", "source": { "type": "git", "url": "https://github.com/thephpleague/commonmark.git", - "reference": "b73c0b7288bd0e6f9f56bd0b20d0657214b91838" + "reference": "19fb96643beba24e681c371dc133e25409742664" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/thephpleague/commonmark/zipball/b73c0b7288bd0e6f9f56bd0b20d0657214b91838", - "reference": "b73c0b7288bd0e6f9f56bd0b20d0657214b91838", + "url": "https://api.github.com/repos/thephpleague/commonmark/zipball/19fb96643beba24e681c371dc133e25409742664", + "reference": "19fb96643beba24e681c371dc133e25409742664", "shasum": "" }, "require": { @@ -1061,7 +1061,7 @@ "require-dev": { "cebe/markdown": "~1.0", "erusev/parsedown": "~1.0", - "jgm/commonmark": "0.25", + "jgm/commonmark": "0.26", "michelf/php-markdown": "~1.4", "mikehaertl/php-shellcommand": "~1.2.0", "phpunit/phpunit": "~4.3|~5.0", @@ -1077,7 +1077,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "0.15-dev" + "dev-master": "0.16-dev" } }, "autoload": { @@ -1104,7 +1104,7 @@ "markdown", "parser" ], - "time": "2016-07-02 18:48:39" + "time": "2016-09-14 15:44:35" }, { "name": "league/csv", @@ -2014,7 +2014,7 @@ }, { "name": "symfony/event-dispatcher", - "version": "v3.1.3", + "version": "v3.1.4", "source": { "type": "git", "url": "https://github.com/symfony/event-dispatcher.git", @@ -4240,16 +4240,16 @@ }, { "name": "symfony/class-loader", - "version": "v3.1.3", + "version": "v3.1.4", "source": { "type": "git", "url": "https://github.com/symfony/class-loader.git", - "reference": "817f09b4c37b7688fa4342cb4642d8f2d81c1097" + "reference": "2d0ba77c46ecc96a6641009a98f72632216811ba" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/class-loader/zipball/817f09b4c37b7688fa4342cb4642d8f2d81c1097", - "reference": "817f09b4c37b7688fa4342cb4642d8f2d81c1097", + "url": "https://api.github.com/repos/symfony/class-loader/zipball/2d0ba77c46ecc96a6641009a98f72632216811ba", + "reference": "2d0ba77c46ecc96a6641009a98f72632216811ba", "shasum": "" }, "require": { @@ -4292,7 +4292,7 @@ ], "description": "Symfony ClassLoader Component", "homepage": "https://symfony.com", - "time": "2016-07-10 08:05:47" + "time": "2016-08-23 13:39:15" }, { "name": "symfony/css-selector", @@ -4405,16 +4405,16 @@ }, { "name": "symfony/yaml", - "version": "v3.1.3", + "version": "v3.1.4", "source": { "type": "git", "url": "https://github.com/symfony/yaml.git", - "reference": "1819adf2066880c7967df7180f4f662b6f0567ac" + "reference": "f291ed25eb1435bddbe8a96caaef16469c2a092d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/yaml/zipball/1819adf2066880c7967df7180f4f662b6f0567ac", - "reference": "1819adf2066880c7967df7180f4f662b6f0567ac", + "url": "https://api.github.com/repos/symfony/yaml/zipball/f291ed25eb1435bddbe8a96caaef16469c2a092d", + "reference": "f291ed25eb1435bddbe8a96caaef16469c2a092d", "shasum": "" }, "require": { @@ -4450,7 +4450,7 @@ ], "description": "Symfony Yaml Component", "homepage": "https://symfony.com", - "time": "2016-07-17 14:02:08" + "time": "2016-09-02 02:12:52" }, { "name": "webmozart/assert", diff --git a/config/firefly.php b/config/firefly.php index 01690b2a69..56074e77c9 100644 --- a/config/firefly.php +++ b/config/firefly.php @@ -10,7 +10,7 @@ return [ ], 'chart' => 'chartjs', - 'version' => '3.10.3', + 'version' => '3.10.4', 'csv_import_enabled' => true, 'maxUploadSize' => 5242880, 'allowedMimes' => ['image/png', 'image/jpeg', 'application/pdf'], diff --git a/config/upgrade.php b/config/upgrade.php index dbf9c1194b..5d1b69393a 100644 --- a/config/upgrade.php +++ b/config/upgrade.php @@ -13,23 +13,9 @@ declare(strict_types = 1); return [ 'text' => [ - '3.7.0' => 'Because of the upgrade to Laravel 5.2, several manual changes must be made to your Firefly III installation. ' . - 'Please follow the instructions on the following page: https://github.com/JC5/firefly-iii/wiki/Upgrade-to-3.7.0', - '3.7.1' => 'Because of the upgrade to Laravel 5.2, several manual changes must be made to your Firefly III installation. ' . - 'Please follow the instructions on the following page: https://github.com/JC5/firefly-iii/wiki/Upgrade-to-3.7.0', - '3.7.2' => 'Because of the upgrade to Laravel 5.2, several manual changes must be made to your Firefly III installation. ' . - 'Please follow the instructions on the following page: https://github.com/JC5/firefly-iii/wiki/Upgrade-to-3.7.0', - '3.7.2.1' => 'Because of the upgrade to Laravel 5.2, several manual changes must be made to your Firefly III installation. ' . - 'Please follow the instructions on the following page: https://github.com/JC5/firefly-iii/wiki/Upgrade-to-3.7.0', - '3.7.2.2' => 'Because of the upgrade to Laravel 5.2, several manual changes must be made to your Firefly III installation. ' . - 'Please follow the instructions on the following page: https://github.com/JC5/firefly-iii/wiki/Upgrade-to-3.7.0', - '3.7.2.3' => 'Because of the upgrade to Laravel 5.2, several manual changes must be made to your Firefly III installation. ' . - 'Please follow the instructions on the following page: https://github.com/JC5/firefly-iii/wiki/Upgrade-to-3.7.0', - '3.8.0' => 'This version of Firefly III requires PHP 7.0.', - '3.8.1' => 'This version of Firefly III requires PHP 7.0.', - '3.10' => 'Please find the full upgrade instructions here: https://github.com/JC5/firefly-iii/wiki/Upgrade-to-3.10', - '3.10.1' => 'Please find the full upgrade instructions here: https://github.com/JC5/firefly-iii/wiki/Upgrade-to-3.10', - '3.10.2' => 'Please find the full upgrade instructions here: https://github.com/JC5/firefly-iii/wiki/Upgrade-to-3.10', - '3.10.3' => 'Please find the full upgrade instructions here: https://github.com/JC5/firefly-iii/wiki/Upgrade-to-3.10', + '3.7' => 'Because of the upgrade to Laravel 5.2, several manual changes must be made to your Firefly III installation. ' . + 'Please follow the instructions on the following page: https://github.com/JC5/firefly-iii/wiki/Upgrade-to-3.7.0', + '3.8' => 'This version of Firefly III requires PHP 7.0.', + '3.10' => 'Please find the full upgrade instructions here: https://github.com/JC5/firefly-iii/wiki/Upgrade-to-3.10', ], ]; diff --git a/database/migrations/2016_09_12_121359_fix_nullables.php b/database/migrations/2016_09_12_121359_fix_nullables.php new file mode 100644 index 0000000000..3a9044d9dc --- /dev/null +++ b/database/migrations/2016_09_12_121359_fix_nullables.php @@ -0,0 +1,41 @@ +text('description')->nullable()->change(); + } + ); + + Schema::table( + 'rules', function (Blueprint $table) { + $table->text('description')->nullable()->change(); + } + ); + } +}