# Booking Approval API Documentation

## Endpoints

### 1. List Approval Requests
```http
GET /api/booking/approvals
```

#### Query Parameters
| Parameter | Type | Description |
|-----------|------|-------------|
| status | string | Filter by status (requested, verified, approved, rejected) |
| type | string | Filter by modification type |
| from_date | date | Filter by request date (from) |
| to_date | date | Filter by request date (to) |

#### Response
```json
{
    "status": 100,
    "message": "Approvals retrieved successfully",
    "data": [
        {
            "id": 1,
            "booking_id": "46",
            "modification_type": "discounted_booking",
            "old_room_id": null,
            "new_room_id": "1",
            "old_rate": "60000.00",
            "new_rate": "60000.00",
            "base_rate": "60000.00",
            "price_difference": "0.00",
            "rate_difference": "0.00",
            "discount_rate": "10.00",
            "requested_by": {
                "id": 5,
                "name": "John Doe"
            },
            "requested_at": "2025-06-10T18:00:21.000000Z",
            "status": "requested",
            "comments": "Discount request: 10% off base rate of 60,000.00. New rate: 60,000.00. Total savings: 0.00",
            "booking": {
                "id": 46,
                "guest_name": "Mr. Evance Chocha 0713577061",
                "phone": "0713577061",
                "check_in": "2025-06-10",
                "check_out": "2025-06-14",
                "room": {
                    "id": 1,
                    "room_number": "Room 101",
                    "room_type": "Standard"
                }
            },
            "booking_details": [
                {
                    "id": 1,
                    "booking_date": "2025-06-10",
                    "status": "requested",
                    "rate": "60000.00",
                    "base_rate": "60000.00"
                }
            ]
        }
    ]
}
```

### 2. Get Approval Request Details
```http
GET /api/booking/approvals/{id}
```

#### Response
```json
{
    "status": 100,
    "message": "Approval details retrieved successfully",
    "data": {
        "id": 1,
        "booking_id": "46",
        "modification_type": "discounted_booking",
        "old_room_id": null,
        "new_room_id": "1",
        "old_rate": "60000.00",
        "new_rate": "60000.00",
        "base_rate": "60000.00",
        "price_difference": "0.00",
        "rate_difference": "0.00",
        "discount_rate": "10.00",
        "requested_by": {
            "id": 5,
            "name": "John Doe"
        },
        "requested_at": "2025-06-10T18:00:21.000000Z",
        "status": "requested",
        "comments": "Discount request: 10% off base rate of 60,000.00. New rate: 60,000.00. Total savings: 0.00",
        "booking": {
            "id": 46,
            "guest_name": "Mr. Evance Chocha 0713577061",
            "phone": "0713577061",
            "check_in": "2025-06-10",
            "check_out": "2025-06-14",
            "room": {
                "id": 1,
                "room_number": "Room 101",
                "room_type": "Standard"
            }
        },
        "booking_details": [
            {
                "id": 1,
                "booking_date": "2025-06-10",
                "status": "requested",
                "rate": "60000.00",
                "base_rate": "60000.00"
            }
        ]
    }
}
```

### 3. Process Approval Request
```http
POST /api/booking/approvals/{id}/process
```

#### Request Body
```json
{
    "status": "approved",
    "comments": "Approved"
}
```

#### Response
```json
{
    "status": 100,
    "message": "Approval processed successfully",
    "data": {
        "id": 1,
        "status": "approved",
        "comments": "Approved"
    }
}
```

### 4. Bulk Process Approval Requests
```http
POST /api/booking/approvals/bulk-process
```

#### Request Body
```json
{
    "ids": [1, 2, 3],
    "status": "approved",
    "comments": "Bulk approval"
}
```

#### Response
```json
{
    "status": 100,
    "message": "Bulk processing completed",
    "data": {
        "successful": [1, 2],
        "failed": [3],
        "errors": {
            "3": "Already processed"
        },
        "summary": {
            "total": 3,
            "successful": 2,
            "failed": 1
        }
    }
}
```

#### Notes
- The `ids` array must contain at least one ID
- The `status` must be one of: "approved", "rejected", "verified"
- The `comments` field is required if status is "rejected"
- The response includes:
  - `successful`: Array of IDs that were processed successfully
  - `failed`: Array of IDs that failed to process
  - `errors`: Object mapping failed IDs to their error messages
  - `summary`: Object containing counts of total, successful, and failed items

## Status Codes
- 100: Success
- 404: Not Found
- 422: Validation Error
- 500: Server Error

## Error Responses
```json
{
    "status": 422,
    "message": "Validation Error",
    "errors": {
        "status": ["The selected status is invalid."],
        "comments": ["The comments field is required when status is rejected."]
    }
}
``` 