# coding: utf-8

"""
    (v2.0) Dynamics 365 Business Central

    (v2.0) Business Central Standard APIs

    The version of the OpenAPI document: 2.0.0
    Generated by OpenAPI Generator (https://openapi-generator.tech)

    Do not edit the class manually.
"""  # noqa: E501


from __future__ import annotations
import pprint
import re  # noqa: F401
import json

from datetime import date, datetime
from pydantic import BaseModel, ConfigDict, Field, StrictBool, StrictStr
from typing import Any, ClassVar, Dict, List, Optional
from uuid import UUID
from typing import Optional, Set
from typing_extensions import Self

class GeneralLedgerSetup(BaseModel):
    """
    GeneralLedgerSetup
    """ # noqa: E501
    id: Optional[UUID] = Field(default=None, description="The id property for the Dynamics 365 Business Central generalLedgerSetup entity")
    allow_posting_from: Optional[date] = Field(default=None, description="The allowPostingFrom property for the Dynamics 365 Business Central generalLedgerSetup entity", alias="allowPostingFrom")
    allow_posting_to: Optional[date] = Field(default=None, description="The allowPostingTo property for the Dynamics 365 Business Central generalLedgerSetup entity", alias="allowPostingTo")
    additional_reporting_currency: Optional[StrictStr] = Field(default=None, description="The additionalReportingCurrency property for the Dynamics 365 Business Central generalLedgerSetup entity", alias="additionalReportingCurrency")
    local_currency_code: Optional[StrictStr] = Field(default=None, description="The localCurrencyCode property for the Dynamics 365 Business Central generalLedgerSetup entity", alias="localCurrencyCode")
    local_currency_symbol: Optional[StrictStr] = Field(default=None, description="The localCurrencySymbol property for the Dynamics 365 Business Central generalLedgerSetup entity", alias="localCurrencySymbol")
    last_modified_date_time: Optional[datetime] = Field(default=None, description="The lastModifiedDateTime property for the Dynamics 365 Business Central generalLedgerSetup entity", alias="lastModifiedDateTime")
    allow_query_from_consolidation: Optional[StrictBool] = Field(default=None, description="the allowQueryFromConsolidation property for the Dynamics 365 Business Central generalLedgerSetup entity", alias="allowQueryFromConsolidation")
    shortcut_dimension1_code: Optional[StrictStr] = Field(default=None, description="The shortcutDimension1Code property for the Dynamics 365 Business Central generalLedgerSetup entity", alias="shortcutDimension1Code")
    shortcut_dimension2_code: Optional[StrictStr] = Field(default=None, description="The shortcutDimension2Code property for the Dynamics 365 Business Central generalLedgerSetup entity", alias="shortcutDimension2Code")
    shortcut_dimension3_code: Optional[StrictStr] = Field(default=None, description="The shortcutDimension3Code property for the Dynamics 365 Business Central generalLedgerSetup entity", alias="shortcutDimension3Code")
    shortcut_dimension4_code: Optional[StrictStr] = Field(default=None, description="The shortcutDimension4Code property for the Dynamics 365 Business Central generalLedgerSetup entity", alias="shortcutDimension4Code")
    shortcut_dimension5_code: Optional[StrictStr] = Field(default=None, description="The shortcutDimension5Code property for the Dynamics 365 Business Central generalLedgerSetup entity", alias="shortcutDimension5Code")
    shortcut_dimension6_code: Optional[StrictStr] = Field(default=None, description="The shortcutDimension6Code property for the Dynamics 365 Business Central generalLedgerSetup entity", alias="shortcutDimension6Code")
    shortcut_dimension7_code: Optional[StrictStr] = Field(default=None, description="The shortcutDimension7Code property for the Dynamics 365 Business Central generalLedgerSetup entity", alias="shortcutDimension7Code")
    shortcut_dimension8_code: Optional[StrictStr] = Field(default=None, description="The shortcutDimension8Code property for the Dynamics 365 Business Central generalLedgerSetup entity", alias="shortcutDimension8Code")
    __properties: ClassVar[List[str]] = ["id", "allowPostingFrom", "allowPostingTo", "additionalReportingCurrency", "localCurrencyCode", "localCurrencySymbol", "lastModifiedDateTime", "allowQueryFromConsolidation", "shortcutDimension1Code", "shortcutDimension2Code", "shortcutDimension3Code", "shortcutDimension4Code", "shortcutDimension5Code", "shortcutDimension6Code", "shortcutDimension7Code", "shortcutDimension8Code"]

    model_config = ConfigDict(
        populate_by_name=True,
        validate_assignment=True,
        protected_namespaces=(),
    )


    def to_str(self) -> str:
        """Returns the string representation of the model using alias"""
        return pprint.pformat(self.model_dump(by_alias=True))

    def to_json(self) -> str:
        """Returns the JSON representation of the model using alias"""
        # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
        return json.dumps(self.to_dict())

    @classmethod
    def from_json(cls, json_str: str) -> Optional[Self]:
        """Create an instance of GeneralLedgerSetup from a JSON string"""
        return cls.from_dict(json.loads(json_str))

    def to_dict(self) -> Dict[str, Any]:
        """Return the dictionary representation of the model using alias.

        This has the following differences from calling pydantic's
        `self.model_dump(by_alias=True)`:

        * `None` is only added to the output dict for nullable fields that
          were set at model initialization. Other fields with value `None`
          are ignored.
        """
        excluded_fields: Set[str] = set([
        ])

        _dict = self.model_dump(
            by_alias=True,
            exclude=excluded_fields,
            exclude_none=True,
        )
        # set to None if additional_reporting_currency (nullable) is None
        # and model_fields_set contains the field
        if self.additional_reporting_currency is None and "additional_reporting_currency" in self.model_fields_set:
            _dict['additionalReportingCurrency'] = None

        # set to None if local_currency_code (nullable) is None
        # and model_fields_set contains the field
        if self.local_currency_code is None and "local_currency_code" in self.model_fields_set:
            _dict['localCurrencyCode'] = None

        # set to None if local_currency_symbol (nullable) is None
        # and model_fields_set contains the field
        if self.local_currency_symbol is None and "local_currency_symbol" in self.model_fields_set:
            _dict['localCurrencySymbol'] = None

        # set to None if last_modified_date_time (nullable) is None
        # and model_fields_set contains the field
        if self.last_modified_date_time is None and "last_modified_date_time" in self.model_fields_set:
            _dict['lastModifiedDateTime'] = None

        # set to None if allow_query_from_consolidation (nullable) is None
        # and model_fields_set contains the field
        if self.allow_query_from_consolidation is None and "allow_query_from_consolidation" in self.model_fields_set:
            _dict['allowQueryFromConsolidation'] = None

        # set to None if shortcut_dimension1_code (nullable) is None
        # and model_fields_set contains the field
        if self.shortcut_dimension1_code is None and "shortcut_dimension1_code" in self.model_fields_set:
            _dict['shortcutDimension1Code'] = None

        # set to None if shortcut_dimension2_code (nullable) is None
        # and model_fields_set contains the field
        if self.shortcut_dimension2_code is None and "shortcut_dimension2_code" in self.model_fields_set:
            _dict['shortcutDimension2Code'] = None

        # set to None if shortcut_dimension3_code (nullable) is None
        # and model_fields_set contains the field
        if self.shortcut_dimension3_code is None and "shortcut_dimension3_code" in self.model_fields_set:
            _dict['shortcutDimension3Code'] = None

        # set to None if shortcut_dimension4_code (nullable) is None
        # and model_fields_set contains the field
        if self.shortcut_dimension4_code is None and "shortcut_dimension4_code" in self.model_fields_set:
            _dict['shortcutDimension4Code'] = None

        # set to None if shortcut_dimension5_code (nullable) is None
        # and model_fields_set contains the field
        if self.shortcut_dimension5_code is None and "shortcut_dimension5_code" in self.model_fields_set:
            _dict['shortcutDimension5Code'] = None

        # set to None if shortcut_dimension6_code (nullable) is None
        # and model_fields_set contains the field
        if self.shortcut_dimension6_code is None and "shortcut_dimension6_code" in self.model_fields_set:
            _dict['shortcutDimension6Code'] = None

        # set to None if shortcut_dimension7_code (nullable) is None
        # and model_fields_set contains the field
        if self.shortcut_dimension7_code is None and "shortcut_dimension7_code" in self.model_fields_set:
            _dict['shortcutDimension7Code'] = None

        # set to None if shortcut_dimension8_code (nullable) is None
        # and model_fields_set contains the field
        if self.shortcut_dimension8_code is None and "shortcut_dimension8_code" in self.model_fields_set:
            _dict['shortcutDimension8Code'] = None

        return _dict

    @classmethod
    def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
        """Create an instance of GeneralLedgerSetup from a dict"""
        if obj is None:
            return None

        if not isinstance(obj, dict):
            return cls.model_validate(obj)

        _obj = cls.model_validate({
            "id": obj.get("id"),
            "allowPostingFrom": obj.get("allowPostingFrom"),
            "allowPostingTo": obj.get("allowPostingTo"),
            "additionalReportingCurrency": obj.get("additionalReportingCurrency"),
            "localCurrencyCode": obj.get("localCurrencyCode"),
            "localCurrencySymbol": obj.get("localCurrencySymbol"),
            "lastModifiedDateTime": obj.get("lastModifiedDateTime"),
            "allowQueryFromConsolidation": obj.get("allowQueryFromConsolidation"),
            "shortcutDimension1Code": obj.get("shortcutDimension1Code"),
            "shortcutDimension2Code": obj.get("shortcutDimension2Code"),
            "shortcutDimension3Code": obj.get("shortcutDimension3Code"),
            "shortcutDimension4Code": obj.get("shortcutDimension4Code"),
            "shortcutDimension5Code": obj.get("shortcutDimension5Code"),
            "shortcutDimension6Code": obj.get("shortcutDimension6Code"),
            "shortcutDimension7Code": obj.get("shortcutDimension7Code"),
            "shortcutDimension8Code": obj.get("shortcutDimension8Code")
        })
        return _obj


