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

effective_start: {
        type: DataTypes.DATE,
      
      

      },

effective_end: {
        type: DataTypes.DATE,
      
      

      },

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

      },

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

  account_price_lists.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.account_price_lists.belongsTo(db.accounts, {
      as: 'account',
      foreignKey: {
        name: 'accountId',
      },
      constraints: false,
    });

    db.account_price_lists.belongsTo(db.price_lists, {
      as: 'price_list',
      foreignKey: {
        name: 'price_listId',
      },
      constraints: false,
    });




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

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



  return account_price_lists;
};


