"""Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT."""

from __future__ import annotations
import dataclasses
from codatassess import utils
from dataclasses_json import Undefined, dataclass_json
from datetime import date
from enum import Enum
from marshmallow import fields
from typing import Optional

class FinancialMetricErrorsType(str, Enum):
    r"""Metric level error."""
    UNCATEGORIZED_ACCOUNTS = 'UncategorizedAccounts'
    MISSING_INPUT_DATA = 'MissingInputData'
    INPUT_DATA_ERROR = 'InputDataError'


@dataclass_json(undefined=Undefined.EXCLUDE)
@dataclasses.dataclass
class FinancialMetricErrors:
    
    details: Optional[dict[str, list[str]]] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('details'), 'exclude': lambda f: f is None }})
    r"""Dictionary list outlining the missing properties or allowed values."""
    message: Optional[str] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('message'), 'exclude': lambda f: f is None }})
    r"""Description of the error."""
    type: Optional[FinancialMetricErrorsType] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('type'), 'exclude': lambda f: f is None }})
    r"""Metric level error."""
    
class FinancialMetricKey(str, Enum):
    UNKNOWN = 'Unknown'
    EBITDA = 'EBITDA'
    DEBT_SERVICE_COVERAGE_RATIO = 'DebtServiceCoverageRatio'
    CURRENT_RATIO_QUICK_RATIO = 'CurrentRatio QuickRatio'
    GROSS_PROFIT_MARGIN = 'GrossProfitMargin'
    FIXED_CHARGE_COVERAGE_RATIO = 'FixedChargeCoverageRatio'
    WORKING_CAPITAL = 'WorkingCapital'
    FREE_CASH_FLOW = 'FreeCashFlow'
    NET_PROFIT_MARGIN = 'NetProfitMargin'
    RETURN_ON_ASSETS_RATIO = 'ReturnOnAssetsRatio'
    RETURN_ON_EQUITY_RATIO = 'ReturnOnEquityRatio'
    OPERATING_PROFIT_MARGIN = 'OperatingProfitMargin'
    DEPT_TO_EQUITY = 'DeptToEquity'
    DEBT_TO_ASSETS = 'DebtToAssets'
    INTEREST_COVERAGE_RATIO = 'InterestCoverageRatio'
    CASH_RATIO = 'CashRatio'
    INVENTORY_TURNOVER_RATIO = 'InventoryTurnoverRatio'
    ASSET_TURNOVER_RATIO = 'AssetTurnoverRatio'
    WORKING_CAPITAL_TURNOVER_RATIO = 'WorkingCapitalTurnoverRatio'
    DAYS_SALES_OUTSTANDING = 'DaysSalesOutstanding'
    DAYS_PAYABLES_OUTSTANDING = 'DaysPayablesOutstanding'

class FinancialMetricMetricUnit(str, Enum):
    RATIO = 'Ratio'
    MONEY = 'Money'

class FinancialMetricPeriodsErrorsType(str, Enum):
    r"""Period error type."""
    MISSING_ACCOUNT_DATA = 'MissingAccountData'
    DATES_OUT_OF_RANGE = 'DatesOutOfRange'


@dataclass_json(undefined=Undefined.EXCLUDE)
@dataclasses.dataclass
class FinancialMetricPeriodsErrors:
    
    details: Optional[dict[str, list[str]]] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('details'), 'exclude': lambda f: f is None }})
    r"""Dictionary list outlining the missing properties or allowed values."""
    massage: Optional[str] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('massage'), 'exclude': lambda f: f is None }})
    r"""Description of the error."""
    type: Optional[FinancialMetricPeriodsErrorsType] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('type'), 'exclude': lambda f: f is None }})
    r"""Period error type."""
    

@dataclass_json(undefined=Undefined.EXCLUDE)
@dataclasses.dataclass
class FinancialMetricPeriodsInputs:
    
    name: Optional[str] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('name'), 'exclude': lambda f: f is None }})
    r"""The name of the metric input e.g. “Current Assets”, “Capital Expenditure”."""
    value: Optional[float] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('value'), 'exclude': lambda f: f is None }})
    r"""The positive or negative number of the input value."""
    

@dataclass_json(undefined=Undefined.EXCLUDE)
@dataclasses.dataclass
class FinancialMetricPeriods:
    
    errors: Optional[list[FinancialMetricPeriodsErrors]] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('errors'), 'exclude': lambda f: f is None }})
    from_date: Optional[date] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('fromDate'), 'encoder': utils.dateisoformat(True), 'decoder': utils.datefromisoformat, 'mm_field': fields.DateTime(format='iso'), 'exclude': lambda f: f is None }})
    r"""The date from which the report starts."""
    inputs: Optional[list[FinancialMetricPeriodsInputs]] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('inputs'), 'exclude': lambda f: f is None }})
    to_date: Optional[date] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('toDate'), 'encoder': utils.dateisoformat(True), 'decoder': utils.datefromisoformat, 'mm_field': fields.DateTime(format='iso'), 'exclude': lambda f: f is None }})
    r"""The date on which the report ends (inclusive of day)."""
    value: Optional[float] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('value'), 'exclude': lambda f: f is None }})
    r"""The top level metric value that is calculated for the specified period.
    
    If the system cannot calculate for that period, the value will be null. The system will still show the metric inputs.
    """
    

@dataclass_json(undefined=Undefined.EXCLUDE)
@dataclasses.dataclass
class FinancialMetric:
    
    errors: Optional[list[FinancialMetricErrors]] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('errors'), 'exclude': lambda f: f is None }})
    key: Optional[FinancialMetricKey] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('key'), 'exclude': lambda f: f is None }})
    metric_unit: Optional[FinancialMetricMetricUnit] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('metricUnit'), 'exclude': lambda f: f is None }})
    name: Optional[str] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('name'), 'exclude': lambda f: f is None }})
    r"""Metric name."""
    periods: Optional[list[FinancialMetricPeriods]] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('periods'), 'exclude': lambda f: f is None }})
    