"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.CreditNoteInput$outboundSchema = exports.CreditNote$inboundSchema = exports.CreditNoteType$outboundSchema = exports.CreditNoteType$inboundSchema = exports.CreditNoteStatus$outboundSchema = exports.CreditNoteStatus$inboundSchema = exports.CreditNoteType = exports.CreditNoteStatus = void 0;
exports.creditNoteFromJSON = creditNoteFromJSON;
exports.creditNoteInputToJSON = creditNoteInputToJSON;
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 allocation_js_1 = require("./allocation.js");
const currency_js_1 = require("./currency.js");
const customfield_js_1 = require("./customfield.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");
/**
 * Status of credit notes
 */
exports.CreditNoteStatus = {
    Draft: "draft",
    Authorised: "authorised",
    Posted: "posted",
    PartiallyPaid: "partially_paid",
    Paid: "paid",
    Voided: "voided",
    Deleted: "deleted",
};
/**
 * Type of payment
 */
exports.CreditNoteType = {
    AccountsReceivableCredit: "accounts_receivable_credit",
    AccountsPayableCredit: "accounts_payable_credit",
};
/** @internal */
exports.CreditNoteStatus$inboundSchema = openEnums.inboundSchema(exports.CreditNoteStatus);
/** @internal */
exports.CreditNoteStatus$outboundSchema = openEnums.outboundSchema(exports.CreditNoteStatus);
/** @internal */
exports.CreditNoteType$inboundSchema = openEnums.inboundSchema(exports.CreditNoteType);
/** @internal */
exports.CreditNoteType$outboundSchema = openEnums.outboundSchema(exports.CreditNoteType);
/** @internal */
exports.CreditNote$inboundSchema = z.object({
    id: types.string(),
    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(),
    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_amount: types.number(),
    total_tax: z.nullable(types.number()).optional(),
    tax_code: z.nullable(types.string()).optional(),
    balance: z.nullable(types.number()).optional(),
    remaining_credit: z.nullable(types.number()).optional(),
    status: types.optional(exports.CreditNoteStatus$inboundSchema),
    reference: z.nullable(types.string()).optional(),
    date_issued: types.optional(types.date()),
    date_paid: z.nullable(types.date()).optional(),
    type: types.optional(exports.CreditNoteType$inboundSchema),
    account: z.nullable(linkedledgeraccount_js_1.LinkedLedgerAccount$inboundSchema).optional(),
    line_items: types.optional(z.array(invoicelineitem_js_1.InvoiceLineItem$inboundSchema)),
    allocations: types.optional(z.array(allocation_js_1.Allocation$inboundSchema)),
    note: z.nullable(types.string()).optional(),
    terms: z.nullable(types.string()).optional(),
    terms_id: z.nullable(types.string()).optional(),
    billing_address: types.optional(address_js_1.Address$inboundSchema),
    shipping_address: types.optional(address_js_1.Address$inboundSchema),
    tracking_categories: z.nullable(z.array(types.nullable(linkedtrackingcategory_js_1.LinkedTrackingCategory$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, {
        "company_id": "companyId",
        "location_id": "locationId",
        "department_id": "departmentId",
        "currency_rate": "currencyRate",
        "tax_inclusive": "taxInclusive",
        "sub_total": "subTotal",
        "total_amount": "totalAmount",
        "total_tax": "totalTax",
        "tax_code": "taxCode",
        "remaining_credit": "remainingCredit",
        "date_issued": "dateIssued",
        "date_paid": "datePaid",
        "line_items": "lineItems",
        "terms_id": "termsId",
        "billing_address": "billingAddress",
        "shipping_address": "shippingAddress",
        "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 creditNoteFromJSON(jsonString) {
    return (0, schemas_js_1.safeParse)(jsonString, (x) => exports.CreditNote$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'CreditNote' from JSON`);
}
/** @internal */
exports.CreditNoteInput$outboundSchema = z.object({
    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(),
    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(),
    totalAmount: z.number(),
    totalTax: z.nullable(z.number()).optional(),
    taxCode: z.nullable(z.string()).optional(),
    balance: z.nullable(z.number()).optional(),
    remainingCredit: z.nullable(z.number()).optional(),
    status: exports.CreditNoteStatus$outboundSchema.optional(),
    reference: z.nullable(z.string()).optional(),
    dateIssued: z.date().transform(v => v.toISOString()).optional(),
    datePaid: z.nullable(z.date().transform(v => v.toISOString())).optional(),
    type: exports.CreditNoteType$outboundSchema.optional(),
    account: z.nullable(linkedledgeraccount_js_1.LinkedLedgerAccount$outboundSchema).optional(),
    lineItems: z.array(invoicelineitem_js_1.InvoiceLineItemInput$outboundSchema).optional(),
    allocations: z.array(allocation_js_1.AllocationInput$outboundSchema).optional(),
    note: z.nullable(z.string()).optional(),
    terms: z.nullable(z.string()).optional(),
    termsId: z.nullable(z.string()).optional(),
    billingAddress: address_js_1.Address$outboundSchema.optional(),
    shippingAddress: address_js_1.Address$outboundSchema.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, {
        companyId: "company_id",
        locationId: "location_id",
        departmentId: "department_id",
        currencyRate: "currency_rate",
        taxInclusive: "tax_inclusive",
        subTotal: "sub_total",
        totalAmount: "total_amount",
        totalTax: "total_tax",
        taxCode: "tax_code",
        remainingCredit: "remaining_credit",
        dateIssued: "date_issued",
        datePaid: "date_paid",
        lineItems: "line_items",
        termsId: "terms_id",
        billingAddress: "billing_address",
        shippingAddress: "shipping_address",
        trackingCategories: "tracking_categories",
        customFields: "custom_fields",
        rowVersion: "row_version",
        passThrough: "pass_through",
    });
});
function creditNoteInputToJSON(creditNoteInput) {
    return JSON.stringify(exports.CreditNoteInput$outboundSchema.parse(creditNoteInput));
}
//# sourceMappingURL=creditnote.js.map