"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""

from __future__ import annotations
from gusto_embedded.types import (
    BaseModel,
    Nullable,
    OptionalNullable,
    UNSET,
    UNSET_SENTINEL,
)
from pydantic import model_serializer
from typing import Optional
from typing_extensions import NotRequired, TypedDict


class BenefitSummaryPayPeriodTypedDict(TypedDict):
    start_date: NotRequired[Nullable[str]]
    r"""The beginning of the payroll's pay period."""
    end_date: NotRequired[Nullable[str]]
    r"""The end of the payroll's pay period."""


class BenefitSummaryPayPeriod(BaseModel):
    start_date: OptionalNullable[str] = UNSET
    r"""The beginning of the payroll's pay period."""

    end_date: OptionalNullable[str] = UNSET
    r"""The end of the payroll's pay period."""

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = ["start_date", "end_date"]
        nullable_fields = ["start_date", "end_date"]
        null_default_fields = []

        serialized = handler(self)

        m = {}

        for n, f in self.model_fields.items():
            k = f.alias or n
            val = serialized.get(k)
            serialized.pop(k, None)

            optional_nullable = k in optional_fields and k in nullable_fields
            is_set = (
                self.__pydantic_fields_set__.intersection({n})
                or k in null_default_fields
            )  # pylint: disable=no-member

            if val is not None and val != UNSET_SENTINEL:
                m[k] = val
            elif val != UNSET_SENTINEL and (
                not k in optional_fields or (optional_nullable and is_set)
            ):
                m[k] = val

        return m


class PayrollBenefitsTypedDict(TypedDict):
    payroll_uuid: NotRequired[str]
    payroll_type: NotRequired[str]
    r"""Whether it is regular or bonus payroll"""
    check_date: NotRequired[str]
    r"""Check date of this payroll."""
    gross_pay: NotRequired[str]
    r"""Gross pay for this employee on the payroll."""
    imputed_pay: NotRequired[str]
    r"""Total imputed pay for this employee on the payroll."""
    company_benefit_deduction: NotRequired[str]
    r"""The employee benefit deduction amount for this employee on the payroll."""
    company_benefit_contribution: NotRequired[str]
    r"""The company contribution amount for this employee on the payroll."""
    pay_period: NotRequired[BenefitSummaryPayPeriodTypedDict]


class PayrollBenefits(BaseModel):
    payroll_uuid: Optional[str] = None

    payroll_type: Optional[str] = None
    r"""Whether it is regular or bonus payroll"""

    check_date: Optional[str] = None
    r"""Check date of this payroll."""

    gross_pay: Optional[str] = None
    r"""Gross pay for this employee on the payroll."""

    imputed_pay: Optional[str] = None
    r"""Total imputed pay for this employee on the payroll."""

    company_benefit_deduction: Optional[str] = None
    r"""The employee benefit deduction amount for this employee on the payroll."""

    company_benefit_contribution: Optional[str] = None
    r"""The company contribution amount for this employee on the payroll."""

    pay_period: Optional[BenefitSummaryPayPeriod] = None


class BenefitSummaryEmployeesTypedDict(TypedDict):
    uuid: NotRequired[str]
    r"""The UUID of the employee"""
    company_benefit_deduction: NotRequired[str]
    r"""The sum of employee deduction for this employee given the period of time and the specific company benefit."""
    company_benefit_contribution: NotRequired[str]
    r"""The sum of company contribution for this employee given the period of time and the specific company benefit."""
    benefit_deduction: NotRequired[str]
    r"""The sum of employee benefit deduction for this employee given the period of time and the benefit type."""
    benefit_contribution: NotRequired[str]
    r"""The sum of company contribution for this employee given the period of time and the benefit type."""
    gross_pay: NotRequired[str]
    r"""Gross pay for this employee given the period of time."""
    imputed_pay: NotRequired[str]
    r"""Total imputed pay for this employee given the period of time (not scoped to a benefit type)."""
    payroll_benefits: NotRequired[PayrollBenefitsTypedDict]


class BenefitSummaryEmployees(BaseModel):
    uuid: Optional[str] = None
    r"""The UUID of the employee"""

    company_benefit_deduction: Optional[str] = None
    r"""The sum of employee deduction for this employee given the period of time and the specific company benefit."""

    company_benefit_contribution: Optional[str] = None
    r"""The sum of company contribution for this employee given the period of time and the specific company benefit."""

    benefit_deduction: Optional[str] = None
    r"""The sum of employee benefit deduction for this employee given the period of time and the benefit type."""

    benefit_contribution: Optional[str] = None
    r"""The sum of company contribution for this employee given the period of time and the benefit type."""

    gross_pay: Optional[str] = None
    r"""Gross pay for this employee given the period of time."""

    imputed_pay: Optional[str] = None
    r"""Total imputed pay for this employee given the period of time (not scoped to a benefit type)."""

    payroll_benefits: Optional[PayrollBenefits] = None


class BenefitSummaryTypedDict(TypedDict):
    r"""Benefit summary response"""

    start_date: NotRequired[str]
    r"""The start date of benefit summary."""
    end_date: NotRequired[str]
    r"""The end date of benefit summary."""
    description: NotRequired[str]
    r"""Description of the benefit."""
    company_benefit_deduction: NotRequired[str]
    r"""The aggregate of employee deduction for all employees given the period of time and the specific company benefit."""
    company_benefit_contribution: NotRequired[str]
    r"""The aggregate of company contribution for all employees given the period of time and the specific company benefit."""
    employees: NotRequired[BenefitSummaryEmployeesTypedDict]


class BenefitSummary(BaseModel):
    r"""Benefit summary response"""

    start_date: Optional[str] = None
    r"""The start date of benefit summary."""

    end_date: Optional[str] = None
    r"""The end date of benefit summary."""

    description: Optional[str] = None
    r"""Description of the benefit."""

    company_benefit_deduction: Optional[str] = None
    r"""The aggregate of employee deduction for all employees given the period of time and the specific company benefit."""

    company_benefit_contribution: Optional[str] = None
    r"""The aggregate of company contribution for all employees given the period of time and the specific company benefit."""

    employees: Optional[BenefitSummaryEmployees] = None
