# coding: utf-8

"""
    CATAPA API

    CATAPA HR and workforce management API for payroll, organization, personnel, time management, and related operations.

    The version of the OpenAPI document: 1.0.0
    Contact: support@catapa.com
    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
from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt, StrictStr, field_validator
from typing import Any, ClassVar, Dict, List, Union
from openapi_client.models.tax_calculation_income_request import TaxCalculationIncomeRequest
from typing import Optional, Set
from typing_extensions import Self

class TaxCalculationRequest(BaseModel):
    """
    TaxCalculationRequest
    """ # noqa: E501
    employee_id: StrictStr = Field(alias="employeeId")
    incomes: List[TaxCalculationIncomeRequest]
    reference_date: date = Field(alias="referenceDate")
    payment_method: StrictStr = Field(alias="paymentMethod")
    external_id: StrictStr = Field(alias="externalId")
    multiplier: Union[StrictFloat, StrictInt]
    payment_date: date = Field(alias="paymentDate")
    calculation_type: StrictStr = Field(alias="calculationType")
    working_days: Union[StrictFloat, StrictInt] = Field(alias="workingDays")
    __properties: ClassVar[List[str]] = ["employeeId", "incomes", "referenceDate", "paymentMethod", "externalId", "multiplier", "paymentDate", "calculationType", "workingDays"]

    @field_validator('payment_method')
    def payment_method_validate_enum(cls, value):
        """Validates the enum"""
        if value not in set(['COMBINED', 'SEPARATED']):
            raise ValueError("must be one of enum values ('COMBINED', 'SEPARATED')")
        return value

    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 TaxCalculationRequest 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,
        )
        # override the default output from pydantic by calling `to_dict()` of each item in incomes (list)
        _items = []
        if self.incomes:
            for _item_incomes in self.incomes:
                if _item_incomes:
                    _items.append(_item_incomes.to_dict())
            _dict['incomes'] = _items
        return _dict

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

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

        _obj = cls.model_validate({
            "employeeId": obj.get("employeeId"),
            "incomes": [TaxCalculationIncomeRequest.from_dict(_item) for _item in obj["incomes"]] if obj.get("incomes") is not None else None,
            "referenceDate": obj.get("referenceDate"),
            "paymentMethod": obj.get("paymentMethod"),
            "externalId": obj.get("externalId"),
            "multiplier": obj.get("multiplier"),
            "paymentDate": obj.get("paymentDate"),
            "calculationType": obj.get("calculationType"),
            "workingDays": obj.get("workingDays")
        })
        return _obj


