import { DataTypes } from 'sequelize';

export default function defineJobCard(sequelize) {
  return sequelize.define(
    'JobCard',
    {
      id: { type: DataTypes.BIGINT.UNSIGNED, primaryKey: true, autoIncrement: true },
      booking_id: { type: DataTypes.BIGINT.UNSIGNED, allowNull: false, unique: true },
      status: {
        type: DataTypes.ENUM('open', 'in_progress', 'completed', 'closed'),
        allowNull: false,
        defaultValue: 'open',
      },
      estimated_cost: { type: DataTypes.DECIMAL(10, 2), allowNull: true },
      final_cost: { type: DataTypes.DECIMAL(10, 2), allowNull: true },
      created_at: {
        type: DataTypes.DATE(3),
        allowNull: false,
        defaultValue: DataTypes.NOW,
      },
    },
    { tableName: 'job_cards' }
  );
}
