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

const BillingDocument = sequelize.define('BillingDocument', {
  id: {
    type: DataTypes.INTEGER,
    primaryKey: true,
    autoIncrement: true,
    allowNull: false
  },
  runId: {
    type: DataTypes.INTEGER,
    allowNull: false,
    field: 'run_id'
  },
  displayName: {
    type: DataTypes.STRING(255),
    allowNull: false,
    field: 'display_name'
  },
  status: {
    type: DataTypes.ENUM('draft', 'generated', 'error'),
    allowNull: false,
    defaultValue: 'draft'
  },
  pdfStoragePath: {
    type: DataTypes.STRING(1000),
    allowNull: true,
    field: 'pdf_storage_path'
  },
  pdfFilename: {
    type: DataTypes.STRING(255),
    allowNull: true,
    field: 'pdf_filename'
  },
  errorMessage: {
    type: DataTypes.TEXT,
    allowNull: true,
    field: 'error_message'
  }
}, {
  tableName: 'billing_document',
  underscored: true,
  timestamps: true
});

export default BillingDocument;
