"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.ReserveSchema = void 0;
const mongoose_1 = __importDefault(require("mongoose"));
const _models_1 = require("./_models");
const reserve_types_enum_1 = require("../enums/reserve-types.enum");
const mongooseLeanId = require('../plugins/id.plugin');
exports.ReserveSchema = new mongoose_1.default.Schema({
    bbcDateId: {
        type: mongoose_1.default.Schema.Types.ObjectId,
        ref: _models_1.MODEL_NAMES.BBCDates,
        required: true,
    },
    summary: {
        [reserve_types_enum_1.EReserveTypes.RENT]: {
            amount: {
                type: Number,
                required: true,
            }
        },
        [reserve_types_enum_1.EReserveTypes.PAYROLL]: {
            amount: {
                type: Number,
                required: true,
            }
        },
        [reserve_types_enum_1.EReserveTypes.INSURANCE]: {
            amount: {
                type: Number,
                required: true,
            }
        },
        [reserve_types_enum_1.EReserveTypes.TAX]: {
            amount: {
                type: Number,
                required: true,
            }
        },
        [reserve_types_enum_1.EReserveTypes.OTHER]: {
            amount: {
                type: Number,
                required: true,
            }
        },
        [reserve_types_enum_1.EReserveTypes.INVENTORY]: {
            amount: {
                type: Number,
                required: true,
            }
        },
        [reserve_types_enum_1.EReserveTypes.RECEIVABLES]: {
            amount: {
                type: Number,
                required: true,
            }
        },
        [reserve_types_enum_1.EReserveTypes.EQUIPMENT]: {
            amount: {
                type: Number,
                required: true,
            }
        },
    },
    items: [
        {
            active: {
                type: Boolean,
                required: true,
            },
            reserveName: {
                type: String,
                trim: true,
                required: true,
            },
            type: {
                type: String,
                required: true,
                trim: true,
            },
            amount: {
                type: Number,
                required: true,
            },
        },
    ],
    notes: {
        type: String,
        required: false,
        trim: true,
    },
    __v: { type: Number, select: false },
}, { timestamps: true });
exports.ReserveSchema.plugin(mongooseLeanId);
exports.default = mongoose_1.default.model(_models_1.MODEL_NAMES.reserves, exports.ReserveSchema);
