const { DataTypes } = require("sequelize");

module.exports = (sequelize) => {
    const ReceiptOfGood = sequelize.define(
        "receiptofgood",
        {
            id: {
                type: DataTypes.INTEGER,
                autoIncrement: true,
                primaryKey: true,
            },
            creation: { type: DataTypes.DATE, allowNull: false },
            modified: { type: DataTypes.DATE, allowNull: false },
            modified_by: { type: DataTypes.INTEGER, allowNull: false },
            owner: { type: DataTypes.INTEGER, allowNull: false },

            material_request_name: { type: DataTypes.STRING, allowNull: false },
            material_request_title: { type: DataTypes.TEXT, allowNull: false },
            purchase_order_name: { type: DataTypes.STRING, allowNull: false },
            purchase_order_supplier_name: { type: DataTypes.STRING, allowNull: false },
            received_date: { type: DataTypes.DATE, allowNull: false },
            item_code: { type: DataTypes.STRING, allowNull: false },
            item_name: { type: DataTypes.STRING, allowNull: false },
            is_received_in_good_condition: { type: DataTypes.BOOLEAN, allowNull: false },
            is_received_in_full: { type: DataTypes.BOOLEAN, allowNull: false },
            item_quantity: { type: DataTypes.INTEGER, allowNull: false },
            received_quantity: { type: DataTypes.INTEGER, allowNull: false },
            received_uom: { type: DataTypes.STRING, allowNull: false },
            received_by: { type: DataTypes.STRING, allowNull: false },
            submitted_by: { type: DataTypes.STRING, allowNull: false },
            received_by_signature: { type: DataTypes.STRING, allowNull: true },
            submitted_by_signature: { type: DataTypes.STRING, allowNull: true },

            comment: { type: DataTypes.TEXT, allowNull: true },
            item_rating: { type: DataTypes.INTEGER, allowNull: true },
            procurement_rating: { type: DataTypes.INTEGER, allowNull: true },
            submitted_by_rating: { type: DataTypes.INTEGER, allowNull: true },
            comment_suggestion: { type: DataTypes.TEXT, allowNull: true },
            notes: { type: DataTypes.TEXT, allowNull: true },

            filename: { type: DataTypes.STRING, allowNull: true },
        },
        {
            tableName: "receiptofgoods",
            freezeTableName: true,
        }
    );

    return ReceiptOfGood;
};
