mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2026-05-03 20:56:21 +00:00
Code cleanup
This commit is contained in:
@@ -545,6 +545,33 @@ class AccountRepository implements AccountRepositoryInterface
|
||||
return in_array($account->accountType->type, [AccountType::CREDITCARD, AccountType::LOAN, AccountType::DEBT, AccountType::MORTGAGE], true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function maxOrder(string $type): int
|
||||
{
|
||||
$sets = [
|
||||
AccountType::ASSET => [AccountType::DEFAULT, AccountType::ASSET],
|
||||
AccountType::EXPENSE => [AccountType::EXPENSE, AccountType::BENEFICIARY],
|
||||
AccountType::REVENUE => [AccountType::REVENUE],
|
||||
AccountType::LOAN => [AccountType::LOAN, AccountType::DEBT, AccountType::CREDITCARD, AccountType::MORTGAGE],
|
||||
AccountType::DEBT => [AccountType::LOAN, AccountType::DEBT, AccountType::CREDITCARD, AccountType::MORTGAGE],
|
||||
AccountType::MORTGAGE => [AccountType::LOAN, AccountType::DEBT, AccountType::CREDITCARD, AccountType::MORTGAGE],
|
||||
];
|
||||
if (array_key_exists(ucfirst($type), $sets)) {
|
||||
$order = (int)$this->getAccountsByType($sets[ucfirst($type)])->max('order');
|
||||
Log::debug(sprintf('Return max order of "%s" set: %d', $type, $order));
|
||||
|
||||
return $order;
|
||||
}
|
||||
$specials = [AccountType::CASH, AccountType::INITIAL_BALANCE, AccountType::IMPORT, AccountType::RECONCILIATION];
|
||||
|
||||
$order = (int)$this->getAccountsByType($specials)->max('order');
|
||||
Log::debug(sprintf('Return max order of "%s" set (specials!): %d', $type, $order));
|
||||
|
||||
return $order;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the date of the very first transaction in this account.
|
||||
*
|
||||
@@ -720,31 +747,4 @@ class AccountRepository implements AccountRepositoryInterface
|
||||
|
||||
return $service->update($account, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function maxOrder(string $type): int
|
||||
{
|
||||
$sets = [
|
||||
AccountType::ASSET => [AccountType::DEFAULT, AccountType::ASSET],
|
||||
AccountType::EXPENSE => [AccountType::EXPENSE, AccountType::BENEFICIARY],
|
||||
AccountType::REVENUE => [AccountType::REVENUE],
|
||||
AccountType::LOAN => [AccountType::LOAN, AccountType::DEBT, AccountType::CREDITCARD, AccountType::MORTGAGE],
|
||||
AccountType::DEBT => [AccountType::LOAN, AccountType::DEBT, AccountType::CREDITCARD, AccountType::MORTGAGE],
|
||||
AccountType::MORTGAGE => [AccountType::LOAN, AccountType::DEBT, AccountType::CREDITCARD, AccountType::MORTGAGE],
|
||||
];
|
||||
if (array_key_exists(ucfirst($type), $sets)) {
|
||||
$order = (int)$this->getAccountsByType($sets[ucfirst($type)])->max('order');
|
||||
Log::debug(sprintf('Return max order of "%s" set: %d', $type, $order));
|
||||
|
||||
return $order;
|
||||
}
|
||||
$specials = [AccountType::CASH, AccountType::INITIAL_BALANCE, AccountType::IMPORT, AccountType::RECONCILIATION];
|
||||
|
||||
$order = (int)$this->getAccountsByType($specials)->max('order');
|
||||
Log::debug(sprintf('Return max order of "%s" set (specials!): %d', $type, $order));
|
||||
|
||||
return $order;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,13 +47,6 @@ interface AccountRepositoryInterface
|
||||
*/
|
||||
public function count(array $types): int;
|
||||
|
||||
/**
|
||||
* @param string $type
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function maxOrder(string $type): int;
|
||||
|
||||
/**
|
||||
* Moved here from account CRUD.
|
||||
*
|
||||
@@ -243,6 +236,13 @@ interface AccountRepositoryInterface
|
||||
*/
|
||||
public function isLiability(Account $account): bool;
|
||||
|
||||
/**
|
||||
* @param string $type
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function maxOrder(string $type): int;
|
||||
|
||||
/**
|
||||
* Returns the date of the very first transaction in this account.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user