/* * 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 } from "./currency.js"; /** * `account`: a ledger account. `unappropriated_result`: the result of earlier fiscal years not yet posted to an equity account, added by the connector. `unmapped`: a balance the accounting system reports without a ledger account. */ export const LineType = { Account: "account", UnappropriatedResult: "unappropriated_result", Unmapped: "unmapped", } as const; /** * `account`: a ledger account. `unappropriated_result`: the result of earlier fiscal years not yet posted to an equity account, added by the connector. `unmapped`: a balance the accounting system reports without a ledger account. */ export type LineType = OpenEnum; export type Accounts = { /** * `account`: a ledger account. `unappropriated_result`: the result of earlier fiscal years not yet posted to an equity account, added by the connector. `unmapped`: a balance the accounting system reports without a ledger account. */ lineType?: LineType | undefined; /** * The ledger account's id, the same id `GET /accounting/ledger-accounts/{id}` takes. Null when `line_type` is not `account`, or when the connector cannot resolve the ledger account. */ accountId?: string | null | undefined; /** * The ledger account's code (account number). */ code?: string | null | undefined; /** * The ledger account's name. */ name?: string | null | undefined; /** * The account's balance when it is a debit balance, otherwise 0. */ debit: number; /** * The account's balance when it is a credit balance, otherwise 0. */ credit: number; /** * The signed balance: debit minus credit. */ balance?: number | null | undefined; }; /** * The balance of every ledger account as of a date, split into debit and credit columns. Balance sheet accounts are cumulative to `end_date`; income and expense accounts are year-to-date within the fiscal year that contains `end_date`. */ export type TrialBalance = { /** * The name of the report as returned by the connector. */ reportName?: string | null | undefined; /** * The date income and expense balances accumulate from: the start of the fiscal year containing `end_date`, unless the connector notes say otherwise. Null when the connector does not report it. */ startDate?: string | null | undefined; /** * The date the balances are reported as of. Connectors that only report per period round the requested date up to the end of its period; this field returns the date actually used. */ endDate: string; /** * 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; /** * One line per ledger account with a non-zero balance, plus any line the connector adds to make the report complete (see `line_type`). */ accounts: Array; /** * The sum of the debit column. */ totalDebit?: number | null | undefined; /** * The sum of the credit column. Equals total_debit, up to rounding of the individual lines: connectors return a 502 rather than a report whose debits and credits differ by half a cent or more. */ totalCredit?: number | null | undefined; /** * When custom mappings are configured on the resource, the result is included here. */ customMappings?: { [k: string]: any } | null | undefined; }; /** @internal */ export const LineType$inboundSchema: z.ZodType< LineType, z.ZodTypeDef, unknown > = /* @__PURE__ */ lazySchema$(() => openEnums.inboundSchema(LineType)); /** @internal */ export const Accounts$inboundSchema: z.ZodType< Accounts, z.ZodTypeDef, unknown > = /* @__PURE__ */ lazySchema$(() => z.object({ line_type: types.optional(LineType$inboundSchema), account_id: z.nullable(types.string()).optional(), code: z.nullable(types.string()).optional(), name: z.nullable(types.string()).optional(), debit: types.number(), credit: types.number(), balance: z.nullable(types.number()).optional(), }).transform((v) => { return remap$(v, { "line_type": "lineType", "account_id": "accountId", }); }) ); export function accountsFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Accounts$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Accounts' from JSON`, ); } /** @internal */ export const TrialBalance$inboundSchema: z.ZodType< TrialBalance, z.ZodTypeDef, unknown > = /* @__PURE__ */ lazySchema$(() => z.object({ report_name: z.nullable(types.string()).optional(), start_date: z.nullable(types.string()).optional(), end_date: types.string(), currency: z.nullable(Currency$inboundSchema).optional(), accounts: z.array(z.lazy(() => Accounts$inboundSchema)), total_debit: z.nullable(types.number()).optional(), total_credit: z.nullable(types.number()).optional(), custom_mappings: z.nullable(z.record(z.any())).optional(), }).transform((v) => { return remap$(v, { "report_name": "reportName", "start_date": "startDate", "end_date": "endDate", "total_debit": "totalDebit", "total_credit": "totalCredit", "custom_mappings": "customMappings", }); }) ); export function trialBalanceFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => TrialBalance$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'TrialBalance' from JSON`, ); }