From d2e39f9c6c7b70eae6553c38be95b879a105a5a1 Mon Sep 17 00:00:00 2001 From: Hillel Coren Date: Tue, 27 Mar 2018 15:41:26 +0300 Subject: [PATCH] Fix recurrence timezone --- app/Models/Traits/HasRecurrence.php | 6 ++---- resources/views/invoices/edit.blade.php | 6 ++++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/app/Models/Traits/HasRecurrence.php b/app/Models/Traits/HasRecurrence.php index 2888e54bc014..a81ef8cc0280 100644 --- a/app/Models/Traits/HasRecurrence.php +++ b/app/Models/Traits/HasRecurrence.php @@ -129,12 +129,10 @@ trait HasRecurrence $startDate = $this->getOriginal('last_sent_date') ?: $this->getOriginal('start_date'); $startDate .= ' ' . $this->account->recurring_hour . ':00:00'; - $startDate = $this->account->getDateTime($startDate); - $endDate = $this->end_date ? $this->account->getDateTime($this->getOriginal('end_date')) : null; $timezone = $this->account->getTimezone(); $rule = $this->getRecurrenceRule(); - $rule = new \Recurr\Rule("{$rule}", $startDate); + $rule = new \Recurr\Rule("{$rule}", $startDate, null, $timezone); // Fix for months with less than 31 days $transformerConfig = new \Recurr\Transformer\ArrayTransformerConfig(); @@ -144,7 +142,7 @@ trait HasRecurrence $transformer->setConfig($transformerConfig); $dates = $transformer->transform($rule); - if (count($dates) < 2) { + if (count($dates) < 1) { return false; } diff --git a/resources/views/invoices/edit.blade.php b/resources/views/invoices/edit.blade.php index fc665767c78d..b7350ef4529f 100644 --- a/resources/views/invoices/edit.blade.php +++ b/resources/views/invoices/edit.blade.php @@ -294,8 +294,10 @@ {!! trans('texts.last_sent_on', ['date' => link_to('/invoices/'.$lastSent->public_id, $invoice->last_sent_date, ['id' => 'lastSent'])]) !!}

@endif @if ($invoice->is_recurring && $invoice->start_date && $invoice->is_public) - {!! trans('texts.next_send_on', ['date' => ''.$account->formatDate($invoice->getNextSendDate() ?: $invoice->start_date). - '']) !!} + @if ($sendNextDate = $invoice->getNextSendDate()) + {!! trans('texts.next_send_on', ['date' => '' . $account->formatDate($sendNextDate). + '']) !!} + @endif @if ($invoice->getDueDate())
{!! trans('texts.next_due_on', ['date' => ''.$account->formatDate($invoice->getDueDate($invoice->getNextSendDate())).'']) !!}