chore: reformat code.

This commit is contained in:
James Cole
2023-06-21 12:34:58 +02:00
parent 8d87abde64
commit 3dcb35710b
799 changed files with 23319 additions and 22173 deletions

View File

@@ -40,8 +40,8 @@ use stdClass;
class AccountDestroyService
{
/**
* @param Account $account
* @param Account|null $moveTo
* @param Account $account
* @param Account|null $moveTo
*
* @return void
*/
@@ -71,60 +71,7 @@ class AccountDestroyService
}
/**
* @param Account $account
* @param Account $moveTo
*/
public function moveTransactions(Account $account, Account $moveTo): void
{
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')]);
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 = (int)$row->transaction_journal_id;
$journal = $user->transactionJournals()->find($journalId);
if (null !== $journal) {
Log::debug(sprintf('Deleted journal #%d because it has the same source as destination.', $journal->id));
$service->destroy($journal);
}
}
}
}
/**
* @param Account $account
*/
private function destroyJournals(Account $account): void
{
/** @var JournalDestroyService $service */
$service = app(JournalDestroyService::class);
Log::debug('Now trigger account delete response #'.$account->id);
/** @var Transaction $transaction */
foreach ($account->transactions()->get() as $transaction) {
Log::debug('Now at transaction #'.$transaction->id);
/** @var TransactionJournal $journal */
$journal = $transaction->transactionJournal()->first();
if (null !== $journal) {
Log::debug('Call for deletion of journal #'.$journal->id);
$service->destroy($journal);
}
}
}
/**
* @param Account $account
* @param Account $account
*/
private function destroyOpeningBalance(Account $account): void
{
@@ -160,7 +107,70 @@ class AccountDestroyService
}
/**
* @param Account $account
* @param Account $account
* @param Account $moveTo
*/
public function moveTransactions(Account $account, Account $moveTo): void
{
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')]);
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 = (int)$row->transaction_journal_id;
$journal = $user->transactionJournals()->find($journalId);
if (null !== $journal) {
Log::debug(sprintf('Deleted journal #%d because it has the same source as destination.', $journal->id));
$service->destroy($journal);
}
}
}
}
/**
* @param Account $account
* @param Account $moveTo
*/
private function updateRecurrences(Account $account, Account $moveTo): void
{
DB::table('recurrences_transactions')->where('source_id', $account->id)->update(['source_id' => $moveTo->id]);
DB::table('recurrences_transactions')->where('destination_id', $account->id)->update(['destination_id' => $moveTo->id]);
}
/**
* @param Account $account
*/
private function destroyJournals(Account $account): void
{
/** @var JournalDestroyService $service */
$service = app(JournalDestroyService::class);
Log::debug('Now trigger account delete response #' . $account->id);
/** @var Transaction $transaction */
foreach ($account->transactions()->get() as $transaction) {
Log::debug('Now at transaction #' . $transaction->id);
/** @var TransactionJournal $journal */
$journal = $transaction->transactionJournal()->first();
if (null !== $journal) {
Log::debug('Call for deletion of journal #' . $journal->id);
$service->destroy($journal);
}
}
}
/**
* @param Account $account
*/
private function destroyRecurrences(Account $account): void
{
@@ -177,14 +187,4 @@ class AccountDestroyService
$destroyService->destroyById((int)$recurrenceId);
}
}
/**
* @param Account $account
* @param Account $moveTo
*/
private function updateRecurrences(Account $account, Account $moveTo): void
{
DB::table('recurrences_transactions')->where('source_id', $account->id)->update(['source_id' => $moveTo->id]);
DB::table('recurrences_transactions')->where('destination_id', $account->id)->update(['destination_id' => $moveTo->id]);
}
}

View File

@@ -31,7 +31,7 @@ use FireflyIII\Models\Bill;
class BillDestroyService
{
/**
* @param Bill $bill
* @param Bill $bill
*/
public function destroy(Bill $bill): void
{

View File

@@ -34,7 +34,7 @@ use FireflyIII\Models\Budget;
class BudgetDestroyService
{
/**
* @param Budget $budget
* @param Budget $budget
*/
public function destroy(Budget $budget): void
{

View File

@@ -34,7 +34,7 @@ use FireflyIII\Models\Category;
class CategoryDestroyService
{
/**
* @param Category $category
* @param Category $category
*/
public function destroy(Category $category): void
{

View File

@@ -33,7 +33,7 @@ use FireflyIII\Models\TransactionCurrency;
class CurrencyDestroyService
{
/**
* @param TransactionCurrency $currency
* @param TransactionCurrency $currency
*/
public function destroy(TransactionCurrency $currency): void
{

View File

@@ -37,7 +37,7 @@ use Illuminate\Support\Facades\Log;
class JournalDestroyService
{
/**
* @param TransactionJournal $journal
* @param TransactionJournal $journal
*/
public function destroy(TransactionJournal $journal): void
{

View File

@@ -31,10 +31,24 @@ use FireflyIII\Models\RecurrenceTransaction;
*/
class RecurrenceDestroyService
{
/**
* Delete recurrence by ID
*
* @param int $recurrenceId
*/
public function destroyById(int $recurrenceId): void
{
$recurrence = Recurrence::find($recurrenceId);
if (null === $recurrence) {
return;
}
$this->destroy($recurrence);
}
/**
* Delete recurrence.
*
* @param Recurrence $recurrence
* @param Recurrence $recurrence
*
*/
public function destroy(Recurrence $recurrence): void
@@ -53,18 +67,4 @@ class RecurrenceDestroyService
// delete recurrence
$recurrence->delete();
}
/**
* Delete recurrence by ID
*
* @param int $recurrenceId
*/
public function destroyById(int $recurrenceId): void
{
$recurrence = Recurrence::find($recurrenceId);
if (null === $recurrence) {
return;
}
$this->destroy($recurrence);
}
}

View File

@@ -35,7 +35,7 @@ use Illuminate\Support\Facades\Log;
class TransactionGroupDestroyService
{
/**
* @param TransactionGroup $transactionGroup
* @param TransactionGroup $transactionGroup
*/
public function destroy(TransactionGroup $transactionGroup): void
{