mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2024-11-22 17:06:39 -06:00
This commit is contained in:
parent
c3e971c419
commit
936c2b8888
@ -83,6 +83,17 @@ class SetBudget implements ActionInterface
|
||||
return false;
|
||||
}
|
||||
|
||||
// find previous budget
|
||||
/** @var TransactionJournal $object */
|
||||
$object = $user->transactionJournals()->find($journal['transaction_journal_id']);
|
||||
$oldBudget = $object->budgets()->first();
|
||||
$oldBudgetName = $oldBudget?->name;
|
||||
if ((int)$oldBudget?->id === (int)$budget->id) {
|
||||
event(new RuleActionFailedOnArray($this->action, $journal, trans('rules.already_linked_to_budget', ['name' => $budget->name])));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
Log::debug(
|
||||
sprintf('RuleAction SetBudget set the budget of journal #%d to budget #%d ("%s").', $journal['transaction_journal_id'], $budget->id, $budget->name)
|
||||
);
|
||||
@ -92,7 +103,7 @@ class SetBudget implements ActionInterface
|
||||
|
||||
/** @var TransactionJournal $object */
|
||||
$object = TransactionJournal::where('user_id', $journal['user_id'])->find($journal['transaction_journal_id']);
|
||||
event(new TriggeredAuditLog($this->action->rule, $object, 'set_budget', null, $budget->name));
|
||||
event(new TriggeredAuditLog($this->action->rule, $object, 'set_budget', $oldBudgetName, $budget->name));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -87,12 +87,22 @@ class SetCategory implements ActionInterface
|
||||
)
|
||||
);
|
||||
|
||||
// find previous category
|
||||
/** @var TransactionJournal $object */
|
||||
$object = $user->transactionJournals()->find($journal['transaction_journal_id']);
|
||||
$oldCategory = $object->categories()->first();
|
||||
$oldCategoryName = $oldCategory?->name;
|
||||
if ((int)$oldCategory?->id === (int)$category->id) {
|
||||
event(new RuleActionFailedOnArray($this->action, $journal, trans('rules.already_linked_to_category', ['name' => $category->name])));
|
||||
return false;
|
||||
}
|
||||
|
||||
DB::table('category_transaction_journal')->where('transaction_journal_id', '=', $journal['transaction_journal_id'])->delete();
|
||||
DB::table('category_transaction_journal')->insert(['transaction_journal_id' => $journal['transaction_journal_id'], 'category_id' => $category->id]);
|
||||
|
||||
/** @var TransactionJournal $object */
|
||||
$object = TransactionJournal::where('user_id', $journal['user_id'])->find($journal['transaction_journal_id']);
|
||||
event(new TriggeredAuditLog($this->action->rule, $object, 'set_category', null, $category->name));
|
||||
event(new TriggeredAuditLog($this->action->rule, $object, 'set_category', $oldCategoryName, $category->name));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -50,6 +50,8 @@ return [
|
||||
'already_has_destination' => 'This transaction already has ":name" as the destination account',
|
||||
'already_has_source' => 'This transaction already has ":name" as the source account',
|
||||
'already_linked_to_subscription' => 'The transaction is already linked to subscription ":name"',
|
||||
'already_linked_to_category' => 'The transaction is already linked to category ":name"',
|
||||
'already_linked_to_budget' => 'The transaction is already linked to budget ":name"',
|
||||
'cannot_find_subscription' => 'Firefly III can\'t find subscription ":name"',
|
||||
'no_notes_to_move' => 'The transaction has no notes to move to the description field',
|
||||
'no_tags_to_remove' => 'The transaction has no tags to remove',
|
||||
|
Loading…
Reference in New Issue
Block a user