/* * 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 { BankAccount, BankAccount$Outbound, BankAccount$outboundSchema, } from "./bankaccount.js"; import { BillLineItemInput, BillLineItemInput$Outbound, BillLineItemInput$outboundSchema, } from "./billlineiteminput.js"; import { Currency, Currency$outboundSchema } from "./currency.js"; import { CustomField, CustomField$Outbound, CustomField$outboundSchema, } from "./customfield.js"; import { LinkedAttachment, LinkedAttachment$Outbound, LinkedAttachment$outboundSchema, } from "./linkedattachment.js"; import { LinkedLedgerAccount, LinkedLedgerAccount$Outbound, LinkedLedgerAccount$outboundSchema, } from "./linkedledgeraccount.js"; import { LinkedPaymentAllocations, LinkedPaymentAllocations$Outbound, LinkedPaymentAllocations$outboundSchema, } from "./linkedpaymentallocations.js"; import { LinkedSubsidiaryInput, LinkedSubsidiaryInput$Outbound, LinkedSubsidiaryInput$outboundSchema, } from "./linkedsubsidiaryinput.js"; import { LinkedSupplierInput, LinkedSupplierInput$Outbound, LinkedSupplierInput$outboundSchema, } from "./linkedsupplierinput.js"; import { LinkedTrackingCategory, LinkedTrackingCategory$Outbound, LinkedTrackingCategory$outboundSchema, } from "./linkedtrackingcategory.js"; import { PassThroughBody, PassThroughBody$Outbound, PassThroughBody$outboundSchema, } from "./passthroughbody.js"; /** * Invoice status */ export const BillCreateInputStatus = { Draft: "draft", Submitted: "submitted", Authorised: "authorised", PartiallyPaid: "partially_paid", Paid: "paid", Void: "void", Credit: "credit", Deleted: "deleted", Posted: "posted", } as const; /** * Invoice status */ export type BillCreateInputStatus = OpenEnum; /** * Type of amortization */ export const BillCreateInputAmortizationType = { Manual: "manual", Receipt: "receipt", Schedule: "schedule", Other: "other", } as const; /** * Type of amortization */ export type BillCreateInputAmortizationType = OpenEnum< typeof BillCreateInputAmortizationType >; /** * The writable shape of Bill for a batch create. Identical to [Bill](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 BillCreateInput = { /** * Id to be displayed. */ displayId?: string | null | undefined; /** * Reference to supplier bill number */ billNumber?: string | null | undefined; /** * The supplier this entity is linked to. */ supplier?: LinkedSupplierInput | 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; /** * 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; /** * Date bill was issued - YYYY-MM-DD. */ billDate?: Date | null | undefined; /** * The due date is the date on which a payment is scheduled to be received - YYYY-MM-DD. */ dueDate?: Date | null | undefined; /** * The paid date is the date on which a payment was sent to the supplier - YYYY-MM-DD. */ paidDate?: Date | 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; lineItems?: Array | undefined; /** * Terms of payment. */ terms?: string | null | undefined; /** * The ID of the payment terms */ termsId?: string | null | undefined; /** * Balance of bill due. */ balance?: number | null | undefined; /** * Amount of deposit made to this bill. */ deposit?: number | null | undefined; /** * Subtotal amount, normally before tax. */ subTotal?: number | null | undefined; /** * Total tax amount applied to this transaction. */ totalTax?: number | null | undefined; /** * Total amount of bill, including tax. */ total?: number | null | undefined; /** * Applicable tax id/code override if tax is not supplied on a line item basis. */ taxCode?: string | null | undefined; notes?: string | null | undefined; /** * Invoice status */ status?: BillCreateInputStatus | null | undefined; ledgerAccount?: LinkedLedgerAccount | 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; /** * Discount percentage applied to this transaction. */ discountPercentage?: number | null | undefined; /** * Optional bill template */ templateId?: string | null | undefined; /** * The user who approved the bill */ approvedBy?: string | null | undefined; /** * Type of amortization */ amortizationType?: BillCreateInputAmortizationType | null | undefined; /** * Method of tax calculation */ taxMethod?: string | null | undefined; /** * Whether the document has been received */ documentReceived?: boolean | 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; /** * A list of linked payment allocations. */ paymentAllocations?: | Array | null | undefined; /** * A list of linked tracking categories. */ trackingCategories?: Array | 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; customFields?: Array | 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; /** * Accounting period */ accountingPeriod?: string | null | undefined; attachments?: Array | undefined; }; /** @internal */ export const BillCreateInputStatus$outboundSchema: z.ZodType< string, z.ZodTypeDef, BillCreateInputStatus > = /* @__PURE__ */ lazySchema$(() => openEnums.outboundSchema(BillCreateInputStatus) ); /** @internal */ export const BillCreateInputAmortizationType$outboundSchema: z.ZodType< string, z.ZodTypeDef, BillCreateInputAmortizationType > = /* @__PURE__ */ lazySchema$(() => openEnums.outboundSchema(BillCreateInputAmortizationType) ); /** @internal */ export type BillCreateInput$Outbound = { display_id?: string | null | undefined; bill_number?: string | null | undefined; supplier?: LinkedSupplierInput$Outbound | null | undefined; company_id?: string | null | undefined; subsidiary?: LinkedSubsidiaryInput$Outbound | null | undefined; location_id?: string | null | undefined; department_id?: string | null | undefined; currency?: string | null | undefined; currency_rate?: number | null | undefined; tax_inclusive?: boolean | null | undefined; bill_date?: string | null | undefined; due_date?: string | null | undefined; paid_date?: string | null | undefined; po_number?: string | null | undefined; reference?: string | null | undefined; line_items?: Array | undefined; terms?: string | null | undefined; terms_id?: string | null | undefined; balance?: number | null | undefined; deposit?: number | null | undefined; sub_total?: number | null | undefined; total_tax?: number | null | undefined; total?: number | null | undefined; tax_code?: string | null | undefined; notes?: string | null | undefined; status?: string | null | undefined; ledger_account?: LinkedLedgerAccount$Outbound | 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; discount_percentage?: number | null | undefined; template_id?: string | null | undefined; approved_by?: string | null | undefined; amortization_type?: string | null | undefined; tax_method?: string | null | undefined; document_received?: boolean | null | undefined; source_document_url?: string | null | undefined; payment_allocations?: | Array | null | undefined; tracking_categories?: | Array | null | undefined; row_version?: string | null | undefined; custom_fields?: Array | undefined; pass_through?: Array | undefined; accounting_period?: string | null | undefined; attachments?: Array | undefined; }; /** @internal */ export const BillCreateInput$outboundSchema: z.ZodType< BillCreateInput$Outbound, z.ZodTypeDef, BillCreateInput > = /* @__PURE__ */ lazySchema$(() => z.object({ displayId: z.nullable(z.string()).optional(), billNumber: z.nullable(z.string()).optional(), supplier: z.nullable(LinkedSupplierInput$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(), currency: z.nullable(Currency$outboundSchema).optional(), currencyRate: z.nullable(z.number()).optional(), taxInclusive: z.nullable(z.boolean()).optional(), billDate: 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(), paidDate: z.nullable( z.date().transform(v => v.toISOString().slice(0, "YYYY-MM-DD".length)), ).optional(), poNumber: z.nullable(z.string()).optional(), reference: z.nullable(z.string()).optional(), lineItems: z.array(BillLineItemInput$outboundSchema).optional(), terms: z.nullable(z.string()).optional(), termsId: z.nullable(z.string()).optional(), balance: z.nullable(z.number()).optional(), deposit: z.nullable(z.number()).optional(), subTotal: z.nullable(z.number()).optional(), totalTax: z.nullable(z.number()).optional(), total: z.nullable(z.number()).optional(), taxCode: z.nullable(z.string()).optional(), notes: z.nullable(z.string()).optional(), status: z.nullable(BillCreateInputStatus$outboundSchema).optional(), ledgerAccount: z.nullable(LinkedLedgerAccount$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(), discountPercentage: z.nullable(z.number()).optional(), templateId: z.nullable(z.string()).optional(), approvedBy: z.nullable(z.string()).optional(), amortizationType: z.nullable(BillCreateInputAmortizationType$outboundSchema) .optional(), taxMethod: z.nullable(z.string()).optional(), documentReceived: z.nullable(z.boolean()).optional(), sourceDocumentUrl: z.nullable(z.string()).optional(), paymentAllocations: z.nullable( z.array(z.nullable(LinkedPaymentAllocations$outboundSchema)), ).optional(), trackingCategories: z.nullable( z.array(z.nullable(LinkedTrackingCategory$outboundSchema)), ).optional(), rowVersion: z.nullable(z.string()).optional(), customFields: z.array(CustomField$outboundSchema).optional(), passThrough: z.array(PassThroughBody$outboundSchema).optional(), accountingPeriod: z.nullable(z.string()).optional(), attachments: z.array(z.nullable(LinkedAttachment$outboundSchema)) .optional(), }).transform((v) => { return remap$(v, { displayId: "display_id", billNumber: "bill_number", companyId: "company_id", locationId: "location_id", departmentId: "department_id", currencyRate: "currency_rate", taxInclusive: "tax_inclusive", billDate: "bill_date", dueDate: "due_date", paidDate: "paid_date", poNumber: "po_number", lineItems: "line_items", termsId: "terms_id", subTotal: "sub_total", totalTax: "total_tax", taxCode: "tax_code", ledgerAccount: "ledger_account", paymentMethod: "payment_method", accountingByRow: "accounting_by_row", bankAccount: "bank_account", discountPercentage: "discount_percentage", templateId: "template_id", approvedBy: "approved_by", amortizationType: "amortization_type", taxMethod: "tax_method", documentReceived: "document_received", sourceDocumentUrl: "source_document_url", paymentAllocations: "payment_allocations", trackingCategories: "tracking_categories", rowVersion: "row_version", customFields: "custom_fields", passThrough: "pass_through", accountingPeriod: "accounting_period", }); }) ); export function billCreateInputToJSON( billCreateInput: BillCreateInput, ): string { return JSON.stringify(BillCreateInput$outboundSchema.parse(billCreateInput)); }