# OpenPeriod

## Permission Scope

periodManagement

## Overview

openPeriod transitions an accounting period from NEVER_OPENED to OPEN status, enabling journal entry postings. An OPEN period is the active state for accepting transactional postings from both manual entry and source-module posting workflows.

## Business Rules

- Period must exist and be in NEVER_OPENED status
- After transition, the period accepts all journal entry postings

## Process Flow

```mermaid
flowchart TD
    A[Receive openPeriod request] --> B{Period exists?}
    B -->|No| C[Return error: period not found]
    B -->|Yes| D{Period status is NEVER_OPENED?}
    D -->|No| E[Return error: invalid status transition]
    D -->|Yes| F[Transition period to OPEN]
    F --> H[Return updated period]
```

## External Dependencies

- None

## Error Scenarios

- **ACCOUNTING_PERIOD_NOT_FOUND**: Referenced accounting period does not exist
- **INVALID_STATUS_TRANSITION**: Requested status transition is not allowed from the current status

## Test Cases

- returns error when accounting period does not exist
- returns error when period is in OPEN status
- returns error when period is in CLOSED status
- returns error when period is in PERMANENTLY_CLOSED status
- transitions NEVER_OPENED period to OPEN
