"use strict";
/*
 * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
 */
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    var desc = Object.getOwnPropertyDescriptor(m, k);
    if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
      desc = { enumerable: true, get: function() { return m[k]; } };
    }
    Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
    Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
    o["default"] = v;
});
var __importStar = (this && this.__importStar) || (function () {
    var ownKeys = function(o) {
        ownKeys = Object.getOwnPropertyNames || function (o) {
            var ar = [];
            for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
            return ar;
        };
        return ownKeys(o);
    };
    return function (mod) {
        if (mod && mod.__esModule) return mod;
        var result = {};
        if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
        __setModuleDefault(result, mod);
        return result;
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.PurchaseOrderInput$outboundSchema = exports.PurchaseOrder$inboundSchema = exports.PurchaseOrderAmortizationType$outboundSchema = exports.PurchaseOrderAmortizationType$inboundSchema = exports.PurchaseOrderStatus$outboundSchema = exports.PurchaseOrderStatus$inboundSchema = exports.PurchaseOrderAmortizationType = exports.PurchaseOrderStatus = void 0;
exports.purchaseOrderFromJSON = purchaseOrderFromJSON;
exports.purchaseOrderInputToJSON = purchaseOrderInputToJSON;
const z = __importStar(require("zod/v3"));
const primitives_js_1 = require("../../lib/primitives.js");
const schemas_js_1 = require("../../lib/schemas.js");
const rfcdate_js_1 = require("../../types/rfcdate.js");
const address_js_1 = require("./address.js");
const bankaccount_js_1 = require("./bankaccount.js");
const currency_js_1 = require("./currency.js");
const customfield_js_1 = require("./customfield.js");
const invoicelineitem_js_1 = require("./invoicelineitem.js");
const linkedledgeraccount_js_1 = require("./linkedledgeraccount.js");
const linkedsupplier_js_1 = require("./linkedsupplier.js");
const linkedsupplierinput_js_1 = require("./linkedsupplierinput.js");
const linkedtrackingcategory_js_1 = require("./linkedtrackingcategory.js");
const passthroughbody_js_1 = require("./passthroughbody.js");
exports.PurchaseOrderStatus = {
    Draft: "draft",
    Open: "open",
    Closed: "closed",
    Deleted: "deleted",
    Billed: "billed",
    Other: "other",
};
/**
 * Type of amortization
 */
exports.PurchaseOrderAmortizationType = {
    Manual: "manual",
    Receipt: "receipt",
    Schedule: "schedule",
    Other: "other",
};
/** @internal */
exports.PurchaseOrderStatus$inboundSchema = z.nativeEnum(exports.PurchaseOrderStatus);
/** @internal */
exports.PurchaseOrderStatus$outboundSchema = exports.PurchaseOrderStatus$inboundSchema;
/** @internal */
exports.PurchaseOrderAmortizationType$inboundSchema = z.nativeEnum(exports.PurchaseOrderAmortizationType);
/** @internal */
exports.PurchaseOrderAmortizationType$outboundSchema = exports.PurchaseOrderAmortizationType$inboundSchema;
/** @internal */
exports.PurchaseOrder$inboundSchema = z.object({
    id: z.string().optional(),
    downstream_id: z.nullable(z.string()).optional(),
    display_id: z.nullable(z.string()).optional(),
    po_number: z.nullable(z.string()).optional(),
    reference: z.nullable(z.string()).optional(),
    supplier: z.nullable(linkedsupplier_js_1.LinkedSupplier$inboundSchema).optional(),
    subsidiary_id: z.nullable(z.string()).optional(),
    company_id: z.nullable(z.string()).optional(),
    department_id: z.nullable(z.string()).optional(),
    status: z.nullable(exports.PurchaseOrderStatus$inboundSchema).optional(),
    issued_date: z.nullable(z.string().transform(v => new rfcdate_js_1.RFCDate(v))).optional(),
    delivery_date: z.nullable(z.string().transform(v => new rfcdate_js_1.RFCDate(v)))
        .optional(),
    expected_arrival_date: z.nullable(z.string().transform(v => new rfcdate_js_1.RFCDate(v)))
        .optional(),
    currency: z.nullable(currency_js_1.Currency$inboundSchema).optional(),
    currency_rate: z.nullable(z.number()).optional(),
    sub_total: z.nullable(z.number()).optional(),
    total_tax: z.nullable(z.number()).optional(),
    total: z.nullable(z.number()).optional(),
    tax_inclusive: z.nullable(z.boolean()).optional(),
    line_items: z.array(invoicelineitem_js_1.InvoiceLineItem$inboundSchema).optional(),
    billing_address: address_js_1.Address$inboundSchema.optional(),
    shipping_address: address_js_1.Address$inboundSchema.optional(),
    ledger_account: z.nullable(linkedledgeraccount_js_1.LinkedLedgerAccount$inboundSchema).optional(),
    template_id: z.nullable(z.string()).optional(),
    discount_percentage: z.nullable(z.number()).optional(),
    bank_account: bankaccount_js_1.BankAccount$inboundSchema.optional(),
    accounting_by_row: z.nullable(z.boolean()).optional(),
    due_date: z.nullable(z.string().transform(v => new rfcdate_js_1.RFCDate(v))).optional(),
    payment_method: z.nullable(z.string()).optional(),
    terms: z.nullable(z.string()).optional(),
    amortization_type: z.nullable(exports.PurchaseOrderAmortizationType$inboundSchema)
        .optional(),
    tax_code: z.nullable(z.string()).optional(),
    tax_method: z.nullable(z.string()).optional(),
    issued_method: z.nullable(z.string()).optional(),
    issued_email: z.nullable(z.string()).optional(),
    channel: z.nullable(z.string()).optional(),
    memo: z.nullable(z.string()).optional(),
    notes: z.nullable(z.string()).optional(),
    tracking_categories: z.nullable(z.array(z.nullable(linkedtrackingcategory_js_1.LinkedTrackingCategory$inboundSchema))).optional(),
    custom_mappings: z.nullable(z.record(z.any())).optional(),
    custom_fields: z.array(customfield_js_1.CustomField$inboundSchema).optional(),
    row_version: z.nullable(z.string()).optional(),
    updated_by: z.nullable(z.string()).optional(),
    created_by: z.nullable(z.string()).optional(),
    updated_at: z.nullable(z.string().datetime({ offset: true }).transform(v => new Date(v))).optional(),
    created_at: z.nullable(z.string().datetime({ offset: true }).transform(v => new Date(v))).optional(),
    pass_through: z.array(passthroughbody_js_1.PassThroughBody$inboundSchema).optional(),
}).transform((v) => {
    return (0, primitives_js_1.remap)(v, {
        "downstream_id": "downstreamId",
        "display_id": "displayId",
        "po_number": "poNumber",
        "subsidiary_id": "subsidiaryId",
        "company_id": "companyId",
        "department_id": "departmentId",
        "issued_date": "issuedDate",
        "delivery_date": "deliveryDate",
        "expected_arrival_date": "expectedArrivalDate",
        "currency_rate": "currencyRate",
        "sub_total": "subTotal",
        "total_tax": "totalTax",
        "tax_inclusive": "taxInclusive",
        "line_items": "lineItems",
        "billing_address": "billingAddress",
        "shipping_address": "shippingAddress",
        "ledger_account": "ledgerAccount",
        "template_id": "templateId",
        "discount_percentage": "discountPercentage",
        "bank_account": "bankAccount",
        "accounting_by_row": "accountingByRow",
        "due_date": "dueDate",
        "payment_method": "paymentMethod",
        "amortization_type": "amortizationType",
        "tax_code": "taxCode",
        "tax_method": "taxMethod",
        "issued_method": "issuedMethod",
        "issued_email": "issuedEmail",
        "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",
    });
});
function purchaseOrderFromJSON(jsonString) {
    return (0, schemas_js_1.safeParse)(jsonString, (x) => exports.PurchaseOrder$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'PurchaseOrder' from JSON`);
}
/** @internal */
exports.PurchaseOrderInput$outboundSchema = z.object({
    displayId: z.nullable(z.string()).optional(),
    poNumber: z.nullable(z.string()).optional(),
    reference: z.nullable(z.string()).optional(),
    supplier: z.nullable(linkedsupplierinput_js_1.LinkedSupplierInput$outboundSchema).optional(),
    subsidiaryId: z.nullable(z.string()).optional(),
    companyId: z.nullable(z.string()).optional(),
    departmentId: z.nullable(z.string()).optional(),
    status: z.nullable(exports.PurchaseOrderStatus$outboundSchema).optional(),
    issuedDate: z.nullable(z.instanceof(rfcdate_js_1.RFCDate).transform(v => v.toString()))
        .optional(),
    deliveryDate: z.nullable(z.instanceof(rfcdate_js_1.RFCDate).transform(v => v.toString()))
        .optional(),
    expectedArrivalDate: z.nullable(z.instanceof(rfcdate_js_1.RFCDate).transform(v => v.toString())).optional(),
    currency: z.nullable(currency_js_1.Currency$outboundSchema).optional(),
    currencyRate: z.nullable(z.number()).optional(),
    subTotal: z.nullable(z.number()).optional(),
    totalTax: z.nullable(z.number()).optional(),
    total: z.nullable(z.number()).optional(),
    taxInclusive: z.nullable(z.boolean()).optional(),
    lineItems: z.array(invoicelineitem_js_1.InvoiceLineItemInput$outboundSchema).optional(),
    billingAddress: address_js_1.Address$outboundSchema.optional(),
    shippingAddress: address_js_1.Address$outboundSchema.optional(),
    ledgerAccount: z.nullable(linkedledgeraccount_js_1.LinkedLedgerAccount$outboundSchema).optional(),
    templateId: z.nullable(z.string()).optional(),
    discountPercentage: z.nullable(z.number()).optional(),
    bankAccount: bankaccount_js_1.BankAccount$outboundSchema.optional(),
    accountingByRow: z.nullable(z.boolean()).optional(),
    dueDate: z.nullable(z.instanceof(rfcdate_js_1.RFCDate).transform(v => v.toString()))
        .optional(),
    paymentMethod: z.nullable(z.string()).optional(),
    terms: z.nullable(z.string()).optional(),
    amortizationType: z.nullable(exports.PurchaseOrderAmortizationType$outboundSchema)
        .optional(),
    taxCode: z.nullable(z.string()).optional(),
    taxMethod: z.nullable(z.string()).optional(),
    issuedMethod: z.nullable(z.string()).optional(),
    issuedEmail: z.nullable(z.string()).optional(),
    channel: z.nullable(z.string()).optional(),
    memo: z.nullable(z.string()).optional(),
    notes: z.nullable(z.string()).optional(),
    trackingCategories: z.nullable(z.array(z.nullable(linkedtrackingcategory_js_1.LinkedTrackingCategory$outboundSchema))).optional(),
    customFields: z.array(customfield_js_1.CustomField$outboundSchema).optional(),
    rowVersion: z.nullable(z.string()).optional(),
    passThrough: z.array(passthroughbody_js_1.PassThroughBody$outboundSchema).optional(),
}).transform((v) => {
    return (0, primitives_js_1.remap)(v, {
        displayId: "display_id",
        poNumber: "po_number",
        subsidiaryId: "subsidiary_id",
        companyId: "company_id",
        departmentId: "department_id",
        issuedDate: "issued_date",
        deliveryDate: "delivery_date",
        expectedArrivalDate: "expected_arrival_date",
        currencyRate: "currency_rate",
        subTotal: "sub_total",
        totalTax: "total_tax",
        taxInclusive: "tax_inclusive",
        lineItems: "line_items",
        billingAddress: "billing_address",
        shippingAddress: "shipping_address",
        ledgerAccount: "ledger_account",
        templateId: "template_id",
        discountPercentage: "discount_percentage",
        bankAccount: "bank_account",
        accountingByRow: "accounting_by_row",
        dueDate: "due_date",
        paymentMethod: "payment_method",
        amortizationType: "amortization_type",
        taxCode: "tax_code",
        taxMethod: "tax_method",
        issuedMethod: "issued_method",
        issuedEmail: "issued_email",
        trackingCategories: "tracking_categories",
        customFields: "custom_fields",
        rowVersion: "row_version",
        passThrough: "pass_through",
    });
});
function purchaseOrderInputToJSON(purchaseOrderInput) {
    return JSON.stringify(exports.PurchaseOrderInput$outboundSchema.parse(purchaseOrderInput));
}
//# sourceMappingURL=purchaseorder.js.map