/* * 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 { CustomField, CustomField$inboundSchema, CustomField$Outbound, CustomField$outboundSchema, } from "./customfield.js"; import { LinkedInvoiceItem, LinkedInvoiceItem$inboundSchema, LinkedInvoiceItem$Outbound, LinkedInvoiceItem$outboundSchema, } from "./linkedinvoiceitem.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 { LinkedWorktag, LinkedWorktag$inboundSchema, LinkedWorktag$Outbound, LinkedWorktag$outboundSchema, } from "./linkedworktag.js"; /** * Item type */ export const InvoiceLineItemType = { SalesItem: "sales_item", Discount: "discount", Info: "info", SubTotal: "sub_total", Service: "service", Other: "other", } as const; /** * Item type */ export type InvoiceLineItemType = OpenEnum; export type InvoiceLineItem = { /** * A unique identifier for an object. */ id?: string | null | undefined; /** * Row ID */ rowId?: string | undefined; /** * User defined item code */ code?: string | null | undefined; /** * Line number of the resource */ lineNumber?: number | null | undefined; /** * User defined description */ description?: string | null | undefined; /** * Item type */ type?: InvoiceLineItemType | null | undefined; /** * Tax amount */ taxAmount?: number | null | undefined; /** * Total amount of the line item */ totalAmount?: number | null | undefined; quantity?: number | null | undefined; unitPrice?: number | null | undefined; /** * Description of the unit type the item is sold as, ie: kg, hour. */ unitOfMeasure?: string | null | undefined; /** * Discount percentage applied to the line item when supported downstream. */ discountPercentage?: number | null | undefined; /** * Discount amount applied to the line item when supported downstream. */ discountAmount?: number | null | undefined; /** * Date on which the service was provided or performed - YYYY-MM-DD. */ serviceDate?: Date | null | undefined; /** * ID of the category of the line item */ categoryId?: string | null | undefined; /** * The ID of the location */ locationId?: string | null | undefined; /** * The ID of the department */ departmentId?: string | null | undefined; /** * The ID of the subsidiary */ subsidiaryId?: string | null | undefined; /** * ID of the shipping of the line item */ shippingId?: string | null | undefined; /** * Memo */ memo?: string | null | undefined; /** * Whether the line item is prepaid */ prepaid?: boolean | null | undefined; item?: LinkedInvoiceItem | undefined; /** * If true, this line item is subject to tax. Read-only, and only populated by connectors that record taxability on the line itself. */ taxable?: boolean | null | undefined; /** * Tax applicable on */ taxApplicableOn?: string | null | undefined; /** * Tax recoverability */ taxRecoverability?: string | null | undefined; /** * Method of tax calculation */ taxMethod?: string | null | undefined; /** * Worktags of the line item. This is currently only supported in Workday. */ worktags?: Array | undefined; taxRate?: LinkedTaxRate | undefined; /** * A list of linked tracking categories. */ trackingCategories?: Array | null | undefined; ledgerAccount?: LinkedLedgerAccount | null | undefined; customFields?: Array | 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 created. */ createdAt?: Date | null | undefined; /** * The date and time when the object was last updated. */ updatedAt?: Date | null | undefined; }; export type InvoiceLineItemInput = { /** * A unique identifier for an object. */ id?: string | null | undefined; /** * Row ID */ rowId?: string | undefined; /** * User defined item code */ code?: string | null | undefined; /** * Line number of the resource */ lineNumber?: number | null | undefined; /** * User defined description */ description?: string | null | undefined; /** * Item type */ type?: InvoiceLineItemType | null | undefined; /** * Tax amount */ taxAmount?: number | null | undefined; /** * Total amount of the line item */ totalAmount?: number | null | undefined; quantity?: number | null | undefined; unitPrice?: number | null | undefined; /** * Description of the unit type the item is sold as, ie: kg, hour. */ unitOfMeasure?: string | null | undefined; /** * Discount percentage applied to the line item when supported downstream. */ discountPercentage?: number | null | undefined; /** * Discount amount applied to the line item when supported downstream. */ discountAmount?: number | null | undefined; /** * Date on which the service was provided or performed - YYYY-MM-DD. */ serviceDate?: Date | null | undefined; /** * ID of the category of the line item */ categoryId?: string | null | undefined; /** * The ID of the location */ locationId?: string | null | undefined; /** * The ID of the department */ departmentId?: string | null | undefined; /** * The ID of the subsidiary */ subsidiaryId?: string | null | undefined; /** * ID of the shipping of the line item */ shippingId?: string | null | undefined; /** * Memo */ memo?: string | null | undefined; /** * Whether the line item is prepaid */ prepaid?: boolean | null | undefined; item?: LinkedInvoiceItem | undefined; /** * Tax applicable on */ taxApplicableOn?: string | null | undefined; /** * Tax recoverability */ taxRecoverability?: string | null | undefined; /** * Method of tax calculation */ taxMethod?: string | null | undefined; /** * Worktags of the line item. This is currently only supported in Workday. */ worktags?: Array | undefined; taxRate?: LinkedTaxRateInput | undefined; /** * A list of linked tracking categories. */ trackingCategories?: Array | null | undefined; ledgerAccount?: LinkedLedgerAccount | null | undefined; customFields?: Array | 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; }; /** @internal */ export const InvoiceLineItemType$inboundSchema: z.ZodType< InvoiceLineItemType, z.ZodTypeDef, unknown > = /* @__PURE__ */ lazySchema$(() => openEnums.inboundSchema(InvoiceLineItemType) ); /** @internal */ export const InvoiceLineItemType$outboundSchema: z.ZodType< string, z.ZodTypeDef, InvoiceLineItemType > = /* @__PURE__ */ lazySchema$(() => openEnums.outboundSchema(InvoiceLineItemType) ); /** @internal */ export const InvoiceLineItem$inboundSchema: z.ZodType< InvoiceLineItem, z.ZodTypeDef, unknown > = /* @__PURE__ */ lazySchema$(() => z.object({ id: z.nullable(types.string()).optional(), row_id: types.optional(types.string()), code: z.nullable(types.string()).optional(), line_number: z.nullable(types.number()).optional(), description: z.nullable(types.string()).optional(), type: z.nullable(InvoiceLineItemType$inboundSchema).optional(), tax_amount: z.nullable(types.number()).optional(), total_amount: z.nullable(types.number()).optional(), quantity: z.nullable(types.number()).optional(), unit_price: z.nullable(types.number()).optional(), unit_of_measure: z.nullable(types.string()).optional(), discount_percentage: z.nullable(types.number()).optional(), discount_amount: z.nullable(types.number()).optional(), service_date: z.nullable(types.date()).optional(), category_id: z.nullable(types.string()).optional(), location_id: z.nullable(types.string()).optional(), department_id: z.nullable(types.string()).optional(), subsidiary_id: z.nullable(types.string()).optional(), shipping_id: z.nullable(types.string()).optional(), memo: z.nullable(types.string()).optional(), prepaid: z.nullable(types.boolean()).optional(), item: types.optional(LinkedInvoiceItem$inboundSchema), taxable: z.nullable(types.boolean()).optional(), tax_applicable_on: z.nullable(types.string()).optional(), tax_recoverability: z.nullable(types.string()).optional(), tax_method: z.nullable(types.string()).optional(), worktags: types.optional( z.array(types.nullable(LinkedWorktag$inboundSchema)), ), tax_rate: types.optional(LinkedTaxRate$inboundSchema), tracking_categories: z.nullable( z.array(types.nullable(LinkedTrackingCategory$inboundSchema)), ).optional(), ledger_account: z.nullable(LinkedLedgerAccount$inboundSchema).optional(), custom_fields: types.optional(z.array(CustomField$inboundSchema)), row_version: z.nullable(types.string()).optional(), updated_by: z.nullable(types.string()).optional(), created_by: z.nullable(types.string()).optional(), created_at: z.nullable(types.date()).optional(), updated_at: z.nullable(types.date()).optional(), }).transform((v) => { return remap$(v, { "row_id": "rowId", "line_number": "lineNumber", "tax_amount": "taxAmount", "total_amount": "totalAmount", "unit_price": "unitPrice", "unit_of_measure": "unitOfMeasure", "discount_percentage": "discountPercentage", "discount_amount": "discountAmount", "service_date": "serviceDate", "category_id": "categoryId", "location_id": "locationId", "department_id": "departmentId", "subsidiary_id": "subsidiaryId", "shipping_id": "shippingId", "tax_applicable_on": "taxApplicableOn", "tax_recoverability": "taxRecoverability", "tax_method": "taxMethod", "tax_rate": "taxRate", "tracking_categories": "trackingCategories", "ledger_account": "ledgerAccount", "custom_fields": "customFields", "row_version": "rowVersion", "updated_by": "updatedBy", "created_by": "createdBy", "created_at": "createdAt", "updated_at": "updatedAt", }); }) ); export function invoiceLineItemFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => InvoiceLineItem$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'InvoiceLineItem' from JSON`, ); } /** @internal */ export type InvoiceLineItemInput$Outbound = { id?: string | null | undefined; row_id?: string | undefined; code?: string | null | undefined; line_number?: number | null | undefined; description?: string | null | undefined; type?: string | null | undefined; tax_amount?: number | null | undefined; total_amount?: number | null | undefined; quantity?: number | null | undefined; unit_price?: number | null | undefined; unit_of_measure?: string | null | undefined; discount_percentage?: number | null | undefined; discount_amount?: number | null | undefined; service_date?: string | null | undefined; category_id?: string | null | undefined; location_id?: string | null | undefined; department_id?: string | null | undefined; subsidiary_id?: string | null | undefined; shipping_id?: string | null | undefined; memo?: string | null | undefined; prepaid?: boolean | null | undefined; item?: LinkedInvoiceItem$Outbound | undefined; tax_applicable_on?: string | null | undefined; tax_recoverability?: string | null | undefined; tax_method?: string | null | undefined; worktags?: Array | undefined; tax_rate?: LinkedTaxRateInput$Outbound | undefined; tracking_categories?: | Array | null | undefined; ledger_account?: LinkedLedgerAccount$Outbound | null | undefined; custom_fields?: Array | undefined; row_version?: string | null | undefined; }; /** @internal */ export const InvoiceLineItemInput$outboundSchema: z.ZodType< InvoiceLineItemInput$Outbound, z.ZodTypeDef, InvoiceLineItemInput > = /* @__PURE__ */ lazySchema$(() => z.object({ id: z.nullable(z.string()).optional(), rowId: z.string().optional(), code: z.nullable(z.string()).optional(), lineNumber: z.nullable(z.number().int()).optional(), description: z.nullable(z.string()).optional(), type: z.nullable(InvoiceLineItemType$outboundSchema).optional(), taxAmount: z.nullable(z.number()).optional(), totalAmount: z.nullable(z.number()).optional(), quantity: z.nullable(z.number()).optional(), unitPrice: z.nullable(z.number()).optional(), unitOfMeasure: z.nullable(z.string()).optional(), discountPercentage: z.nullable(z.number()).optional(), discountAmount: z.nullable(z.number()).optional(), serviceDate: z.nullable( z.date().transform(v => v.toISOString().slice(0, "YYYY-MM-DD".length)), ).optional(), categoryId: z.nullable(z.string()).optional(), locationId: z.nullable(z.string()).optional(), departmentId: z.nullable(z.string()).optional(), subsidiaryId: z.nullable(z.string()).optional(), shippingId: z.nullable(z.string()).optional(), memo: z.nullable(z.string()).optional(), prepaid: z.nullable(z.boolean()).optional(), item: LinkedInvoiceItem$outboundSchema.optional(), taxApplicableOn: z.nullable(z.string()).optional(), taxRecoverability: z.nullable(z.string()).optional(), taxMethod: z.nullable(z.string()).optional(), worktags: z.array(z.nullable(LinkedWorktag$outboundSchema)).optional(), taxRate: LinkedTaxRateInput$outboundSchema.optional(), trackingCategories: z.nullable( z.array(z.nullable(LinkedTrackingCategory$outboundSchema)), ).optional(), ledgerAccount: z.nullable(LinkedLedgerAccount$outboundSchema).optional(), customFields: z.array(CustomField$outboundSchema).optional(), rowVersion: z.nullable(z.string()).optional(), }).transform((v) => { return remap$(v, { rowId: "row_id", lineNumber: "line_number", taxAmount: "tax_amount", totalAmount: "total_amount", unitPrice: "unit_price", unitOfMeasure: "unit_of_measure", discountPercentage: "discount_percentage", discountAmount: "discount_amount", serviceDate: "service_date", categoryId: "category_id", locationId: "location_id", departmentId: "department_id", subsidiaryId: "subsidiary_id", shippingId: "shipping_id", taxApplicableOn: "tax_applicable_on", taxRecoverability: "tax_recoverability", taxMethod: "tax_method", taxRate: "tax_rate", trackingCategories: "tracking_categories", ledgerAccount: "ledger_account", customFields: "custom_fields", rowVersion: "row_version", }); }) ); export function invoiceLineItemInputToJSON( invoiceLineItemInput: InvoiceLineItemInput, ): string { return JSON.stringify( InvoiceLineItemInput$outboundSchema.parse(invoiceLineItemInput), ); }