Make sure sorting doesnt break opening balance.

This commit is contained in:
James Cole
2020-07-26 15:05:48 +02:00
parent c86673f3ec
commit fdea25051c
11 changed files with 162 additions and 9 deletions

View File

@@ -697,4 +697,20 @@ class AccountRepository implements AccountRepositoryInterface
return TransactionCurrency::whereIn('id', $currencyIds)->get();
}
/**
* @inheritDoc
*/
public function resetAccountOrder(array $types): void
{
$list = $this->getAccountsByType($types);
/**
* @var int $index
* @var Account $account
*/
foreach ($list as $index => $account) {
$account->order = $index + 1;
$account->save();
}
}
}