/* * 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 { Currency, Currency$inboundSchema } from "./currency.js"; import { CustomField, CustomField$inboundSchema } from "./customfield.js"; import { GoodsReceiptLineItem, GoodsReceiptLineItem$inboundSchema, } from "./goodsreceiptlineitem.js"; import { LinkedSupplier, LinkedSupplier$inboundSchema, } from "./linkedsupplier.js"; import { LinkedTrackingCategory, LinkedTrackingCategory$inboundSchema, } from "./linkedtrackingcategory.js"; /** * Lifecycle status of the receipt. `draft` covers unposted or awaiting-validation documents, `pending_approval` covers documents submitted into an approval flow, `received` covers posted/validated/released receipts that have affected stock or the receiving ledger, `cancelled` covers voided, reversed or denied receipts. */ export const GoodsReceiptStatus = { Draft: "draft", PendingApproval: "pending_approval", Received: "received", Cancelled: "cancelled", Other: "other", } as const; /** * Lifecycle status of the receipt. `draft` covers unposted or awaiting-validation documents, `pending_approval` covers documents submitted into an approval flow, `received` covers posted/validated/released receipts that have affected stock or the receiving ledger, `cancelled` covers voided, reversed or denied receipts. */ export type GoodsReceiptStatus = OpenEnum; export type GoodsReceipt = { /** * A unique identifier for an object. */ id: string; /** * The third-party API ID of original entity */ downstreamId?: string | null | undefined; /** * Id to be displayed. */ displayId?: string | null | undefined; /** * Human-readable document number of the goods receipt as shown in the accounting system. */ receiptNumber?: string | null | undefined; /** * Supplier-side reference recorded on the receipt, typically the supplier's delivery note or packing slip number. */ reference?: string | null | undefined; /** * ID of the purchase order this receipt was created against. Populated when every line of the receipt belongs to the same purchase order, or when the accounting system itself records a single originating purchase order on the receipt (see the connector gotchas); otherwise null, and the per-line `line_items[].purchase_order` carries the link. */ purchaseOrderId?: string | null | undefined; /** * Human-readable number of the purchase order this receipt was created against. */ poNumber?: string | null | undefined; /** * The supplier this entity is linked to. */ supplier?: LinkedSupplier | null | undefined; /** * The company ID the transaction belongs to */ companyId?: string | null | undefined; /** * The ID of the subsidiary */ subsidiaryId?: string | null | undefined; /** * ID of the warehouse or location the goods were received into. */ locationId?: string | null | undefined; /** * The ID of the department */ departmentId?: string | null | undefined; /** * Lifecycle status of the receipt. `draft` covers unposted or awaiting-validation documents, `pending_approval` covers documents submitted into an approval flow, `received` covers posted/validated/released receipts that have affected stock or the receiving ledger, `cancelled` covers voided, reversed or denied receipts. */ status?: GoodsReceiptStatus | null | undefined; /** * Date the goods were received - YYYY-MM-DD. */ receivedDate?: Date | null | undefined; /** * Accounting posting date of the receipt when the system distinguishes it from the received date - YYYY-MM-DD. */ postedDate?: Date | 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; lineItems?: Array | undefined; /** * Internal notes or description recorded on the receipt. */ notes?: 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; }; /** @internal */ export const GoodsReceiptStatus$inboundSchema: z.ZodType< GoodsReceiptStatus, z.ZodTypeDef, unknown > = /* @__PURE__ */ lazySchema$(() => openEnums.inboundSchema(GoodsReceiptStatus) ); /** @internal */ export const GoodsReceipt$inboundSchema: z.ZodType< GoodsReceipt, z.ZodTypeDef, unknown > = /* @__PURE__ */ lazySchema$(() => z.object({ id: types.string(), downstream_id: z.nullable(types.string()).optional(), display_id: z.nullable(types.string()).optional(), receipt_number: z.nullable(types.string()).optional(), reference: z.nullable(types.string()).optional(), purchase_order_id: z.nullable(types.string()).optional(), po_number: z.nullable(types.string()).optional(), supplier: z.nullable(LinkedSupplier$inboundSchema).optional(), company_id: z.nullable(types.string()).optional(), subsidiary_id: z.nullable(types.string()).optional(), location_id: z.nullable(types.string()).optional(), department_id: z.nullable(types.string()).optional(), status: z.nullable(GoodsReceiptStatus$inboundSchema).optional(), received_date: z.nullable(types.date()).optional(), posted_date: z.nullable(types.date()).optional(), currency: z.nullable(Currency$inboundSchema).optional(), currency_rate: z.nullable(types.number()).optional(), line_items: types.optional(z.array(GoodsReceiptLineItem$inboundSchema)), notes: 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(), }).transform((v) => { return remap$(v, { "downstream_id": "downstreamId", "display_id": "displayId", "receipt_number": "receiptNumber", "purchase_order_id": "purchaseOrderId", "po_number": "poNumber", "company_id": "companyId", "subsidiary_id": "subsidiaryId", "location_id": "locationId", "department_id": "departmentId", "received_date": "receivedDate", "posted_date": "postedDate", "currency_rate": "currencyRate", "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", }); }) ); export function goodsReceiptFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => GoodsReceipt$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'GoodsReceipt' from JSON`, ); }