mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-12 15:35:15 +00:00
Remove static references
This commit is contained in:
@@ -75,7 +75,7 @@ class AccountDestroyService
|
||||
*/
|
||||
private function destroyOpeningBalance(Account $account): void
|
||||
{
|
||||
Log::debug(sprintf('Searching for opening balance for account #%d "%s"', $account->id, $account->name));
|
||||
app('log')->debug(sprintf('Searching for opening balance for account #%d "%s"', $account->id, $account->name));
|
||||
$set = $account->transactions()
|
||||
->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id')
|
||||
->leftJoin('transaction_types', 'transaction_types.id', '=', 'transaction_journals.transaction_type_id')
|
||||
@@ -83,7 +83,7 @@ class AccountDestroyService
|
||||
->get(['transactions.transaction_journal_id']);
|
||||
if ($set->count() > 0) {
|
||||
$journalId = (int)$set->first()->transaction_journal_id;
|
||||
Log::debug(sprintf('Found opening balance journal with ID #%d', $journalId));
|
||||
app('log')->debug(sprintf('Found opening balance journal with ID #%d', $journalId));
|
||||
|
||||
// get transactions with this journal (should be just one):
|
||||
$transactions = Transaction::where('transaction_journal_id', $journalId)
|
||||
@@ -91,9 +91,9 @@ class AccountDestroyService
|
||||
->get();
|
||||
/** @var Transaction $transaction */
|
||||
foreach ($transactions as $transaction) {
|
||||
Log::debug(sprintf('Found transaction with ID #%d', $transaction->id));
|
||||
app('log')->debug(sprintf('Found transaction with ID #%d', $transaction->id));
|
||||
$ibAccount = $transaction->account;
|
||||
Log::debug(sprintf('Connected to account #%d "%s"', $ibAccount->id, $ibAccount->name));
|
||||
app('log')->debug(sprintf('Connected to account #%d "%s"', $ibAccount->id, $ibAccount->name));
|
||||
|
||||
$ibAccount->accountMeta()->delete();
|
||||
$transaction->delete();
|
||||
@@ -114,7 +114,7 @@ class AccountDestroyService
|
||||
*/
|
||||
public function moveTransactions(Account $account, Account $moveTo): void
|
||||
{
|
||||
Log::debug(sprintf('Move from account #%d to #%d', $account->id, $moveTo->id));
|
||||
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')
|
||||
@@ -133,7 +133,7 @@ class AccountDestroyService
|
||||
$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));
|
||||
app('log')->debug(sprintf('Deleted journal #%d because it has the same source as destination.', $journal->id));
|
||||
$service->destroy($journal);
|
||||
}
|
||||
}
|
||||
@@ -158,14 +158,14 @@ class AccountDestroyService
|
||||
/** @var JournalDestroyService $service */
|
||||
$service = app(JournalDestroyService::class);
|
||||
|
||||
Log::debug('Now trigger account delete response #' . $account->id);
|
||||
app('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);
|
||||
app('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);
|
||||
app('log')->debug('Call for deletion of journal #' . $journal->id);
|
||||
$service->destroy($journal);
|
||||
}
|
||||
}
|
||||
|
@@ -41,17 +41,17 @@ class JournalDestroyService
|
||||
*/
|
||||
public function destroy(TransactionJournal $journal): void
|
||||
{
|
||||
Log::debug(sprintf('Now in %s', __METHOD__));
|
||||
app('log')->debug(sprintf('Now in %s', __METHOD__));
|
||||
/** @var Transaction $transaction */
|
||||
foreach ($journal->transactions()->get() as $transaction) {
|
||||
Log::debug(sprintf('Will now delete transaction #%d', $transaction->id));
|
||||
app('log')->debug(sprintf('Will now delete transaction #%d', $transaction->id));
|
||||
$transaction->delete();
|
||||
}
|
||||
|
||||
// also delete journal_meta entries.
|
||||
/** @var TransactionJournalMeta $meta */
|
||||
foreach ($journal->transactionJournalMeta()->get() as $meta) {
|
||||
Log::debug(sprintf('Will now delete meta-entry #%d', $meta->id));
|
||||
app('log')->debug(sprintf('Will now delete meta-entry #%d', $meta->id));
|
||||
$meta->delete();
|
||||
}
|
||||
|
||||
|
@@ -39,7 +39,7 @@ class TransactionGroupDestroyService
|
||||
*/
|
||||
public function destroy(TransactionGroup $transactionGroup): void
|
||||
{
|
||||
Log::debug(sprintf('Now in %s', __METHOD__));
|
||||
app('log')->debug(sprintf('Now in %s', __METHOD__));
|
||||
/** @var JournalDestroyService $service */
|
||||
$service = app(JournalDestroyService::class);
|
||||
foreach ($transactionGroup->transactionJournals as $journal) {
|
||||
|
Reference in New Issue
Block a user