From 77f9c95139470015574ef9d50f9fae9f71acb7e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20Beganovi=C4=87?= Date: Wed, 15 Sep 2021 17:21:31 +0200 Subject: [PATCH] Fixes for options key pushing --- app/Services/Client/Statement.php | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/app/Services/Client/Statement.php b/app/Services/Client/Statement.php index 822984e2a0e3..c87719e8267e 100644 --- a/app/Services/Client/Statement.php +++ b/app/Services/Client/Statement.php @@ -47,7 +47,9 @@ class Statement public function run(): ?string { - $this->setupEntity()->setupOptions(); + $this + ->setupOptions() + ->setupEntity(); $html = new HtmlEngine($this->getInvitation()); @@ -111,10 +113,6 @@ class Statement $this->entity = $this->getInvoices()->first(); } - if (count($this->getPayments()) >= 1) { - $this->entity = $this->getPayments()->first(); - } - return $this; } @@ -125,19 +123,19 @@ class Statement */ protected function setupOptions(): self { - if (\array_key_exists('start_date', $this->options)) { + if (! \array_key_exists('start_date', $this->options)) { $this->options['start_date'] = now()->startOfYear()->format('Y-m-d'); } - if (\array_key_exists('end_date', $this->options)) { + if (! \array_key_exists('end_date', $this->options)) { $this->options['end_date'] = now()->format('Y-m-d'); } - if (\array_key_exists('show_payments_table', $this->options)) { + if (! \array_key_exists('show_payments_table', $this->options)) { $this->options['show_payments_table'] = false; } - if (\array_key_exists('show_aging_table', $this->options)) { + if (! \array_key_exists('show_aging_table', $this->options)) { $this->options['show_aging_table'] = false; } @@ -182,7 +180,7 @@ class Statement if ($this->entity instanceof Invoice || $this->entity instanceof Payment) { return $this->entity->invitations->first(); } - + return false; }