'use strict';

module.exports = {
  async up(queryInterface, Sequelize) {
    const permissions = [
      // ========== DASHBOARD ==========
      { permission_code: 'DASHBOARD.VIEW', permission_name: 'Dashboard - View', module: 'DASHBOARD', resource: 'dashboard', action: 'READ', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      { permission_code: 'QUICK_ACCESS.VIEW', permission_name: 'Quick Access - View', module: 'QUICK_ACCESS', resource: 'quick_access', action: 'READ', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },

      // ========== MASTER DATA ==========
      // Organization (parent menu - required to see Organization section in sidebar)
      { permission_code: 'MASTER.ORGANIZATION.VIEW', permission_name: 'Organization - View', module: 'MASTER', resource: 'organization', action: 'READ', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      { permission_code: 'MASTER.COMPANY.ALL', permission_name: 'Company - All', module: 'MASTER', resource: 'company', action: 'ALL', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      { permission_code: 'MASTER.COMPANY.READ', permission_name: 'Company - Read', module: 'MASTER', resource: 'company', action: 'READ', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      { permission_code: 'MASTER.PLANT.ALL', permission_name: 'Plant - All', module: 'MASTER', resource: 'plant', action: 'ALL', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      { permission_code: 'MASTER.PLANT.READ', permission_name: 'Plant - Read', module: 'MASTER', resource: 'plant', action: 'READ', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      { permission_code: 'MASTER.DEPARTMENT.ALL', permission_name: 'Department - All', module: 'MASTER', resource: 'department', action: 'ALL', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      { permission_code: 'MASTER.DEPARTMENT.READ', permission_name: 'Department - Read', module: 'MASTER', resource: 'department', action: 'READ', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      { permission_code: 'MASTER.COST_CENTER.ALL', permission_name: 'Cost Center - All', module: 'MASTER', resource: 'cost_center', action: 'ALL', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      { permission_code: 'MASTER.COST_CENTER.READ', permission_name: 'Cost Center - Read', module: 'MASTER', resource: 'cost_center', action: 'READ', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      { permission_code: 'MASTER.STORAGE_LOCATION.ALL', permission_name: 'Storage Location - All', module: 'MASTER', resource: 'storage_location', action: 'ALL', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      { permission_code: 'MASTER.STORAGE_LOCATION.READ', permission_name: 'Storage Location - Read', module: 'MASTER', resource: 'storage_location', action: 'READ', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      { permission_code: 'MASTER.GSTIN.ALL', permission_name: 'GSTIN - All', module: 'MASTER', resource: 'gstin', action: 'ALL', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      { permission_code: 'MASTER.GSTIN.READ', permission_name: 'GSTIN - Read', module: 'MASTER', resource: 'gstin', action: 'READ', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      { permission_code: 'MASTER.PRINT_HEADER.ALL', permission_name: 'Print Header - All', module: 'MASTER', resource: 'print_header', action: 'ALL', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      { permission_code: 'MASTER.PRINT_HEADER.READ', permission_name: 'Print Header - Read', module: 'MASTER', resource: 'print_header', action: 'READ', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      
      // Material Master
      { permission_code: 'MASTER.MATERIAL.ALL', permission_name: 'Material - All', module: 'MASTER', resource: 'material', action: 'ALL', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      { permission_code: 'MASTER.MATERIAL.READ', permission_name: 'Material - Read', module: 'MASTER', resource: 'material', action: 'READ', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      { permission_code: 'MASTER.MATERIAL.CREATE', permission_name: 'Material - Create', module: 'MASTER', resource: 'material', action: 'CREATE', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      { permission_code: 'MASTER.MATERIAL.UPDATE', permission_name: 'Material - Update', module: 'MASTER', resource: 'material', action: 'UPDATE', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      { permission_code: 'MASTER.MATERIAL_TYPE.ALL', permission_name: 'Material Type - All', module: 'MASTER', resource: 'material_type', action: 'ALL', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      { permission_code: 'MASTER.MATERIAL_GROUP.ALL', permission_name: 'Material Group - All', module: 'MASTER', resource: 'material_group', action: 'ALL', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      { permission_code: 'MASTER.MATERIAL_THICKNESS.ALL', permission_name: 'Material Thickness - All', module: 'MASTER', resource: 'material_thickness', action: 'ALL', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      { permission_code: 'MASTER.MATERIAL_THICKNESS.READ', permission_name: 'Material Thickness - Read', module: 'MASTER', resource: 'material_thickness', action: 'READ', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      { permission_code: 'MASTER.MATERIAL_GRADE.ALL', permission_name: 'Material Grade - All', module: 'MASTER', resource: 'material_grade', action: 'ALL', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      { permission_code: 'MASTER.MATERIAL_GRADE.READ', permission_name: 'Material Grade - Read', module: 'MASTER', resource: 'material_grade', action: 'READ', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      { permission_code: 'MASTER.MATERIAL_SHEET_TYPE.ALL', permission_name: 'Sheet Type - All', module: 'MASTER', resource: 'material_sheet_type', action: 'ALL', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      { permission_code: 'MASTER.MATERIAL_SHEET_TYPE.READ', permission_name: 'Sheet Type - Read', module: 'MASTER', resource: 'material_sheet_type', action: 'READ', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      { permission_code: 'MASTER.MATERIAL_SUBSTITUTION.ALL', permission_name: 'Material Substitution - All', module: 'MASTER', resource: 'material_substitution', action: 'ALL', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      { permission_code: 'MASTER.MATERIAL_SUBSTITUTION.READ', permission_name: 'Material Substitution - Read', module: 'MASTER', resource: 'material_substitution', action: 'READ', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      { permission_code: 'MASTER.UOM.ALL', permission_name: 'UOM - All', module: 'MASTER', resource: 'uom', action: 'ALL', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      { permission_code: 'MASTER.UOM.READ', permission_name: 'UOM - Read', module: 'MASTER', resource: 'uom', action: 'READ', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      { permission_code: 'MASTER.UOM_CONVERSION.ALL', permission_name: 'UOM Conversion - All', module: 'MASTER', resource: 'uom_conversion', action: 'ALL', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      { permission_code: 'MASTER.UOM_CONVERSION.READ', permission_name: 'UOM Conversion - Read', module: 'MASTER', resource: 'uom_conversion', action: 'READ', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      
      // Business Partner
      { permission_code: 'MASTER.BUSINESS_PARTNER.ALL', permission_name: 'Business Partner - All', module: 'MASTER', resource: 'business_partner', action: 'ALL', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      { permission_code: 'MASTER.BUSINESS_PARTNER.READ', permission_name: 'Business Partner - Read', module: 'MASTER', resource: 'business_partner', action: 'READ', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      { permission_code: 'MASTER.BP_ADDRESS.ALL', permission_name: 'BP Address - All', module: 'MASTER', resource: 'bp_address', action: 'ALL', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      { permission_code: 'MASTER.BP_ADDRESS.READ', permission_name: 'BP Address - Read', module: 'MASTER', resource: 'bp_address', action: 'READ', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      { permission_code: 'MASTER.BP_BANK.ALL', permission_name: 'BP Bank - All', module: 'MASTER', resource: 'bp_bank', action: 'ALL', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      { permission_code: 'MASTER.BP_BANK.READ', permission_name: 'BP Bank - Read', module: 'MASTER', resource: 'bp_bank', action: 'READ', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      { permission_code: 'MASTER.BP_GSTIN.ALL', permission_name: 'BP GSTIN - All', module: 'MASTER', resource: 'bp_gstin', action: 'ALL', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      { permission_code: 'MASTER.BP_GSTIN.READ', permission_name: 'BP GSTIN - Read', module: 'MASTER', resource: 'bp_gstin', action: 'READ', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      { permission_code: 'MASTER.VENDOR_CATEGORY.ALL', permission_name: 'Vendor Category - All', module: 'MASTER', resource: 'vendor_category', action: 'ALL', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      { permission_code: 'MASTER.VENDOR_CATEGORY.READ', permission_name: 'Vendor Category - Read', module: 'MASTER', resource: 'vendor_category', action: 'READ', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      
      // Production Master
      { permission_code: 'MASTER.BOM.ALL', permission_name: 'BOM - All', module: 'MASTER', resource: 'bom', action: 'ALL', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      { permission_code: 'MASTER.BOM.READ', permission_name: 'BOM - Read', module: 'MASTER', resource: 'bom', action: 'READ', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      { permission_code: 'MASTER.ROUTING.ALL', permission_name: 'Routing - All', module: 'MASTER', resource: 'routing', action: 'ALL', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      { permission_code: 'MASTER.ROUTING.READ', permission_name: 'Routing - Read', module: 'MASTER', resource: 'routing', action: 'READ', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      { permission_code: 'MASTER.WORK_CENTER.ALL', permission_name: 'Work Center - All', module: 'MASTER', resource: 'work_center', action: 'ALL', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      { permission_code: 'MASTER.MACHINE.ALL', permission_name: 'Machine - All', module: 'MASTER', resource: 'machine', action: 'ALL', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      { permission_code: 'MASTER.MACHINE.READ', permission_name: 'Machine - Read', module: 'MASTER', resource: 'machine', action: 'READ', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      
      // Other Masters
      { permission_code: 'MASTER.DOCUMENT.ALL', permission_name: 'Document - All', module: 'MASTER', resource: 'document', action: 'ALL', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      { permission_code: 'MASTER.DOCUMENT.READ', permission_name: 'Document - Read', module: 'MASTER', resource: 'document', action: 'READ', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      { permission_code: 'MASTER.NUMBER_FORMAT.ALL', permission_name: 'Number Format - All', module: 'MASTER', resource: 'number_format', action: 'ALL', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      { permission_code: 'MASTER.TAX_MASTER.ALL', permission_name: 'Tax Master - All', module: 'MASTER', resource: 'tax_master', action: 'ALL', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      { permission_code: 'MASTER.GL_ACCOUNT.ALL', permission_name: 'GL Account - All', module: 'MASTER', resource: 'gl_account', action: 'ALL', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      { permission_code: 'MASTER.GL_ACCOUNT.READ', permission_name: 'GL Account - Read', module: 'MASTER', resource: 'gl_account', action: 'READ', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      { permission_code: 'MASTER.FINANCE.VIEW', permission_name: 'Finance Masters - View', module: 'MASTER', resource: 'finance', action: 'READ', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      { permission_code: 'MASTER.FISCAL_YEAR.ALL', permission_name: 'Fiscal Year - All', module: 'MASTER', resource: 'fiscal_year', action: 'ALL', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      { permission_code: 'MASTER.FISCAL_YEAR.READ', permission_name: 'Fiscal Year - Read', module: 'MASTER', resource: 'fiscal_year', action: 'READ', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      { permission_code: 'MASTER.FISCAL_PERIOD.ALL', permission_name: 'Fiscal Period - All', module: 'MASTER', resource: 'fiscal_period', action: 'ALL', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      { permission_code: 'MASTER.FISCAL_PERIOD.READ', permission_name: 'Fiscal Period - Read', module: 'MASTER', resource: 'fiscal_period', action: 'READ', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      { permission_code: 'MASTER.TDS_MASTER.ALL', permission_name: 'TDS Master - All', module: 'MASTER', resource: 'tds_master', action: 'ALL', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      { permission_code: 'MASTER.TDS_MASTER.READ', permission_name: 'TDS Master - Read', module: 'MASTER', resource: 'tds_master', action: 'READ', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      { permission_code: 'MASTER.CURRENCY.ALL', permission_name: 'Currency - All', module: 'MASTER', resource: 'currency', action: 'ALL', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      { permission_code: 'MASTER.CURRENCY.READ', permission_name: 'Currency - Read', module: 'MASTER', resource: 'currency', action: 'READ', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      { permission_code: 'MASTER.CURRENCY_RATE.ALL', permission_name: 'Currency Rate - All', module: 'MASTER', resource: 'currency_rate', action: 'ALL', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      { permission_code: 'MASTER.CURRENCY_RATE.READ', permission_name: 'Currency Rate - Read', module: 'MASTER', resource: 'currency_rate', action: 'READ', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      { permission_code: 'MASTER.EMPLOYEE.ALL', permission_name: 'Employee Master - All', module: 'MASTER', resource: 'employee', action: 'ALL', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      { permission_code: 'MASTER.EMPLOYEE.READ', permission_name: 'Employee Master - Read', module: 'MASTER', resource: 'employee', action: 'READ', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      { permission_code: 'MASTER.FABRICATOR.ALL', permission_name: 'Fabricator - All', module: 'MASTER', resource: 'fabricator', action: 'ALL', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      { permission_code: 'MASTER.FABRICATOR.READ', permission_name: 'Fabricator - Read', module: 'MASTER', resource: 'fabricator', action: 'READ', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      { permission_code: 'MASTER.DESIGNATION.ALL', permission_name: 'Designation - All', module: 'MASTER', resource: 'designation', action: 'ALL', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      { permission_code: 'MASTER.DESIGNATION.READ', permission_name: 'Designation - Read', module: 'MASTER', resource: 'designation', action: 'READ', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      { permission_code: 'MASTER.BASE.VIEW', permission_name: 'Base Masters - View', module: 'MASTER', resource: 'base', action: 'READ', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      { permission_code: 'MASTER.COUNTRY.ALL', permission_name: 'Country - All', module: 'MASTER', resource: 'country', action: 'ALL', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      { permission_code: 'MASTER.COUNTRY.READ', permission_name: 'Country - Read', module: 'MASTER', resource: 'country', action: 'READ', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      { permission_code: 'MASTER.STATE.ALL', permission_name: 'State - All', module: 'MASTER', resource: 'state', action: 'ALL', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      { permission_code: 'MASTER.STATE.READ', permission_name: 'State - Read', module: 'MASTER', resource: 'state', action: 'READ', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      { permission_code: 'MASTER.CITY.ALL', permission_name: 'City - All', module: 'MASTER', resource: 'city', action: 'ALL', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      { permission_code: 'MASTER.CITY.READ', permission_name: 'City - Read', module: 'MASTER', resource: 'city', action: 'READ', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      { permission_code: 'MASTER.BANK.ALL', permission_name: 'Bank - All', module: 'MASTER', resource: 'bank', action: 'ALL', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      { permission_code: 'MASTER.BANK.READ', permission_name: 'Bank - Read', module: 'MASTER', resource: 'bank', action: 'READ', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },

      // ========== PURCHASE ==========
      { permission_code: 'PURCHASE.PURCHASE_REQUISITION.ALL', permission_name: 'Purchase Requisition - All', module: 'PURCHASE', resource: 'purchase_requisition', action: 'ALL', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      { permission_code: 'PURCHASE.PURCHASE_REQUISITION.CREATE', permission_name: 'Purchase Requisition - Create', module: 'PURCHASE', resource: 'purchase_requisition', action: 'CREATE', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      { permission_code: 'PURCHASE.PURCHASE_REQUISITION.READ', permission_name: 'Purchase Requisition - Read', module: 'PURCHASE', resource: 'purchase_requisition', action: 'READ', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      { permission_code: 'PURCHASE.PURCHASE_REQUISITION.APPROVE', permission_name: 'Purchase Requisition - Approve', module: 'PURCHASE', resource: 'purchase_requisition', action: 'APPROVE', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      
      { permission_code: 'PURCHASE.REQUEST_FOR_QUOTATION.ALL', permission_name: 'Request for Quotation - All', module: 'PURCHASE', resource: 'request_for_quotation', action: 'ALL', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      { permission_code: 'PURCHASE.REQUEST_FOR_QUOTATION.CREATE', permission_name: 'Request for Quotation - Create', module: 'PURCHASE', resource: 'request_for_quotation', action: 'CREATE', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      { permission_code: 'PURCHASE.REQUEST_FOR_QUOTATION.READ', permission_name: 'Request for Quotation - Read', module: 'PURCHASE', resource: 'request_for_quotation', action: 'READ', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      
      { permission_code: 'PURCHASE.PURCHASE_ORDER.ALL', permission_name: 'Purchase Order - All', module: 'PURCHASE', resource: 'purchase_order', action: 'ALL', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      { permission_code: 'PURCHASE.PURCHASE_ORDER.CREATE', permission_name: 'Purchase Order - Create', module: 'PURCHASE', resource: 'purchase_order', action: 'CREATE', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      { permission_code: 'PURCHASE.PURCHASE_ORDER.READ', permission_name: 'Purchase Order - Read', module: 'PURCHASE', resource: 'purchase_order', action: 'READ', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      { permission_code: 'PURCHASE.PURCHASE_ORDER.UPDATE', permission_name: 'Purchase Order - Update', module: 'PURCHASE', resource: 'purchase_order', action: 'UPDATE', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      { permission_code: 'PURCHASE.PURCHASE_ORDER.APPROVE', permission_name: 'Purchase Order - Approve', module: 'PURCHASE', resource: 'purchase_order', action: 'APPROVE', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      
      { permission_code: 'PURCHASE.GATE_ENTRY.ALL', permission_name: 'Gate Entry - All', module: 'PURCHASE', resource: 'gate_entry', action: 'ALL', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      { permission_code: 'PURCHASE.GATE_ENTRY.CREATE', permission_name: 'Gate Entry - Create', module: 'PURCHASE', resource: 'gate_entry', action: 'CREATE', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      { permission_code: 'PURCHASE.GATE_ENTRY.READ', permission_name: 'Gate Entry - Read', module: 'PURCHASE', resource: 'gate_entry', action: 'READ', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      { permission_code: 'PURCHASE.GATE_ENTRY.QC_APPROVE', permission_name: 'Gate Entry - QC Approve', module: 'PURCHASE', resource: 'gate_entry', action: 'APPROVE', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      { permission_code: 'PURCHASE.GATE_ENTRY.QC.ALL', permission_name: 'Gate Entry QC Pending - All', module: 'PURCHASE', resource: 'gate_entry_qc', action: 'ALL', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      { permission_code: 'PURCHASE.GATE_ENTRY.QC.READ', permission_name: 'Gate Entry QC Pending - Read', module: 'PURCHASE', resource: 'gate_entry_qc', action: 'READ', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      
      { permission_code: 'PURCHASE.GRN.ALL', permission_name: 'GRN - All', module: 'PURCHASE', resource: 'grn', action: 'ALL', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      { permission_code: 'PURCHASE.GRN.CREATE', permission_name: 'GRN - Create', module: 'PURCHASE', resource: 'grn', action: 'CREATE', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      { permission_code: 'PURCHASE.GRN.READ', permission_name: 'GRN - Read', module: 'PURCHASE', resource: 'grn', action: 'READ', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      
      { permission_code: 'PURCHASE.VENDOR_INVOICE.ALL', permission_name: 'Vendor Invoice - All', module: 'PURCHASE', resource: 'vendor_invoice', action: 'ALL', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      { permission_code: 'PURCHASE.VENDOR_INVOICE.CREATE', permission_name: 'Vendor Invoice - Create', module: 'PURCHASE', resource: 'vendor_invoice', action: 'CREATE', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      { permission_code: 'PURCHASE.VENDOR_INVOICE.READ', permission_name: 'Vendor Invoice - Read', module: 'PURCHASE', resource: 'vendor_invoice', action: 'READ', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      { permission_code: 'PURCHASE.VQR.ALL', permission_name: 'Vendor Quotation Request - All', module: 'PURCHASE', resource: 'vendor_quotation_request', action: 'ALL', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      { permission_code: 'PURCHASE.VQR.CREATE', permission_name: 'Vendor Quotation Request - Create', module: 'PURCHASE', resource: 'vendor_quotation_request', action: 'CREATE', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      { permission_code: 'PURCHASE.VQR.READ', permission_name: 'Vendor Quotation Request - Read', module: 'PURCHASE', resource: 'vendor_quotation_request', action: 'READ', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },

      // ========== STORES (Material Request, Issue, Return, PR from Stores) ==========
      { permission_code: 'STORES.MATERIAL_REQUEST.ALL', permission_name: 'Stores Material Request - All', module: 'STORES', resource: 'material_request', action: 'ALL', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      { permission_code: 'STORES.MATERIAL_REQUEST.CREATE', permission_name: 'Stores Material Request - Create', module: 'STORES', resource: 'material_request', action: 'CREATE', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      { permission_code: 'STORES.MATERIAL_REQUEST.READ', permission_name: 'Stores Material Request - Read', module: 'STORES', resource: 'material_request', action: 'READ', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      { permission_code: 'STORES.MATERIAL_ISSUE.ALL', permission_name: 'Stores Material Issue - All', module: 'STORES', resource: 'material_issue', action: 'ALL', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      { permission_code: 'STORES.MATERIAL_ISSUE.CREATE', permission_name: 'Stores Material Issue - Create', module: 'STORES', resource: 'material_issue', action: 'CREATE', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      { permission_code: 'STORES.MATERIAL_ISSUE.READ', permission_name: 'Stores Material Issue - Read', module: 'STORES', resource: 'material_issue', action: 'READ', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      { permission_code: 'STORES.MATERIAL_RETURN.ALL', permission_name: 'Stores Material Return - All', module: 'STORES', resource: 'material_return', action: 'ALL', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      { permission_code: 'STORES.MATERIAL_RETURN.CREATE', permission_name: 'Stores Material Return - Create', module: 'STORES', resource: 'material_return', action: 'CREATE', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      { permission_code: 'STORES.MATERIAL_RETURN.READ', permission_name: 'Stores Material Return - Read', module: 'STORES', resource: 'material_return', action: 'READ', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      { permission_code: 'STORES.PURCHASE_REQUISITION.ALL', permission_name: 'Stores Purchase Requisition - All', module: 'STORES', resource: 'purchase_requisition', action: 'ALL', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      { permission_code: 'STORES.PURCHASE_REQUISITION.CREATE', permission_name: 'Stores Purchase Requisition - Create', module: 'STORES', resource: 'purchase_requisition', action: 'CREATE', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      { permission_code: 'STORES.PURCHASE_REQUISITION.READ', permission_name: 'Stores Purchase Requisition - Read', module: 'STORES', resource: 'purchase_requisition', action: 'READ', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },

      // ========== INVENTORY ==========
      { permission_code: 'INVENTORY.GOODS_RECEIPT.ALL', permission_name: 'Goods Receipt - All', module: 'INVENTORY', resource: 'goods_receipt', action: 'ALL', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      { permission_code: 'INVENTORY.GOODS_RECEIPT.CREATE', permission_name: 'Goods Receipt - Create', module: 'INVENTORY', resource: 'goods_receipt', action: 'CREATE', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      { permission_code: 'INVENTORY.GOODS_RECEIPT.READ', permission_name: 'Goods Receipt - Read', module: 'INVENTORY', resource: 'goods_receipt', action: 'READ', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      
      { permission_code: 'INVENTORY.GOODS_ISSUE.ALL', permission_name: 'Goods Issue - All', module: 'INVENTORY', resource: 'goods_issue', action: 'ALL', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      { permission_code: 'INVENTORY.GOODS_ISSUE.CREATE', permission_name: 'Goods Issue - Create', module: 'INVENTORY', resource: 'goods_issue', action: 'CREATE', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      { permission_code: 'INVENTORY.GOODS_ISSUE.READ', permission_name: 'Goods Issue - Read', module: 'INVENTORY', resource: 'goods_issue', action: 'READ', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      
      { permission_code: 'INVENTORY.STOCK_TRANSFER.ALL', permission_name: 'Stock Transfer - All', module: 'INVENTORY', resource: 'stock_transfer', action: 'ALL', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      { permission_code: 'INVENTORY.STOCK_TRANSFER.CREATE', permission_name: 'Stock Transfer - Create', module: 'INVENTORY', resource: 'stock_transfer', action: 'CREATE', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      { permission_code: 'INVENTORY.STOCK_TRANSFER.READ', permission_name: 'Stock Transfer - Read', module: 'INVENTORY', resource: 'stock_transfer', action: 'READ', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      
      { permission_code: 'INVENTORY.STOCK_ADJUSTMENT.ALL', permission_name: 'Stock Adjustment - All', module: 'INVENTORY', resource: 'stock_adjustment', action: 'ALL', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      { permission_code: 'INVENTORY.STOCK_ADJUSTMENT.CREATE', permission_name: 'Stock Adjustment - Create', module: 'INVENTORY', resource: 'stock_adjustment', action: 'CREATE', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      { permission_code: 'INVENTORY.STOCK_ADJUSTMENT.READ', permission_name: 'Stock Adjustment - Read', module: 'INVENTORY', resource: 'stock_adjustment', action: 'READ', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      
      { permission_code: 'INVENTORY.STOCK_VIEW.READ', permission_name: 'Stock View - Read', module: 'INVENTORY', resource: 'stock_view', action: 'READ', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      { permission_code: 'INVENTORY.STOCK_REGISTER.ALL', permission_name: 'Stock Register - All', module: 'INVENTORY', resource: 'stock_register', action: 'ALL', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      { permission_code: 'INVENTORY.STOCK_REGISTER.READ', permission_name: 'Stock Register - Read', module: 'INVENTORY', resource: 'stock_register', action: 'READ', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      { permission_code: 'INVENTORY.TRANSACTION_HISTORY.ALL', permission_name: 'Transaction History (Stock Transfer History) - All', module: 'INVENTORY', resource: 'transaction_history', action: 'ALL', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      { permission_code: 'INVENTORY.TRANSACTION_HISTORY.READ', permission_name: 'Transaction History (Stock Transfer History) - Read', module: 'INVENTORY', resource: 'transaction_history', action: 'READ', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      { permission_code: 'INVENTORY.BATCH_SERIAL.ALL', permission_name: 'Batch & Serial Tracking - All', module: 'INVENTORY', resource: 'batch_serial', action: 'ALL', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      { permission_code: 'INVENTORY.BATCH_SERIAL.READ', permission_name: 'Batch & Serial Tracking - Read', module: 'INVENTORY', resource: 'batch_serial', action: 'READ', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },

      // ========== PRODUCTION ==========
      { permission_code: 'PRODUCTION.PRODUCTION_ORDER.ALL', permission_name: 'Production Order - All', module: 'PRODUCTION', resource: 'production_order', action: 'ALL', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      { permission_code: 'PRODUCTION.PRODUCTION_ORDER.CREATE', permission_name: 'Production Order - Create', module: 'PRODUCTION', resource: 'production_order', action: 'CREATE', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      { permission_code: 'PRODUCTION.PRODUCTION_ORDER.READ', permission_name: 'Production Order - Read', module: 'PRODUCTION', resource: 'production_order', action: 'READ', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      { permission_code: 'PRODUCTION.PRODUCTION_ORDER.APPROVE', permission_name: 'Production Order - Approve', module: 'PRODUCTION', resource: 'production_order', action: 'APPROVE', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      
      { permission_code: 'PRODUCTION.MATERIAL_ISSUE.ALL', permission_name: 'Material Issue - All', module: 'PRODUCTION', resource: 'material_issue', action: 'ALL', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      { permission_code: 'PRODUCTION.MATERIAL_ISSUE.CREATE', permission_name: 'Material Issue - Create', module: 'PRODUCTION', resource: 'material_issue', action: 'CREATE', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      { permission_code: 'PRODUCTION.MATERIAL_ISSUE.READ', permission_name: 'Material Issue - Read', module: 'PRODUCTION', resource: 'material_issue', action: 'READ', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      
      { permission_code: 'PRODUCTION.PRODUCTION_CONFIRMATION.ALL', permission_name: 'Production Confirmation - All', module: 'PRODUCTION', resource: 'production_confirmation', action: 'ALL', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      { permission_code: 'PRODUCTION.PRODUCTION_CONFIRMATION.CREATE', permission_name: 'Production Confirmation - Create', module: 'PRODUCTION', resource: 'production_confirmation', action: 'CREATE', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      { permission_code: 'PRODUCTION.PRODUCTION_CONFIRMATION.READ', permission_name: 'Production Confirmation - Read', module: 'PRODUCTION', resource: 'production_confirmation', action: 'READ', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      
      { permission_code: 'PRODUCTION.WIP_TRACKING.ALL', permission_name: 'WIP Tracking - All', module: 'PRODUCTION', resource: 'wip_tracking', action: 'ALL', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      { permission_code: 'PRODUCTION.WIP_TRACKING.READ', permission_name: 'WIP Tracking - Read', module: 'PRODUCTION', resource: 'wip_tracking', action: 'READ', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      
      { permission_code: 'PRODUCTION.SCRAP_REPORTING.ALL', permission_name: 'Scrap Reporting - All', module: 'PRODUCTION', resource: 'scrap_reporting', action: 'ALL', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      { permission_code: 'PRODUCTION.SCRAP_REPORTING.CREATE', permission_name: 'Scrap Reporting - Create', module: 'PRODUCTION', resource: 'scrap_reporting', action: 'CREATE', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },

      { permission_code: 'PRODUCTION.JOB_CARD.ALL', permission_name: 'Job Card / Operation Execution - All', module: 'PRODUCTION', resource: 'job_card', action: 'ALL', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      { permission_code: 'PRODUCTION.JOB_CARD.VIEW', permission_name: 'Job Card / Operation Execution - View', module: 'PRODUCTION', resource: 'job_card', action: 'READ', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      { permission_code: 'PRODUCTION.WIP_BY_OPERATION.ALL', permission_name: 'WIP by Operation - All', module: 'PRODUCTION', resource: 'wip_by_operation', action: 'ALL', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      { permission_code: 'PRODUCTION.WIP_BY_OPERATION.VIEW', permission_name: 'WIP by Operation - View', module: 'PRODUCTION', resource: 'wip_by_operation', action: 'READ', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      { permission_code: 'PRODUCTION.MRP.ALL', permission_name: 'Material Requirement Planning (MRP) - All', module: 'PRODUCTION', resource: 'mrp', action: 'ALL', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      { permission_code: 'PRODUCTION.MRP.READ', permission_name: 'Material Requirement Planning (MRP) - Read', module: 'PRODUCTION', resource: 'mrp', action: 'READ', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      { permission_code: 'PRODUCTION.STOCK_REGISTER.ALL', permission_name: 'Department Stock Register - All', module: 'PRODUCTION', resource: 'stock_register', action: 'ALL', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      { permission_code: 'PRODUCTION.STOCK_REGISTER.READ', permission_name: 'Department Stock Register - Read', module: 'PRODUCTION', resource: 'stock_register', action: 'READ', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },

      // ========== SALES ==========
      { permission_code: 'SALES.SALES_QUOTATION.ALL', permission_name: 'Sales Quotation - All', module: 'SALES', resource: 'sales_quotation', action: 'ALL', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      { permission_code: 'SALES.SALES_QUOTATION.CREATE', permission_name: 'Sales Quotation - Create', module: 'SALES', resource: 'sales_quotation', action: 'CREATE', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      { permission_code: 'SALES.SALES_QUOTATION.READ', permission_name: 'Sales Quotation - Read', module: 'SALES', resource: 'sales_quotation', action: 'READ', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      { permission_code: 'SALES.SALES_QUOTATION.APPROVE', permission_name: 'Sales Quotation - Approve', module: 'SALES', resource: 'sales_quotation', action: 'APPROVE', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      
      { permission_code: 'SALES.SALES_ORDER.ALL', permission_name: 'Sales Order - All', module: 'SALES', resource: 'sales_order', action: 'ALL', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      { permission_code: 'SALES.SALES_ORDER.CREATE', permission_name: 'Sales Order - Create', module: 'SALES', resource: 'sales_order', action: 'CREATE', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      { permission_code: 'SALES.SALES_ORDER.READ', permission_name: 'Sales Order - Read', module: 'SALES', resource: 'sales_order', action: 'READ', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      { permission_code: 'SALES.SALES_ORDER.APPROVE', permission_name: 'Sales Order - Approve', module: 'SALES', resource: 'sales_order', action: 'APPROVE', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      
      { permission_code: 'SALES.DELIVERY.ALL', permission_name: 'Delivery - All', module: 'SALES', resource: 'delivery', action: 'ALL', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      { permission_code: 'SALES.DELIVERY.CREATE', permission_name: 'Delivery - Create', module: 'SALES', resource: 'delivery', action: 'CREATE', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      { permission_code: 'SALES.DELIVERY.READ', permission_name: 'Delivery - Read', module: 'SALES', resource: 'delivery', action: 'READ', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      
      { permission_code: 'SALES.SALES_INVOICE.ALL', permission_name: 'Sales Invoice - All', module: 'SALES', resource: 'sales_invoice', action: 'ALL', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      { permission_code: 'SALES.SALES_INVOICE.CREATE', permission_name: 'Sales Invoice - Create', module: 'SALES', resource: 'sales_invoice', action: 'CREATE', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      { permission_code: 'SALES.SALES_INVOICE.READ', permission_name: 'Sales Invoice - Read', module: 'SALES', resource: 'sales_invoice', action: 'READ', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },

      // ========== CUSTOMER ==========
      { permission_code: 'CUSTOMER.CUSTOMER_QUOTATION.ALL', permission_name: 'Customer Quotation - All', module: 'CUSTOMER', resource: 'customer_quotation', action: 'ALL', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      { permission_code: 'CUSTOMER.CUSTOMER_QUOTATION.CREATE', permission_name: 'Customer Quotation - Create', module: 'CUSTOMER', resource: 'customer_quotation', action: 'CREATE', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      { permission_code: 'CUSTOMER.CUSTOMER_QUOTATION.READ', permission_name: 'Customer Quotation - Read', module: 'CUSTOMER', resource: 'customer_quotation', action: 'READ', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      { permission_code: 'CUSTOMER.CUSTOMER_QUOTATION.APPROVE', permission_name: 'Customer Quotation - Approve', module: 'CUSTOMER', resource: 'customer_quotation', action: 'APPROVE', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      
      { permission_code: 'CUSTOMER.CUSTOMER_PO.ALL', permission_name: 'Customer PO - All', module: 'CUSTOMER', resource: 'customer_po', action: 'ALL', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      { permission_code: 'CUSTOMER.CUSTOMER_PO.CREATE', permission_name: 'Customer PO - Create', module: 'CUSTOMER', resource: 'customer_po', action: 'CREATE', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      { permission_code: 'CUSTOMER.CUSTOMER_PO.READ', permission_name: 'Customer PO - Read', module: 'CUSTOMER', resource: 'customer_po', action: 'READ', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      { permission_code: 'CUSTOMER.CUSTOMER_PO.APPROVE', permission_name: 'Customer PO - Approve', module: 'CUSTOMER', resource: 'customer_po', action: 'APPROVE', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },

      // ========== FINANCE ==========
      { permission_code: 'FINANCE.GL_ACCOUNT.ALL', permission_name: 'GL Account - All', module: 'FINANCE', resource: 'gl_account', action: 'ALL', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      { permission_code: 'FINANCE.GL_ACCOUNT.READ', permission_name: 'GL Account - Read', module: 'FINANCE', resource: 'gl_account', action: 'READ', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      { permission_code: 'FINANCE.ACCOUNTING_DOCUMENT.ALL', permission_name: 'Accounting Document - All', module: 'FINANCE', resource: 'accounting_document', action: 'ALL', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      { permission_code: 'FINANCE.ACCOUNTING_DOCUMENT.READ', permission_name: 'Accounting Document - Read', module: 'FINANCE', resource: 'accounting_document', action: 'READ', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      { permission_code: 'FINANCE.TRIAL_BALANCE.READ', permission_name: 'Trial Balance - Read', module: 'FINANCE', resource: 'trial_balance', action: 'READ', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },

      // ========== HR ==========
      { permission_code: 'HR.EMPLOYEE.ALL', permission_name: 'Employee - All', module: 'HR', resource: 'employee', action: 'ALL', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      { permission_code: 'HR.EMPLOYEE.READ', permission_name: 'Employee - Read', module: 'HR', resource: 'employee', action: 'READ', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      { permission_code: 'HR.ATTENDANCE.ALL', permission_name: 'Attendance - All', module: 'HR', resource: 'attendance', action: 'ALL', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      { permission_code: 'HR.ATTENDANCE.CREATE', permission_name: 'Attendance - Create', module: 'HR', resource: 'attendance', action: 'CREATE', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      { permission_code: 'HR.ATTENDANCE.READ', permission_name: 'Attendance - Read', module: 'HR', resource: 'attendance', action: 'READ', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      { permission_code: 'HR.PAYROLL.ALL', permission_name: 'Payroll - All', module: 'HR', resource: 'payroll', action: 'ALL', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      { permission_code: 'HR.PAYROLL.READ', permission_name: 'Payroll - Read', module: 'HR', resource: 'payroll', action: 'READ', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      { permission_code: 'HR.MUSTER_ROLL.ALL', permission_name: 'Muster Roll - All', module: 'HR', resource: 'muster_roll', action: 'ALL', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      { permission_code: 'HR.MUSTER_ROLL.READ', permission_name: 'Muster Roll - Read', module: 'HR', resource: 'muster_roll', action: 'READ', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      { permission_code: 'HR.PAYSLIP.ALL', permission_name: 'Payslip - All', module: 'HR', resource: 'payslip', action: 'ALL', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      { permission_code: 'HR.PAYSLIP.READ', permission_name: 'Payslip - Read', module: 'HR', resource: 'payslip', action: 'READ', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },

      // ========== QA ==========
      { permission_code: 'QA.INCOMING_INSPECTION.ALL', permission_name: 'Incoming Inspection - All', module: 'QA', resource: 'incoming_inspection', action: 'ALL', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      { permission_code: 'QA.INCOMING_INSPECTION.READ', permission_name: 'Incoming Inspection - Read', module: 'QA', resource: 'incoming_inspection', action: 'READ', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      { permission_code: 'QA.DIMENSIONAL_REPORT.ALL', permission_name: 'Dimensional Report - All', module: 'QA', resource: 'dimensional_report', action: 'ALL', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      { permission_code: 'QA.DIMENSIONAL_REPORT.READ', permission_name: 'Dimensional Report - Read', module: 'QA', resource: 'dimensional_report', action: 'READ', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      { permission_code: 'QA.IN_PROCESS_CHECKLIST.ALL', permission_name: 'In Process Checklist - All', module: 'QA', resource: 'in_process_checklist', action: 'ALL', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      { permission_code: 'QA.IN_PROCESS_CHECKLIST.READ', permission_name: 'In Process Checklist - Read', module: 'QA', resource: 'in_process_checklist', action: 'READ', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      { permission_code: 'QA.WELDING_FINAL_INSPECTION.ALL', permission_name: 'Welding Final Inspection - All', module: 'QA', resource: 'welding_final_inspection', action: 'ALL', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      { permission_code: 'QA.WELDING_FINAL_INSPECTION.READ', permission_name: 'Welding Final Inspection - Read', module: 'QA', resource: 'welding_final_inspection', action: 'READ', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      { permission_code: 'QA.ASSEMBLY_FINAL_INSPECTION.ALL', permission_name: 'Assembly Final Inspection - All', module: 'QA', resource: 'assembly_final_inspection', action: 'ALL', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      { permission_code: 'QA.ASSEMBLY_FINAL_INSPECTION.READ', permission_name: 'Assembly Final Inspection - Read', module: 'QA', resource: 'assembly_final_inspection', action: 'READ', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      { permission_code: 'QA.MEASURING_INSTRUMENTS.ALL', permission_name: 'Measuring Instruments - All', module: 'QA', resource: 'measuring_instruments', action: 'ALL', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      { permission_code: 'QA.MEASURING_INSTRUMENTS.READ', permission_name: 'Measuring Instruments - Read', module: 'QA', resource: 'measuring_instruments', action: 'READ', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      { permission_code: 'QA.MEASURING_INSTRUMENT_HISTORY_CARD.ALL', permission_name: 'Measuring Instrument History Card - All', module: 'QA', resource: 'measuring_instrument_history_card', action: 'ALL', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      { permission_code: 'QA.MEASURING_INSTRUMENT_HISTORY_CARD.READ', permission_name: 'Measuring Instrument History Card - Read', module: 'QA', resource: 'measuring_instrument_history_card', action: 'READ', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      { permission_code: 'QA.REJECTION_REWORK.ALL', permission_name: 'Rejection / Rework Record - All', module: 'QA', resource: 'rejection_rework', action: 'ALL', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      { permission_code: 'QA.REJECTION_REWORK.READ', permission_name: 'Rejection / Rework Record - Read', module: 'QA', resource: 'rejection_rework', action: 'READ', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      { permission_code: 'QA.CUSTOMER_COMPLAINT.ALL', permission_name: 'Customer Complaint Register - All', module: 'QA', resource: 'customer_complaint', action: 'ALL', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      { permission_code: 'QA.CUSTOMER_COMPLAINT.READ', permission_name: 'Customer Complaint Register - Read', module: 'QA', resource: 'customer_complaint', action: 'READ', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      { permission_code: 'QA.CORRECTIVE_ACTION.ALL', permission_name: 'Corrective Action Report - All', module: 'QA', resource: 'corrective_action', action: 'ALL', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      { permission_code: 'QA.CORRECTIVE_ACTION.READ', permission_name: 'Corrective Action Report - Read', module: 'QA', resource: 'corrective_action', action: 'READ', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },

      // ========== REPORT ==========
      { permission_code: 'REPORT.VIEW', permission_name: 'Reports - View', module: 'REPORT', resource: 'report', action: 'READ', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      { permission_code: 'REPORT.BOM.ALL', permission_name: 'BOM Report - All', module: 'REPORT', resource: 'bom', action: 'ALL', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      { permission_code: 'REPORT.BOM.READ', permission_name: 'BOM Report - Read', module: 'REPORT', resource: 'bom', action: 'READ', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      { permission_code: 'REPORT.MATERIAL_MASTER.ALL', permission_name: 'Material Master Report - All', module: 'REPORT', resource: 'material_master', action: 'ALL', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      { permission_code: 'REPORT.MATERIAL_MASTER.READ', permission_name: 'Material Master Report - Read', module: 'REPORT', resource: 'material_master', action: 'READ', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      { permission_code: 'REPORT.BUSINESS_PARTNER.ALL', permission_name: 'Business Partner Report - All', module: 'REPORT', resource: 'business_partner', action: 'ALL', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      { permission_code: 'REPORT.BUSINESS_PARTNER.READ', permission_name: 'Business Partner Report - Read', module: 'REPORT', resource: 'business_partner', action: 'READ', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      { permission_code: 'REPORT.APPROVED_SUPPLIERS.ALL', permission_name: 'Approved Suppliers Report - All', module: 'REPORT', resource: 'approved_suppliers', action: 'ALL', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      { permission_code: 'REPORT.APPROVED_SUPPLIERS.READ', permission_name: 'Approved Suppliers Report - Read', module: 'REPORT', resource: 'approved_suppliers', action: 'READ', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      { permission_code: 'REPORT.PURCHASE_ORDER.ALL', permission_name: 'Purchase Order Register Report - All', module: 'REPORT', resource: 'purchase_order', action: 'ALL', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      { permission_code: 'REPORT.PURCHASE_ORDER.READ', permission_name: 'Purchase Order Register Report - Read', module: 'REPORT', resource: 'purchase_order', action: 'READ', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      { permission_code: 'REPORT.GOODS_RECEIPT.ALL', permission_name: 'Goods Receipt Register Report - All', module: 'REPORT', resource: 'goods_receipt', action: 'ALL', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      { permission_code: 'REPORT.GOODS_RECEIPT.READ', permission_name: 'Goods Receipt Register Report - Read', module: 'REPORT', resource: 'goods_receipt', action: 'READ', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      { permission_code: 'REPORT.VENDOR_INVOICE.ALL', permission_name: 'Vendor Invoice Register Report - All', module: 'REPORT', resource: 'vendor_invoice', action: 'ALL', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      { permission_code: 'REPORT.VENDOR_INVOICE.READ', permission_name: 'Vendor Invoice Register Report - Read', module: 'REPORT', resource: 'vendor_invoice', action: 'READ', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      { permission_code: 'REPORT.PURCHASE_REQUISITION.ALL', permission_name: 'Purchase Requisition Register Report - All', module: 'REPORT', resource: 'purchase_requisition', action: 'ALL', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      { permission_code: 'REPORT.PURCHASE_REQUISITION.READ', permission_name: 'Purchase Requisition Register Report - Read', module: 'REPORT', resource: 'purchase_requisition', action: 'READ', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      { permission_code: 'REPORT.PRODUCTION_ORDER.ALL', permission_name: 'Production Order Register Report - All', module: 'REPORT', resource: 'production_order', action: 'ALL', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      { permission_code: 'REPORT.PRODUCTION_ORDER.READ', permission_name: 'Production Order Register Report - Read', module: 'REPORT', resource: 'production_order', action: 'READ', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      { permission_code: 'REPORT.PRODUCTION_CONFIRMATION.ALL', permission_name: 'Production Confirmation Register Report - All', module: 'REPORT', resource: 'production_confirmation', action: 'ALL', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      { permission_code: 'REPORT.PRODUCTION_CONFIRMATION.READ', permission_name: 'Production Confirmation Register Report - Read', module: 'REPORT', resource: 'production_confirmation', action: 'READ', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      { permission_code: 'REPORT.SCRAP.ALL', permission_name: 'Scrap Report Register - All', module: 'REPORT', resource: 'scrap', action: 'ALL', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      { permission_code: 'REPORT.SCRAP.READ', permission_name: 'Scrap Report Register - Read', module: 'REPORT', resource: 'scrap', action: 'READ', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },

      // ========== ADMIN ==========
      { permission_code: 'ADMIN.USER.ALL', permission_name: 'User - All', module: 'ADMIN', resource: 'user', action: 'ALL', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      { permission_code: 'ADMIN.USER.READ', permission_name: 'User - Read', module: 'ADMIN', resource: 'user', action: 'READ', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      { permission_code: 'ADMIN.ROLE.ALL', permission_name: 'Role - All', module: 'ADMIN', resource: 'role', action: 'ALL', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      { permission_code: 'ADMIN.ROLE.READ', permission_name: 'Role - Read', module: 'ADMIN', resource: 'role', action: 'READ', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      { permission_code: 'ADMIN.PERMISSION.ALL', permission_name: 'Permission - All', module: 'ADMIN', resource: 'permission', action: 'ALL', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() },
      { permission_code: 'ADMIN.APPROVAL_MASTER.ALL', permission_name: 'Approval Master - All', module: 'ADMIN', resource: 'approval_master', action: 'ALL', is_system_permission: true, status: 'ACTIVE', created_at: new Date(), updated_at: new Date() }
    ];

    await queryInterface.bulkInsert('permission', permissions, {
      ignoreDuplicates: true
    });
  },

  async down(queryInterface, Sequelize) {
    await queryInterface.bulkDelete('permission', null, {});
  }
};

