/* * 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, Currency$outboundSchema, } from "./currency.js"; import { DeprecatedLinkedTrackingCategory, DeprecatedLinkedTrackingCategory$inboundSchema, DeprecatedLinkedTrackingCategory$Outbound, DeprecatedLinkedTrackingCategory$outboundSchema, } from "./deprecatedlinkedtrackingcategory.js"; import { LinkedLedgerAccount, LinkedLedgerAccount$inboundSchema, LinkedLedgerAccount$Outbound, LinkedLedgerAccount$outboundSchema, } from "./linkedledgeraccount.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 { PassThroughBody, PassThroughBody$inboundSchema, PassThroughBody$Outbound, PassThroughBody$outboundSchema, } from "./passthroughbody.js"; /** * Item type */ export const InvoiceItemTypeType = { Inventory: "inventory", NonInventory: "non_inventory", Service: "service", Description: "description", Other: "other", } as const; /** * Item type */ export type InvoiceItemTypeType = OpenEnum; export type SalesDetails = { unitPrice?: number | null | undefined; /** * Description of the unit type the item is sold as, ie: kg, hour. */ unitOfMeasure?: string | null | undefined; /** * Amounts are including tax */ taxInclusive?: boolean | null | undefined; taxRate?: LinkedTaxRate | undefined; }; export type PurchaseDetails = { unitPrice?: number | null | undefined; /** * Description of the unit type the item is sold as, ie: kg, hour. */ unitOfMeasure?: string | null | undefined; /** * Amounts are including tax */ taxInclusive?: boolean | null | undefined; taxRate?: LinkedTaxRate | undefined; }; export type InvoiceItem = { /** * The ID of the item. */ id?: string | undefined; /** * Item name */ name?: string | null | undefined; /** * A short description of the item */ description?: string | null | undefined; /** * Display ID of the item */ displayId?: string | null | undefined; /** * User defined item code */ code?: string | null | undefined; /** * Item will be available on sales transactions */ sold?: boolean | null | undefined; /** * Item is available for purchase transactions */ purchased?: boolean | null | undefined; /** * Item is inventoried */ tracked?: boolean | null | undefined; /** * If true, transactions for this item are taxable */ taxable?: boolean | null | undefined; /** * The date of opening balance if inventory item is tracked - YYYY-MM-DD. */ inventoryDate?: Date | null | undefined; /** * Item type */ type?: InvoiceItemTypeType | null | undefined; salesDetails?: SalesDetails | undefined; purchaseDetails?: PurchaseDetails | undefined; quantity?: number | null | undefined; unitPrice?: number | 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; assetAccount?: LinkedLedgerAccount | null | undefined; incomeAccount?: LinkedLedgerAccount | null | undefined; expenseAccount?: LinkedLedgerAccount | 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; active?: boolean | null | undefined; /** * The ID of the department */ departmentId?: string | null | undefined; /** * The ID of the location */ locationId?: string | null | undefined; /** * The ID of the subsidiary */ subsidiaryId?: string | null | undefined; /** * ID of the category of the item */ categoryId?: string | null | undefined; /** * The ID of the tax schedule */ taxScheduleId?: string | null | undefined; /** * When custom mappings are configured on the resource, the result is included here. */ customMappings?: { [k: string]: any } | null | undefined; /** * A binary value used to detect updates to a object and prevent data conflicts. It is incremented each time an update is made to the object. */ rowVersion?: string | null | 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; /** * The pass_through property allows passing service-specific, custom data or structured modifications in request body when creating or updating resources. */ passThrough?: Array | undefined; }; export type InvoiceItemSalesDetails = { unitPrice?: number | null | undefined; /** * Description of the unit type the item is sold as, ie: kg, hour. */ unitOfMeasure?: string | null | undefined; /** * Amounts are including tax */ taxInclusive?: boolean | null | undefined; taxRate?: LinkedTaxRateInput | undefined; }; export type InvoiceItemPurchaseDetails = { unitPrice?: number | null | undefined; /** * Description of the unit type the item is sold as, ie: kg, hour. */ unitOfMeasure?: string | null | undefined; /** * Amounts are including tax */ taxInclusive?: boolean | null | undefined; taxRate?: LinkedTaxRateInput | undefined; }; export type InvoiceItemInput = { /** * Item name */ name?: string | null | undefined; /** * A short description of the item */ description?: string | null | undefined; /** * Display ID of the item */ displayId?: string | null | undefined; /** * User defined item code */ code?: string | null | undefined; /** * Item will be available on sales transactions */ sold?: boolean | null | undefined; /** * Item is available for purchase transactions */ purchased?: boolean | null | undefined; /** * Item is inventoried */ tracked?: boolean | null | undefined; /** * If true, transactions for this item are taxable */ taxable?: boolean | null | undefined; /** * The date of opening balance if inventory item is tracked - YYYY-MM-DD. */ inventoryDate?: Date | null | undefined; /** * Item type */ type?: InvoiceItemTypeType | null | undefined; salesDetails?: InvoiceItemSalesDetails | undefined; purchaseDetails?: InvoiceItemPurchaseDetails | undefined; quantity?: number | null | undefined; unitPrice?: number | 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; assetAccount?: LinkedLedgerAccount | null | undefined; incomeAccount?: LinkedLedgerAccount | null | undefined; expenseAccount?: LinkedLedgerAccount | 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; active?: boolean | null | undefined; /** * The ID of the department */ departmentId?: string | null | undefined; /** * The ID of the location */ locationId?: string | null | undefined; /** * The ID of the subsidiary */ subsidiaryId?: string | null | undefined; /** * ID of the category of the item */ categoryId?: string | null | undefined; /** * The ID of the tax schedule */ taxScheduleId?: string | null | undefined; /** * A binary value used to detect updates to a object and prevent data conflicts. It is incremented each time an update is made to the object. */ rowVersion?: string | 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 InvoiceItemTypeType$inboundSchema: z.ZodType< InvoiceItemTypeType, z.ZodTypeDef, unknown > = /* @__PURE__ */ lazySchema$(() => openEnums.inboundSchema(InvoiceItemTypeType) ); /** @internal */ export const InvoiceItemTypeType$outboundSchema: z.ZodType< string, z.ZodTypeDef, InvoiceItemTypeType > = /* @__PURE__ */ lazySchema$(() => openEnums.outboundSchema(InvoiceItemTypeType) ); /** @internal */ export const SalesDetails$inboundSchema: z.ZodType< SalesDetails, z.ZodTypeDef, unknown > = /* @__PURE__ */ lazySchema$(() => z.object({ unit_price: z.nullable(types.number()).optional(), unit_of_measure: z.nullable(types.string()).optional(), tax_inclusive: z.nullable(types.boolean()).optional(), tax_rate: types.optional(LinkedTaxRate$inboundSchema), }).transform((v) => { return remap$(v, { "unit_price": "unitPrice", "unit_of_measure": "unitOfMeasure", "tax_inclusive": "taxInclusive", "tax_rate": "taxRate", }); }) ); export function salesDetailsFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => SalesDetails$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'SalesDetails' from JSON`, ); } /** @internal */ export const PurchaseDetails$inboundSchema: z.ZodType< PurchaseDetails, z.ZodTypeDef, unknown > = /* @__PURE__ */ lazySchema$(() => z.object({ unit_price: z.nullable(types.number()).optional(), unit_of_measure: z.nullable(types.string()).optional(), tax_inclusive: z.nullable(types.boolean()).optional(), tax_rate: types.optional(LinkedTaxRate$inboundSchema), }).transform((v) => { return remap$(v, { "unit_price": "unitPrice", "unit_of_measure": "unitOfMeasure", "tax_inclusive": "taxInclusive", "tax_rate": "taxRate", }); }) ); export function purchaseDetailsFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => PurchaseDetails$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'PurchaseDetails' from JSON`, ); } /** @internal */ export const InvoiceItem$inboundSchema: z.ZodType< InvoiceItem, z.ZodTypeDef, unknown > = /* @__PURE__ */ lazySchema$(() => z.object({ id: types.optional(types.string()), name: z.nullable(types.string()).optional(), description: z.nullable(types.string()).optional(), display_id: z.nullable(types.string()).optional(), code: z.nullable(types.string()).optional(), sold: z.nullable(types.boolean()).optional(), purchased: z.nullable(types.boolean()).optional(), tracked: z.nullable(types.boolean()).optional(), taxable: z.nullable(types.boolean()).optional(), inventory_date: z.nullable(types.date()).optional(), type: z.nullable(InvoiceItemTypeType$inboundSchema).optional(), sales_details: types.optional(z.lazy(() => SalesDetails$inboundSchema)), purchase_details: types.optional( z.lazy(() => PurchaseDetails$inboundSchema), ), quantity: z.nullable(types.number()).optional(), unit_price: z.nullable(types.number()).optional(), currency: z.nullable(Currency$inboundSchema).optional(), asset_account: z.nullable(LinkedLedgerAccount$inboundSchema).optional(), income_account: z.nullable(LinkedLedgerAccount$inboundSchema).optional(), expense_account: z.nullable(LinkedLedgerAccount$inboundSchema).optional(), tracking_category: z.nullable( DeprecatedLinkedTrackingCategory$inboundSchema, ).optional(), tracking_categories: z.nullable( z.array(types.nullable(LinkedTrackingCategory$inboundSchema)), ).optional(), active: z.nullable(types.boolean()).optional(), department_id: z.nullable(types.string()).optional(), location_id: z.nullable(types.string()).optional(), subsidiary_id: z.nullable(types.string()).optional(), category_id: z.nullable(types.string()).optional(), tax_schedule_id: z.nullable(types.string()).optional(), custom_mappings: z.nullable(z.record(z.any())).optional(), row_version: z.nullable(types.string()).optional(), 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(), pass_through: types.optional(z.array(PassThroughBody$inboundSchema)), }).transform((v) => { return remap$(v, { "display_id": "displayId", "inventory_date": "inventoryDate", "sales_details": "salesDetails", "purchase_details": "purchaseDetails", "unit_price": "unitPrice", "asset_account": "assetAccount", "income_account": "incomeAccount", "expense_account": "expenseAccount", "tracking_category": "trackingCategory", "tracking_categories": "trackingCategories", "department_id": "departmentId", "location_id": "locationId", "subsidiary_id": "subsidiaryId", "category_id": "categoryId", "tax_schedule_id": "taxScheduleId", "custom_mappings": "customMappings", "row_version": "rowVersion", "updated_by": "updatedBy", "created_by": "createdBy", "updated_at": "updatedAt", "created_at": "createdAt", "pass_through": "passThrough", }); }) ); export function invoiceItemFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => InvoiceItem$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'InvoiceItem' from JSON`, ); } /** @internal */ export type InvoiceItemSalesDetails$Outbound = { unit_price?: number | null | undefined; unit_of_measure?: string | null | undefined; tax_inclusive?: boolean | null | undefined; tax_rate?: LinkedTaxRateInput$Outbound | undefined; }; /** @internal */ export const InvoiceItemSalesDetails$outboundSchema: z.ZodType< InvoiceItemSalesDetails$Outbound, z.ZodTypeDef, InvoiceItemSalesDetails > = /* @__PURE__ */ lazySchema$(() => z.object({ unitPrice: z.nullable(z.number()).optional(), unitOfMeasure: z.nullable(z.string()).optional(), taxInclusive: z.nullable(z.boolean()).optional(), taxRate: LinkedTaxRateInput$outboundSchema.optional(), }).transform((v) => { return remap$(v, { unitPrice: "unit_price", unitOfMeasure: "unit_of_measure", taxInclusive: "tax_inclusive", taxRate: "tax_rate", }); }) ); export function invoiceItemSalesDetailsToJSON( invoiceItemSalesDetails: InvoiceItemSalesDetails, ): string { return JSON.stringify( InvoiceItemSalesDetails$outboundSchema.parse(invoiceItemSalesDetails), ); } /** @internal */ export type InvoiceItemPurchaseDetails$Outbound = { unit_price?: number | null | undefined; unit_of_measure?: string | null | undefined; tax_inclusive?: boolean | null | undefined; tax_rate?: LinkedTaxRateInput$Outbound | undefined; }; /** @internal */ export const InvoiceItemPurchaseDetails$outboundSchema: z.ZodType< InvoiceItemPurchaseDetails$Outbound, z.ZodTypeDef, InvoiceItemPurchaseDetails > = /* @__PURE__ */ lazySchema$(() => z.object({ unitPrice: z.nullable(z.number()).optional(), unitOfMeasure: z.nullable(z.string()).optional(), taxInclusive: z.nullable(z.boolean()).optional(), taxRate: LinkedTaxRateInput$outboundSchema.optional(), }).transform((v) => { return remap$(v, { unitPrice: "unit_price", unitOfMeasure: "unit_of_measure", taxInclusive: "tax_inclusive", taxRate: "tax_rate", }); }) ); export function invoiceItemPurchaseDetailsToJSON( invoiceItemPurchaseDetails: InvoiceItemPurchaseDetails, ): string { return JSON.stringify( InvoiceItemPurchaseDetails$outboundSchema.parse(invoiceItemPurchaseDetails), ); } /** @internal */ export type InvoiceItemInput$Outbound = { name?: string | null | undefined; description?: string | null | undefined; display_id?: string | null | undefined; code?: string | null | undefined; sold?: boolean | null | undefined; purchased?: boolean | null | undefined; tracked?: boolean | null | undefined; taxable?: boolean | null | undefined; inventory_date?: string | null | undefined; type?: string | null | undefined; sales_details?: InvoiceItemSalesDetails$Outbound | undefined; purchase_details?: InvoiceItemPurchaseDetails$Outbound | undefined; quantity?: number | null | undefined; unit_price?: number | null | undefined; currency?: string | null | undefined; asset_account?: LinkedLedgerAccount$Outbound | null | undefined; income_account?: LinkedLedgerAccount$Outbound | null | undefined; expense_account?: LinkedLedgerAccount$Outbound | null | undefined; tracking_category?: | DeprecatedLinkedTrackingCategory$Outbound | null | undefined; tracking_categories?: | Array | null | undefined; active?: boolean | null | undefined; department_id?: string | null | undefined; location_id?: string | null | undefined; subsidiary_id?: string | null | undefined; category_id?: string | null | undefined; tax_schedule_id?: string | null | undefined; row_version?: string | null | undefined; pass_through?: Array | undefined; }; /** @internal */ export const InvoiceItemInput$outboundSchema: z.ZodType< InvoiceItemInput$Outbound, z.ZodTypeDef, InvoiceItemInput > = /* @__PURE__ */ lazySchema$(() => z.object({ name: z.nullable(z.string()).optional(), description: z.nullable(z.string()).optional(), displayId: z.nullable(z.string()).optional(), code: z.nullable(z.string()).optional(), sold: z.nullable(z.boolean()).optional(), purchased: z.nullable(z.boolean()).optional(), tracked: z.nullable(z.boolean()).optional(), taxable: z.nullable(z.boolean()).optional(), inventoryDate: z.nullable( z.date().transform(v => v.toISOString().slice(0, "YYYY-MM-DD".length)), ).optional(), type: z.nullable(InvoiceItemTypeType$outboundSchema).optional(), salesDetails: z.lazy(() => InvoiceItemSalesDetails$outboundSchema) .optional(), purchaseDetails: z.lazy(() => InvoiceItemPurchaseDetails$outboundSchema) .optional(), quantity: z.nullable(z.number()).optional(), unitPrice: z.nullable(z.number()).optional(), currency: z.nullable(Currency$outboundSchema).optional(), assetAccount: z.nullable(LinkedLedgerAccount$outboundSchema).optional(), incomeAccount: z.nullable(LinkedLedgerAccount$outboundSchema).optional(), expenseAccount: z.nullable(LinkedLedgerAccount$outboundSchema).optional(), trackingCategory: z.nullable( DeprecatedLinkedTrackingCategory$outboundSchema, ).optional(), trackingCategories: z.nullable( z.array(z.nullable(LinkedTrackingCategory$outboundSchema)), ).optional(), active: z.nullable(z.boolean()).optional(), departmentId: z.nullable(z.string()).optional(), locationId: z.nullable(z.string()).optional(), subsidiaryId: z.nullable(z.string()).optional(), categoryId: z.nullable(z.string()).optional(), taxScheduleId: z.nullable(z.string()).optional(), rowVersion: z.nullable(z.string()).optional(), passThrough: z.array(PassThroughBody$outboundSchema).optional(), }).transform((v) => { return remap$(v, { displayId: "display_id", inventoryDate: "inventory_date", salesDetails: "sales_details", purchaseDetails: "purchase_details", unitPrice: "unit_price", assetAccount: "asset_account", incomeAccount: "income_account", expenseAccount: "expense_account", trackingCategory: "tracking_category", trackingCategories: "tracking_categories", departmentId: "department_id", locationId: "location_id", subsidiaryId: "subsidiary_id", categoryId: "category_id", taxScheduleId: "tax_schedule_id", rowVersion: "row_version", passThrough: "pass_through", }); }) ); export function invoiceItemInputToJSON( invoiceItemInput: InvoiceItemInput, ): string { return JSON.stringify( InvoiceItemInput$outboundSchema.parse(invoiceItemInput), ); }