# DeleteBudgetLineItem

## Permission Scope

accounting

## Overview

deleteBudgetLineItem removes a line item from a budget. Line items can only be removed when the parent budget is in DRAFT status.

## Business Rules

- Budget line item must exist
- Parent budget must be in DRAFT status
- Line items cannot be removed from budgets in SUBMITTED, APPROVED, ACTIVE, or CLOSED status
- Deletion permanently removes the line item from the budget
- Emits an audit event recording the line item deletion and acting user

## Process Flow

```mermaid
flowchart TD
    A[Receive delete budget line item request] --> B{Budget line item exists?}
    B -->|No| C[Return error: BUDGET_LINE_ITEM_NOT_FOUND]
    B -->|Yes| D{Parent budget status is DRAFT?}
    D -->|No| E[Return error: INVALID_STATE]
    D -->|Yes| F[Delete budget line item]
    F --> G[Emit audit event]
    G --> H[Return success]
```

## External Dependencies

- None

## Error Scenarios

- **BUDGET_LINE_ITEM_NOT_FOUND**: Budget line item with the specified ID does not exist
- **INVALID_STATE**: Target entity is not in a valid status for this operation

## Test Cases

- deletes a line item from a DRAFT budget
- returns error when budget line item does not exist
- returns error when parent budget is in SUBMITTED status
- returns error when parent budget is in APPROVED status
- returns error when parent budget is in ACTIVE status
- returns error when parent budget is in CLOSED status
- emits audit event recording the line item deletion and acting user
