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

drug_name: {
        type: DataTypes.TEXT,
      
      

      },

supplier: {
        type: DataTypes.TEXT,
      
      

      },

wholesale_price: {
        type: DataTypes.DECIMAL,
      
      

      },

retail_price: {
        type: DataTypes.DECIMAL,
      
      

      },

quantity: {
        type: DataTypes.INTEGER,
      
      

      },

expiry_date: {
        type: DataTypes.DATE,
      
      

      },

batch_number: {
        type: DataTypes.TEXT,
      
      

      },

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

  pharmacy_inventory.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.pharmacy_inventory.belongsTo(db.users, {
      as: 'createdBy',
    });

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



  return pharmacy_inventory;
};


