"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.LoanPaymentModel = exports.LoanPaymentSchema = exports.LOAN_PAYMENT_FIELDS = void 0;
const mongoose_1 = __importDefault(require("mongoose"));
const _models_1 = require("./_models");
exports.LOAN_PAYMENT_FIELDS = [
    '_id',
    'date',
    'productId',
    'amount',
    'paid',
    'settlementCode',
    'paymentOrder',
];
exports.LoanPaymentSchema = new mongoose_1.default.Schema({
    date: {
        type: Date,
        required: true,
    },
    productId: {
        type: mongoose_1.default.Schema.Types.ObjectId,
        ref: _models_1.MODEL_NAMES.loanProducts,
        required: true,
    },
    amount: {
        type: Number,
        required: true,
    },
    paid: [
        {
            statementId: {
                type: mongoose_1.default.Schema.Types.ObjectId,
                ref: _models_1.MODEL_NAMES.loanStatements,
            },
            amount: {
                type: Number,
            },
        },
    ],
    loanTransactions: [
        {
            transactionId: {
                type: mongoose_1.default.Schema.Types.ObjectId,
                ref: _models_1.MODEL_NAMES.loanTransactions,
            },
            amount: {
                type: Number,
            },
        },
    ],
    settlementCode: {
        type: String,
        trim: true,
    },
    paymentOrder: [{
            type: String,
        }],
    __v: { type: Number, select: false },
}, { timestamps: true });
exports.LoanPaymentModel = mongoose_1.default.model(_models_1.MODEL_NAMES.loanPayments, exports.LoanPaymentSchema);
