# RemoveJournalLine

## Overview

removeJournalLine removes an existing line item from a DRAFT journal entry. Lines can only be removed while the parent entry is in DRAFT status. Lines on posted or reversed entries are immutable and cannot be removed, as this would compromise the audit trail.

## Business Rules

- Journal line must exist and its parent journal entry must be in DRAFT status
- Lines on POSTED or REVERSED entries cannot be removed
- Removing a line does not automatically delete the parent entry even if no lines remain
- Emits an audit event recording the line removal, acting user, and timestamp

## Process Flow

```mermaid
flowchart TD
    A[Receive remove journal line request] --> B{Journal line exists?}
    B -->|No| C[Return error: journal line not found]
    B -->|Yes| D{Parent entry status is DRAFT?}
    D -->|No| E[Return error: cannot remove lines from non-draft entry]
    D -->|Yes| F[Remove journal line]
    F --> G[Emit audit event]
    G --> H[Return success]
```

## External Dependencies

- None

## Error Scenarios

- **JOURNAL_LINE_NOT_FOUND**: Referenced journal line does not exist
- **INVALID_STATUS_FOR_LINE_REMOVE**: Parent journal entry is not in DRAFT status

## Test Cases

- returns error when journal line does not exist
- returns error when parent journal entry is in POSTED status
- returns error when parent journal entry is in REVERSED status
- removes journal line from DRAFT entry
- emits audit event recording line removal and acting user
