# This file was auto-generated by Fern from our API Definition.

import typing
import uuid

import pydantic
from ....core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel
from .allocation_earmark_type import AllocationEarmarkType


class BalanceEarmark(UniversalBaseModel):
    """
    Represents an active balance earmarking record that holds allocated funds for future auto-allocation.
    Earmarks are created when funds are allocated but should be held for a specific encounter or date of service.
    Only active (non-deleted) earmarks are returned.
    """

    id: uuid.UUID
    target: AllocationEarmarkType = pydantic.Field()
    """
    The target for this earmark (date of service or external encounter ID)
    """

    amount_earmarked_cents: typing.Optional[int] = pydantic.Field(default=None)
    """
    The amount earmarked in cents for future allocation
    """

    created_by_allocation_id: typing.Optional[uuid.UUID] = pydantic.Field(default=None)
    """
    The ID of the allocation that created this earmark
    """

    if IS_PYDANTIC_V2:
        model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True)  # type: ignore # Pydantic v2
    else:

        class Config:
            frozen = True
            smart_union = True
            extra = pydantic.Extra.allow
