1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-08 20:22:42 +01:00

Fixes recurring invoices end date parsing (port of #2905 to master) (#2906)

* Invoice edit view: fix date parsing

View gets the date already formatted and Carbon isn't always able to parse that format automatically, so convert it back to SQL format

* RecurringInvoiceDatatable: fix status label
This commit is contained in:
Francisco Ferreira 2019-07-18 07:26:59 +01:00 committed by David Bomba
parent 2a290765e9
commit 5f998b0ea8
2 changed files with 4 additions and 1 deletions

View File

@ -3,6 +3,7 @@
namespace App\Ninja\Datatables; namespace App\Ninja\Datatables;
use Auth; use Auth;
use Carbon;
use URL; use URL;
use Utils; use Utils;
use App\Models\Invoice; use App\Models\Invoice;
@ -84,6 +85,8 @@ class RecurringInvoiceDatatable extends EntityDatatable
if ($model->invoice_status_id == INVOICE_STATUS_SENT) { if ($model->invoice_status_id == INVOICE_STATUS_SENT) {
if (! $model->last_sent_date_sql || $model->last_sent_date_sql == '0000-00-00') { if (! $model->last_sent_date_sql || $model->last_sent_date_sql == '0000-00-00') {
$label = trans('texts.pending'); $label = trans('texts.pending');
} elseif ($model->end_date_sql && Carbon::parse($model->end_date_sql)->isPast()) {
$label = trans('texts.status_completed');
} else { } else {
$label = trans('texts.active'); $label = trans('texts.active');
} }

View File

@ -76,7 +76,7 @@
@if ($invoice->is_recurring && $invoice->isSent()) @if ($invoice->is_recurring && $invoice->isSent())
@if (! $invoice->last_sent_date || $invoice->last_sent_date == '0000-00-00') @if (! $invoice->last_sent_date || $invoice->last_sent_date == '0000-00-00')
{!! $invoice->present()->statusLabel(trans('texts.pending')) !!} {!! $invoice->present()->statusLabel(trans('texts.pending')) !!}
@elseif ($invoice->end_date && Carbon::parse($invoice->end_date)->isPast()) @elseif ($invoice->end_date && Carbon::parse(Utils::toSqlDate($invoice->end_date))->isPast())
{!! $invoice->present()->statusLabel(trans('texts.status_completed')) !!} {!! $invoice->present()->statusLabel(trans('texts.status_completed')) !!}
@else @else
{!! $invoice->present()->statusLabel(trans('texts.active')) !!} {!! $invoice->present()->statusLabel(trans('texts.active')) !!}