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()); } /**