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

default_currency_code: {
        type: DataTypes.TEXT,
      
      

      },

default_language: {
        type: DataTypes.TEXT,
      
      

      },

default_timezone: {
        type: DataTypes.TEXT,
      
      

      },

invoice_prefix: {
        type: DataTypes.TEXT,
      
      

      },

quote_prefix: {
        type: DataTypes.TEXT,
      
      

      },

receipt_prefix: {
        type: DataTypes.TEXT,
      
      

      },

default_vat_rate: {
        type: DataTypes.DECIMAL,
      
      

      },

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

      },

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

      },

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

      },

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

      },

invoice_footer_note: {
        type: DataTypes.TEXT,
      
      

      },

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

  organization_settings.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.organization_settings.belongsTo(db.organizations, {
      as: 'organization',
      foreignKey: {
        name: 'organizationId',
      },
      constraints: false,
    });




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

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



  return organization_settings;
};


