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

transaction_datetime: {
        type: DataTypes.DATE,

      },

transaction_amount: {
        type: DataTypes.DECIMAL,

      },

deduct_amount: {
        type: DataTypes.DECIMAL,

      },

interest_amount: {
        type: DataTypes.DECIMAL,

      },

commission_amount: {
        type: DataTypes.DECIMAL,

      },

revenue_amount: {
        type: DataTypes.DECIMAL,

      },

setlement_datetime: {
        type: DataTypes.DATE,

      },

type: {
        type: DataTypes.ENUM,

        values: [

"interest",

"deduction",

"reverse"

        ],

      },

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

  payment_transactions.associate = (db) => {

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

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

  return payment_transactions;
};

