// //modals/admin/orgModal.js
// const mongoose = require("mongoose");

// const orgSchema = new mongoose.Schema(
//     {
//         orgName: {
//             type: String,
//             required: [true, "Organization name is required"],
//             trim: true,
//             minlength: [3, "Organization name must be at least 3 characters long"],
//             maxlength: [150, "Organization name cannot exceed 150 characters"],
//         },
//         status: {
//             type: Boolean,
//             default: true, // active by default
//         },
//         isDeleted: {
//             type: Boolean,
//             default: false, // soft delete flag
//         },
//         createdBy: {
//             type: mongoose.Schema.Types.ObjectId,
//             ref: "User",
//             required: true,
//         },
//         updatedBy: {
//             type: mongoose.Schema.Types.ObjectId,
//             ref: "User",
//             required: true,
//         },
//     },
//     {
//         timestamps: true,
//     }
// );

// module.exports = mongoose.model("Organization", orgSchema);
// models/admin/orgModel.js
// models/admin/orgModel.js
const mongoose = require("mongoose");

const orgSchema = new mongoose.Schema(
  {
    orgName: {
      type: String,
      required: true,
      trim: true,
      minlength: 3,
      maxlength: 150,
    },

    // Required for invoice display
    address: {
      type: String,
      required: true,
    },

    gstin: {
      type: String,
      default: null, // optional but GST-ready
      uppercase: true,
      trim: true,
    },

    status: {
      type: Boolean,
      default: true,
    },

    isDeleted: {
      type: Boolean,
      default: false,
    },

    createdBy: {
      type: mongoose.Schema.Types.ObjectId,
      ref: "User",
      required: true,
    },

    updatedBy: {
      type: mongoose.Schema.Types.ObjectId,
      ref: "User",
      required: true,
    },
  },
  { timestamps: true }
);

module.exports = mongoose.model("Organization", orgSchema);
