PHPStorm can order methods by alphabet, who knew.

This commit is contained in:
James Cole
2024-02-22 20:11:09 +01:00
parent f9d4a43e05
commit 68c9c4ec3c
221 changed files with 5840 additions and 5843 deletions

View File

@@ -61,36 +61,6 @@ class AccountDestroyService
$account->delete();
}
public function moveTransactions(Account $account, Account $moveTo): void
{
app('log')->debug(sprintf('Move from account #%d to #%d', $account->id, $moveTo->id));
\DB::table('transactions')->where('account_id', $account->id)->update(['account_id' => $moveTo->id]);
$collection = Transaction::groupBy('transaction_journal_id', 'account_id')
->where('account_id', $moveTo->id)
->get(['transaction_journal_id', 'account_id', \DB::raw('count(*) as the_count')]) // @phpstan-ignore-line
;
if (0 === $collection->count()) {
return;
}
/** @var JournalDestroyService $service */
$service = app(JournalDestroyService::class);
$user = $account->user;
/** @var \stdClass $row */
foreach ($collection as $row) {
if ((int)$row->the_count > 1) {
$journalId = $row->transaction_journal_id;
$journal = $user->transactionJournals()->find($journalId);
if (null !== $journal) {
app('log')->debug(sprintf('Deleted journal #%d because it has the same source as destination.', $journal->id));
$service->destroy($journal);
}
}
}
}
private function destroyOpeningBalance(Account $account): void
{
app('log')->debug(sprintf('Searching for opening balance for account #%d "%s"', $account->id, $account->name));
@@ -129,6 +99,36 @@ class AccountDestroyService
}
}
public function moveTransactions(Account $account, Account $moveTo): void
{
app('log')->debug(sprintf('Move from account #%d to #%d', $account->id, $moveTo->id));
\DB::table('transactions')->where('account_id', $account->id)->update(['account_id' => $moveTo->id]);
$collection = Transaction::groupBy('transaction_journal_id', 'account_id')
->where('account_id', $moveTo->id)
->get(['transaction_journal_id', 'account_id', \DB::raw('count(*) as the_count')]) // @phpstan-ignore-line
;
if (0 === $collection->count()) {
return;
}
/** @var JournalDestroyService $service */
$service = app(JournalDestroyService::class);
$user = $account->user;
/** @var \stdClass $row */
foreach ($collection as $row) {
if ((int)$row->the_count > 1) {
$journalId = $row->transaction_journal_id;
$journal = $user->transactionJournals()->find($journalId);
if (null !== $journal) {
app('log')->debug(sprintf('Deleted journal #%d because it has the same source as destination.', $journal->id));
$service->destroy($journal);
}
}
}
}
private function updateRecurrences(Account $account, Account $moveTo): void
{
\DB::table('recurrences_transactions')->where('source_id', $account->id)->update(['source_id' => $moveTo->id]);