/* * 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"; /** * The status of the external payroll. The status will be `unprocessed` when the external payroll is created and transition to `processed` once tax liabilities are entered and finalized. Once in the `processed` status all actions that can edit an external payroll will be disabled. */ export const ExternalPayrollStatus = { Unprocessed: "unprocessed", Processed: "processed", } as const; /** * The status of the external payroll. The status will be `unprocessed` when the external payroll is created and transition to `processed` once tax liabilities are entered and finalized. Once in the `processed` status all actions that can edit an external payroll will be disabled. */ export type ExternalPayrollStatus = ClosedEnum; export type Earnings = { amount?: string | undefined; hours?: string | undefined; earningType?: string | undefined; earningId?: number | undefined; }; export type Benefits = { benefitId?: number | undefined; companyContributionAmount?: string | undefined; employeeDeductionAmount?: string | undefined; }; export type ExternalPayrollTaxes = { taxId?: number | undefined; amount?: string | undefined; }; export type ExternalPayrollItems = { employeeUuid?: string | undefined; earnings?: Array | undefined; benefits?: Array | undefined; taxes?: Array | undefined; }; export type ApplicableEarnings = { earningType?: string | undefined; earningId?: number | undefined; name?: string | undefined; inputType?: string | undefined; category?: string | undefined; }; export type ApplicableBenefits = { id?: number | undefined; description?: string | undefined; active?: boolean | undefined; }; export type ApplicableTaxes = { id?: number | undefined; name?: string | undefined; /** * Some taxes may have an amount withheld from the employee and an amount withheld from the employer, e.g. Social Security. A `true` value indicates this is the employer's amount. */ employerTax?: boolean | undefined; /** * Some taxes may have different rates or reporting requirements depending on if the employee is a resident or non-resident of the tax jurisdiction. */ residentTax?: boolean | undefined; }; /** * Stores metadata of the external payroll. */ export type ExternalPayrollMetadata = { /** * Determines if the external payroll can be deleted. */ deletable?: boolean | undefined; }; /** * The representation of an external payroll. */ export type ExternalPayroll = { /** * The UUID of the external payroll. */ uuid: string; /** * The UUID of the company. */ companyUuid?: string | undefined; /** * External payroll's check date. */ checkDate?: string | undefined; /** * External payroll's pay period start date. */ paymentPeriodStartDate?: string | undefined; /** * External payroll's pay period end date. */ paymentPeriodEndDate?: string | undefined; /** * The status of the external payroll. The status will be `unprocessed` when the external payroll is created and transition to `processed` once tax liabilities are entered and finalized. Once in the `processed` status all actions that can edit an external payroll will be disabled. */ status?: ExternalPayrollStatus | undefined; /** * External payroll items for employees */ externalPayrollItems?: Array | undefined; /** * Applicable earnings based on company provisioning. */ applicableEarnings?: Array | undefined; /** * Applicable benefits based on company provisioning. */ applicableBenefits?: Array | null | undefined; /** * Applicable taxes based on company provisioning. */ applicableTaxes?: Array | undefined; /** * Stores metadata of the external payroll. */ metadata?: ExternalPayrollMetadata | undefined; }; /** @internal */ export const ExternalPayrollStatus$inboundSchema: z.ZodNativeEnum< typeof ExternalPayrollStatus > = z.nativeEnum(ExternalPayrollStatus); /** @internal */ export const Earnings$inboundSchema: z.ZodType< Earnings, z.ZodTypeDef, unknown > = z.object({ amount: z.string().optional(), hours: z.string().optional(), earning_type: z.string().optional(), earning_id: z.number().int().optional(), }).transform((v) => { return remap$(v, { "earning_type": "earningType", "earning_id": "earningId", }); }); export function earningsFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Earnings$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Earnings' from JSON`, ); } /** @internal */ export const Benefits$inboundSchema: z.ZodType< Benefits, z.ZodTypeDef, unknown > = z.object({ benefit_id: z.number().int().optional(), company_contribution_amount: z.string().optional(), employee_deduction_amount: z.string().optional(), }).transform((v) => { return remap$(v, { "benefit_id": "benefitId", "company_contribution_amount": "companyContributionAmount", "employee_deduction_amount": "employeeDeductionAmount", }); }); export function benefitsFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Benefits$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Benefits' from JSON`, ); } /** @internal */ export const ExternalPayrollTaxes$inboundSchema: z.ZodType< ExternalPayrollTaxes, z.ZodTypeDef, unknown > = z.object({ tax_id: z.number().int().optional(), amount: z.string().optional(), }).transform((v) => { return remap$(v, { "tax_id": "taxId", }); }); export function externalPayrollTaxesFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => ExternalPayrollTaxes$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'ExternalPayrollTaxes' from JSON`, ); } /** @internal */ export const ExternalPayrollItems$inboundSchema: z.ZodType< ExternalPayrollItems, z.ZodTypeDef, unknown > = z.object({ employee_uuid: z.string().optional(), earnings: z.array(z.lazy(() => Earnings$inboundSchema)).optional(), benefits: z.array(z.lazy(() => Benefits$inboundSchema)).optional(), taxes: z.array(z.lazy(() => ExternalPayrollTaxes$inboundSchema)).optional(), }).transform((v) => { return remap$(v, { "employee_uuid": "employeeUuid", }); }); export function externalPayrollItemsFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => ExternalPayrollItems$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'ExternalPayrollItems' from JSON`, ); } /** @internal */ export const ApplicableEarnings$inboundSchema: z.ZodType< ApplicableEarnings, z.ZodTypeDef, unknown > = z.object({ earning_type: z.string().optional(), earning_id: z.number().optional(), name: z.string().optional(), input_type: z.string().optional(), category: z.string().optional(), }).transform((v) => { return remap$(v, { "earning_type": "earningType", "earning_id": "earningId", "input_type": "inputType", }); }); export function applicableEarningsFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => ApplicableEarnings$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'ApplicableEarnings' from JSON`, ); } /** @internal */ export const ApplicableBenefits$inboundSchema: z.ZodType< ApplicableBenefits, z.ZodTypeDef, unknown > = z.object({ id: z.number().int().optional(), description: z.string().optional(), active: z.boolean().optional(), }); export function applicableBenefitsFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => ApplicableBenefits$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'ApplicableBenefits' from JSON`, ); } /** @internal */ export const ApplicableTaxes$inboundSchema: z.ZodType< ApplicableTaxes, z.ZodTypeDef, unknown > = z.object({ id: z.number().int().optional(), name: z.string().optional(), employer_tax: z.boolean().optional(), resident_tax: z.boolean().optional(), }).transform((v) => { return remap$(v, { "employer_tax": "employerTax", "resident_tax": "residentTax", }); }); export function applicableTaxesFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => ApplicableTaxes$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'ApplicableTaxes' from JSON`, ); } /** @internal */ export const ExternalPayrollMetadata$inboundSchema: z.ZodType< ExternalPayrollMetadata, z.ZodTypeDef, unknown > = z.object({ deletable: z.boolean().optional(), }); export function externalPayrollMetadataFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => ExternalPayrollMetadata$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'ExternalPayrollMetadata' from JSON`, ); } /** @internal */ export const ExternalPayroll$inboundSchema: z.ZodType< ExternalPayroll, z.ZodTypeDef, unknown > = z.object({ uuid: z.string(), company_uuid: z.string().optional(), check_date: z.string().optional(), payment_period_start_date: z.string().optional(), payment_period_end_date: z.string().optional(), status: ExternalPayrollStatus$inboundSchema.optional(), external_payroll_items: z.array( z.lazy(() => ExternalPayrollItems$inboundSchema), ).optional(), applicable_earnings: z.array(z.lazy(() => ApplicableEarnings$inboundSchema)) .optional(), applicable_benefits: z.nullable( z.array(z.lazy(() => ApplicableBenefits$inboundSchema)), ).optional(), applicable_taxes: z.array(z.lazy(() => ApplicableTaxes$inboundSchema)) .optional(), metadata: z.lazy(() => ExternalPayrollMetadata$inboundSchema).optional(), }).transform((v) => { return remap$(v, { "company_uuid": "companyUuid", "check_date": "checkDate", "payment_period_start_date": "paymentPeriodStartDate", "payment_period_end_date": "paymentPeriodEndDate", "external_payroll_items": "externalPayrollItems", "applicable_earnings": "applicableEarnings", "applicable_benefits": "applicableBenefits", "applicable_taxes": "applicableTaxes", }); }); export function externalPayrollFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => ExternalPayroll$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'ExternalPayroll' from JSON`, ); }