"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.EquipmentSchema = void 0;
const mongoose_1 = __importDefault(require("mongoose"));
const _models_1 = require("./_models");
const equipment_types_enum_1 = require("../enums/equipment-types.enum");
const mongooseLeanId = require('../plugins/id.plugin');
exports.EquipmentSchema = new mongoose_1.default.Schema({
    borrowerId: {
        type: mongoose_1.default.Schema.Types.ObjectId,
        ref: _models_1.MODEL_NAMES.borrowers,
        required: true,
    },
    date: {
        type: Date,
        required: true,
    },
    summary: {
        [equipment_types_enum_1.EEquipmentTypes.EQUIPMENT]: {
            amount: {
                type: Number,
                required: true,
            },
            availability: {
                type: Number,
                required: true,
            },
            advanceRate: {
                type: Number,
                required: true,
            },
        },
        [equipment_types_enum_1.EEquipmentTypes.REAL_ESTATE]: {
            amount: {
                type: Number,
                required: true,
            },
            availability: {
                type: Number,
                required: true,
            },
            advanceRate: {
                type: Number,
                required: true,
            },
        },
        [equipment_types_enum_1.EEquipmentTypes.BOOT_COLLATERAL]: {
            amount: {
                type: Number,
                required: true,
            },
            availability: {
                type: Number,
                required: true,
            },
            advanceRate: {
                type: Number,
                required: true,
            },
        },
        netTotal: {
            amount: {
                type: Number,
                required: true,
            },
            availability: {
                type: Number,
                required: true,
            },
            advanceRate: {
                type: Number,
                required: true,
            },
        },
        [equipment_types_enum_1.EEquipmentTypes.INTELLECTUAL_PROPERTY]: {
            amount: {
                type: Number,
                required: true,
            },
            availability: {
                type: Number,
                required: true,
            },
            advanceRate: {
                type: Number,
                required: true,
            },
        },
        grossTotal: {
            amount: {
                type: Number,
                required: true,
            },
            availability: {
                type: Number,
                required: true,
            },
            advanceRate: {
                type: Number,
                required: true,
            },
        },
    },
    items: [
        {
            active: {
                type: Boolean,
                required: true,
            },
            inventoryName: {
                type: String,
                trim: true,
                required: true,
            },
            type: {
                type: String,
                required: true,
                trim: true,
            },
            amount: {
                type: Number,
                required: true,
            },
            advanceRate: {
                type: Number,
                required: false,
            },
            productId: {
                type: mongoose_1.default.Types.ObjectId,
                ref: _models_1.MODEL_NAMES.loanProducts,
                required: false,
            }
        },
    ],
    __v: { type: Number, select: false },
}, { timestamps: true });
exports.EquipmentSchema.plugin(mongooseLeanId);
exports.default = mongoose_1.default.model(_models_1.MODEL_NAMES.equipment, exports.EquipmentSchema);
