First part of a large code cleanup commit.

This commit is contained in:
James Cole
2019-02-12 21:49:28 +01:00
parent b273af341c
commit e0d87aa11e
70 changed files with 336 additions and 354 deletions

View File

@@ -102,10 +102,12 @@ class ConvertToDeposit implements ActionInterface
if (TransactionType::WITHDRAWAL === $type) {
Log::debug('Going to transform a withdrawal to a deposit.');
return $this->convertWithdrawal($journal);
}
if (TransactionType::TRANSFER === $type) {
Log::debug('Going to transform a transfer to a deposit.');
return $this->convertTransfer($journal);
}
@@ -133,7 +135,7 @@ class ConvertToDeposit implements ActionInterface
// get the action value, or use the original source name in case the action value is empty:
// this becomes a new or existing revenue account.
/** @var Account $source */
$source = $sourceTransactions->first()->account;
$source = $sourceTransactions->first()->account;
$revenueName = '' === $this->action->action_value ? $source->name : $this->action->action_value;
$revenue = $factory->findOrCreate($revenueName, AccountType::REVENUE);

View File

@@ -62,22 +62,6 @@ class Processor
$this->actions = new Collection;
}
/**
* @return bool
*/
public function isStrict(): bool
{
return $this->strict;
}
/**
* @param bool $strict
*/
public function setStrict(bool $strict): void
{
$this->strict = $strict;
}
/**
* Return found triggers
*
@@ -170,6 +154,22 @@ class Processor
return false;
}
/**
* @return bool
*/
public function isStrict(): bool
{
return $this->strict;
}
/**
* @param bool $strict
*/
public function setStrict(bool $strict): void
{
$this->strict = $strict;
}
/**
* This method will make a Processor that will process each transaction journal using the triggers
* and actions found in the given Rule.

View File

@@ -23,7 +23,6 @@ declare(strict_types=1);
namespace FireflyIII\TransactionRules;
use Carbon\Carbon;
use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Helpers\Collector\TransactionCollectorInterface;
use FireflyIII\Helpers\Filter\InternalTransferFilter;
use FireflyIII\Models\Rule;
@@ -69,10 +68,8 @@ class TransactionMatcher
*/
public function __construct()
{
$this->strict = false;
$this->startDate = null;
$this->endDate = null;
$this->accounts = new Collection;
$this->strict = false;
$this->accounts = new Collection;
Log::debug('Created new transaction matcher');
}
@@ -89,6 +86,7 @@ class TransactionMatcher
Log::debug('Now in findTransactionsByRule()');
if (0 === \count($this->rule->ruleTriggers)) {
Log::error('Rule has no triggers!');
return new Collection;
}
@@ -290,7 +288,7 @@ class TransactionMatcher
if ($this->accounts->count() > 0) {
$collector->setAccounts($this->accounts);
}
if(null !== $this->startDate && null !== $this->endDate) {
if (null !== $this->startDate && null !== $this->endDate) {
$collector->setRange($this->startDate, $this->endDate);
}

View File

@@ -68,7 +68,7 @@ final class NotesAny extends AbstractTrigger implements TriggerInterface
$text = $note->text;
}
if (\strlen($text) > 0) {
if ('' !== $text) {
Log::debug(sprintf('RuleTrigger NotesEmpty for journal #%d: strlen > 0, return true.', $journal->id));
return true;

View File

@@ -75,7 +75,7 @@ final class NotesAre extends AbstractTrigger implements TriggerInterface
}
$search = strtolower($this->triggerValue);
if ($text === $search && \strlen($text) > 0) {
if ($text === $search && '' != $text) {
Log::debug(sprintf('RuleTrigger NotesAre for journal #%d: "%s" is "%s", return true.', $journal->id, $text, $search));
return true;