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

as_of_at: {
        type: DataTypes.DATE,
      
      

      },

currency: {
        type: DataTypes.TEXT,
      
      

      },

cash_balance: {
        type: DataTypes.DECIMAL,
      
      

      },

net_burn_monthly: {
        type: DataTypes.DECIMAL,
      
      

      },

gross_margin_percent: {
        type: DataTypes.DECIMAL,
      
      

      },

mrr: {
        type: DataTypes.DECIMAL,
      
      

      },

arr: {
        type: DataTypes.DECIMAL,
      
      

      },

accounts_receivable: {
        type: DataTypes.DECIMAL,
      
      

      },

accounts_payable: {
        type: DataTypes.DECIMAL,
      
      

      },

runway_months: {
        type: DataTypes.DECIMAL,
      
      

      },

quality_grade: {
        type: DataTypes.ENUM,
      
      

        values: [

"excellent",


"good",


"fair",


"poor"

        ],

      },

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

  metrics_snapshots.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.metrics_snapshots.belongsTo(db.workspaces, {
      as: 'workspace',
      foreignKey: {
        name: 'workspaceId',
      },
      constraints: false,
    });

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




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

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



  return metrics_snapshots;
};


