"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.ReceivableItemModel = exports.ReceivableItemSchema = exports.RECEIVABLE_FIELDS = void 0;
const mongoose_1 = __importDefault(require("mongoose"));
const _models_1 = require("./_models");
const mongooseLeanId = require('../plugins/id.plugin');
exports.RECEIVABLE_FIELDS = [
    '_id',
    'invoiceDate',
    'invoiceNumber',
    'customerTitle',
    'dueDate',
    'invoiceAmount',
    'originalAmount',
    'invoiceDetail1',
    'invoiceDetail2',
    'invoiceDetail3',
];
exports.ReceivableItemSchema = new mongoose_1.default.Schema({
    bbcSheetId: {
        type: mongoose_1.default.Schema.Types.ObjectId,
        ref: _models_1.MODEL_NAMES.BBCSheets,
        required: true,
    },
    order: {
        type: Number,
        required: true,
    },
    invoiceNumber: {
        type: String,
        trim: true,
        required: true,
    },
    invoiceDate: {
        type: Date,
        required: true,
    },
    customerTitle: {
        type: String,
        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.ReceivableItemSchema.index({ customerTitle: 'text' });
exports.ReceivableItemSchema.plugin(mongooseLeanId);
exports.ReceivableItemModel = mongoose_1.default.model(_models_1.MODEL_NAMES.receivableItems, exports.ReceivableItemSchema);
