File size: 1,056 Bytes
8c7b7ca
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
const { mongoose, baseSchemaOptions } = require('./base');

const VendorSchema = new mongoose.Schema({
  name: { type: String, required: true, trim: true },
  pan: { type: String, trim: true, default: null },
  gstin: { type: String, trim: true, default: null },
  vendor_code: { type: String, required: true, trim: true },
  epf_code: { type: String, trim: true, default: null },
  esi_code: { type: String, trim: true, default: null },
  work_order_no: { type: String, trim: true, default: null },
  contract_start: { type: Date, default: null },
  contract_end: { type: Date, default: null },
  max_workers: { type: Number, default: null },
  form1_path: { type: String, default: null },
  form2_path: { type: String, default: null },
  is_active: { type: Boolean, default: true }
}, baseSchemaOptions());

VendorSchema.index({ vendor_code: 1 }, { unique: true });
VendorSchema.index({ pan: 1 }, { unique: true, sparse: true });
VendorSchema.index({ gstin: 1 }, { unique: true, sparse: true });

module.exports = mongoose.model('Vendor', VendorSchema);