mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-09-30 10:33:30 +00:00
This commit is contained in:
@@ -83,6 +83,17 @@ class SetBudget implements ActionInterface
|
|||||||
return false;
|
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(
|
Log::debug(
|
||||||
sprintf('RuleAction SetBudget set the budget of journal #%d to budget #%d ("%s").', $journal['transaction_journal_id'], $budget->id, $budget->name)
|
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 */
|
/** @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, 'set_budget', null, $budget->name));
|
event(new TriggeredAuditLog($this->action->rule, $object, 'set_budget', $oldBudgetName, $budget->name));
|
||||||
|
|
||||||
return true;
|
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')->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]);
|
DB::table('category_transaction_journal')->insert(['transaction_journal_id' => $journal['transaction_journal_id'], 'category_id' => $category->id]);
|
||||||
|
|
||||||
/** @var TransactionJournal $object */
|
/** @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, 'set_category', null, $category->name));
|
event(new TriggeredAuditLog($this->action->rule, $object, 'set_category', $oldCategoryName, $category->name));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@@ -50,6 +50,8 @@ return [
|
|||||||
'already_has_destination' => 'This transaction already has ":name" as the destination account',
|
'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_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_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"',
|
'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_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',
|
'no_tags_to_remove' => 'The transaction has no tags to remove',
|
||||||
|
Reference in New Issue
Block a user