<?php

namespace Database\Seeders;

use App\Models\Permission;
use Illuminate\Database\Seeder;

class PermissionSeeder extends Seeder
{
    public function run(): void
    {
        Permission::truncate();

        $permissions = [
            ['name' => 'View Dashboard', 'slug' => 'dashboard.view', 'description' => 'Can view dashboard'],
            ['name' => 'View Products', 'slug' => 'products.view', 'description' => 'Can view products list'],
            ['name' => 'Create Products', 'slug' => 'products.create', 'description' => 'Can create products'],
            ['name' => 'Edit Products', 'slug' => 'products.edit', 'description' => 'Can edit products'],
            ['name' => 'Delete Products', 'slug' => 'products.delete', 'description' => 'Can delete products'],
            ['name' => 'View Categories', 'slug' => 'categories.view', 'description' => 'Can view categories'],
            ['name' => 'Create Categories', 'slug' => 'categories.create', 'description' => 'Can create categories'],
            ['name' => 'Edit Categories', 'slug' => 'categories.edit', 'description' => 'Can edit categories'],
            ['name' => 'Delete Categories', 'slug' => 'categories.delete', 'description' => 'Can delete categories'],
            ['name' => 'View Unit of Measures', 'slug' => 'unit-of-measures.view', 'description' => 'Can view unit of measures'],
            ['name' => 'Create Unit of Measures', 'slug' => 'unit-of-measures.create', 'description' => 'Can create unit of measures'],
            ['name' => 'Edit Unit of Measures', 'slug' => 'unit-of-measures.edit', 'description' => 'Can edit unit of measures'],
            ['name' => 'Delete Unit of Measures', 'slug' => 'unit-of-measures.delete', 'description' => 'Can delete unit of measures'],
            ['name' => 'View Customers', 'slug' => 'customers.view', 'description' => 'Can view customers'],
            ['name' => 'Create Customers', 'slug' => 'customers.create', 'description' => 'Can create customers'],
            ['name' => 'Edit Customers', 'slug' => 'customers.edit', 'description' => 'Can edit customers'],
            ['name' => 'Delete Customers', 'slug' => 'customers.delete', 'description' => 'Can delete customers'],
            ['name' => 'View Suppliers', 'slug' => 'suppliers.view', 'description' => 'Can view suppliers'],
            ['name' => 'Create Suppliers', 'slug' => 'suppliers.create', 'description' => 'Can create suppliers'],
            ['name' => 'Edit Suppliers', 'slug' => 'suppliers.edit', 'description' => 'Can edit suppliers'],
            ['name' => 'Delete Suppliers', 'slug' => 'suppliers.delete', 'description' => 'Can delete suppliers'],
            ['name' => 'Supplier Finance', 'slug' => 'suppliers.finance', 'description' => 'Can view supplier finance'],
            ['name' => 'POS Sales', 'slug' => 'pos.sales', 'description' => 'Can make sales'],
            ['name' => 'Opening Balance', 'slug' => 'opening-balance.view', 'description' => 'Can view opening balance'],
            ['name' => 'Expiry Management', 'slug' => 'expiry.manage', 'description' => 'Can manage product expiry'],
            ['name' => 'View Orders', 'slug' => 'orders.view', 'description' => 'Can view orders'],
            ['name' => 'Cancel Orders', 'slug' => 'orders.cancel', 'description' => 'Can cancel orders'],
            ['name' => 'View Inventory', 'slug' => 'inventory.view', 'description' => 'Can view inventory'],
            ['name' => 'Stock In', 'slug' => 'inventory.stock-in', 'description' => 'Can add stock'],
            ['name' => 'Price Adjustment', 'slug' => 'inventory.adjustment', 'description' => 'Can adjust inventory'],
            ['name' => 'Products Reconciliation', 'slug' => 'products.reconciliation', 'description' => 'Can manage products reconciliation'],
            ['name' => 'Reconciliation Report', 'slug' => 'reports.reconciliation', 'description' => 'Can view reconciliation report'],
            ['name' => 'View Reports', 'slug' => 'reports.view', 'description' => 'Can view reports'],
            ['name' => 'Sales Report', 'slug' => 'reports.sales', 'description' => 'Can view sales report'],
            ['name' => 'Profit Report', 'slug' => 'reports.profit', 'description' => 'Can view profit report'],
            ['name' => 'Inventory Report', 'slug' => 'reports.inventory', 'description' => 'Can view inventory report'],
            ['name' => 'Stock Value Report', 'slug' => 'reports.stock-value', 'description' => 'Can view detailed stock value report'],
            ['name' => 'Supplier Payments Report', 'slug' => 'reports.supplier-payments', 'description' => 'Can view supplier payments report'],
            ['name' => 'Opening Balance Report', 'slug' => 'reports.opening-balance', 'description' => 'Can view opening balance report'],
            ['name' => 'Stock Movement Report', 'slug' => 'reports.stock-movement', 'description' => 'Can view stock movement report'],
            ['name' => 'Cashier Report', 'slug' => 'reports.cashier', 'description' => 'Can view cashier report'],
            ['name' => 'Cashier Sales Report', 'slug' => 'reports.cashier-sales', 'description' => 'Can view cashier sales report'],
            ['name' => 'Disposed Products Report', 'slug' => 'reports.disposed', 'description' => 'Can view disposed products report'],
            ['name' => 'Manage Users', 'slug' => 'users.manage', 'description' => 'Can manage users'],
            ['name' => 'Manage Permissions', 'slug' => 'permissions.manage', 'description' => 'Can manage user permissions'],
            ['name' => 'View Expenses', 'slug' => 'expenses.view', 'description' => 'Can view expenses'],
            ['name' => 'Create Expenses', 'slug' => 'expenses.create', 'description' => 'Can create expenses'],
            ['name' => 'Delete Expenses', 'slug' => 'expenses.delete', 'description' => 'Can delete expenses'],
            ['name' => 'View Cash Flow', 'slug' => 'expenses.cashflow', 'description' => 'Can view cash flow report'],
            ['name' => 'View Tax', 'slug' => 'tax.view', 'description' => 'Can view tax configuration'],
            ['name' => 'Manage Tax', 'slug' => 'tax.manage', 'description' => 'Can manage tax settings'],
            ['name' => 'View e-TIMS', 'slug' => 'tax.etims.view', 'description' => 'Can view e-TIMS configuration'],
            ['name' => 'Manage e-TIMS', 'slug' => 'tax.etims.manage', 'description' => 'Can manage e-TIMS settings'],
            ['name' => 'View M-Pesa', 'slug' => 'mpesa.view', 'description' => 'Can view M-Pesa configuration'],
            ['name' => 'Manage M-Pesa', 'slug' => 'mpesa.manage', 'description' => 'Can manage M-Pesa settings'],
            ['name' => 'View Credit', 'slug' => 'credit.view', 'description' => 'Can view credit management'],
            ['name' => 'Manage Credit', 'slug' => 'credit.manage', 'description' => 'Can manage credit and receive payments'],
            ['name' => 'Send Reminders', 'slug' => 'credit.reminders', 'description' => 'Can send payment reminders'],
            ['name' => 'SMS Settings', 'slug' => 'settings.sms', 'description' => 'Can manage SMS integration settings'],
            ['name' => 'Receipt Settings', 'slug' => 'settings.receipt', 'description' => 'Can manage receipt and report settings'],
            ['name' => 'System Settings', 'slug' => 'settings.system', 'description' => 'Can manage system settings'],
            ['name' => 'M-Pesa Access', 'slug' => 'mpesa.access', 'description' => 'Can access M-Pesa menu'],
            ['name' => 'M-Pesa Transactions Report', 'slug' => 'reports.mpesa-transactions', 'description' => 'Can view M-Pesa transactions report'],
        ];

        foreach ($permissions as $perm) {
            Permission::firstOrCreate(['slug' => $perm['slug']], $perm);
        }
    }
}
