From 50a1a746f315240650bba0977fc09030403c4d1d Mon Sep 17 00:00:00 2001 From: David Bomba Date: Sat, 1 Feb 2025 14:38:14 +1100 Subject: [PATCH] Fixes for recurring due dates --- app/Models/Task.php | 6 +++--- tests/Unit/RecurringDatesTest.php | 7 +++---- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/app/Models/Task.php b/app/Models/Task.php index df76cc4a07..b3f18dcec5 100644 --- a/app/Models/Task.php +++ b/app/Models/Task.php @@ -380,16 +380,16 @@ class Task extends BaseModel if ($this->company->invoice_task_datelog) { $date_time[] = Carbon::createFromTimestamp((int)$log[0]) - ->setTimeZone($this->company->timezone()->name) + // ->setTimeZone($this->company->timezone()->name) ->format($parent_entity->date_format()); } if ($this->company->invoice_task_timelog) { $date_time[] = Carbon::createFromTimestamp((int)$log[0]) - ->setTimeZone($this->company->timezone()->name) + // ->setTimeZone($this->company->timezone()->name) ->format($time_format) . " - " . Carbon::createFromTimestamp((int)$log[1]) - ->setTimeZone($this->company->timezone()->name) + // ->setTimeZone($this->company->timezone()->name) ->format($time_format); } diff --git a/tests/Unit/RecurringDatesTest.php b/tests/Unit/RecurringDatesTest.php index d6d6a54939..bba0d22c3a 100644 --- a/tests/Unit/RecurringDatesTest.php +++ b/tests/Unit/RecurringDatesTest.php @@ -114,17 +114,16 @@ class RecurringDatesTest extends TestCase $recurring_invoice->frequency_id = RecurringInvoice::FREQUENCY_MONTHLY; $recurring_invoice->remaining_cycles = 5; $recurring_invoice->due_date_days = '1'; - $recurring_invoice->next_send_date = now()->format('Y-m-d'); + $recurring_invoice->next_send_date = now()->setTimezone($this->client->timezone()->name)->format('Y-m-d'); $recurring_invoice->save(); $recurring_invoice = $recurring_invoice->calc()->getInvoice(); - $recurring_invoice->service()->sendNow(); $r = $recurring_invoice->fresh(); - $invoice = $recurring_invoice->invoices()->latest()->first(); $this->assertGreaterThan(0, $recurring_invoice->invoices()->count()); - $expected_due_date = now()->startOfDay()->addMonthWithoutOverflow()->startOfMonth()->format('Y-m-d'); + $expected_due_date = now()->setTimezone($this->client->timezone()->name)->startOfDay()->addMonthWithoutOverflow()->startOfMonth()->format('Y-m-d'); + $this->assertEquals($expected_due_date, $invoice->due_date); }