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/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/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/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/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), 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..d00d7b2036 --- /dev/null +++ b/tests/Unit/RangeDetectionTest.php @@ -0,0 +1,55 @@ +makeRanges($range); + } + + foreach($ranges as $range) + { + + } + + } + + private function makeRanges(array $range) + { + + return range($range[0], $range[1]); + + } + +}