const config = require('../../config');
const providers = config.providers;
const crypto = require('crypto');
const bcrypt = require('bcrypt');
const moment = require('moment');

module.exports = function(sequelize, DataTypes) {
  const bid_evaluations = sequelize.define(
    'bid_evaluations',
    {
      id: {
        type: DataTypes.UUID,
        defaultValue: DataTypes.UUIDV4,
        primaryKey: true,
      },

technical_score: {
        type: DataTypes.DECIMAL,
      
      

      },

financial_score: {
        type: DataTypes.DECIMAL,
      
      

      },

total_score: {
        type: DataTypes.DECIMAL,
      
      

      },

recommendation: {
        type: DataTypes.ENUM,
      
      

        values: [

"award",


"reserve",


"reject"

        ],

      },

justification: {
        type: DataTypes.TEXT,
      
      

      },

evaluated_at: {
        type: DataTypes.DATE,
      
      

      },

      importHash: {
        type: DataTypes.STRING(255),
        allowNull: true,
        unique: true,
      },
    },
    {
      timestamps: true,
      paranoid: true,
      freezeTableName: true,
    },
  );

  bid_evaluations.associate = (db) => {


/// loop through entities and it's fields, and if ref === current e[name] and create relation has many on parent entity




















































//end loop



    db.bid_evaluations.belongsTo(db.bids, {
      as: 'bid',
      foreignKey: {
        name: 'bidId',
      },
      constraints: false,
    });

    db.bid_evaluations.belongsTo(db.users, {
      as: 'lead_evaluator_user',
      foreignKey: {
        name: 'lead_evaluator_userId',
      },
      constraints: false,
    });

    db.bid_evaluations.belongsTo(db.organizations, {
      as: 'organizations',
      foreignKey: {
        name: 'organizationsId',
      },
      constraints: false,
    });




    db.bid_evaluations.belongsTo(db.users, {
      as: 'createdBy',
    });

    db.bid_evaluations.belongsTo(db.users, {
      as: 'updatedBy',
    });
  };



  return bid_evaluations;
};


