/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod/v3"; import { remap as remap$ } from "../../lib/primitives.js"; import { ClosedEnum } from "../../types/enums.js"; import { RFCDate } from "../../types/rfcdate.js"; /** * The company contribution scheme. * * @remarks * * `amount`: The company contributes a fixed amount per payroll. If elective is true, the contribution is matching, dollar-for-dollar. * * `percentage`: The company contributes a percentage of the payroll amount per payroll period. If elective is true, the contribution is matching, dollar-for-dollar. * * `tiered`: The size of the company contribution corresponds to the size of the employee deduction relative to a tiered matching scheme. */ export const EmployeeBenefitUpdateRequestType = { Amount: "amount", Percentage: "percentage", Tiered: "tiered", } as const; /** * The company contribution scheme. * * @remarks * * `amount`: The company contributes a fixed amount per payroll. If elective is true, the contribution is matching, dollar-for-dollar. * * `percentage`: The company contributes a percentage of the payroll amount per payroll period. If elective is true, the contribution is matching, dollar-for-dollar. * * `tiered`: The size of the company contribution corresponds to the size of the employee deduction relative to a tiered matching scheme. */ export type EmployeeBenefitUpdateRequestType = ClosedEnum< typeof EmployeeBenefitUpdateRequestType >; /** * A single tier of a tiered matching scheme. */ export type EmployeeBenefitUpdateRequestValue2 = { /** * The percentage of employee deduction within this tier the company contribution will match. */ rate?: string | undefined; /** * Specifies the upper limit (inclusive) percentage of the employee contribution that this tier applies to. * * @remarks * * Use threshold to define each tier's end point, with tiers applied cumulatively from 0% upwards. * * For example: * * If the first tier has a threshold of "3", and rate of "100", the company will match 100% of employee contributions from 0% up to and including 3% of payroll. * * If the next tier has a threshold of "5" and a rate of "50", the company will match 50% of contributions from above 3% up to and including 5% of payroll. */ threshold?: string | undefined; }; /** * For the `amount` and `percentage` contribution types, the value of the corresponding amount or percentage. * * @remarks * * For the `tiered` contribution type, an array of tiers. */ export type EmployeeBenefitUpdateRequestValue = | string | Array; /** * An object representing the type and value of the company contribution. */ export type EmployeeBenefitUpdateRequestContribution = { /** * The company contribution scheme. * * @remarks * * `amount`: The company contributes a fixed amount per payroll. If elective is true, the contribution is matching, dollar-for-dollar. * * `percentage`: The company contributes a percentage of the payroll amount per payroll period. If elective is true, the contribution is matching, dollar-for-dollar. * * `tiered`: The size of the company contribution corresponds to the size of the employee deduction relative to a tiered matching scheme. */ type?: EmployeeBenefitUpdateRequestType | undefined; /** * For the `amount` and `percentage` contribution types, the value of the corresponding amount or percentage. * * @remarks * * For the `tiered` contribution type, an array of tiers. */ value?: string | Array | undefined; }; export const EmployeeBenefitUpdateRequestLimitOption = { Family: "Family", Individual: "Individual", JointFilingOrSingle: "Joint Filing or Single", MarriedAndFilingSeparately: "Married and Filing Separately", } as const; export type EmployeeBenefitUpdateRequestLimitOption = ClosedEnum< typeof EmployeeBenefitUpdateRequestLimitOption >; export const EmployeeBenefitUpdateRequestDeductionReducesTaxableIncome = { Unset: "unset", ReducesTaxableIncome: "reduces_taxable_income", DoesNotReduceTaxableIncome: "does_not_reduce_taxable_income", } as const; export type EmployeeBenefitUpdateRequestDeductionReducesTaxableIncome = ClosedEnum; export type EmployeeBenefitUpdateRequest = { /** * The current version of the object. See the [versioning guide](https://docs.gusto.com/embedded-payroll/docs/versioning#object-layer) for information on how to use this field. */ version: string; /** * Whether the employee benefit is active. */ active?: boolean | undefined; /** * The amount to be deducted, per pay period, from the employee's pay. */ employeeDeduction?: string | undefined; /** * Whether the employee deduction amount should be treated as a percentage to be deducted from each payroll. */ deductAsPercentage?: boolean | undefined; /** * The maximum employee deduction amount per year. A null value signifies no limit. */ employeeDeductionAnnualMaximum?: string | null | undefined; /** * The date the employee benefit will start. */ effectiveDate?: RFCDate | undefined; /** * The date the employee benefit will expire. A null value indicates the benefit will not expire. */ expirationDate?: RFCDate | null | undefined; /** * An object representing the type and value of the company contribution. */ contribution?: EmployeeBenefitUpdateRequestContribution | undefined; /** * Whether the company contribution is elective (aka "matching"). For `tiered`, `elective_amount`, and `elective_percentage` contribution types this is ignored and assumed to be `true`. */ elective?: boolean | undefined; /** * The maximum company contribution amount per year. A null value signifies no limit. */ companyContributionAnnualMaximum?: string | null | undefined; /** * Some benefits require additional information to determine * * @remarks * their limit. * * `Family` or `Individual`: Applicable to HSA benefit. * * `Joint Filing or Single` or `Married and Filing Separately`: Applicable to Dependent Care FSA benefit. */ limitOption?: EmployeeBenefitUpdateRequestLimitOption | null | undefined; /** * Whether the employee should use a benefit's "catch up" rate. Only Roth 401k and 401k benefits use this value for employees over 50. */ catchUp?: boolean | undefined; /** * The amount that the employee is insured for. Note: company contribution cannot be present if coverage amount is set. */ coverageAmount?: string | null | undefined; /** * Whether the employee deduction reduces taxable income or not. Only valid for Group Term Life benefits. Note: when the value is not "unset", coverage amount and coverage salary multiplier are ignored. */ deductionReducesTaxableIncome?: | EmployeeBenefitUpdateRequestDeductionReducesTaxableIncome | null | undefined; /** * The coverage amount as a multiple of the employee's salary. Only applicable for Group Term Life benefits. Note: cannot be set if coverage amount is also set. */ coverageSalaryMultiplier?: string | undefined; /** * The amount to be paid, per pay period, by the company. * * @deprecated field: This will be removed in a future release, please migrate away from it as soon as possible. */ companyContribution?: string | undefined; /** * Whether the company contribution amount should be treated as a percentage to be deducted from each payroll. * * @deprecated field: This will be removed in a future release, please migrate away from it as soon as possible. */ contributeAsPercentage?: boolean | undefined; }; /** @internal */ export const EmployeeBenefitUpdateRequestType$outboundSchema: z.ZodNativeEnum< typeof EmployeeBenefitUpdateRequestType > = z.nativeEnum(EmployeeBenefitUpdateRequestType); /** @internal */ export type EmployeeBenefitUpdateRequestValue2$Outbound = { rate?: string | undefined; threshold?: string | undefined; }; /** @internal */ export const EmployeeBenefitUpdateRequestValue2$outboundSchema: z.ZodType< EmployeeBenefitUpdateRequestValue2$Outbound, z.ZodTypeDef, EmployeeBenefitUpdateRequestValue2 > = z.object({ rate: z.string().optional(), threshold: z.string().optional(), }); export function employeeBenefitUpdateRequestValue2ToJSON( employeeBenefitUpdateRequestValue2: EmployeeBenefitUpdateRequestValue2, ): string { return JSON.stringify( EmployeeBenefitUpdateRequestValue2$outboundSchema.parse( employeeBenefitUpdateRequestValue2, ), ); } /** @internal */ export type EmployeeBenefitUpdateRequestValue$Outbound = | string | Array; /** @internal */ export const EmployeeBenefitUpdateRequestValue$outboundSchema: z.ZodType< EmployeeBenefitUpdateRequestValue$Outbound, z.ZodTypeDef, EmployeeBenefitUpdateRequestValue > = z.union([ z.string(), z.array(z.lazy(() => EmployeeBenefitUpdateRequestValue2$outboundSchema)), ]); export function employeeBenefitUpdateRequestValueToJSON( employeeBenefitUpdateRequestValue: EmployeeBenefitUpdateRequestValue, ): string { return JSON.stringify( EmployeeBenefitUpdateRequestValue$outboundSchema.parse( employeeBenefitUpdateRequestValue, ), ); } /** @internal */ export type EmployeeBenefitUpdateRequestContribution$Outbound = { type?: string | undefined; value?: | string | Array | undefined; }; /** @internal */ export const EmployeeBenefitUpdateRequestContribution$outboundSchema: z.ZodType< EmployeeBenefitUpdateRequestContribution$Outbound, z.ZodTypeDef, EmployeeBenefitUpdateRequestContribution > = z.object({ type: EmployeeBenefitUpdateRequestType$outboundSchema.optional(), value: z.union([ z.string(), z.array(z.lazy(() => EmployeeBenefitUpdateRequestValue2$outboundSchema)), ]).optional(), }); export function employeeBenefitUpdateRequestContributionToJSON( employeeBenefitUpdateRequestContribution: EmployeeBenefitUpdateRequestContribution, ): string { return JSON.stringify( EmployeeBenefitUpdateRequestContribution$outboundSchema.parse( employeeBenefitUpdateRequestContribution, ), ); } /** @internal */ export const EmployeeBenefitUpdateRequestLimitOption$outboundSchema: z.ZodNativeEnum = z .nativeEnum(EmployeeBenefitUpdateRequestLimitOption); /** @internal */ export const EmployeeBenefitUpdateRequestDeductionReducesTaxableIncome$outboundSchema: z.ZodNativeEnum< typeof EmployeeBenefitUpdateRequestDeductionReducesTaxableIncome > = z.nativeEnum(EmployeeBenefitUpdateRequestDeductionReducesTaxableIncome); /** @internal */ export type EmployeeBenefitUpdateRequest$Outbound = { version: string; active?: boolean | undefined; employee_deduction: string; deduct_as_percentage?: boolean | undefined; employee_deduction_annual_maximum?: string | null | undefined; effective_date?: string | undefined; expiration_date?: string | null | undefined; contribution?: EmployeeBenefitUpdateRequestContribution$Outbound | undefined; elective: boolean; company_contribution_annual_maximum?: string | null | undefined; limit_option?: string | null | undefined; catch_up: boolean; coverage_amount?: string | null | undefined; deduction_reduces_taxable_income?: string | null | undefined; coverage_salary_multiplier: string; company_contribution: string; contribute_as_percentage: boolean; }; /** @internal */ export const EmployeeBenefitUpdateRequest$outboundSchema: z.ZodType< EmployeeBenefitUpdateRequest$Outbound, z.ZodTypeDef, EmployeeBenefitUpdateRequest > = z.object({ version: z.string(), active: z.boolean().optional(), employeeDeduction: z.string().default("0.00"), deductAsPercentage: z.boolean().optional(), employeeDeductionAnnualMaximum: z.nullable(z.string()).optional(), effectiveDate: z.instanceof(RFCDate).transform(v => v.toString()).optional(), expirationDate: z.nullable(z.instanceof(RFCDate).transform(v => v.toString())) .optional(), contribution: z.lazy(() => EmployeeBenefitUpdateRequestContribution$outboundSchema ).optional(), elective: z.boolean().default(false), companyContributionAnnualMaximum: z.nullable(z.string()).optional(), limitOption: z.nullable( EmployeeBenefitUpdateRequestLimitOption$outboundSchema, ).optional(), catchUp: z.boolean().default(false), coverageAmount: z.nullable(z.string()).optional(), deductionReducesTaxableIncome: z.nullable( EmployeeBenefitUpdateRequestDeductionReducesTaxableIncome$outboundSchema, ).optional(), coverageSalaryMultiplier: z.string().default("0.00"), companyContribution: z.string().default("0.00"), contributeAsPercentage: z.boolean().default(false), }).transform((v) => { return remap$(v, { employeeDeduction: "employee_deduction", deductAsPercentage: "deduct_as_percentage", employeeDeductionAnnualMaximum: "employee_deduction_annual_maximum", effectiveDate: "effective_date", expirationDate: "expiration_date", companyContributionAnnualMaximum: "company_contribution_annual_maximum", limitOption: "limit_option", catchUp: "catch_up", coverageAmount: "coverage_amount", deductionReducesTaxableIncome: "deduction_reduces_taxable_income", coverageSalaryMultiplier: "coverage_salary_multiplier", companyContribution: "company_contribution", contributeAsPercentage: "contribute_as_percentage", }); }); export function employeeBenefitUpdateRequestToJSON( employeeBenefitUpdateRequest: EmployeeBenefitUpdateRequest, ): string { return JSON.stringify( EmployeeBenefitUpdateRequest$outboundSchema.parse( employeeBenefitUpdateRequest, ), ); }