/* * 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 { AllocationInput, AllocationInput$Outbound, AllocationInput$outboundSchema, } from "./allocation.js"; import { Currency, Currency$outboundSchema } from "./currency.js"; import { CustomField, CustomField$Outbound, CustomField$outboundSchema, } from "./customfield.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 { 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"; /** * Status of credit notes */ export const CreditNoteCreateInputCreditNoteStatus = { Draft: "draft", Authorised: "authorised", Posted: "posted", PartiallyPaid: "partially_paid", Paid: "paid", Voided: "voided", Deleted: "deleted", } as const; /** * Status of credit notes */ export type CreditNoteCreateInputCreditNoteStatus = OpenEnum< typeof CreditNoteCreateInputCreditNoteStatus >; /** * Whether this credit note reduces an amount owed by a customer (accounts receivable) or owed to a supplier (accounts payable). `accounts_payable_credit` support is connector-specific — most connectors only expose the accounts-receivable side. Check the connector's gotchas for known deviations. */ export const CreditNoteCreateInputCreditNoteType = { AccountsReceivableCredit: "accounts_receivable_credit", AccountsPayableCredit: "accounts_payable_credit", } as const; /** * Whether this credit note reduces an amount owed by a customer (accounts receivable) or owed to a supplier (accounts payable). `accounts_payable_credit` support is connector-specific — most connectors only expose the accounts-receivable side. Check the connector's gotchas for known deviations. */ export type CreditNoteCreateInputCreditNoteType = OpenEnum< typeof CreditNoteCreateInputCreditNoteType >; /** * The writable shape of CreditNote for a batch create. Identical to [CreditNote](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 CreditNoteCreateInput = { /** * Credit note 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; /** * 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; /** * Amount of transaction */ totalAmount: number; /** * 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; /** * The balance reflecting any payments made against the transaction. */ balance?: number | null | undefined; /** * Indicates the total credit amount still available to apply towards the payment. */ remainingCredit?: number | null | undefined; /** * Status of credit notes */ status?: CreditNoteCreateInputCreditNoteStatus | undefined; /** * Optional reference message ie: Debit remittance detail. */ reference?: string | null | undefined; /** * Date credit note issued - YYYY:MM::DDThh:mm:ss.sTZD */ dateIssued?: Date | undefined; /** * Date credit note paid - YYYY:MM::DDThh:mm:ss.sTZD */ datePaid?: Date | null | undefined; /** * Whether this credit note reduces an amount owed by a customer (accounts receivable) or owed to a supplier (accounts payable). `accounts_payable_credit` support is connector-specific — most connectors only expose the accounts-receivable side. Check the connector's gotchas for known deviations. */ type?: CreditNoteCreateInputCreditNoteType | undefined; account?: LinkedLedgerAccount | null | undefined; lineItems?: Array | undefined; allocations?: Array | undefined; /** * Optional note to be associated with the credit note. */ note?: string | null | undefined; /** * Optional terms to be associated with the credit note. */ terms?: string | null | undefined; /** * The ID of the payment terms */ termsId?: string | null | undefined; billingAddress?: Address | undefined; shippingAddress?: Address | undefined; /** * A list of linked tracking categories. */ trackingCategories?: Array | 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 CreditNoteCreateInputCreditNoteStatus$outboundSchema: z.ZodType< string, z.ZodTypeDef, CreditNoteCreateInputCreditNoteStatus > = /* @__PURE__ */ lazySchema$(() => openEnums.outboundSchema(CreditNoteCreateInputCreditNoteStatus) ); /** @internal */ export const CreditNoteCreateInputCreditNoteType$outboundSchema: z.ZodType< string, z.ZodTypeDef, CreditNoteCreateInputCreditNoteType > = /* @__PURE__ */ lazySchema$(() => openEnums.outboundSchema(CreditNoteCreateInputCreditNoteType) ); /** @internal */ export type CreditNoteCreateInput$Outbound = { 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; currency?: string | null | undefined; currency_rate?: number | null | undefined; tax_inclusive?: boolean | null | undefined; sub_total?: number | null | undefined; total_amount: number; total_tax?: number | null | undefined; tax_code?: string | null | undefined; balance?: number | null | undefined; remaining_credit?: number | null | undefined; status?: string | undefined; reference?: string | null | undefined; date_issued?: string | undefined; date_paid?: string | null | undefined; type?: string | undefined; account?: LinkedLedgerAccount$Outbound | null | undefined; line_items?: Array | undefined; allocations?: Array | undefined; note?: string | null | undefined; terms?: string | null | undefined; terms_id?: string | null | undefined; billing_address?: Address$Outbound | undefined; shipping_address?: Address$Outbound | undefined; tracking_categories?: | Array | null | undefined; custom_fields?: Array | undefined; row_version?: string | null | undefined; pass_through?: Array | undefined; }; /** @internal */ export const CreditNoteCreateInput$outboundSchema: z.ZodType< CreditNoteCreateInput$Outbound, z.ZodTypeDef, CreditNoteCreateInput > = /* @__PURE__ */ lazySchema$(() => z.object({ 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(), currency: z.nullable(Currency$outboundSchema).optional(), currencyRate: z.nullable(z.number()).optional(), taxInclusive: z.nullable(z.boolean()).optional(), subTotal: z.nullable(z.number()).optional(), totalAmount: z.number(), totalTax: z.nullable(z.number()).optional(), taxCode: z.nullable(z.string()).optional(), balance: z.nullable(z.number()).optional(), remainingCredit: z.nullable(z.number()).optional(), status: CreditNoteCreateInputCreditNoteStatus$outboundSchema.optional(), reference: z.nullable(z.string()).optional(), dateIssued: z.date().transform(v => v.toISOString()).optional(), datePaid: z.nullable(z.date().transform(v => v.toISOString())).optional(), type: CreditNoteCreateInputCreditNoteType$outboundSchema.optional(), account: z.nullable(LinkedLedgerAccount$outboundSchema).optional(), lineItems: z.array(InvoiceLineItemInput$outboundSchema).optional(), allocations: z.array(AllocationInput$outboundSchema).optional(), note: z.nullable(z.string()).optional(), terms: z.nullable(z.string()).optional(), termsId: z.nullable(z.string()).optional(), billingAddress: Address$outboundSchema.optional(), shippingAddress: Address$outboundSchema.optional(), trackingCategories: z.nullable( z.array(z.nullable(LinkedTrackingCategory$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", locationId: "location_id", departmentId: "department_id", currencyRate: "currency_rate", taxInclusive: "tax_inclusive", subTotal: "sub_total", totalAmount: "total_amount", totalTax: "total_tax", taxCode: "tax_code", remainingCredit: "remaining_credit", dateIssued: "date_issued", datePaid: "date_paid", lineItems: "line_items", termsId: "terms_id", billingAddress: "billing_address", shippingAddress: "shipping_address", trackingCategories: "tracking_categories", customFields: "custom_fields", rowVersion: "row_version", passThrough: "pass_through", }); }) ); export function creditNoteCreateInputToJSON( creditNoteCreateInput: CreditNoteCreateInput, ): string { return JSON.stringify( CreditNoteCreateInput$outboundSchema.parse(creditNoteCreateInput), ); }