# DeactivateWorkRegime

## Permission Scope

`workRegime`

## Overview

DeactivateWorkRegime marks an ACTIVE WorkRegime catalog entry INACTIVE so it is no longer selectable for new employments, while historical WorkerEmployment rows that reference it keep resolving.

## Business Rules

- The entry is identified by `id` and must currently be ACTIVE
- Deactivation flips `status` ACTIVE → INACTIVE; the entry is not hard-deleted
- Deactivating an entry that is already INACTIVE is rejected as an invalid status transition
- An INACTIVE entry stays referenced by existing WorkerEmployments but is not offered for new ones

## Process Flow

```mermaid
flowchart TD
    A[Deactivate WorkRegime by id] --> B{WorkRegime exists?}
    B -- No --> X[Reject: WORK_REGIME_NOT_FOUND]
    B -- Yes --> C{status is ACTIVE?}
    C -- No --> Y[Reject: INVALID_WORK_REGIME_STATUS]
    C -- Yes --> D[Set status = INACTIVE]
    D --> E[No longer selectable for new employments]
```

## External Dependencies

- [workforce::WorkRegime](../model/WorkRegime.md) model — the entity this command mutates

## Error Scenarios

- **WORK_REGIME_NOT_FOUND**: no WorkRegime exists for the given id
- **INVALID_WORK_REGIME_STATUS**: the work regime is not in a status that allows this transition

## Test Cases

- deactivating an ACTIVE entry sets it INACTIVE
- deactivating an already-INACTIVE entry is rejected
- deactivating a non-existent work regime is rejected
