'use strict';
const { Model } = require('sequelize');
const { defaultKeys, modelDefaults, actionUsers } = require('../sequelize/defaults');
module.exports = (sequelize, DataTypes) => {
  class ItemCategory extends Model {
    static associate(models) {
      actionUsers(ItemCategory, models);
      ItemCategory.belongsTo(models.Branch, {
        targetKey: "branch_id",
        foreignKey: "branch_id",
        as: "branches",
      });
    }
  }

  ItemCategory.init({
    ...defaultKeys("item_category_id"),
    tbl_ref_id: {
      type: DataTypes.STRING,
      allowNull: true,
    },
    item_category_name: {
      type: DataTypes.STRING,
      allowNull: false,
    },
    item_category_descp: {
      type: DataTypes.STRING,
      allowNull: true,
    },
    active_status: {
      type: DataTypes.BOOLEAN,
      allowNull: false,
      defaultValue: 1,
    },
  }, modelDefaults(sequelize, 'item_categories'));
  return ItemCategory;
};