/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod/v3"; import { safeParse } from "../../../lib/schemas.js"; import { Decimal as Decimal$ } from "../../types/decimal.js"; import { ClosedEnum } from "../../types/enums.js"; import { Result as SafeParseResult } from "../../types/fp.js"; import { SDKValidationError } from "../errors/sdkvalidationerror.js"; /** * Type of transaction for the bank statement line. */ export const BankTransactionType = { Unknown: "Unknown", Credit: "Credit", Debit: "Debit", Int: "Int", Div: "Div", Fee: "Fee", SerChg: "SerChg", Dep: "Dep", Atm: "Atm", Pos: "Pos", Xfer: "Xfer", Check: "Check", Payment: "Payment", Cash: "Cash", DirectDep: "DirectDep", DirectDebit: "DirectDebit", RepeatPmt: "RepeatPmt", Other: "Other", } as const; /** * Type of transaction for the bank statement line. */ export type BankTransactionType = ClosedEnum; export type BankTransactions = { /** * Identifier for the bank account transaction, unique for the company in the accounting software. */ id?: string | undefined; /** * In Codat's data model, dates and times are represented using the ISO 8601 standard. Date and time fields are formatted as strings; for example: * * @remarks * * ``` * 2023-08-22T10:21:00 * 2023-08-22 * ``` * * When pushing bank transaction data to Codat, the date is treated as a local date. This means: * * - The date/time is used exactly as provided, without any timezone conversion. * - If a timezone offset is included (e.g., `2023-08-22T10:21:00-05:00`), the offset will be ignored and only the local date/time portion will be used. * - We recommend providing dates without a timezone suffix for clarity (e.g., `2023-08-22T10:21:00` rather than `2023-08-22T10:21:00Z`). */ date?: string | undefined; /** * Description of the bank transaction. */ description?: string | null | undefined; /** * The giving or receiving party such as a person or organization. */ counterparty?: string | null | undefined; /** * An optional reference to the bank transaction. */ reference?: string | null | undefined; /** * `True` if the bank transaction has been [reconciled](https://www.xero.com/uk/guides/what-is-bank-reconciliation/) in the accounting software. */ reconciled?: boolean | null | undefined; /** * The amount transacted in the bank transaction. */ amount?: Decimal$ | number | undefined; /** * The remaining balance in the account with ID `accountId`. This field is optional for QuickBooks Online but is required for Xero, Sage, NetSuite, Exact, and FreeAgent. */ balance?: Decimal$ | number | undefined; /** * Type of transaction for the bank statement line. */ transactionType?: BankTransactionType | null | undefined; }; /** @internal */ export const BankTransactionType$inboundSchema: z.ZodNativeEnum< typeof BankTransactionType > = z.nativeEnum(BankTransactionType); /** @internal */ export const BankTransactionType$outboundSchema: z.ZodNativeEnum< typeof BankTransactionType > = BankTransactionType$inboundSchema; /** @internal */ export const BankTransactions$inboundSchema: z.ZodType< BankTransactions, z.ZodTypeDef, unknown > = z.object({ id: z.string().optional(), date: z.string().optional(), description: z.nullable(z.string()).optional(), counterparty: z.nullable(z.string()).optional(), reference: z.nullable(z.string()).optional(), reconciled: z.nullable(z.boolean()).optional(), amount: z.number().transform(v => new Decimal$(v)).optional(), balance: z.number().transform(v => new Decimal$(v)).optional(), transactionType: z.nullable(BankTransactionType$inboundSchema).optional(), }); /** @internal */ export type BankTransactions$Outbound = { id?: string | undefined; date?: string | undefined; description?: string | null | undefined; counterparty?: string | null | undefined; reference?: string | null | undefined; reconciled?: boolean | null | undefined; amount?: number | undefined; balance?: number | undefined; transactionType?: string | null | undefined; }; /** @internal */ export const BankTransactions$outboundSchema: z.ZodType< BankTransactions$Outbound, z.ZodTypeDef, BankTransactions > = z.object({ id: z.string().optional(), date: z.string().optional(), description: z.nullable(z.string()).optional(), counterparty: z.nullable(z.string()).optional(), reference: z.nullable(z.string()).optional(), reconciled: z.nullable(z.boolean()).optional(), amount: z.union([z.instanceof(Decimal$), z.number()]).transform(v => typeof v === "number" ? v : v.toNumber() ).optional(), balance: z.union([z.instanceof(Decimal$), z.number()]).transform(v => typeof v === "number" ? v : v.toNumber() ).optional(), transactionType: z.nullable(BankTransactionType$outboundSchema).optional(), }); export function bankTransactionsToJSON( bankTransactions: BankTransactions, ): string { return JSON.stringify( BankTransactions$outboundSchema.parse(bankTransactions), ); } export function bankTransactionsFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => BankTransactions$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'BankTransactions' from JSON`, ); }