/* * 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 { lazySchema as lazySchema$, safeParse } from "../../lib/schemas.js"; import * as openEnums from "../../types/enums.js"; import { OpenEnum } from "../../types/enums.js"; import { Result as SafeParseResult } from "../../types/fp.js"; import * as types from "../../types/primitives.js"; import { SDKValidationError } from "../errors/sdkvalidationerror.js"; /** * Whether transactions can be posted into the period. `open`: postings are accepted on at least the last day of the period; a lock date inside the period still rejects earlier dates (see `locked_through`). `locked`: posting is blocked for some users or transaction types only, for example everyone except advisers or administrators. `closed`: posting is blocked for all users until the period or year is reopened. `future`: the accounting system reports the period as not yet opened. Null or absent means the connector does not expose the period's status. */ export const FiscalPeriodStatus = { Open: "open", Locked: "locked", Closed: "closed", Future: "future", } as const; /** * Whether transactions can be posted into the period. `open`: postings are accepted on at least the last day of the period; a lock date inside the period still rejects earlier dates (see `locked_through`). `locked`: posting is blocked for some users or transaction types only, for example everyone except advisers or administrators. `closed`: posting is blocked for all users until the period or year is reopened. `future`: the accounting system reports the period as not yet opened. Null or absent means the connector does not expose the period's status. */ export type FiscalPeriodStatus = OpenEnum; /** * Whether this record is a posting period, or a quarter or year that groups posting periods. */ export const FiscalPeriodPeriodType = { Period: "period", Quarter: "quarter", Year: "year", } as const; /** * Whether this record is a posting period, or a quarter or year that groups posting periods. */ export type FiscalPeriodPeriodType = OpenEnum; export type FiscalPeriod = { /** * A unique identifier for an object. */ id?: string | undefined; /** * Name of the fiscal period as shown in the accounting system. */ name?: string | null | undefined; /** * The calendar year in which the period's fiscal year ends, as four digits (Jul 2025 to Jun 2026 is `2026`). Derived from the fiscal year's end date; the accounting system's own label is in `name`. */ fiscalYear?: string | null | undefined; /** * Position of the period within its fiscal year, starting at 1. */ periodNumber?: number | null | undefined; /** * First day of the period (inclusive). */ startDate?: Date | null | undefined; /** * Last day of the period (inclusive). */ endDate?: Date | null | undefined; /** * Whether transactions can be posted into the period. `open`: postings are accepted on at least the last day of the period; a lock date inside the period still rejects earlier dates (see `locked_through`). `locked`: posting is blocked for some users or transaction types only, for example everyone except advisers or administrators. `closed`: posting is blocked for all users until the period or year is reopened. `future`: the accounting system reports the period as not yet opened. Null or absent means the connector does not expose the period's status. */ status?: FiscalPeriodStatus | null | undefined; /** * The last date in the period on which the accounting system's lock date rejects postings for at least some users: the lock date itself, or the period's end date when the lock date is later. Null when no lock date reaches the period or the connector does not expose lock dates. */ lockedThrough?: Date | null | undefined; /** * Whether this record is a posting period, or a quarter or year that groups posting periods. */ type?: FiscalPeriodPeriodType | null | undefined; /** * Whether the period is an adjustment (closing) period used for year-end entries rather than regular postings. */ isAdjustment?: boolean | null | undefined; /** * The date and time when the object was created. */ createdAt?: Date | null | undefined; /** * The date and time when the object was last updated. */ updatedAt?: Date | null | undefined; /** * When custom mappings are configured on the resource, the result is included here. */ customMappings?: { [k: string]: any } | null | undefined; }; /** @internal */ export const FiscalPeriodStatus$inboundSchema: z.ZodType< FiscalPeriodStatus, z.ZodTypeDef, unknown > = /* @__PURE__ */ lazySchema$(() => openEnums.inboundSchema(FiscalPeriodStatus) ); /** @internal */ export const FiscalPeriodPeriodType$inboundSchema: z.ZodType< FiscalPeriodPeriodType, z.ZodTypeDef, unknown > = /* @__PURE__ */ lazySchema$(() => openEnums.inboundSchema(FiscalPeriodPeriodType) ); /** @internal */ export const FiscalPeriod$inboundSchema: z.ZodType< FiscalPeriod, z.ZodTypeDef, unknown > = /* @__PURE__ */ lazySchema$(() => z.object({ id: types.optional(types.string()), name: z.nullable(types.string()).optional(), fiscal_year: z.nullable(types.string()).optional(), period_number: z.nullable(types.number()).optional(), start_date: z.nullable(types.date()).optional(), end_date: z.nullable(types.date()).optional(), status: z.nullable(FiscalPeriodStatus$inboundSchema).optional(), locked_through: z.nullable(types.date()).optional(), type: z.nullable(FiscalPeriodPeriodType$inboundSchema).optional(), is_adjustment: z.nullable(types.boolean()).optional(), created_at: z.nullable(types.date()).optional(), updated_at: z.nullable(types.date()).optional(), custom_mappings: z.nullable(z.record(z.any())).optional(), }).transform((v) => { return remap$(v, { "fiscal_year": "fiscalYear", "period_number": "periodNumber", "start_date": "startDate", "end_date": "endDate", "locked_through": "lockedThrough", "is_adjustment": "isAdjustment", "created_at": "createdAt", "updated_at": "updatedAt", "custom_mappings": "customMappings", }); }) ); export function fiscalPeriodFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => FiscalPeriod$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'FiscalPeriod' from JSON`, ); }