'use strict';
const {
  Model
} = require('sequelize');
module.exports = (sequelize, DataTypes) => {
  class Payment extends Model {
    /**
     * Helper method for defining associations.
     * This method is not a part of Sequelize lifecycle.
     * The `models/index` file will call this method automatically.
     */
    static associate(models) {
      // define association here
      Payment.belongsTo(models.Transaction, { foreignKey: 'transactionId', as: 'transaction' });
     Payment.belongsTo(models.User, { foreignKey: 'processedBy', as: 'user' });
    
      
      
    }
  }
  Payment.init({
    transactionId: DataTypes.INTEGER,
    paymentMethod: DataTypes.STRING,
    amount: DataTypes.DECIMAL,
    status: DataTypes.STRING,
    referenceNumber: DataTypes.STRING,
    cardLastFour: DataTypes.STRING,
    cardType: DataTypes.STRING,
    mobileMoneyProvider: DataTypes.STRING,
    mobileMoneyNumber: DataTypes.STRING,
    processedBy: DataTypes.INTEGER,
    processedAt: DataTypes.DATE
  }, {
    sequelize,
    modelName: 'Payment',
  });
  return Payment;
};