"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.InvoiceInput$outboundSchema = exports.Invoice$inboundSchema = exports.PaymentAllocations$outboundSchema = exports.PaymentAllocations$inboundSchema = exports.InvoiceStatus$outboundSchema = exports.InvoiceStatus$inboundSchema = exports.InvoiceType$outboundSchema = exports.InvoiceType$inboundSchema = exports.InvoiceStatus = exports.InvoiceType = void 0;
exports.paymentAllocationsToJSON = paymentAllocationsToJSON;
exports.paymentAllocationsFromJSON = paymentAllocationsFromJSON;
exports.invoiceFromJSON = invoiceFromJSON;
exports.invoiceInputToJSON = invoiceInputToJSON;
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 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 deprecatedlinkedtrackingcategory_js_1 = require("./deprecatedlinkedtrackingcategory.js");
const invoicelineitem_js_1 = require("./invoicelineitem.js");
const linkedcustomer_js_1 = require("./linkedcustomer.js");
const linkedcustomerinput_js_1 = require("./linkedcustomerinput.js");
const linkedledgeraccount_js_1 = require("./linkedledgeraccount.js");
const linkedtrackingcategory_js_1 = require("./linkedtrackingcategory.js");
const passthroughbody_js_1 = require("./passthroughbody.js");
/**
 * Invoice type
 */
exports.InvoiceType = {
    Standard: "standard",
    Credit: "credit",
    Service: "service",
    Product: "product",
    Supplier: "supplier",
    Other: "other",
};
/**
 * Invoice status
 */
exports.InvoiceStatus = {
    Draft: "draft",
    Submitted: "submitted",
    Authorised: "authorised",
    PartiallyPaid: "partially_paid",
    Paid: "paid",
    Unpaid: "unpaid",
    Void: "void",
    Credit: "credit",
    Deleted: "deleted",
    Posted: "posted",
};
/** @internal */
exports.InvoiceType$inboundSchema = openEnums.inboundSchema(exports.InvoiceType);
/** @internal */
exports.InvoiceType$outboundSchema = openEnums.outboundSchema(exports.InvoiceType);
/** @internal */
exports.InvoiceStatus$inboundSchema = openEnums.inboundSchema(exports.InvoiceStatus);
/** @internal */
exports.InvoiceStatus$outboundSchema = openEnums.outboundSchema(exports.InvoiceStatus);
/** @internal */
exports.PaymentAllocations$inboundSchema = z.object({
    id: types.optional(types.string()),
    allocated_amount: z.nullable(types.number()).optional(),
    date: z.nullable(types.date()).optional(),
}).transform((v) => {
    return (0, primitives_js_1.remap)(v, {
        "allocated_amount": "allocatedAmount",
    });
});
/** @internal */
exports.PaymentAllocations$outboundSchema = z.object({
    id: z.string().optional(),
    allocatedAmount: z.nullable(z.number()).optional(),
    date: z.nullable(z.date().transform(v => v.toISOString())).optional(),
}).transform((v) => {
    return (0, primitives_js_1.remap)(v, {
        allocatedAmount: "allocated_amount",
    });
});
function paymentAllocationsToJSON(paymentAllocations) {
    return JSON.stringify(exports.PaymentAllocations$outboundSchema.parse(paymentAllocations));
}
function paymentAllocationsFromJSON(jsonString) {
    return (0, schemas_js_1.safeParse)(jsonString, (x) => exports.PaymentAllocations$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'PaymentAllocations' from JSON`);
}
/** @internal */
exports.Invoice$inboundSchema = z.object({
    id: types.optional(types.string()),
    downstream_id: z.nullable(types.string()).optional(),
    display_id: z.nullable(types.string()).optional(),
    type: z.nullable(exports.InvoiceType$inboundSchema).optional(),
    number: z.nullable(types.string()).optional(),
    customer: z.nullable(linkedcustomer_js_1.LinkedCustomer$inboundSchema).optional(),
    company_id: z.nullable(types.string()).optional(),
    location_id: z.nullable(types.string()).optional(),
    department_id: z.nullable(types.string()).optional(),
    invoice_date: z.nullable(types.date()).optional(),
    due_date: z.nullable(types.date()).optional(),
    terms: z.nullable(types.string()).optional(),
    terms_id: z.nullable(types.string()).optional(),
    po_number: z.nullable(types.string()).optional(),
    reference: z.nullable(types.string()).optional(),
    status: z.nullable(exports.InvoiceStatus$inboundSchema).optional(),
    invoice_sent: types.optional(types.boolean()),
    currency: z.nullable(currency_js_1.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_tax: z.nullable(types.number()).optional(),
    tax_code: z.nullable(types.string()).optional(),
    discount_percentage: z.nullable(types.number()).optional(),
    discount_amount: z.nullable(types.number()).optional(),
    total: z.nullable(types.number()).optional(),
    balance: z.nullable(types.number()).optional(),
    deposit: z.nullable(types.number()).optional(),
    customer_memo: z.nullable(types.string()).optional(),
    tracking_category: z.nullable(deprecatedlinkedtrackingcategory_js_1.DeprecatedLinkedTrackingCategory$inboundSchema).optional(),
    tracking_categories: z.nullable(z.array(types.nullable(linkedtrackingcategory_js_1.LinkedTrackingCategory$inboundSchema))).optional(),
    line_items: types.optional(z.array(invoicelineitem_js_1.InvoiceLineItem$inboundSchema)),
    billing_address: types.optional(address_js_1.Address$inboundSchema),
    shipping_address: types.optional(address_js_1.Address$inboundSchema),
    template_id: z.nullable(types.string()).optional(),
    source_document_url: z.nullable(types.string()).optional(),
    payment_allocations: z.nullable(z.array(z.lazy(() => exports.PaymentAllocations$inboundSchema))).optional(),
    payment_method: z.nullable(types.string()).optional(),
    channel: z.nullable(types.string()).optional(),
    language: z.nullable(types.string()).optional(),
    accounting_by_row: z.nullable(types.boolean()).optional(),
    bank_account: types.optional(bankaccount_js_1.BankAccount$inboundSchema),
    ledger_account: z.nullable(linkedledgeraccount_js_1.LinkedLedgerAccount$inboundSchema).optional(),
    custom_mappings: z.nullable(z.record(z.any())).optional(),
    custom_fields: types.optional(z.array(customfield_js_1.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_js_1.PassThroughBody$inboundSchema)),
}).transform((v) => {
    return (0, primitives_js_1.remap)(v, {
        "downstream_id": "downstreamId",
        "display_id": "displayId",
        "company_id": "companyId",
        "location_id": "locationId",
        "department_id": "departmentId",
        "invoice_date": "invoiceDate",
        "due_date": "dueDate",
        "terms_id": "termsId",
        "po_number": "poNumber",
        "invoice_sent": "invoiceSent",
        "currency_rate": "currencyRate",
        "tax_inclusive": "taxInclusive",
        "sub_total": "subTotal",
        "total_tax": "totalTax",
        "tax_code": "taxCode",
        "discount_percentage": "discountPercentage",
        "discount_amount": "discountAmount",
        "customer_memo": "customerMemo",
        "tracking_category": "trackingCategory",
        "tracking_categories": "trackingCategories",
        "line_items": "lineItems",
        "billing_address": "billingAddress",
        "shipping_address": "shippingAddress",
        "template_id": "templateId",
        "source_document_url": "sourceDocumentUrl",
        "payment_allocations": "paymentAllocations",
        "payment_method": "paymentMethod",
        "accounting_by_row": "accountingByRow",
        "bank_account": "bankAccount",
        "ledger_account": "ledgerAccount",
        "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 invoiceFromJSON(jsonString) {
    return (0, schemas_js_1.safeParse)(jsonString, (x) => exports.Invoice$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Invoice' from JSON`);
}
/** @internal */
exports.InvoiceInput$outboundSchema = z.object({
    displayId: z.nullable(z.string()).optional(),
    type: z.nullable(exports.InvoiceType$outboundSchema).optional(),
    number: z.nullable(z.string()).optional(),
    customer: z.nullable(linkedcustomerinput_js_1.LinkedCustomerInput$outboundSchema).optional(),
    companyId: z.nullable(z.string()).optional(),
    locationId: z.nullable(z.string()).optional(),
    departmentId: z.nullable(z.string()).optional(),
    invoiceDate: z.nullable(z.date().transform(v => v.toISOString().slice(0, "YYYY-MM-DD".length))).optional(),
    dueDate: z.nullable(z.date().transform(v => v.toISOString().slice(0, "YYYY-MM-DD".length))).optional(),
    terms: z.nullable(z.string()).optional(),
    termsId: z.nullable(z.string()).optional(),
    poNumber: z.nullable(z.string()).optional(),
    reference: z.nullable(z.string()).optional(),
    status: z.nullable(exports.InvoiceStatus$outboundSchema).optional(),
    invoiceSent: z.boolean().optional(),
    currency: z.nullable(currency_js_1.Currency$outboundSchema).optional(),
    currencyRate: z.nullable(z.number()).optional(),
    taxInclusive: z.nullable(z.boolean()).optional(),
    subTotal: z.nullable(z.number()).optional(),
    totalTax: z.nullable(z.number()).optional(),
    taxCode: z.nullable(z.string()).optional(),
    discountPercentage: z.nullable(z.number()).optional(),
    discountAmount: z.nullable(z.number()).optional(),
    total: z.nullable(z.number()).optional(),
    balance: z.nullable(z.number()).optional(),
    deposit: z.nullable(z.number()).optional(),
    customerMemo: z.nullable(z.string()).optional(),
    trackingCategory: z.nullable(deprecatedlinkedtrackingcategory_js_1.DeprecatedLinkedTrackingCategory$outboundSchema)
        .optional(),
    trackingCategories: z.nullable(z.array(z.nullable(linkedtrackingcategory_js_1.LinkedTrackingCategory$outboundSchema))).optional(),
    lineItems: z.array(invoicelineitem_js_1.InvoiceLineItemInput$outboundSchema).optional(),
    billingAddress: address_js_1.Address$outboundSchema.optional(),
    shippingAddress: address_js_1.Address$outboundSchema.optional(),
    templateId: z.nullable(z.string()).optional(),
    sourceDocumentUrl: z.nullable(z.string()).optional(),
    paymentAllocations: z.nullable(z.array(z.lazy(() => exports.PaymentAllocations$outboundSchema))).optional(),
    paymentMethod: z.nullable(z.string()).optional(),
    channel: z.nullable(z.string()).optional(),
    language: z.nullable(z.string()).optional(),
    accountingByRow: z.nullable(z.boolean()).optional(),
    bankAccount: bankaccount_js_1.BankAccount$outboundSchema.optional(),
    ledgerAccount: z.nullable(linkedledgeraccount_js_1.LinkedLedgerAccount$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",
        companyId: "company_id",
        locationId: "location_id",
        departmentId: "department_id",
        invoiceDate: "invoice_date",
        dueDate: "due_date",
        termsId: "terms_id",
        poNumber: "po_number",
        invoiceSent: "invoice_sent",
        currencyRate: "currency_rate",
        taxInclusive: "tax_inclusive",
        subTotal: "sub_total",
        totalTax: "total_tax",
        taxCode: "tax_code",
        discountPercentage: "discount_percentage",
        discountAmount: "discount_amount",
        customerMemo: "customer_memo",
        trackingCategory: "tracking_category",
        trackingCategories: "tracking_categories",
        lineItems: "line_items",
        billingAddress: "billing_address",
        shippingAddress: "shipping_address",
        templateId: "template_id",
        sourceDocumentUrl: "source_document_url",
        paymentAllocations: "payment_allocations",
        paymentMethod: "payment_method",
        accountingByRow: "accounting_by_row",
        bankAccount: "bank_account",
        ledgerAccount: "ledger_account",
        customFields: "custom_fields",
        rowVersion: "row_version",
        passThrough: "pass_through",
    });
});
function invoiceInputToJSON(invoiceInput) {
    return JSON.stringify(exports.InvoiceInput$outboundSchema.parse(invoiceInput));
}
//# sourceMappingURL=invoice.js.map