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

module.exports = (sequelize) => {
    const GoodReceipt = sequelize.define(
        "goodsreceipt",
        {
            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 },

            shipper: { type: DataTypes.INTEGER, allowNull: false },
            shipper_company: { type: DataTypes.INTEGER, allowNull: false },
            shipper_date: { type: DataTypes.DATEONLY, 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 },
            item_code: { type: DataTypes.STRING, allowNull: false },
            item_name: { type: DataTypes.STRING, allowNull: false },
            sku_code: { type: DataTypes.STRING, allowNull: true },
            item_quantity: { type: DataTypes.INTEGER, allowNull: false },
            item_uom: { type: DataTypes.STRING, allowNull: false },
            shipper_signature: { type: DataTypes.STRING, allowNull: true },
            shipper_latitude: { type: DataTypes.STRING, allowNull: true },
            shipper_longitude: { type: DataTypes.STRING, allowNull: true },
            shipper_address: { type: DataTypes.TEXT, allowNull: true },
            shipper_filename: { type: DataTypes.STRING, allowNull: true },
            shipper_takepicture_date: { type: DataTypes.DATEONLY, allowNull: true },
            shipper_status: { type: DataTypes.STRING, allowNull: true },

            cosignee: { type: DataTypes.INTEGER, allowNull: false },
            cosignee_company: { type: DataTypes.INTEGER, allowNull: false },
            received_date: { type: DataTypes.DATEONLY, allowNull: true },
            is_received_in_good_condition: { type: DataTypes.BOOLEAN, allowNull: true },
            is_received_in_full: { type: DataTypes.BOOLEAN, allowNull: true },
            received_quantity: { type: DataTypes.INTEGER, allowNull: true },
            received_uom: { type: DataTypes.STRING, allowNull: true },
            item_rating: { type: DataTypes.INTEGER, allowNull: true },
            shipper_rating: { type: DataTypes.INTEGER, allowNull: true },
            comment_suggestion: { type: DataTypes.TEXT, allowNull: true },
            comment: { type: DataTypes.TEXT, allowNull: true },
            notes: { type: DataTypes.TEXT, allowNull: true },
            cosignee_signature: { type: DataTypes.STRING, allowNull: true },
            cosignee_latitude: { type: DataTypes.STRING, allowNull: true },
            cosignee_longitude: { type: DataTypes.STRING, allowNull: true },
            cosignee_address: { type: DataTypes.TEXT, allowNull: true },
            cosignee_filename: { type: DataTypes.STRING, allowNull: true },
            cosignee_takepicture_date: { type: DataTypes.DATEONLY, allowNull: true },
            cosignee_status: { type: DataTypes.STRING, allowNull: true },

            item_status: { type: DataTypes.STRING, allowNull: true },
            status: { type: DataTypes.STRING, allowNull: true },
        },
        {
            tableName: "goodsreceipts",
            freezeTableName: true,
        }
    );

    return GoodReceipt;
};

