diff --git a/app/Services/InvoiceService.php b/app/Services/InvoiceService.php index 203edb8a1b..dc712011d5 100644 --- a/app/Services/InvoiceService.php +++ b/app/Services/InvoiceService.php @@ -160,7 +160,7 @@ class InvoiceService extends BaseService [ 'invoice_status_name', function ($model) { - return $model->quote_invoice_id ? link_to("invoices/{$model->quote_invoice_id}/edit", trans('texts.converted')) : self::getStatusLabel($model->invoice_status_id, $model->invoice_status_name); + return $model->quote_invoice_id ? link_to("invoices/{$model->quote_invoice_id}/edit", trans('texts.converted')) : self::getStatusLabel($model); } ] ]; @@ -236,11 +236,18 @@ class InvoiceService extends BaseService ]; } - private function getStatusLabel($statusId, $statusName) + private function getStatusLabel($model) { - $label = trans("texts.status_" . strtolower($statusName)); + // check if invoice is overdue + if (Utils::parseFloat($model->balance) && $model->due_date && $model->due_date != '0000-00-00') { + if (\DateTime::createFromFormat('Y-m-d', $model->due_date) < new \DateTime("now")) { + return "