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

snapshot_at: {
        type: DataTypes.DATE,
      
      

      },

rooms_available: {
        type: DataTypes.INTEGER,
      
      

      },

rooms_occupied: {
        type: DataTypes.INTEGER,
      
      

      },

rooms_dirty: {
        type: DataTypes.INTEGER,
      
      

      },

rooms_out_of_service: {
        type: DataTypes.INTEGER,
      
      

      },

occupancy_rate_percent: {
        type: DataTypes.DECIMAL,
      
      

      },

revenue_today: {
        type: DataTypes.DECIMAL,
      
      

      },

revenue_month_to_date: {
        type: DataTypes.DECIMAL,
      
      

      },

adr: {
        type: DataTypes.DECIMAL,
      
      

      },

revpar: {
        type: DataTypes.DECIMAL,
      
      

      },

arrivals_today: {
        type: DataTypes.INTEGER,
      
      

      },

departures_today: {
        type: DataTypes.INTEGER,
      
      

      },

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

  daily_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.daily_snapshots.belongsTo(db.hotels, {
      as: 'hotel',
      foreignKey: {
        name: 'hotelId',
      },
      constraints: false,
    });

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




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

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



  return daily_snapshots;
};


