import { Schema, model } from 'mongoose';
import { paginate, toJSON } from '@/shared/utils/plugins/index.js';
import { IQuotationDoc, IQuotationModel } from './quotation.interface';

const quotationSchema = new Schema<IQuotationDoc>(
  {
    companyId: { type: Schema.Types.ObjectId, ref: 'Company' },
    project: { type: Schema.Types.ObjectId, ref: 'Project' },
    termsConditions: { type: String, required: true },
    createdBy: { type: Schema.Types.ObjectId, ref: 'User' },
    updatedBy: { type: Schema.Types.ObjectId, ref: 'User' },
  },
  {
    timestamps: true,
  },
);

quotationSchema.plugin(toJSON);
quotationSchema.plugin(paginate);

export const Quotation = model<IQuotationDoc, IQuotationModel>(
  'Quotation',
  quotationSchema,
);
