/* * 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"; import { CustomField, CustomField$inboundSchema } from "./customfield.js"; import { GeneralLedgerTransactionLineItem, GeneralLedgerTransactionLineItem$inboundSchema, } from "./generalledgertransactionlineitem.js"; import { PassThroughBody, PassThroughBody$inboundSchema, } from "./passthroughbody.js"; /** * The originating transaction type that produced this posting in the general ledger. Discriminates whether the entry came from an invoice, a bill, a payment, a manual journal, etc. This is the key field that distinguishes general-ledger-transactions from journal-entries (which only covers manually-captured entries). May be `null` when the upstream connector did not return an origin discriminator (e.g. Xero's single-record endpoint strips `SourceType` for every record; certain historical records also omit it). To recover a populated value, query the list endpoint. */ export const GeneralLedgerTransactionSourceType = { Other: "other", Invoice: "invoice", Bill: "bill", CreditNote: "credit_note", Payment: "payment", Refund: "refund", Expense: "expense", JournalEntry: "journal_entry", Payroll: "payroll", } as const; /** * The originating transaction type that produced this posting in the general ledger. Discriminates whether the entry came from an invoice, a bill, a payment, a manual journal, etc. This is the key field that distinguishes general-ledger-transactions from journal-entries (which only covers manually-captured entries). May be `null` when the upstream connector did not return an origin discriminator (e.g. Xero's single-record endpoint strips `SourceType` for every record; certain historical records also omit it). To recover a populated value, query the list endpoint. */ export type GeneralLedgerTransactionSourceType = OpenEnum< typeof GeneralLedgerTransactionSourceType >; export type GeneralLedgerTransaction = { /** * A unique identifier for an object. */ id?: string | undefined; /** * The originating transaction type that produced this posting in the general ledger. Discriminates whether the entry came from an invoice, a bill, a payment, a manual journal, etc. This is the key field that distinguishes general-ledger-transactions from journal-entries (which only covers manually-captured entries). May be `null` when the upstream connector did not return an origin discriminator (e.g. Xero's single-record endpoint strips `SourceType` for every record; certain historical records also omit it). To recover a populated value, query the list endpoint. */ sourceType: GeneralLedgerTransactionSourceType | null; /** * Identifier of the originating document in the vendor system. For example, when source_type is 'invoice', this is the id of the invoice that produced this posting. Use this id together with source_type to fetch the source document via its dedicated unified resource. */ sourceId?: string | null | undefined; /** * The date on which the transaction was posted to the general ledger. This is the accounting date — it is what determines the period the transaction belongs to and can be earlier than the creation date for backdated postings. */ postedAt?: Date | undefined; /** * Optional reference identifier for the transaction. */ reference?: string | null | undefined; /** * Sequential number auto-assigned by the vendor system to the transaction (e.g. Xero JournalNumber). Unique per company. */ number?: string | 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; /** * Currency Exchange Rate at the time entity was recorded/generated. */ currencyRate?: number | null | undefined; /** * Free-text description at the header level. Typically populated when the transaction originates from a manual journal — for system-generated postings (invoice, payment, etc.) the source document carries the descriptive text. */ memo?: string | null | undefined; /** * Lines of the transaction. Each line affects one ledger account with either a debit or a credit. The signed sum of net_amount across all lines must equal zero (double-entry invariant). */ lineItems: Array; customFields?: Array | 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; /** * When custom mappings are configured on the resource, the result is included here. */ customMappings?: { [k: string]: any } | 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 GeneralLedgerTransactionSourceType$inboundSchema: z.ZodType< GeneralLedgerTransactionSourceType, z.ZodTypeDef, unknown > = /* @__PURE__ */ lazySchema$(() => openEnums.inboundSchema(GeneralLedgerTransactionSourceType) ); /** @internal */ export const GeneralLedgerTransaction$inboundSchema: z.ZodType< GeneralLedgerTransaction, z.ZodTypeDef, unknown > = /* @__PURE__ */ lazySchema$(() => z.object({ id: types.optional(types.string()), source_type: types.nullable( GeneralLedgerTransactionSourceType$inboundSchema, ), source_id: z.nullable(types.string()).optional(), posted_at: types.optional(types.date()), reference: z.nullable(types.string()).optional(), number: z.nullable(types.string()).optional(), currency: z.nullable(Currency$inboundSchema).optional(), currency_rate: z.nullable(types.number()).optional(), memo: z.nullable(types.string()).optional(), line_items: z.array(GeneralLedgerTransactionLineItem$inboundSchema), custom_fields: types.optional(z.array(CustomField$inboundSchema)), 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(), custom_mappings: z.nullable(z.record(z.any())).optional(), pass_through: types.optional(z.array(PassThroughBody$inboundSchema)), }).transform((v) => { return remap$(v, { "source_type": "sourceType", "source_id": "sourceId", "posted_at": "postedAt", "currency_rate": "currencyRate", "line_items": "lineItems", "custom_fields": "customFields", "updated_by": "updatedBy", "created_by": "createdBy", "updated_at": "updatedAt", "created_at": "createdAt", "custom_mappings": "customMappings", "pass_through": "passThrough", }); }) ); export function generalLedgerTransactionFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => GeneralLedgerTransaction$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'GeneralLedgerTransaction' from JSON`, ); }