From 1060dad7d7747a88239c3d374b9b5c1ee3b54b68 Mon Sep 17 00:00:00 2001 From: paulwer Date: Mon, 18 Dec 2023 15:58:16 +0100 Subject: [PATCH] better logging for jobs --- app/Jobs/Bank/ProcessBankTransactionsNordigen.php | 14 +++++++------- app/Jobs/Bank/ProcessBankTransactionsYodlee.php | 8 ++++---- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/app/Jobs/Bank/ProcessBankTransactionsNordigen.php b/app/Jobs/Bank/ProcessBankTransactionsNordigen.php index 962bcb4cfd85..ff59383a1766 100644 --- a/app/Jobs/Bank/ProcessBankTransactionsNordigen.php +++ b/app/Jobs/Bank/ProcessBankTransactionsNordigen.php @@ -67,14 +67,16 @@ class ProcessBankTransactionsNordigen implements ShouldQueue set_time_limit(0); + nlog("Nordigen: Processing transactions for account: {$this->bank_integration->account->key}"); + // UPDATE ACCOUNT try { $this->updateAccount(); } catch (\Exception $e) { - nlog("{$this->bank_integration->account->key} - exited abnormally => " . $e->getMessage()); + nlog("Nordigen: {$this->bank_integration->nordigen_account_id} - exited abnormally => " . $e->getMessage()); $content = [ - "Processing transactions for account: {$this->bank_integration->account->key} failed", + "Processing transactions for account: {$this->bank_integration->nordigen_account_id} failed", "Exception Details => ", $e->getMessage(), ]; @@ -94,10 +96,10 @@ class ProcessBankTransactionsNordigen implements ShouldQueue $this->bank_integration->from_date = now()->subDays(90); $this->bank_integration->save(); - nlog("{$this->bank_integration->account->key} - exited abnormally => " . $e->getMessage()); + nlog("Nordigen: {$this->bank_integration->nordigen_account_id} - exited abnormally => " . $e->getMessage()); $content = [ - "Processing transactions for account: {$this->bank_integration->account->key} failed", + "Processing transactions for account: {$this->bank_integration->nordigen_account_id} failed", "Exception Details => ", $e->getMessage(), ]; @@ -114,13 +116,11 @@ class ProcessBankTransactionsNordigen implements ShouldQueue private function updateAccount() { - - Log::info("try to execute updateAccount"); if (!$this->nordigen->isAccountActive($this->bank_integration->nordigen_account_id)) { $this->bank_integration->disabled_upstream = true; $this->bank_integration->save(); $this->stop_loop = false; - Log::info("account inactive"); + Log::info("Nordigen: account inactive: " . $this->bank_integration->nordigen_account_id); // @turbo124 @todo send email for expired account return; } diff --git a/app/Jobs/Bank/ProcessBankTransactionsYodlee.php b/app/Jobs/Bank/ProcessBankTransactionsYodlee.php index f5344169e211..0d2122c6733c 100644 --- a/app/Jobs/Bank/ProcessBankTransactionsYodlee.php +++ b/app/Jobs/Bank/ProcessBankTransactionsYodlee.php @@ -71,16 +71,16 @@ class ProcessBankTransactionsYodlee implements ShouldQueue //Loop through everything until we are up to date $this->from_date = $this->from_date ?: '2021-01-01'; - nlog("Processing transactions for account: {$this->bank_integration->account->key}"); + nlog("Yodlee: Processing transactions for account: {$this->bank_integration->account->key}"); do { try { $this->processTransactions(); } catch (\Exception $e) { - nlog("{$this->account->bank_integration_account_id} - exited abnormally => " . $e->getMessage()); + nlog("Yodlee: {$this->bank_integration->bank_account_id} - exited abnormally => " . $e->getMessage()); $content = [ - "Processing transactions for account: {$this->bank_integration->account->key} failed", + "Processing transactions for account: {$this->bank_integration->bank_account_id} failed", "Exception Details => ", $e->getMessage(), ]; @@ -164,7 +164,7 @@ class ProcessBankTransactionsYodlee implements ShouldQueue $now = now(); foreach ($transactions as $transaction) { - if (BankTransaction::query()->where('transaction_id', $transaction['transaction_id'])->where('company_id', $this->company->id)->withTrashed()->exists()) { + if (BankTransaction::query()->where('transaction_id', $transaction['transaction_id'])->where('company_id', $this->company->id)->where('bank_integration_id', $this->bank_integration->id)->withTrashed()->exists()) { // @turbo124 was not scoped to bank_integration_id => from my pov this should be present, because when an account was historized (is_deleted) a transaction can occur multiple (in the archived bank_integration and in the new one continue; }