/* * 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 { Result as SafeParseResult } from "../../types/fp.js"; import * as types from "../../types/primitives.js"; import { SDKValidationError } from "../errors/sdkvalidationerror.js"; import { Address, Address$inboundSchema } from "./address.js"; import { Allocation, Allocation$inboundSchema } from "./allocation.js"; import { Currency, Currency$inboundSchema } from "./currency.js"; import { CustomField, CustomField$inboundSchema } from "./customfield.js"; import { InvoiceLineItem, InvoiceLineItem$inboundSchema, } from "./invoicelineitem.js"; import { LinkedCustomer, LinkedCustomer$inboundSchema, } from "./linkedcustomer.js"; import { LinkedDepartment, LinkedDepartment$inboundSchema, } from "./linkeddepartment.js"; import { LinkedLedgerAccount, LinkedLedgerAccount$inboundSchema, } from "./linkedledgeraccount.js"; import { LinkedLocation, LinkedLocation$inboundSchema, } from "./linkedlocation.js"; import { LinkedTrackingCategory, LinkedTrackingCategory$inboundSchema, } from "./linkedtrackingcategory.js"; import { PassThroughBody, PassThroughBody$inboundSchema, } from "./passthroughbody.js"; import { RefundStatus, RefundStatus$inboundSchema } from "./refundstatus.js"; import { RefundType, RefundType$inboundSchema } from "./refundtype.js"; export type Refund = { /** * Unique identifier representing the refund */ id: string; /** * Reference number for the refund. */ number?: string | null | undefined; /** * The customer this entity is linked to. */ customer?: LinkedCustomer | null | undefined; /** * The company ID the transaction belongs to */ companyId?: 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; /** * Subtotal amount, normally before tax. */ subTotal?: number | null | undefined; /** * The total amount of the transaction or record */ totalAmount: number | null; /** * Total tax amount applied to this transaction. */ totalTax?: number | null | undefined; /** * The date of the refund - YYYY-MM-DDThh:mm:ss.sTZD */ refundDate?: Date | null | undefined; /** * Status of refund. Maps to: QBO (limited status), NetSuite CashRefund status, Sage Intacct state (draft/posted/voided), Zoho Books vis_state. */ status?: RefundStatus | undefined; /** * Type of refund. `refund_receipt` for itemized refunds with product/service lines and payment (QBO RefundReceipt; also NetSuite's apply-list-based CustomerRefund). `cash_refund` for cash-out refunds with GL distribution or allocations (Sage Intacct). `credit_note_refund` for refunds applied against a credit note (Zoho Books). `sale_refund` for itemized refunds tied to a cash sale or return authorization, without an apply-list (NetSuite CashRefund) — NetSuite's apply-list-based CustomerRefund reports as `refund_receipt` instead. */ type?: RefundType | undefined; /** * Payment method used for the transaction, such as cash, credit card, bank transfer, or check */ paymentMethod?: string | null | undefined; /** * Optional reference message returned by payment method on processing */ paymentMethodReference?: string | null | undefined; /** * A unique identifier for an object. */ paymentMethodId?: string | null | undefined; account?: LinkedLedgerAccount | null | undefined; /** * Line items for itemized refunds (type: refund_receipt or sale_refund). Used when the refund includes product/service details with quantities and pricing. Supported by QBO RefundReceipt and NetSuite CashRefund. */ lineItems?: Array | undefined; /** * Allocations linking refund to existing documents (invoices, credit notes, overpayments). Used for credit_note_refund and cash_refund types where the refund is applied against prior transactions. Supported by Sage Intacct and Zoho Books. */ allocations?: Array | 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 refund. */ discountPercentage?: number | null | undefined; /** * Discount amount applied to this refund. */ discountAmount?: number | null | undefined; /** * Optional note to be associated with the refund. */ note?: string | null | undefined; /** * Customer memo */ customerMemo?: string | null | undefined; /** * Optional reference message for the refund. */ reference?: string | null | undefined; billingAddress?: Address | undefined; shippingAddress?: Address | undefined; department?: LinkedDepartment | null | undefined; location?: LinkedLocation | 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; }; /** @internal */ export const Refund$inboundSchema: z.ZodType = /* @__PURE__ */ lazySchema$(() => z.object({ id: types.string(), number: z.nullable(types.string()).optional(), customer: z.nullable(LinkedCustomer$inboundSchema).optional(), company_id: z.nullable(types.string()).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.nullable(types.number()), total_tax: z.nullable(types.number()).optional(), refund_date: z.nullable(types.date()).optional(), status: types.optional(RefundStatus$inboundSchema), type: types.optional(RefundType$inboundSchema), payment_method: z.nullable(types.string()).optional(), payment_method_reference: z.nullable(types.string()).optional(), payment_method_id: z.nullable(types.string()).optional(), account: z.nullable(LinkedLedgerAccount$inboundSchema).optional(), line_items: types.optional(z.array(InvoiceLineItem$inboundSchema)), allocations: types.optional(z.array(Allocation$inboundSchema)), tax_code: z.nullable(types.string()).optional(), discount_percentage: z.nullable(types.number()).optional(), discount_amount: z.nullable(types.number()).optional(), note: z.nullable(types.string()).optional(), customer_memo: z.nullable(types.string()).optional(), reference: z.nullable(types.string()).optional(), billing_address: types.optional(Address$inboundSchema), shipping_address: types.optional(Address$inboundSchema), department: z.nullable(LinkedDepartment$inboundSchema).optional(), location: z.nullable(LinkedLocation$inboundSchema).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, { "company_id": "companyId", "currency_rate": "currencyRate", "tax_inclusive": "taxInclusive", "sub_total": "subTotal", "total_amount": "totalAmount", "total_tax": "totalTax", "refund_date": "refundDate", "payment_method": "paymentMethod", "payment_method_reference": "paymentMethodReference", "payment_method_id": "paymentMethodId", "line_items": "lineItems", "tax_code": "taxCode", "discount_percentage": "discountPercentage", "discount_amount": "discountAmount", "customer_memo": "customerMemo", "billing_address": "billingAddress", "shipping_address": "shippingAddress", "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 refundFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Refund$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Refund' from JSON`, ); }