> ## Documentation Index
> Fetch the complete documentation index at: https://lopiv2-invenicum-25.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Report Generation

> Generate and manage detailed reports in PDF and Excel formats

## Generate Report

```bash GET /reports/generate/{containerId} theme={null}
curl -X GET "https://api.invenicum.com/reports/generate/1?type=inventory&format=pdf" \
  -H "Authorization: Bearer YOUR_API_TOKEN" \
  --output report.pdf
```

Generates a comprehensive report for a specific container and downloads it in the requested format.

### Path Parameters

**containerId** `integer` *required*

The unique identifier of the container to generate the report for

### Query Parameters

**type** `string` *required*

Type of report to generate

**Options:**

* `inventory` - Complete inventory listing with all items
* `loans` - Active and historical loan records
* `assets` - Asset tracking and valuation report

**format** `string` *required*

Export format for the report

**Options:**

* `pdf` - PDF document (application/pdf)
* `excel` - Excel spreadsheet (application/vnd.ms-excel)

**startDate** `string`

Filter records from this date (ISO 8601 format: YYYY-MM-DD)

**Example:** `2024-01-01`

**endDate** `string`

Filter records until this date (ISO 8601 format: YYYY-MM-DD)

**Example:** `2024-12-31`

**assetTypeId** `integer`

Filter by specific asset type category

**locationId** `integer`

Filter by specific location within the container

**includeImages** `boolean`

Include item images in the report (PDF only)

**Default:** `false`

**lowStockOnly** `boolean`

Only include items below minimum stock threshold

**Default:** `false`

### Response

Returns a binary file download with appropriate Content-Type and Content-Disposition headers.

**Headers:**

* `Content-Type`: `application/pdf` or `application/vnd.ms-excel`
* `Content-Disposition`: `attachment; filename="informe_inventory_20240315T143022.pdf"`

## Get Report Preview

```bash GET /reports/preview/{containerId} theme={null}
curl -X GET "https://api.invenicum.com/reports/preview/1?type=inventory" \
  -H "Authorization: Bearer YOUR_API_TOKEN"
```

Returns a preview or summary of the report data before generating the full document.

### Path Parameters

**containerId** `integer` *required*

The unique identifier of the container

### Query Parameters

**type** `string` *required*

Type of report: `inventory`, `loans`, or `assets`

### Response

**preview** `string`

HTML or text preview of the report content

```json Response theme={null}
{
  "preview": "<div class='report-preview'><h2>Inventory Report</h2><p>Total Items: 342</p><p>Total Value: $45,789.50</p></div>"
}
```

## Get Report History

```bash GET /reports/history/{containerId} theme={null}
curl -X GET "https://api.invenicum.com/reports/history/1" \
  -H "Authorization: Bearer YOUR_API_TOKEN"
```

Retrieves the history of previously generated reports for a container.

### Path Parameters

**containerId** `integer` *required*

The unique identifier of the container

### Response

**data** `array` *required*

List of historical report records

**Report Properties**

**id** `integer` *required*

Unique identifier for the report record

**type** `string` *required*

Report type: `inventory`, `loans`, or `assets`

**format** `string` *required*

File format: `pdf` or `excel`

**fileName** `string` *required*

Generated filename

**fileSize** `integer` *required*

File size in bytes

**generatedAt** `string` *required*

Timestamp when the report was generated (ISO 8601)

**generatedBy** `string` *required*

Username or ID of the user who generated the report

**filters** `object`

Applied filters for this report

```json Response theme={null}
{
  "data": [
    {
      "id": 1245,
      "type": "inventory",
      "format": "pdf",
      "fileName": "informe_inventory_20240315T143022.pdf",
      "fileSize": 2457600,
      "generatedAt": "2024-03-15T14:30:22Z",
      "generatedBy": "admin@company.com",
      "filters": {
        "assetTypeId": 3,
        "includeImages": true
      }
    },
    {
      "id": 1244,
      "type": "loans",
      "format": "excel",
      "fileName": "informe_loans_20240314T093015.xlsx",
      "fileSize": 156800,
      "generatedAt": "2024-03-14T09:30:15Z",
      "generatedBy": "manager@company.com",
      "filters": {
        "startDate": "2024-01-01",
        "endDate": "2024-03-14"
      }
    }
  ]
}
```

## Download Report

```bash GET /reports/download/{reportId} theme={null}
curl -X GET "https://api.invenicum.com/reports/download/1245" \
  -H "Authorization: Bearer YOUR_API_TOKEN" \
  --output report.pdf
```

Downloads a previously generated report from the history.

### Path Parameters

**reportId** `integer` *required*

The unique identifier of the report to download

### Response

Returns the report file as a binary download with appropriate headers.

## Delete Report

```bash DELETE /reports/{reportId} theme={null}
curl -X DELETE "https://api.invenicum.com/reports/1245" \
  -H "Authorization: Bearer YOUR_API_TOKEN"
```

Deletes a report from the history.

### Path Parameters

**reportId** `integer` *required*

The unique identifier of the report to delete

### Response

Returns `204 No Content` on successful deletion.

## Report Types

### Inventory Report

Comprehensive listing of all inventory items including:

* Item names, descriptions, and barcodes
* Current quantities and minimum stock levels
* Market values and total portfolio value
* Locations and container assignments
* Custom field values
* Item images (when `includeImages=true`)

**Use Cases:**

* Annual inventory audits
* Insurance documentation
* Asset valuation reports
* Stock level analysis

### Loans Report

Detailed loan tracking information including:

* Active and completed loans
* Borrower information
* Loan dates and due dates
* Overdue loan identification
* Return status
* Loan history trends

**Use Cases:**

* Usage analysis
* Compliance reporting
* Equipment utilization tracking
* Overdue item follow-up

### Assets Report

Asset management and tracking details:

* Asset categories and types
* Acquisition dates and costs
* Depreciation calculations
* Maintenance schedules
* Asset lifecycle tracking
* Disposal records

**Use Cases:**

* Financial reporting
* Asset lifecycle management
* Budget planning
* Depreciation tracking

## File Naming Convention

Generated reports follow this naming pattern:

```
informe_{reportType}_{timestamp}.{extension}
```

**Examples:**

* `informe_inventory_20240315T143022.pdf`
* `informe_loans_20240314T093015.xlsx`
* `informe_assets_20240313T161245.pdf`

Where `timestamp` is in ISO 8601 format with colons removed.

## Filtering Examples

### Date Range Filter

```bash theme={null}
curl -X GET "https://api.invenicum.com/reports/generate/1?type=loans&format=excel&startDate=2024-01-01&endDate=2024-03-31"
```

Generates a loans report for Q1 2024.

### Low Stock Report

```bash theme={null}
curl -X GET "https://api.invenicum.com/reports/generate/1?type=inventory&format=pdf&lowStockOnly=true"
```

Generates an inventory report showing only items below minimum stock.

### Filtered by Location and Asset Type

```bash theme={null}
curl -X GET "https://api.invenicum.com/reports/generate/1?type=inventory&format=excel&locationId=5&assetTypeId=3"
```

Generates an inventory report for specific location and asset type.

### Detailed PDF with Images

```bash theme={null}
curl -X GET "https://api.invenicum.com/reports/generate/1?type=inventory&format=pdf&includeImages=true"
```

Generates a comprehensive PDF report including all item images.

## Error Responses

**400 Bad Request**

Returned when invalid parameters are provided.

```json theme={null}
{
  "error": "Invalid report type. Must be: inventory, loans, or assets"
}
```

**404 Not Found**

Returned when the container or report is not found.

```json theme={null}
{
  "error": "Container not found"
}
```

**500 Internal Server Error**

Returned when report generation fails.

```json theme={null}
{
  "error": "Error al generar el informe",
  "message": "PDF generation service unavailable"
}
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.