/* * 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 { LinkedFinancialAccount, LinkedFinancialAccount$inboundSchema, LinkedFinancialAccountInput, LinkedFinancialAccountInput$Outbound, LinkedFinancialAccountInput$outboundSchema, } from "./linkedfinancialaccount.js"; /** * Normalized journal classification. */ export const JournalType = { General: "general", Sales: "sales", Purchase: "purchase", SalesCreditNote: "sales_credit_note", PurchaseCreditNote: "purchase_credit_note", Cash: "cash", Bank: "bank", PaymentService: "payment_service", Other: "other", } as const; /** * Normalized journal classification. */ export type JournalType = OpenEnum; export type Journal = { /** * A unique identifier for an object. */ id?: string | undefined; /** * Code used to select this journal when posting entries. For Exact Online, pass this code as journal_symbol, not the journal id. */ code?: string | null | undefined; /** * Name of the journal. */ name?: string | null | undefined; /** * Description of the journal. */ description?: string | null | undefined; /** * Normalized journal classification. */ type?: JournalType | null | undefined; /** * Whether the journal permits VAT on entries. Null or absent means unknown. Exact Online exposes this setting for general journals; it must not be treated as a universal VAT capability flag for other journal types. */ allowVat?: boolean | 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; /** * International Bank Account Number */ iban?: string | null | undefined; /** * A flexible account reference that can represent a ledger account (GL account), a bank account, or an employee payable account, depending on the connector's requirements. */ defaultAccount?: LinkedFinancialAccount | null | undefined; /** * A flexible account reference that can represent a ledger account (GL account), a bank account, or an employee payable account, depending on the connector's requirements. */ clearingAccount?: LinkedFinancialAccount | null | undefined; /** * Whether the journal is blocked for posting. */ blocked?: 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; }; export type JournalInput = { /** * Code used to select this journal when posting entries. For Exact Online, pass this code as journal_symbol, not the journal id. */ code?: string | null | undefined; /** * Name of the journal. */ name?: string | null | undefined; /** * Description of the journal. */ description?: string | null | undefined; /** * Normalized journal classification. */ type?: JournalType | null | undefined; /** * Whether the journal permits VAT on entries. Null or absent means unknown. Exact Online exposes this setting for general journals; it must not be treated as a universal VAT capability flag for other journal types. */ allowVat?: boolean | 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; /** * International Bank Account Number */ iban?: string | null | undefined; /** * A flexible account reference that can represent a ledger account (GL account), a bank account, or an employee payable account, depending on the connector's requirements. */ defaultAccount?: LinkedFinancialAccountInput | null | undefined; /** * A flexible account reference that can represent a ledger account (GL account), a bank account, or an employee payable account, depending on the connector's requirements. */ clearingAccount?: LinkedFinancialAccountInput | null | undefined; /** * Whether the journal is blocked for posting. */ blocked?: boolean | null | undefined; }; /** @internal */ export const JournalType$inboundSchema: z.ZodType< JournalType, z.ZodTypeDef, unknown > = /* @__PURE__ */ lazySchema$(() => openEnums.inboundSchema(JournalType)); /** @internal */ export const JournalType$outboundSchema: z.ZodType< string, z.ZodTypeDef, JournalType > = /* @__PURE__ */ lazySchema$(() => openEnums.outboundSchema(JournalType)); /** @internal */ export const Journal$inboundSchema: z.ZodType = /* @__PURE__ */ lazySchema$(() => z.object({ id: types.optional(types.string()), code: z.nullable(types.string()).optional(), name: z.nullable(types.string()).optional(), description: z.nullable(types.string()).optional(), type: z.nullable(JournalType$inboundSchema).optional(), allow_vat: z.nullable(types.boolean()).optional(), currency: z.nullable(Currency$inboundSchema).optional(), iban: z.nullable(types.string()).optional(), default_account: z.nullable(LinkedFinancialAccount$inboundSchema) .optional(), clearing_account: z.nullable(LinkedFinancialAccount$inboundSchema) .optional(), blocked: 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, { "allow_vat": "allowVat", "default_account": "defaultAccount", "clearing_account": "clearingAccount", "created_at": "createdAt", "updated_at": "updatedAt", "custom_mappings": "customMappings", }); }) ); export function journalFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Journal$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Journal' from JSON`, ); } /** @internal */ export type JournalInput$Outbound = { code?: string | null | undefined; name?: string | null | undefined; description?: string | null | undefined; type?: string | null | undefined; allow_vat?: boolean | null | undefined; currency?: string | null | undefined; iban?: string | null | undefined; default_account?: LinkedFinancialAccountInput$Outbound | null | undefined; clearing_account?: LinkedFinancialAccountInput$Outbound | null | undefined; blocked?: boolean | null | undefined; }; /** @internal */ export const JournalInput$outboundSchema: z.ZodType< JournalInput$Outbound, z.ZodTypeDef, JournalInput > = /* @__PURE__ */ lazySchema$(() => z.object({ code: z.nullable(z.string()).optional(), name: z.nullable(z.string()).optional(), description: z.nullable(z.string()).optional(), type: z.nullable(JournalType$outboundSchema).optional(), allowVat: z.nullable(z.boolean()).optional(), currency: z.nullable(Currency$outboundSchema).optional(), iban: z.nullable(z.string()).optional(), defaultAccount: z.nullable(LinkedFinancialAccountInput$outboundSchema) .optional(), clearingAccount: z.nullable(LinkedFinancialAccountInput$outboundSchema) .optional(), blocked: z.nullable(z.boolean()).optional(), }).transform((v) => { return remap$(v, { allowVat: "allow_vat", defaultAccount: "default_account", clearingAccount: "clearing_account", }); }) ); export function journalInputToJSON(journalInput: JournalInput): string { return JSON.stringify(JournalInput$outboundSchema.parse(journalInput)); }