const { DataTypes, Sequelize } = require("sequelize");
const sequelizeConnect = require("../connection/db");

const PurchaseOrderApprovals = sequelizeConnect.define(
  "purchase_order_approvals",
  {
    id: {
      type: DataTypes.BIGINT,
      primaryKey: true,
      allowNull: false,
      autoIncrement: true,
    },
    purchase_order_id: {
      type: DataTypes.BIGINT,
      allowNull: false,
    },
    approver_id: {
      type: DataTypes.BIGINT,
      allowNull: false,
    },
    level: {
      type: DataTypes.INTEGER,
      allowNull: false,
    },
    approval_status: {
      type: DataTypes.ENUM("Pending", "Approved", "Rejected"),
      allowNull: false,
      defaultValue: "Pending",
    },
    remarks: {
      type: DataTypes.TEXT,
      allowNull: true,
    },
    status: {
      type: DataTypes.BOOLEAN,
      allowNull: false,
      defaultValue: true,
    },
  },
  {
    tableName: "purchase_order_approvals",
    timestamps: true,
  }
);

module.exports = PurchaseOrderApprovals;
