/* * 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 { 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"; import { ProfitAndLossIndicator, ProfitAndLossIndicator$inboundSchema, } from "./profitandlossindicator.js"; import { ProfitAndLossType, ProfitAndLossType$inboundSchema, } from "./profitandlosstype.js"; /** * The operating income accounts */ export type Income = { /** * A unique identifier for an object. */ id?: string | undefined; /** * The account code of the account */ code?: string | undefined; /** * The name of the account. */ title?: string | undefined; /** * The type of profit and loss */ type?: ProfitAndLossType | null | undefined; /** * The aggregated total of all accounts within this category. */ total: number | null; records?: any | undefined; }; /** * The cost of goods sold accounts */ export type CostOfGoodsSold = { /** * A unique identifier for an object. */ id?: string | undefined; /** * The account code of the account */ code?: string | undefined; /** * The name of the account. */ title?: string | undefined; /** * The type of profit and loss */ type?: ProfitAndLossType | null | undefined; /** * The aggregated total of all accounts within this category. */ total?: number | null | undefined; records?: any | undefined; }; /** * The operating expenses accounts */ export type Expenses = { /** * A unique identifier for an object. */ id?: string | undefined; /** * The account code of the account */ code?: string | undefined; /** * The name of the account. */ title?: string | undefined; /** * The type of profit and loss */ type?: ProfitAndLossType | null | undefined; /** * The aggregated total of all accounts within this category. */ total: number | null; records?: any | undefined; }; /** * The other income accounts */ export type OtherIncome = { /** * A unique identifier for an object. */ id?: string | undefined; /** * The account code of the account */ code?: string | undefined; /** * The name of the account. */ title?: string | undefined; /** * The type of profit and loss */ type?: ProfitAndLossType | null | undefined; /** * The aggregated total of all accounts within this category. */ total?: number | null | undefined; records?: any | undefined; }; /** * The other expenses accounts */ export type OtherExpenses = { /** * A unique identifier for an object. */ id?: string | undefined; /** * The account code of the account */ code?: string | undefined; /** * The name of the account. */ title?: string | undefined; /** * The type of profit and loss */ type?: ProfitAndLossType | null | undefined; /** * The aggregated total of all accounts within this category. */ total?: number | null | undefined; records?: any | undefined; }; /** * The accounts not categorized in the other sections */ export type UncategorizedAccounts = { /** * A unique identifier for an object. */ id?: string | undefined; /** * The account code of the account */ code?: string | undefined; /** * The name of the account. */ title?: string | undefined; /** * The type of profit and loss */ type?: ProfitAndLossType | null | undefined; /** * The aggregated total of all accounts within this category. */ total: number | null; records?: any | undefined; }; export type ProfitAndLoss = { /** * A unique identifier for an object. */ id?: string | undefined; /** * The name of the report */ reportName: string; /** * The start date of the report */ startDate?: string | undefined; /** * The end date of the report */ endDate?: string | 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 operating income accounts */ income: Income; /** * The cost of goods sold accounts */ costOfGoodsSold?: CostOfGoodsSold | undefined; /** * The operating expenses accounts */ expenses: Expenses; /** * The other income accounts */ otherIncome?: OtherIncome | undefined; /** * The other expenses accounts */ otherExpenses?: OtherExpenses | undefined; /** * The accounts not categorized in the other sections */ uncategorizedAccounts?: UncategorizedAccounts | undefined; grossProfit?: ProfitAndLossIndicator | undefined; netOperatingIncome?: ProfitAndLossIndicator | undefined; netIncome?: ProfitAndLossIndicator | undefined; /** * When custom mappings are configured on the resource, the result is included here. */ customMappings?: { [k: string]: any } | null | undefined; /** * The customer id */ customer?: string | undefined; }; /** @internal */ export const Income$inboundSchema: z.ZodType = /* @__PURE__ */ lazySchema$(() => z.object({ id: types.optional(types.string()), code: types.optional(types.string()), title: types.optional(types.string()), type: z.nullable(ProfitAndLossType$inboundSchema).optional(), total: types.nullable(types.number()), records: types.optional(z.any()), }) ); export function incomeFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Income$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Income' from JSON`, ); } /** @internal */ export const CostOfGoodsSold$inboundSchema: z.ZodType< CostOfGoodsSold, z.ZodTypeDef, unknown > = /* @__PURE__ */ lazySchema$(() => z.object({ id: types.optional(types.string()), code: types.optional(types.string()), title: types.optional(types.string()), type: z.nullable(ProfitAndLossType$inboundSchema).optional(), total: z.nullable(types.number()).optional(), records: types.optional(z.any()), }) ); export function costOfGoodsSoldFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => CostOfGoodsSold$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'CostOfGoodsSold' from JSON`, ); } /** @internal */ export const Expenses$inboundSchema: z.ZodType< Expenses, z.ZodTypeDef, unknown > = /* @__PURE__ */ lazySchema$(() => z.object({ id: types.optional(types.string()), code: types.optional(types.string()), title: types.optional(types.string()), type: z.nullable(ProfitAndLossType$inboundSchema).optional(), total: types.nullable(types.number()), records: types.optional(z.any()), }) ); export function expensesFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Expenses$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Expenses' from JSON`, ); } /** @internal */ export const OtherIncome$inboundSchema: z.ZodType< OtherIncome, z.ZodTypeDef, unknown > = /* @__PURE__ */ lazySchema$(() => z.object({ id: types.optional(types.string()), code: types.optional(types.string()), title: types.optional(types.string()), type: z.nullable(ProfitAndLossType$inboundSchema).optional(), total: z.nullable(types.number()).optional(), records: types.optional(z.any()), }) ); export function otherIncomeFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => OtherIncome$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'OtherIncome' from JSON`, ); } /** @internal */ export const OtherExpenses$inboundSchema: z.ZodType< OtherExpenses, z.ZodTypeDef, unknown > = /* @__PURE__ */ lazySchema$(() => z.object({ id: types.optional(types.string()), code: types.optional(types.string()), title: types.optional(types.string()), type: z.nullable(ProfitAndLossType$inboundSchema).optional(), total: z.nullable(types.number()).optional(), records: types.optional(z.any()), }) ); export function otherExpensesFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => OtherExpenses$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'OtherExpenses' from JSON`, ); } /** @internal */ export const UncategorizedAccounts$inboundSchema: z.ZodType< UncategorizedAccounts, z.ZodTypeDef, unknown > = /* @__PURE__ */ lazySchema$(() => z.object({ id: types.optional(types.string()), code: types.optional(types.string()), title: types.optional(types.string()), type: z.nullable(ProfitAndLossType$inboundSchema).optional(), total: types.nullable(types.number()), records: types.optional(z.any()), }) ); export function uncategorizedAccountsFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => UncategorizedAccounts$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'UncategorizedAccounts' from JSON`, ); } /** @internal */ export const ProfitAndLoss$inboundSchema: z.ZodType< ProfitAndLoss, z.ZodTypeDef, unknown > = /* @__PURE__ */ lazySchema$(() => z.object({ id: types.optional(types.string()), report_name: types.string(), start_date: types.optional(types.string()), end_date: types.optional(types.string()), currency: z.nullable(Currency$inboundSchema).optional(), income: z.lazy(() => Income$inboundSchema), cost_of_goods_sold: types.optional( z.lazy(() => CostOfGoodsSold$inboundSchema), ), expenses: z.lazy(() => Expenses$inboundSchema), other_income: types.optional(z.lazy(() => OtherIncome$inboundSchema)), other_expenses: types.optional(z.lazy(() => OtherExpenses$inboundSchema)), uncategorized_accounts: types.optional( z.lazy(() => UncategorizedAccounts$inboundSchema), ), gross_profit: types.optional(ProfitAndLossIndicator$inboundSchema), net_operating_income: types.optional(ProfitAndLossIndicator$inboundSchema), net_income: types.optional(ProfitAndLossIndicator$inboundSchema), custom_mappings: z.nullable(z.record(z.any())).optional(), customer: types.optional(types.string()), }).transform((v) => { return remap$(v, { "report_name": "reportName", "start_date": "startDate", "end_date": "endDate", "cost_of_goods_sold": "costOfGoodsSold", "other_income": "otherIncome", "other_expenses": "otherExpenses", "uncategorized_accounts": "uncategorizedAccounts", "gross_profit": "grossProfit", "net_operating_income": "netOperatingIncome", "net_income": "netIncome", "custom_mappings": "customMappings", }); }) ); export function profitAndLossFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => ProfitAndLoss$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'ProfitAndLoss' from JSON`, ); }