const mongoose = require('mongoose');

const Schema = mongoose.Schema;

const cardTypeSchema = new Schema(
    {
        telco: { type: String, required: true }, // e.g., 'VIETTEL'
        value: { type: Number, required: true }, // e.g., 10000
        fee: { type: Number, required: true, default: 0 }, // Custom fee percentage
        status: { type: Boolean, default: true },
    },
    {
        timestamps: true,
    },
);

// Create compound index for unique config per card type + value
cardTypeSchema.index({ telco: 1, value: 1 }, { unique: true });

module.exports = mongoose.model('cardType', cardTypeSchema);
