/* * 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"; import { Currency, Currency$inboundSchema, Currency$outboundSchema, } from "./currency.js"; import { CustomField, CustomField$inboundSchema, CustomField$Outbound, CustomField$outboundSchema, } from "./customfield.js"; import { JournalEntryLineItem, JournalEntryLineItem$inboundSchema, JournalEntryLineItemInput, JournalEntryLineItemInput$Outbound, JournalEntryLineItemInput$outboundSchema, } from "./journalentrylineitem.js"; import { LinkedAttachment, LinkedAttachment$inboundSchema, LinkedAttachment$Outbound, LinkedAttachment$outboundSchema, } from "./linkedattachment.js"; import { LinkedSubsidiary, LinkedSubsidiary$inboundSchema, } from "./linkedsubsidiary.js"; import { LinkedSubsidiaryInput, LinkedSubsidiaryInput$Outbound, LinkedSubsidiaryInput$outboundSchema, } from "./linkedsubsidiaryinput.js"; import { LinkedTrackingCategory, LinkedTrackingCategory$inboundSchema, LinkedTrackingCategory$Outbound, LinkedTrackingCategory$outboundSchema, } from "./linkedtrackingcategory.js"; import { PassThroughBody, PassThroughBody$inboundSchema, PassThroughBody$Outbound, PassThroughBody$outboundSchema, } from "./passthroughbody.js"; /** * Journal entry status */ export const JournalEntryStatus = { Draft: "draft", PendingApproval: "pending_approval", Approved: "approved", Posted: "posted", Voided: "voided", Rejected: "rejected", Deleted: "deleted", Other: "other", } as const; /** * Journal entry status */ export type JournalEntryStatus = OpenEnum; export type JournalEntry = { /** * A unique identifier for an object. */ id?: string | undefined; /** * The third-party API ID of original entity */ downstreamId?: string | null | undefined; /** * Display ID of the journal entry */ displayId?: string | null | 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 ID the transaction belongs to */ companyId?: string | null | undefined; subsidiary?: LinkedSubsidiary | null | undefined; /** * Requires a minimum of 2 line items that sum to 0 */ lineItems?: Array | undefined; /** * Journal entry status */ status?: JournalEntryStatus | null | 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. Where supported, list /accounting/journals to discover available journals and their posting rules. For Exact Online, supply the journal code, not its id. */ journalSymbol?: string | null | undefined; /** * Deprecated — use line_items[].tax_type for per-line tax applicability. Kept as fallback: applies to all lines that do not set their own tax_type. * * @deprecated field: Deprecated — use line_items[].. */ 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; /** * Amounts are including tax */ taxInclusive?: boolean | null | undefined; /** * Files attached to this journal entry. Use the attachments endpoints with reference_type=journal-entry and this entry's id where the connector supports it. */ attachments?: Array | undefined; /** * The source type of the journal entry */ sourceType?: string | null | undefined; /** * A unique identifier for the source of the journal entry */ sourceId?: string | null | undefined; /** * When custom mappings are configured on the resource, the result is included here. */ customMappings?: { [k: string]: any } | 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; customFields?: Array | 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; }; export type JournalEntryInput = { /** * Display ID of the journal entry */ displayId?: string | null | 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 ID the transaction belongs to */ companyId?: string | null | undefined; subsidiary?: LinkedSubsidiaryInput | null | undefined; /** * Requires a minimum of 2 line items that sum to 0 */ lineItems?: Array | undefined; /** * Journal entry status */ status?: JournalEntryStatus | null | 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. Where supported, list /accounting/journals to discover available journals and their posting rules. For Exact Online, supply the journal code, not its id. */ journalSymbol?: string | null | undefined; /** * Deprecated — use line_items[].tax_type for per-line tax applicability. Kept as fallback: applies to all lines that do not set their own tax_type. * * @deprecated field: Deprecated — use line_items[].. */ 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; /** * Amounts are including tax */ taxInclusive?: boolean | null | undefined; /** * Files attached to this journal entry. Use the attachments endpoints with reference_type=journal-entry and this entry's id where the connector supports it. */ attachments?: Array | undefined; /** * The source type of the journal entry */ sourceType?: string | null | undefined; /** * A unique identifier for the source of the journal entry */ sourceId?: string | 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; customFields?: Array | 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 JournalEntryStatus$inboundSchema: z.ZodType< JournalEntryStatus, z.ZodTypeDef, unknown > = /* @__PURE__ */ lazySchema$(() => openEnums.inboundSchema(JournalEntryStatus) ); /** @internal */ export const JournalEntryStatus$outboundSchema: z.ZodType< string, z.ZodTypeDef, JournalEntryStatus > = /* @__PURE__ */ lazySchema$(() => openEnums.outboundSchema(JournalEntryStatus) ); /** @internal */ export const JournalEntry$inboundSchema: z.ZodType< JournalEntry, z.ZodTypeDef, unknown > = /* @__PURE__ */ lazySchema$(() => z.object({ id: types.optional(types.string()), downstream_id: z.nullable(types.string()).optional(), display_id: z.nullable(types.string()).optional(), title: z.nullable(types.string()).optional(), currency_rate: z.nullable(types.number()).optional(), currency: z.nullable(Currency$inboundSchema).optional(), company_id: z.nullable(types.string()).optional(), subsidiary: z.nullable(LinkedSubsidiary$inboundSchema).optional(), line_items: types.optional(z.array(JournalEntryLineItem$inboundSchema)), status: z.nullable(JournalEntryStatus$inboundSchema).optional(), memo: z.nullable(types.string()).optional(), posted_at: types.optional(types.date()), journal_symbol: z.nullable(types.string()).optional(), tax_type: z.nullable(types.string()).optional(), tax_code: z.nullable(types.string()).optional(), number: z.nullable(types.string()).optional(), tracking_categories: z.nullable( z.array(types.nullable(LinkedTrackingCategory$inboundSchema)), ).optional(), accounting_period: z.nullable(types.string()).optional(), tax_inclusive: z.nullable(types.boolean()).optional(), attachments: types.optional( z.array(types.nullable(LinkedAttachment$inboundSchema)), ), source_type: z.nullable(types.string()).optional(), source_id: z.nullable(types.string()).optional(), custom_mappings: z.nullable(z.record(z.any())).optional(), updated_by: z.nullable(types.string()).optional(), created_by: z.nullable(types.string()).optional(), updated_at: z.nullable(types.date()).optional(), created_at: z.nullable(types.date()).optional(), row_version: z.nullable(types.string()).optional(), custom_fields: types.optional(z.array(CustomField$inboundSchema)), pass_through: types.optional(z.array(PassThroughBody$inboundSchema)), }).transform((v) => { return remap$(v, { "downstream_id": "downstreamId", "display_id": "displayId", "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", "tax_inclusive": "taxInclusive", "source_type": "sourceType", "source_id": "sourceId", "custom_mappings": "customMappings", "updated_by": "updatedBy", "created_by": "createdBy", "updated_at": "updatedAt", "created_at": "createdAt", "row_version": "rowVersion", "custom_fields": "customFields", "pass_through": "passThrough", }); }) ); export function journalEntryFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => JournalEntry$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'JournalEntry' from JSON`, ); } /** @internal */ export type JournalEntryInput$Outbound = { display_id?: string | null | undefined; title?: string | null | undefined; currency_rate?: number | null | undefined; currency?: string | null | undefined; company_id?: string | null | undefined; subsidiary?: LinkedSubsidiaryInput$Outbound | null | undefined; line_items?: Array | undefined; status?: string | null | 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; tax_inclusive?: boolean | null | undefined; attachments?: Array | undefined; source_type?: string | null | undefined; source_id?: string | null | undefined; row_version?: string | null | undefined; custom_fields?: Array | undefined; pass_through?: Array | undefined; }; /** @internal */ export const JournalEntryInput$outboundSchema: z.ZodType< JournalEntryInput$Outbound, z.ZodTypeDef, JournalEntryInput > = /* @__PURE__ */ lazySchema$(() => z.object({ displayId: z.nullable(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(), subsidiary: z.nullable(LinkedSubsidiaryInput$outboundSchema).optional(), lineItems: z.array(JournalEntryLineItemInput$outboundSchema).optional(), status: z.nullable(JournalEntryStatus$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(z.nullable(LinkedTrackingCategory$outboundSchema)), ).optional(), accountingPeriod: z.nullable(z.string()).optional(), taxInclusive: z.nullable(z.boolean()).optional(), attachments: z.array(z.nullable(LinkedAttachment$outboundSchema)) .optional(), sourceType: z.nullable(z.string()).optional(), sourceId: z.nullable(z.string()).optional(), rowVersion: z.nullable(z.string()).optional(), customFields: z.array(CustomField$outboundSchema).optional(), passThrough: z.array(PassThroughBody$outboundSchema).optional(), }).transform((v) => { return remap$(v, { displayId: "display_id", 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", taxInclusive: "tax_inclusive", sourceType: "source_type", sourceId: "source_id", rowVersion: "row_version", customFields: "custom_fields", passThrough: "pass_through", }); }) ); export function journalEntryInputToJSON( journalEntryInput: JournalEntryInput, ): string { return JSON.stringify( JournalEntryInput$outboundSchema.parse(journalEntryInput), ); }