import { DataTypes } from 'sequelize';
import sequelize from '../database.js';

const BillingTemplate = sequelize.define('BillingTemplate', {
  id: {
    type: DataTypes.INTEGER,
    primaryKey: true,
    autoIncrement: true,
    allowNull: false
  },
  clubId: {
    type: DataTypes.INTEGER,
    allowNull: false,
    field: 'club_id'
  },
  name: {
    type: DataTypes.STRING(255),
    allowNull: false
  },
  description: {
    type: DataTypes.TEXT,
    allowNull: true
  },
  pdfStoragePath: {
    type: DataTypes.STRING(1000),
    allowNull: false,
    field: 'pdf_storage_path'
  },
  pdfFilename: {
    type: DataTypes.STRING(255),
    allowNull: false,
    field: 'pdf_filename'
  },
  pdfMimeType: {
    type: DataTypes.STRING(100),
    allowNull: false,
    defaultValue: 'application/pdf',
    field: 'pdf_mime_type'
  },
  isActive: {
    type: DataTypes.BOOLEAN,
    allowNull: false,
    defaultValue: true,
    field: 'is_active'
  },
  version: {
    type: DataTypes.INTEGER,
    allowNull: false,
    defaultValue: 1
  },
  createdByUserId: {
    type: DataTypes.INTEGER,
    allowNull: true,
    field: 'created_by_user_id'
  }
}, {
  tableName: 'billing_template',
  underscored: true,
  timestamps: true
});

export default BillingTemplate;
