# DeleteFiscalYear

## Overview

deleteFiscalYear permanently removes a fiscal year record. Deletion is only permitted when the fiscal year has no associated accounting periods, ensuring that period data and any downstream journal entries are never orphaned.

## Business Rules

- Fiscal year must exist and be identified by `id`
- Fiscal year cannot be deleted if it has any associated accounting periods
- Deletion is a hard delete — the record is permanently removed
- Emits an audit event via the audit module recording the acting user, timestamp, and deleted fiscal year details

## Process Flow

```mermaid
flowchart TD
    A[Receive delete fiscal year request] --> B{Fiscal year exists?}
    B -->|No| C[Return error: fiscal year not found]
    B -->|Yes| D{Accounting periods exist for this fiscal year?}
    D -->|Yes| E[Return error: has associated periods]
    D -->|No| F[Delete fiscal year record]
    F --> G[Emit audit event]
    G --> H[Return success]
```

## External Dependencies

- None (same-module read for fiscal year and period lookup)

## Error Scenarios

- **FISCAL_YEAR_NOT_FOUND**: No fiscal year matches the given id
- **HAS_ASSOCIATED_PERIODS**: Fiscal year has one or more accounting periods and cannot be deleted

## Test Cases

- returns error when fiscal year does not exist
- returns error when fiscal year has associated accounting periods
- deletes fiscal year with no associated accounting periods
