# DeleteJobProfile

## Permission Scope

`position`

## Overview

DeleteJobProfile removes a JobProfile that is not referenced by any Position, since a role template is only safe to remove once no seat depends on it.

## Business Rules

- Deletion is rejected while any Position references the JobProfile
- Because JobProfile is not effective-dated, deletion is a hard delete once unreferenced — there is no historical generation to preserve

## Process Flow

```mermaid
flowchart TD
    A[Delete JobProfile] --> B{JobProfile exists?}
    B -- No --> X[Reject: JOB_PROFILE_NOT_FOUND]
    B -- Yes --> C{Any Position references it?}
    C -- Yes --> Y[Reject: JOB_PROFILE_IN_USE]
    C -- No --> D[Hard delete JobProfile]
```

## External Dependencies

- [workforce::Position](../model/Position.md) model — checked for references before deletion

## Error Scenarios

- **JOB_PROFILE_NOT_FOUND**: the specified JobProfile does not exist
- **JOB_PROFILE_IN_USE**: the JobProfile is referenced by at least one Position

## Test Cases

- deleting a JobProfile referenced by any Position is rejected
- deleting an unreferenced JobProfile succeeds
- deleting a non-existent JobProfile is rejected

