/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod/v3"; import { Decimal as Decimal$ } from "../../types/decimal.js"; import { ClosedEnum } from "../../types/enums.js"; import { BankAccountStatus, BankAccountStatus$outboundSchema, } from "./bankaccountstatus.js"; /** * The type of transactions and balances on the account. * * @remarks * For Credit accounts, positive balances are liabilities, and positive transactions **reduce** liabilities. * For Debit accounts, positive balances are assets, and positive transactions **increase** assets. */ export const BankAccountType = { Unknown: "Unknown", Credit: "Credit", Debit: "Debit", } as const; /** * The type of transactions and balances on the account. * * @remarks * For Credit accounts, positive balances are liabilities, and positive transactions **reduce** liabilities. * For Debit accounts, positive balances are assets, and positive transactions **increase** assets. */ export type BankAccountType = ClosedEnum; export type BankAccountPrototype = { /** * Name of the bank account in the accounting software. */ accountName?: string | null | undefined; /** * The type of transactions and balances on the account. * * @remarks * For Credit accounts, positive balances are liabilities, and positive transactions **reduce** liabilities. * For Debit accounts, positive balances are assets, and positive transactions **increase** assets. */ accountType?: BankAccountType | undefined; /** * Code used to identify each nominal account for a business. */ nominalCode?: string | null | undefined; /** * Sort code for the bank account. * * @remarks * * Xero integrations * The sort code is only displayed when the currency = GBP and the sort code and account number sum to 14 digits. For non-GBP accounts, this field is not populated. */ sortCode?: string | null | undefined; /** * Account number for the bank account. * * @remarks * * Xero integrations * Only a UK account number shows for bank accounts with GBP currency and a combined total of sort code and account number that equals 14 digits, For non-GBP accounts, the full bank account number is populated. * * FreeAgent integrations * For Credit accounts, only the last four digits are required. For other types, the field is optional. */ accountNumber?: string | null | undefined; /** * International bank account number of the account. Often used when making or receiving international payments. */ iBan?: string | null | undefined; /** * The currency data type in Codat is the [ISO 4217](https://en.wikipedia.org/wiki/ISO_4217) currency code, e.g. _GBP_. * * @remarks * * ## Unknown currencies * * In line with the ISO 4217 specification, the code _XXX_ is used when the data source does not return a currency for a transaction. * * There are only a very small number of edge cases where this currency code is returned by the Codat system. */ currency?: string | undefined; /** * Balance of the bank account. */ balance?: Decimal$ | number | null | undefined; /** * The institution of the bank account. */ institution?: string | null | undefined; /** * Total available balance of the bank account as reported by the underlying data source. This may take into account overdrafts or pending transactions for example. */ availableBalance?: Decimal$ | number | null | undefined; /** * Pre-arranged overdraft limit of the account. * * @remarks * * The value is always positive. For example, an overdraftLimit of `1000` means that the balance of the account can go down to `-1000`. */ overdraftLimit?: Decimal$ | number | null | undefined; /** * Status of the bank account. */ status?: BankAccountStatus | undefined; }; /** @internal */ export const BankAccountType$outboundSchema: z.ZodNativeEnum< typeof BankAccountType > = z.nativeEnum(BankAccountType); /** @internal */ export type BankAccountPrototype$Outbound = { accountName?: string | null | undefined; accountType?: string | undefined; nominalCode?: string | null | undefined; sortCode?: string | null | undefined; accountNumber?: string | null | undefined; iBan?: string | null | undefined; currency?: string | undefined; balance?: number | null | undefined; institution?: string | null | undefined; availableBalance?: number | null | undefined; overdraftLimit?: number | null | undefined; status?: string | undefined; }; /** @internal */ export const BankAccountPrototype$outboundSchema: z.ZodType< BankAccountPrototype$Outbound, z.ZodTypeDef, BankAccountPrototype > = z.object({ accountName: z.nullable(z.string()).optional(), accountType: BankAccountType$outboundSchema.optional(), nominalCode: z.nullable(z.string()).optional(), sortCode: z.nullable(z.string()).optional(), accountNumber: z.nullable(z.string()).optional(), iBan: z.nullable(z.string()).optional(), currency: z.string().optional(), balance: z.nullable( z.union([z.instanceof(Decimal$), z.number()]).transform(v => typeof v === "number" ? v : v.toNumber() ), ).optional(), institution: z.nullable(z.string()).optional(), availableBalance: z.nullable( z.union([z.instanceof(Decimal$), z.number()]).transform(v => typeof v === "number" ? v : v.toNumber() ), ).optional(), overdraftLimit: z.nullable( z.union([z.instanceof(Decimal$), z.number()]).transform(v => typeof v === "number" ? v : v.toNumber() ), ).optional(), status: BankAccountStatus$outboundSchema.optional(), }); export function bankAccountPrototypeToJSON( bankAccountPrototype: BankAccountPrototype, ): string { return JSON.stringify( BankAccountPrototype$outboundSchema.parse(bankAccountPrototype), ); }