from pydantic import BaseModel, Field
from typing import Union, List
from .expense import ExpensePublic, SettlementPublic
from decimal import Decimal

class FinancialActivityResponse(BaseModel):
    activities: List[Union[ExpensePublic, SettlementPublic]]

    class Config:
        orm_mode = True

class SummaryUser(BaseModel):
    """Lightweight representation of a user for summary responses."""
    id: int
    name: str

    class Config:
        orm_mode = True

class DebtCredit(BaseModel):
    """Represents a debt or credit entry in the user financial summary."""
    user: SummaryUser
    amount: float

    class Config:
        orm_mode = True

class UserFinancialSummary(BaseModel):
    """Aggregated financial summary for the authenticated user across all groups."""

    net_balance: float = 0.0
    total_group_spending: float = 0.0
    debts: List[DebtCredit] = Field(default_factory=list)
    credits: List[DebtCredit] = Field(default_factory=list)
    currency: str = "USD"

    class Config:
        orm_mode = True 