"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.BillPaymentInput$outboundSchema = exports.BillPaymentAllocations$outboundSchema = exports.BillPayment$inboundSchema = exports.Allocations$inboundSchema = exports.BillPaymentAllocationType$outboundSchema = exports.BillPaymentAllocationType$inboundSchema = exports.BillPaymentType$outboundSchema = exports.BillPaymentType$inboundSchema = exports.BillPaymentAllocationType = exports.BillPaymentType = void 0;
exports.allocationsFromJSON = allocationsFromJSON;
exports.billPaymentFromJSON = billPaymentFromJSON;
exports.billPaymentAllocationsToJSON = billPaymentAllocationsToJSON;
exports.billPaymentInputToJSON = billPaymentInputToJSON;
const z = __importStar(require("zod/v3"));
const primitives_js_1 = require("../../lib/primitives.js");
const schemas_js_1 = require("../../lib/schemas.js");
const openEnums = __importStar(require("../../types/enums.js"));
const types = __importStar(require("../../types/primitives.js"));
const currency_js_1 = require("./currency.js");
const customfield_js_1 = require("./customfield.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");
const paymentstatus_js_1 = require("./paymentstatus.js");
/**
 * Type of payment
 */
exports.BillPaymentType = {
    AccountsPayableCredit: "accounts_payable_credit",
    AccountsPayableOverpayment: "accounts_payable_overpayment",
    AccountsPayablePrepayment: "accounts_payable_prepayment",
    AccountsPayable: "accounts_payable",
};
/**
 * Type of entity this payment should be attributed to.
 */
exports.BillPaymentAllocationType = {
    Bill: "bill",
    Expense: "expense",
    CreditMemo: "credit_memo",
    OverPayment: "over_payment",
    PrePayment: "pre_payment",
    JournalEntry: "journal_entry",
    Other: "other",
};
/** @internal */
exports.BillPaymentType$inboundSchema = openEnums.inboundSchema(exports.BillPaymentType);
/** @internal */
exports.BillPaymentType$outboundSchema = openEnums.outboundSchema(exports.BillPaymentType);
/** @internal */
exports.BillPaymentAllocationType$inboundSchema = openEnums.inboundSchema(exports.BillPaymentAllocationType);
/** @internal */
exports.BillPaymentAllocationType$outboundSchema = openEnums.outboundSchema(exports.BillPaymentAllocationType);
/** @internal */
exports.Allocations$inboundSchema = z.object({
    id: z.nullable(types.string()).optional(),
    type: types.optional(exports.BillPaymentAllocationType$inboundSchema),
    code: types.optional(types.string()),
    amount: z.nullable(types.number()).optional(),
    allocation_id: types.optional(types.string()),
}).transform((v) => {
    return (0, primitives_js_1.remap)(v, {
        "allocation_id": "allocationId",
    });
});
function allocationsFromJSON(jsonString) {
    return (0, schemas_js_1.safeParse)(jsonString, (x) => exports.Allocations$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Allocations' from JSON`);
}
/** @internal */
exports.BillPayment$inboundSchema = z.object({
    id: types.string(),
    downstream_id: z.nullable(types.string()).optional(),
    currency: z.nullable(currency_js_1.Currency$inboundSchema).optional(),
    currency_rate: z.nullable(types.number()).optional(),
    total_amount: types.nullable(types.number()),
    reference: z.nullable(types.string()).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_js_1.LinkedLedgerAccount$inboundSchema).optional(),
    transaction_date: types.nullable(types.date()),
    supplier: z.nullable(linkedsupplier_js_1.LinkedSupplier$inboundSchema).optional(),
    company_id: z.nullable(types.string()).optional(),
    reconciled: z.nullable(types.boolean()).optional(),
    status: types.optional(paymentstatus_js_1.PaymentStatus$inboundSchema),
    type: types.optional(exports.BillPaymentType$inboundSchema),
    allocations: types.optional(z.array(z.lazy(() => exports.Allocations$inboundSchema))),
    note: z.nullable(types.string()).optional(),
    number: z.nullable(types.string()).optional(),
    tracking_categories: z.nullable(z.array(types.nullable(linkedtrackingcategory_js_1.LinkedTrackingCategory$inboundSchema))).optional(),
    custom_fields: types.optional(z.array(customfield_js_1.CustomField$inboundSchema)),
    row_version: z.nullable(types.string()).optional(),
    display_id: z.nullable(types.string()).optional(),
    custom_mappings: z.nullable(z.record(z.any())).optional(),
    updated_by: z.nullable(types.string()).optional(),
    created_by: z.nullable(types.string()).optional(),
    created_at: z.nullable(types.date()).optional(),
    updated_at: z.nullable(types.date()).optional(),
    pass_through: types.optional(z.array(passthroughbody_js_1.PassThroughBody$inboundSchema)),
}).transform((v) => {
    return (0, primitives_js_1.remap)(v, {
        "downstream_id": "downstreamId",
        "currency_rate": "currencyRate",
        "total_amount": "totalAmount",
        "payment_method": "paymentMethod",
        "payment_method_reference": "paymentMethodReference",
        "payment_method_id": "paymentMethodId",
        "transaction_date": "transactionDate",
        "company_id": "companyId",
        "tracking_categories": "trackingCategories",
        "custom_fields": "customFields",
        "row_version": "rowVersion",
        "display_id": "displayId",
        "custom_mappings": "customMappings",
        "updated_by": "updatedBy",
        "created_by": "createdBy",
        "created_at": "createdAt",
        "updated_at": "updatedAt",
        "pass_through": "passThrough",
    });
});
function billPaymentFromJSON(jsonString) {
    return (0, schemas_js_1.safeParse)(jsonString, (x) => exports.BillPayment$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'BillPayment' from JSON`);
}
/** @internal */
exports.BillPaymentAllocations$outboundSchema = z.object({
    id: z.nullable(z.string()).optional(),
    type: exports.BillPaymentAllocationType$outboundSchema.optional(),
    amount: z.nullable(z.number()).optional(),
    allocationId: z.string().optional(),
}).transform((v) => {
    return (0, primitives_js_1.remap)(v, {
        allocationId: "allocation_id",
    });
});
function billPaymentAllocationsToJSON(billPaymentAllocations) {
    return JSON.stringify(exports.BillPaymentAllocations$outboundSchema.parse(billPaymentAllocations));
}
/** @internal */
exports.BillPaymentInput$outboundSchema = z.object({
    currency: z.nullable(currency_js_1.Currency$outboundSchema).optional(),
    currencyRate: z.nullable(z.number()).optional(),
    totalAmount: z.nullable(z.number()),
    reference: z.nullable(z.string()).optional(),
    paymentMethod: z.nullable(z.string()).optional(),
    paymentMethodReference: z.nullable(z.string()).optional(),
    paymentMethodId: z.nullable(z.string()).optional(),
    account: z.nullable(linkedledgeraccount_js_1.LinkedLedgerAccount$outboundSchema).optional(),
    transactionDate: z.nullable(z.date().transform(v => v.toISOString())),
    supplier: z.nullable(linkedsupplierinput_js_1.LinkedSupplierInput$outboundSchema).optional(),
    companyId: z.nullable(z.string()).optional(),
    reconciled: z.nullable(z.boolean()).optional(),
    status: paymentstatus_js_1.PaymentStatus$outboundSchema.optional(),
    type: exports.BillPaymentType$outboundSchema.optional(),
    allocations: z.array(z.lazy(() => exports.BillPaymentAllocations$outboundSchema))
        .optional(),
    note: z.nullable(z.string()).optional(),
    number: 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(),
    displayId: z.nullable(z.string()).optional(),
    passThrough: z.array(passthroughbody_js_1.PassThroughBody$outboundSchema).optional(),
}).transform((v) => {
    return (0, primitives_js_1.remap)(v, {
        currencyRate: "currency_rate",
        totalAmount: "total_amount",
        paymentMethod: "payment_method",
        paymentMethodReference: "payment_method_reference",
        paymentMethodId: "payment_method_id",
        transactionDate: "transaction_date",
        companyId: "company_id",
        trackingCategories: "tracking_categories",
        customFields: "custom_fields",
        rowVersion: "row_version",
        displayId: "display_id",
        passThrough: "pass_through",
    });
});
function billPaymentInputToJSON(billPaymentInput) {
    return JSON.stringify(exports.BillPaymentInput$outboundSchema.parse(billPaymentInput));
}
//# sourceMappingURL=billpayment.js.map