"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.ExpenseInput$outboundSchema = exports.Expense$inboundSchema = exports.ExpenseStatus$outboundSchema = exports.ExpenseStatus$inboundSchema = exports.ExpenseType$outboundSchema = exports.ExpenseType$inboundSchema = exports.ExpensePaymentType$outboundSchema = exports.ExpensePaymentType$inboundSchema = exports.ExpenseStatus = exports.ExpenseType = exports.ExpensePaymentType = void 0;
exports.expenseFromJSON = expenseFromJSON;
exports.expenseInputToJSON = expenseInputToJSON;
const z = __importStar(require("zod/v3"));
const primitives_js_1 = require("../../lib/primitives.js");
const schemas_js_1 = require("../../lib/schemas.js");
const currency_js_1 = require("./currency.js");
const customfield_js_1 = require("./customfield.js");
const expenselineitem_js_1 = require("./expenselineitem.js");
const expenselineiteminput_js_1 = require("./expenselineiteminput.js");
const linkedbankaccount_js_1 = require("./linkedbankaccount.js");
const linkedledgeraccount_js_1 = require("./linkedledgeraccount.js");
const linkedsupplier_js_1 = require("./linkedsupplier.js");
const linkedsupplierinput_js_1 = require("./linkedsupplierinput.js");
const linkedtaxrate_js_1 = require("./linkedtaxrate.js");
const linkedtaxrateinput_js_1 = require("./linkedtaxrateinput.js");
const passthroughbody_js_1 = require("./passthroughbody.js");
/**
 * The type of payment for the expense.
 */
exports.ExpensePaymentType = {
    Cash: "cash",
    Check: "check",
    CreditCard: "credit_card",
    Other: "other",
};
/**
 * The type of expense.
 */
exports.ExpenseType = {
    Expense: "expense",
    Refund: "refund",
};
/**
 * Expense status
 */
exports.ExpenseStatus = {
    Draft: "draft",
    Posted: "posted",
};
/** @internal */
exports.ExpensePaymentType$inboundSchema = z.nativeEnum(exports.ExpensePaymentType);
/** @internal */
exports.ExpensePaymentType$outboundSchema = exports.ExpensePaymentType$inboundSchema;
/** @internal */
exports.ExpenseType$inboundSchema = z
    .nativeEnum(exports.ExpenseType);
/** @internal */
exports.ExpenseType$outboundSchema = exports.ExpenseType$inboundSchema;
/** @internal */
exports.ExpenseStatus$inboundSchema = z.nativeEnum(exports.ExpenseStatus);
/** @internal */
exports.ExpenseStatus$outboundSchema = exports.ExpenseStatus$inboundSchema;
/** @internal */
exports.Expense$inboundSchema = z.object({
    id: z.string().optional(),
    number: z.nullable(z.string()).optional(),
    transaction_date: z.nullable(z.string().datetime({ offset: true }).transform(v => new Date(v))),
    account_id: z.string().optional(),
    account: z.nullable(linkedledgeraccount_js_1.LinkedLedgerAccount$inboundSchema).optional(),
    bank_account: z.nullable(linkedbankaccount_js_1.LinkedBankAccount$inboundSchema).optional(),
    customer_id: z.string().optional(),
    supplier_id: z.string().optional(),
    supplier: z.nullable(linkedsupplier_js_1.LinkedSupplier$inboundSchema).optional(),
    company_id: z.nullable(z.string()).optional(),
    department_id: z.nullable(z.string()).optional(),
    payment_type: z.nullable(exports.ExpensePaymentType$inboundSchema).optional(),
    currency: z.nullable(currency_js_1.Currency$inboundSchema).optional(),
    currency_rate: z.nullable(z.number()).optional(),
    type: z.nullable(exports.ExpenseType$inboundSchema).optional(),
    memo: z.nullable(z.string()).optional(),
    tax_rate: linkedtaxrate_js_1.LinkedTaxRate$inboundSchema.optional(),
    tax_inclusive: z.nullable(z.boolean()).optional(),
    sub_total: z.nullable(z.number()).optional(),
    total_tax: z.nullable(z.number()).optional(),
    total_amount: z.nullable(z.number()).optional(),
    line_items: z.array(expenselineitem_js_1.ExpenseLineItem$inboundSchema),
    reference: z.nullable(z.string()).optional(),
    source_document_url: z.nullable(z.string()).optional(),
    custom_fields: z.array(customfield_js_1.CustomField$inboundSchema).optional(),
    custom_mappings: z.nullable(z.record(z.any())).optional(),
    status: z.nullable(exports.ExpenseStatus$inboundSchema).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(),
    row_version: z.nullable(z.string()).optional(),
    updated_by: z.nullable(z.string()).optional(),
    created_by: z.nullable(z.string()).optional(),
    pass_through: z.array(passthroughbody_js_1.PassThroughBody$inboundSchema).optional(),
}).transform((v) => {
    return (0, primitives_js_1.remap)(v, {
        "transaction_date": "transactionDate",
        "account_id": "accountId",
        "bank_account": "bankAccount",
        "customer_id": "customerId",
        "supplier_id": "supplierId",
        "company_id": "companyId",
        "department_id": "departmentId",
        "payment_type": "paymentType",
        "currency_rate": "currencyRate",
        "tax_rate": "taxRate",
        "tax_inclusive": "taxInclusive",
        "sub_total": "subTotal",
        "total_tax": "totalTax",
        "total_amount": "totalAmount",
        "line_items": "lineItems",
        "source_document_url": "sourceDocumentUrl",
        "custom_fields": "customFields",
        "custom_mappings": "customMappings",
        "updated_at": "updatedAt",
        "created_at": "createdAt",
        "row_version": "rowVersion",
        "updated_by": "updatedBy",
        "created_by": "createdBy",
        "pass_through": "passThrough",
    });
});
function expenseFromJSON(jsonString) {
    return (0, schemas_js_1.safeParse)(jsonString, (x) => exports.Expense$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Expense' from JSON`);
}
/** @internal */
exports.ExpenseInput$outboundSchema = z.object({
    number: z.nullable(z.string()).optional(),
    transactionDate: z.nullable(z.date().transform(v => v.toISOString())),
    accountId: z.string().optional(),
    account: z.nullable(linkedledgeraccount_js_1.LinkedLedgerAccount$outboundSchema).optional(),
    bankAccount: z.nullable(linkedbankaccount_js_1.LinkedBankAccount$outboundSchema).optional(),
    customerId: z.string().optional(),
    supplierId: z.string().optional(),
    supplier: z.nullable(linkedsupplierinput_js_1.LinkedSupplierInput$outboundSchema).optional(),
    companyId: z.nullable(z.string()).optional(),
    departmentId: z.nullable(z.string()).optional(),
    paymentType: z.nullable(exports.ExpensePaymentType$outboundSchema).optional(),
    currency: z.nullable(currency_js_1.Currency$outboundSchema).optional(),
    currencyRate: z.nullable(z.number()).optional(),
    type: z.nullable(exports.ExpenseType$outboundSchema).optional(),
    memo: z.nullable(z.string()).optional(),
    taxRate: linkedtaxrateinput_js_1.LinkedTaxRateInput$outboundSchema.optional(),
    taxInclusive: z.nullable(z.boolean()).optional(),
    subTotal: z.nullable(z.number()).optional(),
    totalTax: z.nullable(z.number()).optional(),
    totalAmount: z.nullable(z.number()).optional(),
    lineItems: z.array(expenselineiteminput_js_1.ExpenseLineItemInput$outboundSchema),
    reference: z.nullable(z.string()).optional(),
    sourceDocumentUrl: z.nullable(z.string()).optional(),
    customFields: z.array(customfield_js_1.CustomField$outboundSchema).optional(),
    status: z.nullable(exports.ExpenseStatus$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, {
        transactionDate: "transaction_date",
        accountId: "account_id",
        bankAccount: "bank_account",
        customerId: "customer_id",
        supplierId: "supplier_id",
        companyId: "company_id",
        departmentId: "department_id",
        paymentType: "payment_type",
        currencyRate: "currency_rate",
        taxRate: "tax_rate",
        taxInclusive: "tax_inclusive",
        subTotal: "sub_total",
        totalTax: "total_tax",
        totalAmount: "total_amount",
        lineItems: "line_items",
        sourceDocumentUrl: "source_document_url",
        customFields: "custom_fields",
        rowVersion: "row_version",
        passThrough: "pass_through",
    });
});
function expenseInputToJSON(expenseInput) {
    return JSON.stringify(exports.ExpenseInput$outboundSchema.parse(expenseInput));
}
//# sourceMappingURL=expense.js.map