Equipment
Represents a physical piece of transportation equipment (truck, trailer, chassis, etc.) owned or managed by an organization. Equipment records are organization-scoped and support soft-deletion and extensible custom values.
Fields
| Field | Type | Required | Max Length | Description |
|---|---|---|---|---|
equipmentId | Int | — | — | Primary key |
organizationId | Int | Yes | — | Owning organization |
unitNumber | String | Yes | 50 | Unique identifier within the organization (e.g., truck number, trailer number). Unique constraint includes soft-deleted records. |
equipmentTypeId | Int | Yes | — | FK to EquipmentType — must belong to the same organization |
equipmentStatusId | Int | Yes | — | FK to EquipmentStatus — must belong to the same organization |
notes | String? | No | 700 | Free-text notes |
customValues | JSON? | No | — | JSONB dictionary of organization-specific properties |
isDeleted | Bool | — | — | Soft-delete flag. Set by Delete() or ChangeIsDeleted(). Filtered from default queries. |
created | DateTime | — | — | Audit: creation timestamp |
createdBy | String | — | — | Audit: creating user ID |
lastModified | DateTime | — | — | Audit: last modification timestamp |
lastModifiedBy | String | — | — | Audit: last modifying user ID |
Relationships
- Organization — belongs to one
Organization - EquipmentType — many-to-one; defines the equipment category (truck, trailer, etc.)
- EquipmentStatus — many-to-one; current status with lifecycle stage and color
Domain Methods
| Method | Description |
|---|---|
ChangeUnitNumber(string) | Update the unit number |
ChangeEquipmentTypeId(int) | Reassign equipment type |
ChangeEquipmentStatusId(int) | Change current status |
ChangeNotes(string?) | Update or clear notes |
ChangeCustomValues(Dictionary<string, object?>?) | Full-replace — pass null to clear all custom values, or a new dictionary to replace the entire set |
ChangeCustomValue(string fieldName, object? value) | Single-key upsert — adds or updates one key without affecting others |
ChangeIsDeleted(bool) | Toggle soft-delete state |
Delete() | Convenience method that sets IsDeleted = true |
Soft-Delete Behavior
Equipment uses soft-deletion. The IsDeleted flag is applied as a global query filter — deleted equipment does not appear in standard queries unless filters are explicitly ignored.
The UnitNumber uniqueness constraint applies across all records including soft-deleted ones. Restoring a deleted equipment record with a unit number that has been reused will fail validation.
Custom Values
CustomValues is a Dictionary<string, object?> persisted as JSONB. Two update modes are available:
Full-replace (use when updating multiple keys at once):
- task: Equipment/Update@1
inputs:
organizationId: ${organizationId}
equipmentId: ${equipmentId}
equipment:
customValues:
licensePlate: "ABC-1234"
color: "White"
year: 2022
Passing null for customValues preserves the existing dictionary (no-op). To clear all custom values, use the full-replace with an empty object or use the domain method directly.
Single-key update (use to update one key without affecting others):
- task: Equipment/ChangeCustomValue@1
inputs:
organizationId: ${organizationId}
equipmentId: ${equipmentId}
key: "lastInspectionDate"
value: "2026-04-15"
See Custom Values for filtering, sorting, and UI configuration.
Workflow Examples
Create equipment
- task: Equipment/Create@1
name: createEquipment
inputs:
organizationId: ${organizationId}
equipment:
unitNumber: "TRL-0042"
equipmentTypeId: ${trailerTypeId}
equipmentStatusId: ${availableStatusId}
notes: "48ft flatbed"
customValues:
licensePlate: "XYZ-9900"
year: 2021
Change status
- task: Equipment/Update@1
inputs:
organizationId: ${organizationId}
equipmentId: ${equipmentId}
equipment:
equipmentStatusId: ${inUseStatusId}
Soft-delete equipment
- task: Equipment/Delete@1
inputs:
organizationId: ${organizationId}
equipmentId: ${equipmentId}
Validation Rules
unitNumberis required and must be unique within the organization (including deleted records).equipmentTypeIdmust reference anEquipmentTypethat exists in the same organization.equipmentStatusIdmust reference anEquipmentStatusthat exists in the same organization.
See Also
- EquipmentStatus — status definitions with lifecycle stages and colors
- EquipmentType — equipment category definitions
- Custom Values — JSONB extension pattern