/* * 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 { safeParse } from "../../lib/schemas.js"; import { ClosedEnum } from "../../types/enums.js"; import { Result as SafeParseResult } from "../../types/fp.js"; import { SDKValidationError } from "../errors/sdkvalidationerror.js"; import { GarnishmentChildSupport, GarnishmentChildSupport$inboundSchema, } from "./garnishmentchildsupport.js"; export const GarnishmentType = { ChildSupport: "child_support", FederalTaxLien: "federal_tax_lien", StateTaxLien: "state_tax_lien", StudentLoan: "student_loan", CreditorGarnishment: "creditor_garnishment", FederalLoan: "federal_loan", OtherGarnishment: "other_garnishment", } as const; export type GarnishmentType = ClosedEnum; /** * Garnishments, or employee deductions, are fixed amounts or percentages deducted from an employee’s pay. They can be deducted a specific number of times or on a recurring basis. Garnishments can also have maximum deductions on a yearly or per-pay-period bases. Common uses for garnishments are court-ordered payments for child support or back taxes. Some companies provide loans to their employees that are repaid via garnishments. */ export type Garnishment = { /** * The UUID of the garnishment in Gusto. */ uuid: string; /** * 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; /** * The UUID of the employee to which this garnishment belongs. */ employeeUuid?: string | undefined; /** * Whether or not this garnishment is currently active. */ active: boolean; /** * The amount of the garnishment. Either a percentage or a fixed dollar amount. Represented as a float, e.g. "8.00". */ amount?: string | undefined; /** * The description of the garnishment. */ description?: string | undefined; /** * Whether the garnishment is court ordered. */ courtOrdered?: boolean | undefined; /** * The number of times to apply the garnishment. Ignored if recurring is true. */ times: number | null; /** * Whether the garnishment should recur indefinitely. */ recurring: boolean; /** * The maximum deduction per annum. A null value indicates no maximum. Represented as a float, e.g. "200.00". */ annualMaximum: string | null; /** * A maximum total deduction for the lifetime of this garnishment. A null value indicates no maximum. */ totalAmount: string | null; /** * The maximum deduction per pay period. A null value indicates no maximum. Represented as a float, e.g. "16.00". */ payPeriodMaximum: string | null; /** * Whether the amount should be treated as a percentage to be deducted per pay period. */ deductAsPercentage: boolean; /** * The specific type of garnishment for court ordered garnishments. */ garnishmentType?: GarnishmentType | null | undefined; /** * Additional child support order details */ childSupport?: GarnishmentChildSupport | null | undefined; }; /** @internal */ export const GarnishmentType$inboundSchema: z.ZodNativeEnum< typeof GarnishmentType > = z.nativeEnum(GarnishmentType); /** @internal */ export const Garnishment$inboundSchema: z.ZodType< Garnishment, z.ZodTypeDef, unknown > = z.object({ uuid: z.string(), version: z.string().optional(), employee_uuid: z.string().optional(), active: z.boolean().default(true), amount: z.string().optional(), description: z.string().optional(), court_ordered: z.boolean().optional(), times: z.nullable(z.number().int()).default(null), recurring: z.boolean().default(false), annual_maximum: z.nullable(z.string()).default(null), total_amount: z.nullable(z.string()).default(null), pay_period_maximum: z.nullable(z.string()).default(null), deduct_as_percentage: z.boolean().default(false), garnishment_type: z.nullable(GarnishmentType$inboundSchema).optional(), child_support: z.nullable(GarnishmentChildSupport$inboundSchema).optional(), }).transform((v) => { return remap$(v, { "employee_uuid": "employeeUuid", "court_ordered": "courtOrdered", "annual_maximum": "annualMaximum", "total_amount": "totalAmount", "pay_period_maximum": "payPeriodMaximum", "deduct_as_percentage": "deductAsPercentage", "garnishment_type": "garnishmentType", "child_support": "childSupport", }); }); export function garnishmentFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Garnishment$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Garnishment' from JSON`, ); }