/* * 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 { BankAccount, BankAccount$inboundSchema, BankAccount$Outbound, BankAccount$outboundSchema, } from "./bankaccount.js"; import { Currency, Currency$inboundSchema, Currency$outboundSchema, } from "./currency.js"; import { CustomField, CustomField$inboundSchema, CustomField$Outbound, CustomField$outboundSchema, } from "./customfield.js"; import { LinkedTaxRate, LinkedTaxRate$inboundSchema } from "./linkedtaxrate.js"; import { LinkedTaxRateInput, LinkedTaxRateInput$Outbound, LinkedTaxRateInput$outboundSchema, } from "./linkedtaxrateinput.js"; import { PassThroughBody, PassThroughBody$inboundSchema, PassThroughBody$Outbound, PassThroughBody$outboundSchema, } from "./passthroughbody.js"; /** * The classification of account. */ export const LedgerAccountClassification = { Asset: "asset", Equity: "equity", Expense: "expense", Liability: "liability", Revenue: "revenue", Income: "income", OtherIncome: "other_income", OtherExpense: "other_expense", CostsOfSales: "costs_of_sales", Other: "other", } as const; /** * The classification of account. */ export type LedgerAccountClassification = OpenEnum< typeof LedgerAccountClassification >; /** * The type of account. */ export const LedgerAccountType = { AccountsPayable: "accounts_payable", AccountsReceivable: "accounts_receivable", Balancesheet: "balancesheet", Bank: "bank", CostsOfSales: "costs_of_sales", CreditCard: "credit_card", CurrentAsset: "current_asset", CurrentLiability: "current_liability", Equity: "equity", Expense: "expense", FixedAsset: "fixed_asset", NonCurrentAsset: "non_current_asset", NonCurrentLiability: "non_current_liability", OtherAsset: "other_asset", OtherExpense: "other_expense", OtherIncome: "other_income", OtherLiability: "other_liability", Revenue: "revenue", Sales: "sales", Other: "other", } as const; /** * The type of account. */ export type LedgerAccountType = OpenEnum; /** * The depreciation method of the assets, normalised across accounting systems: declining-balance variants (for example 150% or 200%) are all `declining_balance`, and the accounting system's own value is in `downstream_depreciation_method`. Set only when every asset recorded in the account uses the same method. */ export const DepreciationMethod = { Other: "other", StraightLine: "straight_line", DecliningBalance: "declining_balance", None: "none", } as const; /** * The depreciation method of the assets, normalised across accounting systems: declining-balance variants (for example 150% or 200%) are all `declining_balance`, and the accounting system's own value is in `downstream_depreciation_method`. Set only when every asset recorded in the account uses the same method. */ export type DepreciationMethod = OpenEnum; /** * For an account that holds the cost of fixed assets, the fixed-asset register's figures for the assets recorded in it. Null for other accounts, including accumulated-depreciation accounts, and when the accounting system does not provide them. */ export type FixedAsset = { /** * The total cost of the fixed assets recorded in the account. */ cost?: number | null | undefined; /** * The depreciation accumulated so far on the fixed assets recorded in the account, as a positive amount. */ accumulatedDepreciation?: number | null | undefined; /** * The date the assets were purchased - YYYY-MM-DD. Set only when every asset recorded in the account shares the same date. */ acquisitionDate?: Date | null | undefined; /** * The depreciation method of the assets, normalised across accounting systems: declining-balance variants (for example 150% or 200%) are all `declining_balance`, and the accounting system's own value is in `downstream_depreciation_method`. Set only when every asset recorded in the account uses the same method. */ depreciationMethod?: DepreciationMethod | null | undefined; /** * The depreciation method exactly as the accounting system names it, under the same condition as `depreciation_method`. */ downstreamDepreciationMethod?: string | null | undefined; /** * The useful life of the assets, in months. Set only when every asset recorded in the account has the same useful life. */ usefulLifeMonths?: number | null | undefined; }; /** * The status of the account. */ export const AccountStatus = { Active: "active", Inactive: "inactive", Archived: "archived", } as const; /** * The status of the account. */ export type AccountStatus = OpenEnum; export type Categories = { id?: string | undefined; /** * The name of the category. */ name?: string | undefined; }; export type ParentAccount = { /** * The ID of the parent account. */ id?: string | undefined; /** * The name of the parent account. */ name?: string | undefined; /** * The human readable display ID used when displaying the parent account */ displayId?: string | undefined; }; export type SubAccounts = { /** * The ID of the sub account. */ id?: string | undefined; /** * The name of the sub account. */ accountSubName?: string | undefined; }; export type LedgerAccountSubsidiaries = { /** * The ID of the subsidiary. */ id?: string | undefined; }; export type LedgerAccount = { /** * A unique identifier for an object. */ id?: string | undefined; /** * The human readable display ID used when displaying the account */ displayId?: string | undefined; /** * The nominal code of the ledger account. * * @deprecated field: This field is deprecated and may be removed in a future version.. */ nominalCode?: string | null | undefined; /** * The code assigned to the account. */ code?: string | null | undefined; /** * The classification of account. */ classification?: LedgerAccountClassification | null | undefined; /** * The type of account. */ type?: LedgerAccountType | undefined; /** * The sub type of account. */ subType?: string | null | undefined; /** * The name of the account. */ name?: string | null | undefined; /** * The fully qualified name of the account. */ fullyQualifiedName?: string | null | undefined; /** * The description of the account. */ description?: string | null | undefined; /** * The opening balance of the account. */ openingBalance?: number | null | undefined; /** * The current balance of the account. */ currentBalance?: number | null | undefined; /** * For an account that holds the cost of fixed assets, the fixed-asset register's figures for the assets recorded in it. Null for other accounts, including accumulated-depreciation accounts, and when the accounting system does not provide them. */ fixedAsset?: FixedAsset | 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 tax type of the account. */ taxType?: string | null | undefined; taxRate?: LinkedTaxRate | undefined; level?: number | null | undefined; /** * Whether the account is active or not. */ active?: boolean | null | undefined; /** * The status of the account. */ status?: AccountStatus | null | undefined; /** * Whether the account is a header or not. */ header?: boolean | null | undefined; bankAccount?: BankAccount | undefined; /** * The categories of the account. */ categories?: Array | undefined; parentAccount?: ParentAccount | undefined; /** * Whether the account is a sub account or not. */ subAccount?: boolean | null | undefined; /** * The sub accounts of the account. */ subAccounts?: Array | undefined; /** * Reconciliation Date means the last calendar day of each Reconciliation Period. */ lastReconciliationDate?: Date | null | undefined; /** * The subsidiaries the account belongs to. */ subsidiaries?: Array | undefined; /** * When custom mappings are configured on the resource, the result is included here. */ customMappings?: { [k: string]: any } | null | undefined; customFields?: Array | 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 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; /** * 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 LedgerAccountInput = { /** * The human readable display ID used when displaying the account */ displayId?: string | undefined; /** * The nominal code of the ledger account. * * @deprecated field: This field is deprecated and may be removed in a future version.. */ nominalCode?: string | null | undefined; /** * The code assigned to the account. */ code?: string | null | undefined; /** * The classification of account. */ classification?: LedgerAccountClassification | null | undefined; /** * The type of account. */ type?: LedgerAccountType | undefined; /** * The sub type of account. */ subType?: string | null | undefined; /** * The name of the account. */ name?: string | null | undefined; /** * The fully qualified name of the account. */ fullyQualifiedName?: string | null | undefined; /** * The description of the account. */ description?: string | null | undefined; /** * The opening balance of the account. */ openingBalance?: number | null | undefined; /** * The current balance of the account. */ currentBalance?: 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 tax type of the account. */ taxType?: string | null | undefined; taxRate?: LinkedTaxRateInput | undefined; level?: number | null | undefined; /** * Whether the account is active or not. */ active?: boolean | null | undefined; /** * The status of the account. */ status?: AccountStatus | null | undefined; /** * Whether the account is a header or not. */ header?: boolean | null | undefined; bankAccount?: BankAccount | undefined; parentAccount?: ParentAccount | undefined; /** * Whether the account is a sub account or not. */ subAccount?: boolean | null | undefined; /** * Reconciliation Date means the last calendar day of each Reconciliation Period. */ lastReconciliationDate?: Date | null | undefined; /** * The subsidiaries the account belongs to. */ subsidiaries?: Array | undefined; customFields?: Array | 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 LedgerAccountClassification$inboundSchema: z.ZodType< LedgerAccountClassification, z.ZodTypeDef, unknown > = /* @__PURE__ */ lazySchema$(() => openEnums.inboundSchema(LedgerAccountClassification) ); /** @internal */ export const LedgerAccountClassification$outboundSchema: z.ZodType< string, z.ZodTypeDef, LedgerAccountClassification > = /* @__PURE__ */ lazySchema$(() => openEnums.outboundSchema(LedgerAccountClassification) ); /** @internal */ export const LedgerAccountType$inboundSchema: z.ZodType< LedgerAccountType, z.ZodTypeDef, unknown > = /* @__PURE__ */ lazySchema$(() => openEnums.inboundSchema(LedgerAccountType) ); /** @internal */ export const LedgerAccountType$outboundSchema: z.ZodType< string, z.ZodTypeDef, LedgerAccountType > = /* @__PURE__ */ lazySchema$(() => openEnums.outboundSchema(LedgerAccountType) ); /** @internal */ export const DepreciationMethod$inboundSchema: z.ZodType< DepreciationMethod, z.ZodTypeDef, unknown > = /* @__PURE__ */ lazySchema$(() => openEnums.inboundSchema(DepreciationMethod) ); /** @internal */ export const FixedAsset$inboundSchema: z.ZodType< FixedAsset, z.ZodTypeDef, unknown > = /* @__PURE__ */ lazySchema$(() => z.object({ cost: z.nullable(types.number()).optional(), accumulated_depreciation: z.nullable(types.number()).optional(), acquisition_date: z.nullable(types.date()).optional(), depreciation_method: z.nullable(DepreciationMethod$inboundSchema) .optional(), downstream_depreciation_method: z.nullable(types.string()).optional(), useful_life_months: z.nullable(types.number()).optional(), }).transform((v) => { return remap$(v, { "accumulated_depreciation": "accumulatedDepreciation", "acquisition_date": "acquisitionDate", "depreciation_method": "depreciationMethod", "downstream_depreciation_method": "downstreamDepreciationMethod", "useful_life_months": "usefulLifeMonths", }); }) ); export function fixedAssetFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => FixedAsset$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'FixedAsset' from JSON`, ); } /** @internal */ export const AccountStatus$inboundSchema: z.ZodType< AccountStatus, z.ZodTypeDef, unknown > = /* @__PURE__ */ lazySchema$(() => openEnums.inboundSchema(AccountStatus)); /** @internal */ export const AccountStatus$outboundSchema: z.ZodType< string, z.ZodTypeDef, AccountStatus > = /* @__PURE__ */ lazySchema$(() => openEnums.outboundSchema(AccountStatus)); /** @internal */ export const Categories$inboundSchema: z.ZodType< Categories, z.ZodTypeDef, unknown > = /* @__PURE__ */ lazySchema$(() => z.object({ id: types.optional(types.string()), name: types.optional(types.string()), }) ); export function categoriesFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Categories$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Categories' from JSON`, ); } /** @internal */ export const ParentAccount$inboundSchema: z.ZodType< ParentAccount, z.ZodTypeDef, unknown > = /* @__PURE__ */ lazySchema$(() => z.object({ id: types.optional(types.string()), name: types.optional(types.string()), display_id: types.optional(types.string()), }).transform((v) => { return remap$(v, { "display_id": "displayId", }); }) ); /** @internal */ export type ParentAccount$Outbound = { id?: string | undefined; name?: string | undefined; display_id?: string | undefined; }; /** @internal */ export const ParentAccount$outboundSchema: z.ZodType< ParentAccount$Outbound, z.ZodTypeDef, ParentAccount > = /* @__PURE__ */ lazySchema$(() => z.object({ id: z.string().optional(), name: z.string().optional(), displayId: z.string().optional(), }).transform((v) => { return remap$(v, { displayId: "display_id", }); }) ); export function parentAccountToJSON(parentAccount: ParentAccount): string { return JSON.stringify(ParentAccount$outboundSchema.parse(parentAccount)); } export function parentAccountFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => ParentAccount$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'ParentAccount' from JSON`, ); } /** @internal */ export const SubAccounts$inboundSchema: z.ZodType< SubAccounts, z.ZodTypeDef, unknown > = /* @__PURE__ */ lazySchema$(() => z.object({ id: types.optional(types.string()), account_sub_name: types.optional(types.string()), }).transform((v) => { return remap$(v, { "account_sub_name": "accountSubName", }); }) ); export function subAccountsFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => SubAccounts$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'SubAccounts' from JSON`, ); } /** @internal */ export const LedgerAccountSubsidiaries$inboundSchema: z.ZodType< LedgerAccountSubsidiaries, z.ZodTypeDef, unknown > = /* @__PURE__ */ lazySchema$(() => z.object({ id: types.optional(types.string()), }) ); /** @internal */ export type LedgerAccountSubsidiaries$Outbound = { id?: string | undefined; }; /** @internal */ export const LedgerAccountSubsidiaries$outboundSchema: z.ZodType< LedgerAccountSubsidiaries$Outbound, z.ZodTypeDef, LedgerAccountSubsidiaries > = /* @__PURE__ */ lazySchema$(() => z.object({ id: z.string().optional(), }) ); export function ledgerAccountSubsidiariesToJSON( ledgerAccountSubsidiaries: LedgerAccountSubsidiaries, ): string { return JSON.stringify( LedgerAccountSubsidiaries$outboundSchema.parse(ledgerAccountSubsidiaries), ); } export function ledgerAccountSubsidiariesFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => LedgerAccountSubsidiaries$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'LedgerAccountSubsidiaries' from JSON`, ); } /** @internal */ export const LedgerAccount$inboundSchema: z.ZodType< LedgerAccount, z.ZodTypeDef, unknown > = /* @__PURE__ */ lazySchema$(() => z.object({ id: types.optional(types.string()), display_id: types.optional(types.string()), nominal_code: z.nullable(types.string()).optional(), code: z.nullable(types.string()).optional(), classification: z.nullable(LedgerAccountClassification$inboundSchema) .optional(), type: types.optional(LedgerAccountType$inboundSchema), sub_type: z.nullable(types.string()).optional(), name: z.nullable(types.string()).optional(), fully_qualified_name: z.nullable(types.string()).optional(), description: z.nullable(types.string()).optional(), opening_balance: z.nullable(types.number()).optional(), current_balance: z.nullable(types.number()).optional(), fixed_asset: z.nullable(z.lazy(() => FixedAsset$inboundSchema)).optional(), currency: z.nullable(Currency$inboundSchema).optional(), tax_type: z.nullable(types.string()).optional(), tax_rate: types.optional(LinkedTaxRate$inboundSchema), level: z.nullable(types.number()).optional(), active: z.nullable(types.boolean()).optional(), status: z.nullable(AccountStatus$inboundSchema).optional(), header: z.nullable(types.boolean()).optional(), bank_account: types.optional(BankAccount$inboundSchema), categories: types.optional(z.array(z.lazy(() => Categories$inboundSchema))), parent_account: types.optional(z.lazy(() => ParentAccount$inboundSchema)), sub_account: z.nullable(types.boolean()).optional(), sub_accounts: types.optional( z.array(z.lazy(() => SubAccounts$inboundSchema)), ), last_reconciliation_date: z.nullable(types.date()).optional(), subsidiaries: types.optional( z.array(z.lazy(() => LedgerAccountSubsidiaries$inboundSchema)), ), custom_mappings: z.nullable(z.record(z.any())).optional(), custom_fields: types.optional(z.array(CustomField$inboundSchema)), row_version: z.nullable(types.string()).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(), pass_through: types.optional(z.array(PassThroughBody$inboundSchema)), }).transform((v) => { return remap$(v, { "display_id": "displayId", "nominal_code": "nominalCode", "sub_type": "subType", "fully_qualified_name": "fullyQualifiedName", "opening_balance": "openingBalance", "current_balance": "currentBalance", "fixed_asset": "fixedAsset", "tax_type": "taxType", "tax_rate": "taxRate", "bank_account": "bankAccount", "parent_account": "parentAccount", "sub_account": "subAccount", "sub_accounts": "subAccounts", "last_reconciliation_date": "lastReconciliationDate", "custom_mappings": "customMappings", "custom_fields": "customFields", "row_version": "rowVersion", "updated_by": "updatedBy", "created_by": "createdBy", "updated_at": "updatedAt", "created_at": "createdAt", "pass_through": "passThrough", }); }) ); export function ledgerAccountFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => LedgerAccount$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'LedgerAccount' from JSON`, ); } /** @internal */ export type LedgerAccountInput$Outbound = { display_id?: string | undefined; nominal_code?: string | null | undefined; code?: string | null | undefined; classification?: string | null | undefined; type?: string | undefined; sub_type?: string | null | undefined; name?: string | null | undefined; fully_qualified_name?: string | null | undefined; description?: string | null | undefined; opening_balance?: number | null | undefined; current_balance?: number | null | undefined; currency?: string | null | undefined; tax_type?: string | null | undefined; tax_rate?: LinkedTaxRateInput$Outbound | undefined; level?: number | null | undefined; active?: boolean | null | undefined; status?: string | null | undefined; header?: boolean | null | undefined; bank_account?: BankAccount$Outbound | undefined; parent_account?: ParentAccount$Outbound | undefined; sub_account?: boolean | null | undefined; last_reconciliation_date?: string | null | undefined; subsidiaries?: Array | undefined; custom_fields?: Array | undefined; row_version?: string | null | undefined; pass_through?: Array | undefined; }; /** @internal */ export const LedgerAccountInput$outboundSchema: z.ZodType< LedgerAccountInput$Outbound, z.ZodTypeDef, LedgerAccountInput > = /* @__PURE__ */ lazySchema$(() => z.object({ displayId: z.string().optional(), nominalCode: z.nullable(z.string()).optional(), code: z.nullable(z.string()).optional(), classification: z.nullable(LedgerAccountClassification$outboundSchema) .optional(), type: LedgerAccountType$outboundSchema.optional(), subType: z.nullable(z.string()).optional(), name: z.nullable(z.string()).optional(), fullyQualifiedName: z.nullable(z.string()).optional(), description: z.nullable(z.string()).optional(), openingBalance: z.nullable(z.number()).optional(), currentBalance: z.nullable(z.number()).optional(), currency: z.nullable(Currency$outboundSchema).optional(), taxType: z.nullable(z.string()).optional(), taxRate: LinkedTaxRateInput$outboundSchema.optional(), level: z.nullable(z.number()).optional(), active: z.nullable(z.boolean()).optional(), status: z.nullable(AccountStatus$outboundSchema).optional(), header: z.nullable(z.boolean()).optional(), bankAccount: BankAccount$outboundSchema.optional(), parentAccount: z.lazy(() => ParentAccount$outboundSchema).optional(), subAccount: z.nullable(z.boolean()).optional(), lastReconciliationDate: z.nullable( z.date().transform(v => v.toISOString().slice(0, "YYYY-MM-DD".length)), ).optional(), subsidiaries: z.array( z.lazy(() => LedgerAccountSubsidiaries$outboundSchema), ).optional(), customFields: z.array(CustomField$outboundSchema).optional(), rowVersion: z.nullable(z.string()).optional(), passThrough: z.array(PassThroughBody$outboundSchema).optional(), }).transform((v) => { return remap$(v, { displayId: "display_id", nominalCode: "nominal_code", subType: "sub_type", fullyQualifiedName: "fully_qualified_name", openingBalance: "opening_balance", currentBalance: "current_balance", taxType: "tax_type", taxRate: "tax_rate", bankAccount: "bank_account", parentAccount: "parent_account", subAccount: "sub_account", lastReconciliationDate: "last_reconciliation_date", customFields: "custom_fields", rowVersion: "row_version", passThrough: "pass_through", }); }) ); export function ledgerAccountInputToJSON( ledgerAccountInput: LedgerAccountInput, ): string { return JSON.stringify( LedgerAccountInput$outboundSchema.parse(ledgerAccountInput), ); }