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 "

".trans('texts.overdue')."

"; + } + } + + $label = trans("texts.status_" . strtolower($model->invoice_status_name)); $class = 'default'; - switch ($statusId) { + switch ($model->invoice_status_id) { case INVOICE_STATUS_SENT: $class = 'info'; break; diff --git a/resources/lang/en/texts.php b/resources/lang/en/texts.php index 2b9c80f974..b94a2b5edb 100644 --- a/resources/lang/en/texts.php +++ b/resources/lang/en/texts.php @@ -1149,4 +1149,6 @@ return array( 'trial_footer_last_day' => 'This is the last day of your free trial, :link to upgrade now.', 'trial_call_to_action' => 'Start Free Trial', 'trial_success' => 'Successfully enabled two week free pro plan trial', + 'overdue' => 'Overdue', + );