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

transaction_date: {
        type: DataTypes.DATE,

      },

admin_fee_amount: {
        type: DataTypes.DECIMAL,

      },

interest_amount: {
        type: DataTypes.DECIMAL,

      },

commission_amount: {
        type: DataTypes.DECIMAL,

      },

expense_amount: {
        type: DataTypes.DECIMAL,

      },

setlement_datetime: {
        type: DataTypes.DATE,

      },

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

  payment_revenues.associate = (db) => {

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

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

  return payment_revenues;
};

