/* * 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 { LinkedLedgerAccount, LinkedLedgerAccount$inboundSchema, } from "./linkedledgeraccount.js"; import { LinkedTaxRate, LinkedTaxRate$inboundSchema } from "./linkedtaxrate.js"; import { LinkedTrackingCategory, LinkedTrackingCategory$inboundSchema, } from "./linkedtrackingcategory.js"; /** * Side of the entry. Redundant with the sign of net_amount but exposed as an explicit flag for filtering convenience. */ export const GeneralLedgerTransactionLineItemType = { Debit: "debit", Credit: "credit", } as const; /** * Side of the entry. Redundant with the sign of net_amount but exposed as an explicit flag for filtering convenience. */ export type GeneralLedgerTransactionLineItemType = OpenEnum< typeof GeneralLedgerTransactionLineItemType >; export type GeneralLedgerTransactionLineItem = { /** * A unique identifier for an object. */ id?: string | undefined; /** * Free-text description of the line. */ description?: string | null | undefined; /** * The amount posted to the ledger account, tax-exclusive. Debit entries are positive, credit entries are negative. In general-ledger views the tax component lives in its own dedicated line against a tax payable/receivable account, so net_amount is the canonical figure for reporting. */ netAmount?: number | null | undefined; /** * Side of the entry. Redundant with the sign of net_amount but exposed as an explicit flag for filtering convenience. */ type: GeneralLedgerTransactionLineItemType | null; /** * Tax embedded in the line. In GL views this is typically 0 or null because tax has its own dedicated line against a tax payable/receivable account. Exposed for completeness and for tax-inclusive setups. */ taxAmount?: number | null | undefined; taxRate?: LinkedTaxRate | undefined; /** * A list of linked tracking categories. */ trackingCategories?: Array | null | undefined; ledgerAccount: LinkedLedgerAccount | null; /** * Line number of the resource */ lineNumber?: number | null | undefined; }; /** @internal */ export const GeneralLedgerTransactionLineItemType$inboundSchema: z.ZodType< GeneralLedgerTransactionLineItemType, z.ZodTypeDef, unknown > = /* @__PURE__ */ lazySchema$(() => openEnums.inboundSchema(GeneralLedgerTransactionLineItemType) ); /** @internal */ export const GeneralLedgerTransactionLineItem$inboundSchema: z.ZodType< GeneralLedgerTransactionLineItem, z.ZodTypeDef, unknown > = /* @__PURE__ */ lazySchema$(() => z.object({ id: types.optional(types.string()), description: z.nullable(types.string()).optional(), net_amount: z.nullable(types.number()).optional(), type: types.nullable(GeneralLedgerTransactionLineItemType$inboundSchema), tax_amount: z.nullable(types.number()).optional(), tax_rate: types.optional(LinkedTaxRate$inboundSchema), tracking_categories: z.nullable( z.array(types.nullable(LinkedTrackingCategory$inboundSchema)), ).optional(), ledger_account: types.nullable(LinkedLedgerAccount$inboundSchema), line_number: z.nullable(types.number()).optional(), }).transform((v) => { return remap$(v, { "net_amount": "netAmount", "tax_amount": "taxAmount", "tax_rate": "taxRate", "tracking_categories": "trackingCategories", "ledger_account": "ledgerAccount", "line_number": "lineNumber", }); }) ); export function generalLedgerTransactionLineItemFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => GeneralLedgerTransactionLineItem$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'GeneralLedgerTransactionLineItem' from JSON`, ); }