"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.BillInput$outboundSchema = exports.Bill$inboundSchema = exports.AmortizationType$outboundSchema = exports.AmortizationType$inboundSchema = exports.BillStatus$outboundSchema = exports.BillStatus$inboundSchema = exports.AmortizationType = exports.BillStatus = void 0;
exports.billFromJSON = billFromJSON;
exports.billInputToJSON = billInputToJSON;
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 bankaccount_js_1 = require("./bankaccount.js");
const billlineitem_js_1 = require("./billlineitem.js");
const billlineiteminput_js_1 = require("./billlineiteminput.js");
const currency_js_1 = require("./currency.js");
const customfield_js_1 = require("./customfield.js");
const linkedattachment_js_1 = require("./linkedattachment.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");
/**
 * Invoice status
 */
exports.BillStatus = {
    Draft: "draft",
    Submitted: "submitted",
    Authorised: "authorised",
    PartiallyPaid: "partially_paid",
    Paid: "paid",
    Void: "void",
    Credit: "credit",
    Deleted: "deleted",
    Posted: "posted",
};
/**
 * Type of amortization
 */
exports.AmortizationType = {
    Manual: "manual",
    Receipt: "receipt",
    Schedule: "schedule",
    Other: "other",
};
/** @internal */
exports.BillStatus$inboundSchema = openEnums.inboundSchema(exports.BillStatus);
/** @internal */
exports.BillStatus$outboundSchema = openEnums.outboundSchema(exports.BillStatus);
/** @internal */
exports.AmortizationType$inboundSchema = openEnums.inboundSchema(exports.AmortizationType);
/** @internal */
exports.AmortizationType$outboundSchema = openEnums.outboundSchema(exports.AmortizationType);
/** @internal */
exports.Bill$inboundSchema = z
    .object({
    id: types.optional(types.string()),
    downstream_id: z.nullable(types.string()).optional(),
    display_id: z.nullable(types.string()).optional(),
    bill_number: z.nullable(types.string()).optional(),
    supplier: z.nullable(linkedsupplier_js_1.LinkedSupplier$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(),
    bill_date: z.nullable(types.date()).optional(),
    due_date: z.nullable(types.date()).optional(),
    paid_date: z.nullable(types.date()).optional(),
    po_number: z.nullable(types.string()).optional(),
    reference: z.nullable(types.string()).optional(),
    line_items: types.optional(z.array(billlineitem_js_1.BillLineItem$inboundSchema)),
    terms: z.nullable(types.string()).optional(),
    terms_id: z.nullable(types.string()).optional(),
    balance: z.nullable(types.number()).optional(),
    deposit: z.nullable(types.number()).optional(),
    sub_total: z.nullable(types.number()).optional(),
    total_tax: z.nullable(types.number()).optional(),
    total: z.nullable(types.number()).optional(),
    tax_code: z.nullable(types.string()).optional(),
    notes: z.nullable(types.string()).optional(),
    status: z.nullable(exports.BillStatus$inboundSchema).optional(),
    ledger_account: z.nullable(linkedledgeraccount_js_1.LinkedLedgerAccount$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),
    discount_percentage: z.nullable(types.number()).optional(),
    template_id: z.nullable(types.string()).optional(),
    approved_by: z.nullable(types.string()).optional(),
    amortization_type: z.nullable(exports.AmortizationType$inboundSchema).optional(),
    tax_method: z.nullable(types.string()).optional(),
    document_received: z.nullable(types.boolean()).optional(),
    source_document_url: z.nullable(types.string()).optional(),
    tracking_categories: z.nullable(z.array(types.nullable(linkedtrackingcategory_js_1.LinkedTrackingCategory$inboundSchema))).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(),
    row_version: z.nullable(types.string()).optional(),
    custom_fields: types.optional(z.array(customfield_js_1.CustomField$inboundSchema)),
    custom_mappings: z.nullable(z.record(z.any())).optional(),
    pass_through: types.optional(z.array(passthroughbody_js_1.PassThroughBody$inboundSchema)),
    accounting_period: z.nullable(types.string()).optional(),
    attachments: types.optional(z.array(types.nullable(linkedattachment_js_1.LinkedAttachment$inboundSchema))),
}).transform((v) => {
    return (0, primitives_js_1.remap)(v, {
        "downstream_id": "downstreamId",
        "display_id": "displayId",
        "bill_number": "billNumber",
        "company_id": "companyId",
        "location_id": "locationId",
        "department_id": "departmentId",
        "currency_rate": "currencyRate",
        "tax_inclusive": "taxInclusive",
        "bill_date": "billDate",
        "due_date": "dueDate",
        "paid_date": "paidDate",
        "po_number": "poNumber",
        "line_items": "lineItems",
        "terms_id": "termsId",
        "sub_total": "subTotal",
        "total_tax": "totalTax",
        "tax_code": "taxCode",
        "ledger_account": "ledgerAccount",
        "payment_method": "paymentMethod",
        "accounting_by_row": "accountingByRow",
        "bank_account": "bankAccount",
        "discount_percentage": "discountPercentage",
        "template_id": "templateId",
        "approved_by": "approvedBy",
        "amortization_type": "amortizationType",
        "tax_method": "taxMethod",
        "document_received": "documentReceived",
        "source_document_url": "sourceDocumentUrl",
        "tracking_categories": "trackingCategories",
        "updated_by": "updatedBy",
        "created_by": "createdBy",
        "updated_at": "updatedAt",
        "created_at": "createdAt",
        "row_version": "rowVersion",
        "custom_fields": "customFields",
        "custom_mappings": "customMappings",
        "pass_through": "passThrough",
        "accounting_period": "accountingPeriod",
    });
});
function billFromJSON(jsonString) {
    return (0, schemas_js_1.safeParse)(jsonString, (x) => exports.Bill$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Bill' from JSON`);
}
/** @internal */
exports.BillInput$outboundSchema = z.object({
    displayId: z.nullable(z.string()).optional(),
    billNumber: z.nullable(z.string()).optional(),
    supplier: z.nullable(linkedsupplierinput_js_1.LinkedSupplierInput$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(),
    billDate: 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(),
    paidDate: z.nullable(z.date().transform(v => v.toISOString().slice(0, "YYYY-MM-DD".length))).optional(),
    poNumber: z.nullable(z.string()).optional(),
    reference: z.nullable(z.string()).optional(),
    lineItems: z.array(billlineiteminput_js_1.BillLineItemInput$outboundSchema).optional(),
    terms: z.nullable(z.string()).optional(),
    termsId: z.nullable(z.string()).optional(),
    balance: z.nullable(z.number()).optional(),
    deposit: z.nullable(z.number()).optional(),
    subTotal: z.nullable(z.number()).optional(),
    totalTax: z.nullable(z.number()).optional(),
    total: z.nullable(z.number()).optional(),
    taxCode: z.nullable(z.string()).optional(),
    notes: z.nullable(z.string()).optional(),
    status: z.nullable(exports.BillStatus$outboundSchema).optional(),
    ledgerAccount: z.nullable(linkedledgeraccount_js_1.LinkedLedgerAccount$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(),
    discountPercentage: z.nullable(z.number()).optional(),
    templateId: z.nullable(z.string()).optional(),
    approvedBy: z.nullable(z.string()).optional(),
    amortizationType: z.nullable(exports.AmortizationType$outboundSchema).optional(),
    taxMethod: z.nullable(z.string()).optional(),
    documentReceived: z.nullable(z.boolean()).optional(),
    sourceDocumentUrl: z.nullable(z.string()).optional(),
    trackingCategories: z.nullable(z.array(z.nullable(linkedtrackingcategory_js_1.LinkedTrackingCategory$outboundSchema))).optional(),
    rowVersion: z.nullable(z.string()).optional(),
    customFields: z.array(customfield_js_1.CustomField$outboundSchema).optional(),
    passThrough: z.array(passthroughbody_js_1.PassThroughBody$outboundSchema).optional(),
    accountingPeriod: z.nullable(z.string()).optional(),
    attachments: z.array(z.nullable(linkedattachment_js_1.LinkedAttachment$outboundSchema)).optional(),
}).transform((v) => {
    return (0, primitives_js_1.remap)(v, {
        displayId: "display_id",
        billNumber: "bill_number",
        companyId: "company_id",
        locationId: "location_id",
        departmentId: "department_id",
        currencyRate: "currency_rate",
        taxInclusive: "tax_inclusive",
        billDate: "bill_date",
        dueDate: "due_date",
        paidDate: "paid_date",
        poNumber: "po_number",
        lineItems: "line_items",
        termsId: "terms_id",
        subTotal: "sub_total",
        totalTax: "total_tax",
        taxCode: "tax_code",
        ledgerAccount: "ledger_account",
        paymentMethod: "payment_method",
        accountingByRow: "accounting_by_row",
        bankAccount: "bank_account",
        discountPercentage: "discount_percentage",
        templateId: "template_id",
        approvedBy: "approved_by",
        amortizationType: "amortization_type",
        taxMethod: "tax_method",
        documentReceived: "document_received",
        sourceDocumentUrl: "source_document_url",
        trackingCategories: "tracking_categories",
        rowVersion: "row_version",
        customFields: "custom_fields",
        passThrough: "pass_through",
        accountingPeriod: "accounting_period",
    });
});
function billInputToJSON(billInput) {
    return JSON.stringify(exports.BillInput$outboundSchema.parse(billInput));
}
//# sourceMappingURL=bill.js.map