Skip to content

[BE-26] Implement maintenance records CRUD — POST, GET, PATCH /assets/:id/maintenance #899

Description

@yusuftomilola

Overview

The "Maintenance" tab on the asset detail page shows service history and lets users log new maintenance events. Maintenance records track what was done, by whom, at what cost, and the outcome.

Context

  • Frontend API: frontend/lib/api/assets.tscreateMaintenanceRecord(assetId, data), getMaintenanceRecords(assetId), update status via PATCH /assets/:id/maintenance/:maintId
  • Frontend types in frontend/lib/query/types/asset.ts: MaintenanceRecord with type (PREVENTIVE, CORRECTIVE, SCHEDULED), status (SCHEDULED, IN_PROGRESS, COMPLETED, CANCELLED), scheduledDate, completedDate, cost, notes, technician
  • Status changes set asset status to MAINTENANCE when IN_PROGRESS, and back to ACTIVE when COMPLETED

Acceptance Criteria

  • Create MaintenanceRecord entity: id, assetId, type (MaintenanceType enum), status (MaintenanceStatus enum), title, description, scheduledDate, completedDate, cost (decimal), technicianName, providerId (nullable FK to Vendor), notes, createdBy, createdAt, updatedAt
  • POST /assets/:id/maintenance — creates record, if status: IN_PROGRESS sets asset status to MAINTENANCE, logs MAINTENANCE history entry
  • GET /assets/:id/maintenance — paginated list of maintenance records, most recent first, with total cost sum
  • PATCH /assets/:id/maintenance/:maintId — update status, completedDate, cost, notes. If status becomes COMPLETED, set asset status back to ACTIVE
  • Return 404 if maintenance record does not belong to the specified asset

Metadata

Metadata

Assignees

Labels

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions