/* * 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 { DeprecatedLinkedTrackingCategory, DeprecatedLinkedTrackingCategory$inboundSchema, DeprecatedLinkedTrackingCategory$Outbound, DeprecatedLinkedTrackingCategory$outboundSchema, } from "./deprecatedlinkedtrackingcategory.js"; import { LinkedCustomer, LinkedCustomer$inboundSchema, } from "./linkedcustomer.js"; import { LinkedCustomerInput, LinkedCustomerInput$Outbound, LinkedCustomerInput$outboundSchema, } from "./linkedcustomerinput.js"; import { LinkedEmployee, LinkedEmployee$inboundSchema, LinkedEmployee$Outbound, LinkedEmployee$outboundSchema, } from "./linkedemployee.js"; import { LinkedLedgerAccount, LinkedLedgerAccount$inboundSchema, LinkedLedgerAccount$Outbound, LinkedLedgerAccount$outboundSchema, } from "./linkedledgeraccount.js"; import { LinkedSupplier, LinkedSupplier$inboundSchema, } from "./linkedsupplier.js"; import { LinkedSupplierInput, LinkedSupplierInput$Outbound, LinkedSupplierInput$outboundSchema, } from "./linkedsupplierinput.js"; import { LinkedTaxRate, LinkedTaxRate$inboundSchema } from "./linkedtaxrate.js"; import { LinkedTaxRateInput, LinkedTaxRateInput$Outbound, LinkedTaxRateInput$outboundSchema, } from "./linkedtaxrateinput.js"; import { LinkedTrackingCategory, LinkedTrackingCategory$inboundSchema, LinkedTrackingCategory$Outbound, LinkedTrackingCategory$outboundSchema, } from "./linkedtrackingcategory.js"; import { LinkedWorktag, LinkedWorktag$inboundSchema, LinkedWorktag$Outbound, LinkedWorktag$outboundSchema, } from "./linkedworktag.js"; /** * Debit entries are considered positive, and credit entries are considered negative. */ export const JournalEntryLineItemType = { Debit: "debit", Credit: "credit", } as const; /** * Debit entries are considered positive, and credit entries are considered negative. */ export type JournalEntryLineItemType = OpenEnum< typeof JournalEntryLineItemType >; /** * The tax applicability of this line item. Overrides the root-level tax_type for this line. */ export const TaxType = { Sales: "sales", Purchase: "purchase", } as const; /** * The tax applicability of this line item. Overrides the root-level tax_type for this line. */ export type TaxType = OpenEnum; export type JournalEntryLineItem = { /** * A unique identifier for an object. */ id?: string | undefined; /** * User defined description */ description?: string | null | undefined; /** * Tax amount */ taxAmount?: number | null | undefined; /** * Sub-total amount, normally before tax. */ subTotal?: number | null | undefined; /** * Debit entries are considered positive, and credit entries are considered negative. */ totalAmount?: number | null | undefined; /** * Amount for this line in the company's base currency. Used when the journal entry currency differs from the company's base currency. */ baseCurrencyAmount?: number | null | undefined; /** * Debit entries are considered positive, and credit entries are considered negative. */ type: JournalEntryLineItemType | null; taxRate?: LinkedTaxRate | undefined; /** * The tax applicability of this line item. Overrides the root-level tax_type for this line. */ taxType?: TaxType | null | undefined; /** * @deprecated field: This field is deprecated and may be removed in a future version.. */ trackingCategory?: DeprecatedLinkedTrackingCategory | null | undefined; /** * A list of linked tracking categories. */ trackingCategories?: Array | null | undefined; ledgerAccount: LinkedLedgerAccount | null; /** * The customer this entity is linked to. */ customer?: LinkedCustomer | null | undefined; /** * The supplier this entity is linked to. */ supplier?: LinkedSupplier | null | undefined; /** * The employee this entity is linked to. */ employee?: LinkedEmployee | null | undefined; /** * The ID of the department */ departmentId?: string | null | undefined; /** * The ID of the location */ locationId?: string | null | undefined; /** * Line number of the resource */ lineNumber?: number | null | undefined; /** * Worktags of the line item. This is currently only supported in Workday. */ worktags?: Array | undefined; /** * The financial date of this specific line, when it differs from the journal entry's own posted_at date - for example when booking a historical or backdated transaction. Not populated by every connector: some post the entry date at the header level only, in which case this line-level date is legitimately absent rather than wrong. */ date?: Date | null | undefined; /** * A unique identifier for the source of this specific line, distinct from the journal entry's own source_id. Useful for reconciling an individual line back to an external system's own record when a single journal entry aggregates lines originating from more than one source. */ sourceId?: string | null | undefined; }; export type JournalEntryLineItemInput = { /** * User defined description */ description?: string | null | undefined; /** * Tax amount */ taxAmount?: number | null | undefined; /** * Sub-total amount, normally before tax. */ subTotal?: number | null | undefined; /** * Debit entries are considered positive, and credit entries are considered negative. */ totalAmount?: number | null | undefined; /** * Amount for this line in the company's base currency. Used when the journal entry currency differs from the company's base currency. */ baseCurrencyAmount?: number | null | undefined; /** * Debit entries are considered positive, and credit entries are considered negative. */ type: JournalEntryLineItemType | null; taxRate?: LinkedTaxRateInput | undefined; /** * The tax applicability of this line item. Overrides the root-level tax_type for this line. */ taxType?: TaxType | null | undefined; /** * @deprecated field: This field is deprecated and may be removed in a future version.. */ trackingCategory?: DeprecatedLinkedTrackingCategory | null | undefined; /** * A list of linked tracking categories. */ trackingCategories?: Array | null | undefined; ledgerAccount: LinkedLedgerAccount | null; /** * The customer this entity is linked to. */ customer?: LinkedCustomerInput | null | undefined; /** * The supplier this entity is linked to. */ supplier?: LinkedSupplierInput | null | undefined; /** * The employee this entity is linked to. */ employee?: LinkedEmployee | null | undefined; /** * The ID of the department */ departmentId?: string | null | undefined; /** * The ID of the location */ locationId?: string | null | undefined; /** * Line number of the resource */ lineNumber?: number | null | undefined; /** * Worktags of the line item. This is currently only supported in Workday. */ worktags?: Array | undefined; /** * The financial date of this specific line, when it differs from the journal entry's own posted_at date - for example when booking a historical or backdated transaction. Not populated by every connector: some post the entry date at the header level only, in which case this line-level date is legitimately absent rather than wrong. */ date?: Date | null | undefined; /** * A unique identifier for the source of this specific line, distinct from the journal entry's own source_id. Useful for reconciling an individual line back to an external system's own record when a single journal entry aggregates lines originating from more than one source. */ sourceId?: string | null | undefined; }; /** @internal */ export const JournalEntryLineItemType$inboundSchema: z.ZodType< JournalEntryLineItemType, z.ZodTypeDef, unknown > = /* @__PURE__ */ lazySchema$(() => openEnums.inboundSchema(JournalEntryLineItemType) ); /** @internal */ export const JournalEntryLineItemType$outboundSchema: z.ZodType< string, z.ZodTypeDef, JournalEntryLineItemType > = /* @__PURE__ */ lazySchema$(() => openEnums.outboundSchema(JournalEntryLineItemType) ); /** @internal */ export const TaxType$inboundSchema: z.ZodType = /* @__PURE__ */ lazySchema$(() => openEnums.inboundSchema(TaxType)); /** @internal */ export const TaxType$outboundSchema: z.ZodType = /* @__PURE__ */ lazySchema$(() => openEnums.outboundSchema(TaxType)); /** @internal */ export const JournalEntryLineItem$inboundSchema: z.ZodType< JournalEntryLineItem, z.ZodTypeDef, unknown > = /* @__PURE__ */ lazySchema$(() => z.object({ id: types.optional(types.string()), description: z.nullable(types.string()).optional(), tax_amount: z.nullable(types.number()).optional(), sub_total: z.nullable(types.number()).optional(), total_amount: z.nullable(types.number()).optional(), base_currency_amount: z.nullable(types.number()).optional(), type: types.nullable(JournalEntryLineItemType$inboundSchema), tax_rate: types.optional(LinkedTaxRate$inboundSchema), tax_type: z.nullable(TaxType$inboundSchema).optional(), tracking_category: z.nullable( DeprecatedLinkedTrackingCategory$inboundSchema, ).optional(), tracking_categories: z.nullable( z.array(types.nullable(LinkedTrackingCategory$inboundSchema)), ).optional(), ledger_account: types.nullable(LinkedLedgerAccount$inboundSchema), customer: z.nullable(LinkedCustomer$inboundSchema).optional(), supplier: z.nullable(LinkedSupplier$inboundSchema).optional(), employee: z.nullable(LinkedEmployee$inboundSchema).optional(), department_id: z.nullable(types.string()).optional(), location_id: z.nullable(types.string()).optional(), line_number: z.nullable(types.number()).optional(), worktags: types.optional( z.array(types.nullable(LinkedWorktag$inboundSchema)), ), date: z.nullable(types.date()).optional(), source_id: z.nullable(types.string()).optional(), }).transform((v) => { return remap$(v, { "tax_amount": "taxAmount", "sub_total": "subTotal", "total_amount": "totalAmount", "base_currency_amount": "baseCurrencyAmount", "tax_rate": "taxRate", "tax_type": "taxType", "tracking_category": "trackingCategory", "tracking_categories": "trackingCategories", "ledger_account": "ledgerAccount", "department_id": "departmentId", "location_id": "locationId", "line_number": "lineNumber", "source_id": "sourceId", }); }) ); export function journalEntryLineItemFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => JournalEntryLineItem$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'JournalEntryLineItem' from JSON`, ); } /** @internal */ export type JournalEntryLineItemInput$Outbound = { description?: string | null | undefined; tax_amount?: number | null | undefined; sub_total?: number | null | undefined; total_amount?: number | null | undefined; base_currency_amount?: number | null | undefined; type: string | null; tax_rate?: LinkedTaxRateInput$Outbound | undefined; tax_type?: string | null | undefined; tracking_category?: | DeprecatedLinkedTrackingCategory$Outbound | null | undefined; tracking_categories?: | Array | null | undefined; ledger_account: LinkedLedgerAccount$Outbound | null; customer?: LinkedCustomerInput$Outbound | null | undefined; supplier?: LinkedSupplierInput$Outbound | null | undefined; employee?: LinkedEmployee$Outbound | null | undefined; department_id?: string | null | undefined; location_id?: string | null | undefined; line_number?: number | null | undefined; worktags?: Array | undefined; date?: string | null | undefined; source_id?: string | null | undefined; }; /** @internal */ export const JournalEntryLineItemInput$outboundSchema: z.ZodType< JournalEntryLineItemInput$Outbound, z.ZodTypeDef, JournalEntryLineItemInput > = /* @__PURE__ */ lazySchema$(() => z.object({ description: z.nullable(z.string()).optional(), taxAmount: z.nullable(z.number()).optional(), subTotal: z.nullable(z.number()).optional(), totalAmount: z.nullable(z.number()).optional(), baseCurrencyAmount: z.nullable(z.number()).optional(), type: z.nullable(JournalEntryLineItemType$outboundSchema), taxRate: LinkedTaxRateInput$outboundSchema.optional(), taxType: z.nullable(TaxType$outboundSchema).optional(), trackingCategory: z.nullable( DeprecatedLinkedTrackingCategory$outboundSchema, ).optional(), trackingCategories: z.nullable( z.array(z.nullable(LinkedTrackingCategory$outboundSchema)), ).optional(), ledgerAccount: z.nullable(LinkedLedgerAccount$outboundSchema), customer: z.nullable(LinkedCustomerInput$outboundSchema).optional(), supplier: z.nullable(LinkedSupplierInput$outboundSchema).optional(), employee: z.nullable(LinkedEmployee$outboundSchema).optional(), departmentId: z.nullable(z.string()).optional(), locationId: z.nullable(z.string()).optional(), lineNumber: z.nullable(z.number().int()).optional(), worktags: z.array(z.nullable(LinkedWorktag$outboundSchema)).optional(), date: z.nullable( z.date().transform(v => v.toISOString().slice(0, "YYYY-MM-DD".length)), ).optional(), sourceId: z.nullable(z.string()).optional(), }).transform((v) => { return remap$(v, { taxAmount: "tax_amount", subTotal: "sub_total", totalAmount: "total_amount", baseCurrencyAmount: "base_currency_amount", taxRate: "tax_rate", taxType: "tax_type", trackingCategory: "tracking_category", trackingCategories: "tracking_categories", ledgerAccount: "ledger_account", departmentId: "department_id", locationId: "location_id", lineNumber: "line_number", sourceId: "source_id", }); }) ); export function journalEntryLineItemInputToJSON( journalEntryLineItemInput: JournalEntryLineItemInput, ): string { return JSON.stringify( JournalEntryLineItemInput$outboundSchema.parse(journalEntryLineItemInput), ); }