/* * 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$ } from "../../lib/schemas.js"; import * as openEnums from "../../types/enums.js"; import { OpenEnum } from "../../types/enums.js"; import { Address, Address$Outbound, Address$outboundSchema, } from "./address.js"; import { BankAccount, BankAccount$Outbound, BankAccount$outboundSchema, } from "./bankaccount.js"; import { Currency, Currency$outboundSchema } from "./currency.js"; import { CustomField, CustomField$Outbound, CustomField$outboundSchema, } from "./customfield.js"; import { DeprecatedLinkedTrackingCategory, DeprecatedLinkedTrackingCategory$Outbound, DeprecatedLinkedTrackingCategory$outboundSchema, } from "./deprecatedlinkedtrackingcategory.js"; import { InvoiceLineItemInput, InvoiceLineItemInput$Outbound, InvoiceLineItemInput$outboundSchema, } from "./invoicelineitem.js"; import { LinkedCustomerInput, LinkedCustomerInput$Outbound, LinkedCustomerInput$outboundSchema, } from "./linkedcustomerinput.js"; import { LinkedLedgerAccount, LinkedLedgerAccount$Outbound, LinkedLedgerAccount$outboundSchema, } from "./linkedledgeraccount.js"; import { LinkedQuotesInput, LinkedQuotesInput$Outbound, LinkedQuotesInput$outboundSchema, } from "./linkedquotesinput.js"; import { LinkedSubsidiaryInput, LinkedSubsidiaryInput$Outbound, LinkedSubsidiaryInput$outboundSchema, } from "./linkedsubsidiaryinput.js"; import { LinkedTrackingCategory, LinkedTrackingCategory$Outbound, LinkedTrackingCategory$outboundSchema, } from "./linkedtrackingcategory.js"; import { PassThroughBody, PassThroughBody$Outbound, PassThroughBody$outboundSchema, } from "./passthroughbody.js"; /** * Invoice type */ export const InvoiceCreateInputInvoiceType = { Standard: "standard", Credit: "credit", Service: "service", Product: "product", Supplier: "supplier", Other: "other", } as const; /** * Invoice type */ export type InvoiceCreateInputInvoiceType = OpenEnum< typeof InvoiceCreateInputInvoiceType >; /** * Invoice status */ export const InvoiceCreateInputStatus = { Draft: "draft", Submitted: "submitted", Authorised: "authorised", PartiallyPaid: "partially_paid", Paid: "paid", Unpaid: "unpaid", Void: "void", Credit: "credit", Deleted: "deleted", Posted: "posted", } as const; /** * Invoice status */ export type InvoiceCreateInputStatus = OpenEnum< typeof InvoiceCreateInputStatus >; export type InvoiceCreateInputPaymentAllocations = { /** * ID of the payment */ id?: string | undefined; /** * Amount of the payment allocated to the invoice */ allocatedAmount?: number | null | undefined; /** * Date of the payment */ date?: Date | null | undefined; }; /** * The writable shape of Invoice for a batch create. Identical to [Invoice](the model returned on reads) with the read-only properties removed — the same properties the single-record create endpoint rejects, so a batched record and a single-record create accept exactly the same body. */ export type InvoiceCreateInput = { /** * Id to be displayed. */ displayId?: string | null | undefined; /** * Invoice type */ type?: InvoiceCreateInputInvoiceType | null | undefined; /** * Invoice number. */ number?: string | null | undefined; /** * The customer this entity is linked to. */ customer?: LinkedCustomerInput | null | undefined; /** * The company ID the transaction belongs to */ companyId?: string | null | undefined; subsidiary?: LinkedSubsidiaryInput | null | undefined; /** * The ID of the location */ locationId?: string | null | undefined; /** * The ID of the department */ departmentId?: string | null | undefined; /** * Date invoice was issued - YYYY-MM-DD. */ invoiceDate?: Date | 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?: Date | null | undefined; /** * Terms of payment. */ terms?: string | null | undefined; /** * The ID of the payment terms */ termsId?: 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 reference identifier for the transaction. */ reference?: string | null | undefined; /** * Invoice status */ status?: InvoiceCreateInputStatus | 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 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; 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; /** * IDs of payments made on the invoice */ paymentAllocations?: | Array | null | undefined; /** * A list of quotes linked to this record. */ quotes?: Array | 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; 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 InvoiceCreateInputInvoiceType$outboundSchema: z.ZodType< string, z.ZodTypeDef, InvoiceCreateInputInvoiceType > = /* @__PURE__ */ lazySchema$(() => openEnums.outboundSchema(InvoiceCreateInputInvoiceType) ); /** @internal */ export const InvoiceCreateInputStatus$outboundSchema: z.ZodType< string, z.ZodTypeDef, InvoiceCreateInputStatus > = /* @__PURE__ */ lazySchema$(() => openEnums.outboundSchema(InvoiceCreateInputStatus) ); /** @internal */ export type InvoiceCreateInputPaymentAllocations$Outbound = { id?: string | undefined; allocated_amount?: number | null | undefined; date?: string | null | undefined; }; /** @internal */ export const InvoiceCreateInputPaymentAllocations$outboundSchema: z.ZodType< InvoiceCreateInputPaymentAllocations$Outbound, z.ZodTypeDef, InvoiceCreateInputPaymentAllocations > = /* @__PURE__ */ lazySchema$(() => z.object({ id: z.string().optional(), allocatedAmount: z.nullable(z.number()).optional(), date: z.nullable(z.date().transform(v => v.toISOString())).optional(), }).transform((v) => { return remap$(v, { allocatedAmount: "allocated_amount", }); }) ); export function invoiceCreateInputPaymentAllocationsToJSON( invoiceCreateInputPaymentAllocations: InvoiceCreateInputPaymentAllocations, ): string { return JSON.stringify( InvoiceCreateInputPaymentAllocations$outboundSchema.parse( invoiceCreateInputPaymentAllocations, ), ); } /** @internal */ export type InvoiceCreateInput$Outbound = { display_id?: string | null | undefined; type?: string | null | undefined; number?: string | null | undefined; customer?: LinkedCustomerInput$Outbound | null | undefined; company_id?: string | null | undefined; subsidiary?: LinkedSubsidiaryInput$Outbound | null | undefined; location_id?: string | null | undefined; department_id?: string | null | undefined; invoice_date?: string | null | undefined; due_date?: string | null | undefined; terms?: string | null | undefined; terms_id?: 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_allocations?: | Array | null | undefined; quotes?: Array | 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_fields?: Array | undefined; row_version?: string | null | undefined; pass_through?: Array | undefined; }; /** @internal */ export const InvoiceCreateInput$outboundSchema: z.ZodType< InvoiceCreateInput$Outbound, z.ZodTypeDef, InvoiceCreateInput > = /* @__PURE__ */ lazySchema$(() => z.object({ displayId: z.nullable(z.string()).optional(), type: z.nullable(InvoiceCreateInputInvoiceType$outboundSchema).optional(), number: z.nullable(z.string()).optional(), customer: z.nullable(LinkedCustomerInput$outboundSchema).optional(), companyId: z.nullable(z.string()).optional(), subsidiary: z.nullable(LinkedSubsidiaryInput$outboundSchema).optional(), locationId: z.nullable(z.string()).optional(), departmentId: z.nullable(z.string()).optional(), invoiceDate: z.nullable( z.date().transform(v => v.toISOString().slice(0, "YYYY-MM-DD".length)), ).optional(), dueDate: z.nullable( z.date().transform(v => v.toISOString().slice(0, "YYYY-MM-DD".length)), ).optional(), terms: z.nullable(z.string()).optional(), termsId: z.nullable(z.string()).optional(), poNumber: z.nullable(z.string()).optional(), reference: z.nullable(z.string()).optional(), status: z.nullable(InvoiceCreateInputStatus$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(z.nullable(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(), paymentAllocations: z.nullable( z.array( z.lazy(() => InvoiceCreateInputPaymentAllocations$outboundSchema), ), ).optional(), quotes: z.nullable(z.array(LinkedQuotesInput$outboundSchema)).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(), customFields: z.array(CustomField$outboundSchema).optional(), rowVersion: z.nullable(z.string()).optional(), passThrough: z.array(PassThroughBody$outboundSchema).optional(), }).transform((v) => { return remap$(v, { displayId: "display_id", companyId: "company_id", locationId: "location_id", departmentId: "department_id", invoiceDate: "invoice_date", dueDate: "due_date", termsId: "terms_id", 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", paymentAllocations: "payment_allocations", paymentMethod: "payment_method", accountingByRow: "accounting_by_row", bankAccount: "bank_account", ledgerAccount: "ledger_account", customFields: "custom_fields", rowVersion: "row_version", passThrough: "pass_through", }); }) ); export function invoiceCreateInputToJSON( invoiceCreateInput: InvoiceCreateInput, ): string { return JSON.stringify( InvoiceCreateInput$outboundSchema.parse(invoiceCreateInput), ); }