Skip to content

Firefly III: a personal finances manager

Merge remote-tracking branch 'upstream/main' into feat/expression-engine

Michael Thomasb572c1dcd341
diff --cc app/TransactionRules/Actions/AddTag.php
index 45da90e91e,e9a0ed716d..20d1adfce6
--- a/app/TransactionRules/Actions/AddTag.php
+++ b/app/TransactionRules/Actions/AddTag.php
@@@ -30,9 -28,7 +29,8 @@@ use FireflyIII\Events\TriggeredAuditLog
use FireflyIII\Factory\TagFactory;
use FireflyIII\Models\RuleAction;
use FireflyIII\Models\TransactionJournal;
+use FireflyIII\TransactionRules\Expressions\ActionExpressionEvaluator;
use FireflyIII\User;
- use Illuminate\Support\Facades\Log;
/**
* Class AddTag.
@@@ -44,26 -39,22 +42,24 @@@ class AddTag implements ActionInterfac
/**
* TriggerInterface constructor.
- *
- * @param RuleAction $action
*/
- public function __construct(RuleAction $action)
+ public function __construct(RuleAction $action, ActionExpressionEvaluator $evaluator)
{
$this->action = $action;
+ $this->evaluator = $evaluator;
}
- /**
- * @inheritDoc
- */
public function actOnArray(array $journal): bool
{
// journal has this tag maybe?
/** @var TagFactory $factory */
$factory = app(TagFactory::class);
- $factory->setUser(User::find($journal['user_id']));
+
+ /** @var User $user */
+ $user = User::find($journal['user_id']);
+ $factory->setUser($user);
- $tag = $factory->findOrCreate($this->action->action_value);
+ $tagName = $this->evaluator->evaluate($journal);
- $tag = $factory->findOrCreate($tagName);
++ $tag = $factory->findOrCreate($tagName);
if (null === $tag) {
// could not find, could not create tag.
@@@ -72,24 -63,28 +68,27 @@@
return false;
}
- $count = DB::table('tag_transaction_journal')
+ $count = \DB::table('tag_transaction_journal')
->where('tag_id', $tag->id)
->where('transaction_journal_id', $journal['transaction_journal_id'])
- ->count()
- ;
+ ->count();
if (0 === $count) {
// add to journal:
- DB::table('tag_transaction_journal')->insert(['tag_id' => $tag->id, 'transaction_journal_id' => $journal['transaction_journal_id']]);
- Log::debug(sprintf('RuleAction AddTag. Added tag #%d ("%s") to journal %d.', $tag->id, $tag->tag, $journal['transaction_journal_id']));
+ \DB::table('tag_transaction_journal')->insert(['tag_id' => $tag->id, 'transaction_journal_id' => $journal['transaction_journal_id']]);
+ app('log')->debug(sprintf('RuleAction AddTag. Added tag #%d ("%s") to journal %d.', $tag->id, $tag->tag, $journal['transaction_journal_id']));
+
+ /** @var TransactionJournal $object */
$object = TransactionJournal::find($journal['transaction_journal_id']);
// event for audit log entry
event(new TriggeredAuditLog($this->action->rule, $object, 'add_tag', null, $tag->tag));
+
return true;
}
- Log::debug(
+ app('log')->debug(
sprintf('RuleAction AddTag fired but tag %d ("%s") was already added to journal %d.', $tag->id, $tag->tag, $journal['transaction_journal_id'])
);
- event(new RuleActionFailedOnArray($this->action, $journal, trans('rules.tag_already_added', ['tag' => $this->action->action_value])));
+ event(new RuleActionFailedOnArray($this->action, $journal, trans('rules.tag_already_added', ['tag' => $tagName])));
return false;
}
diff --cc app/TransactionRules/Actions/AppendDescription.php
index 46eef629af,5b5b318ce0..5f8fa29d66
--- a/app/TransactionRules/Actions/AppendDescription.php
+++ b/app/TransactionRules/Actions/AppendDescription.php
@@@ -40,23 -36,16 +39,18 @@@ class AppendDescription implements Acti
/**
* TriggerInterface constructor.
- *
- * @param RuleAction $action
*/
- public function __construct(RuleAction $action)
+ public function __construct(RuleAction $action, ActionExpressionEvaluator $evaluator)
{
$this->action = $action;
+ $this->evaluator = $evaluator;
}
- /**
- * @inheritDoc
- */
public function actOnArray(array $journal): bool
{
- $description = sprintf('%s %s', $journal['description'], $this->action->action_value);
+ $actionValue = $this->evaluator->evaluate($journal);
- $description = sprintf('%s%s', $journal['description'], $actionValue);
- DB::table('transaction_journals')->where('id', $journal['transaction_journal_id'])->limit(1)->update(['description' => $description]);
++ $description = sprintf('%s %s', $journal['description'], $actionValue);
+ \DB::table('transaction_journals')->where('id', $journal['transaction_journal_id'])->limit(1)->update(['description' => $description]);
// event for audit log entry
/** @var TransactionJournal $object */
diff --cc app/TransactionRules/Actions/AppendNotes.php
index 49d7e6e71f,bb990d438f..922be054d2
--- a/app/TransactionRules/Actions/AppendNotes.php
+++ b/app/TransactionRules/Actions/AppendNotes.php
@@@ -28,8 -27,6 +28,7 @@@ use FireflyIII\Events\TriggeredAuditLog
use FireflyIII\Models\Note;
use FireflyIII\Models\RuleAction;
use FireflyIII\Models\TransactionJournal;
+use FireflyIII\TransactionRules\Expressions\ActionExpressionEvaluator;
- use Illuminate\Support\Facades\Log;
/**
* Class AppendNotes.
@@@ -41,33 -37,27 +40,28 @@@ class AppendNotes implements ActionInte
/**
* TriggerInterface constructor.
- *
- * @param RuleAction $action
*/
- public function __construct(RuleAction $action)
+ public function __construct(RuleAction $action, ActionExpressionEvaluator $evaluator)
{
$this->action = $action;
+ $this->evaluator = $evaluator;
}
- /**
- * @inheritDoc
- */
public function actOnArray(array $journal): bool
{
+ $actionValue = $this->evaluator->evaluate($journal);
- $dbNote = Note::where('noteable_id', (int)$journal['transaction_journal_id'])
+ $dbNote = Note::where('noteable_id', (int)$journal['transaction_journal_id'])
->where('noteable_type', TransactionJournal::class)
- ->first(['notes.*'])
- ;
+ ->first(['notes.*']);
if (null === $dbNote) {
$dbNote = new Note();
$dbNote->noteable_id = (int)$journal['transaction_journal_id'];
$dbNote->noteable_type = TransactionJournal::class;
$dbNote->text = '';
}
- Log::debug(sprintf('RuleAction AppendNotes appended "%s" to "%s".', $actionValue, $dbNote->text));
- app('log')->debug(sprintf('RuleAction AppendNotes appended "%s" to "%s".', $this->action->action_value, $dbNote->text));
++ app('log')->debug(sprintf('RuleAction AppendNotes appended "%s" to "%s".', $actionValue, $dbNote->text));
$before = $dbNote->text;
- $text = sprintf('%s%s', $dbNote->text, $this->action->action_value);
+ $text = sprintf('%s%s', $dbNote->text, $actionValue);
$dbNote->text = $text;
$dbNote->save();
diff --cc app/TransactionRules/Actions/ConvertToDeposit.php
index bd13cfa406,e8f9abf59e..fedea72779
--- a/app/TransactionRules/Actions/ConvertToDeposit.php
+++ b/app/TransactionRules/Actions/ConvertToDeposit.php
@@@ -36,12 -34,8 +35,9 @@@ use FireflyIII\Models\Transaction
use FireflyIII\Models\TransactionJournal;
use FireflyIII\Models\TransactionType;
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
+use FireflyIII\TransactionRules\Expressions\ActionExpressionEvaluator;
- use Illuminate\Support\Facades\Log;
- use JsonException;
/**
- *
* Class ConvertToDeposit
*/
class ConvertToDeposit implements ActionInterface
@@@ -51,28 -44,21 +47,24 @@@
/**
* TriggerInterface constructor.
- *
- * @param RuleAction $action
*/
- public function __construct(RuleAction $action)
+ public function __construct(RuleAction $action, ActionExpressionEvaluator $evaluator)
{
$this->action = $action;
+ $this->evaluator = $evaluator;
}
- /**
- * @inheritDoc
- */
public function actOnArray(array $journal): bool
{
+ $actionValue = $this->evaluator->evaluate($journal);
+
// make object from array (so the data is fresh).
- /** @var TransactionJournal|null $object */
- $object = TransactionJournal::where('user_id', $journal['user_id'])->find($journal['transaction_journal_id']);
+ /** @var null|TransactionJournal $object */
+ $object = TransactionJournal::where('user_id', $journal['user_id'])->find($journal['transaction_journal_id']);
if (null === $object) {
- Log::error(sprintf('Cannot find journal #%d, cannot convert to deposit.', $journal['transaction_journal_id']));
+ app('log')->error(sprintf('Cannot find journal #%d, cannot convert to deposit.', $journal['transaction_journal_id']));
event(new RuleActionFailedOnArray($this->action, $journal, trans('rules.journal_not_found')));
+
return false;
}
$groupCount = TransactionJournal::where('transaction_group_id', $journal['transaction_group_id'])->count();
@@@ -91,14 -79,15 +85,15 @@@
}
if (TransactionType::WITHDRAWAL === $type) {
- Log::debug('Going to transform a withdrawal to a deposit.');
+ app('log')->debug('Going to transform a withdrawal to a deposit.');
try {
- $res = $this->convertWithdrawalArray($object);
+ $res = $this->convertWithdrawalArray($object, $actionValue);
- } catch (JsonException | FireflyException $e) {
- Log::debug('Could not convert withdrawal to deposit.');
- Log::error($e->getMessage());
+ } catch (FireflyException $e) {
+ app('log')->debug('Could not convert withdrawal to deposit.');
+ app('log')->error($e->getMessage());
event(new RuleActionFailedOnArray($this->action, $journal, trans('rules.complex_error')));
+
return false;
}
@@@ -107,14 -96,15 +102,15 @@@
return $res;
}
if (TransactionType::TRANSFER === $type) {
- Log::debug('Going to transform a transfer to a deposit.');
+ app('log')->debug('Going to transform a transfer to a deposit.');
try {
-- $res = $this->convertTransferArray($object);
- } catch (JsonException | FireflyException $e) {
- Log::debug('Could not convert transfer to deposit.');
- Log::error($e->getMessage());
++ $res = $this->convertTransferArray($object, $actionValue);
+ } catch (FireflyException $e) {
+ app('log')->debug('Could not convert transfer to deposit.');
+ app('log')->error($e->getMessage());
event(new RuleActionFailedOnArray($this->action, $journal, trans('rules.complex_error')));
+
return false;
}
event(new TriggeredAuditLog($this->action->rule, $object, 'update_transaction_type', TransactionType::TRANSFER, TransactionType::DEPOSIT));
@@@ -129,29 -120,26 +126,26 @@@
* Input is a withdrawal from A to B
* Is converted to a deposit from C to A.
*
- * @param TransactionJournal $journal
- *
- * @return bool
* @throws FireflyException
- * @throws JsonException
*/
- private function convertWithdrawalArray(TransactionJournal $journal): bool
+ private function convertWithdrawalArray(TransactionJournal $journal, string $actionValue): bool
{
- $user = $journal->user;
+ $user = $journal->user;
+
// find or create revenue account.
/** @var AccountFactory $factory */
- $factory = app(AccountFactory::class);
+ $factory = app(AccountFactory::class);
$factory->setUser($user);
- $repository = app(AccountRepositoryInterface::class);
+ $repository = app(AccountRepositoryInterface::class);
$repository->setUser($user);
- $destAccount = $this->getDestinationAccount($journal);
- $sourceAccount = $this->getSourceAccount($journal);
+ $destAccount = $this->getDestinationAccount($journal);
+ $sourceAccount = $this->getSourceAccount($journal);
// get the action value, or use the original destination name in case the action value is empty:
// this becomes a new or existing (revenue) account, which is the source of the new deposit.
- $opposingName = '' === $actionValue ? $destAccount->name : $actionValue;
- $opposingName = '' === $this->action->action_value ? $destAccount->name : $this->action->action_value;
++ $opposingName = '' === $actionValue ? $destAccount->name : $actionValue;
// we check all possible source account types if one exists:
$validTypes = config('firefly.expected_source_types.source.Deposit');
$opposingAccount = $repository->findByName($opposingName, $validTypes);
@@@ -159,28 -147,31 +153,28 @@@
$opposingAccount = $factory->findOrCreate($opposingName, AccountType::REVENUE);
}
- Log::debug(sprintf('ConvertToDeposit. Action value is "%s", new opposing name is "%s"', $actionValue, $opposingAccount->name));
- app('log')->debug(sprintf('ConvertToDeposit. Action value is "%s", new opposing name is "%s"', $this->action->action_value, $opposingAccount->name));
++ app('log')->debug(sprintf('ConvertToDeposit. Action value is "%s", new opposing name is "%s"', $actionValue, $opposingAccount->name));
// update the source transaction and put in the new revenue ID.
- DB::table('transactions')
+ \DB::table('transactions')
->where('transaction_journal_id', '=', $journal->id)
->where('amount', '<', 0)
- ->update(['account_id' => $opposingAccount->id])
- ;
+ ->update(['account_id' => $opposingAccount->id]);
// update the destination transaction and put in the original source account ID.
- DB::table('transactions')
+ \DB::table('transactions')
->where('transaction_journal_id', '=', $journal->id)
->where('amount', '>', 0)
- ->update(['account_id' => $sourceAccount->id])
- ;
+ ->update(['account_id' => $sourceAccount->id]);
// change transaction type of journal:
- $newType = TransactionType::whereType(TransactionType::DEPOSIT)->first();
+ $newType = TransactionType::whereType(TransactionType::DEPOSIT)->first();
- DB::table('transaction_journals')
+ \DB::table('transaction_journals')
->where('id', '=', $journal->id)
- ->update(['transaction_type_id' => $newType->id, 'bill_id' => null])
- ;
+ ->update(['transaction_type_id' => $newType->id, 'bill_id' => null]);
- Log::debug('Converted withdrawal to deposit.');
+ app('log')->debug('Converted withdrawal to deposit.');
return true;
}
@@@ -222,28 -209,25 +212,25 @@@
* Output is a deposit from C to B.
* The source account is replaced.
*
- * @param TransactionJournal $journal
- *
- * @return bool
* @throws FireflyException
- * @throws JsonException
*/
-- private function convertTransferArray(TransactionJournal $journal): bool
++ private function convertTransferArray(TransactionJournal $journal, string $actionValue): bool
{
- $user = $journal->user;
+ $user = $journal->user;
+
// find or create revenue account.
/** @var AccountFactory $factory */
- $factory = app(AccountFactory::class);
+ $factory = app(AccountFactory::class);
$factory->setUser($user);
- $repository = app(AccountRepositoryInterface::class);
+ $repository = app(AccountRepositoryInterface::class);
$repository->setUser($user);
- $sourceAccount = $this->getSourceAccount($journal);
+ $sourceAccount = $this->getSourceAccount($journal);
// 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, which is the source of the new deposit.
- $opposingName = '' === $actionValue ? $sourceAccount->name : $actionValue;
- $opposingName = '' === $this->action->action_value ? $sourceAccount->name : $this->action->action_value;
++ $opposingName = '' === $actionValue ? $sourceAccount->name : $actionValue;
// we check all possible source account types if one exists:
$validTypes = config('firefly.expected_source_types.source.Deposit');
$opposingAccount = $repository->findByName($opposingName, $validTypes);
@@@ -251,22 -235,24 +238,22 @@@
$opposingAccount = $factory->findOrCreate($opposingName, AccountType::REVENUE);
}
- Log::debug(sprintf('ConvertToDeposit. Action value is "%s", revenue name is "%s"', $actionValue, $opposingAccount->name));
+ app('log')->debug(sprintf('ConvertToDeposit. Action value is "%s", revenue name is "%s"', $this->action->action_value, $opposingAccount->name));
// update source transaction(s) to be revenue account
- DB::table('transactions')
+ \DB::table('transactions')
->where('transaction_journal_id', '=', $journal->id)
->where('amount', '<', 0)
- ->update(['account_id' => $opposingAccount->id])
- ;
+ ->update(['account_id' => $opposingAccount->id]);
// change transaction type of journal:
- $newType = TransactionType::whereType(TransactionType::DEPOSIT)->first();
+ $newType = TransactionType::whereType(TransactionType::DEPOSIT)->first();
- DB::table('transaction_journals')
+ \DB::table('transaction_journals')
->where('id', '=', $journal->id)
- ->update(['transaction_type_id' => $newType->id, 'bill_id' => null])
- ;
+ ->update(['transaction_type_id' => $newType->id, 'bill_id' => null]);
- Log::debug('Converted transfer to deposit.');
+ app('log')->debug('Converted transfer to deposit.');
return true;
}
diff --cc app/TransactionRules/Actions/ConvertToTransfer.php
index 7cd5fd887b,323270f35c..559125eced
--- a/app/TransactionRules/Actions/ConvertToTransfer.php
+++ b/app/TransactionRules/Actions/ConvertToTransfer.php
@@@ -35,11 -33,8 +34,9 @@@ use FireflyIII\Models\Transaction
use FireflyIII\Models\TransactionJournal;
use FireflyIII\Models\TransactionType;
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
+use FireflyIII\TransactionRules\Expressions\ActionExpressionEvaluator;
- use Illuminate\Support\Facades\Log;
/**
- *
* Class ConvertToTransfer
*/
class ConvertToTransfer implements ActionInterface
@@@ -49,13 -43,10 +46,11 @@@
/**
* TriggerInterface constructor.
- *
- * @param RuleAction $action
*/
- public function __construct(RuleAction $action)
+ public function __construct(RuleAction $action, ActionExpressionEvaluator $evaluator)
{
-- $this->action = $action;
++ $this->action = $action;
+ $this->evaluator = $evaluator;
}
/**
@@@ -63,20 -55,20 +59,22 @@@
*/
public function actOnArray(array $journal): bool
{
+ $actionValue = $this->evaluator->evaluate($journal);
+
// make object from array (so the data is fresh).
- /** @var TransactionJournal|null $object */
- $object = TransactionJournal::where('user_id', $journal['user_id'])->find($journal['transaction_journal_id']);
+ /** @var null|TransactionJournal $object */
+ $object = TransactionJournal::where('user_id', $journal['user_id'])->find($journal['transaction_journal_id']);
if (null === $object) {
- Log::error(sprintf('Cannot find journal #%d, cannot convert to transfer.', $journal['transaction_journal_id']));
+ app('log')->error(sprintf('Cannot find journal #%d, cannot convert to transfer.', $journal['transaction_journal_id']));
event(new RuleActionFailedOnArray($this->action, $journal, trans('rules.journal_not_found')));
+
return false;
}
- $groupCount = TransactionJournal::where('transaction_group_id', $journal['transaction_group_id'])->count();
+ $groupCount = TransactionJournal::where('transaction_group_id', $journal['transaction_group_id'])->count();
if ($groupCount > 1) {
- Log::error(sprintf('Group #%d has more than one transaction in it, cannot convert to transfer.', $journal['transaction_group_id']));
+ app('log')->error(sprintf('Group #%d has more than one transaction in it, cannot convert to transfer.', $journal['transaction_group_id']));
event(new RuleActionFailedOnArray($this->action, $journal, trans('rules.split_group')));
+
return false;
}
@@@ -109,10 -102,10 +108,10 @@@
$expectedType = $this->getDestinationType($journalId);
// Deposit? Replace source with account with same type as destination.
}
- $opposing = $repository->findByName($actionValue, [$expectedType]);
- $opposing = $repository->findByName($this->action->action_value, [$expectedType]);
++ $opposing = $repository->findByName($actionValue, [$expectedType]);
if (null === $opposing) {
- Log::error(
+ app('log')->error(
sprintf(
'Journal #%d cannot be converted because no valid %s account with name "%s" exists (rule #%d).',
$expectedType,
@@@ -219,19 -205,21 +211,19 @@@
}
// update destination transaction:
- DB::table('transactions')
+ \DB::table('transactions')
->where('transaction_journal_id', '=', $journal->id)
->where('amount', '>', 0)
- ->update(['account_id' => $opposing->id])
- ;
+ ->update(['account_id' => $opposing->id]);
// change transaction type of journal:
- $newType = TransactionType::whereType(TransactionType::TRANSFER)->first();
+ $newType = TransactionType::whereType(TransactionType::TRANSFER)->first();
- DB::table('transaction_journals')
+ \DB::table('transaction_journals')
->where('id', '=', $journal->id)
- ->update(['transaction_type_id' => $newType->id, 'bill_id' => null])
- ;
+ ->update(['transaction_type_id' => $newType->id, 'bill_id' => null]);
- Log::debug('Converted withdrawal to transfer.');
+ app('log')->debug('Converted withdrawal to transfer.');
return true;
}
@@@ -278,19 -260,21 +264,19 @@@
}
// update source transaction:
- DB::table('transactions')
+ \DB::table('transactions')
->where('transaction_journal_id', '=', $journal->id)
->where('amount', '<', 0)
- ->update(['account_id' => $opposing->id])
- ;
+ ->update(['account_id' => $opposing->id]);
// change transaction type of journal:
- $newType = TransactionType::whereType(TransactionType::TRANSFER)->first();
+ $newType = TransactionType::whereType(TransactionType::TRANSFER)->first();
- DB::table('transaction_journals')
+ \DB::table('transaction_journals')
->where('id', '=', $journal->id)
- ->update(['transaction_type_id' => $newType->id, 'bill_id' => null])
- ;
+ ->update(['transaction_type_id' => $newType->id, 'bill_id' => null]);
- Log::debug('Converted deposit to transfer.');
+ app('log')->debug('Converted deposit to transfer.');
return true;
}
diff --cc app/TransactionRules/Actions/ConvertToWithdrawal.php
index 73b04b0ac8,d7b9684826..14725d1320
--- a/app/TransactionRules/Actions/ConvertToWithdrawal.php
+++ b/app/TransactionRules/Actions/ConvertToWithdrawal.php
@@@ -36,12 -34,8 +35,9 @@@ use FireflyIII\Models\Transaction
use FireflyIII\Models\TransactionJournal;
use FireflyIII\Models\TransactionType;
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
+use FireflyIII\TransactionRules\Expressions\ActionExpressionEvaluator;
- use Illuminate\Support\Facades\Log;
- use JsonException;
/**
- *
* Class ConvertToWithdrawal
*/
class ConvertToWithdrawal implements ActionInterface
@@@ -51,28 -44,21 +47,24 @@@
/**
* TriggerInterface constructor.
- *
- * @param RuleAction $action
*/
- public function __construct(RuleAction $action)
+ public function __construct(RuleAction $action, ActionExpressionEvaluator $evaluator)
{
$this->action = $action;
+ $this->evaluator = $evaluator;
}
- /**
- * @inheritDoc
- */
public function actOnArray(array $journal): bool
{
+ $actionValue = $this->evaluator->evaluate($journal);
+
// make object from array (so the data is fresh).
- /** @var TransactionJournal|null $object */
- $object = TransactionJournal::where('user_id', $journal['user_id'])->find($journal['transaction_journal_id']);
+ /** @var null|TransactionJournal $object */
+ $object = TransactionJournal::where('user_id', $journal['user_id'])->find($journal['transaction_journal_id']);
if (null === $object) {
- Log::error(sprintf('Cannot find journal #%d, cannot convert to withdrawal.', $journal['transaction_journal_id']));
+ app('log')->error(sprintf('Cannot find journal #%d, cannot convert to withdrawal.', $journal['transaction_journal_id']));
event(new RuleActionFailedOnArray($this->action, $journal, trans('rules.journal_not_found')));
+
return false;
}
$groupCount = TransactionJournal::where('transaction_group_id', $journal['transaction_group_id'])->count();
@@@ -93,57 -82,54 +88,54 @@@
return false;
}
if (TransactionType::DEPOSIT === $type) {
- Log::debug('Going to transform a deposit to a withdrawal.');
+ app('log')->debug('Going to transform a deposit to a withdrawal.');
+
try {
- $res = $this->convertDepositArray($object);
+ $res = $this->convertDepositArray($object, $actionValue);
- } catch (JsonException | FireflyException $e) {
- Log::debug('Could not convert transfer to deposit.');
- Log::error($e->getMessage());
+ } catch (FireflyException $e) {
+ app('log')->debug('Could not convert transfer to deposit.');
+ app('log')->error($e->getMessage());
event(new RuleActionFailedOnArray($this->action, $journal, trans('rules.complex_error')));
+
return false;
}
event(new TriggeredAuditLog($this->action->rule, $object, 'update_transaction_type', TransactionType::DEPOSIT, TransactionType::WITHDRAWAL));
return $res;
}
- if (TransactionType::TRANSFER === $type) {
- Log::debug('Going to transform a transfer to a withdrawal.');
+ // can only be transfer at this point.
+ app('log')->debug('Going to transform a transfer to a withdrawal.');
- try {
- $res = $this->convertTransferArray($object, $actionValue);
- } catch (JsonException | FireflyException $e) {
- Log::debug('Could not convert transfer to deposit.');
- Log::error($e->getMessage());
- event(new RuleActionFailedOnArray($this->action, $journal, trans('rules.complex_error')));
- return false;
- }
- event(new TriggeredAuditLog($this->action->rule, $object, 'update_transaction_type', TransactionType::TRANSFER, TransactionType::WITHDRAWAL));
+ try {
- $res = $this->convertTransferArray($object);
++ $res = $this->convertTransferArray($object, $actionValue);
+ } catch (FireflyException $e) {
+ app('log')->debug('Could not convert transfer to deposit.');
+ app('log')->error($e->getMessage());
+ event(new RuleActionFailedOnArray($this->action, $journal, trans('rules.complex_error')));
- return $res;
+ return false;
}
- event(new RuleActionFailedOnArray($this->action, $journal, trans('rules.unsupported_transaction_type_withdrawal', ['type' => $type])));
- return false;
+ event(new TriggeredAuditLog($this->action->rule, $object, 'update_transaction_type', TransactionType::TRANSFER, TransactionType::WITHDRAWAL));
+
+ return $res;
}
/**
- * @param TransactionJournal $journal
- *
- * @return bool
* @throws FireflyException
- * @throws JsonException
*/
- private function convertDepositArray(TransactionJournal $journal): bool
+ private function convertDepositArray(TransactionJournal $journal, string $actionValue): bool
{
- $user = $journal->user;
+ $user = $journal->user;
+
/** @var AccountFactory $factory */
- $factory = app(AccountFactory::class);
+ $factory = app(AccountFactory::class);
$factory->setUser($user);
- $repository = app(AccountRepositoryInterface::class);
+ $repository = app(AccountRepositoryInterface::class);
$repository->setUser($user);
- $sourceAccount = $this->getSourceAccount($journal);
- $destAccount = $this->getDestinationAccount($journal);
+ $sourceAccount = $this->getSourceAccount($journal);
+ $destAccount = $this->getDestinationAccount($journal);
// get the action value, or use the original source name in case the action value is empty:
// this becomes a new or existing (expense) account, which is the destination of the new withdrawal.
@@@ -155,27 -141,30 +147,27 @@@
$opposingAccount = $factory->findOrCreate($opposingName, AccountType::EXPENSE);
}
- Log::debug(sprintf('ConvertToWithdrawal. Action value is "%s", expense name is "%s"', $actionValue, $opposingName));
- app('log')->debug(sprintf('ConvertToWithdrawal. Action value is "%s", expense name is "%s"', $this->action->action_value, $opposingName));
++ app('log')->debug(sprintf('ConvertToWithdrawal. Action value is "%s", expense name is "%s"', $actionValue, $opposingName));
// update source transaction(s) to be the original destination account
- DB::table('transactions')
+ \DB::table('transactions')
->where('transaction_journal_id', '=', $journal->id)
->where('amount', '<', 0)
- ->update(['account_id' => $destAccount->id])
- ;
+ ->update(['account_id' => $destAccount->id]);
// update destination transaction(s) to be new expense account.
- DB::table('transactions')
+ \DB::table('transactions')
->where('transaction_journal_id', '=', $journal->id)
->where('amount', '>', 0)
- ->update(['account_id' => $opposingAccount->id])
- ;
+ ->update(['account_id' => $opposingAccount->id]);
// change transaction type of journal:
- $newType = TransactionType::whereType(TransactionType::WITHDRAWAL)->first();
- DB::table('transaction_journals')
+ $newType = TransactionType::whereType(TransactionType::WITHDRAWAL)->first();
+ \DB::table('transaction_journals')
->where('id', '=', $journal->id)
- ->update(['transaction_type_id' => $newType->id])
- ;
+ ->update(['transaction_type_id' => $newType->id]);
- Log::debug('Converted deposit to withdrawal.');
+ app('log')->debug('Converted deposit to withdrawal.');
return true;
}
@@@ -216,28 -201,25 +204,25 @@@
* Input is a transfer from A to B.
* Output is a withdrawal from A to C.
*
- * @param TransactionJournal $journal
- *
- * @return bool
* @throws FireflyException
- * @throws JsonException
*/
- private function convertTransferArray(TransactionJournal $journal): bool
+ private function convertTransferArray(TransactionJournal $journal, string $actionValue): bool
{
// find or create expense account.
- $user = $journal->user;
+ $user = $journal->user;
+
/** @var AccountFactory $factory */
- $factory = app(AccountFactory::class);
+ $factory = app(AccountFactory::class);
$factory->setUser($user);
- $repository = app(AccountRepositoryInterface::class);
+ $repository = app(AccountRepositoryInterface::class);
$repository->setUser($user);
- $destAccount = $this->getDestinationAccount($journal);
+ $destAccount = $this->getDestinationAccount($journal);
// get the action value, or use the original source name in case the action value is empty:
// this becomes a new or existing (expense) account, which is the destination of the new withdrawal.
- $opposingName = '' === $actionValue ? $destAccount->name : $actionValue;
- $opposingName = '' === $this->action->action_value ? $destAccount->name : $this->action->action_value;
++ $opposingName = '' === $actionValue ? $destAccount->name : $actionValue;
// we check all possible source account types if one exists:
$validTypes = config('firefly.expected_source_types.destination.Withdrawal');
$opposingAccount = $repository->findByName($opposingName, $validTypes);
@@@ -245,21 -227,23 +230,21 @@@
$opposingAccount = $factory->findOrCreate($opposingName, AccountType::EXPENSE);
}
- Log::debug(sprintf('ConvertToWithdrawal. Action value is "%s", destination name is "%s"', $actionValue, $opposingName));
- app('log')->debug(sprintf('ConvertToWithdrawal. Action value is "%s", destination name is "%s"', $this->action->action_value, $opposingName));
++ app('log')->debug(sprintf('ConvertToWithdrawal. Action value is "%s", destination name is "%s"', $actionValue, $opposingName));
// update destination transaction(s) to be new expense account.
- DB::table('transactions')
+ \DB::table('transactions')
->where('transaction_journal_id', '=', $journal->id)
->where('amount', '>', 0)
- ->update(['account_id' => $opposingAccount->id])
- ;
+ ->update(['account_id' => $opposingAccount->id]);
// change transaction type of journal:
- $newType = TransactionType::whereType(TransactionType::WITHDRAWAL)->first();
- DB::table('transaction_journals')
+ $newType = TransactionType::whereType(TransactionType::WITHDRAWAL)->first();
+ \DB::table('transaction_journals')
->where('id', '=', $journal->id)
- ->update(['transaction_type_id' => $newType->id])
- ;
+ ->update(['transaction_type_id' => $newType->id]);
- Log::debug('Converted transfer to withdrawal.');
+ app('log')->debug('Converted transfer to withdrawal.');
return true;
}
diff --cc app/TransactionRules/Actions/LinkToBill.php
index 2b817077c6,f9e0406d34..677a3d2f46
--- a/app/TransactionRules/Actions/LinkToBill.php
+++ b/app/TransactionRules/Actions/LinkToBill.php
@@@ -31,9 -29,7 +30,8 @@@ use FireflyIII\Models\RuleAction
use FireflyIII\Models\TransactionJournal;
use FireflyIII\Models\TransactionType;
use FireflyIII\Repositories\Bill\BillRepositoryInterface;
+use FireflyIII\TransactionRules\Expressions\ActionExpressionEvaluator;
use FireflyIII\User;
- use Illuminate\Support\Facades\Log;
/**
* Class LinkToBill.
@@@ -45,33 -40,29 +43,29 @@@ class LinkToBill implements ActionInter
/**
* TriggerInterface constructor.
- *
- *
- * @param RuleAction $action
*/
- public function __construct(RuleAction $action)
+ public function __construct(RuleAction $action, ActionExpressionEvaluator $evaluator)
{
$this->action = $action;
+ $this->evaluator = $evaluator;
}
- /**
- * @inheritDoc
- */
public function actOnArray(array $journal): bool
{
- $user = User::find($journal['user_id']);
+ /** @var User $user */
+ $user = User::find($journal['user_id']);
+
/** @var BillRepositoryInterface $repository */
$repository = app(BillRepositoryInterface::class);
$repository->setUser($user);
- $billName = $this->evaluator->evaluate($journal);
- $bill = $repository->findByName($billName);
- $billName = (string)$this->action->action_value;
++ $billName = $this->evaluator->evaluate($journal);
+ $bill = $repository->findByName($billName);
- if (null !== $bill && $journal['transaction_type_type'] === TransactionType::WITHDRAWAL) {
- $count = DB::table('transaction_journals')->where('id', '=', $journal['transaction_journal_id'])
+ if (null !== $bill && TransactionType::WITHDRAWAL === $journal['transaction_type_type']) {
+ $count = \DB::table('transaction_journals')->where('id', '=', $journal['transaction_journal_id'])
- ->where('bill_id', $bill->id)->count()
- ;
+ ->where('bill_id', $bill->id)->count();
if (0 !== $count) {
- Log::error(
+ app('log')->error(
sprintf(
'RuleAction LinkToBill could not set the bill of journal #%d to bill "%s": already set.',
$journal['transaction_journal_id'],
@@@ -82,11 -74,11 +77,10 @@@
return false;
}
-
- DB::table('transaction_journals')
+ \DB::table('transaction_journals')
->where('id', '=', $journal['transaction_journal_id'])
- ->update(['bill_id' => $bill->id])
- ;
+ ->update(['bill_id' => $bill->id]);
- Log::debug(
+ app('log')->debug(
sprintf('RuleAction LinkToBill set the bill of journal #%d to bill #%d ("%s").', $journal['transaction_journal_id'], $bill->id, $bill->name)
);
diff --cc app/TransactionRules/Actions/PrependDescription.php
index ef8a36931c,f00db5d501..ba407f4cdb
--- a/app/TransactionRules/Actions/PrependDescription.php
+++ b/app/TransactionRules/Actions/PrependDescription.php
@@@ -40,25 -36,17 +39,20 @@@ class PrependDescription implements Act
/**
* TriggerInterface constructor.
- *
- * @param RuleAction $action
*/
- public function __construct(RuleAction $action)
+ public function __construct(RuleAction $action, ActionExpressionEvaluator $evaluator)
{
$this->action = $action;
+ $this->evaluator = $evaluator;
}
- /**
- * @inheritDoc
- */
public function actOnArray(array $journal): bool
{
+ $actionValue = $this->evaluator->evaluate($journal);
+
$before = $journal['description'];
- $after = sprintf('%s%s', $this->action->action_value, $journal['description']);
+ $after = sprintf('%s%s', $actionValue, $journal['description']);
- DB::table('transaction_journals')->where('id', $journal['transaction_journal_id'])->limit(1)->update(['description' => $after]);
+ \DB::table('transaction_journals')->where('id', $journal['transaction_journal_id'])->limit(1)->update(['description' => $after]);
// journal
/** @var TransactionJournal $object */
diff --cc app/TransactionRules/Actions/PrependNotes.php
index 9f86739067,7bbfd70f71..d82cbe43b0
--- a/app/TransactionRules/Actions/PrependNotes.php
+++ b/app/TransactionRules/Actions/PrependNotes.php
@@@ -28,8 -27,6 +28,7 @@@ use FireflyIII\Events\TriggeredAuditLog
use FireflyIII\Models\Note;
use FireflyIII\Models\RuleAction;
use FireflyIII\Models\TransactionJournal;
+use FireflyIII\TransactionRules\Expressions\ActionExpressionEvaluator;
- use Illuminate\Support\Facades\Log;
/**
* Class PrependNotes.
@@@ -41,34 -37,27 +40,28 @@@ class PrependNotes implements ActionInt
/**
* TriggerInterface constructor.
- *
- * @param RuleAction $action
*/
- public function __construct(RuleAction $action)
+ public function __construct(RuleAction $action, ActionExpressionEvaluator $evaluator)
{
-- $this->action = $action;
++ $this->action = $action;
+ $this->evaluator = $evaluator;
}
- /**
- * @inheritDoc
- */
public function actOnArray(array $journal): bool
{
- $actionValue = $this->evaluator->evaluate($journal);
-
- $dbNote = Note::where('noteable_id', (int)$journal['transaction_journal_id'])
++ $actionValue = $this->evaluator->evaluate($journal);
+ $dbNote = Note::where('noteable_id', (int)$journal['transaction_journal_id'])
->where('noteable_type', TransactionJournal::class)
- ->first(['notes.*'])
- ;
+ ->first(['notes.*']);
if (null === $dbNote) {
$dbNote = new Note();
$dbNote->noteable_id = (int)$journal['transaction_journal_id'];
$dbNote->noteable_type = TransactionJournal::class;
$dbNote->text = '';
}
- $before = $dbNote->text;
- Log::debug(sprintf('RuleAction PrependNotes prepended "%s" to "%s".', $actionValue, $dbNote->text));
+ $before = $dbNote->text;
- app('log')->debug(sprintf('RuleAction PrependNotes prepended "%s" to "%s".', $this->action->action_value, $dbNote->text));
- $text = sprintf('%s%s', $this->action->action_value, $dbNote->text);
++ app('log')->debug(sprintf('RuleAction PrependNotes prepended "%s" to "%s".', $actionValue, $dbNote->text));
+ $text = sprintf('%s%s', $actionValue, $dbNote->text);
$dbNote->text = $text;
$dbNote->save();
diff --cc app/TransactionRules/Actions/RemoveTag.php
index b67a10aaa4,55ef91531a..20693779bf
--- a/app/TransactionRules/Actions/RemoveTag.php
+++ b/app/TransactionRules/Actions/RemoveTag.php
@@@ -29,9 -27,7 +28,8 @@@ use FireflyIII\Events\Model\Rule\RuleAc
use FireflyIII\Events\TriggeredAuditLog;
use FireflyIII\Models\RuleAction;
use FireflyIII\Models\TransactionJournal;
+use FireflyIII\TransactionRules\Expressions\ActionExpressionEvaluator;
use FireflyIII\User;
- use Illuminate\Support\Facades\Log;
/**
* Class RemoveTag.
@@@ -43,27 -38,23 +41,24 @@@ class RemoveTag implements ActionInterf
/**
* TriggerInterface constructor.
- *
- * @param RuleAction $action
*/
- public function __construct(RuleAction $action)
+ public function __construct(RuleAction $action, ActionExpressionEvaluator $evaluator)
{
$this->action = $action;
+ $this->evaluator = $evaluator;
}
- /**
- * @inheritDoc
- */
public function actOnArray(array $journal): bool
{
// if tag does not exist, no need to continue:
- $name = $this->evaluator->evaluate($journal);
- $user = User::find($journal['user_id']);
- $tag = $user->tags()->where('tag', $name)->first();
- $name = $this->action->action_value;
++ $name = $this->evaluator->evaluate($journal);
+
+ /** @var User $user */
+ $user = User::find($journal['user_id']);
+ $tag = $user->tags()->where('tag', $name)->first();
if (null === $tag) {
- Log::debug(
+ app('log')->debug(
sprintf('RuleAction RemoveTag tried to remove tag "%s" from journal #%d but no such tag exists.', $name, $journal['transaction_journal_id'])
);
event(new RuleActionFailedOnArray($this->action, $journal, trans('rules.cannot_find_tag', ['tag' => $name])));
@@@ -78,11 -71,12 +75,11 @@@
return false;
}
- Log::debug(sprintf('RuleAction RemoveTag removed tag #%d ("%s") from journal #%d.', $tag->id, $tag->tag, $journal['transaction_journal_id']));
- DB::table('tag_transaction_journal')
+ app('log')->debug(sprintf('RuleAction RemoveTag removed tag #%d ("%s") from journal #%d.', $tag->id, $tag->tag, $journal['transaction_journal_id']));
+ \DB::table('tag_transaction_journal')
->where('transaction_journal_id', $journal['transaction_journal_id'])
->where('tag_id', $tag->id)
- ->delete()
- ;
+ ->delete();
/** @var TransactionJournal $object */
$object = TransactionJournal::where('user_id', $journal['user_id'])->find($journal['transaction_journal_id']);
diff --cc app/TransactionRules/Actions/SetBudget.php
index 9a88f49257,260ea63cb5..5dc595de3d
--- a/app/TransactionRules/Actions/SetBudget.php
+++ b/app/TransactionRules/Actions/SetBudget.php
@@@ -30,9 -28,7 +29,8 @@@ use FireflyIII\Events\TriggeredAuditLog
use FireflyIII\Models\RuleAction;
use FireflyIII\Models\TransactionJournal;
use FireflyIII\Models\TransactionType;
+use FireflyIII\TransactionRules\Expressions\ActionExpressionEvaluator;
use FireflyIII\User;
- use Illuminate\Support\Facades\Log;
/**
* Class SetBudget.
@@@ -44,26 -39,21 +42,22 @@@ class SetBudget implements ActionInterf
/**
* TriggerInterface constructor.
- *
- * @param RuleAction $action
*/
- public function __construct(RuleAction $action)
+ public function __construct(RuleAction $action, ActionExpressionEvaluator $evaluator)
{
$this->action = $action;
+ $this->evaluator = $evaluator;
}
- /**
- * @inheritDoc
- */
public function actOnArray(array $journal): bool
{
- $user = User::find($journal['user_id']);
- $search = $this->evaluator->evaluate($journal);
+ /** @var User $user */
+ $user = User::find($journal['user_id']);
- $search = $this->action->action_value;
++ $search = $this->evaluator->evaluate($journal);
- $budget = $user->budgets()->where('name', $search)->first();
+ $budget = $user->budgets()->where('name', $search)->first();
if (null === $budget) {
- Log::debug(
+ app('log')->debug(
sprintf(
'RuleAction SetBudget could not set budget of journal #%d to "%s" because no such budget exists.',
$journal['transaction_journal_id'],
diff --cc app/TransactionRules/Actions/SetCategory.php
index a4ed08d7d6,8785ade043..fe8309647c
--- a/app/TransactionRules/Actions/SetCategory.php
+++ b/app/TransactionRules/Actions/SetCategory.php
@@@ -30,9 -28,7 +29,8 @@@ use FireflyIII\Events\TriggeredAuditLog
use FireflyIII\Factory\CategoryFactory;
use FireflyIII\Models\RuleAction;
use FireflyIII\Models\TransactionJournal;
+use FireflyIII\TransactionRules\Expressions\ActionExpressionEvaluator;
use FireflyIII\User;
- use Illuminate\Support\Facades\Log;
/**
* Class SetCategory.
@@@ -44,25 -39,21 +42,22 @@@ class SetCategory implements ActionInte
/**
* TriggerInterface constructor.
- *
- * @param RuleAction $action
*/
- public function __construct(RuleAction $action)
+ public function __construct(RuleAction $action, ActionExpressionEvaluator $evaluator)
{
$this->action = $action;
+ $this->evaluator = $evaluator;
}
- /**
- * @inheritDoc
- */
public function actOnArray(array $journal): bool
{
- $user = User::find($journal['user_id']);
- $search = $this->evaluator->evaluate($journal);
+ /** @var null|User $user */
+ $user = User::find($journal['user_id']);
- $search = $this->action->action_value;
++ $search = $this->evaluator->evaluate($journal);
if (null === $user) {
- Log::error(sprintf('Journal has no valid user ID so action SetCategory("%s") cannot be applied', $search), $journal);
+ app('log')->error(sprintf('Journal has no valid user ID so action SetCategory("%s") cannot be applied', $search), $journal);
event(new RuleActionFailedOnArray($this->action, $journal, trans('rules.no_such_journal')));
+
return false;
}
diff --cc app/TransactionRules/Actions/SetDescription.php
index 799a02ed70,3d5e392014..8ce0d001b5
--- a/app/TransactionRules/Actions/SetDescription.php
+++ b/app/TransactionRules/Actions/SetDescription.php
@@@ -27,9 -26,6 +27,7 @@@ namespace FireflyIII\TransactionRules\A
use FireflyIII\Events\TriggeredAuditLog;
use FireflyIII\Models\RuleAction;
use FireflyIII\Models\TransactionJournal;
+use FireflyIII\TransactionRules\Expressions\ActionExpressionEvaluator;
- use Illuminate\Support\Facades\Log;
/**
* Class SetDescription.
@@@ -41,30 -36,24 +39,25 @@@ class SetDescription implements ActionI
/**
* TriggerInterface constructor.
- *
- * @param RuleAction $action
*/
- public function __construct(RuleAction $action)
+ public function __construct(RuleAction $action, ActionExpressionEvaluator $evaluator)
{
$this->action = $action;
+ $this->evaluator = $evaluator;
}
- /**
- * @inheritDoc
- */
public function actOnArray(array $journal): bool
{
/** @var TransactionJournal $object */
$object = TransactionJournal::where('user_id', $journal['user_id'])->find($journal['transaction_journal_id']);
- $before = $object->description;
+ $before = $journal['description'];
+ $after = $this->evaluator->evaluate($journal);
- DB::table('transaction_journals')
+ \DB::table('transaction_journals')
->where('id', '=', $journal['transaction_journal_id'])
- ->update(['description' => $after]);
- ->update(['description' => $this->action->action_value])
- ;
++ ->update(['description' => $this->action->action_value]);
- Log::debug(
+ app('log')->debug(
sprintf(
'RuleAction SetDescription changed the description of journal #%d from "%s" to "%s".',
$journal['transaction_journal_id'],
diff --cc app/TransactionRules/Actions/SetDestinationAccount.php
index e4c2688831,455acb4dfd..6521e02e94
--- a/app/TransactionRules/Actions/SetDestinationAccount.php
+++ b/app/TransactionRules/Actions/SetDestinationAccount.php
@@@ -33,9 -31,7 +32,8 @@@ use FireflyIII\Models\Transaction
use FireflyIII\Models\TransactionJournal;
use FireflyIII\Models\TransactionType;
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
+use FireflyIII\TransactionRules\Expressions\ActionExpressionEvaluator;
use FireflyIII\User;
- use Illuminate\Support\Facades\Log;
/**
* Class SetDestinationAccount.
@@@ -48,24 -43,18 +46,21 @@@ class SetDestinationAccount implements
/**
* TriggerInterface constructor.
- *
- * @param RuleAction $action
*/
- public function __construct(RuleAction $action)
+ public function __construct(RuleAction $action, ActionExpressionEvaluator $evaluator)
{
$this->action = $action;
+ $this->evaluator = $evaluator;
}
- /**
- * @inheritDoc
- */
public function actOnArray(array $journal): bool
{
+ $accountName = $this->evaluator->evaluate($journal);
- $user = User::find($journal['user_id']);
- $type = $journal['transaction_type_type'];
- /** @var TransactionJournal|null $object */
++
+ /** @var User $user */
+ $user = User::find($journal['user_id']);
+
+ /** @var null|TransactionJournal $object */
$object = $user->transactionJournals()->find((int)$journal['transaction_journal_id']);
$this->repository = app(AccountRepositoryInterface::class);
@@@ -78,16 -68,17 +74,17 @@@
$this->repository->setUser($user);
// if this is a transfer or a deposit, the new destination account must be an asset account or a default account, and it MUST exist:
- $newAccount = $this->findAssetAccount($type, $accountName);
- $newAccount = $this->findAssetAccount($type);
++ $newAccount = $this->findAssetAccount($type, $accountName);
if ((TransactionType::DEPOSIT === $type || TransactionType::TRANSFER === $type) && null === $newAccount) {
- Log::error(
+ app('log')->error(
sprintf(
'Cant change destination account of journal #%d because no asset account with name "%s" exists.',
$object->id,
- $this->action->action_value
+ $accountName
)
);
- event(new RuleActionFailedOnArray($this->action, $journal, trans('rules.cannot_find_asset', ['name' => $this->action->action_value])));
+ event(new RuleActionFailedOnArray($this->action, $journal, trans('rules.cannot_find_asset', ['name' => $accountName])));
+
return false;
}
@@@ -121,49 -115,42 +121,41 @@@
// if this is a withdrawal, the new destination account must be a expense account and may be created:
// or it is a liability, in which case it must be returned.
if (TransactionType::WITHDRAWAL === $type) {
- $newAccount = $this->findWithdrawalDestinationAccount();
+ $newAccount = $this->findWithdrawalDestinationAccount($accountName);
}
- Log::debug(sprintf('New destination account is #%d ("%s").', $newAccount->id, $newAccount->name));
+ app('log')->debug(sprintf('New destination account is #%d ("%s").', $newAccount->id, $newAccount->name));
event(new TriggeredAuditLog($this->action->rule, $object, 'set_destination', null, $newAccount->name));
// update destination transaction with new destination account:
- DB::table('transactions')
+ \DB::table('transactions')
->where('transaction_journal_id', '=', $object->id)
->where('amount', '>', 0)
- ->update(['account_id' => $newAccount->id])
- ;
+ ->update(['account_id' => $newAccount->id]);
- Log::debug(sprintf('Updated journal #%d (group #%d) and gave it new destination account ID.', $object->id, $object->transaction_group_id));
+ app('log')->debug(sprintf('Updated journal #%d (group #%d) and gave it new destination account ID.', $object->id, $object->transaction_group_id));
return true;
}
- /**
- * @param string $type
- *
- * @return Account|null
- */
- private function findAssetAccount(string $type): ?Account
+ private function findAssetAccount(string $type, string $accountName): ?Account
{
// switch on type:
$allowed = config(sprintf('firefly.expected_source_types.destination.%s', $type));
$allowed = is_array($allowed) ? $allowed : [];
- Log::debug(sprintf('Check config for expected_source_types.destination.%s, result is', $type), $allowed);
+ app('log')->debug(sprintf('Check config for expected_source_types.destination.%s, result is', $type), $allowed);
- return $this->repository->findByName($this->action->action_value, $allowed);
+ return $this->repository->findByName($accountName, $allowed);
}
- /**
- * @return Account
- */
- private function findWithdrawalDestinationAccount(): Account
+ private function findWithdrawalDestinationAccount(string $accountName): Account
{
$allowed = config('firefly.expected_source_types.destination.Withdrawal');
- $account = $this->repository->findByName($this->action->action_value, $allowed);
+ $account = $this->repository->findByName($accountName, $allowed);
if (null === $account) {
$data = [
- 'name' => $this->action->action_value,
+ 'name' => $accountName,
'account_type_name' => 'expense',
'account_type_id' => null,
'virtual_balance' => 0,
diff --cc app/TransactionRules/Actions/SetNotes.php
index 28926ba319,260ccfe4d4..8abdf02f8c
--- a/app/TransactionRules/Actions/SetNotes.php
+++ b/app/TransactionRules/Actions/SetNotes.php
@@@ -28,35 -27,27 +28,29 @@@ use FireflyIII\Events\TriggeredAuditLog
use FireflyIII\Models\Note;
use FireflyIII\Models\RuleAction;
use FireflyIII\Models\TransactionJournal;
+use FireflyIII\TransactionRules\Expressions\ActionExpressionEvaluator;
- use Illuminate\Support\Facades\Log;
/**
* Class SetNotes.
*/
class SetNotes implements ActionInterface
{
- private RuleACtion $action;
- private RuleAction $action;
++ private RuleAction $action;
+ private ActionExpressionEvaluator $evaluator;
/**
* TriggerInterface constructor.
- *
- * @param RuleAction $action
*/
- public function __construct(RuleAction $action)
+ public function __construct(RuleAction $action, ActionExpressionEvaluator $evaluator)
{
$this->action = $action;
+ $this->evaluator = $evaluator;
}
- /**
- * @inheritDoc
- */
public function actOnArray(array $journal): bool
{
- $dbNote = Note::where('noteable_id', $journal['transaction_journal_id'])
+ $dbNote = Note::where('noteable_id', $journal['transaction_journal_id'])
- ->where('noteable_type', TransactionJournal::class)->first()
- ;
+ ->where('noteable_type', TransactionJournal::class)->first();
if (null === $dbNote) {
$dbNote = new Note();
$dbNote->noteable_id = $journal['transaction_journal_id'];
@@@ -64,11 -55,10 +58,11 @@@
$dbNote->text = '';
}
$oldNotes = $dbNote->text;
- $dbNote->text = $this->action->action_value;
+ $newNotes = $this->evaluator->evaluate($journal);
+ $dbNote->text = $newNotes;
$dbNote->save();
- Log::debug(
+ app('log')->debug(
sprintf(
'RuleAction SetNotes changed the notes of journal #%d from "%s" to "%s".',
$journal['transaction_journal_id'],
@@@ -78,9 -68,9 +72,9 @@@
);
/** @var TransactionJournal $object */
- $object = TransactionJournal::where('user_id', $journal['user_id'])->find($journal['transaction_journal_id']);
+ $object = TransactionJournal::where('user_id', $journal['user_id'])->find($journal['transaction_journal_id']);
- event(new TriggeredAuditLog($this->action->rule, $object, 'update_notes', $oldNotes, $this->action->action_value));
+ event(new TriggeredAuditLog($this->action->rule, $object, 'update_notes', $oldNotes, $newNotes));
return true;
}
diff --cc app/TransactionRules/Actions/SetSourceAccount.php
index 8a2e1c326b,aafe75569b..dc195b9d61
--- a/app/TransactionRules/Actions/SetSourceAccount.php
+++ b/app/TransactionRules/Actions/SetSourceAccount.php
@@@ -33,9 -31,7 +32,8 @@@ use FireflyIII\Models\Transaction
use FireflyIII\Models\TransactionJournal;
use FireflyIII\Models\TransactionType;
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
+use FireflyIII\TransactionRules\Expressions\ActionExpressionEvaluator;
use FireflyIII\User;
- use Illuminate\Support\Facades\Log;
/**
* Class SetSourceAccount.
@@@ -48,24 -43,18 +46,21 @@@ class SetSourceAccount implements Actio
/**
* TriggerInterface constructor.
- *
- * @param RuleAction $action
*/
- public function __construct(RuleAction $action)
+ public function __construct(RuleAction $action, ActionExpressionEvaluator $evaluator)
{
$this->action = $action;
+ $this->evaluator = $evaluator;
}
- /**
- * @inheritDoc
- */
public function actOnArray(array $journal): bool
{
- $user = User::find($journal['user_id']);
- $type = $journal['transaction_type_type'];
- $name = $this->evaluator->evaluate($journal);
- /** @var TransactionJournal|null $object */
++ $accountName = $this->evaluator->evaluate($journal);
++
+ /** @var User $user */
+ $user = User::find($journal['user_id']);
+
+ /** @var null|TransactionJournal $object */
$object = $user->transactionJournals()->find((int)$journal['transaction_journal_id']);
$this->repository = app(AccountRepositoryInterface::class);
if (null === $object) {
@@@ -77,12 -67,13 +73,13 @@@
$this->repository->setUser($user);
// if this is a transfer or a withdrawal, the new source account must be an asset account or a default account, and it MUST exist:
- $newAccount = $this->findAssetAccount($type, $name);
- $newAccount = $this->findAssetAccount($type);
++ $newAccount = $this->findAssetAccount($type, $accountName);
if ((TransactionType::WITHDRAWAL === $type || TransactionType::TRANSFER === $type) && null === $newAccount) {
- Log::error(
- sprintf('Cant change source account of journal #%d because no asset account with name "%s" exists.', $object->id, $name)
+ app('log')->error(
- sprintf('Cant change source account of journal #%d because no asset account with name "%s" exists.', $object->id, $this->action->action_value)
++ sprintf('Cant change source account of journal #%d because no asset account with name "%s" exists.', $object->id, $accountName)
);
- event(new RuleActionFailedOnArray($this->action, $journal, trans('rules.cannot_find_asset', ['name' => $name])));
- event(new RuleActionFailedOnArray($this->action, $journal, trans('rules.cannot_find_asset', ['name' => $this->action->action_value])));
++ event(new RuleActionFailedOnArray($this->action, $journal, trans('rules.cannot_find_asset', ['name' => $accountName])));
+
return false;
}
@@@ -115,16 -109,17 +115,16 @@@
// if this is a deposit, the new source account must be a revenue account and may be created:
// or it's a liability
if (TransactionType::DEPOSIT === $type) {
- $newAccount = $this->findDepositSourceAccount($name);
- $newAccount = $this->findDepositSourceAccount();
++ $newAccount = $this->findDepositSourceAccount($accountName);
}
- Log::debug(sprintf('New source account is #%d ("%s").', $newAccount->id, $newAccount->name));
+ app('log')->debug(sprintf('New source account is #%d ("%s").', $newAccount->id, $newAccount->name));
// update source transaction with new source account:
- DB::table('transactions')
+ \DB::table('transactions')
->where('transaction_journal_id', '=', $object->id)
->where('amount', '<', 0)
- ->update(['account_id' => $newAccount->id])
- ;
+ ->update(['account_id' => $newAccount->id]);
event(new TriggeredAuditLog($this->action->rule, $object, 'set_source', null, $newAccount->name));
@@@ -133,28 -128,20 +133,20 @@@
return true;
}
- /**
- * @param string $type
- *
- * @return Account|null
- */
- private function findAssetAccount(string $type): ?Account
+ private function findAssetAccount(string $type, string $name): ?Account
{
// switch on type:
$allowed = config(sprintf('firefly.expected_source_types.source.%s', $type));
$allowed = is_array($allowed) ? $allowed : [];
- Log::debug(sprintf('Check config for expected_source_types.source.%s, result is', $type), $allowed);
+ app('log')->debug(sprintf('Check config for expected_source_types.source.%s, result is', $type), $allowed);
- return $this->repository->findByName($this->action->action_value, $allowed);
+ return $this->repository->findByName($name, $allowed);
}
- /**
- * @return Account
- */
- private function findDepositSourceAccount(): Account
+ private function findDepositSourceAccount(string $name): Account
{
$allowed = config('firefly.expected_source_types.source.Deposit');
- $account = $this->repository->findByName($this->action->action_value, $allowed);
+ $account = $this->repository->findByName($name, $allowed);
if (null === $account) {
// create new revenue account with this name:
$data = [
diff --cc app/TransactionRules/Actions/UpdatePiggybank.php
index faab1c7f6c,4bd1d1de19..82061f9b10
--- a/app/TransactionRules/Actions/UpdatePiggybank.php
+++ b/app/TransactionRules/Actions/UpdatePiggybank.php
@@@ -30,11 -30,8 +30,9 @@@ use FireflyIII\Models\PiggyBank
use FireflyIII\Models\RuleAction;
use FireflyIII\Models\Transaction;
use FireflyIII\Models\TransactionJournal;
- use FireflyIII\Models\TransactionType;
use FireflyIII\Repositories\PiggyBank\PiggyBankRepositoryInterface;
+use FireflyIII\TransactionRules\Expressions\ActionExpressionEvaluator;
use FireflyIII\User;
- use Illuminate\Support\Facades\Log;
/**
* Class UpdatePiggybank
@@@ -46,35 -42,30 +44,32 @@@ class UpdatePiggybank implements Action
/**
* TriggerInterface constructor.
- *
- * @param RuleAction $action
*/
- public function __construct(RuleAction $action)
+ public function __construct(RuleAction $action, ActionExpressionEvaluator $evaluator)
{
$this->action = $action;
+ $this->evaluator = $evaluator;
}
- /**
- * @inheritDoc
- */
public function actOnArray(array $journal): bool
{
- Log::debug(sprintf('Triggered rule action UpdatePiggybank on journal #%d', $journal['transaction_journal_id']));
+ app('log')->debug(sprintf('Triggered rule action UpdatePiggybank on journal #%d', $journal['transaction_journal_id']));
+ $piggyBankName = $this->evaluator->evaluate($journal);
// refresh the transaction type.
- $user = User::find($journal['user_id']);
+ /** @var User $user */
+ $user = User::find($journal['user_id']);
+
/** @var TransactionJournal $journalObj */
- $journalObj = $user->transactionJournals()->find($journal['transaction_journal_id']);
- $type = TransactionType::find((int)$journalObj->transaction_type_id);
+ $journalObj = $user->transactionJournals()->find($journal['transaction_journal_id']);
- $piggyBank = $this->findPiggyBank($user, $piggyBankName);
- $piggyBank = $this->findPiggyBank($user);
++ $piggyBank = $this->findPiggyBank($user, $piggyBankName);
if (null === $piggyBank) {
- Log::info(
+ app('log')->info(
- sprintf('No piggy bank named "%s", cant execute action #%d of rule #%d', $this->action->action_value, $this->action->id, $this->action->rule_id)
+ sprintf('No piggy bank named "%s", cant execute action #%d of rule #%d', $piggyBankName, $this->action->id, $this->action->rule_id)
);
- event(new RuleActionFailedOnArray($this->action, $journal, trans('rules.cannot_find_piggy', ['name' => $this->action->action_value])));
+ event(new RuleActionFailedOnArray($this->action, $journal, trans('rules.cannot_find_piggy', ['name' => $piggyBankName])));
+
return false;
}
@@@ -134,27 -126,16 +130,16 @@@
$destination->account_id
)
);
- event(new RuleActionFailedOnArray($this->action, $journal, trans('rules.no_link_piggy', ['name' => $this->action->action_value])));
+ event(new RuleActionFailedOnArray($this->action, $journal, trans('rules.no_link_piggy', ['name' => $piggyBankName])));
+
return false;
}
- /**
- * @param User $user
- *
- * @return PiggyBank|null
- */
- private function findPiggyBank(User $user): ?PiggyBank
+ private function findPiggyBank(User $user, string $name): ?PiggyBank
{
- return $user->piggyBanks()->where('piggy_banks.name', $this->action->action_value)->first();
+ return $user->piggyBanks()->where('piggy_banks.name', $name)->first();
}
- /**
- * @param PiggyBank $piggyBank
- * @param TransactionJournal $journal
- * @param string $amount
- *
- * @return void
- */
private function removeAmount(PiggyBank $piggyBank, TransactionJournal $journal, string $amount): void
{
$repository = app(PiggyBankRepositoryInterface::class);
diff --cc app/TransactionRules/Factory/ActionFactory.php
index c53d8c1a67,23780bce6d..a34bf7615b
--- a/app/TransactionRules/Factory/ActionFactory.php
+++ b/app/TransactionRules/Factory/ActionFactory.php
@@@ -28,9 -27,6 +28,8 @@@ use FireflyIII\Exceptions\FireflyExcept
use FireflyIII\Models\RuleAction;
use FireflyIII\Support\Domain;
use FireflyIII\TransactionRules\Actions\ActionInterface;
+use FireflyIII\TransactionRules\Expressions\ActionExpressionEvaluator;
+use FireflyIII\TransactionRules\Factory\ExpressionLanguageFactory;
- use Illuminate\Support\Facades\Log;
/**
* Class ActionFactory can create actions.
@@@ -57,12 -47,9 +50,12 @@@ class ActionFactor
public static function getAction(RuleAction $action): ActionInterface
{
$class = self::getActionClass($action->action_type);
- Log::debug(sprintf('self::getActionClass("%s") = "%s"', $action->action_type, $class));
+ app('log')->debug(sprintf('self::getActionClass("%s") = "%s"', $action->action_type, $class));
- return new $class($action); // @phpstan-ignore-line
+ $expressionLanguage = ExpressionLanguageFactory::get();
+ $expressionEvaluator = new ActionExpressionEvaluator($expressionLanguage, $action->action_value);
+
- return new $class($action, $expressionEvaluator);
++ return new $class($action, $expressionEvaluator); // @phpstan-ignore-line
}
/**
@@@ -81,12 -64,12 +70,12 @@@
$actionTypes = self::getActionTypes();
if (!array_key_exists($actionType, $actionTypes)) {
- throw new FireflyException('No such action exists ("'.e($actionType).'").');
+ throw new FireflyException('No such action exists ("' . e($actionType) . '").');
}
- $class = $actionTypes[$actionType];
+ $class = $actionTypes[$actionType];
if (!class_exists($class)) {
- throw new FireflyException('Could not instantiate class for rule action type "'.e($actionType).'" ('.e($class).').');
+ throw new FireflyException('Could not instantiate class for rule action type "' . e($actionType) . '" (' . e($class) . ').');
}
return $class;
diff --cc composer.json
index d83366f6dc,0fce808942..82186beb6c
--- a/composer.json
+++ b/composer.json
@@@ -1,194 -1,198 +1,198 @@@
{
- "name": "grumpydictator/firefly-iii",
- "description": "Firefly III: a personal finances manager.",
- "keywords": [
- "finance",
- "finances",
- "manager",
- "management",
- "euro",
- "dollar",
- "laravel",
- "money",
- "currency",
- "financials",
- "financial",
- "budgets",
- "administration",
- "tool",
- "tooling",
- "help",
- "helper",
- "assistant",
- "planning",
- "organizing",
- "bills",
- "personal finance",
- "budgets",
- "budgeting",
- "budgeting tool",
- "budgeting application",
- "transactions",
- "self hosted",
- "self-hosted",
- "transfers",
- "management"
- ],
- "license": "AGPL-3.0-or-later",
- "homepage": "https://github.com/firefly-iii/firefly-iii",
- "type": "project",
- "readme": "readme.md",
- "authors": [
- {
- "name": "James Cole",
- "email": "[email protected]",
- "homepage": "https://github.com/firefly-iii",
- "role": "Developer"
- }
- ],
- "support": {
- "email": "[email protected]",
- "issues": "https://github.com/firefly-iii/firefly-iii/issues",
- "forum": "https://gitter.im/firefly-iii/firefly-iii",
- "wiki": "https://github.com/firefly-iii/help/wiki",
- "source": "https://github.com/firefly-iii/firefly-iii",
- "docs": "https://docs.firefly-iii.org/"
- },
- "funding": [
- {
- "type": "patreon",
- "url": "https://www.patreon.com/JC5"
- },
- {
- "type": "github",
- "url": "https://github.com/sponsors/JC5"
- }
- ],
- "require": {
- "php": ">=8.2",
- "ext-bcmath": "*",
- "ext-curl": "*",
- "ext-fileinfo": "*",
- "ext-iconv": "*",
- "ext-intl": "*",
- "ext-json": "*",
- "ext-mbstring": "*",
- "ext-openssl": "*",
- "ext-pdo": "*",
- "ext-session": "*",
- "ext-simplexml": "*",
- "ext-sodium": "*",
- "ext-tokenizer": "*",
- "ext-xml": "*",
- "ext-xmlwriter": "*",
- "bacon/bacon-qr-code": "2.*",
- "diglactic/laravel-breadcrumbs": "^8.1",
- "doctrine/dbal": "3.*",
- "gdbots/query-parser": "^3.0",
- "guzzlehttp/guzzle": "^7.8",
- "jc5/google2fa-laravel": "^2.0",
- "jc5/recovery": "^2",
- "laravel/framework": "^10",
- "laravel/passport": "11.*",
- "laravel/sanctum": "^3.3",
- "laravel/slack-notification-channel": "^3.0",
- "laravel/ui": "^4.2",
- "league/commonmark": "2.*",
- "league/csv": "^9.10",
- "league/fractal": "0.*",
- "nunomaduro/collision": "^7.7",
- "pragmarx/google2fa": "^8.0",
- "predis/predis": "^2.2",
- "psr/log": "<4",
- "ramsey/uuid": "^4.7",
- "rcrowe/twigbridge": "^0.14",
- "spatie/laravel-html": "^3.2",
- "spatie/laravel-ignition": "^2",
- "spatie/period": "^2.4",
- "symfony/expression-language": "^6.3",
- "symfony/http-client": "^6.3",
- "symfony/mailgun-mailer": "^6.3",
- "therobfonz/laravel-mandrill-driver": "^5.0"
- },
- "require-dev": {
- "barryvdh/laravel-ide-helper": "2.*",
- "ergebnis/phpstan-rules": "^2.1",
- "fakerphp/faker": "1.*",
- "filp/whoops": "2.*",
- "mockery/mockery": "1.*",
- "nunomaduro/larastan": "^2.6",
- "phpstan/phpstan": "^1.10",
- "phpstan/phpstan-deprecation-rules": "^1.1",
- "phpstan/phpstan-strict-rules": "^1.4",
- "phpunit/phpunit": "^10",
- "thecodingmachine/phpstan-strict-rules": "^1.0"
- },
- "suggest": {
- },
- "autoload": {
- "psr-4": {
- "FireflyIII\\": "app/",
- "Domain\\": "domain/",
- "Database\\Factories\\": "database/factories/",
- "Database\\Seeders\\": "database/seeders/"
- }
- },
- "autoload-dev": {
- "psr-4": {
- "Tests\\": "tests/"
- }
- },
- "extra": {
- "laravel": {
- "dont-discover": []
- }
- },
- "scripts": {
- "post-root-package-install": [
- "@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
- ],
- "post-create-project-cmd": [
- "@php artisan key:generate"
- ],
- "post-autoload-dump": [
- "Illuminate\\Foundation\\ComposerScripts::postAutoloadDump"
+ "name": "grumpydictator/firefly-iii",
+ "description": "Firefly III: a personal finances manager.",
+ "keywords": [
+ "finance",
+ "finances",
+ "manager",
+ "management",
+ "euro",
+ "dollar",
+ "laravel",
+ "money",
+ "currency",
+ "financials",
+ "financial",
+ "budgets",
+ "administration",
+ "tool",
+ "tooling",
+ "help",
+ "helper",
+ "assistant",
+ "planning",
+ "organizing",
+ "bills",
+ "personal finance",
+ "budgets",
+ "budgeting",
+ "budgeting tool",
+ "budgeting application",
+ "transactions",
+ "self hosted",
+ "self-hosted",
+ "transfers",
+ "management"
],
- "post-update-cmd": [
- "@php artisan config:clear",
- "@php artisan route:clear",
- "@php artisan twig:clean",
- "@php artisan view:clear",
- "@php artisan clear-compiled",
- "@php artisan cache:clear",
- "@php artisan firefly-iii:upgrade-database",
- "@php artisan firefly-iii:correct-database",
- "@php artisan firefly-iii:report-integrity",
- "@php artisan passport:install",
- "@php artisan firefly:instructions update"
+ "license": "AGPL-3.0-or-later",
+ "homepage": "https://github.com/firefly-iii/firefly-iii",
+ "type": "project",
+ "readme": "readme.md",
+ "authors": [
+ {
+ "name": "James Cole",
+ "email": "[email protected]",
+ "homepage": "https://github.com/firefly-iii",
+ "role": "Developer"
+ }
],
- "post-install-cmd": [
- "@php artisan firefly:instructions install",
- "@php artisan firefly-iii:verify-security-alerts"
- ],
- "unit-test": [
- "@php vendor/bin/phpunit -c phpunit.xml --testsuite unit --no-coverage"
- ],
- "integration-test": [
- "@php vendor/bin/phpunit -c phpunit.xml --testsuite integration --no-coverage"
+ "support": {
+ "email": "[email protected]",
+ "issues": "https://github.com/firefly-iii/firefly-iii/issues",
+ "forum": "https://gitter.im/firefly-iii/firefly-iii",
+ "wiki": "https://github.com/firefly-iii/help/wiki",
+ "source": "https://github.com/firefly-iii/firefly-iii",
+ "docs": "https://docs.firefly-iii.org/"
+ },
+ "funding": [
+ {
+ "type": "patreon",
+ "url": "https://www.patreon.com/JC5"
+ },
+ {
+ "type": "github",
+ "url": "https://github.com/sponsors/JC5"
+ }
],
- "coverage": [
- "@php vendor/bin/phpunit -c phpunit.xml --testsuite unit"
- ]
- },
- "config": {
- "platform": {
- "php": "8.2"
+ "require": {
+ "php": ">=8.3",
+ "ext-bcmath": "*",
+ "ext-curl": "*",
+ "ext-fileinfo": "*",
+ "ext-iconv": "*",
+ "ext-intl": "*",
+ "ext-json": "*",
+ "ext-mbstring": "*",
+ "ext-openssl": "*",
+ "ext-pdo": "*",
+ "ext-session": "*",
+ "ext-simplexml": "*",
+ "ext-sodium": "*",
+ "ext-tokenizer": "*",
+ "ext-xml": "*",
+ "ext-xmlwriter": "*",
+ "bacon/bacon-qr-code": "2.*",
+ "diglactic/laravel-breadcrumbs": "^8.1",
+ "doctrine/dbal": "3.*",
+ "gdbots/query-parser": "^3.0",
+ "guzzlehttp/guzzle": "^7.8",
+ "jc5/google2fa-laravel": "^2.0",
+ "jc5/recovery": "^2",
+ "laravel/framework": "^10",
+ "laravel/passport": "11.*",
+ "laravel/sanctum": "^3.3",
+ "laravel/slack-notification-channel": "^3.0",
+ "laravel/ui": "^4.2",
+ "league/commonmark": "2.*",
+ "league/csv": "^9.10",
+ "league/fractal": "0.*",
+ "nunomaduro/collision": "^7.7",
+ "pragmarx/google2fa": "^8.0",
+ "predis/predis": "^2.2",
+ "psr/log": "<4",
+ "ramsey/uuid": "^4.7",
+ "rcrowe/twigbridge": "^0.14",
+ "spatie/laravel-html": "^3.2",
+ "spatie/laravel-ignition": "^2",
+ "spatie/period": "^2.4",
++ "symfony/expression-language": "^6.4",
+ "symfony/http-client": "^7.0",
+ "symfony/mailgun-mailer": "^7.0",
+ "therobfonz/laravel-mandrill-driver": "^5.0"
+ },
+ "require-dev": {
+ "barryvdh/laravel-debugbar": "^3.9",
+ "barryvdh/laravel-ide-helper": "2.*",
+ "ergebnis/phpstan-rules": "^2.1",
+ "fakerphp/faker": "1.*",
+ "filp/whoops": "2.*",
+ "larastan/larastan": "^2",
+ "mockery/mockery": "1.*",
+ "phpstan/extension-installer": "^1.3",
+ "phpstan/phpstan": "^1.10",
+ "phpstan/phpstan-deprecation-rules": "^1.1",
+ "phpstan/phpstan-strict-rules": "^1.4",
+ "phpunit/phpunit": "^10",
+ "thecodingmachine/phpstan-strict-rules": "^1.0"
+ },
- "suggest": {
- },
++ "suggest": {},
+ "autoload": {
+ "psr-4": {
+ "FireflyIII\\": "app/",
+ "Domain\\": "domain/",
+ "Database\\Factories\\": "database/factories/",
+ "Database\\Seeders\\": "database/seeders/"
+ }
+ },
+ "autoload-dev": {
+ "psr-4": {
+ "Tests\\": "tests/"
+ }
+ },
+ "extra": {
+ "laravel": {
+ "dont-discover": []
+ },
+ "phpstan": {
+ "includes": [
+ "extension.neon"
+ ]
+ }
+ },
+ "scripts": {
+ "post-root-package-install": [
+ "@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
+ ],
+ "post-create-project-cmd": [
+ "@php artisan key:generate"
+ ],
+ "post-autoload-dump": [
+ "Illuminate\\Foundation\\ComposerScripts::postAutoloadDump"
+ ],
+ "post-update-cmd": [
+ "@php artisan config:clear",
+ "@php artisan route:clear",
+ "@php artisan twig:clean",
+ "@php artisan view:clear",
+ "@php artisan clear-compiled",
+ "@php artisan cache:clear",
+ "@php artisan firefly-iii:upgrade-database",
+ "@php artisan firefly-iii:correct-database",
+ "@php artisan firefly-iii:report-integrity",
+ "@php artisan passport:install",
+ "@php artisan firefly:instructions update"
+ ],
+ "post-install-cmd": [
+ "@php artisan firefly:instructions install",
+ "@php artisan firefly-iii:verify-security-alerts"
+ ],
+ "unit-test": [
+ "@php vendor/bin/phpunit -c phpunit.xml --testsuite unit --no-coverage"
+ ],
+ "integration-test": [
+ "@php vendor/bin/phpunit -c phpunit.xml --testsuite integration --no-coverage"
+ ],
+ "coverage": [
+ "@php vendor/bin/phpunit -c phpunit.xml"
+ ]
},
- "preferred-install": "dist",
- "sort-packages": true,
- "optimize-autoloader": true,
- "allow-plugins": {
- "composer/package-versions-deprecated": true
+ "config": {
+ "preferred-install": "dist",
+ "sort-packages": true,
+ "optimize-autoloader": true,
+ "allow-plugins": {
+ "composer/package-versions-deprecated": true,
+ "phpstan/extension-installer": true
+ }
}
- }
}
diff --cc composer.lock
index ae7655de64,70475bdfc3..1b9a6fd3f5
--- a/composer.lock
+++ b/composer.lock
@@@ -4,7 -4,7 +4,7 @@@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
- "content-hash": "2dd09680aeb9e09c15bc6f6f19666952",
- "content-hash": "a290b73e0cc243be7afa30409d4069a4",
++ "content-hash": "1046ba3997e4bfc3802e62f157cd311b",
"packages": [
{
"name": "bacon/bacon-qr-code",
@@@ -5946,181 -6026,9 +6026,181 @@@
},
"time": "2023-02-20T14:31:09+00:00"
},
+ {
+ "name": "symfony/cache",
+ "version": "v6.3.6",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/symfony/cache.git",
+ "reference": "84aff8d948d6292d2b5a01ac622760be44dddc72"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/symfony/cache/zipball/84aff8d948d6292d2b5a01ac622760be44dddc72",
+ "reference": "84aff8d948d6292d2b5a01ac622760be44dddc72",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=8.1",
+ "psr/cache": "^2.0|^3.0",
+ "psr/log": "^1.1|^2|^3",
+ "symfony/cache-contracts": "^2.5|^3",
+ "symfony/service-contracts": "^2.5|^3",
+ "symfony/var-exporter": "^6.3.6"
+ },
+ "conflict": {
+ "doctrine/dbal": "<2.13.1",
+ "symfony/dependency-injection": "<5.4",
+ "symfony/http-kernel": "<5.4",
+ "symfony/var-dumper": "<5.4"
+ },
+ "provide": {
+ "psr/cache-implementation": "2.0|3.0",
+ "psr/simple-cache-implementation": "1.0|2.0|3.0",
+ "symfony/cache-implementation": "1.1|2.0|3.0"
+ },
+ "require-dev": {
+ "cache/integration-tests": "dev-master",
+ "doctrine/dbal": "^2.13.1|^3|^4",
+ "predis/predis": "^1.1|^2.0",
+ "psr/simple-cache": "^1.0|^2.0|^3.0",
+ "symfony/config": "^5.4|^6.0",
+ "symfony/dependency-injection": "^5.4|^6.0",
+ "symfony/filesystem": "^5.4|^6.0",
+ "symfony/http-kernel": "^5.4|^6.0",
+ "symfony/messenger": "^5.4|^6.0",
+ "symfony/var-dumper": "^5.4|^6.0"
+ },
+ "type": "library",
+ "autoload": {
+ "psr-4": {
+ "Symfony\\Component\\Cache\\": ""
+ },
+ "classmap": [
+ "Traits/ValueWrapper.php"
+ ],
+ "exclude-from-classmap": [
+ "/Tests/"
+ ]
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Nicolas Grekas",
+ "email": "[email protected]"
+ },
+ {
+ "name": "Symfony Community",
+ "homepage": "https://symfony.com/contributors"
+ }
+ ],
+ "description": "Provides extended PSR-6, PSR-16 (and tags) implementations",
+ "homepage": "https://symfony.com",
+ "keywords": [
+ "caching",
+ "psr6"
+ ],
+ "support": {
+ "source": "https://github.com/symfony/cache/tree/v6.3.6"
+ },
+ "funding": [
+ {
+ "url": "https://symfony.com/sponsor",
+ "type": "custom"
+ },
+ {
+ "url": "https://github.com/fabpot",
+ "type": "github"
+ },
+ {
+ "url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
+ "type": "tidelift"
+ }
+ ],
+ "time": "2023-10-17T14:44:58+00:00"
+ },
+ {
+ "name": "symfony/cache-contracts",
+ "version": "v3.3.0",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/symfony/cache-contracts.git",
+ "reference": "ad945640ccc0ae6e208bcea7d7de4b39b569896b"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/symfony/cache-contracts/zipball/ad945640ccc0ae6e208bcea7d7de4b39b569896b",
+ "reference": "ad945640ccc0ae6e208bcea7d7de4b39b569896b",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=8.1",
+ "psr/cache": "^3.0"
+ },
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-main": "3.4-dev"
+ },
+ "thanks": {
+ "name": "symfony/contracts",
+ "url": "https://github.com/symfony/contracts"
+ }
+ },
+ "autoload": {
+ "psr-4": {
+ "Symfony\\Contracts\\Cache\\": ""
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Nicolas Grekas",
+ "email": "[email protected]"
+ },
+ {
+ "name": "Symfony Community",
+ "homepage": "https://symfony.com/contributors"
+ }
+ ],
+ "description": "Generic abstractions related to caching",
+ "homepage": "https://symfony.com",
+ "keywords": [
+ "abstractions",
+ "contracts",
+ "decoupling",
+ "interfaces",
+ "interoperability",
+ "standards"
+ ],
+ "support": {
+ "source": "https://github.com/symfony/cache-contracts/tree/v3.3.0"
+ },
+ "funding": [
+ {
+ "url": "https://symfony.com/sponsor",
+ "type": "custom"
+ },
+ {
+ "url": "https://github.com/fabpot",
+ "type": "github"
+ },
+ {
+ "url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
+ "type": "tidelift"
+ }
+ ],
+ "time": "2023-05-23T14:45:45+00:00"
+ },
{
"name": "symfony/console",
- "version": "v6.3.4",
+ "version": "v6.4.4",
"source": {
"type": "git",
"url": "https://github.com/symfony/console.git",
@@@ -6570,73 -6483,9 +6655,73 @@@
],
"time": "2023-05-23T14:45:45+00:00"
},
+ {
+ "name": "symfony/expression-language",
- "version": "v6.3.0",
++ "version": "v6.4.3",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/symfony/expression-language.git",
- "reference": "6d560c4c80e7e328708efd923f93ad67e6a0c1c0"
++ "reference": "b4a4ae33fbb33a99d23c5698faaecadb76ad0fe4"
+ },
+ "dist": {
+ "type": "zip",
- "url": "https://api.github.com/repos/symfony/expression-language/zipball/6d560c4c80e7e328708efd923f93ad67e6a0c1c0",
- "reference": "6d560c4c80e7e328708efd923f93ad67e6a0c1c0",
++ "url": "https://api.github.com/repos/symfony/expression-language/zipball/b4a4ae33fbb33a99d23c5698faaecadb76ad0fe4",
++ "reference": "b4a4ae33fbb33a99d23c5698faaecadb76ad0fe4",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=8.1",
- "symfony/cache": "^5.4|^6.0",
++ "symfony/cache": "^5.4|^6.0|^7.0",
+ "symfony/deprecation-contracts": "^2.5|^3",
+ "symfony/service-contracts": "^2.5|^3"
+ },
+ "type": "library",
+ "autoload": {
+ "psr-4": {
+ "Symfony\\Component\\ExpressionLanguage\\": ""
+ },
+ "exclude-from-classmap": [
+ "/Tests/"
+ ]
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Fabien Potencier",
+ "email": "[email protected]"
+ },
+ {
+ "name": "Symfony Community",
+ "homepage": "https://symfony.com/contributors"
+ }
+ ],
+ "description": "Provides an engine that can compile and evaluate expressions",
+ "homepage": "https://symfony.com",
+ "support": {
- "source": "https://github.com/symfony/expression-language/tree/v6.3.0"
++ "source": "https://github.com/symfony/expression-language/tree/v6.4.3"
+ },
+ "funding": [
+ {
+ "url": "https://symfony.com/sponsor",
+ "type": "custom"
+ },
+ {
+ "url": "https://github.com/fabpot",
+ "type": "github"
+ },
+ {
+ "url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
+ "type": "tidelift"
+ }
+ ],
- "time": "2023-04-28T16:05:33+00:00"
++ "time": "2024-01-23T14:51:35+00:00"
+ },
{
"name": "symfony/finder",
- "version": "v6.3.5",
+ "version": "v6.4.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/finder.git",
@@@ -8759,82 -8582,8 +8818,82 @@@
"type": "tidelift"
}
],
- "time": "2023-09-12T10:11:35+00:00"
+ "time": "2024-02-15T11:23:52+00:00"
},
+ {
+ "name": "symfony/var-exporter",
+ "version": "v6.3.6",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/symfony/var-exporter.git",
+ "reference": "374d289c13cb989027274c86206ddc63b16a2441"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/symfony/var-exporter/zipball/374d289c13cb989027274c86206ddc63b16a2441",
+ "reference": "374d289c13cb989027274c86206ddc63b16a2441",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=8.1"
+ },
+ "require-dev": {
+ "symfony/var-dumper": "^5.4|^6.0"
+ },
+ "type": "library",
+ "autoload": {
+ "psr-4": {
+ "Symfony\\Component\\VarExporter\\": ""
+ },
+ "exclude-from-classmap": [
+ "/Tests/"
+ ]
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Nicolas Grekas",
+ "email": "[email protected]"
+ },
+ {
+ "name": "Symfony Community",
+ "homepage": "https://symfony.com/contributors"
+ }
+ ],
+ "description": "Allows exporting any serializable PHP data structure to plain PHP code",
+ "homepage": "https://symfony.com",
+ "keywords": [
+ "clone",
+ "construct",
+ "export",
+ "hydrate",
+ "instantiate",
+ "lazy-loading",
+ "proxy",
+ "serialize"
+ ],
+ "support": {
+ "source": "https://github.com/symfony/var-exporter/tree/v6.3.6"
+ },
+ "funding": [
+ {
+ "url": "https://symfony.com/sponsor",
+ "type": "custom"
+ },
+ {
+ "url": "https://github.com/fabpot",
+ "type": "github"
+ },
+ {
+ "url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
+ "type": "tidelift"
+ }
+ ],
+ "time": "2023-10-13T09:16:49+00:00"
+ },
{
"name": "therobfonz/laravel-mandrill-driver",
"version": "5.0.0",