# 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, Optional, Union
from openapi_client.models.employee_simple_response import EmployeeSimpleResponse
from openapi_client.models.former_employee_income_response import FormerEmployeeIncomeResponse
from typing import Optional, Set
from typing_extensions import Self

class FormerEmployeeIncomeEmployeeResponse(BaseModel):
    """
    FormerEmployeeIncomeEmployeeResponse
    """ # noqa: E501
    id: Optional[StrictStr] = Field(default=None, description="Former employee income employee ID")
    former_employee_income: Optional[FormerEmployeeIncomeResponse] = Field(default=None, alias="formerEmployeeIncome")
    employee: Optional[EmployeeSimpleResponse] = None
    amount: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, description="Income amount")
    last_working_date: Optional[date] = Field(default=None, description="Last working date", alias="lastWorkingDate")
    payment_date: Optional[date] = Field(default=None, description="Payment date", alias="paymentDate")
    payment_method: Optional[StrictStr] = Field(default=None, description="Payment method", alias="paymentMethod")
    total_thp: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, description="Total take home pay", alias="totalThp")
    original_tax: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, description="Original tax amount", alias="originalTax")
    penalty_tax: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, description="Penalty tax amount", alias="penaltyTax")
    tax_allowance: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, description="Tax allowance amount", alias="taxAllowance")
    __properties: ClassVar[List[str]] = ["id", "formerEmployeeIncome", "employee", "amount", "lastWorkingDate", "paymentDate", "paymentMethod", "totalThp", "originalTax", "penaltyTax", "taxAllowance"]

    @field_validator('payment_method')
    def payment_method_validate_enum(cls, value):
        """Validates the enum"""
        if value is None:
            return value

        if value not in set(['CASH', 'TRANSFER', 'NONE']):
            raise ValueError("must be one of enum values ('CASH', 'TRANSFER', 'NONE')")
        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 FormerEmployeeIncomeEmployeeResponse 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 former_employee_income
        if self.former_employee_income:
            _dict['formerEmployeeIncome'] = self.former_employee_income.to_dict()
        # override the default output from pydantic by calling `to_dict()` of employee
        if self.employee:
            _dict['employee'] = self.employee.to_dict()
        return _dict

    @classmethod
    def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
        """Create an instance of FormerEmployeeIncomeEmployeeResponse 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"),
            "formerEmployeeIncome": FormerEmployeeIncomeResponse.from_dict(obj["formerEmployeeIncome"]) if obj.get("formerEmployeeIncome") is not None else None,
            "employee": EmployeeSimpleResponse.from_dict(obj["employee"]) if obj.get("employee") is not None else None,
            "amount": obj.get("amount"),
            "lastWorkingDate": obj.get("lastWorkingDate"),
            "paymentDate": obj.get("paymentDate"),
            "paymentMethod": obj.get("paymentMethod"),
            "totalThp": obj.get("totalThp"),
            "originalTax": obj.get("originalTax"),
            "penaltyTax": obj.get("penaltyTax"),
            "taxAllowance": obj.get("taxAllowance")
        })
        return _obj


