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

module.exports = (sequelize) => {
  const ProductReturnFU = sequelize.define(
    "productreturnfu",
    {
      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 },
      enabled: { type: DataTypes.BOOLEAN, allowNull: false },

      date: { type: DataTypes.DATE, allowNull: true },
      description: { type: DataTypes.TEXT, allowNull: true },

      //fk
      productreturn_id: {
        type: DataTypes.INTEGER,
        allowNull: false,
        references: {
          model: "productreturns",
          key: "id",
        },
      },
    },
    {
      tableName: "productreturnfus",
      freezeTableName: true,
    }
  );


  ProductReturnFU.associate = (models) => {

    ProductReturnFU.belongsTo(models.ProductReturn, {
      foreignKey: "productreturn_id",
      as: "productreturn",
    });
  };

  return ProductReturnFU;
};
