"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.YieldData = exports.YieldDataSchema = exports.YIELD_TOTALS_MAP = exports.ETotalType = exports.yieldParamsValidationSchema = void 0;
const joi_1 = __importDefault(require("joi"));
const mongoose_1 = __importDefault(require("mongoose"));
const _models_1 = require("./_models");
exports.yieldParamsValidationSchema = joi_1.default.object({
    periodStart: joi_1.default.object({
        month: joi_1.default.number().integer().min(1).max(12),
        year: joi_1.default.number().integer().min(1900).max(9999),
    }),
    periodEnd: joi_1.default.object({
        month: joi_1.default.number().integer().min(1).max(12),
        year: joi_1.default.number().integer().min(1900).max(9999),
    }),
    forLifetime: joi_1.default.boolean(),
    ignoreOldData: joi_1.default.boolean(),
});
var ETotalType;
(function (ETotalType) {
    ETotalType["AVERAGE_BALANCE"] = "AVERAGE_BALANCE";
    ETotalType["AVERAGE_LIFE_BALANCE"] = "AVERAGE_LIFE_BALANCE";
    ETotalType["BROKER"] = "BROKER";
    ETotalType["GROSS"] = "GROSS";
    ETotalType["NET"] = "NET";
    ETotalType["APR"] = "APR";
    ETotalType["APR_GROSS"] = "APR_GROSS";
    ETotalType["APR_LIFE_GROSS"] = "APR_LIFE_GROSS";
})(ETotalType || (exports.ETotalType = ETotalType = {}));
exports.YIELD_TOTALS_MAP = {
    [ETotalType.AVERAGE_BALANCE]: { order: -2, title: 'Average Balance in Month $', class: 'whiteOnOrange' },
    [ETotalType.AVERAGE_LIFE_BALANCE]: { order: -1, title: 'Average loan life balance $', class: 'whiteOnOrange' },
    [ETotalType.GROSS]: { order: 1, title: 'Gross income $', class: 'whiteOnGray' },
    [ETotalType.BROKER]: { order: 2, title: 'Broker Fees $', class: 'whiteOnGray' },
    [ETotalType.NET]: { order: 3, title: 'Net income $', class: 'whiteOnGray' },
    [ETotalType.APR]: { order: 5, title: 'Yield APR', class: 'whiteOnGray' },
    [ETotalType.APR_GROSS]: { order: 6, title: 'Yield in month', class: 'whiteOnBlack' },
    [ETotalType.APR_LIFE_GROSS]: { order: 7, title: 'Yield since inception', class: 'whiteOnBlack' },
};
exports.YieldDataSchema = new mongoose_1.default.Schema({
    productId: {
        type: mongoose_1.default.Schema.Types.ObjectId,
        ref: _models_1.MODEL_NAMES.loanProducts,
        required: false,
    },
    chargeId: {
        type: mongoose_1.default.Schema.Types.ObjectId,
        ref: _models_1.MODEL_NAMES.loanCharges,
        required: false,
    },
    totalType: {
        type: String,
    },
    year: {
        type: Number,
        required: true,
    },
    month: {
        type: Number,
        required: true,
    },
    value: {
        type: Number,
    },
    valuePercent: {
        type: Number,
    },
}, {
    timestamps: { createdAt: false, updatedAt: false },
});
exports.YieldData = mongoose_1.default.model(_models_1.MODEL_NAMES.yieldData, exports.YieldDataSchema);
