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

module.exports = (sequelize) => {
    const GoodReceipt = sequelize.define(
        "goodreceipt",
        {
            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.DATEONLY, allowNull: false },
            item_code: { type: DataTypes.STRING, allowNull: false },
            item_name: { type: DataTypes.STRING, allowNull: false },
            sku_code: { type: DataTypes.STRING, allowNull: true },
            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 },
            item_uom: { type: DataTypes.STRING, allowNull: false },
            received_quantity: { type: DataTypes.INTEGER, allowNull: false },
            received_uom: { type: DataTypes.STRING, allowNull: false },
            received_by: { type: DataTypes.INTEGER, allowNull: false },
            submitted_by: { type: DataTypes.INTEGER, allowNull: false },
            received_by_signature: { type: DataTypes.TEXT, allowNull: true },
            submitted_by_signature: { type: DataTypes.TEXT, allowNull: true },
            received_company: { type: DataTypes.INTEGER, allowNull: true },
            submitted_company: { type: DataTypes.INTEGER, 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 },

            latitude: { type: DataTypes.STRING, allowNull: true },
            longitude: { type: DataTypes.STRING, allowNull: true },
            address: { type: DataTypes.TEXT, allowNull: true },
            filename: { type: DataTypes.STRING, allowNull: true },
            takepicture_date: { type: DataTypes.DATEONLY, allowNull: true },
        },
        {
            tableName: "goodreceipts",
            freezeTableName: true,
        }
    );

    return GoodReceipt;
};

