/* * 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"; /** * A single tier of a tiered matching scheme. */ export type ValueTiers = { /** * 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; /** * The step up difference between this tier's threshold and the previous tier's threshold. In the first tier, this is equivalent to threshold. */ thresholdDelta?: string | undefined; }; export type Value2 = { tiers?: Array | 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 EmployeeBenefitForCompanyBenefitValue = string | Value2; /** * An object representing the type and value of the company contribution. */ export type EmployeeBenefitForCompanyBenefitContribution = { /** * 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 company contribution varies according to the size of the employee deduction. */ type?: 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. */ value?: string | Value2 | undefined; }; export const EmployeeBenefitForCompanyBenefitDeductionReducesTaxableIncome = { Unset: "unset", ReducesTaxableIncome: "reduces_taxable_income", DoesNotReduceTaxableIncome: "does_not_reduce_taxable_income", } as const; export type EmployeeBenefitForCompanyBenefitDeductionReducesTaxableIncome = ClosedEnum< typeof EmployeeBenefitForCompanyBenefitDeductionReducesTaxableIncome >; /** * The action to perform on the employee benefit. Required for creating/updating an effective dated employee benefit. */ export const Action = { Create: "create", Update: "update", } as const; /** * The action to perform on the employee benefit. Required for creating/updating an effective dated employee benefit. */ export type Action = ClosedEnum; /** * The representation of an employee benefit for a company benefit. */ export type EmployeeBenefitForCompanyBenefit = { /** * The current version of the object. See the [versioning guide](https://docs.gusto.com/embedded-payroll/docs/idempotency) for information on how to use this field. */ version?: string | undefined; /** * 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; /** * An object representing the type and value of the company contribution. */ contribution?: EmployeeBenefitForCompanyBenefitContribution | undefined; /** * Whether the company contribution is elective (aka matching). For "tiered" contribution types, this is always 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 their limit. * * @remarks * * `Family` and `Individual` are applicable to HSA benefit. * * `Joint Filing or Single` and `Married and Filing Separately` are applicable to Dependent Care FSA benefit. */ limitOption?: string | 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 | null | undefined; /** * Identifier for a 401(k) loan assigned by the 401(k) provider */ retirementLoanIdentifier?: string | null | 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?: | EmployeeBenefitForCompanyBenefitDeductionReducesTaxableIncome | 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 | null | undefined; /** * The amount to be paid, per pay period, by the company. This field will not appear for tiered contribution types. * * @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 value should be treated as a percentage to be added to each payroll. This field will not appear for tiered contribution types. * * @deprecated field: This will be removed in a future release, please migrate away from it as soon as possible. */ contributeAsPercentage?: boolean | 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; /** * The UUID of the employee to which the benefit belongs. */ employeeUuid: string; /** * The UUID of the employee benefit. Required for updating an effective dated employee benefit. */ uuid?: string | undefined; /** * The action to perform on the employee benefit. Required for creating/updating an effective dated employee benefit. */ action?: Action | undefined; additionalProperties?: { [k: string]: any } | undefined; }; /** @internal */ export type ValueTiers$Outbound = { rate?: string | undefined; threshold?: string | undefined; threshold_delta?: string | undefined; }; /** @internal */ export const ValueTiers$outboundSchema: z.ZodType< ValueTiers$Outbound, z.ZodTypeDef, ValueTiers > = z.object({ rate: z.string().optional(), threshold: z.string().optional(), thresholdDelta: z.string().optional(), }).transform((v) => { return remap$(v, { thresholdDelta: "threshold_delta", }); }); export function valueTiersToJSON(valueTiers: ValueTiers): string { return JSON.stringify(ValueTiers$outboundSchema.parse(valueTiers)); } /** @internal */ export type Value2$Outbound = { tiers?: Array | undefined; }; /** @internal */ export const Value2$outboundSchema: z.ZodType< Value2$Outbound, z.ZodTypeDef, Value2 > = z.object({ tiers: z.array(z.lazy(() => ValueTiers$outboundSchema)).optional(), }); export function value2ToJSON(value2: Value2): string { return JSON.stringify(Value2$outboundSchema.parse(value2)); } /** @internal */ export type EmployeeBenefitForCompanyBenefitValue$Outbound = | string | Value2$Outbound; /** @internal */ export const EmployeeBenefitForCompanyBenefitValue$outboundSchema: z.ZodType< EmployeeBenefitForCompanyBenefitValue$Outbound, z.ZodTypeDef, EmployeeBenefitForCompanyBenefitValue > = z.union([z.string(), z.lazy(() => Value2$outboundSchema)]); export function employeeBenefitForCompanyBenefitValueToJSON( employeeBenefitForCompanyBenefitValue: EmployeeBenefitForCompanyBenefitValue, ): string { return JSON.stringify( EmployeeBenefitForCompanyBenefitValue$outboundSchema.parse( employeeBenefitForCompanyBenefitValue, ), ); } /** @internal */ export type EmployeeBenefitForCompanyBenefitContribution$Outbound = { type?: string | undefined; value?: string | Value2$Outbound | undefined; }; /** @internal */ export const EmployeeBenefitForCompanyBenefitContribution$outboundSchema: z.ZodType< EmployeeBenefitForCompanyBenefitContribution$Outbound, z.ZodTypeDef, EmployeeBenefitForCompanyBenefitContribution > = z.object({ type: z.string().optional(), value: z.union([z.string(), z.lazy(() => Value2$outboundSchema)]) .optional(), }); export function employeeBenefitForCompanyBenefitContributionToJSON( employeeBenefitForCompanyBenefitContribution: EmployeeBenefitForCompanyBenefitContribution, ): string { return JSON.stringify( EmployeeBenefitForCompanyBenefitContribution$outboundSchema.parse( employeeBenefitForCompanyBenefitContribution, ), ); } /** @internal */ export const EmployeeBenefitForCompanyBenefitDeductionReducesTaxableIncome$outboundSchema: z.ZodNativeEnum< typeof EmployeeBenefitForCompanyBenefitDeductionReducesTaxableIncome > = z.nativeEnum( EmployeeBenefitForCompanyBenefitDeductionReducesTaxableIncome, ); /** @internal */ export const Action$outboundSchema: z.ZodNativeEnum = z .nativeEnum(Action); /** @internal */ export type EmployeeBenefitForCompanyBenefit$Outbound = { version?: string | undefined; active: boolean; employee_deduction: string; deduct_as_percentage: boolean; employee_deduction_annual_maximum?: string | null | undefined; contribution?: | EmployeeBenefitForCompanyBenefitContribution$Outbound | undefined; elective: boolean; company_contribution_annual_maximum?: string | null | undefined; limit_option?: string | null | undefined; catch_up: boolean | null; retirement_loan_identifier?: string | null | undefined; coverage_amount?: string | null | undefined; deduction_reduces_taxable_income?: string | null | undefined; coverage_salary_multiplier: string | null; company_contribution: string; contribute_as_percentage: boolean; effective_date?: string | undefined; expiration_date?: string | null | undefined; employee_uuid: string; uuid?: string | undefined; action?: string | undefined; [additionalProperties: string]: unknown; }; /** @internal */ export const EmployeeBenefitForCompanyBenefit$outboundSchema: z.ZodType< EmployeeBenefitForCompanyBenefit$Outbound, z.ZodTypeDef, EmployeeBenefitForCompanyBenefit > = z.object({ version: z.string().optional(), active: z.boolean().default(true), employeeDeduction: z.string().default("0.00"), deductAsPercentage: z.boolean().default(false), employeeDeductionAnnualMaximum: z.nullable(z.string()).optional(), contribution: z.lazy(() => EmployeeBenefitForCompanyBenefitContribution$outboundSchema ).optional(), elective: z.boolean().default(false), companyContributionAnnualMaximum: z.nullable(z.string()).optional(), limitOption: z.nullable(z.string()).optional(), catchUp: z.nullable(z.boolean().default(false)), retirementLoanIdentifier: z.nullable(z.string()).optional(), coverageAmount: z.nullable(z.string()).optional(), deductionReducesTaxableIncome: z.nullable( EmployeeBenefitForCompanyBenefitDeductionReducesTaxableIncome$outboundSchema, ).optional(), coverageSalaryMultiplier: z.nullable(z.string().default("0.00")), companyContribution: z.string().default("0.00"), contributeAsPercentage: z.boolean().default(false), effectiveDate: z.instanceof(RFCDate).transform(v => v.toString()).optional(), expirationDate: z.nullable(z.instanceof(RFCDate).transform(v => v.toString())) .optional(), employeeUuid: z.string(), uuid: z.string().optional(), action: Action$outboundSchema.optional(), additionalProperties: z.record(z.any()).optional(), }).transform((v) => { return { ...v.additionalProperties, ...remap$(v, { employeeDeduction: "employee_deduction", deductAsPercentage: "deduct_as_percentage", employeeDeductionAnnualMaximum: "employee_deduction_annual_maximum", companyContributionAnnualMaximum: "company_contribution_annual_maximum", limitOption: "limit_option", catchUp: "catch_up", retirementLoanIdentifier: "retirement_loan_identifier", coverageAmount: "coverage_amount", deductionReducesTaxableIncome: "deduction_reduces_taxable_income", coverageSalaryMultiplier: "coverage_salary_multiplier", companyContribution: "company_contribution", contributeAsPercentage: "contribute_as_percentage", effectiveDate: "effective_date", expirationDate: "expiration_date", employeeUuid: "employee_uuid", additionalProperties: null, }), }; }); export function employeeBenefitForCompanyBenefitToJSON( employeeBenefitForCompanyBenefit: EmployeeBenefitForCompanyBenefit, ): string { return JSON.stringify( EmployeeBenefitForCompanyBenefit$outboundSchema.parse( employeeBenefitForCompanyBenefit, ), ); }