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

from __future__ import annotations
from .lineitem import LineItem, LineItemTypedDict
from datetime import datetime
from panora_sdk.types import BaseModel, Nullable, OptionalNullable, UNSET, UNSET_SENTINEL
from pydantic import model_serializer
from typing import List, Optional, TypedDict
from typing_extensions import NotRequired


class UnifiedAccountingBalancesheetOutputFieldMappingsTypedDict(TypedDict):
    r"""The custom field mappings of the object between the remote 3rd party & Panora"""
    
    

class UnifiedAccountingBalancesheetOutputFieldMappings(BaseModel):
    r"""The custom field mappings of the object between the remote 3rd party & Panora"""
    
    

class UnifiedAccountingBalancesheetOutputRemoteDataTypedDict(TypedDict):
    r"""The remote data of the balance sheet in the context of the 3rd Party"""
    
    

class UnifiedAccountingBalancesheetOutputRemoteData(BaseModel):
    r"""The remote data of the balance sheet in the context of the 3rd Party"""
    
    

class UnifiedAccountingBalancesheetOutputTypedDict(TypedDict):
    name: NotRequired[Nullable[str]]
    r"""The name of the balance sheet"""
    currency: NotRequired[Nullable[str]]
    r"""The currency used in the balance sheet"""
    company_info_id: NotRequired[Nullable[str]]
    r"""The UUID of the associated company info"""
    date: NotRequired[Nullable[datetime]]
    r"""The date of the balance sheet"""
    net_assets: NotRequired[Nullable[float]]
    r"""The net assets value"""
    assets: NotRequired[Nullable[List[str]]]
    r"""The list of assets"""
    liabilities: NotRequired[Nullable[List[str]]]
    r"""The list of liabilities"""
    equity: NotRequired[Nullable[List[str]]]
    r"""The list of equity items"""
    remote_generated_at: NotRequired[Nullable[datetime]]
    r"""The date when the balance sheet was generated in the remote system"""
    line_items: NotRequired[List[LineItemTypedDict]]
    r"""The report items associated with this balance sheet"""
    field_mappings: NotRequired[Nullable[UnifiedAccountingBalancesheetOutputFieldMappingsTypedDict]]
    r"""The custom field mappings of the object between the remote 3rd party & Panora"""
    id: NotRequired[Nullable[str]]
    r"""The UUID of the balance sheet record"""
    remote_id: NotRequired[Nullable[str]]
    r"""The remote ID of the balance sheet in the context of the 3rd Party"""
    remote_data: NotRequired[Nullable[UnifiedAccountingBalancesheetOutputRemoteDataTypedDict]]
    r"""The remote data of the balance sheet in the context of the 3rd Party"""
    created_at: NotRequired[Nullable[datetime]]
    r"""The created date of the balance sheet record"""
    modified_at: NotRequired[Nullable[datetime]]
    r"""The last modified date of the balance sheet record"""
    

class UnifiedAccountingBalancesheetOutput(BaseModel):
    name: OptionalNullable[str] = UNSET
    r"""The name of the balance sheet"""
    currency: OptionalNullable[str] = UNSET
    r"""The currency used in the balance sheet"""
    company_info_id: OptionalNullable[str] = UNSET
    r"""The UUID of the associated company info"""
    date: OptionalNullable[datetime] = UNSET
    r"""The date of the balance sheet"""
    net_assets: OptionalNullable[float] = UNSET
    r"""The net assets value"""
    assets: OptionalNullable[List[str]] = UNSET
    r"""The list of assets"""
    liabilities: OptionalNullable[List[str]] = UNSET
    r"""The list of liabilities"""
    equity: OptionalNullable[List[str]] = UNSET
    r"""The list of equity items"""
    remote_generated_at: OptionalNullable[datetime] = UNSET
    r"""The date when the balance sheet was generated in the remote system"""
    line_items: Optional[List[LineItem]] = None
    r"""The report items associated with this balance sheet"""
    field_mappings: OptionalNullable[UnifiedAccountingBalancesheetOutputFieldMappings] = UNSET
    r"""The custom field mappings of the object between the remote 3rd party & Panora"""
    id: OptionalNullable[str] = UNSET
    r"""The UUID of the balance sheet record"""
    remote_id: OptionalNullable[str] = UNSET
    r"""The remote ID of the balance sheet in the context of the 3rd Party"""
    remote_data: OptionalNullable[UnifiedAccountingBalancesheetOutputRemoteData] = UNSET
    r"""The remote data of the balance sheet in the context of the 3rd Party"""
    created_at: OptionalNullable[datetime] = UNSET
    r"""The created date of the balance sheet record"""
    modified_at: OptionalNullable[datetime] = UNSET
    r"""The last modified date of the balance sheet record"""
    
    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = ["name", "currency", "company_info_id", "date", "net_assets", "assets", "liabilities", "equity", "remote_generated_at", "line_items", "field_mappings", "id", "remote_id", "remote_data", "created_at", "modified_at"]
        nullable_fields = ["name", "currency", "company_info_id", "date", "net_assets", "assets", "liabilities", "equity", "remote_generated_at", "field_mappings", "id", "remote_id", "remote_data", "created_at", "modified_at"]
        null_default_fields = []

        serialized = handler(self)

        m = {}

        for n, f in self.model_fields.items():
            k = f.alias or n
            val = serialized.get(k)

            if val is not None and val != UNSET_SENTINEL:
                m[k] = val
            elif val != UNSET_SENTINEL and (
                not k in optional_fields
                or (
                    k in optional_fields
                    and k in nullable_fields
                    and (
                        self.__pydantic_fields_set__.intersection({n})
                        or k in null_default_fields
                    )  # pylint: disable=no-member
                )
            ):
                m[k] = val

        return m
        
