/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod"; import { remap as remap$ } from "../../lib/primitives.js"; import { safeParse } from "../../lib/schemas.js"; import { ClosedEnum } from "../../types/enums.js"; import { Result as SafeParseResult } from "../../types/fp.js"; import { SDKValidationError } from "../errors/sdkvalidationerror.js"; import { DeprecatedLinkedTrackingCategory, DeprecatedLinkedTrackingCategory$inboundSchema, DeprecatedLinkedTrackingCategory$Outbound, DeprecatedLinkedTrackingCategory$outboundSchema, } from "./deprecatedlinkedtrackingcategory.js"; import { LinkedCustomer, LinkedCustomer$inboundSchema, LinkedCustomer$Outbound, LinkedCustomer$outboundSchema, } from "./linkedcustomer.js"; import { LinkedCustomerInput, LinkedCustomerInput$inboundSchema, LinkedCustomerInput$Outbound, LinkedCustomerInput$outboundSchema, } from "./linkedcustomerinput.js"; import { LinkedLedgerAccount, LinkedLedgerAccount$inboundSchema, LinkedLedgerAccount$Outbound, LinkedLedgerAccount$outboundSchema, } from "./linkedledgeraccount.js"; import { LinkedLedgerAccountInput, LinkedLedgerAccountInput$inboundSchema, LinkedLedgerAccountInput$Outbound, LinkedLedgerAccountInput$outboundSchema, } from "./linkedledgeraccountinput.js"; import { LinkedSupplier, LinkedSupplier$inboundSchema, LinkedSupplier$Outbound, LinkedSupplier$outboundSchema, } from "./linkedsupplier.js"; import { LinkedSupplierInput, LinkedSupplierInput$inboundSchema, LinkedSupplierInput$Outbound, LinkedSupplierInput$outboundSchema, } from "./linkedsupplierinput.js"; import { LinkedTaxRate, LinkedTaxRate$inboundSchema, LinkedTaxRate$Outbound, LinkedTaxRate$outboundSchema, } from "./linkedtaxrate.js"; import { LinkedTaxRateInput, LinkedTaxRateInput$inboundSchema, LinkedTaxRateInput$Outbound, LinkedTaxRateInput$outboundSchema, } from "./linkedtaxrateinput.js"; import { LinkedTrackingCategory, LinkedTrackingCategory$inboundSchema, LinkedTrackingCategory$Outbound, LinkedTrackingCategory$outboundSchema, } from "./linkedtrackingcategory.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 = ClosedEnum< typeof JournalEntryLineItemType >; 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; /** * Debit entries are considered positive, and credit entries are considered negative. */ type: JournalEntryLineItemType; taxRate?: LinkedTaxRate | undefined; /** * @deprecated field: This will be removed in a future release, please migrate away from it as soon as possible. */ 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; /** * A unique identifier for an object. */ departmentId?: string | undefined; /** * A unique identifier for an object. */ locationId?: string | undefined; /** * Line number of the resource */ lineNumber?: number | 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; /** * Debit entries are considered positive, and credit entries are considered negative. */ type: JournalEntryLineItemType; taxRate?: LinkedTaxRateInput | undefined; /** * @deprecated field: This will be removed in a future release, please migrate away from it as soon as possible. */ trackingCategory?: DeprecatedLinkedTrackingCategory | null | undefined; /** * A list of linked tracking categories. */ trackingCategories?: Array | null | undefined; ledgerAccount: LinkedLedgerAccountInput | null; /** * The customer this entity is linked to. */ customer?: LinkedCustomerInput | null | undefined; /** * The supplier this entity is linked to. */ supplier?: LinkedSupplierInput | null | undefined; /** * Line number of the resource */ lineNumber?: number | null | undefined; }; /** @internal */ export const JournalEntryLineItemType$inboundSchema: z.ZodNativeEnum< typeof JournalEntryLineItemType > = z.nativeEnum(JournalEntryLineItemType); /** @internal */ export const JournalEntryLineItemType$outboundSchema: z.ZodNativeEnum< typeof JournalEntryLineItemType > = JournalEntryLineItemType$inboundSchema; /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace JournalEntryLineItemType$ { /** @deprecated use `JournalEntryLineItemType$inboundSchema` instead. */ export const inboundSchema = JournalEntryLineItemType$inboundSchema; /** @deprecated use `JournalEntryLineItemType$outboundSchema` instead. */ export const outboundSchema = JournalEntryLineItemType$outboundSchema; } /** @internal */ export const JournalEntryLineItem$inboundSchema: z.ZodType< JournalEntryLineItem, z.ZodTypeDef, unknown > = z.object({ id: z.string().optional(), description: z.nullable(z.string()).optional(), tax_amount: z.nullable(z.number()).optional(), sub_total: z.nullable(z.number()).optional(), total_amount: z.nullable(z.number()).optional(), type: JournalEntryLineItemType$inboundSchema, tax_rate: LinkedTaxRate$inboundSchema.optional(), tracking_category: z.nullable(DeprecatedLinkedTrackingCategory$inboundSchema) .optional(), tracking_categories: z.nullable(z.array(LinkedTrackingCategory$inboundSchema)) .optional(), ledger_account: z.nullable(LinkedLedgerAccount$inboundSchema), customer: z.nullable(LinkedCustomer$inboundSchema).optional(), supplier: z.nullable(LinkedSupplier$inboundSchema).optional(), department_id: z.string().optional(), location_id: z.string().optional(), line_number: z.nullable(z.number().int()).optional(), }).transform((v) => { return remap$(v, { "tax_amount": "taxAmount", "sub_total": "subTotal", "total_amount": "totalAmount", "tax_rate": "taxRate", "tracking_category": "trackingCategory", "tracking_categories": "trackingCategories", "ledger_account": "ledgerAccount", "department_id": "departmentId", "location_id": "locationId", "line_number": "lineNumber", }); }); /** @internal */ export type JournalEntryLineItem$Outbound = { id?: string | undefined; description?: string | null | undefined; tax_amount?: number | null | undefined; sub_total?: number | null | undefined; total_amount?: number | null | undefined; type: string; tax_rate?: LinkedTaxRate$Outbound | undefined; tracking_category?: | DeprecatedLinkedTrackingCategory$Outbound | null | undefined; tracking_categories?: | Array | null | undefined; ledger_account: LinkedLedgerAccount$Outbound | null; customer?: LinkedCustomer$Outbound | null | undefined; supplier?: LinkedSupplier$Outbound | null | undefined; department_id?: string | undefined; location_id?: string | undefined; line_number?: number | null | undefined; }; /** @internal */ export const JournalEntryLineItem$outboundSchema: z.ZodType< JournalEntryLineItem$Outbound, z.ZodTypeDef, JournalEntryLineItem > = z.object({ id: z.string().optional(), description: z.nullable(z.string()).optional(), taxAmount: z.nullable(z.number()).optional(), subTotal: z.nullable(z.number()).optional(), totalAmount: z.nullable(z.number()).optional(), type: JournalEntryLineItemType$outboundSchema, taxRate: LinkedTaxRate$outboundSchema.optional(), trackingCategory: z.nullable(DeprecatedLinkedTrackingCategory$outboundSchema) .optional(), trackingCategories: z.nullable(z.array(LinkedTrackingCategory$outboundSchema)) .optional(), ledgerAccount: z.nullable(LinkedLedgerAccount$outboundSchema), customer: z.nullable(LinkedCustomer$outboundSchema).optional(), supplier: z.nullable(LinkedSupplier$outboundSchema).optional(), departmentId: z.string().optional(), locationId: z.string().optional(), lineNumber: z.nullable(z.number().int()).optional(), }).transform((v) => { return remap$(v, { taxAmount: "tax_amount", subTotal: "sub_total", totalAmount: "total_amount", taxRate: "tax_rate", trackingCategory: "tracking_category", trackingCategories: "tracking_categories", ledgerAccount: "ledger_account", departmentId: "department_id", locationId: "location_id", lineNumber: "line_number", }); }); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace JournalEntryLineItem$ { /** @deprecated use `JournalEntryLineItem$inboundSchema` instead. */ export const inboundSchema = JournalEntryLineItem$inboundSchema; /** @deprecated use `JournalEntryLineItem$outboundSchema` instead. */ export const outboundSchema = JournalEntryLineItem$outboundSchema; /** @deprecated use `JournalEntryLineItem$Outbound` instead. */ export type Outbound = JournalEntryLineItem$Outbound; } export function journalEntryLineItemToJSON( journalEntryLineItem: JournalEntryLineItem, ): string { return JSON.stringify( JournalEntryLineItem$outboundSchema.parse(journalEntryLineItem), ); } export function journalEntryLineItemFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => JournalEntryLineItem$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'JournalEntryLineItem' from JSON`, ); } /** @internal */ export const JournalEntryLineItemInput$inboundSchema: z.ZodType< JournalEntryLineItemInput, z.ZodTypeDef, unknown > = z.object({ description: z.nullable(z.string()).optional(), tax_amount: z.nullable(z.number()).optional(), sub_total: z.nullable(z.number()).optional(), total_amount: z.nullable(z.number()).optional(), type: JournalEntryLineItemType$inboundSchema, tax_rate: LinkedTaxRateInput$inboundSchema.optional(), tracking_category: z.nullable(DeprecatedLinkedTrackingCategory$inboundSchema) .optional(), tracking_categories: z.nullable(z.array(LinkedTrackingCategory$inboundSchema)) .optional(), ledger_account: z.nullable(LinkedLedgerAccountInput$inboundSchema), customer: z.nullable(LinkedCustomerInput$inboundSchema).optional(), supplier: z.nullable(LinkedSupplierInput$inboundSchema).optional(), line_number: z.nullable(z.number().int()).optional(), }).transform((v) => { return remap$(v, { "tax_amount": "taxAmount", "sub_total": "subTotal", "total_amount": "totalAmount", "tax_rate": "taxRate", "tracking_category": "trackingCategory", "tracking_categories": "trackingCategories", "ledger_account": "ledgerAccount", "line_number": "lineNumber", }); }); /** @internal */ export type JournalEntryLineItemInput$Outbound = { description?: string | null | undefined; tax_amount?: number | null | undefined; sub_total?: number | null | undefined; total_amount?: number | null | undefined; type: string; tax_rate?: LinkedTaxRateInput$Outbound | undefined; tracking_category?: | DeprecatedLinkedTrackingCategory$Outbound | null | undefined; tracking_categories?: | Array | null | undefined; ledger_account: LinkedLedgerAccountInput$Outbound | null; customer?: LinkedCustomerInput$Outbound | null | undefined; supplier?: LinkedSupplierInput$Outbound | null | undefined; line_number?: number | null | undefined; }; /** @internal */ export const JournalEntryLineItemInput$outboundSchema: z.ZodType< JournalEntryLineItemInput$Outbound, z.ZodTypeDef, JournalEntryLineItemInput > = 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(), type: JournalEntryLineItemType$outboundSchema, taxRate: LinkedTaxRateInput$outboundSchema.optional(), trackingCategory: z.nullable(DeprecatedLinkedTrackingCategory$outboundSchema) .optional(), trackingCategories: z.nullable(z.array(LinkedTrackingCategory$outboundSchema)) .optional(), ledgerAccount: z.nullable(LinkedLedgerAccountInput$outboundSchema), customer: z.nullable(LinkedCustomerInput$outboundSchema).optional(), supplier: z.nullable(LinkedSupplierInput$outboundSchema).optional(), lineNumber: z.nullable(z.number().int()).optional(), }).transform((v) => { return remap$(v, { taxAmount: "tax_amount", subTotal: "sub_total", totalAmount: "total_amount", taxRate: "tax_rate", trackingCategory: "tracking_category", trackingCategories: "tracking_categories", ledgerAccount: "ledger_account", lineNumber: "line_number", }); }); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace JournalEntryLineItemInput$ { /** @deprecated use `JournalEntryLineItemInput$inboundSchema` instead. */ export const inboundSchema = JournalEntryLineItemInput$inboundSchema; /** @deprecated use `JournalEntryLineItemInput$outboundSchema` instead. */ export const outboundSchema = JournalEntryLineItemInput$outboundSchema; /** @deprecated use `JournalEntryLineItemInput$Outbound` instead. */ export type Outbound = JournalEntryLineItemInput$Outbound; } export function journalEntryLineItemInputToJSON( journalEntryLineItemInput: JournalEntryLineItemInput, ): string { return JSON.stringify( JournalEntryLineItemInput$outboundSchema.parse(journalEntryLineItemInput), ); } export function journalEntryLineItemInputFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => JournalEntryLineItemInput$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'JournalEntryLineItemInput' from JSON`, ); }