mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-12-12 09:52:20 +00:00
Code cleanup
This commit is contained in:
@@ -57,7 +57,7 @@ class AppendDescriptionToNotes implements ActionInterface
|
||||
$object = TransactionJournal::where('user_id', $journal['user_id'])->find($journal['transaction_journal_id']);
|
||||
if (null === $object) {
|
||||
app('log')->error(sprintf('No journal #%d belongs to user #%d.', $journal['transaction_journal_id'], $journal['user_id']));
|
||||
event(new RuleActionFailedOnArray($this->action, $journal, (string)trans('rules.journal_other_user')));
|
||||
event(new RuleActionFailedOnArray($this->action, $journal, (string) trans('rules.journal_other_user')));
|
||||
|
||||
return false;
|
||||
}
|
||||
@@ -72,7 +72,7 @@ class AppendDescriptionToNotes implements ActionInterface
|
||||
$note->text = trim(sprintf("%s \n%s", $note->text, $object->description));
|
||||
}
|
||||
if ('' === $note->text) {
|
||||
$note->text = (string)$object->description;
|
||||
$note->text = (string) $object->description;
|
||||
}
|
||||
$after = $note->text;
|
||||
|
||||
|
||||
@@ -50,13 +50,13 @@ class AppendNotes implements ActionInterface
|
||||
public function actOnArray(array $journal): bool
|
||||
{
|
||||
$this->refreshNotes($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.*'])
|
||||
;
|
||||
if (null === $dbNote) {
|
||||
$dbNote = new Note();
|
||||
$dbNote->noteable_id = (int)$journal['transaction_journal_id'];
|
||||
$dbNote->noteable_id = (int) $journal['transaction_journal_id'];
|
||||
$dbNote->noteable_type = TransactionJournal::class;
|
||||
$dbNote->text = '';
|
||||
}
|
||||
|
||||
@@ -74,7 +74,7 @@ class AppendNotesToDescription implements ActionInterface
|
||||
// only append if there is something to append
|
||||
if ('' !== $note->text) {
|
||||
$before = $object->description;
|
||||
$object->description = trim(sprintf('%s %s', $object->description, (string)$this->clearString($note->text)));
|
||||
$object->description = trim(sprintf('%s %s', $object->description, (string) $this->clearString($note->text)));
|
||||
$object->save();
|
||||
app('log')->debug(sprintf('Journal description is updated to "%s".', $object->description));
|
||||
|
||||
|
||||
@@ -169,7 +169,7 @@ class ConvertToTransfer implements ActionInterface
|
||||
return '';
|
||||
}
|
||||
|
||||
return (string)$journal->transactions()->where('amount', '<', 0)->first()?->account?->accountType?->type;
|
||||
return (string) $journal->transactions()->where('amount', '<', 0)->first()?->account?->accountType?->type;
|
||||
}
|
||||
|
||||
private function getDestinationType(int $journalId): string
|
||||
@@ -182,7 +182,7 @@ class ConvertToTransfer implements ActionInterface
|
||||
return '';
|
||||
}
|
||||
|
||||
return (string)$journal->transactions()->where('amount', '>', 0)->first()?->account?->accountType?->type;
|
||||
return (string) $journal->transactions()->where('amount', '>', 0)->first()?->account?->accountType?->type;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -71,7 +71,7 @@ class MoveDescriptionToNotes implements ActionInterface
|
||||
$object->description = '(no description)';
|
||||
}
|
||||
if ('' === $note->text) {
|
||||
$note->text = (string)$object->description;
|
||||
$note->text = (string) $object->description;
|
||||
$object->description = '(no description)';
|
||||
}
|
||||
$after = $note->text;
|
||||
|
||||
@@ -78,7 +78,7 @@ class MoveNotesToDescription implements ActionInterface
|
||||
}
|
||||
$before = $object->description;
|
||||
$beforeNote = $note->text;
|
||||
$object->description = (string)$this->clearString($note->text);
|
||||
$object->description = (string) $this->clearString($note->text);
|
||||
$object->save();
|
||||
$note->delete();
|
||||
|
||||
|
||||
@@ -46,13 +46,13 @@ class PrependNotes implements ActionInterface
|
||||
|
||||
public function actOnArray(array $journal): bool
|
||||
{
|
||||
$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.*'])
|
||||
;
|
||||
if (null === $dbNote) {
|
||||
$dbNote = new Note();
|
||||
$dbNote->noteable_id = (int)$journal['transaction_journal_id'];
|
||||
$dbNote->noteable_id = (int) $journal['transaction_journal_id'];
|
||||
$dbNote->noteable_type = TransactionJournal::class;
|
||||
$dbNote->text = '';
|
||||
}
|
||||
|
||||
@@ -84,7 +84,7 @@ class SetBudget implements ActionInterface
|
||||
$object = $user->transactionJournals()->find($journal['transaction_journal_id']);
|
||||
$oldBudget = $object->budgets()->first();
|
||||
$oldBudgetName = $oldBudget?->name;
|
||||
if ((int)$oldBudget?->id === $budget->id) {
|
||||
if ((int) $oldBudget?->id === $budget->id) {
|
||||
event(new RuleActionFailedOnArray($this->action, $journal, trans('rules.already_linked_to_budget', ['name' => $budget->name])));
|
||||
|
||||
return false;
|
||||
|
||||
@@ -88,7 +88,7 @@ class SetCategory implements ActionInterface
|
||||
$object = $user->transactionJournals()->find($journal['transaction_journal_id']);
|
||||
$oldCategory = $object->categories()->first();
|
||||
$oldCategoryName = $oldCategory?->name;
|
||||
if ((int)$oldCategory?->id === $category->id) {
|
||||
if ((int) $oldCategory?->id === $category->id) {
|
||||
// event(new RuleActionFailedOnArray($this->action, $journal, trans('rules.already_linked_to_category', ['name' => $category->name])));
|
||||
|
||||
return false;
|
||||
|
||||
@@ -57,7 +57,7 @@ class SetDestinationAccount implements ActionInterface
|
||||
$user = User::find($journal['user_id']);
|
||||
|
||||
/** @var null|TransactionJournal $object */
|
||||
$object = $user->transactionJournals()->find((int)$journal['transaction_journal_id']);
|
||||
$object = $user->transactionJournals()->find((int) $journal['transaction_journal_id']);
|
||||
$this->repository = app(AccountRepositoryInterface::class);
|
||||
|
||||
if (null === $object) {
|
||||
|
||||
@@ -54,7 +54,7 @@ class SetDestinationToCashAccount implements ActionInterface
|
||||
$user = User::find($journal['user_id']);
|
||||
|
||||
/** @var null|TransactionJournal $object */
|
||||
$object = $user->transactionJournals()->find((int)$journal['transaction_journal_id']);
|
||||
$object = $user->transactionJournals()->find((int) $journal['transaction_journal_id']);
|
||||
$repository = app(AccountRepositoryInterface::class);
|
||||
|
||||
if (null === $object) {
|
||||
|
||||
@@ -57,7 +57,7 @@ class SetSourceAccount implements ActionInterface
|
||||
$user = User::find($journal['user_id']);
|
||||
|
||||
/** @var null|TransactionJournal $object */
|
||||
$object = $user->transactionJournals()->find((int)$journal['transaction_journal_id']);
|
||||
$object = $user->transactionJournals()->find((int) $journal['transaction_journal_id']);
|
||||
$this->repository = app(AccountRepositoryInterface::class);
|
||||
if (null === $object) {
|
||||
app('log')->error('Could not find journal.');
|
||||
|
||||
@@ -54,7 +54,7 @@ class SetSourceToCashAccount implements ActionInterface
|
||||
$user = User::find($journal['user_id']);
|
||||
|
||||
/** @var null|TransactionJournal $object */
|
||||
$object = $user->transactionJournals()->find((int)$journal['transaction_journal_id']);
|
||||
$object = $user->transactionJournals()->find((int) $journal['transaction_journal_id']);
|
||||
$repository = app(AccountRepositoryInterface::class);
|
||||
|
||||
if (null === $object) {
|
||||
|
||||
@@ -114,11 +114,11 @@ class UpdatePiggybank implements ActionInterface
|
||||
'add_to_piggy',
|
||||
null,
|
||||
[
|
||||
'currency_symbol' => $journalObj->transactionCurrency->symbol,
|
||||
'decimal_places' => $journalObj->transactionCurrency->decimal_places,
|
||||
'amount' => $destination->amount,
|
||||
'piggy' => $piggyBank->name,
|
||||
'piggy_id' => $piggyBank->id,
|
||||
'currency_symbol' => $journalObj->transactionCurrency->symbol,
|
||||
'decimal_places' => $journalObj->transactionCurrency->decimal_places,
|
||||
'amount' => $destination->amount,
|
||||
'piggy' => $piggyBank->name,
|
||||
'piggy_id' => $piggyBank->id,
|
||||
]
|
||||
)
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user