/* * 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 { 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 { LinkedTrackingCategory, LinkedTrackingCategory$inboundSchema, } from "./linkedtrackingcategory.js"; import { PassThroughBody, PassThroughBody$inboundSchema, } from "./passthroughbody.js"; export type SalesReceipt = { /** * Unique identifier representing the sales receipt */ id: string; /** * Reference number for the sales receipt. */ number?: string | null | undefined; /** * The customer this entity is linked to. */ customer?: LinkedCustomer | 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 sales receipt transaction - YYYY-MM-DDThh:mm:ss.sTZD */ transactionDate?: Date | null | 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 sales receipts. Used when the sales receipt includes product/service details with quantities and pricing. */ lineItems?: 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 sales receipt. */ discountPercentage?: number | null | undefined; /** * Discount amount applied to this sales receipt. */ discountAmount?: number | null | undefined; /** * Optional note to be associated with the sales receipt. */ note?: string | null | undefined; /** * Customer memo */ customerMemo?: string | null | undefined; /** * Optional reference message for the sales receipt. */ reference?: string | null | undefined; billingAddress?: Address | undefined; shippingAddress?: Address | undefined; department?: LinkedDepartment | 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 SalesReceipt$inboundSchema: z.ZodType< SalesReceipt, z.ZodTypeDef, unknown > = /* @__PURE__ */ lazySchema$(() => z.object({ id: types.string(), number: z.nullable(types.string()).optional(), customer: z.nullable(LinkedCustomer$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.nullable(types.number()), total_tax: z.nullable(types.number()).optional(), transaction_date: z.nullable(types.date()).optional(), 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)), 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(), 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", "transaction_date": "transactionDate", "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 salesReceiptFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => SalesReceipt$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'SalesReceipt' from JSON`, ); }