From c8f1c97078dd1d2ce4485c18a97577d38a0f07ac Mon Sep 17 00:00:00 2001 From: Deon George Date: Thu, 22 May 2025 09:23:21 +1000 Subject: [PATCH] Fix working out invoice start date, when start_at or invoice_next_at is null --- app/Models/Service.php | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/app/Models/Service.php b/app/Models/Service.php index 6a44702..cbafdb2 100644 --- a/app/Models/Service.php +++ b/app/Models/Service.php @@ -608,12 +608,15 @@ class Service extends Model implements IDs { $last = $this->getInvoicedToAttribute(); - if ($this->stop_at && $last->greaterThan($this->stop_at)) - return NULL; + if ($last) { + return ($this->stop_at && $last->greaterThan($this->stop_at)) + ? NULL + : $last->addDay(); + } - return $last - ? $last->addDay() - : (min($this->start_at,$this->invoice_next_at) ?: Carbon::now()); + return ($this->invoice_next_at) + ? $this->invoice_next_at + : ($this->start_at ?: Carbon::now()); } /**