"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.ReceivableModel = exports.ReceivableSchema = void 0;
const mongoose_1 = __importDefault(require("mongoose"));
const _models_1 = require("./_models");
const mongooseLeanId = require('../plugins/id.plugin');
exports.ReceivableSchema = new mongoose_1.default.Schema({
    borrowerId: {
        type: String,
        trim: true,
        required: true,
    },
    bbcDate: {
        type: Date,
        required: true,
    },
    uploadUser: {
        type: String,
        trim: true,
    },
    fileHash: {
        type: String,
        trim: true,
    },
    fileName: {
        type: String,
        trim: true,
    },
    sheetName: {
        type: String,
        trim: true,
    },
    invoices: [
        {
            bbcDate: {
                type: Date,
                required: true,
            },
            invoiceNumber: {
                type: String,
                trim: true,
                required: true,
            },
            invoiceDate: {
                type: Date,
                required: true,
            },
            customerTitle: {
                type: String,
                required: true,
                trim: true,
                default: 'No Title',
            },
            invoiceAmount: {
                type: Number,
                required: true,
            },
            originalAmount: {
                type: Number,
                required: false,
            },
            dueDate: {
                type: Date,
            },
            invoiceDetail1: {
                type: String,
                trim: true,
            },
            invoiceDetail2: {
                type: String,
                trim: true,
            },
            invoiceDetail3: {
                type: String,
                trim: true,
            },
        },
    ],
    __v: { type: Number, select: false },
}, { timestamps: true });
exports.ReceivableSchema.plugin(mongooseLeanId);
exports.ReceivableModel = mongoose_1.default.model(_models_1.MODEL_NAMES.receivables, exports.ReceivableSchema);
