/** * Processor Model for Value Chain * Represents processors who transform raw materials into by-products */ import mongoose from "mongoose"; const processorSchema = new mongoose.Schema( { userId: { type: mongoose.Schema.Types.ObjectId, ref: "User", required: true, unique: true, }, businessName: { type: String, required: true, trim: true, maxlength: 200, }, businessType: { type: String, enum: ["oil_mill", "refinery", "solvent_extraction", "packaging", "export", "other"], required: true, }, registrationNumber: { type: String, trim: true, }, gstNumber: { type: String, trim: true, }, fssaiLicense: { type: String, trim: true, }, location: { type: { type: String, enum: ["Point"], required: true, default: "Point", }, coordinates: { type: [Number], required: true, }, address: String, district: String, state: String, pincode: String, }, processingCapacity: { daily: Number, // in kg monthly: Number, unit: { type: String, default: "kg", }, }, productsProcessed: [ { type: String, enum: [ "groundnut_oil", "sunflower_oil", "soybean_oil", "mustard_oil", "oilseed_meal", "oilseed_cake", "oilseed_husk", "refined_oil", "crude_oil", "other", ], }, ], rawMaterialsNeeded: [ { productType: String, quantityPerMonth: Number, preferredGrade: String, }, ], certifications: [ { name: String, issuer: String, validUntil: Date, documentUrl: String, }, ], bankDetails: { accountName: String, accountNumber: String, ifscCode: String, bankName: String, // Encrypted in production }, contactPerson: { name: String, phone: String, email: String, designation: String, }, rating: { average: { type: Number, min: 0, max: 5, default: 0, }, count: { type: Number, default: 0, }, }, verified: { type: Boolean, default: false, }, verifiedAt: Date, status: { type: String, enum: ["active", "inactive", "suspended", "pending_verification"], default: "pending_verification", }, transformRequests: [ { type: mongoose.Schema.Types.ObjectId, ref: "TransformRequest", }, ], }, { timestamps: true, } ); // Geospatial index processorSchema.index({ location: "2dsphere" }); processorSchema.index({ businessType: 1, status: 1 }); processorSchema.index({ "productsProcessed": 1 }); const Processor = mongoose.model("Processor", processorSchema); export default Processor;