"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.BBCDateModel = exports.BBCDateSchema = exports.ICreateBBCDateSchema = void 0;
const joi_1 = __importDefault(require("joi"));
const mongoose_1 = __importDefault(require("mongoose"));
const _models_1 = require("./_models");
const mongooseLeanId = require('../plugins/id.plugin');
exports.ICreateBBCDateSchema = joi_1.default.object({
    date: joi_1.default.date().required(),
    inventory: joi_1.default.boolean().required(),
    receivables: joi_1.default.boolean().required(),
    borrowerId: joi_1.default.string().required(),
});
exports.BBCDateSchema = new mongoose_1.default.Schema({
    borrowerId: {
        type: mongoose_1.default.Schema.Types.ObjectId,
        ref: _models_1.MODEL_NAMES.borrowers,
        required: true,
    },
    bbcDate: {
        type: Date,
        required: true,
    },
    __v: { type: Number, select: false },
}, { timestamps: true });
exports.BBCDateSchema.plugin(mongooseLeanId);
exports.BBCDateSchema.index({
    borrowerId: 1,
    bbcDate: -1,
});
exports.BBCDateModel = mongoose_1.default.model(_models_1.MODEL_NAMES.BBCDates, exports.BBCDateSchema);
