mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-15 16:57:09 +00:00
Fix some tests for account API
This commit is contained in:
@@ -586,16 +586,25 @@ class AccountRepository implements AccountRepositoryInterface
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function resetAccountOrder(array $types): void
|
||||
public function resetAccountOrder(): void
|
||||
{
|
||||
$list = $this->getAccountsByType($types);
|
||||
/**
|
||||
* @var int $index
|
||||
* @var Account $account
|
||||
*/
|
||||
foreach ($list as $index => $account) {
|
||||
$account->order = $index + 1;
|
||||
$account->save();
|
||||
$sets = [
|
||||
[AccountType::DEFAULT, AccountType::ASSET],
|
||||
[AccountType::EXPENSE, AccountType::BENEFICIARY],
|
||||
[AccountType::REVENUE],
|
||||
[AccountType::LOAN, AccountType::DEBT, AccountType::CREDITCARD, AccountType::MORTGAGE],
|
||||
[AccountType::CASH, AccountType::INITIAL_BALANCE, AccountType::IMPORT, AccountType::RECONCILIATION],
|
||||
];
|
||||
foreach ($sets as $set) {
|
||||
$list = $this->getAccountsByType($set);
|
||||
$index = 1;
|
||||
foreach ($list as $account) {
|
||||
if ($index !== $account->order) {
|
||||
$account->order = $index;
|
||||
$account->save();
|
||||
}
|
||||
$index++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -753,4 +762,12 @@ class AccountRepository implements AccountRepositoryInterface
|
||||
|
||||
return $service->update($account, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function maxOrder(array $types): int
|
||||
{
|
||||
return (int)$this->getAccountsByType($types)->max('order');
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user