"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.HistoricalLoanCharge = exports.HistoricalLoanChargeSchema = exports.HistoricalLoanChargeUpdateValidationSchema = exports.HistoricalLoanChargeCreateValidationSchema = void 0;
const mongoose_1 = __importDefault(require("mongoose"));
const joi_1 = __importDefault(require("joi"));
const _models_1 = require("./_models");
exports.HistoricalLoanChargeCreateValidationSchema = joi_1.default.object({
    loanProductId: joi_1.default.string().required(),
    date: joi_1.default.date().required(),
    paymentDate: joi_1.default.date().required(),
    chargeId: joi_1.default.string().required(),
    source: joi_1.default.string().required(),
    chargeName: joi_1.default.string().required(),
    amount: joi_1.default.number().required(),
    amountPaid: joi_1.default.number().required(),
});
exports.HistoricalLoanChargeUpdateValidationSchema = joi_1.default.object({
    _id: joi_1.default.string().required(),
    loanProductId: joi_1.default.string(),
    date: joi_1.default.date(),
    paymentDate: joi_1.default.date(),
    chargeId: joi_1.default.string(),
    source: joi_1.default.string(),
    chargeName: joi_1.default.string(),
    amount: joi_1.default.number(),
    amountPaid: joi_1.default.number(),
});
exports.HistoricalLoanChargeSchema = new mongoose_1.default.Schema({
    loanProductId: {
        type: mongoose_1.default.Schema.Types.ObjectId,
        ref: _models_1.MODEL_NAMES.loanProducts,
        required: true,
    },
    date: {
        type: Date,
        required: true,
    },
    paymentDate: {
        type: Date,
        required: true,
    },
    source: {
        type: String,
        required: true,
    },
    chargeId: {
        type: mongoose_1.default.Schema.Types.ObjectId,
        ref: _models_1.MODEL_NAMES.loanCharges,
        required: true,
    },
    chargeName: {
        type: String,
        required: true,
    },
    amount: {
        type: Number,
        required: true,
    },
    amountPaid: {
        type: Number,
        required: true,
    },
}, {
    timestamps: { createdAt: true, updatedAt: true },
    versionKey: false,
});
exports.HistoricalLoanChargeSchema.index({ loanProductId: 1, chargeId: 1, date: 1 }, { unique: true });
exports.HistoricalLoanCharge = mongoose_1.default.model(_models_1.MODEL_NAMES.historicalLoanCharges, exports.HistoricalLoanChargeSchema);
