/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod"; import { remap as remap$ } from "../../lib/primitives.js"; import { safeParse } from "../../lib/schemas.js"; import { Result as SafeParseResult } from "../../types/fp.js"; import { SDKValidationError } from "../errors/sdkvalidationerror.js"; import { Currency, Currency$inboundSchema, Currency$outboundSchema, } from "./currency.js"; import { CustomMappings, CustomMappings$inboundSchema, CustomMappings$Outbound, CustomMappings$outboundSchema, } from "./custommappings.js"; import { JournalEntryLineItem, JournalEntryLineItem$inboundSchema, JournalEntryLineItem$Outbound, JournalEntryLineItem$outboundSchema, } from "./journalentrylineitem.js"; import { LinkedTrackingCategory, LinkedTrackingCategory$inboundSchema, LinkedTrackingCategory$Outbound, LinkedTrackingCategory$outboundSchema, } from "./linkedtrackingcategory.js"; import { PassThroughBody, PassThroughBody$inboundSchema, PassThroughBody$Outbound, PassThroughBody$outboundSchema, } from "./passthroughbody.js"; export type JournalEntry = { /** * A unique identifier for an object. */ id?: string | undefined; /** * Journal entry title */ title?: string | null | undefined; /** * Currency Exchange Rate at the time entity was recorded/generated. */ currencyRate?: number | null | undefined; /** * Indicates the associated currency for an amount of money. Values correspond to [ISO 4217](https://en.wikipedia.org/wiki/ISO_4217). */ currency?: Currency | null | undefined; /** * The company or subsidiary id the transaction belongs to */ companyId?: string | null | undefined; /** * Requires a minimum of 2 line items that sum to 0 */ lineItems?: Array | undefined; /** * Reference for the journal entry. */ memo?: string | null | undefined; /** * This is the date on which the journal entry was added. This can be different from the creation date and can also be backdated. */ postedAt?: Date | undefined; /** * Journal symbol of the entry. For example IND for indirect costs */ journalSymbol?: string | null | undefined; /** * The specific category of tax associated with a transaction like sales or purchase */ taxType?: string | null | undefined; /** * Applicable tax id/code override if tax is not supplied on a line item basis. */ taxCode?: string | null | undefined; /** * Journal entry number. */ number?: string | null | undefined; /** * A list of linked tracking categories. */ trackingCategories?: Array | null | undefined; /** * Accounting period */ accountingPeriod?: string | null | undefined; /** * When custom mappings are configured on the resource, the result is included here. */ customMappings?: CustomMappings | null | undefined; /** * The user who last updated the object. */ updatedBy?: string | null | undefined; /** * The user who created the object. */ createdBy?: string | null | undefined; /** * The date and time when the object was last updated. */ updatedAt?: Date | null | undefined; /** * The date and time when the object was created. */ createdAt?: Date | null | undefined; /** * A binary value used to detect updates to a object and prevent data conflicts. It is incremented each time an update is made to the object. */ rowVersion?: string | null | undefined; /** * The pass_through property allows passing service-specific, custom data or structured modifications in request body when creating or updating resources. */ passThrough?: Array | undefined; }; /** @internal */ export const JournalEntry$inboundSchema: z.ZodType< JournalEntry, z.ZodTypeDef, unknown > = z.object({ id: z.string().optional(), title: z.nullable(z.string()).optional(), currency_rate: z.nullable(z.number()).optional(), currency: z.nullable(Currency$inboundSchema).optional(), company_id: z.nullable(z.string()).optional(), line_items: z.array(JournalEntryLineItem$inboundSchema).optional(), memo: z.nullable(z.string()).optional(), posted_at: z.string().datetime({ offset: true }).transform(v => new Date(v)) .optional(), journal_symbol: z.nullable(z.string()).optional(), tax_type: z.nullable(z.string()).optional(), tax_code: z.nullable(z.string()).optional(), number: z.nullable(z.string()).optional(), tracking_categories: z.nullable(z.array(LinkedTrackingCategory$inboundSchema)) .optional(), accounting_period: z.nullable(z.string()).optional(), custom_mappings: z.nullable(CustomMappings$inboundSchema).optional(), updated_by: z.nullable(z.string()).optional(), created_by: z.nullable(z.string()).optional(), updated_at: z.nullable( z.string().datetime({ offset: true }).transform(v => new Date(v)), ).optional(), created_at: z.nullable( z.string().datetime({ offset: true }).transform(v => new Date(v)), ).optional(), row_version: z.nullable(z.string()).optional(), pass_through: z.array(PassThroughBody$inboundSchema).optional(), }).transform((v) => { return remap$(v, { "currency_rate": "currencyRate", "company_id": "companyId", "line_items": "lineItems", "posted_at": "postedAt", "journal_symbol": "journalSymbol", "tax_type": "taxType", "tax_code": "taxCode", "tracking_categories": "trackingCategories", "accounting_period": "accountingPeriod", "custom_mappings": "customMappings", "updated_by": "updatedBy", "created_by": "createdBy", "updated_at": "updatedAt", "created_at": "createdAt", "row_version": "rowVersion", "pass_through": "passThrough", }); }); /** @internal */ export type JournalEntry$Outbound = { id?: string | undefined; title?: string | null | undefined; currency_rate?: number | null | undefined; currency?: string | null | undefined; company_id?: string | null | undefined; line_items?: Array | undefined; memo?: string | null | undefined; posted_at?: string | undefined; journal_symbol?: string | null | undefined; tax_type?: string | null | undefined; tax_code?: string | null | undefined; number?: string | null | undefined; tracking_categories?: | Array | null | undefined; accounting_period?: string | null | undefined; custom_mappings?: CustomMappings$Outbound | null | undefined; updated_by?: string | null | undefined; created_by?: string | null | undefined; updated_at?: string | null | undefined; created_at?: string | null | undefined; row_version?: string | null | undefined; pass_through?: Array | undefined; }; /** @internal */ export const JournalEntry$outboundSchema: z.ZodType< JournalEntry$Outbound, z.ZodTypeDef, JournalEntry > = z.object({ id: z.string().optional(), title: z.nullable(z.string()).optional(), currencyRate: z.nullable(z.number()).optional(), currency: z.nullable(Currency$outboundSchema).optional(), companyId: z.nullable(z.string()).optional(), lineItems: z.array(JournalEntryLineItem$outboundSchema).optional(), memo: z.nullable(z.string()).optional(), postedAt: z.date().transform(v => v.toISOString()).optional(), journalSymbol: z.nullable(z.string()).optional(), taxType: z.nullable(z.string()).optional(), taxCode: z.nullable(z.string()).optional(), number: z.nullable(z.string()).optional(), trackingCategories: z.nullable(z.array(LinkedTrackingCategory$outboundSchema)) .optional(), accountingPeriod: z.nullable(z.string()).optional(), customMappings: z.nullable(CustomMappings$outboundSchema).optional(), updatedBy: z.nullable(z.string()).optional(), createdBy: z.nullable(z.string()).optional(), updatedAt: z.nullable(z.date().transform(v => v.toISOString())).optional(), createdAt: z.nullable(z.date().transform(v => v.toISOString())).optional(), rowVersion: z.nullable(z.string()).optional(), passThrough: z.array(PassThroughBody$outboundSchema).optional(), }).transform((v) => { return remap$(v, { currencyRate: "currency_rate", companyId: "company_id", lineItems: "line_items", postedAt: "posted_at", journalSymbol: "journal_symbol", taxType: "tax_type", taxCode: "tax_code", trackingCategories: "tracking_categories", accountingPeriod: "accounting_period", customMappings: "custom_mappings", updatedBy: "updated_by", createdBy: "created_by", updatedAt: "updated_at", createdAt: "created_at", rowVersion: "row_version", passThrough: "pass_through", }); }); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace JournalEntry$ { /** @deprecated use `JournalEntry$inboundSchema` instead. */ export const inboundSchema = JournalEntry$inboundSchema; /** @deprecated use `JournalEntry$outboundSchema` instead. */ export const outboundSchema = JournalEntry$outboundSchema; /** @deprecated use `JournalEntry$Outbound` instead. */ export type Outbound = JournalEntry$Outbound; } export function journalEntryToJSON(journalEntry: JournalEntry): string { return JSON.stringify(JournalEntry$outboundSchema.parse(journalEntry)); } export function journalEntryFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => JournalEntry$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'JournalEntry' from JSON`, ); }