From f95f2469a03a98d49db5cb09de1e50b117f5f4a2 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Wed, 26 Jul 2023 09:27:16 +1000 Subject: [PATCH] Fixes for static analysis --- .../Controllers/BankIntegrationController.php | 5 +- .../Controllers/BankTransactionController.php | 4 +- app/Jobs/Bank/MatchBankTransactions.php | 6 +- app/Jobs/Bank/ProcessBankTransactions.php | 10 ++-- app/Models/ClientContact.php | 55 +------------------ 5 files changed, 15 insertions(+), 65 deletions(-) diff --git a/app/Http/Controllers/BankIntegrationController.php b/app/Http/Controllers/BankIntegrationController.php index e5095bdaff..e80a9b31a5 100644 --- a/app/Http/Controllers/BankIntegrationController.php +++ b/app/Http/Controllers/BankIntegrationController.php @@ -12,6 +12,7 @@ namespace App\Http\Controllers; use Illuminate\Http\Request; +use Illuminate\Http\Response; use App\Models\BankIntegration; use App\Utils\Traits\MakesHash; use Illuminate\Http\JsonResponse; @@ -50,7 +51,7 @@ class BankIntegrationController extends BaseController /** * @param BankIntegrationFilters $filters - * @return Responsec + * @return Response */ public function index(BankIntegrationFilters $filters) { @@ -250,7 +251,7 @@ class BankIntegrationController extends BaseController * Return the remote list of accounts stored on the third party provider * and update our local cache. * - * @return Response + * @return Response | JsonResponse * */ diff --git a/app/Http/Controllers/BankTransactionController.php b/app/Http/Controllers/BankTransactionController.php index eefad1dd49..d8b05a3d5e 100644 --- a/app/Http/Controllers/BankTransactionController.php +++ b/app/Http/Controllers/BankTransactionController.php @@ -71,7 +71,7 @@ class BankTransactionController extends BaseController public function create(CreateBankTransactionRequest $request) { - $bank_transaction = BankTransactionFactory::create(auth()->user()->company()->id, auth()->user()->id, auth()->user()->account_id); + $bank_transaction = BankTransactionFactory::create(auth()->user()->company()->id, auth()->user()->id); return $this->itemResponse($bank_transaction); } @@ -79,7 +79,7 @@ class BankTransactionController extends BaseController public function store(StoreBankTransactionRequest $request) { //stub to store the model - $bank_transaction = $this->bank_transaction_repo->save($request->all(), BankTransactionFactory::create(auth()->user()->company()->id, auth()->user()->id, auth()->user()->account_id)); + $bank_transaction = $this->bank_transaction_repo->save($request->all(), BankTransactionFactory::create(auth()->user()->company()->id, auth()->user()->id)); return $this->itemResponse($bank_transaction); } diff --git a/app/Jobs/Bank/MatchBankTransactions.php b/app/Jobs/Bank/MatchBankTransactions.php index f2a44c60c8..ca6dc4a5a2 100644 --- a/app/Jobs/Bank/MatchBankTransactions.php +++ b/app/Jobs/Bank/MatchBankTransactions.php @@ -47,11 +47,11 @@ class MatchBankTransactions implements ShouldQueue private array $input; - protected Company $company; + protected ?Company $company; public Invoice $invoice; - private BankTransaction $bt; + private ?BankTransaction $bt; private $categories; @@ -78,8 +78,6 @@ class MatchBankTransactions implements ShouldQueue /** * Execute the job. * - * - * @return void */ public function handle() { diff --git a/app/Jobs/Bank/ProcessBankTransactions.php b/app/Jobs/Bank/ProcessBankTransactions.php index f2c3a519eb..aeb309c50e 100644 --- a/app/Jobs/Bank/ProcessBankTransactions.php +++ b/app/Jobs/Bank/ProcessBankTransactions.php @@ -108,10 +108,12 @@ class ProcessBankTransactions implements ShouldQueue $at = new AccountTransformer(); $account = $at->transform($account_summary); - $this->bank_integration->balance = $account['current_balance']; - $this->bank_integration->currency = $account['account_currency']; - $this->bank_integration->save(); - + if($account[0]['current_balance']) { + $this->bank_integration->balance = $account['current_balance']; + $this->bank_integration->currency = $account['account_currency']; + $this->bank_integration->save(); + } + } } catch(\Exception $e) { diff --git a/app/Models/ClientContact.php b/app/Models/ClientContact.php index 2de9ed0b9b..4c0c054b8e 100644 --- a/app/Models/ClientContact.php +++ b/app/Models/ClientContact.php @@ -130,59 +130,8 @@ use Laracasts\Presenter\PresentableTrait; * @property-read \Illuminate\Database\Eloquent\Collection $recurring_invoice_invitations * @property-read \Illuminate\Database\Eloquent\Collection $credit_invitations * @property-read \Illuminate\Database\Eloquent\Collection $invoice_invitations - * @property-read \Illuminate\Notifications\DatabaseNotificationCollection $notifications - * @property-read \Illuminate\Database\Eloquent\Collection $quote_invitations - * @property-read \Illuminate\Database\Eloquent\Collection $recurring_invoice_invitations - * @property-read \Illuminate\Database\Eloquent\Collection $credit_invitations - * @property-read \Illuminate\Database\Eloquent\Collection $invoice_invitations - * @property-read \Illuminate\Notifications\DatabaseNotificationCollection $notifications - * @property-read \Illuminate\Database\Eloquent\Collection $quote_invitations - * @property-read \Illuminate\Database\Eloquent\Collection $recurring_invoice_invitations - * @property-read \Illuminate\Database\Eloquent\Collection $credit_invitations - * @property-read \Illuminate\Database\Eloquent\Collection $invoice_invitations - * @property-read \Illuminate\Notifications\DatabaseNotificationCollection $notifications - * @property-read \Illuminate\Database\Eloquent\Collection $quote_invitations - * @property-read \Illuminate\Database\Eloquent\Collection $recurring_invoice_invitations - * @property-read \Illuminate\Database\Eloquent\Collection $credit_invitations - * @property-read \Illuminate\Database\Eloquent\Collection $invoice_invitations - * @property-read \Illuminate\Notifications\DatabaseNotificationCollection $notifications - * @property-read \Illuminate\Database\Eloquent\Collection $quote_invitations - * @property-read \Illuminate\Database\Eloquent\Collection $recurring_invoice_invitations - * @property-read \Illuminate\Database\Eloquent\Collection $credit_invitations - * @property-read \Illuminate\Database\Eloquent\Collection $invoice_invitations - * @property-read \Illuminate\Notifications\DatabaseNotificationCollection $notifications - * @property-read \Illuminate\Database\Eloquent\Collection $quote_invitations - * @property-read \Illuminate\Database\Eloquent\Collection $recurring_invoice_invitations - * @property-read \Illuminate\Database\Eloquent\Collection $credit_invitations - * @property-read \Illuminate\Database\Eloquent\Collection $invoice_invitations - * @property-read \Illuminate\Notifications\DatabaseNotificationCollection $notifications - * @property-read \Illuminate\Database\Eloquent\Collection $quote_invitations - * @property-read \Illuminate\Database\Eloquent\Collection $recurring_invoice_invitations - * @property-read \Illuminate\Database\Eloquent\Collection $credit_invitations - * @property-read \Illuminate\Database\Eloquent\Collection $invoice_invitations - * @property-read \Illuminate\Notifications\DatabaseNotificationCollection $notifications - * @property-read \Illuminate\Database\Eloquent\Collection $quote_invitations - * @property-read \Illuminate\Database\Eloquent\Collection $recurring_invoice_invitations - * @property-read \Illuminate\Database\Eloquent\Collection $credit_invitations - * @property-read \Illuminate\Database\Eloquent\Collection $invoice_invitations - * @property-read \Illuminate\Notifications\DatabaseNotificationCollection $notifications - * @property-read \Illuminate\Database\Eloquent\Collection $quote_invitations - * @property-read \Illuminate\Database\Eloquent\Collection $recurring_invoice_invitations - * @property-read \Illuminate\Database\Eloquent\Collection $credit_invitations - * @property-read \Illuminate\Database\Eloquent\Collection $invoice_invitations - * @property-read \Illuminate\Notifications\DatabaseNotificationCollection $notifications - * @property-read \Illuminate\Database\Eloquent\Collection $quote_invitations - * @property-read \Illuminate\Database\Eloquent\Collection $recurring_invoice_invitations - * @property-read \Illuminate\Database\Eloquent\Collection $credit_invitations - * @property-read \Illuminate\Database\Eloquent\Collection $invoice_invitations - * @property-read \Illuminate\Notifications\DatabaseNotificationCollection $notifications - * @property-read \Illuminate\Database\Eloquent\Collection $quote_invitations - * @property-read \Illuminate\Database\Eloquent\Collection $recurring_invoice_invitations - * @property-read \Illuminate\Database\Eloquent\Collection $credit_invitations - * @property-read \Illuminate\Database\Eloquent\Collection $invoice_invitations - * @property-read \Illuminate\Notifications\DatabaseNotificationCollection $notifications - * @property-read \Illuminate\Database\Eloquent\Collection $quote_invitations - * @property-read \Illuminate\Database\Eloquent\Collection $recurring_invoice_invitations + * @property-read \Illuminate\Database\Eloquent\Collection $client + * @mixin \Eloquent */ class ClientContact extends Authenticatable implements HasLocalePreference