Skip to content

Firefly III: a personal finances manager

First code for #2723

James Colebe2794406c2b
diff --git a/app/Models/Account.php b/app/Models/Account.php
index 998240fdf7..cc52b690db 100644
--- a/app/Models/Account.php
+++ b/app/Models/Account.php
@@ -150,6 +150,21 @@ class Account extends Model
return $this->belongsTo(AccountType::class);
}
+ /**
+ * Get the account number.
+ *
+ * @return string
+ */
+ public function getAccountNumberAttribute(): ?string
+ {
+ /** @var AccountMeta $metaValue */
+ $metaValue = $this->accountMeta()
+ ->where('name', 'account_number')
+ ->first();
+
+ return $metaValue ? $metaValue->data : null;
+ }
+
/**
* @return string
* @codeCoverageIgnore
diff --git a/app/Repositories/Journal/JournalRepository.php b/app/Repositories/Journal/JournalRepository.php
index f51a24ec7f..ebd663f4c4 100644
--- a/app/Repositories/Journal/JournalRepository.php
+++ b/app/Repositories/Journal/JournalRepository.php
@@ -23,6 +23,7 @@ declare(strict_types=1);
namespace FireflyIII\Repositories\Journal;
use Carbon\Carbon;
+use FireflyIII\Models\Account;
use FireflyIII\Models\Note;
use FireflyIII\Models\Transaction;
use FireflyIII\Models\TransactionGroup;
@@ -377,4 +378,26 @@ class JournalRepository implements JournalRepositoryInterface
return $value;
}
+
+ /**
+ * @inheritDoc
+ */
+ public function getSourceAccount(TransactionJournal $journal): Account
+ {
+ /** @var Transaction $transaction */
+ $transaction = $journal->transactions()->with('account')->where('amount', '<', 0)->first();
+
+ return $transaction->account;
+ }
+
+ /**
+ * @inheritDoc
+ */
+ public function getDestinationAccount(TransactionJournal $journal): Account
+ {
+ /** @var Transaction $transaction */
+ $transaction = $journal->transactions()->with('account')->where('amount', '>', 0)->first();
+
+ return $transaction->account;
+ }
}
diff --git a/app/Repositories/Journal/JournalRepositoryInterface.php b/app/Repositories/Journal/JournalRepositoryInterface.php
index af2a752612..b7c4ca61f0 100644
--- a/app/Repositories/Journal/JournalRepositoryInterface.php
+++ b/app/Repositories/Journal/JournalRepositoryInterface.php
@@ -23,6 +23,7 @@ declare(strict_types=1);
namespace FireflyIII\Repositories\Journal;
use Carbon\Carbon;
+use FireflyIII\Models\Account;
use FireflyIII\Models\TransactionGroup;
use FireflyIII\Models\TransactionJournal;
use FireflyIII\Models\TransactionJournalLink;
@@ -109,6 +110,22 @@ interface JournalRepositoryInterface
*/
public function getJournalSourceAccounts(TransactionJournal $journal): Collection;
+ /**
+ * Returns the source account of the journal.
+ *
+ * @param TransactionJournal $journal
+ * @return Account
+ */
+ public function getSourceAccount(TransactionJournal $journal): Account;
+
+ /**
+ * Returns the destination account of the journal.
+ *
+ * @param TransactionJournal $journal
+ * @return Account
+ */
+ public function getDestinationAccount(TransactionJournal $journal): Account;
+
/**
* Return total amount of journal. Is always positive.
*
diff --git a/app/TransactionRules/Triggers/FromAccountContains.php b/app/TransactionRules/Triggers/FromAccountContains.php
index 8f9323d488..3473aeffaa 100644
--- a/app/TransactionRules/Triggers/FromAccountContains.php
+++ b/app/TransactionRules/Triggers/FromAccountContains.php
@@ -22,7 +22,6 @@ declare(strict_types=1);
namespace FireflyIII\TransactionRules\Triggers;
-use FireflyIII\Models\Account;
use FireflyIII\Models\TransactionJournal;
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
use Log;
@@ -72,21 +71,18 @@ final class FromAccountContains extends AbstractTrigger implements TriggerInterf
*/
public function triggered(TransactionJournal $journal): bool
{
- $fromAccountName = '';
-
/** @var JournalRepositoryInterface $repository */
$repository = app(JournalRepositoryInterface::class);
-
- /** @var Account $account */
- foreach ($repository->getJournalSourceAccounts($journal, false) as $account) {
- $fromAccountName .= strtolower($account->name);
- }
-
- $search = strtolower($this->triggerValue);
- $strpos = strpos($fromAccountName, $search);
+ $source = $repository->getSourceAccount($journal);
+ $strpos = stripos($source->name, $this->triggerValue);
if (!(false === $strpos)) {
- Log::debug(sprintf('RuleTrigger FromAccountContains for journal #%d: "%s" contains "%s", return true.', $journal->id, $fromAccountName, $search));
+ Log::debug(
+ sprintf(
+ 'RuleTrigger FromAccountContains for journal #%d: "%s" contains "%s", return true.',
+ $journal->id, $source->name, $this->triggerValue
+ )
+ );
return true;
}
@@ -95,8 +91,8 @@ final class FromAccountContains extends AbstractTrigger implements TriggerInterf
sprintf(
'RuleTrigger FromAccountContains for journal #%d: "%s" does not contain "%s", return false.',
$journal->id,
- $fromAccountName,
- $search
+ $source->name,
+ $this->triggerValue
)
);
diff --git a/app/TransactionRules/Triggers/FromAccountEnds.php b/app/TransactionRules/Triggers/FromAccountEnds.php
index 9b9d08ce0c..e5e70df7ce 100644
--- a/app/TransactionRules/Triggers/FromAccountEnds.php
+++ b/app/TransactionRules/Triggers/FromAccountEnds.php
@@ -22,7 +22,6 @@ declare(strict_types=1);
namespace FireflyIII\TransactionRules\Triggers;
-use FireflyIII\Models\Account;
use FireflyIII\Models\TransactionJournal;
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
use Log;
@@ -72,19 +71,13 @@ final class FromAccountEnds extends AbstractTrigger implements TriggerInterface
*/
public function triggered(TransactionJournal $journal): bool
{
- $name = '';
-
/** @var JournalRepositoryInterface $repository */
- $repository = app(JournalRepositoryInterface::class);
-
- /** @var Account $account */
- foreach ($repository->getJournalSourceAccounts($journal, false) as $account) {
- $name .= strtolower($account->name);
- }
-
- $nameLength = strlen($name);
- $search = strtolower($this->triggerValue);
+ $repository = app(JournalRepositoryInterface::class);
+ $source = $repository->getSourceAccount($journal);
+ $nameLength = strlen($source->name);
+ $search = $this->triggerValue;
$searchLength = strlen($search);
+ $part = substr($source->name, $searchLength * -1);
// if the string to search for is longer than the account name,
// it will never be in the account name.
@@ -94,9 +87,7 @@ final class FromAccountEnds extends AbstractTrigger implements TriggerInterface
return false;
}
- $part = substr($name, $searchLength * -1);
-
- if ($part === $search) {
+ if (strtolower($part) === strtolower($search)) {
Log::debug(sprintf('RuleTrigger FromAccountEnds for journal #%d: "%s" ends with "%s", return true.', $journal->id, $name, $search));
return true;
diff --git a/app/TransactionRules/Triggers/FromAccountIs.php b/app/TransactionRules/Triggers/FromAccountIs.php
index 7dc767f008..baffc421a1 100644
--- a/app/TransactionRules/Triggers/FromAccountIs.php
+++ b/app/TransactionRules/Triggers/FromAccountIs.php
@@ -22,7 +22,6 @@ declare(strict_types=1);
namespace FireflyIII\TransactionRules\Triggers;
-use FireflyIII\Models\Account;
use FireflyIII\Models\TransactionJournal;
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
use Log;
@@ -72,19 +71,12 @@ final class FromAccountIs extends AbstractTrigger implements TriggerInterface
*/
public function triggered(TransactionJournal $journal): bool
{
- $name = '';
-
/** @var JournalRepositoryInterface $repository */
$repository = app(JournalRepositoryInterface::class);
+ $source = $repository->getSourceAccount($journal);
+ $search = strtolower($this->triggerValue);
- /** @var Account $account */
- foreach ($repository->getJournalSourceAccounts($journal, false) as $account) {
- $name .= strtolower($account->name);
- }
-
- $search = strtolower($this->triggerValue);
-
- if ($name === $search) {
+ if (strtolower($source->name) === $search) {
Log::debug(sprintf('RuleTrigger FromAccountIs for journal #%d: "%s" is "%s", return true.', $journal->id, $name, $search));
return true;
diff --git a/app/TransactionRules/Triggers/FromAccountNumberContains.php b/app/TransactionRules/Triggers/FromAccountNumberContains.php
new file mode 100644
index 0000000000..034a61baaf
--- /dev/null
+++ b/app/TransactionRules/Triggers/FromAccountNumberContains.php
@@ -0,0 +1,103 @@
+<?php
+/**
+ * FromAccountContains.php
+ * Copyright (c) 2019 [email protected]
+ *
+ * This file is part of Firefly III (https://github.com/firefly-iii).
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
+ */
+declare(strict_types=1);
+
+namespace FireflyIII\TransactionRules\Triggers;
+
+use FireflyIII\Models\TransactionJournal;
+use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
+use Log;
+
+/**
+ * Class FromAccountContains.
+ */
+final class FromAccountNumberContains extends AbstractTrigger implements TriggerInterface
+{
+ /**
+ * A trigger is said to "match anything", or match any given transaction,
+ * when the trigger value is very vague or has no restrictions. Easy examples
+ * are the "AmountMore"-trigger combined with an amount of 0: any given transaction
+ * has an amount of more than zero! Other examples are all the "Description"-triggers
+ * which have hard time handling empty trigger values such as "" or "*" (wild cards).
+ *
+ * If the user tries to create such a trigger, this method MUST return true so Firefly III
+ * can stop the storing / updating the trigger. If the trigger is in any way restrictive
+ * (even if it will still include 99.9% of the users transactions), this method MUST return
+ * false.
+ *
+ * @param mixed $value
+ *
+ * @return bool
+ */
+ public static function willMatchEverything($value = null): bool
+ {
+ if (null !== $value) {
+ $res = '' === (string)$value;
+ if (true === $res) {
+ Log::error(sprintf('Cannot use %s with "" as a value.', self::class));
+ }
+
+ return $res;
+ }
+ Log::error(sprintf('Cannot use %s with a null value.', self::class));
+
+ return true;
+ }
+
+ /**
+ * Returns true when from-account contains X
+ *
+ * @param TransactionJournal $journal
+ *
+ * @return bool
+ */
+ public function triggered(TransactionJournal $journal): bool
+ {
+ /** @var JournalRepositoryInterface $repository */
+ $repository = app(JournalRepositoryInterface::class);
+ $source = $repository->getSourceAccount($journal);
+ $strpos1 = stripos($source->iban, $this->triggerValue);
+ $strpos2 = stripos($source->account_number, $this->triggerValue);
+
+ if (!(false === $strpos1) || !(false === $strpos2)) {
+ Log::debug(
+ sprintf(
+ 'RuleTrigger FromAccountContains for journal #%d: "%s" or "%s" contains "%s", return true.',
+ $journal->id, $source->iban, $source->account_number, $this->triggerValue
+ )
+ );
+
+ return true;
+ }
+
+ Log::debug(
+ sprintf(
+ 'RuleTrigger FromAccountContains for journal #%d: "%s" and "%s" does not contain "%s", return false.',
+ $journal->id,
+ $source->iban,
+ $source->account_number,
+ $this->triggerValue
+ )
+ );
+
+ return false;
+ }
+}
diff --git a/app/TransactionRules/Triggers/FromAccountNumberEnds.php b/app/TransactionRules/Triggers/FromAccountNumberEnds.php
new file mode 100644
index 0000000000..c3afaed82f
--- /dev/null
+++ b/app/TransactionRules/Triggers/FromAccountNumberEnds.php
@@ -0,0 +1,104 @@
+<?php
+/**
+ * FromAccountEnds.php
+ * Copyright (c) 2019 [email protected]
+ *
+ * This file is part of Firefly III (https://github.com/firefly-iii).
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
+ */
+declare(strict_types=1);
+
+namespace FireflyIII\TransactionRules\Triggers;
+
+use FireflyIII\Models\TransactionJournal;
+use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
+use Log;
+
+/**
+ * Class FromAccountNumberEnds.
+ */
+final class FromAccountNumberEnds extends AbstractTrigger implements TriggerInterface
+{
+ /**
+ * A trigger is said to "match anything", or match any given transaction,
+ * when the trigger value is very vague or has no restrictions. Easy examples
+ * are the "AmountMore"-trigger combined with an amount of 0: any given transaction
+ * has an amount of more than zero! Other examples are all the "Description"-triggers
+ * which have hard time handling empty trigger values such as "" or "*" (wild cards).
+ *
+ * If the user tries to create such a trigger, this method MUST return true so Firefly III
+ * can stop the storing / updating the trigger. If the trigger is in any way restrictive
+ * (even if it will still include 99.9% of the users transactions), this method MUST return
+ * false.
+ *
+ * @param mixed $value
+ *
+ * @return bool
+ */
+ public static function willMatchEverything($value = null): bool
+ {
+ if (null !== $value) {
+ $res = '' === (string)$value;
+ if (true === $res) {
+ Log::error(sprintf('Cannot use %s with "" as a value.', self::class));
+ }
+
+ return $res;
+ }
+ Log::error(sprintf('Cannot use %s with a null value.', self::class));
+
+ return true;
+ }
+
+ /**
+ * Returns true when from account ends with X
+ *
+ * @param TransactionJournal $journal
+ *
+ * @return bool
+ */
+ public function triggered(TransactionJournal $journal): bool
+ {
+ /** @var JournalRepositoryInterface $repository */
+ $repository = app(JournalRepositoryInterface::class);
+ $source = $repository->getSourceAccount($journal);
+ $search = $this->triggerValue;
+ $searchLength = strlen($search);
+
+ $part1 = substr($source->iban, $searchLength * -1);
+ $part2 = substr($source->account_number, $searchLength * -1);
+
+ if (strtolower($part1) === strtolower($search)
+ || strtolower($part2) === strtolower($search)) {
+ Log::debug(
+ sprintf(
+ 'RuleTrigger FromAccountEnds for journal #%d: "%s" or "%s" ends with "%s", return true.',
+ $journal->id, $part1, $part2, $search
+ )
+ );
+
+ return true;
+ }
+
+ Log::debug(
+ sprintf(
+ 'RuleTrigger FromAccountEnds for journal #%d: "%s" and "%s" do not end with "%s", return false.',
+ $journal->id, $part1, $part2, $search
+ )
+ );
+
+ return false;
+ }
+}
diff --git a/app/TransactionRules/Triggers/FromAccountNumberIs.php b/app/TransactionRules/Triggers/FromAccountNumberIs.php
new file mode 100644
index 0000000000..3ad768645b
--- /dev/null
+++ b/app/TransactionRules/Triggers/FromAccountNumberIs.php
@@ -0,0 +1,99 @@
+<?php
+/**
+ * FromAccountNumberIs.php
+ * Copyright (c) 2019 [email protected]
+ *
+ * This file is part of Firefly III (https://github.com/firefly-iii).
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
+ */
+declare(strict_types=1);
+
+namespace FireflyIII\TransactionRules\Triggers;
+
+use FireflyIII\Models\TransactionJournal;
+use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
+use Log;
+
+/**
+ * Class FromAccountNumberIs.
+ */
+final class FromAccountNumberIs extends AbstractTrigger implements TriggerInterface
+{
+ /**
+ * A trigger is said to "match anything", or match any given transaction,
+ * when the trigger value is very vague or has no restrictions. Easy examples
+ * are the "AmountMore"-trigger combined with an amount of 0: any given transaction
+ * has an amount of more than zero! Other examples are all the "Description"-triggers
+ * which have hard time handling empty trigger values such as "" or "*" (wild cards).
+ *
+ * If the user tries to create such a trigger, this method MUST return true so Firefly III
+ * can stop the storing / updating the trigger. If the trigger is in any way restrictive
+ * (even if it will still include 99.9% of the users transactions), this method MUST return
+ * false.
+ *
+ * @param mixed $value
+ *
+ * @return bool
+ */
+ public static function willMatchEverything($value = null): bool
+ {
+ if (null !== $value) {
+ $res = '' === (string)$value;
+ if (true === $res) {
+ Log::error(sprintf('Cannot use %s with "" as a value.', self::class));
+ }
+
+ return $res;
+ }
+ Log::error(sprintf('Cannot use %s with a null value.', self::class));
+
+ return true;
+ }
+
+ /**
+ * Returns true when from-account is X.
+ *
+ * @param TransactionJournal $journal
+ *
+ * @return bool
+ */
+ public function triggered(TransactionJournal $journal): bool
+ {
+ /** @var JournalRepositoryInterface $repository */
+ $repository = app(JournalRepositoryInterface::class);
+ $source = $repository->getSourceAccount($journal);
+ $search = strtolower($this->triggerValue);
+
+ if (strtolower($source->iban) === $search || strtolower($source->account_number) === $search) {
+ Log::debug(
+ sprintf(
+ 'RuleTrigger FromAccountIs for journal #%d: "%s" or "%s" is "%s", return true.', $journal->id,
+ $source->iban, $source->account_number, $search
+ )
+ );
+
+ return true;
+ }
+
+ Log::debug(
+ sprintf(
+ 'RuleTrigger FromAccountIs for journal #%d: "%s" and "%s" is NOT "%s", return false.', $journal->id, $source->iban, $source->account_number,
+ $search
+ )
+ );
+
+ return false;
+ }
+}
diff --git a/app/TransactionRules/Triggers/FromAccountNumberStarts.php b/app/TransactionRules/Triggers/FromAccountNumberStarts.php
new file mode 100644
index 0000000000..4343a10427
--- /dev/null
+++ b/app/TransactionRules/Triggers/FromAccountNumberStarts.php
@@ -0,0 +1,101 @@
+<?php
+/**
+ * FromAccountNumberStarts.php
+ * Copyright (c) 2019 [email protected]
+ *
+ * This file is part of Firefly III (https://github.com/firefly-iii).
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
+ */
+declare(strict_types=1);
+
+namespace FireflyIII\TransactionRules\Triggers;
+
+use FireflyIII\Models\TransactionJournal;
+use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
+use Log;
+
+/**
+ * Class FromAccountNumberStarts.
+ */
+final class FromAccountNumberStarts extends AbstractTrigger implements TriggerInterface
+{
+ /**
+ * A trigger is said to "match anything", or match any given transaction,
+ * when the trigger value is very vague or has no restrictions. Easy examples
+ * are the "AmountMore"-trigger combined with an amount of 0: any given transaction
+ * has an amount of more than zero! Other examples are all the "Description"-triggers
+ * which have hard time handling empty trigger values such as "" or "*" (wild cards).
+ *
+ * If the user tries to create such a trigger, this method MUST return true so Firefly III
+ * can stop the storing / updating the trigger. If the trigger is in any way restrictive
+ * (even if it will still include 99.9% of the users transactions), this method MUST return
+ * false.
+ *
+ * @param mixed $value
+ *
+ * @return bool
+ */
+ public static function willMatchEverything($value = null): bool
+ {
+ if (null !== $value) {
+ $res = '' === (string)$value;
+ if (true === $res) {
+ Log::error(sprintf('Cannot use %s with "" as a value.', self::class));
+ }
+
+ return $res;
+ }
+ Log::error(sprintf('Cannot use %s with a null value.', self::class));
+
+ return true;
+ }
+
+ /**
+ * Returns true when from-account starts with X.
+ *
+ * @param TransactionJournal $journal
+ *
+ * @return bool
+ */
+ public function triggered(TransactionJournal $journal): bool
+ {
+ /** @var JournalRepositoryInterface $repository */
+ $repository = app(JournalRepositoryInterface::class);
+ $source = $repository->getSourceAccount($journal);
+ $search = strtolower($this->triggerValue);
+ $part1 = strtolower(substr($source->iban, 0, strlen($search)));
+ $part2 = strtolower(substr($source->account_number, 0, strlen($search)));
+
+ if ($part1 === $search || $part2 === $search) {
+ Log::debug(
+ sprintf(
+ 'RuleTrigger FromAccountStarts for journal #%d: "%s" or "%s" starts with "%s", return true.', $journal->id,
+ $part1, $part2, $search
+ )
+ );
+
+ return true;
+ }
+
+ Log::debug(
+ sprintf(
+ 'RuleTrigger FromAccountStarts for journal #%d: "%s" and "%s" do not start with "%s", return false.',
+ $journal->id, $part1, $part2, $search
+ )
+ );
+
+ return false;
+ }
+}
diff --git a/app/TransactionRules/Triggers/FromAccountStarts.php b/app/TransactionRules/Triggers/FromAccountStarts.php
index 502347cb5a..5bbf044ca7 100644
--- a/app/TransactionRules/Triggers/FromAccountStarts.php
+++ b/app/TransactionRules/Triggers/FromAccountStarts.php
@@ -22,7 +22,6 @@ declare(strict_types=1);
namespace FireflyIII\TransactionRules\Triggers;
-use FireflyIII\Models\Account;
use FireflyIII\Models\TransactionJournal;
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
use Log;
@@ -72,18 +71,11 @@ final class FromAccountStarts extends AbstractTrigger implements TriggerInterfac
*/
public function triggered(TransactionJournal $journal): bool
{
- $name = '';
-
/** @var JournalRepositoryInterface $repository */
$repository = app(JournalRepositoryInterface::class);
-
- /** @var Account $account */
- foreach ($repository->getJournalSourceAccounts($journal, false) as $account) {
- $name .= strtolower($account->name);
- }
-
- $search = strtolower($this->triggerValue);
- $part = substr($name, 0, strlen($search));
+ $source = $repository->getSourceAccount($journal);
+ $search = strtolower($this->triggerValue);
+ $part = substr($source->name, 0, strlen($search));
if ($part === $search) {
Log::debug(sprintf('RuleTrigger FromAccountStarts for journal #%d: "%s" starts with "%s", return true.', $journal->id, $name, $search));
diff --git a/config/firefly.php b/config/firefly.php
index c1df887329..0d9c17637c 100644
--- a/config/firefly.php
+++ b/config/firefly.php
@@ -90,6 +90,10 @@ use FireflyIII\TransactionRules\Triggers\DescriptionStarts;
use FireflyIII\TransactionRules\Triggers\FromAccountContains;
use FireflyIII\TransactionRules\Triggers\FromAccountEnds;
use FireflyIII\TransactionRules\Triggers\FromAccountIs;
+use FireflyIII\TransactionRules\Triggers\FromAccountNumberContains;
+use FireflyIII\TransactionRules\Triggers\FromAccountNumberEnds;
+use FireflyIII\TransactionRules\Triggers\FromAccountNumberIs;
+use FireflyIII\TransactionRules\Triggers\FromAccountNumberStarts;
use FireflyIII\TransactionRules\Triggers\FromAccountStarts;
use FireflyIII\TransactionRules\Triggers\HasAnyBudget;
use FireflyIII\TransactionRules\Triggers\HasAnyCategory;
@@ -404,40 +408,48 @@ return [
],
'rule-triggers' => [
- 'user_action' => UserAction::class,
- 'from_account_starts' => FromAccountStarts::class,
- 'from_account_ends' => FromAccountEnds::class,
- 'from_account_is' => FromAccountIs::class,
- 'from_account_contains' => FromAccountContains::class,
- 'to_account_starts' => ToAccountStarts::class,
- 'to_account_ends' => ToAccountEnds::class,
- 'to_account_is' => ToAccountIs::class,
- 'to_account_contains' => ToAccountContains::class,
- 'amount_less' => AmountLess::class,
- 'amount_exactly' => AmountExactly::class,
- 'amount_more' => AmountMore::class,
- 'description_starts' => DescriptionStarts::class,
- 'description_ends' => DescriptionEnds::class,
- 'description_contains' => DescriptionContains::class,
- 'description_is' => DescriptionIs::class,
- 'transaction_type' => TransactionType::class,
- 'category_is' => CategoryIs::class,
- 'budget_is' => BudgetIs::class,
- 'tag_is' => TagIs::class,
- 'currency_is' => CurrencyIs::class,
- 'has_attachments' => HasAttachment::class,
- 'has_no_category' => HasNoCategory::class,
- 'has_any_category' => HasAnyCategory::class,
- 'has_no_budget' => HasNoBudget::class,
- 'has_any_budget' => HasAnyBudget::class,
- 'has_no_tag' => HasNoTag::class,
- 'has_any_tag' => HasAnyTag::class,
- 'notes_contain' => NotesContain::class,
- 'notes_start' => NotesStart::class,
- 'notes_end' => NotesEnd::class,
- 'notes_are' => NotesAre::class,
- 'no_notes' => NotesEmpty::class,
- 'any_notes' => NotesAny::class,
+ 'user_action' => UserAction::class,
+ 'from_account_starts' => FromAccountStarts::class,
+ 'from_account_ends' => FromAccountEnds::class,
+ 'from_account_is' => FromAccountIs::class,
+ 'from_account_contains' => FromAccountContains::class,
+ 'from_account_nr_starts' => FromAccountNumberStarts::class,
+ 'from_account_nr_ends' => FromAccountNumberEnds::class,
+ 'from_account_nr_is' => FromAccountNumberIs::class,
+ 'from_account_nr_contains' => FromAccountNumberContains::class,
+ 'to_account_starts' => ToAccountStarts::class,
+ 'to_account_ends' => ToAccountEnds::class,
+ 'to_account_is' => ToAccountIs::class,
+ 'to_account_contains' => ToAccountContains::class,
+ //'to_account_nr_starts' => ToAccountNumberStarts::class,
+ //'to_account_nr_ends' => ToAccountNumberEnds::class,
+ //'to_account_nr_is' => ToAccountNumberIs::class,
+ //'to_account_nr_contains' => ToAccountNumberContains::class,
+ 'amount_less' => AmountLess::class,
+ 'amount_exactly' => AmountExactly::class,
+ 'amount_more' => AmountMore::class,
+ 'description_starts' => DescriptionStarts::class,
+ 'description_ends' => DescriptionEnds::class,
+ 'description_contains' => DescriptionContains::class,
+ 'description_is' => DescriptionIs::class,
+ 'transaction_type' => TransactionType::class,
+ 'category_is' => CategoryIs::class,
+ 'budget_is' => BudgetIs::class,
+ 'tag_is' => TagIs::class,
+ 'currency_is' => CurrencyIs::class,
+ 'has_attachments' => HasAttachment::class,
+ 'has_no_category' => HasNoCategory::class,
+ 'has_any_category' => HasAnyCategory::class,
+ 'has_no_budget' => HasNoBudget::class,
+ 'has_any_budget' => HasAnyBudget::class,
+ 'has_no_tag' => HasNoTag::class,
+ 'has_any_tag' => HasAnyTag::class,
+ 'notes_contain' => NotesContain::class,
+ 'notes_start' => NotesStart::class,
+ 'notes_end' => NotesEnd::class,
+ 'notes_are' => NotesAre::class,
+ 'no_notes' => NotesEmpty::class,
+ 'any_notes' => NotesAny::class,
],
'rule-actions' => [
'set_category' => SetCategory::class,
diff --git a/resources/lang/en_US/firefly.php b/resources/lang/en_US/firefly.php
index 06acfd2c19..031ff04247 100644
--- a/resources/lang/en_US/firefly.php
+++ b/resources/lang/en_US/firefly.php
@@ -352,22 +352,43 @@ return [
// actions and triggers
'rule_trigger_user_action' => 'User action is ":trigger_value"',
- 'rule_trigger_from_account_starts_choice' => 'Source account starts with..',
- 'rule_trigger_from_account_starts' => 'Source account starts with ":trigger_value"',
- 'rule_trigger_from_account_ends_choice' => 'Source account ends with..',
- 'rule_trigger_from_account_ends' => 'Source account ends with ":trigger_value"',
- 'rule_trigger_from_account_is_choice' => 'Source account is..',
- 'rule_trigger_from_account_is' => 'Source account is ":trigger_value"',
- 'rule_trigger_from_account_contains_choice' => 'Source account contains..',
- 'rule_trigger_from_account_contains' => 'Source account contains ":trigger_value"',
- 'rule_trigger_to_account_starts_choice' => 'Destination account starts with..',
- 'rule_trigger_to_account_starts' => 'Destination account starts with ":trigger_value"',
- 'rule_trigger_to_account_ends_choice' => 'Destination account ends with..',
- 'rule_trigger_to_account_ends' => 'Destination account ends with ":trigger_value"',
- 'rule_trigger_to_account_is_choice' => 'Destination account is..',
- 'rule_trigger_to_account_is' => 'Destination account is ":trigger_value"',
- 'rule_trigger_to_account_contains_choice' => 'Destination account contains..',
- 'rule_trigger_to_account_contains' => 'Destination account contains ":trigger_value"',
+
+ 'rule_trigger_from_account_starts_choice' => 'Source account name starts with..',
+ 'rule_trigger_from_account_starts' => 'Source account name starts with ":trigger_value"',
+ 'rule_trigger_from_account_ends_choice' => 'Source account name ends with..',
+ 'rule_trigger_from_account_ends' => 'Source account name ends with ":trigger_value"',
+ 'rule_trigger_from_account_is_choice' => 'Source account name is..',
+ 'rule_trigger_from_account_is' => 'Source account name is ":trigger_value"',
+ 'rule_trigger_from_account_contains_choice' => 'Source account name contains..',
+ 'rule_trigger_from_account_contains' => 'Source account name contains ":trigger_value"',
+
+ 'rule_trigger_from_account_nr_starts_choice' => 'Source account number / IBAN starts with..',
+ 'rule_trigger_from_account_nr_starts' => 'Source account number / IBAN starts with ":trigger_value"',
+ 'rule_trigger_from_account_nr_ends_choice' => 'Source account number / IBAN ends with..',
+ 'rule_trigger_from_account_nr_ends' => 'Source account number / IBAN ends with ":trigger_value"',
+ 'rule_trigger_from_account_nr_is_choice' => 'Source account number / IBAN is..',
+ 'rule_trigger_from_account_nr_is' => 'Source account number / IBAN is ":trigger_value"',
+ 'rule_trigger_from_account_nr_contains_choice' => 'Source account number / IBAN contains..',
+ 'rule_trigger_from_account_nr_contains' => 'Source account number / IBAN contains ":trigger_value"',
+
+ 'rule_trigger_to_account_starts_choice' => 'Destination account name starts with..',
+ 'rule_trigger_to_account_starts' => 'Destination account name starts with ":trigger_value"',
+ 'rule_trigger_to_account_ends_choice' => 'Destination account name ends with..',
+ 'rule_trigger_to_account_ends' => 'Destination account name ends with ":trigger_value"',
+ 'rule_trigger_to_account_is_choice' => 'Destination account name is..',
+ 'rule_trigger_to_account_is' => 'Destination account name is ":trigger_value"',
+ 'rule_trigger_to_account_contains_choice' => 'Destination account name contains..',
+ 'rule_trigger_to_account_contains' => 'Destination account name contains ":trigger_value"',
+
+ 'rule_trigger_to_account_nr_starts_choice' => 'Destination account number / IBAN starts with..',
+ 'rule_trigger_to_account_nr_starts' => 'Destination account number / IBAN starts with ":trigger_value"',
+ 'rule_trigger_to_account_nr_ends_choice' => 'Destination account number / IBAN ends with..',
+ 'rule_trigger_to_account_nr_ends' => 'Destination account number / IBAN ends with ":trigger_value"',
+ 'rule_trigger_to_account_nr_is_choice' => 'Destination account number / IBAN is..',
+ 'rule_trigger_to_account_nr_is' => 'Destination account number / IBAN is ":trigger_value"',
+ 'rule_trigger_to_account_nr_contains_choice' => 'Destination account number / IBAN contains..',
+ 'rule_trigger_to_account_nr_contains' => 'Destination account number / IBAN contains ":trigger_value"',
+
'rule_trigger_transaction_type_choice' => 'Transaction is of type..',
'rule_trigger_transaction_type' => 'Transaction is of type ":trigger_value"',
'rule_trigger_category_is_choice' => 'Category is..',