# coding: utf-8

"""
    CATAPA API

    No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)

    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 pydantic import BaseModel, ConfigDict, Field, StrictBool, StrictFloat, StrictInt, StrictStr, field_validator
from typing import Any, ClassVar, Dict, List, Optional, Union
from openapi_client.models.tax_amount_response import TaxAmountResponse
from openapi_client.models.tax_income_response import TaxIncomeResponse
from typing import Optional, Set
from typing_extensions import Self

class MonthlyTaxDetailResponse(BaseModel):
    """
    MonthlyTaxDetailResponse
    """ # noqa: E501
    annual_calculation: Optional[StrictBool] = Field(default=None, alias="annualCalculation")
    tax_object: Optional[StrictStr] = Field(default=None, alias="taxObject")
    year: Optional[StrictInt] = None
    month: Optional[StrictInt] = None
    employee_id: Optional[StrictStr] = Field(default=None, alias="employeeId")
    npwp_number: Optional[StrictStr] = Field(default=None, alias="npwpNumber")
    npwp_address: Optional[StrictStr] = Field(default=None, alias="npwpAddress")
    ptkp_category_code: Optional[StrictStr] = Field(default=None, alias="ptkpCategoryCode")
    ter_category: Optional[StrictStr] = Field(default=None, alias="terCategory")
    percentage: Optional[Union[StrictFloat, StrictInt]] = None
    monthly_gross_income: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, alias="monthlyGrossIncome")
    tax: Optional[TaxAmountResponse] = None
    regular_tax: Optional[TaxAmountResponse] = Field(default=None, alias="regularTax")
    bonus_tax: Optional[TaxAmountResponse] = Field(default=None, alias="bonusTax")
    income: Optional[TaxIncomeResponse] = None
    positional_allowance: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, alias="positionalAllowance")
    base_income_tax_deduction: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, alias="baseIncomeTaxDeduction")
    __properties: ClassVar[List[str]] = ["annualCalculation", "taxObject", "year", "month", "employeeId", "npwpNumber", "npwpAddress", "ptkpCategoryCode", "terCategory", "percentage", "monthlyGrossIncome", "tax", "regularTax", "bonusTax", "income", "positionalAllowance", "baseIncomeTaxDeduction"]

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

        if value not in set(['PERMANENT', 'TEMPORARY', 'MULTI_LEVEL_DISTRIBUTOR', 'INSURANCE_AGENT', 'MERCHANT_GOODS', 'EXPERT_CONTINUOUS', 'EXPERT_NON_CONTINUOUS', 'CONTINUOUS', 'NON_CONTINUOUS', 'COMMISSIONER', 'FORMER_EMPLOYEE', 'EVENT_PARTICIPANT', 'EXPATRIATE', 'PERMANENT_DTP', 'EXPERT', 'MEETING_PARTICIPANT', 'COMMITTEE_PARTICIPANT', 'EDUCATION_PARTICIPANT', 'OTHER_PARTICIPANT', 'ADVISOR_LECTURER', 'AUTHOR_RESEARCHER', 'SERVICE_PROVIDER', 'ADVERTISING_AGENT', 'PROJECT_MANAGER', 'INTERMEDIARY', 'TEMPORARY_DTP', 'NON_EMPLOYEE_DTP', 'ARTIST', 'ATHLETE', 'TEMPORARY_MONTHLY', 'COMPETITION_PARTICIPANT']):
            raise ValueError("must be one of enum values ('PERMANENT', 'TEMPORARY', 'MULTI_LEVEL_DISTRIBUTOR', 'INSURANCE_AGENT', 'MERCHANT_GOODS', 'EXPERT_CONTINUOUS', 'EXPERT_NON_CONTINUOUS', 'CONTINUOUS', 'NON_CONTINUOUS', 'COMMISSIONER', 'FORMER_EMPLOYEE', 'EVENT_PARTICIPANT', 'EXPATRIATE', 'PERMANENT_DTP', 'EXPERT', 'MEETING_PARTICIPANT', 'COMMITTEE_PARTICIPANT', 'EDUCATION_PARTICIPANT', 'OTHER_PARTICIPANT', 'ADVISOR_LECTURER', 'AUTHOR_RESEARCHER', 'SERVICE_PROVIDER', 'ADVERTISING_AGENT', 'PROJECT_MANAGER', 'INTERMEDIARY', 'TEMPORARY_DTP', 'NON_EMPLOYEE_DTP', 'ARTIST', 'ATHLETE', 'TEMPORARY_MONTHLY', 'COMPETITION_PARTICIPANT')")
        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 MonthlyTaxDetailResponse 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 tax
        if self.tax:
            _dict['tax'] = self.tax.to_dict()
        # override the default output from pydantic by calling `to_dict()` of regular_tax
        if self.regular_tax:
            _dict['regularTax'] = self.regular_tax.to_dict()
        # override the default output from pydantic by calling `to_dict()` of bonus_tax
        if self.bonus_tax:
            _dict['bonusTax'] = self.bonus_tax.to_dict()
        # override the default output from pydantic by calling `to_dict()` of income
        if self.income:
            _dict['income'] = self.income.to_dict()
        return _dict

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

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

        _obj = cls.model_validate({
            "annualCalculation": obj.get("annualCalculation"),
            "taxObject": obj.get("taxObject"),
            "year": obj.get("year"),
            "month": obj.get("month"),
            "employeeId": obj.get("employeeId"),
            "npwpNumber": obj.get("npwpNumber"),
            "npwpAddress": obj.get("npwpAddress"),
            "ptkpCategoryCode": obj.get("ptkpCategoryCode"),
            "terCategory": obj.get("terCategory"),
            "percentage": obj.get("percentage"),
            "monthlyGrossIncome": obj.get("monthlyGrossIncome"),
            "tax": TaxAmountResponse.from_dict(obj["tax"]) if obj.get("tax") is not None else None,
            "regularTax": TaxAmountResponse.from_dict(obj["regularTax"]) if obj.get("regularTax") is not None else None,
            "bonusTax": TaxAmountResponse.from_dict(obj["bonusTax"]) if obj.get("bonusTax") is not None else None,
            "income": TaxIncomeResponse.from_dict(obj["income"]) if obj.get("income") is not None else None,
            "positionalAllowance": obj.get("positionalAllowance"),
            "baseIncomeTaxDeduction": obj.get("baseIncomeTaxDeduction")
        })
        return _obj


