/* * 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 { Allocation, Allocation$inboundSchema, AllocationInput, AllocationInput$Outbound, AllocationInput$outboundSchema, } from "./allocation.js"; import { BillCreditNoteLineItem, BillCreditNoteLineItem$inboundSchema, } from "./billcreditnotelineitem.js"; import { BillCreditNoteLineItemInput, BillCreditNoteLineItemInput$Outbound, BillCreditNoteLineItemInput$outboundSchema, } from "./billcreditnotelineiteminput.js"; import { Currency, Currency$inboundSchema, Currency$outboundSchema, } from "./currency.js"; import { CustomField, CustomField$inboundSchema, CustomField$Outbound, CustomField$outboundSchema, } from "./customfield.js"; import { LinkedDepartment, LinkedDepartment$inboundSchema, } from "./linkeddepartment.js"; import { LinkedDepartmentInput, LinkedDepartmentInput$Outbound, LinkedDepartmentInput$outboundSchema, } from "./linkeddepartmentinput.js"; import { LinkedLedgerAccount, LinkedLedgerAccount$inboundSchema, LinkedLedgerAccount$Outbound, LinkedLedgerAccount$outboundSchema, } from "./linkedledgeraccount.js"; import { LinkedLocation, LinkedLocation$inboundSchema, } from "./linkedlocation.js"; import { LinkedLocationInput, LinkedLocationInput$Outbound, LinkedLocationInput$outboundSchema, } from "./linkedlocationinput.js"; import { LinkedSubsidiary, LinkedSubsidiary$inboundSchema, } from "./linkedsubsidiary.js"; import { LinkedSubsidiaryInput, LinkedSubsidiaryInput$Outbound, LinkedSubsidiaryInput$outboundSchema, } from "./linkedsubsidiaryinput.js"; import { LinkedSupplier, LinkedSupplier$inboundSchema, } from "./linkedsupplier.js"; import { LinkedSupplierInput, LinkedSupplierInput$Outbound, LinkedSupplierInput$outboundSchema, } from "./linkedsupplierinput.js"; import { LinkedTrackingCategory, LinkedTrackingCategory$inboundSchema, LinkedTrackingCategory$Outbound, LinkedTrackingCategory$outboundSchema, } from "./linkedtrackingcategory.js"; import { PassThroughBody, PassThroughBody$inboundSchema, PassThroughBody$Outbound, PassThroughBody$outboundSchema, } from "./passthroughbody.js"; /** * Status of bill credit notes */ export const BillCreditNoteStatus = { Draft: "draft", Authorised: "authorised", Posted: "posted", PartiallyPaid: "partially_paid", Paid: "paid", Voided: "voided", Deleted: "deleted", } as const; /** * Status of bill credit notes */ export type BillCreditNoteStatus = OpenEnum; /** * The type of credit note. A bill credit note is always an accounts payable (supplier-side) credit. */ export const BillCreditNoteType = { AccountsPayableCredit: "accounts_payable_credit", } as const; /** * The type of credit note. A bill credit note is always an accounts payable (supplier-side) credit. */ export type BillCreditNoteType = OpenEnum; export type BillCreditNote = { /** * Unique identifier representing the entity */ id?: string | undefined; /** * Bill credit note number. */ number?: string | null | undefined; /** * The supplier this entity is linked to. */ supplier?: LinkedSupplier | null | undefined; subsidiary?: LinkedSubsidiary | null | undefined; location?: LinkedLocation | null | undefined; department?: LinkedDepartment | 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 | undefined; /** * Total tax amount applied to this bill credit note. */ 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 bill credit notes */ status?: BillCreditNoteStatus | undefined; /** * Optional reference message ie: Debit remittance detail. */ reference?: string | null | undefined; /** * Date bill credit note issued - YYYY:MM::DDThh:mm:ss.sTZD */ dateIssued?: Date | undefined; /** * Date bill credit note paid - YYYY:MM::DDThh:mm:ss.sTZD */ datePaid?: Date | null | undefined; /** * The type of credit note. A bill credit note is always an accounts payable (supplier-side) credit. */ type?: BillCreditNoteType | undefined; account?: LinkedLedgerAccount | null | undefined; lineItems?: Array | undefined; allocations?: Array | undefined; /** * Optional note to be associated with the bill credit note. */ note?: string | null | undefined; /** * Optional terms to be associated with the bill credit note. */ terms?: string | null | undefined; /** * A list of linked tracking categories. */ trackingCategories?: Array | null | undefined; /** * When custom mappings are configured on the resource, the result is included here. */ customMappings?: { [k: string]: any } | 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 BillCreditNoteInput = { /** * Bill credit note number. */ number?: string | null | undefined; /** * The supplier this entity is linked to. */ supplier?: LinkedSupplierInput | null | undefined; subsidiary?: LinkedSubsidiaryInput | null | undefined; location?: LinkedLocationInput | null | undefined; department?: LinkedDepartmentInput | 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 | undefined; /** * Total tax amount applied to this bill credit note. */ 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 bill credit notes */ status?: BillCreditNoteStatus | undefined; /** * Optional reference message ie: Debit remittance detail. */ reference?: string | null | undefined; /** * Date bill credit note issued - YYYY:MM::DDThh:mm:ss.sTZD */ dateIssued?: Date | undefined; /** * Date bill credit note paid - YYYY:MM::DDThh:mm:ss.sTZD */ datePaid?: Date | null | undefined; /** * The type of credit note. A bill credit note is always an accounts payable (supplier-side) credit. */ type?: BillCreditNoteType | undefined; account?: LinkedLedgerAccount | null | undefined; lineItems?: Array | undefined; allocations?: Array | undefined; /** * Optional note to be associated with the bill credit note. */ note?: string | null | undefined; /** * Optional terms to be associated with the bill credit note. */ terms?: string | null | 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 BillCreditNoteStatus$inboundSchema: z.ZodType< BillCreditNoteStatus, z.ZodTypeDef, unknown > = /* @__PURE__ */ lazySchema$(() => openEnums.inboundSchema(BillCreditNoteStatus) ); /** @internal */ export const BillCreditNoteStatus$outboundSchema: z.ZodType< string, z.ZodTypeDef, BillCreditNoteStatus > = /* @__PURE__ */ lazySchema$(() => openEnums.outboundSchema(BillCreditNoteStatus) ); /** @internal */ export const BillCreditNoteType$inboundSchema: z.ZodType< BillCreditNoteType, z.ZodTypeDef, unknown > = /* @__PURE__ */ lazySchema$(() => openEnums.inboundSchema(BillCreditNoteType) ); /** @internal */ export const BillCreditNoteType$outboundSchema: z.ZodType< string, z.ZodTypeDef, BillCreditNoteType > = /* @__PURE__ */ lazySchema$(() => openEnums.outboundSchema(BillCreditNoteType) ); /** @internal */ export const BillCreditNote$inboundSchema: z.ZodType< BillCreditNote, z.ZodTypeDef, unknown > = /* @__PURE__ */ lazySchema$(() => z.object({ id: types.optional(types.string()), number: z.nullable(types.string()).optional(), supplier: z.nullable(LinkedSupplier$inboundSchema).optional(), subsidiary: z.nullable(LinkedSubsidiary$inboundSchema).optional(), location: z.nullable(LinkedLocation$inboundSchema).optional(), department: z.nullable(LinkedDepartment$inboundSchema).optional(), currency: z.nullable(Currency$inboundSchema).optional(), currency_rate: z.nullable(types.number()).optional(), tax_inclusive: z.nullable(types.boolean()).optional(), sub_total: z.nullable(types.number()).optional(), total_amount: types.optional(types.number()), total_tax: z.nullable(types.number()).optional(), tax_code: z.nullable(types.string()).optional(), balance: z.nullable(types.number()).optional(), remaining_credit: z.nullable(types.number()).optional(), status: types.optional(BillCreditNoteStatus$inboundSchema), reference: z.nullable(types.string()).optional(), date_issued: types.optional(types.date()), date_paid: z.nullable(types.date()).optional(), type: types.optional(BillCreditNoteType$inboundSchema), account: z.nullable(LinkedLedgerAccount$inboundSchema).optional(), line_items: types.optional(z.array(BillCreditNoteLineItem$inboundSchema)), allocations: types.optional(z.array(Allocation$inboundSchema)), note: z.nullable(types.string()).optional(), terms: z.nullable(types.string()).optional(), tracking_categories: z.nullable( z.array(types.nullable(LinkedTrackingCategory$inboundSchema)), ).optional(), custom_mappings: z.nullable(z.record(z.any())).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(), updated_at: z.nullable(types.date()).optional(), created_at: z.nullable(types.date()).optional(), pass_through: types.optional(z.array(PassThroughBody$inboundSchema)), }).transform((v) => { return remap$(v, { "currency_rate": "currencyRate", "tax_inclusive": "taxInclusive", "sub_total": "subTotal", "total_amount": "totalAmount", "total_tax": "totalTax", "tax_code": "taxCode", "remaining_credit": "remainingCredit", "date_issued": "dateIssued", "date_paid": "datePaid", "line_items": "lineItems", "tracking_categories": "trackingCategories", "custom_mappings": "customMappings", "custom_fields": "customFields", "row_version": "rowVersion", "updated_by": "updatedBy", "created_by": "createdBy", "updated_at": "updatedAt", "created_at": "createdAt", "pass_through": "passThrough", }); }) ); export function billCreditNoteFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => BillCreditNote$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'BillCreditNote' from JSON`, ); } /** @internal */ export type BillCreditNoteInput$Outbound = { number?: string | null | undefined; supplier?: LinkedSupplierInput$Outbound | null | undefined; subsidiary?: LinkedSubsidiaryInput$Outbound | null | undefined; location?: LinkedLocationInput$Outbound | null | undefined; department?: LinkedDepartmentInput$Outbound | null | undefined; currency?: string | null | undefined; currency_rate?: number | null | undefined; tax_inclusive?: boolean | null | undefined; sub_total?: number | null | undefined; total_amount?: number | undefined; 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; tracking_categories?: | Array | null | undefined; custom_fields?: Array | undefined; row_version?: string | null | undefined; pass_through?: Array | undefined; }; /** @internal */ export const BillCreditNoteInput$outboundSchema: z.ZodType< BillCreditNoteInput$Outbound, z.ZodTypeDef, BillCreditNoteInput > = /* @__PURE__ */ lazySchema$(() => z.object({ number: z.nullable(z.string()).optional(), supplier: z.nullable(LinkedSupplierInput$outboundSchema).optional(), subsidiary: z.nullable(LinkedSubsidiaryInput$outboundSchema).optional(), location: z.nullable(LinkedLocationInput$outboundSchema).optional(), department: z.nullable(LinkedDepartmentInput$outboundSchema).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().optional(), 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: BillCreditNoteStatus$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: BillCreditNoteType$outboundSchema.optional(), account: z.nullable(LinkedLedgerAccount$outboundSchema).optional(), lineItems: z.array(BillCreditNoteLineItemInput$outboundSchema).optional(), allocations: z.array(AllocationInput$outboundSchema).optional(), note: z.nullable(z.string()).optional(), terms: z.nullable(z.string()).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, { 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", trackingCategories: "tracking_categories", customFields: "custom_fields", rowVersion: "row_version", passThrough: "pass_through", }); }) ); export function billCreditNoteInputToJSON( billCreditNoteInput: BillCreditNoteInput, ): string { return JSON.stringify( BillCreditNoteInput$outboundSchema.parse(billCreditNoteInput), ); }