"""Billing subscription request/response schemas."""
from datetime import date
from typing import Optional
from pydantic import BaseModel


class SubscriptionResponse(BaseModel):
    plan_name: str
    plan_slug: str
    price_monthly: int
    currency: str
    status: str
    next_billing_date: Optional[str] = None
    # True while payment_status == "trialing" (card saved, not yet charged).
    # The billing page shows "Free Trial" as the current plan while this is
    # true, and records_limit is capped at TRIAL_RECORD_LIMIT server-side.
    is_trial: bool = False
    trial_ends_at: Optional[str] = None
    records_limit: Optional[int] = None
    # billing contact fields (read-only)
    org_name: Optional[str] = None
    contact_name: Optional[str] = None
    contact_email: Optional[str] = None


class UpdatePlanRequest(BaseModel):
    plan: str  # "starter" | "professional" | "enterprise"


class BillingInvoiceItem(BaseModel):
    id: str
    invoice_number: str
    date: Optional[str] = None
    plan_name: str
    amount: float
    currency: str = "CAD"
    status: str


class PaymentIntentResponse(BaseModel):
    client_secret: str


class ConfirmPaymentRequest(BaseModel):
    payment_intent_id: str


class ConfirmPaymentResponse(BaseModel):
    invoice_id: str
    status: str
