> ## Documentation Index
> Fetch the complete documentation index at: https://mintlify.com/Braian551/viax/llms.txt
> Use this file to discover all available pages before exploring further.

# Driver Earnings

> View driver earnings and payment history

## Get Earnings

```
GET /conductor/get_earnings.php
```

Retrieve driver earnings for a specific time period.

### Query Parameters

<ParamField query="conductor_id" type="integer" required>
  Driver ID
</ParamField>

<ParamField query="periodo" type="string" required>
  Time period for earnings report

  **Possible values:**

  * `hoy` - Today's earnings
  * `semana` - This week's earnings
  * `mes` - This month's earnings
  * `total` - All-time earnings
</ParamField>

### Response

<ResponseField name="success" type="boolean">
  Request success status
</ResponseField>

<ResponseField name="earnings" type="object">
  Earnings data for the period

  <Expandable title="earnings structure">
    <ResponseField name="periodo" type="string">
      Requested period
    </ResponseField>

    <ResponseField name="total_viajes" type="integer">
      Number of completed trips
    </ResponseField>

    <ResponseField name="ganancia_total" type="number">
      Total earnings in Colombian Pesos (COP)
    </ResponseField>

    <ResponseField name="ganancia_promedio" type="number">
      Average earnings per trip
    </ResponseField>

    <ResponseField name="fecha_inicio" type="string">
      Period start date (ISO 8601)
    </ResponseField>

    <ResponseField name="fecha_fin" type="string">
      Period end date (ISO 8601)
    </ResponseField>
  </Expandable>
</ResponseField>

### Request Example

<CodeGroup>
  ```bash Today's Earnings theme={null}
  curl -X GET "https://76.13.114.194/conductor/get_earnings.php?conductor_id=25&periodo=hoy" \
    -H "Accept: application/json"
  ```

  ```bash Monthly Earnings theme={null}
  curl -X GET "https://76.13.114.194/conductor/get_earnings.php?conductor_id=25&periodo=mes" \
    -H "Accept: application/json"
  ```

  ```dart Dart theme={null}
  Future<Map<String, dynamic>> getEarnings(
    int conductorId,
    String periodo,
  ) async {
    final response = await http.get(
      Uri.parse(
        'https://76.13.114.194/conductor/get_earnings.php?'
        'conductor_id=$conductorId&periodo=$periodo',
      ),
      headers: {'Accept': 'application/json'},
    );
    
    if (response.statusCode == 200) {
      return jsonDecode(response.body);
    }
    throw Exception('Failed to load earnings');
  }

  // Usage:
  final todayEarnings = await getEarnings(25, 'hoy');
  final monthlyEarnings = await getEarnings(25, 'mes');
  ```
</CodeGroup>

### Response Example

<CodeGroup>
  ```json Today theme={null}
  {
    "success": true,
    "earnings": {
      "periodo": "hoy",
      "total_viajes": 8,
      "ganancia_total": 156000,
      "ganancia_promedio": 19500,
      "fecha_inicio": "2024-03-15T00:00:00.000Z",
      "fecha_fin": "2024-03-15T23:59:59.000Z"
    }
  }
  ```

  ```json This Month theme={null}
  {
    "success": true,
    "earnings": {
      "periodo": "mes",
      "total_viajes": 142,
      "ganancia_total": 2840000,
      "ganancia_promedio": 20000,
      "fecha_inicio": "2024-03-01T00:00:00.000Z",
      "fecha_fin": "2024-03-31T23:59:59.000Z"
    }
  }
  ```

  ```json All Time theme={null}
  {
    "success": true,
    "earnings": {
      "periodo": "total",
      "total_viajes": 1247,
      "ganancia_total": 24940000,
      "ganancia_promedio": 20000,
      "fecha_inicio": "2024-01-01T00:00:00.000Z",
      "fecha_fin": "2024-03-15T23:59:59.000Z"
    }
  }
  ```
</CodeGroup>

***

## Earnings Breakdown

Earnings are calculated based on:

* **Base Fare**: Starting price for the trip
* **Distance Rate**: Price per kilometer
* **Time Rate**: Price per minute (if applicable)
* **Service Fee**: Platform commission (deducted)

### Example Calculation

```dart theme={null}
class TripEarnings {
  final double precioFinal;        // Final trip price
  final double comisionPlataforma; // Platform commission (e.g., 15%)
  
  double get gananciaDriver {
    return precioFinal * (1 - comisionPlataforma / 100);
  }
}

// Example:
final trip = TripEarnings(
  precioFinal: 25000,
  comisionPlataforma: 15,
);

print(trip.gananciaDriver); // 21250 COP
```

***

## Payment Methods

Drivers receive earnings through:

* **Cash**: Collected directly from passengers
* **Digital Wallet**: Platform wallet for cashless payments
* **Bank Transfer**: Weekly/monthly transfers to bank account

<Note>
  Earnings are typically paid out weekly or monthly, depending on the driver's preference and platform policy.
</Note>

***

## Error Responses

<ResponseField name="400" type="Bad Request">
  Invalid period parameter
</ResponseField>

<ResponseField name="404" type="Not Found">
  Driver not found
</ResponseField>

<ResponseField name="500" type="Internal Server Error">
  Server error
</ResponseField>

## See Also

* [Driver Statistics](/api/drivers/statistics) - View performance metrics
* [Trip History](/api/trips/history) - View completed trips
