"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.FinancialSpreading = exports.FinancialSpreadingSchema = exports.financialSpreadingParamsValidationSchema = exports.financialSpreadingViewValidationSchema = exports.FinancialSpreadingDTO = void 0;
const joi_1 = __importDefault(require("joi"));
const mongoose_1 = __importDefault(require("mongoose"));
const _models_1 = require("./_models");
const db_data_helper_1 = require("../helpers/db-data.helper");
const FinancialSpreadingSheet_model_1 = require("./FinancialSpreadingSheet.model");
class FinancialSpreadingDTO extends db_data_helper_1.BasicDTO {
    borrowerId;
    year;
    month;
    sheetId;
    amount;
}
exports.FinancialSpreadingDTO = FinancialSpreadingDTO;
exports.financialSpreadingViewValidationSchema = joi_1.default.object({
    _id: joi_1.default.string().required(),
    borrowerId: joi_1.default.string().required(),
    month: joi_1.default.number().integer().min(1).max(12),
    year: joi_1.default.number().integer().min(1900).max(9999),
    sheetId: joi_1.default.string().required(),
    amount: joi_1.default.number().required().allow(0),
    minus_1: joi_1.default.number(),
    minus_2: joi_1.default.number(),
    minus_3: joi_1.default.number(),
});
exports.financialSpreadingParamsValidationSchema = joi_1.default.object({
    borrowerId: joi_1.default.string().required(),
    selectedMonth: joi_1.default.object({
        month: joi_1.default.number().integer().min(1).max(12),
        year: joi_1.default.number().integer().min(1900).max(9999),
    }).required(),
    financialSpreadingType: joi_1.default.string().valid(...Object.values(FinancialSpreadingSheet_model_1.EFinancialSpreadingType)),
});
exports.FinancialSpreadingSchema = new mongoose_1.default.Schema({
    borrowerId: {
        type: mongoose_1.default.Schema.Types.ObjectId,
        ref: _models_1.MODEL_NAMES.borrowers,
        required: true,
    },
    year: {
        type: Number,
        required: true,
    },
    month: {
        type: Number,
        required: true,
    },
    sheetId: {
        type: mongoose_1.default.Schema.Types.ObjectId,
        ref: _models_1.MODEL_NAMES.financialSpreadingSheets,
        required: true,
    },
    amount: {
        type: Number,
        required: true,
    },
}, {
    timestamps: { createdAt: true, updatedAt: true },
});
exports.FinancialSpreading = mongoose_1.default.model(_models_1.MODEL_NAMES.financialSpreading, exports.FinancialSpreadingSchema);
