Skip to content

A free open source IT asset/license management system

Fixed #19674 - maintenance notes not veing saved on action_log via API

snipe4b71c46b78a6
diff --git a/app/Observers/MaintenanceObserver.php b/app/Observers/MaintenanceObserver.php
index 069cef0197..86fab9f8c8 100644
--- a/app/Observers/MaintenanceObserver.php
+++ b/app/Observers/MaintenanceObserver.php
@@ -89,6 +89,7 @@ class MaintenanceObserver
$logAction->created_at = date('Y-m-d H:i:s');
$logAction->action_date = date('Y-m-d H:i:s');
$logAction->created_by = auth()->id();
+ $logAction->note = $maintenance->notes;
if ($maintenance->imported) {
$logAction->setActionSource('importer');
}
@@ -110,6 +111,7 @@ class MaintenanceObserver
$logAction->created_at = date('Y-m-d H:i:s');
$logAction->action_date = date('Y-m-d H:i:s');
$logAction->created_by = auth()->id();
+ $logAction->note = $maintenance->notes;
$logAction->logaction('delete');
}
}
diff --git a/tests/Feature/Maintenances/Api/CreateMaintenanceTest.php b/tests/Feature/Maintenances/Api/CreateMaintenanceTest.php
index f6a563e2d5..e1fe628469 100644
--- a/tests/Feature/Maintenances/Api/CreateMaintenanceTest.php
+++ b/tests/Feature/Maintenances/Api/CreateMaintenanceTest.php
@@ -72,6 +72,35 @@ class CreateMaintenanceTest extends TestCase
$this->assertHasTheseActionLogs($maintenance, ['create']);
}
+
+ public function test_create_maintenance_action_log_carries_notes()
+ {
+ $actor = User::factory()->superuser()->create();
+ $asset = Asset::factory()->create();
+ $type = MaintenanceType::factory()->create();
+
+ $this->actingAsForApi($actor)
+ ->postJson(route('api.maintenances.store'), [
+ 'name' => 'With Notes',
+ 'asset_id' => $asset->id,
+ 'maintenance_type_id' => $type->id,
+ 'start_date' => '2026-01-01',
+ 'is_warranty' => 0,
+ 'notes' => 'field noise on power-on',
+ ])
+ ->assertOk()
+ ->assertJsonPath('status', 'success');
+
+ $maintenance = Maintenance::where('name', 'With Notes')->firstOrFail();
+
+ $log = \App\Models\Actionlog::query()
+ ->where('item_type', Maintenance::class)
+ ->where('item_id', $maintenance->id)
+ ->where('action_type', 'create')
+ ->firstOrFail();
+
+ $this->assertSame('field noise on power-on', $log->note);
+ }
public function test_bulk_create_creates_one_maintenance_per_asset()
{