# ApprovePurchaseRequisition

## Permission Scope

purchaseRequisition

## Overview

ApprovePurchaseRequisition moves a submitted purchase requisition's `status` to `APPROVED`, authorizing procurement to convert it into a purchase order.

## Business Rules

- Target purchase requisition must exist
- Only requisitions with `status` = `SUBMITTED` can be approved
- The approver and the requester must be different users; self-approval is rejected
- Approval does not create a purchase order; conversion is a separate command

## Process Flow

```mermaid
flowchart TD
    A[Receive approve request] --> B{Purchase requisition exists?}
    B -->|No| C[Return PURCHASE_REQUISITION_NOT_FOUND]
    B -->|Yes| D{Status is SUBMITTED?}
    D -->|No| E[Return PURCHASE_REQUISITION_NOT_SUBMITTED]
    D -->|Yes| F{Approver different from requester?}
    F -->|No| G[Return SELF_APPROVAL_NOT_ALLOWED]
    F -->|Yes| H["Set status to APPROVED"]
    H --> I[Return approved requisition]
```

## External Dependencies

- None

## Error Scenarios

- **PURCHASE_REQUISITION_NOT_FOUND**: Referenced purchase requisition does not exist
- **PURCHASE_REQUISITION_NOT_SUBMITTED**: Purchase requisition is not in `SUBMITTED` status
- **SELF_APPROVAL_NOT_ALLOWED**: The approver is the same user as the requester

## Test Cases

- approves a valid submitted purchase requisition
- returns error when purchase requisition does not exist
- returns error when purchase requisition is not submitted
- returns error when approver is the same as the requester
