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

name: {
        type: DataTypes.TEXT,
      
      

      },

plan_type: {
        type: DataTypes.ENUM,
      
      

        values: [

"standard_day_camp",


"pickup_dropoff_only",


"late_shift_only",


"combined_package"

        ],

      },

monthly_tuition: {
        type: DataTypes.DECIMAL,
      
      

      },

included_summary: {
        type: DataTypes.TEXT,
      
      

      },

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

      },

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

      },

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

      },

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

      },

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

      },

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

  pricing_plans.associate = (db) => {


/// loop through entities and it's fields, and if ref === current e[name] and create relation has many on parent entity













    db.pricing_plans.hasMany(db.enrollments, {
      as: 'enrollments_pricing_plan',
      foreignKey: {
          name: 'pricing_planId',
      },
      constraints: false,
    });
















//end loop



    db.pricing_plans.belongsTo(db.camp_sessions, {
      as: 'camp_session',
      foreignKey: {
        name: 'camp_sessionId',
      },
      constraints: false,
    });




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

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



  return pricing_plans;
};


