mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-12 15:35:15 +00:00
Display audit logs
This commit is contained in:
@@ -55,7 +55,7 @@ class AppendDescription implements ActionInterface
|
||||
// event for audit log entry
|
||||
/** @var TransactionJournal $journal */
|
||||
$journal = TransactionJournal::where('user_id', $journal['user_id'])->find($journal['transaction_journal_id']);
|
||||
event(new TriggeredAuditLog($this->action->rule, $journal, 'update_description', null, $description));
|
||||
event(new TriggeredAuditLog($this->action->rule, $journal, 'update_description', $journal['description'], $description));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@@ -61,7 +61,7 @@ class ClearBudget implements ActionInterface
|
||||
|
||||
DB::table('budget_transaction_journal')->where('transaction_journal_id', '=', $journal['transaction_journal_id'])->delete();
|
||||
|
||||
event(new TriggeredAuditLog($this->action->rule, $journal, 'remove_budget', $budget->name, null));
|
||||
event(new TriggeredAuditLog($this->action->rule, $journal, 'clear_budget', $budget->name, null));
|
||||
|
||||
Log::debug(sprintf('RuleAction ClearBudget removed all budgets from journal #%d.', $journal['transaction_journal_id']));
|
||||
|
||||
|
@@ -60,7 +60,7 @@ class ClearCategory implements ActionInterface
|
||||
|
||||
DB::table('category_transaction_journal')->where('transaction_journal_id', '=', $journal['transaction_journal_id'])->delete();
|
||||
|
||||
event(new TriggeredAuditLog($this->action->rule, $journal, 'removed_category', $category->name, null));
|
||||
event(new TriggeredAuditLog($this->action->rule, $journal, 'clear_category', $category->name, null));
|
||||
|
||||
Log::debug(sprintf('RuleAction ClearCategory removed all categories from journal #%d.', $journal['transaction_journal_id']));
|
||||
|
||||
|
@@ -64,7 +64,7 @@ class ClearNotes implements ActionInterface
|
||||
->delete();
|
||||
Log::debug(sprintf('RuleAction ClearNotes removed all notes from journal #%d.', $journal['transaction_journal_id']));
|
||||
|
||||
event(new TriggeredAuditLog($this->action->rule, $journal, 'remove_notes', $before, null));
|
||||
event(new TriggeredAuditLog($this->action->rule, $journal, 'clear_notes', $before, null));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@@ -75,13 +75,13 @@ class ConvertToDeposit implements ActionInterface
|
||||
if (TransactionType::WITHDRAWAL === $type) {
|
||||
Log::debug('Going to transform a withdrawal to a deposit.');
|
||||
$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::DEPOSIT));
|
||||
event(new TriggeredAuditLog($this->action->rule, $object, 'update_transaction_type', TransactionType::WITHDRAWAL, TransactionType::DEPOSIT));
|
||||
|
||||
return $this->convertWithdrawalArray($journal);
|
||||
}
|
||||
if (TransactionType::TRANSFER === $type) {
|
||||
$object = TransactionJournal::where('user_id', $journal['user_id'])->find($journal['transaction_journal_id']);
|
||||
event(new TriggeredAuditLog($this->action->rule, $object, 'change_transaction_type', TransactionType::TRANSFER, TransactionType::DEPOSIT));
|
||||
event(new TriggeredAuditLog($this->action->rule, $object, 'update_transaction_type', TransactionType::TRANSFER, TransactionType::DEPOSIT));
|
||||
Log::debug('Going to transform a transfer to a deposit.');
|
||||
|
||||
return $this->convertTransferArray($journal);
|
||||
|
@@ -92,7 +92,7 @@ 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));
|
||||
event(new TriggeredAuditLog($this->action->rule, $object, 'update_transaction_type', TransactionType::WITHDRAWAL, TransactionType::TRANSFER));
|
||||
|
||||
return $this->convertWithdrawalArray($journal, $asset);
|
||||
}
|
||||
@@ -100,7 +100,7 @@ class ConvertToTransfer implements ActionInterface
|
||||
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));
|
||||
event(new TriggeredAuditLog($this->action->rule, $object, 'update_transaction_type', TransactionType::DEPOSIT, TransactionType::TRANSFER));
|
||||
|
||||
return $this->convertDepositArray($journal, $asset);
|
||||
}
|
||||
|
@@ -73,14 +73,14 @@ class ConvertToWithdrawal implements ActionInterface
|
||||
if (TransactionType::DEPOSIT === $type) {
|
||||
Log::debug('Going to transform a deposit to a withdrawal.');
|
||||
$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::WITHDRAWAL));
|
||||
event(new TriggeredAuditLog($this->action->rule, $object, 'update_transaction_type', TransactionType::DEPOSIT, TransactionType::WITHDRAWAL));
|
||||
|
||||
return $this->convertDepositArray($journal);
|
||||
}
|
||||
if (TransactionType::TRANSFER === $type) {
|
||||
Log::debug('Going to transform a transfer to a withdrawal.');
|
||||
$object = TransactionJournal::where('user_id', $journal['user_id'])->find($journal['transaction_journal_id']);
|
||||
event(new TriggeredAuditLog($this->action->rule, $object, 'change_transaction_type', TransactionType::TRANSFER, TransactionType::WITHDRAWAL));
|
||||
event(new TriggeredAuditLog($this->action->rule, $object, 'update_transaction_type', TransactionType::TRANSFER, TransactionType::WITHDRAWAL));
|
||||
|
||||
return $this->convertTransferArray($journal);
|
||||
}
|
||||
|
@@ -63,6 +63,14 @@ class LinkToBill implements ActionInterface
|
||||
$bill = $repository->findByName($billName);
|
||||
|
||||
if (null !== $bill && $journal['transaction_type_type'] === TransactionType::WITHDRAWAL) {
|
||||
$count = DB::table('transaction_journals')->where('id', '=', $journal['transaction_journal_id'])
|
||||
->where('bill_id', $bill->id)->count();
|
||||
if (0 !== $count) {
|
||||
Log::error(sprintf('RuleAction LinkToBill could not set the bill of journal #%d to bill "%s": already set.', $journal['transaction_journal_id'], $billName));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
DB::table('transaction_journals')
|
||||
->where('id', '=', $journal['transaction_journal_id'])
|
||||
->update(['bill_id' => $bill->id]);
|
||||
@@ -71,7 +79,7 @@ class LinkToBill implements ActionInterface
|
||||
);
|
||||
|
||||
$journal = TransactionJournal::where('user_id', $journal['user_id'])->find($journal['transaction_journal_id']);
|
||||
event(new TriggeredAuditLog($this->action->rule, $journal, 'change_bill', null, $bill->id));
|
||||
event(new TriggeredAuditLog($this->action->rule, $journal, 'set_bill', null, $bill->name));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@@ -74,7 +74,7 @@ class MoveNotesToDescription implements ActionInterface
|
||||
$note->delete();
|
||||
|
||||
event(new TriggeredAuditLog($this->action->rule, $journal, 'update_description', $before, $journal->description));
|
||||
event(new TriggeredAuditLog($this->action->rule, $journal, 'remove_notes', $beforeNote, null));
|
||||
event(new TriggeredAuditLog($this->action->rule, $journal, 'clear_notes', $beforeNote, null));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@@ -50,14 +50,19 @@ class RemoveAllTags implements ActionInterface
|
||||
*/
|
||||
public function actOnArray(array $journal): bool
|
||||
{
|
||||
Log::debug(sprintf('RuleAction ClearCategory removed all tags from journal %d.', $journal['transaction_journal_id']));
|
||||
DB::table('tag_transaction_journal')->where('transaction_journal_id', $journal['transaction_journal_id'])->delete();
|
||||
$count = DB::table('tag_transaction_journal')->where('transaction_journal_id', $journal['transaction_journal_id'])->count();
|
||||
if (0 === $count) {
|
||||
Log::debug(sprintf('RuleAction RemoveAllTags, journal #%d has no tags.', $journal['transaction_journal_id']));
|
||||
return false;
|
||||
}
|
||||
Log::debug(sprintf('RuleAction RemoveAllTags removed all tags from journal %d.', $journal['transaction_journal_id']));
|
||||
|
||||
/** @var TransactionJournal $journal */
|
||||
$journal = TransactionJournal::where('user_id', $journal['user_id'])->find($journal['transaction_journal_id']);
|
||||
|
||||
// audit log
|
||||
event(new TriggeredAuditLog($this->action->rule, $journal, 'remove_all_tags', null, null));
|
||||
event(new TriggeredAuditLog($this->action->rule, $journal, 'clear_all_tags', null, null));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@@ -62,6 +62,11 @@ class RemoveTag implements ActionInterface
|
||||
);
|
||||
return false;
|
||||
}
|
||||
$count = DB::table('tag_transaction_journal')->where('transaction_journal_id', $journal['transaction_journal_id'])->where('tag_id', $tag->id)->count();
|
||||
if(0 === $count) {
|
||||
Log::debug(sprintf('RuleAction RemoveTag tried to remove tag "%s" from journal #%d but no such tag is linked.', $name, $journal['transaction_journal_id']));
|
||||
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')
|
||||
@@ -71,7 +76,7 @@ class RemoveTag implements ActionInterface
|
||||
|
||||
/** @var TransactionJournal $journal */
|
||||
$journal = TransactionJournal::where('user_id', $journal['user_id'])->find($journal['transaction_journal_id']);
|
||||
event(new TriggeredAuditLog($this->action->rule, $journal, 'remove_tag', $tag->tag, null));
|
||||
event(new TriggeredAuditLog($this->action->rule, $journal, 'clear_tag', $tag->tag, null));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@@ -28,6 +28,7 @@ use FireflyIII\Events\TriggeredAuditLog;
|
||||
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\User;
|
||||
@@ -61,6 +62,7 @@ class UpdatePiggybank implements ActionInterface
|
||||
|
||||
// refresh the transaction type.
|
||||
$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);
|
||||
$journal['transaction_type_type'] = $type->type;
|
||||
@@ -91,7 +93,7 @@ class UpdatePiggybank implements ActionInterface
|
||||
Log::debug('Piggy bank account is linked to source, so remove amount.');
|
||||
$this->removeAmount($journal, $piggyBank, $destination->amount);
|
||||
|
||||
event(new TriggeredAuditLog($this->action->rule, $journalObj, 'remove_from_piggy', null, ['amount' => $destination->amount, 'piggy' => $piggyBank->name]));
|
||||
event(new TriggeredAuditLog($this->action->rule, $journalObj, 'remove_from_piggy', null, ['currency_symbol' => $journalObj->transactionCurrency->symbol, 'decimal_places' => $journalObj->transactionCurrency->decimal_places, 'amount' => $destination->amount, 'piggy' => $piggyBank->name]));
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -99,7 +101,7 @@ class UpdatePiggybank implements ActionInterface
|
||||
Log::debug('Piggy bank account is linked to source, so add amount.');
|
||||
$this->addAmount($journal, $piggyBank, $destination->amount);
|
||||
|
||||
event(new TriggeredAuditLog($this->action->rule, $journalObj, 'add_to_piggy', null, ['amount' => $destination->amount, 'piggy' => $piggyBank->name]));
|
||||
event(new TriggeredAuditLog($this->action->rule, $journalObj, 'add_to_piggy', null, ['currency_symbol' => $journalObj->transactionCurrency->symbol, 'decimal_places' => $journalObj->transactionCurrency->decimal_places, 'amount' => $destination->amount, 'piggy' => $piggyBank->name]));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
Reference in New Issue
Block a user