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

statement_type: {
        type: DataTypes.ENUM,
      
      

        values: [

"income_statement",


"balance_sheet",


"cash_flow"

        ],

      },

period_type: {
        type: DataTypes.ENUM,
      
      

        values: [

"annual",


"quarterly"

        ],

      },

period_end_at: {
        type: DataTypes.DATE,
      
      

      },

total_revenue: {
        type: DataTypes.DECIMAL,
      
      

      },

net_income: {
        type: DataTypes.DECIMAL,
      
      

      },

total_assets: {
        type: DataTypes.DECIMAL,
      
      

      },

total_liabilities: {
        type: DataTypes.DECIMAL,
      
      

      },

free_cash_flow: {
        type: DataTypes.DECIMAL,
      
      

      },

notes: {
        type: DataTypes.TEXT,
      
      

      },

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

  ir_financial_statement_summaries.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.ir_financial_statement_summaries.belongsTo(db.ir_companies, {
      as: 'ir_company',
      foreignKey: {
        name: 'ir_companyId',
      },
      constraints: false,
    });




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

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



  return ir_financial_statement_summaries;
};


