# /opt/docker/dev/service_finder/backend/app/schemas/asset_cost.py
from pydantic import BaseModel, ConfigDict, Field
from typing import Optional, Dict, Any
from datetime import datetime
from decimal import Decimal
from uuid import UUID

class AssetCostBase(BaseModel):
    cost_type: str # fuel, service, tax, insurance
    amount_local: Decimal
    currency_local: str = "HUF"
    net_amount_local: Optional[Decimal] = None
    vat_rate: Optional[Decimal] = Field(default=27.0)
    
    date: datetime = Field(default_factory=datetime.now)
    mileage_at_cost: Optional[int] = None
    description: Optional[str] = None
    data: Dict[str, Any] = Field(default_factory=dict) # nyugta adatai, GPS koordináták

class AssetCostCreate(AssetCostBase):
    asset_id: UUID
    organization_id: int

class AssetCostResponse(AssetCostBase):
    id: UUID
    asset_id: UUID
    organization_id: int
    driver_id: Optional[int] = None
    
    # Pénzügyi dúsítás (Backend számolja)
    amount_eur: Optional[Decimal] = None
    exchange_rate_used: Optional[Decimal] = None
    created_at: datetime
    
    model_config = ConfigDict(from_attributes=True)