# coding: utf-8

"""
    Acre Platform User API

    # CORS CORS is implemented by all Acre API endpoints and only certain hostnames are allowed for each deployment of the API. If your use case requires calling the Acre User API from a browser, please contact Acre to arrange the appropriate configuration. # API Authentication The primary method of authentication for users of the Acre API is with the use of JSON Web Tokens (JWTs), which are suplemented by an application specific API Key. The API key must be provided through the `X-API-KEY` HTTP header and will be provided by your Acre Customer Success Manager. The JWT must be provided through a cookie with key of `authorization`. The JWT must be generated and signed as per the following section. # Generating JWTs JWT must either be generated by a third-party such as Azure ADB2C that has been configured for the appropriate service and/or user account, or alternatively can be generated locally and signed by an private key for which the public key has been made available to Acre via a JWKS URL. In addition to being signed by your private key, the JWT will also need to contain at a minimum:  * An issuer `iss`, which must be a valid URI previously agreed with Acre.  * A subject `sub`, which must be a unique identifier for the user and/or service account previously agreed with Acre.  * An expiry time `exp` which must not be more than four hours in the future.  * A not before time `nbf` which must be in the past, but not greater than six hours in the past.  The JWT should be signed using RS256.

    The version of the OpenAPI document: 1.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 pydantic import BaseModel, ConfigDict, Field, StrictBool, StrictInt, StrictStr
from typing import Any, ClassVar, Dict, List, Optional
from acre_api.models.cdm_address import CdmAddress
from acre_api.models.client_self_employment_income_accountant_qualifications import ClientSelfEmploymentIncomeAccountantQualifications
from acre_api.models.client_self_employment_income_self_employed_basis import ClientSelfEmploymentIncomeSelfEmployedBasis
from typing import Optional, Set
from typing_extensions import Self

class CdmClientSelfEmploymentIncome(BaseModel):
    """
    CdmClientSelfEmploymentIncome
    """ # noqa: E501
    has_accountant: Optional[StrictBool] = Field(default=None, description="Flag indicating whether the company has an accountant.")
    self_employed_basis: Optional[ClientSelfEmploymentIncomeSelfEmployedBasis] = ClientSelfEmploymentIncomeSelfEmployedBasis.INVALID_SELF_EMPLOYED_BASIS
    shareholding_percentage: Optional[StrictInt] = Field(default=None, description="The percentage shareholding in the company, represented as 1/100000 of a percent (precision for up to 5 decimal places of a percent).")
    business_start_date: Optional[StrictStr] = Field(default=None, description="The business' start date (YYYY-MM-DD).")
    your_role_in_business_end_date: Optional[StrictStr] = Field(default=None, description="The date at which your role in the business ended, to delimit the previous self-employment date (YYYY-MM-DD).")
    financial_year_end_date: Optional[StrictStr] = Field(default=None, description="The business' financial year end date (YYYY-MM-DD).")
    connected_with_business_since_date: Optional[StrictStr] = Field(default=None, description="The date when the individual was first connected with the business (YYYY-MM-DD).")
    nature_of_business: Optional[StrictStr] = Field(default=None, description="The nature of the business.")
    limited_company_registration_number: Optional[StrictStr] = Field(default=None, description="The business' limited company registration number.")
    business_name: Optional[StrictStr] = Field(default=None, description="The business' name.")
    accountant_qualifications: Optional[List[ClientSelfEmploymentIncomeAccountantQualifications]] = Field(default=None, description="An array of the business accountant's qualifications.")
    no_of_years_accounts_available: Optional[StrictInt] = None
    net_profits_last_year: Optional[StrictStr] = Field(default=None, description="Last year's net profits (in pence, not GBP).")
    net_profits_two_years_ago: Optional[StrictStr] = Field(default=None, description="Previous year's net profits (in pence, not GBP).")
    net_profits_three_years_ago: Optional[StrictStr] = Field(default=None, description="Year before previous year's net profits (in pence, not GBP).")
    business_address: Optional[CdmAddress] = None
    business_work_phone: Optional[StrictStr] = Field(default=None, description="Work phone number.")
    business_mobile_phone: Optional[StrictStr] = Field(default=None, description="Mobile phone number.")
    business_email: Optional[StrictStr] = Field(default=None, description="Email address.")
    business_alternate_email: Optional[StrictStr] = Field(default=None, description="Alternate email address.")
    accountant_name: Optional[StrictStr] = Field(default=None, description="The business accountant's name.")
    accountant_address: Optional[CdmAddress] = None
    accountant_work_phone: Optional[StrictStr] = Field(default=None, description="The work phone number of the accountant.")
    accountant_mobile_phone: Optional[StrictStr] = Field(default=None, description="The mobile phone number of the accountant.")
    accountant_email: Optional[StrictStr] = Field(default=None, description="The accountant's email address.")
    accountant_alternate_email: Optional[StrictStr] = Field(default=None, description="The accountant's alternate email address.")
    taxable_income_last_year: Optional[StrictStr] = Field(default=None, description="The taxable income from last year (in pence, not GBP).")
    taxable_income_two_years_ago: Optional[StrictStr] = Field(default=None, description="The taxable income from 2 years ago (in pence, not GBP).")
    taxable_income_three_years_ago: Optional[StrictStr] = Field(default=None, description="The taxable income from 3 years ago (in pence, not GBP).")
    percentage_share_last_year: Optional[StrictInt] = Field(default=None, description="The percentage share of the company from last year, represented as 1/100000 of a percent (precision for up to 5 decimal places).")
    percentage_share_two_years_ago: Optional[StrictInt] = Field(default=None, description="The percentage share of the company from 2 years ago, represented as 1/100000 of a percent (precision for up to 5 decimal places).")
    percentage_share_three_years_ago: Optional[StrictInt] = Field(default=None, description="The percentage share of the company from 3 years ago, represented as 1/100000 of a percent (precision for up to 5 decimal places).")
    tax_year_last_year: Optional[StrictInt] = Field(default=None, description="Corresponding tax year from last year.")
    tax_year_two_years_ago: Optional[StrictInt] = Field(default=None, description="Corresponding tax year from 2 years ago.")
    tax_year_three_years_ago: Optional[StrictInt] = Field(default=None, description="Corresponding tax year from 3 years ago.")
    tax_deductions: Optional[StrictStr] = Field(default=None, description="The amount of tax deductions (in pence, not GBP).")
    national_insurance_deductions: Optional[StrictStr] = Field(default=None, description="The amount of national insurance deductions (in pence, not GBP).  DEPRECATED: due to GBP to pence conversion.  string taxable_income_last_year = 28;  string taxable_income_two_years_ago = 29;  string taxable_income_three_years_ago = 30;  string tax_deductions = 37;  string national_insurance_deductions = 38;  google.protobuf.UInt64Value net_profits_last_year = 14;  google.protobuf.UInt64Value net_profits_two_years_ago = 15;  google.protobuf.UInt64Value net_profits_three_years_ago = 16;  google.protobuf.UInt64Value tax_year_last_year = 34;  google.protobuf.UInt64Value tax_year_two_years_ago = 35;  google.protobuf.UInt64Value tax_year_three_years_ago = 36;")
    employed_for_tax_purposes: Optional[StrictBool] = Field(default=None, description="Is the client employed for tax purposes?.")
    salary_income_last_year: Optional[StrictStr] = Field(default=None, description="Salary income last year in pence.")
    salary_income_two_years_ago: Optional[StrictStr] = Field(default=None, description="Salary income two years ago in pence.")
    salary_income_three_years_ago: Optional[StrictStr] = Field(default=None, description="Salary income three years ago in pence.")
    dividend_income_last_year: Optional[StrictStr] = Field(default=None, description="Dividend income last year in pence.")
    dividend_income_two_years_ago: Optional[StrictStr] = Field(default=None, description="Dividend income two years ago in pence.")
    dividend_income_three_years_ago: Optional[StrictStr] = Field(default=None, description="Dividend income three years ago in pence.")
    __properties: ClassVar[List[str]] = ["has_accountant", "self_employed_basis", "shareholding_percentage", "business_start_date", "your_role_in_business_end_date", "financial_year_end_date", "connected_with_business_since_date", "nature_of_business", "limited_company_registration_number", "business_name", "accountant_qualifications", "no_of_years_accounts_available", "net_profits_last_year", "net_profits_two_years_ago", "net_profits_three_years_ago", "business_address", "business_work_phone", "business_mobile_phone", "business_email", "business_alternate_email", "accountant_name", "accountant_address", "accountant_work_phone", "accountant_mobile_phone", "accountant_email", "accountant_alternate_email", "taxable_income_last_year", "taxable_income_two_years_ago", "taxable_income_three_years_ago", "percentage_share_last_year", "percentage_share_two_years_ago", "percentage_share_three_years_ago", "tax_year_last_year", "tax_year_two_years_ago", "tax_year_three_years_ago", "tax_deductions", "national_insurance_deductions", "employed_for_tax_purposes", "salary_income_last_year", "salary_income_two_years_ago", "salary_income_three_years_ago", "dividend_income_last_year", "dividend_income_two_years_ago", "dividend_income_three_years_ago"]

    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 CdmClientSelfEmploymentIncome 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 business_address
        if self.business_address:
            _dict['business_address'] = self.business_address.to_dict()
        # override the default output from pydantic by calling `to_dict()` of accountant_address
        if self.accountant_address:
            _dict['accountant_address'] = self.accountant_address.to_dict()
        return _dict

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

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

        _obj = cls.model_validate({
            "has_accountant": obj.get("has_accountant"),
            "self_employed_basis": obj.get("self_employed_basis") if obj.get("self_employed_basis") is not None else ClientSelfEmploymentIncomeSelfEmployedBasis.INVALID_SELF_EMPLOYED_BASIS,
            "shareholding_percentage": obj.get("shareholding_percentage"),
            "business_start_date": obj.get("business_start_date"),
            "your_role_in_business_end_date": obj.get("your_role_in_business_end_date"),
            "financial_year_end_date": obj.get("financial_year_end_date"),
            "connected_with_business_since_date": obj.get("connected_with_business_since_date"),
            "nature_of_business": obj.get("nature_of_business"),
            "limited_company_registration_number": obj.get("limited_company_registration_number"),
            "business_name": obj.get("business_name"),
            "accountant_qualifications": obj.get("accountant_qualifications"),
            "no_of_years_accounts_available": obj.get("no_of_years_accounts_available"),
            "net_profits_last_year": obj.get("net_profits_last_year"),
            "net_profits_two_years_ago": obj.get("net_profits_two_years_ago"),
            "net_profits_three_years_ago": obj.get("net_profits_three_years_ago"),
            "business_address": CdmAddress.from_dict(obj["business_address"]) if obj.get("business_address") is not None else None,
            "business_work_phone": obj.get("business_work_phone"),
            "business_mobile_phone": obj.get("business_mobile_phone"),
            "business_email": obj.get("business_email"),
            "business_alternate_email": obj.get("business_alternate_email"),
            "accountant_name": obj.get("accountant_name"),
            "accountant_address": CdmAddress.from_dict(obj["accountant_address"]) if obj.get("accountant_address") is not None else None,
            "accountant_work_phone": obj.get("accountant_work_phone"),
            "accountant_mobile_phone": obj.get("accountant_mobile_phone"),
            "accountant_email": obj.get("accountant_email"),
            "accountant_alternate_email": obj.get("accountant_alternate_email"),
            "taxable_income_last_year": obj.get("taxable_income_last_year"),
            "taxable_income_two_years_ago": obj.get("taxable_income_two_years_ago"),
            "taxable_income_three_years_ago": obj.get("taxable_income_three_years_ago"),
            "percentage_share_last_year": obj.get("percentage_share_last_year"),
            "percentage_share_two_years_ago": obj.get("percentage_share_two_years_ago"),
            "percentage_share_three_years_ago": obj.get("percentage_share_three_years_ago"),
            "tax_year_last_year": obj.get("tax_year_last_year"),
            "tax_year_two_years_ago": obj.get("tax_year_two_years_ago"),
            "tax_year_three_years_ago": obj.get("tax_year_three_years_ago"),
            "tax_deductions": obj.get("tax_deductions"),
            "national_insurance_deductions": obj.get("national_insurance_deductions"),
            "employed_for_tax_purposes": obj.get("employed_for_tax_purposes"),
            "salary_income_last_year": obj.get("salary_income_last_year"),
            "salary_income_two_years_ago": obj.get("salary_income_two_years_ago"),
            "salary_income_three_years_ago": obj.get("salary_income_three_years_ago"),
            "dividend_income_last_year": obj.get("dividend_income_last_year"),
            "dividend_income_two_years_ago": obj.get("dividend_income_two_years_ago"),
            "dividend_income_three_years_ago": obj.get("dividend_income_three_years_ago")
        })
        return _obj


