Various code cleanup.

This commit is contained in:
James Cole
2021-05-24 08:54:58 +02:00
parent 815fd5ff6b
commit d60650cff2
63 changed files with 134 additions and 88 deletions

View File

@@ -33,6 +33,7 @@ use FireflyIII\Models\TransactionJournal;
use FireflyIII\Models\TransactionType;
use Illuminate\Database\Eloquent\Builder;
use Log;
use stdClass;
/**
* Class AccountDestroyService
@@ -130,7 +131,7 @@ class AccountDestroyService
/** @var JournalDestroyService $service */
$service = app(JournalDestroyService::class);
$user = $account->user;
/** @var \stdClass $row */
/** @var stdClass $row */
foreach ($collection as $row) {
if ((int)$row->the_count > 1) {
$journalId = (int)$row->transaction_journal_id;

View File

@@ -275,7 +275,6 @@ trait AccountServiceTrait
* @param string $currencyCode
*
* @return TransactionCurrency
* @throws JsonException
*/
protected function getCurrency(int $currencyId, string $currencyCode): TransactionCurrency
{

View File

@@ -49,7 +49,6 @@ trait BillServiceTrait
return;
}
$ruleIds = $bill->user->rules()->get(['id'])->pluck('id')->toArray();
/** @var Collection $set */
$set = RuleAction::whereIn('rule_id', $ruleIds)
->where('action_type', 'link_to_bill')
->where('action_value', $oldName)->get();

View File

@@ -194,7 +194,7 @@ trait JournalServiceTrait
* @param array $data
* @param string $preferredType
*
* @return Account
* @return Account|null
* @throws FireflyException
*/
private function createAccount(?Account $account, array $data, string $preferredType): ?Account
@@ -302,7 +302,7 @@ trait JournalServiceTrait
/**
* @param string|null $amount
*
* @return string
* @return string|null
* @codeCoverageIgnore
*/
protected function getForeignAmount(?string $amount): ?string
@@ -372,7 +372,7 @@ trait JournalServiceTrait
/**
* @param TransactionJournal $journal
* @param string $notes
* @param string|null $notes
*
* @codeCoverageIgnore
*/
@@ -405,7 +405,7 @@ trait JournalServiceTrait
* Link tags to journal.
*
* @param TransactionJournal $journal
* @param array $tags
* @param array|null $tags
*
* @codeCoverageIgnore
*/

View File

@@ -257,6 +257,8 @@ trait RecurringTransactionTrait
/**
* @param RecurrenceTransaction $transaction
* @param int $categoryId
*
* @throws FireflyException
*/
private function setCategory(RecurrenceTransaction $transaction, int $categoryId): void
{

View File

@@ -77,6 +77,8 @@ class AccountUpdateService
* @param array $data
*
* @return Account
* @throws FireflyException
* @throws \JsonException
*/
public function update(Account $account, array $data): Account
{
@@ -179,6 +181,8 @@ class AccountUpdateService
/**
* @param string $type
*
* @return AccountType
*/
private function getAccountType(string $type): AccountType
{
@@ -219,7 +223,7 @@ class AccountUpdateService
$this->user->accounts()->where('accounts.order', '<=', $newOrder)->where('accounts.order', '>', $oldOrder)
->where('accounts.id', '!=', $account->id)
->whereIn('accounts.account_type_id', $list)
->decrement('order', 1);
->decrement('order');
$account->order = $newOrder;
Log::debug(sprintf('Order of account #%d ("%s") is now %d', $account->id, $account->name, $newOrder));
$account->save();
@@ -230,7 +234,7 @@ class AccountUpdateService
$this->user->accounts()->where('accounts.order', '>=', $newOrder)->where('accounts.order', '<', $oldOrder)
->where('accounts.id', '!=', $account->id)
->whereIn('accounts.account_type_id', $list)
->increment('order', 1);
->increment('order');
$account->order = $newOrder;
Log::debug(sprintf('Order of account #%d ("%s") is now %d', $account->id, $account->name, $newOrder));
$account->save();
@@ -339,6 +343,8 @@ class AccountUpdateService
/**
* @param Account $account
*
* @throws FireflyException
*/
private function updatePreferences(Account $account): void
{

View File

@@ -184,14 +184,14 @@ class BillUpdateService
if ($newOrder > $oldOrder) {
$this->user->bills()->where('order', '<=', $newOrder)->where('order', '>', $oldOrder)
->where('bills.id', '!=', $bill->id)
->decrement('bills.order', 1);
->decrement('bills.order');
$bill->order = $newOrder;
$bill->save();
}
if ($newOrder < $oldOrder) {
$this->user->bills()->where('order', '>=', $newOrder)->where('order', '<', $oldOrder)
->where('bills.id', '!=', $bill->id)
->increment('bills.order', 1);
->increment('bills.order');
$bill->order = $newOrder;
$bill->save();
}

View File

@@ -62,6 +62,7 @@ class CategoryUpdateService
* @param array $data
*
* @return Category
* @throws Exception
*/
public function update(Category $category, array $data): Category
{

View File

@@ -165,6 +165,7 @@ class GroupUpdateService
* @param array $data
*
* @throws FireflyException
* @throws \FireflyIII\Exceptions\DuplicateTransactionException
*/
private function createTransactionJournal(TransactionGroup $transactionGroup, array $data): void
{

View File

@@ -143,6 +143,8 @@ class RecurrenceUpdateService
*
* @param Recurrence $recurrence
* @param array $repetitions
*
* @throws FireflyException
*/
private function updateRepetitions(Recurrence $recurrence, array $repetitions): void
{
@@ -184,7 +186,8 @@ class RecurrenceUpdateService
}
/**
* @param array $data
* @param Recurrence $recurrence
* @param array $data
*
* @return RecurrenceRepetition|null
*/
@@ -308,7 +311,8 @@ class RecurrenceUpdateService
}
/**
* @param array $data
* @param Recurrence $recurrence
* @param array $data
*
* @return RecurrenceTransaction|null
*/