A free open source IT asset/license management system
Fixed #19511 - double-formatting date in acceptance notification
snipe6612baab645a
diff --git a/app/Notifications/AcceptanceItemAcceptedToUserNotification.php b/app/Notifications/AcceptanceItemAcceptedToUserNotification.phpindex 642c066387..4a03fc6938 100644--- a/app/Notifications/AcceptanceItemAcceptedToUserNotification.php+++ b/app/Notifications/AcceptanceItemAcceptedToUserNotification.php@@ -2,7 +2,6 @@namespace App\Notifications;-use App\Helpers\Helper;use App\Models\Setting;use Illuminate\Bus\Queueable;use Illuminate\Contracts\Queue\ShouldQueue;@@ -15,16 +14,27 @@ class AcceptanceItemAcceptedToUserNotification extends Notification implements Suse Queueable;public $item_tag;+public $item_name;+public $item_model;+public $item_serial;+public $item_status;+public $accepted_date;+public $assigned_to;+public $note;+public $company_name;+public $file;+public $qty;+public $custom_fields;/**@@ -39,7 +49,10 @@ class AcceptanceItemAcceptedToUserNotification extends Notification implements S$this->item_model = $params['item_model'];$this->item_serial = $params['item_serial'];$this->item_status = $params['item_status'];- $this->accepted_date = Helper::getFormattedDateObject($params['accepted_date'], 'datetime', false);+ // The controller already runs the accepted_date through+ // Helper::getFormattedDateObject, so it arrives pre-formatted+ // in the caller's locale. Don't invoke it here.+ $this->accepted_date = $params['accepted_date'];$this->assigned_to = $params['assigned_to'];$this->note = $params['note'] ?? null;$this->company_name = $params['company_name'];diff --git a/tests/Unit/Notifications/AcceptanceItemAcceptedToUserNotificationTest.php b/tests/Unit/Notifications/AcceptanceItemAcceptedToUserNotificationTest.phpnew file mode 100644index 0000000000..d8ef150ca5--- /dev/null+++ b/tests/Unit/Notifications/AcceptanceItemAcceptedToUserNotificationTest.php@@ -0,0 +1,38 @@+<?php++namespace Tests\Unit\Notifications;++use App\Notifications\AcceptanceItemAcceptedToUserNotification;+use PHPUnit\Framework\Attributes\Test;+use Tests\TestCase;++class AcceptanceItemAcceptedToUserNotificationTest extends TestCase+{+ #[Test]+ public function constructor_does_not_reparse_pre_formatted_accepted_date(): void+ {+ // GH #19511: the controller passes accepted_date already+ // formatted in the tenant's locale (e.g. `dd/mm/rrrr` renders+ // as `27/08/2026 10:00`). The notification constructor used to+ // run that pre-formatted string through Helper::getFormattedDateObject+ // a second time, which tried to `new Carbon('27/08/2026 10:00')`+ // and blew up on any locale format Carbon does not natively+ // parse (dd/mm/yyyy reads as m/d/y, month 27 fails). The+ // constructor must pass the value through unchanged.+ $polishFormatted = '27/08/2026 10:00';++ $notification = new AcceptanceItemAcceptedToUserNotification([+ 'item_tag' => 'AT-1',+ 'item_name' => 'Test',+ 'item_model' => 'Model',+ 'item_serial' => 'SN',+ 'item_status' => 'Deployed',+ 'accepted_date' => $polishFormatted,+ 'assigned_to' => 'Test User',+ 'company_name' => 'Test Co',+ 'qty' => 1,+ ]);++ $this->assertSame($polishFormatted, $notification->accepted_date);+ }+}