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 forecast_scenarios = sequelize.define(
    'forecast_scenarios',
    {
      id: {
        type: DataTypes.UUID,
        defaultValue: DataTypes.UUIDV4,
        primaryKey: true,
      },

scenario_name: {
        type: DataTypes.TEXT,
      
      

      },

scenario_type: {
        type: DataTypes.ENUM,
      
      

        values: [

"base",


"optimistic",


"conservative",


"custom"

        ],

      },

revenue_multiplier: {
        type: DataTypes.DECIMAL,
      
      

      },

expense_multiplier: {
        type: DataTypes.DECIMAL,
      
      

      },

cash_buffer_target: {
        type: DataTypes.DECIMAL,
      
      

      },

is_active: {
        type: DataTypes.BOOLEAN,
      
        allowNull: false,
        defaultValue: false,
      
      

      },

assumptions: {
        type: DataTypes.TEXT,
      
      

      },

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

  forecast_scenarios.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.forecast_scenarios.belongsTo(db.forecasts, {
      as: 'forecast',
      foreignKey: {
        name: 'forecastId',
      },
      constraints: false,
    });

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




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

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



  return forecast_scenarios;
};


