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

business_date: {
        type: DataTypes.DATE,
      
      

      },

gross_sales: {
        type: DataTypes.DECIMAL,
      
      

      },

net_sales: {
        type: DataTypes.DECIMAL,
      
      

      },

transactions_count: {
        type: DataTypes.INTEGER,
      
      

      },

cash_total: {
        type: DataTypes.DECIMAL,
      
      

      },

pix_total: {
        type: DataTypes.DECIMAL,
      
      

      },

card_total: {
        type: DataTypes.DECIMAL,
      
      

      },

wages_paid: {
        type: DataTypes.DECIMAL,
      
      

      },

inventory_purchases: {
        type: DataTypes.DECIMAL,
      
      

      },

notes: {
        type: DataTypes.TEXT,
      
      

      },

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

  daily_reports.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.daily_reports.belongsTo(db.market_stores, {
      as: 'store',
      foreignKey: {
        name: 'storeId',
      },
      constraints: false,
    });




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

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



  return daily_reports;
};


