From e91c82aa8b9181f104fad42299001b9eac5634f5 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Wed, 18 Nov 2020 20:35:09 +1100 Subject: [PATCH] Fixes for bulk import --- app/Console/Commands/CheckData.php | 4 ++-- app/Console/Commands/ImportMigrations.php | 3 ++- app/Jobs/Util/Import.php | 4 +--- app/Jobs/Util/WebhookHandler.php | 4 ++-- 4 files changed, 7 insertions(+), 8 deletions(-) diff --git a/app/Console/Commands/CheckData.php b/app/Console/Commands/CheckData.php index e9fec0c084d0..086f9a9371df 100644 --- a/app/Console/Commands/CheckData.php +++ b/app/Console/Commands/CheckData.php @@ -304,7 +304,7 @@ class CheckData extends Command if ($ledger && number_format($invoice_balance, 4) != number_format($client->balance, 4)) { $wrong_balances++; - $this->logMessage($client->present()->name.' - '.$client->number." - Balance Failure - Invoice Balances = {$invoice_balance} Client Balance = {$client->balance} Ledger Balance = {$ledger->balance}"); + $this->logMessage("# {$client->id} " . $client->present()->name.' - '.$client->number." - Balance Failure - Invoice Balances = {$invoice_balance} Client Balance = {$client->balance} Ledger Balance = {$ledger->balance}"); $this->isValid = false; } @@ -341,7 +341,7 @@ class CheckData extends Command if (round($total_invoice_payments, 2) != round($client->paid_to_date, 2)) { $wrong_paid_to_dates++; - $this->logMessage($client->present()->name.' - '.$client->id." - Paid to date does not match Client Paid To Date = {$client->paid_to_date} - Invoice Payments = {$total_invoice_payments}"); + $this->logMessage($client->present()->name.'id = # '.$client->id." - Paid to date does not match Client Paid To Date = {$client->paid_to_date} - Invoice Payments = {$total_invoice_payments}"); $this->isValid = false; } diff --git a/app/Console/Commands/ImportMigrations.php b/app/Console/Commands/ImportMigrations.php index 9e1e4a00b2eb..ae9fa32c63a2 100644 --- a/app/Console/Commands/ImportMigrations.php +++ b/app/Console/Commands/ImportMigrations.php @@ -72,6 +72,7 @@ class ImportMigrations extends Command foreach ($directory as $file) { if ($file->getExtension() === 'zip') { $this->info('Started processing: '.$file->getBasename().' at '.now()); + info("dispatching"); StartMigration::dispatch($file->getRealPath(), $this->getUser(), $this->getUser()->companies()->first()); } } @@ -84,7 +85,7 @@ class ImportMigrations extends Command $user = User::factory()->create([ 'account_id' => $account->id, - 'email' => $this->faker->email, + 'email' => Str::random(10) . "@example.com", 'confirmation_code' => $this->createDbHash(config('database.default')), ]); diff --git a/app/Jobs/Util/Import.php b/app/Jobs/Util/Import.php index e0d5468ab5ce..98e86fdd700f 100644 --- a/app/Jobs/Util/Import.php +++ b/app/Jobs/Util/Import.php @@ -148,7 +148,7 @@ class Import implements ShouldQueue */ private $ids = []; - public $tries = 1; + public $tries = 0; public $timeout = 86400; @@ -1192,8 +1192,6 @@ class Import implements ShouldQueue $user = UserFactory::create($this->company->account->id); } - info("getting user id = {$user->id} - {$user->email}"); - return $user; } diff --git a/app/Jobs/Util/WebhookHandler.php b/app/Jobs/Util/WebhookHandler.php index 7bb753dcb05f..db3b55a288e5 100644 --- a/app/Jobs/Util/WebhookHandler.php +++ b/app/Jobs/Util/WebhookHandler.php @@ -55,11 +55,11 @@ class WebhookHandler implements ShouldQueue MultiDB::setDb($this->company->db); - if (! $this->entity->company || $this->entity->company->is_disabled) { + if (! $this->company || $this->company->is_disabled) { return true; } - $subscriptions = Webhook::where('company_id', $this->entity->company_id) + $subscriptions = Webhook::where('company_id', $this->company->id) ->where('event_id', $this->event_id) ->get();