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

year: {
        type: DataTypes.INTEGER,
      
      

      },

month: {
        type: DataTypes.INTEGER,
      
      

      },

gross_revenue: {
        type: DataTypes.DECIMAL,
      
      

      },

bookkeeping_deductions: {
        type: DataTypes.DECIMAL,
      
      

      },

taxable_base: {
        type: DataTypes.DECIMAL,
      
      

      },

tax_due: {
        type: DataTypes.DECIMAL,
      
      

      },

darf_paid: {
        type: DataTypes.BOOLEAN,
      
        allowNull: false,
        defaultValue: false,
      
      

      },

darf_document_url: {
        type: DataTypes.TEXT,
      
      

      },

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

  income_carne_leao_monthly.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.income_carne_leao_monthly.belongsTo(db.declarations, {
      as: 'declaration',
      foreignKey: {
        name: 'declarationId',
      },
      constraints: false,
    });

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




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

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



  return income_carne_leao_monthly;
};


