"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""

from __future__ import annotations
from paygentic_sdk.types import BaseModel, UnrecognizedStr
import pydantic
from typing import Literal, Union
from typing_extensions import Annotated, TypedDict


EventType = Union[
    Literal[
        "usage",
        "fee",
    ],
    UnrecognizedStr,
]
r"""Type of event: 'usage' for billable metric events, 'fee' for fee events"""


LineItemType = Union[
    Literal[
        "charge",
        "refund",
    ],
    UnrecognizedStr,
]
r"""Type of line item: 'charge' for regular billing, 'refund' for refunded items (amounts are negated)"""


class InvoiceLineItemTypedDict(TypedDict):
    event_type: EventType
    r"""Type of event: 'usage' for billable metric events, 'fee' for fee events"""
    event_id: str
    r"""The event ID (usage_event_id or fee_event_id)"""
    event_source_id: str
    r"""Source ID: billable_metric_id for usage events, fee_id for fee events"""
    billable_metric_id: str
    r"""HOTFIX: Mirrors eventSourceId for backward compatibility"""
    invoice_display_name: str
    r"""Display name for this line item on invoices"""
    line_item_type: LineItemType
    r"""Type of line item: 'charge' for regular billing, 'refund' for refunded items (amounts are negated)"""
    meter_event_id: str
    r"""The meter event ID (usage events only)"""
    metric_description: str
    r"""Description of what this metric or fee measures"""
    metric_name: str
    r"""Human-readable name of the billable metric or fee"""
    metric_unit: str
    r"""Measurement unit label. Sample values: 'calls' for API calls, 'GB' for storage, 'hours' for compute time, 'tokens' for LLM tokens, 'charge' for fees"""
    quantity: float
    r"""Quantity of usage. Negative for refunds."""
    tax_rate: float
    r"""Tax rate as decimal (0.10 = 10%)"""
    total_amount: str
    r"""Total amount (totalPrice + totalTax) in decimal dollars. Negative for refunds."""
    total_price: str
    r"""Total price (tax-exclusive) in decimal dollars. Negative for refunds."""
    total_tax: str
    r"""Total tax in decimal dollars. Negative for refunds."""
    unit_price: str
    r"""Unit price in decimal dollars"""


class InvoiceLineItem(BaseModel):
    event_type: Annotated[EventType, pydantic.Field(alias="eventType")]
    r"""Type of event: 'usage' for billable metric events, 'fee' for fee events"""

    event_id: Annotated[str, pydantic.Field(alias="eventId")]
    r"""The event ID (usage_event_id or fee_event_id)"""

    event_source_id: Annotated[str, pydantic.Field(alias="eventSourceId")]
    r"""Source ID: billable_metric_id for usage events, fee_id for fee events"""

    billable_metric_id: Annotated[str, pydantic.Field(alias="billableMetricId")]
    r"""HOTFIX: Mirrors eventSourceId for backward compatibility"""

    invoice_display_name: Annotated[str, pydantic.Field(alias="invoiceDisplayName")]
    r"""Display name for this line item on invoices"""

    line_item_type: Annotated[LineItemType, pydantic.Field(alias="lineItemType")]
    r"""Type of line item: 'charge' for regular billing, 'refund' for refunded items (amounts are negated)"""

    meter_event_id: Annotated[str, pydantic.Field(alias="meterEventId")]
    r"""The meter event ID (usage events only)"""

    metric_description: Annotated[str, pydantic.Field(alias="metricDescription")]
    r"""Description of what this metric or fee measures"""

    metric_name: Annotated[str, pydantic.Field(alias="metricName")]
    r"""Human-readable name of the billable metric or fee"""

    metric_unit: Annotated[str, pydantic.Field(alias="metricUnit")]
    r"""Measurement unit label. Sample values: 'calls' for API calls, 'GB' for storage, 'hours' for compute time, 'tokens' for LLM tokens, 'charge' for fees"""

    quantity: float
    r"""Quantity of usage. Negative for refunds."""

    tax_rate: Annotated[float, pydantic.Field(alias="taxRate")]
    r"""Tax rate as decimal (0.10 = 10%)"""

    total_amount: Annotated[str, pydantic.Field(alias="totalAmount")]
    r"""Total amount (totalPrice + totalTax) in decimal dollars. Negative for refunds."""

    total_price: Annotated[str, pydantic.Field(alias="totalPrice")]
    r"""Total price (tax-exclusive) in decimal dollars. Negative for refunds."""

    total_tax: Annotated[str, pydantic.Field(alias="totalTax")]
    r"""Total tax in decimal dollars. Negative for refunds."""

    unit_price: Annotated[str, pydantic.Field(alias="unitPrice")]
    r"""Unit price in decimal dollars"""


try:
    InvoiceLineItem.model_rebuild()
except NameError:
    pass
