diff --git a/app/Models/Client.php b/app/Models/Client.php index 689578df8385..bb83e7297552 100644 --- a/app/Models/Client.php +++ b/app/Models/Client.php @@ -778,7 +778,12 @@ class Client extends BaseModel implements HasLocalePreference $timezone = $this->company->timezone(); - $offset -= $timezone->utc_offset; + //2023-11-08 adjustments for DST + date_default_timezone_set('GMT'); + $date = new \DateTime("now", new \DateTimeZone($timezone->name)); + $offset -= $date->getOffset(); + +// $offset -= $timezone->utc_offset; $offset += ($entity_send_time * 3600); return $offset; diff --git a/app/Models/Company.php b/app/Models/Company.php index 897b7aa584ee..2f10c9d9ae2a 100644 --- a/app/Models/Company.php +++ b/app/Models/Company.php @@ -928,7 +928,11 @@ class Company extends BaseModel $timezone = $this->timezone(); - $offset -= $timezone->utc_offset; + date_default_timezone_set('GMT'); + $date = new \DateTime("now", new \DateTimeZone($timezone->name)); + $offset -= $date->getOffset(); + + // $offset -= $timezone->utc_offset; $offset += ($entity_send_time * 3600); return $offset; diff --git a/tests/Feature/ReminderTest.php b/tests/Feature/ReminderTest.php index 2b9b63c55461..6e2ee4fd28f8 100644 --- a/tests/Feature/ReminderTest.php +++ b/tests/Feature/ReminderTest.php @@ -322,15 +322,29 @@ class ReminderTest extends TestCase $this->travelTo(now()->startOfDay()); - for($x=0; $x<46; $x++) { + $travel_date = Carbon::parse($this->invoice->next_send_date); + $x = false; + for($x=0; $x<50; $x++) { - // nlog("traveller {$x} ".now()->format('Y-m-d h:i:s')); (new ReminderJob())->handle(); - $this->invoice = $this->invoice->fresh(); - $this->assertNull($this->invoice->reminder1_sent); - $this->assertNull($this->invoice->reminder_last_sent); + + if(now()->gt($travel_date) && !$x) { + + + $this->assertNotNull($this->invoice->reminder1_sent); + $this->assertNotNull($this->invoice->reminder_last_sent); + $x=true; + } + + + if(!$x){ + $this->invoice = $this->invoice->fresh(); + $this->assertNull($this->invoice->reminder1_sent); + $this->assertNull($this->invoice->reminder_last_sent); + } $this->travelTo(now()->addHours(1)); + } // nlog("traveller ".now()->format('Y-m-d'));