export default (sequelize, DataTypes) => {

    return sequelize.define('Expense', {

        id: {
            type: DataTypes.INTEGER,
            primaryKey: true,
            autoIncrement: true
        },

        expense_name: {
            type: DataTypes.STRING,
            allowNull: false
        },
        category: {
            type: DataTypes.STRING,
            allowNull: false,

            validate: {
                isIn: [[
                    'infrastructure',
                    'marketing',
                    'travel',
                    'utilities',
                    'office',
                    'salary',
                    'other'
                ]]
            }
        },
        amount: {
            type: DataTypes.DECIMAL(10, 2),
            allowNull: false,
            defaultValue: 0
        },
        expense_date: {
            type: DataTypes.DATEONLY,
            allowNull: false,
            defaultValue: DataTypes.NOW
        },
        vendor: {
            type: DataTypes.STRING,
            allowNull: true
        },
        payment_method: {
            type: DataTypes.STRING,
            allowNull: true
        },
        receipt: {
            type: DataTypes.STRING,
            allowNull: true
        },
        status: {
            type: DataTypes.STRING,
            allowNull: false,
            defaultValue: 'pending',

            validate: {
                isIn: [[
                    'pending',
                    'approved',
                    'rejected'
                ]]
            }
        },
        created_at: {
            type: DataTypes.DATE,
            allowNull: false,
            defaultValue: DataTypes.NOW
        }

    }, {
        tableName: 'expenses',
        timestamps: false
    });

};