mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2026-01-09 20:11:22 +00:00
Migrate actions
This commit is contained in:
@@ -24,6 +24,7 @@ declare(strict_types=1);
|
||||
namespace FireflyIII\TransactionRules\Actions;
|
||||
|
||||
use DB;
|
||||
use FireflyIII\Events\TriggeredAuditLog;
|
||||
use FireflyIII\Models\Account;
|
||||
use FireflyIII\Models\AccountType;
|
||||
use FireflyIII\Models\RuleAction;
|
||||
@@ -57,7 +58,7 @@ class ConvertToTransfer implements ActionInterface
|
||||
public function actOnArray(array $journal): bool
|
||||
{
|
||||
$groupCount = TransactionJournal::where('transaction_group_id', $journal['transaction_group_id'])->count();
|
||||
if($groupCount > 1) {
|
||||
if ($groupCount > 1) {
|
||||
Log::error(sprintf('Group #%d has more than one transaction in it, cannot convert to transfer.', $journal['transaction_group_id']));
|
||||
return false;
|
||||
}
|
||||
@@ -90,12 +91,17 @@ class ConvertToTransfer implements ActionInterface
|
||||
}
|
||||
if (TransactionType::WITHDRAWAL === $type) {
|
||||
Log::debug('Going to transform a withdrawal to a transfer.');
|
||||
$object = TransactionJournal::where('user_id', $journal['user_id'])->find($journal['transaction_journal_id']);
|
||||
event(new TriggeredAuditLog($this->action->rule, $object, 'change_transaction_type', TransactionType::WITHDRAWAL, TransactionType::TRANSFER));
|
||||
|
||||
return $this->convertWithdrawalArray($journal, $asset);
|
||||
}
|
||||
if (TransactionType::DEPOSIT === $type) {
|
||||
Log::debug('Going to transform a deposit to a transfer.');
|
||||
|
||||
$object = TransactionJournal::where('user_id', $journal['user_id'])->find($journal['transaction_journal_id']);
|
||||
event(new TriggeredAuditLog($this->action->rule, $object, 'change_transaction_type', TransactionType::DEPOSIT, TransactionType::TRANSFER));
|
||||
|
||||
return $this->convertDepositArray($journal, $asset);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user