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

@@ -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
*/