/* * 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 { RFCDate } from "../../types/rfcdate.js"; import { SDKValidationError } from "../errors/sdkvalidationerror.js"; import { Address, Address$inboundSchema, Address$Outbound, Address$outboundSchema, } from "./address.js"; import { BankAccount, BankAccount$inboundSchema, BankAccount$Outbound, BankAccount$outboundSchema, } from "./bankaccount.js"; import { Currency, Currency$inboundSchema, Currency$outboundSchema, } from "./currency.js"; import { CustomField, CustomField$inboundSchema, CustomField$Outbound, CustomField$outboundSchema, } from "./customfield.js"; import { CustomMappings, CustomMappings$inboundSchema, CustomMappings$Outbound, CustomMappings$outboundSchema, } from "./custommappings.js"; import { DeprecatedLinkedTrackingCategory, DeprecatedLinkedTrackingCategory$inboundSchema, DeprecatedLinkedTrackingCategory$Outbound, DeprecatedLinkedTrackingCategory$outboundSchema, } from "./deprecatedlinkedtrackingcategory.js"; import { InvoiceLineItem, InvoiceLineItem$inboundSchema, InvoiceLineItem$Outbound, InvoiceLineItem$outboundSchema, InvoiceLineItemInput, InvoiceLineItemInput$inboundSchema, InvoiceLineItemInput$Outbound, InvoiceLineItemInput$outboundSchema, } from "./invoicelineitem.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 { LinkedTrackingCategory, LinkedTrackingCategory$inboundSchema, LinkedTrackingCategory$Outbound, LinkedTrackingCategory$outboundSchema, } from "./linkedtrackingcategory.js"; import { PassThroughBody, PassThroughBody$inboundSchema, PassThroughBody$Outbound, PassThroughBody$outboundSchema, } from "./passthroughbody.js"; /** * Invoice type */ export const InvoiceType = { Standard: "standard", Credit: "credit", Service: "service", Product: "product", Supplier: "supplier", Other: "other", } as const; /** * Invoice type */ export type InvoiceType = ClosedEnum; /** * Invoice status */ export const InvoiceStatus = { Draft: "draft", Submitted: "submitted", Authorised: "authorised", PartiallyPaid: "partially_paid", Paid: "paid", Void: "void", Credit: "credit", Deleted: "deleted", } as const; /** * Invoice status */ export type InvoiceStatus = ClosedEnum; export type Invoice = { /** * A unique identifier for an object. */ id?: string | undefined; /** * The third-party API ID of original entity */ downstreamId?: string | null | undefined; /** * Invoice type */ type?: InvoiceType | null | undefined; /** * Invoice number. */ number?: string | null | undefined; /** * The customer this entity is linked to. */ customer?: LinkedCustomer | null | undefined; /** * The company or subsidiary id the transaction belongs to */ companyId?: string | null | undefined; /** * Date invoice was issued - YYYY-MM-DD. */ invoiceDate?: RFCDate | null | undefined; /** * The invoice due date is the date on which a payment or invoice is scheduled to be received by the seller - YYYY-MM-DD. */ dueDate?: RFCDate | null | undefined; /** * Terms of payment. */ terms?: string | null | undefined; /** * A PO Number uniquely identifies a purchase order and is generally defined by the buyer. The buyer will match the PO number in the invoice to the Purchase Order. */ poNumber?: string | null | undefined; /** * Optional invoice reference. */ reference?: string | null | undefined; /** * Invoice status */ status?: InvoiceStatus | null | undefined; /** * Invoice sent to contact/customer. */ invoiceSent?: boolean | 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; /** * Currency Exchange Rate at the time entity was recorded/generated. */ currencyRate?: number | null | undefined; /** * Amounts are including tax */ taxInclusive?: boolean | null | undefined; /** * Sub-total amount, normally before tax. */ subTotal?: number | null | undefined; /** * Total tax amount applied to this invoice. */ totalTax?: number | null | undefined; /** * Applicable tax id/code override if tax is not supplied on a line item basis. */ taxCode?: string | null | undefined; /** * Discount percentage applied to this invoice. */ discountPercentage?: number | null | undefined; /** * Discount amount applied to this invoice. */ discountAmount?: number | null | undefined; /** * Total amount of invoice, including tax. */ total?: number | null | undefined; /** * Balance of invoice due. */ balance?: number | null | undefined; /** * Amount of deposit made to this invoice. */ deposit?: number | null | undefined; /** * Customer memo */ customerMemo?: string | null | 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; lineItems?: Array | undefined; billingAddress?: Address | undefined; shippingAddress?: Address | undefined; /** * Optional invoice template */ templateId?: string | null | undefined; /** * URL link to a source document - shown as 'Go to [appName]' in the downstream app. Currently only supported for Xero. */ sourceDocumentUrl?: string | null | undefined; /** * Payment method used for the transaction, such as cash, credit card, bank transfer, or check */ paymentMethod?: string | null | undefined; /** * The channel through which the transaction is processed. */ channel?: string | null | undefined; /** * language code according to ISO 639-1. For the United States - EN */ language?: string | null | undefined; /** * Indicates if accounting by row is used (true) or not (false). Accounting by row means that a separate ledger transaction is created for each row. */ accountingByRow?: boolean | null | undefined; bankAccount?: BankAccount | undefined; ledgerAccount?: LinkedLedgerAccount | null | undefined; /** * When custom mappings are configured on the resource, the result is included here. */ customMappings?: CustomMappings | 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 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 InvoiceInput = { /** * Invoice type */ type?: InvoiceType | null | undefined; /** * Invoice number. */ number?: string | null | undefined; /** * The customer this entity is linked to. */ customer?: LinkedCustomerInput | null | undefined; /** * The company or subsidiary id the transaction belongs to */ companyId?: string | null | undefined; /** * Date invoice was issued - YYYY-MM-DD. */ invoiceDate?: RFCDate | null | undefined; /** * The invoice due date is the date on which a payment or invoice is scheduled to be received by the seller - YYYY-MM-DD. */ dueDate?: RFCDate | null | undefined; /** * Terms of payment. */ terms?: string | null | undefined; /** * A PO Number uniquely identifies a purchase order and is generally defined by the buyer. The buyer will match the PO number in the invoice to the Purchase Order. */ poNumber?: string | null | undefined; /** * Optional invoice reference. */ reference?: string | null | undefined; /** * Invoice status */ status?: InvoiceStatus | null | undefined; /** * Invoice sent to contact/customer. */ invoiceSent?: boolean | 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; /** * Currency Exchange Rate at the time entity was recorded/generated. */ currencyRate?: number | null | undefined; /** * Amounts are including tax */ taxInclusive?: boolean | null | undefined; /** * Sub-total amount, normally before tax. */ subTotal?: number | null | undefined; /** * Total tax amount applied to this invoice. */ totalTax?: number | null | undefined; /** * Applicable tax id/code override if tax is not supplied on a line item basis. */ taxCode?: string | null | undefined; /** * Discount percentage applied to this invoice. */ discountPercentage?: number | null | undefined; /** * Discount amount applied to this invoice. */ discountAmount?: number | null | undefined; /** * Total amount of invoice, including tax. */ total?: number | null | undefined; /** * Balance of invoice due. */ balance?: number | null | undefined; /** * Amount of deposit made to this invoice. */ deposit?: number | null | undefined; /** * Customer memo */ customerMemo?: string | null | 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; lineItems?: Array | undefined; billingAddress?: Address | undefined; shippingAddress?: Address | undefined; /** * Optional invoice template */ templateId?: string | null | undefined; /** * URL link to a source document - shown as 'Go to [appName]' in the downstream app. Currently only supported for Xero. */ sourceDocumentUrl?: string | null | undefined; /** * Payment method used for the transaction, such as cash, credit card, bank transfer, or check */ paymentMethod?: string | null | undefined; /** * The channel through which the transaction is processed. */ channel?: string | null | undefined; /** * language code according to ISO 639-1. For the United States - EN */ language?: string | null | undefined; /** * Indicates if accounting by row is used (true) or not (false). Accounting by row means that a separate ledger transaction is created for each row. */ accountingByRow?: boolean | null | undefined; bankAccount?: BankAccount | undefined; ledgerAccount?: LinkedLedgerAccountInput | 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 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 InvoiceType$inboundSchema: z.ZodNativeEnum = z .nativeEnum(InvoiceType); /** @internal */ export const InvoiceType$outboundSchema: z.ZodNativeEnum = InvoiceType$inboundSchema; /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace InvoiceType$ { /** @deprecated use `InvoiceType$inboundSchema` instead. */ export const inboundSchema = InvoiceType$inboundSchema; /** @deprecated use `InvoiceType$outboundSchema` instead. */ export const outboundSchema = InvoiceType$outboundSchema; } /** @internal */ export const InvoiceStatus$inboundSchema: z.ZodNativeEnum< typeof InvoiceStatus > = z.nativeEnum(InvoiceStatus); /** @internal */ export const InvoiceStatus$outboundSchema: z.ZodNativeEnum< typeof InvoiceStatus > = InvoiceStatus$inboundSchema; /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace InvoiceStatus$ { /** @deprecated use `InvoiceStatus$inboundSchema` instead. */ export const inboundSchema = InvoiceStatus$inboundSchema; /** @deprecated use `InvoiceStatus$outboundSchema` instead. */ export const outboundSchema = InvoiceStatus$outboundSchema; } /** @internal */ export const Invoice$inboundSchema: z.ZodType = z.object({ id: z.string().optional(), downstream_id: z.nullable(z.string()).optional(), type: z.nullable(InvoiceType$inboundSchema).optional(), number: z.nullable(z.string()).optional(), customer: z.nullable(LinkedCustomer$inboundSchema).optional(), company_id: z.nullable(z.string()).optional(), invoice_date: z.nullable(z.string().transform(v => new RFCDate(v))) .optional(), due_date: z.nullable(z.string().transform(v => new RFCDate(v))).optional(), terms: z.nullable(z.string()).optional(), po_number: z.nullable(z.string()).optional(), reference: z.nullable(z.string()).optional(), status: z.nullable(InvoiceStatus$inboundSchema).optional(), invoice_sent: z.boolean().optional(), currency: z.nullable(Currency$inboundSchema).optional(), currency_rate: z.nullable(z.number()).optional(), tax_inclusive: z.nullable(z.boolean()).optional(), sub_total: z.nullable(z.number()).optional(), total_tax: z.nullable(z.number()).optional(), tax_code: z.nullable(z.string()).optional(), discount_percentage: z.nullable(z.number()).optional(), discount_amount: z.nullable(z.number()).optional(), total: z.nullable(z.number()).optional(), balance: z.nullable(z.number()).optional(), deposit: z.nullable(z.number()).optional(), customer_memo: z.nullable(z.string()).optional(), tracking_category: z.nullable( DeprecatedLinkedTrackingCategory$inboundSchema, ).optional(), tracking_categories: z.nullable( z.array(LinkedTrackingCategory$inboundSchema), ).optional(), line_items: z.array(InvoiceLineItem$inboundSchema).optional(), billing_address: Address$inboundSchema.optional(), shipping_address: Address$inboundSchema.optional(), template_id: z.nullable(z.string()).optional(), source_document_url: z.nullable(z.string()).optional(), payment_method: z.nullable(z.string()).optional(), channel: z.nullable(z.string()).optional(), language: z.nullable(z.string()).optional(), accounting_by_row: z.nullable(z.boolean()).optional(), bank_account: BankAccount$inboundSchema.optional(), ledger_account: z.nullable(LinkedLedgerAccount$inboundSchema).optional(), custom_mappings: z.nullable(CustomMappings$inboundSchema).optional(), custom_fields: z.array(CustomField$inboundSchema).optional(), row_version: z.nullable(z.string()).optional(), updated_by: z.nullable(z.string()).optional(), created_by: z.nullable(z.string()).optional(), updated_at: z.nullable( z.string().datetime({ offset: true }).transform(v => new Date(v)), ).optional(), created_at: z.nullable( z.string().datetime({ offset: true }).transform(v => new Date(v)), ).optional(), pass_through: z.array(PassThroughBody$inboundSchema).optional(), }).transform((v) => { return remap$(v, { "downstream_id": "downstreamId", "company_id": "companyId", "invoice_date": "invoiceDate", "due_date": "dueDate", "po_number": "poNumber", "invoice_sent": "invoiceSent", "currency_rate": "currencyRate", "tax_inclusive": "taxInclusive", "sub_total": "subTotal", "total_tax": "totalTax", "tax_code": "taxCode", "discount_percentage": "discountPercentage", "discount_amount": "discountAmount", "customer_memo": "customerMemo", "tracking_category": "trackingCategory", "tracking_categories": "trackingCategories", "line_items": "lineItems", "billing_address": "billingAddress", "shipping_address": "shippingAddress", "template_id": "templateId", "source_document_url": "sourceDocumentUrl", "payment_method": "paymentMethod", "accounting_by_row": "accountingByRow", "bank_account": "bankAccount", "ledger_account": "ledgerAccount", "custom_mappings": "customMappings", "custom_fields": "customFields", "row_version": "rowVersion", "updated_by": "updatedBy", "created_by": "createdBy", "updated_at": "updatedAt", "created_at": "createdAt", "pass_through": "passThrough", }); }); /** @internal */ export type Invoice$Outbound = { id?: string | undefined; downstream_id?: string | null | undefined; type?: string | null | undefined; number?: string | null | undefined; customer?: LinkedCustomer$Outbound | null | undefined; company_id?: string | null | undefined; invoice_date?: string | null | undefined; due_date?: string | null | undefined; terms?: string | null | undefined; po_number?: string | null | undefined; reference?: string | null | undefined; status?: string | null | undefined; invoice_sent?: boolean | undefined; currency?: string | null | undefined; currency_rate?: number | null | undefined; tax_inclusive?: boolean | null | undefined; sub_total?: number | null | undefined; total_tax?: number | null | undefined; tax_code?: string | null | undefined; discount_percentage?: number | null | undefined; discount_amount?: number | null | undefined; total?: number | null | undefined; balance?: number | null | undefined; deposit?: number | null | undefined; customer_memo?: string | null | undefined; tracking_category?: | DeprecatedLinkedTrackingCategory$Outbound | null | undefined; tracking_categories?: | Array | null | undefined; line_items?: Array | undefined; billing_address?: Address$Outbound | undefined; shipping_address?: Address$Outbound | undefined; template_id?: string | null | undefined; source_document_url?: string | null | undefined; payment_method?: string | null | undefined; channel?: string | null | undefined; language?: string | null | undefined; accounting_by_row?: boolean | null | undefined; bank_account?: BankAccount$Outbound | undefined; ledger_account?: LinkedLedgerAccount$Outbound | null | undefined; custom_mappings?: CustomMappings$Outbound | null | undefined; custom_fields?: Array | undefined; row_version?: string | null | undefined; updated_by?: string | null | undefined; created_by?: string | null | undefined; updated_at?: string | null | undefined; created_at?: string | null | undefined; pass_through?: Array | undefined; }; /** @internal */ export const Invoice$outboundSchema: z.ZodType< Invoice$Outbound, z.ZodTypeDef, Invoice > = z.object({ id: z.string().optional(), downstreamId: z.nullable(z.string()).optional(), type: z.nullable(InvoiceType$outboundSchema).optional(), number: z.nullable(z.string()).optional(), customer: z.nullable(LinkedCustomer$outboundSchema).optional(), companyId: z.nullable(z.string()).optional(), invoiceDate: z.nullable(z.instanceof(RFCDate).transform(v => v.toString())) .optional(), dueDate: z.nullable(z.instanceof(RFCDate).transform(v => v.toString())) .optional(), terms: z.nullable(z.string()).optional(), poNumber: z.nullable(z.string()).optional(), reference: z.nullable(z.string()).optional(), status: z.nullable(InvoiceStatus$outboundSchema).optional(), invoiceSent: z.boolean().optional(), currency: z.nullable(Currency$outboundSchema).optional(), currencyRate: z.nullable(z.number()).optional(), taxInclusive: z.nullable(z.boolean()).optional(), subTotal: z.nullable(z.number()).optional(), totalTax: z.nullable(z.number()).optional(), taxCode: z.nullable(z.string()).optional(), discountPercentage: z.nullable(z.number()).optional(), discountAmount: z.nullable(z.number()).optional(), total: z.nullable(z.number()).optional(), balance: z.nullable(z.number()).optional(), deposit: z.nullable(z.number()).optional(), customerMemo: z.nullable(z.string()).optional(), trackingCategory: z.nullable(DeprecatedLinkedTrackingCategory$outboundSchema) .optional(), trackingCategories: z.nullable(z.array(LinkedTrackingCategory$outboundSchema)) .optional(), lineItems: z.array(InvoiceLineItem$outboundSchema).optional(), billingAddress: Address$outboundSchema.optional(), shippingAddress: Address$outboundSchema.optional(), templateId: z.nullable(z.string()).optional(), sourceDocumentUrl: z.nullable(z.string()).optional(), paymentMethod: z.nullable(z.string()).optional(), channel: z.nullable(z.string()).optional(), language: z.nullable(z.string()).optional(), accountingByRow: z.nullable(z.boolean()).optional(), bankAccount: BankAccount$outboundSchema.optional(), ledgerAccount: z.nullable(LinkedLedgerAccount$outboundSchema).optional(), customMappings: z.nullable(CustomMappings$outboundSchema).optional(), customFields: z.array(CustomField$outboundSchema).optional(), rowVersion: z.nullable(z.string()).optional(), updatedBy: z.nullable(z.string()).optional(), createdBy: z.nullable(z.string()).optional(), updatedAt: z.nullable(z.date().transform(v => v.toISOString())).optional(), createdAt: z.nullable(z.date().transform(v => v.toISOString())).optional(), passThrough: z.array(PassThroughBody$outboundSchema).optional(), }).transform((v) => { return remap$(v, { downstreamId: "downstream_id", companyId: "company_id", invoiceDate: "invoice_date", dueDate: "due_date", poNumber: "po_number", invoiceSent: "invoice_sent", currencyRate: "currency_rate", taxInclusive: "tax_inclusive", subTotal: "sub_total", totalTax: "total_tax", taxCode: "tax_code", discountPercentage: "discount_percentage", discountAmount: "discount_amount", customerMemo: "customer_memo", trackingCategory: "tracking_category", trackingCategories: "tracking_categories", lineItems: "line_items", billingAddress: "billing_address", shippingAddress: "shipping_address", templateId: "template_id", sourceDocumentUrl: "source_document_url", paymentMethod: "payment_method", accountingByRow: "accounting_by_row", bankAccount: "bank_account", ledgerAccount: "ledger_account", customMappings: "custom_mappings", customFields: "custom_fields", rowVersion: "row_version", updatedBy: "updated_by", createdBy: "created_by", updatedAt: "updated_at", createdAt: "created_at", passThrough: "pass_through", }); }); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace Invoice$ { /** @deprecated use `Invoice$inboundSchema` instead. */ export const inboundSchema = Invoice$inboundSchema; /** @deprecated use `Invoice$outboundSchema` instead. */ export const outboundSchema = Invoice$outboundSchema; /** @deprecated use `Invoice$Outbound` instead. */ export type Outbound = Invoice$Outbound; } export function invoiceToJSON(invoice: Invoice): string { return JSON.stringify(Invoice$outboundSchema.parse(invoice)); } export function invoiceFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Invoice$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Invoice' from JSON`, ); } /** @internal */ export const InvoiceInput$inboundSchema: z.ZodType< InvoiceInput, z.ZodTypeDef, unknown > = z.object({ type: z.nullable(InvoiceType$inboundSchema).optional(), number: z.nullable(z.string()).optional(), customer: z.nullable(LinkedCustomerInput$inboundSchema).optional(), company_id: z.nullable(z.string()).optional(), invoice_date: z.nullable(z.string().transform(v => new RFCDate(v))) .optional(), due_date: z.nullable(z.string().transform(v => new RFCDate(v))).optional(), terms: z.nullable(z.string()).optional(), po_number: z.nullable(z.string()).optional(), reference: z.nullable(z.string()).optional(), status: z.nullable(InvoiceStatus$inboundSchema).optional(), invoice_sent: z.boolean().optional(), currency: z.nullable(Currency$inboundSchema).optional(), currency_rate: z.nullable(z.number()).optional(), tax_inclusive: z.nullable(z.boolean()).optional(), sub_total: z.nullable(z.number()).optional(), total_tax: z.nullable(z.number()).optional(), tax_code: z.nullable(z.string()).optional(), discount_percentage: z.nullable(z.number()).optional(), discount_amount: z.nullable(z.number()).optional(), total: z.nullable(z.number()).optional(), balance: z.nullable(z.number()).optional(), deposit: z.nullable(z.number()).optional(), customer_memo: z.nullable(z.string()).optional(), tracking_category: z.nullable(DeprecatedLinkedTrackingCategory$inboundSchema) .optional(), tracking_categories: z.nullable(z.array(LinkedTrackingCategory$inboundSchema)) .optional(), line_items: z.array(InvoiceLineItemInput$inboundSchema).optional(), billing_address: Address$inboundSchema.optional(), shipping_address: Address$inboundSchema.optional(), template_id: z.nullable(z.string()).optional(), source_document_url: z.nullable(z.string()).optional(), payment_method: z.nullable(z.string()).optional(), channel: z.nullable(z.string()).optional(), language: z.nullable(z.string()).optional(), accounting_by_row: z.nullable(z.boolean()).optional(), bank_account: BankAccount$inboundSchema.optional(), ledger_account: z.nullable(LinkedLedgerAccountInput$inboundSchema).optional(), custom_fields: z.array(CustomField$inboundSchema).optional(), row_version: z.nullable(z.string()).optional(), pass_through: z.array(PassThroughBody$inboundSchema).optional(), }).transform((v) => { return remap$(v, { "company_id": "companyId", "invoice_date": "invoiceDate", "due_date": "dueDate", "po_number": "poNumber", "invoice_sent": "invoiceSent", "currency_rate": "currencyRate", "tax_inclusive": "taxInclusive", "sub_total": "subTotal", "total_tax": "totalTax", "tax_code": "taxCode", "discount_percentage": "discountPercentage", "discount_amount": "discountAmount", "customer_memo": "customerMemo", "tracking_category": "trackingCategory", "tracking_categories": "trackingCategories", "line_items": "lineItems", "billing_address": "billingAddress", "shipping_address": "shippingAddress", "template_id": "templateId", "source_document_url": "sourceDocumentUrl", "payment_method": "paymentMethod", "accounting_by_row": "accountingByRow", "bank_account": "bankAccount", "ledger_account": "ledgerAccount", "custom_fields": "customFields", "row_version": "rowVersion", "pass_through": "passThrough", }); }); /** @internal */ export type InvoiceInput$Outbound = { type?: string | null | undefined; number?: string | null | undefined; customer?: LinkedCustomerInput$Outbound | null | undefined; company_id?: string | null | undefined; invoice_date?: string | null | undefined; due_date?: string | null | undefined; terms?: string | null | undefined; po_number?: string | null | undefined; reference?: string | null | undefined; status?: string | null | undefined; invoice_sent?: boolean | undefined; currency?: string | null | undefined; currency_rate?: number | null | undefined; tax_inclusive?: boolean | null | undefined; sub_total?: number | null | undefined; total_tax?: number | null | undefined; tax_code?: string | null | undefined; discount_percentage?: number | null | undefined; discount_amount?: number | null | undefined; total?: number | null | undefined; balance?: number | null | undefined; deposit?: number | null | undefined; customer_memo?: string | null | undefined; tracking_category?: | DeprecatedLinkedTrackingCategory$Outbound | null | undefined; tracking_categories?: | Array | null | undefined; line_items?: Array | undefined; billing_address?: Address$Outbound | undefined; shipping_address?: Address$Outbound | undefined; template_id?: string | null | undefined; source_document_url?: string | null | undefined; payment_method?: string | null | undefined; channel?: string | null | undefined; language?: string | null | undefined; accounting_by_row?: boolean | null | undefined; bank_account?: BankAccount$Outbound | undefined; ledger_account?: LinkedLedgerAccountInput$Outbound | null | undefined; custom_fields?: Array | undefined; row_version?: string | null | undefined; pass_through?: Array | undefined; }; /** @internal */ export const InvoiceInput$outboundSchema: z.ZodType< InvoiceInput$Outbound, z.ZodTypeDef, InvoiceInput > = z.object({ type: z.nullable(InvoiceType$outboundSchema).optional(), number: z.nullable(z.string()).optional(), customer: z.nullable(LinkedCustomerInput$outboundSchema).optional(), companyId: z.nullable(z.string()).optional(), invoiceDate: z.nullable(z.instanceof(RFCDate).transform(v => v.toString())) .optional(), dueDate: z.nullable(z.instanceof(RFCDate).transform(v => v.toString())) .optional(), terms: z.nullable(z.string()).optional(), poNumber: z.nullable(z.string()).optional(), reference: z.nullable(z.string()).optional(), status: z.nullable(InvoiceStatus$outboundSchema).optional(), invoiceSent: z.boolean().optional(), currency: z.nullable(Currency$outboundSchema).optional(), currencyRate: z.nullable(z.number()).optional(), taxInclusive: z.nullable(z.boolean()).optional(), subTotal: z.nullable(z.number()).optional(), totalTax: z.nullable(z.number()).optional(), taxCode: z.nullable(z.string()).optional(), discountPercentage: z.nullable(z.number()).optional(), discountAmount: z.nullable(z.number()).optional(), total: z.nullable(z.number()).optional(), balance: z.nullable(z.number()).optional(), deposit: z.nullable(z.number()).optional(), customerMemo: z.nullable(z.string()).optional(), trackingCategory: z.nullable(DeprecatedLinkedTrackingCategory$outboundSchema) .optional(), trackingCategories: z.nullable(z.array(LinkedTrackingCategory$outboundSchema)) .optional(), lineItems: z.array(InvoiceLineItemInput$outboundSchema).optional(), billingAddress: Address$outboundSchema.optional(), shippingAddress: Address$outboundSchema.optional(), templateId: z.nullable(z.string()).optional(), sourceDocumentUrl: z.nullable(z.string()).optional(), paymentMethod: z.nullable(z.string()).optional(), channel: z.nullable(z.string()).optional(), language: z.nullable(z.string()).optional(), accountingByRow: z.nullable(z.boolean()).optional(), bankAccount: BankAccount$outboundSchema.optional(), ledgerAccount: z.nullable(LinkedLedgerAccountInput$outboundSchema).optional(), customFields: z.array(CustomField$outboundSchema).optional(), rowVersion: z.nullable(z.string()).optional(), passThrough: z.array(PassThroughBody$outboundSchema).optional(), }).transform((v) => { return remap$(v, { companyId: "company_id", invoiceDate: "invoice_date", dueDate: "due_date", poNumber: "po_number", invoiceSent: "invoice_sent", currencyRate: "currency_rate", taxInclusive: "tax_inclusive", subTotal: "sub_total", totalTax: "total_tax", taxCode: "tax_code", discountPercentage: "discount_percentage", discountAmount: "discount_amount", customerMemo: "customer_memo", trackingCategory: "tracking_category", trackingCategories: "tracking_categories", lineItems: "line_items", billingAddress: "billing_address", shippingAddress: "shipping_address", templateId: "template_id", sourceDocumentUrl: "source_document_url", paymentMethod: "payment_method", accountingByRow: "accounting_by_row", bankAccount: "bank_account", ledgerAccount: "ledger_account", customFields: "custom_fields", rowVersion: "row_version", passThrough: "pass_through", }); }); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace InvoiceInput$ { /** @deprecated use `InvoiceInput$inboundSchema` instead. */ export const inboundSchema = InvoiceInput$inboundSchema; /** @deprecated use `InvoiceInput$outboundSchema` instead. */ export const outboundSchema = InvoiceInput$outboundSchema; /** @deprecated use `InvoiceInput$Outbound` instead. */ export type Outbound = InvoiceInput$Outbound; } export function invoiceInputToJSON(invoiceInput: InvoiceInput): string { return JSON.stringify(InvoiceInput$outboundSchema.parse(invoiceInput)); } export function invoiceInputFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => InvoiceInput$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'InvoiceInput' from JSON`, ); }