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

contract_number: {
        type: DataTypes.TEXT,
      
      

      },

hire_date: {
        type: DataTypes.DATE,
      
      

      },

contract_type: {
        type: DataTypes.ENUM,
      
      

        values: [

"PERMANENT",


"FIXED"

        ],

      },

position: {
        type: DataTypes.TEXT,
      
      

      },

work_schedule: {
        type: DataTypes.TEXT,
      
      

      },

probation_days: {
        type: DataTypes.INTEGER,
      
      

      },

salary: {
        type: DataTypes.DECIMAL,
      
      

      },

daily_allowance: {
        type: DataTypes.DECIMAL,
      
      

      },

bonuses: {
        type: DataTypes.DECIMAL,
      
      

      },

deductions: {
        type: DataTypes.DECIMAL,
      
      

      },

bank_account_iban: {
        type: DataTypes.TEXT,
      
      

      },

bank_name: {
        type: DataTypes.TEXT,
      
      

      },

insurance_number: {
        type: DataTypes.TEXT,
      
      

      },

tax_number: {
        type: DataTypes.TEXT,
      
      

      },

tax_category: {
        type: DataTypes.TEXT,
      
      

      },

vacation_days: {
        type: DataTypes.INTEGER,
      
      

      },

used_vacation_days: {
        type: DataTypes.INTEGER,
      
      

      },

employment_status: {
        type: DataTypes.ENUM,
      
      

        values: [

"ACTIVE",


"SICK",


"VACATION",


"TERMINATED"

        ],

      },

termination_date: {
        type: DataTypes.DATE,
      
      

      },

termination_reason: {
        type: DataTypes.TEXT,
      
      

      },

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

  employee_hr_records.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.employee_hr_records.belongsTo(db.employees, {
      as: 'employee',
      foreignKey: {
        name: 'employeeId',
      },
      constraints: false,
    });




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

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



  return employee_hr_records;
};


