# SubmitBudget

## Permission Scope

accounting

## Overview

submitBudget transitions a budget from DRAFT status to SUBMITTED status, initiating the approval workflow. The budget must have at least one line item before it can be submitted.

## Business Rules

- Budget must exist
- Budget must be in DRAFT status to be submitted
- Budget must have at least one line item
- Submitting a budget without line items is rejected
- Transitions status from DRAFT to SUBMITTED
- Emits an audit event recording the status transition and acting user

## Process Flow

```mermaid
flowchart TD
    A[Receive submit budget request] --> B{Budget exists?}
    B -->|No| C[Return error: BUDGET_NOT_FOUND]
    B -->|Yes| D{Status is DRAFT?}
    D -->|No| E[Return error: INVALID_STATE]
    D -->|Yes| F{Has at least one line item?}
    F -->|No| G[Return error: NO_LINE_ITEMS]
    F -->|Yes| H[Transition status from DRAFT to SUBMITTED]
    H --> I[Emit audit event]
    I --> J[Return submitted budget]
```

## External Dependencies

- None

## Error Scenarios

- **BUDGET_NOT_FOUND**: Budget with the specified ID does not exist
- **INVALID_STATE**: Target entity is not in a valid status for this operation
- **NO_LINE_ITEMS**: Budget has no line items and cannot be submitted

## Test Cases

- submits a DRAFT budget with line items transitioning it to SUBMITTED status
- returns error when budget does not exist
- returns error when budget is not in DRAFT status
- returns error when budget has no line items
- emits audit event recording the status transition and acting user
