From fc803e91ebc378ee78c5be77b30cccbed55ec1af Mon Sep 17 00:00:00 2001 From: = Date: Sat, 27 Feb 2021 11:34:57 +1100 Subject: [PATCH 1/3] Version bump -> v5.1.11 --- VERSION.txt | 2 +- config/ninja.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/VERSION.txt b/VERSION.txt index ed45e0a6e8..831c6cd600 100644 --- a/VERSION.txt +++ b/VERSION.txt @@ -1 +1 @@ -5.1.10 \ No newline at end of file +5.1.11 \ No newline at end of file diff --git a/config/ninja.php b/config/ninja.php index e2e6cf03b9..39402be587 100644 --- a/config/ninja.php +++ b/config/ninja.php @@ -13,7 +13,7 @@ return [ 'require_https' => env('REQUIRE_HTTPS', true), 'app_url' => rtrim(env('APP_URL', ''), '/'), 'app_domain' => env('APP_DOMAIN', ''), - 'app_version' => '5.1.10', + 'app_version' => '5.1.11', 'minimum_client_version' => '5.0.16', 'terms_version' => '1.0.1', 'api_secret' => env('API_SECRET', false), From 5f14cc0c5d56aa053902b8c688461c2c9a4fa024 Mon Sep 17 00:00:00 2001 From: = Date: Sat, 27 Feb 2021 21:08:39 +1100 Subject: [PATCH 2/3] Working on task range overlap --- app/Models/Company.php | 1 + ...1713_add_invoice_task_datelog_property.php | 31 +++++++++++ tests/Unit/RangeDetectionTest.php | 55 +++++++++++++++++++ 3 files changed, 87 insertions(+) create mode 100644 database/migrations/2021_02_27_091713_add_invoice_task_datelog_property.php create mode 100644 tests/Unit/RangeDetectionTest.php diff --git a/app/Models/Company.php b/app/Models/Company.php index 97f376d231..8706ff03f8 100644 --- a/app/Models/Company.php +++ b/app/Models/Company.php @@ -85,6 +85,7 @@ class Company extends BaseModel 'expense_inclusive_taxes', 'session_timeout', 'oauth_password_required', + 'invoice_task_datelog', ]; protected $hidden = [ diff --git a/database/migrations/2021_02_27_091713_add_invoice_task_datelog_property.php b/database/migrations/2021_02_27_091713_add_invoice_task_datelog_property.php new file mode 100644 index 0000000000..3267ab7778 --- /dev/null +++ b/database/migrations/2021_02_27_091713_add_invoice_task_datelog_property.php @@ -0,0 +1,31 @@ +boolean('invoice_task_datelog')->default(0); + }); + + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + // + } +} diff --git a/tests/Unit/RangeDetectionTest.php b/tests/Unit/RangeDetectionTest.php new file mode 100644 index 0000000000..18ff33c08a --- /dev/null +++ b/tests/Unit/RangeDetectionTest.php @@ -0,0 +1,55 @@ +makeRanges($range); + } + + foreach($ranges as $range) + { + + } + + } + + private function makeRanges(array $ranges) + { + + return range($range[0], $range[1]); + + } + +} From e668e7fd5a6604f0e1a791adb0db48b1407d5d4e Mon Sep 17 00:00:00 2001 From: David Bomba Date: Sun, 28 Feb 2021 13:12:55 +1100 Subject: [PATCH 3/3] Fixes for Quotes not attaching to emails --- app/Http/Middleware/UserVerified.php | 6 +++++- app/Mail/Engine/CreditEmailEngine.php | 4 +++- app/Mail/Engine/QuoteEmailEngine.php | 4 ++-- app/Models/Presenters/CompanyPresenter.php | 4 ++-- app/Models/Quote.php | 16 +++++++++------- app/Observers/CreditObserver.php | 2 +- app/Observers/QuoteObserver.php | 2 -- tests/Unit/RangeDetectionTest.php | 2 +- 8 files changed, 23 insertions(+), 17 deletions(-) diff --git a/app/Http/Middleware/UserVerified.php b/app/Http/Middleware/UserVerified.php index 35a0acdeea..ce8a899764 100644 --- a/app/Http/Middleware/UserVerified.php +++ b/app/Http/Middleware/UserVerified.php @@ -26,7 +26,7 @@ class UserVerified public function __construct(?User $user) { - $this->user = $user ?: auth()->user(); + $this->user = property_exists($user, 'id') ? $user : auth()->user(); } /** @@ -44,6 +44,10 @@ class UserVerified 'errors' => new \stdClass, ]; + // nlog(auth()->user()->toArray()); + // nlog($this->user->toArray()); + // nlog((bool)$this->user->isVerified()); + if ($this->user && !$this->user->isVerified()) return response()->json($error, 403); diff --git a/app/Mail/Engine/CreditEmailEngine.php b/app/Mail/Engine/CreditEmailEngine.php index c97827b0fd..835c9d47ae 100644 --- a/app/Mail/Engine/CreditEmailEngine.php +++ b/app/Mail/Engine/CreditEmailEngine.php @@ -89,7 +89,9 @@ class CreditEmailEngine extends BaseEmailEngine ->setInvitation($this->invitation); if ($this->client->getSetting('pdf_email_attachment') !== false) { - $this->setAttachments(['path' => $this->credit->pdf_file_path(), 'name' => basename($this->credit->pdf_file_path())]); + $this->setAttachments([$this->credit->pdf_file_path()]); + + // $this->setAttachments(['path' => $this->credit->pdf_file_path(), 'name' => basename($this->credit->pdf_file_path())]); } //attach third party documents diff --git a/app/Mail/Engine/QuoteEmailEngine.php b/app/Mail/Engine/QuoteEmailEngine.php index a79a1fa077..5751cdf5ac 100644 --- a/app/Mail/Engine/QuoteEmailEngine.php +++ b/app/Mail/Engine/QuoteEmailEngine.php @@ -90,8 +90,8 @@ class QuoteEmailEngine extends BaseEmailEngine if ($this->client->getSetting('pdf_email_attachment') !== false) { - // $this->setAttachments([$this->quote->pdf_file_path()]); - $this->setAttachments(['path' => $this->quote->pdf_file_path(), 'name' => basename($this->quote->pdf_file_path())]); + $this->setAttachments([$this->quote->pdf_file_path()]); + //$this->setAttachments(['path' => $this->quote->pdf_file_path(), 'name' => basename($this->quote->pdf_file_path())]); } diff --git a/app/Models/Presenters/CompanyPresenter.php b/app/Models/Presenters/CompanyPresenter.php index fec12b9eac..10410d9a8a 100644 --- a/app/Models/Presenters/CompanyPresenter.php +++ b/app/Models/Presenters/CompanyPresenter.php @@ -91,13 +91,13 @@ class CompanyPresenter extends EntityPresenter } } - public function getSpcQrCode($client_currency, $invoice_number, $balance) + public function getSpcQrCode($client_currency, $invoice_number, $balance_due_raw) { $settings = $this->entity->settings; return - "SPC\n0200\n1\nCH860021421411198240K\nK\n{$this->name}\n{$settings->address1}\n{$settings->postal_code} {$settings->city}\n\n\nCH\n\n\n\n\n\n\n\n{$balance}\n{$client_currency}\n\n\n\n\n\n\n\nNON\n\n{$invoice_number}\nEPD\n"; + "SPC\n0200\n1\nCH860021421411198240K\nK\n{$this->name}\n{$settings->address1}\n{$settings->postal_code} {$settings->city}\n\n\nCH\n\n\n\n\n\n\n\n{$balance_due_raw}\n{$client_currency}\n\n\n\n\n\n\n\nNON\n\n{$invoice_number}\nEPD\n"; } } diff --git a/app/Models/Quote.php b/app/Models/Quote.php index 9038c6ef3b..1f2b740ea8 100644 --- a/app/Models/Quote.php +++ b/app/Models/Quote.php @@ -200,25 +200,27 @@ class Quote extends BaseModel return new QuoteService($this); } + public function pdf_file_path($invitation = null, string $type = 'url') { if (! $invitation) { - $invitation = $this->invitations->where('client_contact_id', $this->client->primary_contact()->first()->id)->first(); + $invitation = $this->invitations->first(); } $storage_path = Storage::$type($this->client->quote_filepath().$this->number.'.pdf'); - if (Storage::exists($this->client->quote_filepath().$this->number.'.pdf')) { - return $storage_path; + nlog($storage_path); + + if (! Storage::exists($this->client->quote_filepath().$this->number.'.pdf')) { + event(new QuoteWasUpdated($this, $this->company, Ninja::eventVars())); + CreateEntityPdf::dispatchNow($invitation); } - event(new QuoteWasUpdated($this, $this->company, Ninja::eventVars())); - - CreateEntityPdf::dispatchNow($invitation); - return $storage_path; } + + /** * @param int $status * @return string diff --git a/app/Observers/CreditObserver.php b/app/Observers/CreditObserver.php index 9969f7f02c..fd7f3d2d25 100644 --- a/app/Observers/CreditObserver.php +++ b/app/Observers/CreditObserver.php @@ -37,7 +37,7 @@ class CreditObserver */ public function updated(Credit $credit) { - UnlinkFile::dispatchNow(config('filesystems.default'), $credit->client->credit_filepath() . $credit->number.'.pdf'); + } /** diff --git a/app/Observers/QuoteObserver.php b/app/Observers/QuoteObserver.php index f2a9471111..1530b99a38 100644 --- a/app/Observers/QuoteObserver.php +++ b/app/Observers/QuoteObserver.php @@ -51,8 +51,6 @@ class QuoteObserver WebhookHandler::dispatch(Webhook::EVENT_UPDATE_QUOTE, $quote, $quote->company); } - UnlinkFile::dispatchNow(config('filesystems.default'), $quote->client->quote_filepath() . $quote->number.'.pdf'); - } /** diff --git a/tests/Unit/RangeDetectionTest.php b/tests/Unit/RangeDetectionTest.php index 18ff33c08a..d00d7b2036 100644 --- a/tests/Unit/RangeDetectionTest.php +++ b/tests/Unit/RangeDetectionTest.php @@ -45,7 +45,7 @@ class RangeDetectionTest extends TestCase } - private function makeRanges(array $ranges) + private function makeRanges(array $range) { return range($range[0], $range[1]);