Fix working out invoice start date, when start_at or invoice_next_at is null

This commit is contained in:
Deon George 2025-05-22 09:23:21 +10:00
parent 36e379d876
commit c8f1c97078

View File

@ -608,12 +608,15 @@ class Service extends Model implements IDs
{ {
$last = $this->getInvoicedToAttribute(); $last = $this->getInvoicedToAttribute();
if ($this->stop_at && $last->greaterThan($this->stop_at)) if ($last) {
return NULL; return ($this->stop_at && $last->greaterThan($this->stop_at))
? NULL
: $last->addDay();
}
return $last return ($this->invoice_next_at)
? $last->addDay() ? $this->invoice_next_at
: (min($this->start_at,$this->invoice_next_at) ?: Carbon::now()); : ($this->start_at ?: Carbon::now());
} }
/** /**