# Admin API: Get Collection Report by Line

## Endpoint
`GET /admin/collection-report/line`

## Description
Returns a collection report grouped and summarized by line (e.g. "Line 1"). For each line, it lists:
- Unique line name/identifier
- Areas belonging to this line
- Total active/due customers on this line
- Total expected collection amount today
- Total collected amount today
- Remaining pending amount today
- Collection rate percentage

It also includes an overall summary across all lines for the company.

## Authentication
Requires admin authentication via Bearer token (JWT or auth_token).

## Query Parameters
- `date` (optional): Target date for the collection report (YYYY-MM-DD). Defaults to today if not provided.
- `from_date` / `start_date` / `fromDate` (optional): Start date for the date range collection report (YYYY-MM-DD).
- `to_date` / `end_date` / `toDate` (optional): End date for the date range collection report (YYYY-MM-DD).

---

## cURL Examples

### 1. Get Collection Report by Line (Default - Today)
```bash
curl -X GET "https://dayloan.agniplay.com/admin/collection-report/line" \
  -H "Authorization: Bearer YOUR_ADMIN_JWT_TOKEN" \
  -H "Accept: application/json"
```

### 2. Get Collection Report by Line for a Specific Date
```bash
curl -X GET "https://dayloan.agniplay.com/admin/collection-report/line?date=2026-07-15" \
  -H "Authorization: Bearer YOUR_ADMIN_JWT_TOKEN" \
  -H "Accept: application/json"
```

### 3. Get Collection Report by Line for a Date Range
```bash
curl -X GET "https://dayloan.agniplay.com/admin/collection-report/line?from_date=2026-07-10&to_date=2026-07-15" \
  -H "Authorization: Bearer YOUR_ADMIN_JWT_TOKEN" \
  -H "Accept: application/json"
```

---

## Response Format

### Success Response (200 OK)
```json
{
  "status": "success",
  "message": "Collection report by line retrieved successfully",
  "data": {
    "date": "2026-07-15",
    "summary": {
      "total_lines": 3,
      "total_customers": 10,
      "total_expected": 2000.00,
      "total_collected": 1500.00,
      "total_pending": 500.00,
      "average_collection_rate": 75.00
    },
    "report": [
      {
        "line": "Line 1",
        "areas": ["V O C Park", "Karungalpalayam", "P S Park"],
        "total_customers": 10,
        "expected_amount": 2000.00,
        "collected_amount": 1500.00,
        "pending_amount": 500.00,
        "collection_rate": 75.00
      },
      {
        "line": "Line 2",
        "areas": ["Mollapalayam", "Kollampalayam", "Vendipalayam"],
        "total_customers": 0,
        "expected_amount": 0.00,
        "collected_amount": 0.00,
        "pending_amount": 0.00,
        "collection_rate": 0.00
      },
      {
        "line": "Line 3",
        "areas": ["Thindal", "Palayapalayam"],
        "total_customers": 0,
        "expected_amount": 0.00,
        "collected_amount": 0.00,
        "pending_amount": 0.00,
        "collection_rate": 0.00
      }
    ]
  }
}
```
