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

fee_amount: {
        type: DataTypes.DECIMAL,
      
      

      },

amount_paid: {
        type: DataTypes.DECIMAL,
      
      

      },

payment_status: {
        type: DataTypes.ENUM,
      
      

        values: [

"unpaid",


"paid",


"exempt",


"partial"

        ],

      },

last_paid_at: {
        type: DataTypes.DATE,
      
      

      },

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

  league_payments.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.league_payments.belongsTo(db.leagues, {
      as: 'league',
      foreignKey: {
        name: 'leagueId',
      },
      constraints: false,
    });

    db.league_payments.belongsTo(db.players, {
      as: 'player',
      foreignKey: {
        name: 'playerId',
      },
      constraints: false,
    });

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




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

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



  return league_payments;
};


