From 5cbded2ee19fb2b971304d8f83810e193a2f1f0d Mon Sep 17 00:00:00 2001 From: David Bomba Date: Sun, 25 Jun 2023 20:09:45 +1000 Subject: [PATCH] Accept activities for import --- app/Exceptions/Handler.php | 2 +- app/Jobs/Util/Import.php | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/app/Exceptions/Handler.php b/app/Exceptions/Handler.php index c551b6d383..506213d577 100644 --- a/app/Exceptions/Handler.php +++ b/app/Exceptions/Handler.php @@ -105,7 +105,7 @@ class Handler extends ExceptionHandler if($exception instanceof ThrottleRequestsException && class_exists(\Modules\Admin\Events\ThrottledExceptionRaised::class)) { $uri = urldecode(request()->getRequestUri()); - event(new \Modules\Admin\Events\ThrottledExceptionRaised(auth()->user()?->account?->key, $uri, request()->ip())); + // event(new \Modules\Admin\Events\ThrottledExceptionRaised(auth()->user()?->account?->key, $uri, request()->ip())); } Integration::configureScope(function (Scope $scope): void { diff --git a/app/Jobs/Util/Import.php b/app/Jobs/Util/Import.php index ceedd63d0c..b04d4c2467 100644 --- a/app/Jobs/Util/Import.php +++ b/app/Jobs/Util/Import.php @@ -304,7 +304,7 @@ class Import implements ShouldQueue if (round($total_invoice_payments, 2) != round($client->paid_to_date, 2)) { $client->paid_to_date = $total_invoice_payments; - $client->save(); + $client->saveQuietly(); } }); } @@ -320,12 +320,12 @@ class Import implements ShouldQueue $company_ledger->notes = 'Migrated Client Balance'; $company_ledger->balance = $invoice_balances; $company_ledger->activity_id = Activity::CREATE_CLIENT; - $company_ledger->save(); + $company_ledger->saveQuietly(); $client->company_ledger()->save($company_ledger); $client->balance = $invoice_balances; - $client->save(); + $client->saveQuietly(); }); } @@ -1781,6 +1781,7 @@ class Import implements ShouldQueue { Activity::where('company_id', $this->company->id)->cursor()->each(function ($a){ $a->forceDelete(); + nlog("deleting {$a->id}"); }); Activity::unguard(); @@ -1828,6 +1829,8 @@ try { $modified['client_contact_id'] = $this->transformId('client_contacts', $resource['client_contact_id']); } + $modified['updated_at'] = $modified['created_at']; + $act = Activity::make($modified); $act->save(['timestamps' => false]);