"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.ProductBrokerModel = exports.ProductBrokerSchema = exports.ProductBrokerValidationSchema = void 0;
const mongoose_1 = __importDefault(require("mongoose"));
const joi_1 = __importDefault(require("joi"));
const _models_1 = require("./_models");
exports.ProductBrokerValidationSchema = joi_1.default.object({
    _id: joi_1.default.string().required(),
    order: joi_1.default.number(),
    borrowerId: joi_1.default.string().required(),
    active: joi_1.default.boolean().required(),
    loanBrokerId: joi_1.default.string().required(),
    BSCode: joi_1.default.string().required(),
    PLCode: joi_1.default.string().required(),
    productId: joi_1.default.string().required(),
    interestShare: joi_1.default.number().required(),
    adminShare: joi_1.default.number().required(),
    otherShare: joi_1.default.number().required(),
});
exports.ProductBrokerSchema = new mongoose_1.default.Schema({
    borrowerId: {
        type: mongoose_1.default.Schema.Types.ObjectId,
        ref: _models_1.MODEL_NAMES.borrowers,
        required: true,
    },
    order: {
        type: Number,
        required: true,
    },
    active: {
        type: Boolean,
        required: true,
    },
    loanBrokerId: {
        type: mongoose_1.default.Schema.Types.ObjectId,
        ref: _models_1.MODEL_NAMES.loanBrokers,
        required: true,
    },
    BSCode: {
        type: String,
        required: true,
        trim: true,
    },
    PLCode: {
        type: String,
        required: true,
        trim: true,
    },
    productId: {
        type: mongoose_1.default.Schema.Types.ObjectId,
        ref: _models_1.MODEL_NAMES.loanProducts,
        required: true,
    },
    interestShare: {
        type: Number,
        required: true,
    },
    adminShare: {
        type: Number,
        required: true,
    },
    otherShare: {
        type: Number,
        required: true,
    },
    __v: { type: Number, select: false },
}, { timestamps: true });
exports.ProductBrokerModel = mongoose_1.default.model(_models_1.MODEL_NAMES.productBrokers, exports.ProductBrokerSchema);
