From a1e9de5807f365d5926fb19582ecc528fc32edd3 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Sat, 17 Jul 2021 22:01:00 +1000 Subject: [PATCH 1/3] Minor Clean up --- app/Http/Middleware/PasswordProtection.php | 5 ----- app/Jobs/Util/Import.php | 6 +----- 2 files changed, 1 insertion(+), 10 deletions(-) diff --git a/app/Http/Middleware/PasswordProtection.php b/app/Http/Middleware/PasswordProtection.php index 74aea8e573e8..e3a80cf45730 100644 --- a/app/Http/Middleware/PasswordProtection.php +++ b/app/Http/Middleware/PasswordProtection.php @@ -57,9 +57,6 @@ class PasswordProtection $user = false; $google = new Google(); $user = $google->getTokenResponse(request()->header('X-API-OAUTH-PASSWORD')); - - nlog("user"); - nlog($user); if (is_array($user)) { @@ -68,8 +65,6 @@ class PasswordProtection 'oauth_provider_id'=> 'google' ]; - nlog($query); - //If OAuth and user also has a password set - check both if ($existing_user = MultiDB::hasUser($query) && auth()->user()->company()->oauth_password_required && auth()->user()->has_password && Hash::check(auth()->user()->password, $request->header('X-API-PASSWORD'))) { diff --git a/app/Jobs/Util/Import.php b/app/Jobs/Util/Import.php index 111212195505..4200e4efb61f 100644 --- a/app/Jobs/Util/Import.php +++ b/app/Jobs/Util/Import.php @@ -430,8 +430,6 @@ class Import implements ShouldQueue private function transformCompanyData(array $data): array { - nlog("pre transformed"); - nlog($data['settings']); $company_settings = CompanySettings::defaults(); @@ -454,9 +452,7 @@ class Import implements ShouldQueue $data['settings'] = $company_settings; } - - nlog("transformed Settings"); - nlog($data['settings']); + return $data; } From 0f10c4b8dd67079413e8837792cc0ab86e66fe95 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Sun, 18 Jul 2021 08:43:07 +1000 Subject: [PATCH 2/3] minor fixes --- .../Subscription/SubscriptionService.php | 2 +- .../ninja2020/invoices/payment.blade.php | 24 +++++++++++++------ 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/app/Services/Subscription/SubscriptionService.php b/app/Services/Subscription/SubscriptionService.php index de4518e295a1..68b3078cdfb7 100644 --- a/app/Services/Subscription/SubscriptionService.php +++ b/app/Services/Subscription/SubscriptionService.php @@ -940,7 +940,7 @@ class SubscriptionService 'subscription' => $this->subscription->hashed_id, 'recurring_invoice' => $recurring_invoice_hashed_id, 'client' => $invoice->client->hashed_id, - 'contact' => $invoice->client->primary_contact()->first()->hashed_id, + 'contact' => $invoice->client->primary_contact()->first() ? $invoice->client->contacts->first() : false, 'invoice' => $invoice->hashed_id, ]; diff --git a/resources/views/portal/ninja2020/invoices/payment.blade.php b/resources/views/portal/ninja2020/invoices/payment.blade.php index 4f2b8451855f..6596f978e32d 100644 --- a/resources/views/portal/ninja2020/invoices/payment.blade.php +++ b/resources/views/portal/ninja2020/invoices/payment.blade.php @@ -48,18 +48,28 @@ @endif
+ @if($invoice->po_number) +
+ {{ ctrans('texts.po_number') }} +
+
+ {{ $invoice->po_number }} +
+ @elseif($invoice->public_notes) +
+ {{ ctrans('texts.public_notes') }} +
+
+ {{ $invoice->public_notes }} +
+ @else
{{ ctrans('texts.invoice_date') }}
- @if($invoice->po_number) - {{ $invoice->po_number }} - @elseif($invoice->public_notes) - {{ $invoice->public_notes }} - @else - {{ $invoice->date}} - @endif + {{ $invoice->date }}
+ @endif
@if(!empty($invoice->due_date) && !is_null($invoice->due_date)) From d1c4da1d64a0680347631cf7787e4ae3541175a6 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Sun, 18 Jul 2021 14:05:33 +1000 Subject: [PATCH 3/3] Do no add duplicate Task Statuses if they already exist --- .../Company/CreateCompanyTaskStatuses.php | 3 + app/Jobs/Util/RefreshPdfs.php | 76 +++++++++++++++++++ 2 files changed, 79 insertions(+) create mode 100644 app/Jobs/Util/RefreshPdfs.php diff --git a/app/Jobs/Company/CreateCompanyTaskStatuses.php b/app/Jobs/Company/CreateCompanyTaskStatuses.php index d95954f8d25c..2c07dbf6cf1f 100644 --- a/app/Jobs/Company/CreateCompanyTaskStatuses.php +++ b/app/Jobs/Company/CreateCompanyTaskStatuses.php @@ -48,6 +48,9 @@ class CreateCompanyTaskStatuses MultiDB::setDb($this->company->db); + if(TaskStatus::where('company_id', $this->company->id)->count() > 0) + return; + $task_statuses = [ ['name' => ctrans('texts.backlog'), 'company_id' => $this->company->id, 'user_id' => $this->user->id, 'created_at' => now(), 'updated_at' => now(), 'status_order' => 1], ['name' => ctrans('texts.ready_to_do'), 'company_id' => $this->company->id, 'user_id' => $this->user->id, 'created_at' => now(), 'updated_at' => now(), 'status_order' => 2], diff --git a/app/Jobs/Util/RefreshPdfs.php b/app/Jobs/Util/RefreshPdfs.php new file mode 100644 index 000000000000..4de8e77457cd --- /dev/null +++ b/app/Jobs/Util/RefreshPdfs.php @@ -0,0 +1,76 @@ +company = $company; + } + + /** + * Execute the job. + * + * @return void + */ + public function handle() + { + + MultiDB::setDb($this->company->db); + + + InvoiceInvitation::where('company_id', $this->company->id)->cursor()->each(function ($invitation) { + + nlog("generating invoice pdf for {$invitation->invoice_id}"); + CreateEntityPdf::dispatch($invitation); + + }); + + QuoteInvitation::where('company_id', $this->company->id)->cursor()->each(function ($invitation) { + + nlog("generating quote pdf for {$invitation->quote_id}"); + CreateEntityPdf::dispatch($invitation); + + }); + + + CreditInvitation::where('company_id', $this->company->id)->cursor()->each(function ($invitation) { + + nlog("generating credit pdf for {$invitation->credit_id}"); + CreateEntityPdf::dispatch($invitation); + + }); + + } +}