from datetime import datetime
from typing import Optional
from pydantic import BaseModel, Field


class JourneyEntry(BaseModel):
    date: str
    start_km: Optional[int] = None
    end_km: Optional[int] = None
    distance_km: Optional[int] = None
    is_sick_day: bool = False
    is_vacation: bool = False


class RefuelingEntry(BaseModel):
    date: str
    amount_liters: float
    km_at_refuel: Optional[int] = None


class Journey(BaseModel):
    month: str = Field(..., pattern=r"^\d{4}-\d{2}$")
    start_km: int = Field(..., gt=0)
    end_km: int = Field(..., gt=0)
    entries: list[JourneyEntry] = []
    refueling_entries: list[RefuelingEntry] = []

    class Config:
        json_schema_extra = {
            "example": {
                "month": "2024-03",
                "start_km": 12000,
                "end_km": 13500,
                "entries": [],
                "refueling_entries": []
            }
        }
