<?php

use App\Enums\AccountType;
use App\Enums\NormalBalance;
use App\Enums\TaxCategory;
use App\Models\Account;
use App\Models\BankAccount;
use App\Models\Branch;
use App\Models\Contract;
use App\Models\Driver;
use App\Models\FuelEntry;
use App\Models\Party;
use App\Models\RateCard;
use App\Models\ServiceType;
use App\Models\TaxCode;
use App\Models\TransportRoute;
use App\Models\Trip;
use App\Models\Vehicle;
use App\Models\VehicleMaintenance;

return [
    'modules' => [
        'branches' => [
            'title' => 'Branches', 'singular' => 'Branch', 'model' => Branch::class,
            'permission' => 'branches', 'company_scoped' => true, 'branch_scoped' => false,
            'search' => ['code', 'name', 'emirate', 'email'],
            'columns' => ['code' => 'Code', 'name' => 'Branch', 'emirate' => 'Emirate', 'phone' => 'Phone', 'is_active' => 'Active'],
            'fields' => [
                'code' => ['label' => 'Code', 'rules' => 'required|string|max:20', 'unique' => true],
                'name' => ['label' => 'Branch Name', 'rules' => 'required|string|max:150'],
                'emirate' => ['label' => 'Emirate', 'rules' => 'nullable|string|max:100'],
                'phone' => ['label' => 'Phone', 'rules' => 'nullable|string|max:50'],
                'email' => ['label' => 'Email', 'type' => 'email', 'rules' => 'nullable|email|max:150'],
                'address' => ['label' => 'Address', 'type' => 'textarea', 'rules' => 'nullable|string|max:2000'],
                'is_active' => ['label' => 'Active', 'type' => 'checkbox', 'rules' => 'boolean', 'default' => true],
            ],
        ],
        'accounts' => [
            'title' => 'Chart of Accounts', 'singular' => 'Account', 'model' => Account::class,
            'permission' => 'accounts', 'company_scoped' => true, 'branch_scoped' => false,
            'search' => ['code', 'name', 'type'],
            'columns' => ['code' => 'Code', 'name' => 'Account', 'type' => 'Type', 'normal_balance' => 'Normal Balance', 'is_control_account' => 'Control', 'is_active' => 'Active'],
            'fields' => [
                'parent_id' => ['label' => 'Parent Account', 'type' => 'relation', 'model' => Account::class, 'option_label' => 'code_name', 'rules' => 'nullable|integer'],
                'code' => ['label' => 'Account Code', 'rules' => 'required|string|max:30', 'unique' => true],
                'name' => ['label' => 'Account Name', 'rules' => 'required|string|max:150'],
                'type' => ['label' => 'Account Type', 'type' => 'select', 'options' => array_combine(array_column(AccountType::cases(), 'value'), array_map(fn ($case) => ucwords(str_replace('_', ' ', $case->value)), AccountType::cases())), 'rules' => 'required|string'],
                'normal_balance' => ['label' => 'Normal Balance', 'type' => 'select', 'options' => array_combine(array_column(NormalBalance::cases(), 'value'), array_map(fn ($case) => ucfirst($case->value), NormalBalance::cases())), 'rules' => 'required|string'],
                'is_control_account' => ['label' => 'Control Account', 'type' => 'checkbox', 'rules' => 'boolean'],
                'is_active' => ['label' => 'Active', 'type' => 'checkbox', 'rules' => 'boolean', 'default' => true],
            ],
        ],
        'tax-codes' => [
            'title' => 'VAT & Tax Codes', 'singular' => 'Tax Code', 'model' => TaxCode::class,
            'permission' => 'tax_settings', 'company_scoped' => true, 'branch_scoped' => false,
            'search' => ['code', 'name', 'category'],
            'columns' => ['code' => 'Code', 'name' => 'Tax Code', 'category' => 'Category', 'rate' => 'Rate %', 'recoverable_percentage' => 'Recoverable %', 'is_active' => 'Active'],
            'fields' => [
                'code' => ['label' => 'Code', 'rules' => 'required|string|max:30', 'unique' => true],
                'name' => ['label' => 'Name', 'rules' => 'required|string|max:150'],
                'category' => ['label' => 'Category', 'type' => 'select', 'options' => array_combine(array_column(TaxCategory::cases(), 'value'), array_map(fn ($case) => ucwords(str_replace('_', ' ', $case->value)), TaxCategory::cases())), 'rules' => 'required|string'],
                'rate' => ['label' => 'VAT Rate %', 'type' => 'number', 'step' => '0.0001', 'rules' => 'required|numeric|min:0|max:100'],
                'recoverable_percentage' => ['label' => 'Recoverable %', 'type' => 'number', 'step' => '0.0001', 'rules' => 'required|numeric|min:0|max:100'],
                'output_account_id' => ['label' => 'Output VAT Account', 'type' => 'relation', 'model' => Account::class, 'option_label' => 'code_name', 'rules' => 'nullable|integer'],
                'input_account_id' => ['label' => 'Input VAT Account', 'type' => 'relation', 'model' => Account::class, 'option_label' => 'code_name', 'rules' => 'nullable|integer'],
                'requires_trn' => ['label' => 'TRN Required', 'type' => 'checkbox', 'rules' => 'boolean'],
                'requires_evidence' => ['label' => 'Supporting Evidence Required', 'type' => 'checkbox', 'rules' => 'boolean'],
                'is_active' => ['label' => 'Active', 'type' => 'checkbox', 'rules' => 'boolean', 'default' => true],
            ],
        ],
        'service-types' => [
            'title' => 'Transport Service Types', 'singular' => 'Service Type', 'model' => ServiceType::class,
            'permission' => 'service_types', 'company_scoped' => true, 'branch_scoped' => false,
            'search' => ['code', 'name', 'description'],
            'columns' => ['code' => 'Code', 'name' => 'Service Type', 'description' => 'Description', 'is_active' => 'Active'],
            'fields' => [
                'code' => ['label' => 'Code', 'rules' => 'required|string|max:30', 'unique' => true],
                'name' => ['label' => 'Name', 'rules' => 'required|string|max:150'],
                'description' => ['label' => 'Description', 'type' => 'textarea', 'rules' => 'nullable|string|max:3000'],
                'default_tax_code_id' => ['label' => 'Default VAT Code', 'type' => 'relation', 'model' => TaxCode::class, 'option_label' => 'code_name', 'rules' => 'nullable|integer'],
                'default_income_account_id' => ['label' => 'Default Income Account', 'type' => 'relation', 'model' => Account::class, 'option_label' => 'code_name', 'rules' => 'nullable|integer'],
                'default_cost_account_id' => ['label' => 'Default Cost Account', 'type' => 'relation', 'model' => Account::class, 'option_label' => 'code_name', 'rules' => 'nullable|integer'],
                'is_active' => ['label' => 'Active', 'type' => 'checkbox', 'rules' => 'boolean', 'default' => true],
            ],
        ],
        'routes' => [
            'title' => 'Transport Routes', 'singular' => 'Route', 'model' => TransportRoute::class,
            'permission' => 'routes', 'company_scoped' => true, 'branch_scoped' => false,
            'search' => ['code', 'name', 'origin', 'destination'],
            'columns' => ['code' => 'Code', 'name' => 'Route', 'origin' => 'Origin', 'destination' => 'Destination', 'distance_km' => 'Distance KM', 'is_active' => 'Active'],
            'fields' => [
                'code' => ['label' => 'Code', 'rules' => 'required|string|max:30', 'unique' => true],
                'name' => ['label' => 'Route Name', 'rules' => 'required|string|max:150'],
                'origin' => ['label' => 'Origin', 'rules' => 'required|string|max:150'],
                'destination' => ['label' => 'Destination', 'rules' => 'required|string|max:150'],
                'origin_emirate' => ['label' => 'Origin Emirate', 'rules' => 'nullable|string|max:100'],
                'destination_emirate' => ['label' => 'Destination Emirate', 'rules' => 'nullable|string|max:100'],
                'origin_country' => ['label' => 'Origin Country Code', 'rules' => 'required|string|size:2', 'default' => 'AE'],
                'destination_country' => ['label' => 'Destination Country Code', 'rules' => 'required|string|size:2', 'default' => 'AE'],
                'distance_km' => ['label' => 'Distance (KM)', 'type' => 'number', 'step' => '0.01', 'rules' => 'nullable|numeric|min:0'],
                'is_active' => ['label' => 'Active', 'type' => 'checkbox', 'rules' => 'boolean', 'default' => true],
            ],
        ],
        'vehicles' => [
            'title' => 'Vehicles', 'singular' => 'Vehicle', 'model' => Vehicle::class,
            'permission' => 'vehicles', 'company_scoped' => true, 'branch_scoped' => true,
            'search' => ['vehicle_number', 'plate_number', 'vehicle_type', 'make', 'model'],
            'columns' => ['plate_number' => 'Plate', 'vehicle_number' => 'Vehicle No.', 'vehicle_type' => 'Type', 'make' => 'Make', 'model' => 'Model', 'registration_expiry' => 'Registration Expiry', 'is_active' => 'Active'],
            'fields' => [
                'branch_id' => ['label' => 'Branch', 'type' => 'relation', 'model' => Branch::class, 'option_label' => 'code_name', 'rules' => 'nullable|integer'],
                'owner_party_id' => ['label' => 'External Owner / Vendor', 'type' => 'relation', 'model' => Party::class, 'option_label' => 'legal_name', 'rules' => 'nullable|integer'],
                'assigned_driver_id' => ['label' => 'Assigned Driver', 'type' => 'relation', 'model' => Driver::class, 'option_label' => 'name', 'rules' => 'nullable|integer'],
                'vehicle_number' => ['label' => 'Vehicle Number', 'rules' => 'required|string|max:50'],
                'plate_number' => ['label' => 'Plate Number', 'rules' => 'required|string|max:50', 'unique' => true],
                'emirate' => ['label' => 'Emirate', 'rules' => 'nullable|string|max:100'],
                'vehicle_type' => ['label' => 'Vehicle Type', 'rules' => 'nullable|string|max:100'],
                'make' => ['label' => 'Make', 'rules' => 'nullable|string|max:100'],
                'model' => ['label' => 'Model', 'rules' => 'nullable|string|max:100'],
                'year' => ['label' => 'Year', 'type' => 'number', 'rules' => 'nullable|integer|min:1950|max:2100'],
                'ownership_type' => ['label' => 'Ownership', 'type' => 'select', 'options' => ['company' => 'Company Owned', 'hired' => 'Externally Hired', 'leased' => 'Leased'], 'rules' => 'required|string'],
                'current_odometer' => ['label' => 'Current Odometer', 'type' => 'number', 'step' => '0.01', 'rules' => 'nullable|numeric|min:0'],
                'payload_capacity' => ['label' => 'Payload Capacity', 'type' => 'number', 'step' => '0.01', 'rules' => 'nullable|numeric|min:0'],
                'registration_expiry' => ['label' => 'Registration Expiry', 'type' => 'date', 'rules' => 'nullable|date'],
                'insurance_expiry' => ['label' => 'Insurance Expiry', 'type' => 'date', 'rules' => 'nullable|date'],
                'permit_expiry' => ['label' => 'Permit Expiry', 'type' => 'date', 'rules' => 'nullable|date'],
                'inspection_expiry' => ['label' => 'Inspection Expiry', 'type' => 'date', 'rules' => 'nullable|date'],
                'lease_expiry' => ['label' => 'Lease Expiry', 'type' => 'date', 'rules' => 'nullable|date'],
                'notes' => ['label' => 'Notes', 'type' => 'textarea', 'rules' => 'nullable|string|max:3000'],
                'is_active' => ['label' => 'Active', 'type' => 'checkbox', 'rules' => 'boolean', 'default' => true],
            ],
        ],
        'drivers' => [
            'title' => 'Drivers', 'singular' => 'Driver', 'model' => Driver::class,
            'permission' => 'drivers', 'company_scoped' => true, 'branch_scoped' => true,
            'search' => ['driver_code', 'name', 'phone', 'driving_license_number'],
            'columns' => ['driver_code' => 'Code', 'name' => 'Driver', 'phone' => 'Phone', 'employment_type' => 'Type', 'license_expiry' => 'Licence Expiry', 'is_active' => 'Active'],
            'fields' => [
                'branch_id' => ['label' => 'Branch', 'type' => 'relation', 'model' => Branch::class, 'option_label' => 'code_name', 'rules' => 'nullable|integer'],
                'party_id' => ['label' => 'Linked Party', 'type' => 'relation', 'model' => Party::class, 'option_label' => 'legal_name', 'rules' => 'nullable|integer'],
                'assigned_vehicle_id' => ['label' => 'Assigned Vehicle', 'type' => 'relation', 'model' => Vehicle::class, 'option_label' => 'plate_number', 'rules' => 'nullable|integer'],
                'driver_code' => ['label' => 'Driver Code', 'rules' => 'required|string|max:30', 'unique' => true],
                'name' => ['label' => 'Name', 'rules' => 'required|string|max:150'],
                'phone' => ['label' => 'Phone', 'rules' => 'nullable|string|max:50'],
                'email' => ['label' => 'Email', 'type' => 'email', 'rules' => 'nullable|email|max:150'],
                'employment_type' => ['label' => 'Employment Type', 'type' => 'select', 'options' => ['employee' => 'Employee', 'vendor' => 'Vendor Driver', 'contract' => 'Contract Driver'], 'rules' => 'required|string'],
                'driving_license_number' => ['label' => 'Driving Licence Number', 'rules' => 'nullable|string|max:100'],
                'license_expiry' => ['label' => 'Licence Expiry', 'type' => 'date', 'rules' => 'nullable|date'],
                'visa_expiry' => ['label' => 'Visa Expiry', 'type' => 'date', 'rules' => 'nullable|date'],
                'emirates_id_expiry' => ['label' => 'Emirates ID Expiry', 'type' => 'date', 'rules' => 'nullable|date'],
                'passport_expiry' => ['label' => 'Passport Expiry', 'type' => 'date', 'rules' => 'nullable|date'],
                'salary_or_rate' => ['label' => 'Salary / Agreed Rate', 'type' => 'number', 'step' => '0.01', 'rules' => 'nullable|numeric|min:0'],
                'per_trip_allowance' => ['label' => 'Per Trip Allowance', 'type' => 'number', 'step' => '0.01', 'rules' => 'nullable|numeric|min:0'],
                'notes' => ['label' => 'Notes', 'type' => 'textarea', 'rules' => 'nullable|string|max:3000'],
                'is_active' => ['label' => 'Active', 'type' => 'checkbox', 'rules' => 'boolean', 'default' => true],
            ],
        ],
        'contracts' => [
            'title' => 'Contracts & Agreements', 'singular' => 'Contract', 'model' => Contract::class,
            'permission' => 'contracts', 'company_scoped' => true, 'branch_scoped' => true,
            'search' => ['contract_number', 'title', 'contract_type', 'status'],
            'columns' => ['contract_number' => 'Contract No.', 'title' => 'Title', 'contract_type' => 'Type', 'start_date' => 'Start', 'end_date' => 'End', 'status' => 'Status'],
            'auto_number' => ['field' => 'contract_number', 'type' => 'CTR'],
            'fields' => [
                'branch_id' => ['label' => 'Branch', 'type' => 'relation', 'model' => Branch::class, 'option_label' => 'code_name', 'rules' => 'nullable|integer'],
                'party_id' => ['label' => 'Party', 'type' => 'relation', 'model' => Party::class, 'option_label' => 'legal_name', 'rules' => 'required|integer'],
                'contract_number' => ['label' => 'Contract Number', 'rules' => 'nullable|string|max:80'],
                'title' => ['label' => 'Contract Title', 'rules' => 'required|string|max:200'],
                'contract_type' => ['label' => 'Contract Type', 'type' => 'select', 'options' => ['customer_transport' => 'Customer Transport Agreement', 'vendor_subcontractor' => 'Vendor / Subcontractor Agreement', 'vehicle_lease' => 'Vehicle Lease Agreement', 'route_rate' => 'Route / Rate Agreement', 'annual_service' => 'Annual Service Agreement', 'driver' => 'Driver Agreement', 'general' => 'General Business Agreement'], 'rules' => 'required|string'],
                'start_date' => ['label' => 'Start Date', 'type' => 'date', 'rules' => 'required|date'],
                'end_date' => ['label' => 'End Date', 'type' => 'date', 'rules' => 'nullable|date|after_or_equal:start_date'],
                'notice_period_days' => ['label' => 'Notice Period (Days)', 'type' => 'number', 'rules' => 'nullable|integer|min:0'],
                'billing_cycle' => ['label' => 'Billing Cycle', 'type' => 'select', 'options' => ['per_trip' => 'Per Trip', 'weekly' => 'Weekly', 'monthly' => 'Monthly', 'quarterly' => 'Quarterly', 'annual' => 'Annual'], 'rules' => 'nullable|string'],
                'payment_terms_days' => ['label' => 'Payment Terms (Days)', 'type' => 'number', 'rules' => 'nullable|integer|min:0'],
                'credit_limit' => ['label' => 'Credit Limit', 'type' => 'number', 'step' => '0.01', 'rules' => 'nullable|numeric|min:0'],
                'currency_code' => ['label' => 'Currency', 'rules' => 'required|string|size:3', 'default' => 'AED'],
                'tax_code_id' => ['label' => 'Tax Code', 'type' => 'relation', 'model' => TaxCode::class, 'option_label' => 'code_name', 'rules' => 'nullable|integer'],
                'deposit_amount' => ['label' => 'Deposit', 'type' => 'number', 'step' => '0.01', 'rules' => 'nullable|numeric|min:0'],
                'retention_percentage' => ['label' => 'Retention %', 'type' => 'number', 'step' => '0.01', 'rules' => 'nullable|numeric|min:0|max:100'],
                'auto_renewal' => ['label' => 'Auto Renewal', 'type' => 'checkbox', 'rules' => 'boolean'],
                'status' => ['label' => 'Status', 'type' => 'select', 'options' => ['draft' => 'Draft', 'active' => 'Active', 'expired' => 'Expired', 'terminated' => 'Terminated'], 'rules' => 'required|string'],
                'terms' => ['label' => 'Terms & Conditions', 'type' => 'textarea', 'rules' => 'nullable|string'],
                'internal_notes' => ['label' => 'Internal Notes', 'type' => 'textarea', 'rules' => 'nullable|string'],
            ],
        ],
        'rate-cards' => [
            'title' => 'Rate Cards', 'singular' => 'Rate Card', 'model' => RateCard::class,
            'permission' => 'rate_cards', 'company_scoped' => true, 'branch_scoped' => false,
            'search' => ['rate_side', 'vehicle_type', 'charge_basis'],
            'columns' => ['rate_side' => 'Side', 'vehicle_type' => 'Vehicle Type', 'charge_basis' => 'Basis', 'rate' => 'Rate', 'effective_from' => 'Effective From', 'effective_to' => 'Effective To', 'is_active' => 'Active'],
            'fields' => [
                'contract_id' => ['label' => 'Contract', 'type' => 'relation', 'model' => Contract::class, 'option_label' => 'contract_number_title', 'rules' => 'nullable|integer'],
                'party_id' => ['label' => 'Party', 'type' => 'relation', 'model' => Party::class, 'option_label' => 'legal_name', 'rules' => 'required|integer'],
                'rate_side' => ['label' => 'Rate Side', 'type' => 'select', 'options' => ['customer' => 'Customer Rate', 'vendor' => 'Vendor Rate'], 'rules' => 'required|string'],
                'service_type_id' => ['label' => 'Service Type', 'type' => 'relation', 'model' => ServiceType::class, 'option_label' => 'code_name', 'rules' => 'nullable|integer'],
                'route_id' => ['label' => 'Route', 'type' => 'relation', 'model' => TransportRoute::class, 'option_label' => 'code_name', 'rules' => 'nullable|integer'],
                'vehicle_type' => ['label' => 'Vehicle Type', 'rules' => 'nullable|string|max:100'],
                'charge_basis' => ['label' => 'Charge Basis', 'type' => 'select', 'options' => ['trip' => 'Per Trip', 'hour' => 'Per Hour', 'day' => 'Per Day', 'week' => 'Per Week', 'month' => 'Per Month', 'km' => 'Per Kilometre', 'fixed' => 'Fixed Amount'], 'rules' => 'required|string'],
                'rate' => ['label' => 'Rate', 'type' => 'number', 'step' => '0.01', 'rules' => 'required|numeric|min:0'],
                'minimum_charge' => ['label' => 'Minimum Charge', 'type' => 'number', 'step' => '0.01', 'rules' => 'nullable|numeric|min:0'],
                'waiting_rate' => ['label' => 'Waiting Rate', 'type' => 'number', 'step' => '0.01', 'rules' => 'nullable|numeric|min:0'],
                'free_waiting_minutes' => ['label' => 'Free Waiting Minutes', 'type' => 'number', 'step' => '1', 'rules' => 'nullable|numeric|min:0'],
                'fuel_surcharge_percentage' => ['label' => 'Fuel Surcharge %', 'type' => 'number', 'step' => '0.01', 'rules' => 'nullable|numeric|min:0'],
                'additional_stop_rate' => ['label' => 'Additional Stop Rate', 'type' => 'number', 'step' => '0.01', 'rules' => 'nullable|numeric|min:0'],
                'effective_from' => ['label' => 'Effective From', 'type' => 'date', 'rules' => 'required|date'],
                'effective_to' => ['label' => 'Effective To', 'type' => 'date', 'rules' => 'nullable|date|after_or_equal:effective_from'],
                'is_active' => ['label' => 'Active', 'type' => 'checkbox', 'rules' => 'boolean', 'default' => true],
            ],
        ],
        'bank-accounts' => [
            'title' => 'Bank Accounts', 'singular' => 'Bank Account', 'model' => BankAccount::class,
            'permission' => 'bank_accounts', 'company_scoped' => true, 'branch_scoped' => true,
            'search' => ['bank_name', 'account_name', 'account_number', 'iban'],
            'columns' => ['bank_name' => 'Bank', 'account_name' => 'Account Name', 'account_number' => 'Account Number', 'iban' => 'IBAN', 'currency_code' => 'Currency', 'is_active' => 'Active'],
            'fields' => [
                'branch_id' => ['label' => 'Branch', 'type' => 'relation', 'model' => Branch::class, 'option_label' => 'code_name', 'rules' => 'nullable|integer'],
                'account_id' => ['label' => 'General Ledger Account', 'type' => 'relation', 'model' => Account::class, 'option_label' => 'code_name', 'rules' => 'required|integer'],
                'bank_name' => ['label' => 'Bank Name', 'rules' => 'required|string|max:150'],
                'account_name' => ['label' => 'Account Name', 'rules' => 'required|string|max:150'],
                'account_number' => ['label' => 'Account Number', 'rules' => 'required|string|max:100', 'unique' => true],
                'iban' => ['label' => 'IBAN', 'rules' => 'nullable|string|max:100'],
                'swift' => ['label' => 'SWIFT', 'rules' => 'nullable|string|max:50'],
                'currency_code' => ['label' => 'Currency', 'rules' => 'required|string|size:3', 'default' => 'AED'],
                'opening_balance' => ['label' => 'Opening Balance', 'type' => 'number', 'step' => '0.01', 'rules' => 'nullable|numeric'],
                'is_active' => ['label' => 'Active', 'type' => 'checkbox', 'rules' => 'boolean', 'default' => true],
            ],
        ],
        'maintenance' => [
            'title' => 'Vehicle Maintenance', 'singular' => 'Maintenance Order', 'model' => VehicleMaintenance::class,
            'permission' => 'vehicle_maintenance', 'company_scoped' => true, 'branch_scoped' => true,
            'search' => ['maintenance_number', 'maintenance_type', 'status', 'description'],
            'columns' => ['maintenance_number' => 'Order No.', 'maintenance_type' => 'Type', 'start_date' => 'Start', 'completion_date' => 'Completed', 'total_amount' => 'Total', 'status' => 'Status'],
            'auto_number' => ['field' => 'maintenance_number', 'type' => 'MNT'],
            'fields' => [
                'branch_id' => ['label' => 'Branch', 'type' => 'relation', 'model' => Branch::class, 'option_label' => 'code_name', 'rules' => 'nullable|integer'],
                'vehicle_id' => ['label' => 'Vehicle', 'type' => 'relation', 'model' => Vehicle::class, 'option_label' => 'plate_number', 'rules' => 'required|integer'],
                'vendor_id' => ['label' => 'Workshop / Vendor', 'type' => 'relation', 'model' => Party::class, 'option_label' => 'legal_name', 'rules' => 'nullable|integer'],
                'maintenance_number' => ['label' => 'Order Number', 'rules' => 'nullable|string|max:80'],
                'maintenance_type' => ['label' => 'Type', 'type' => 'select', 'options' => ['preventive' => 'Preventive Maintenance', 'repair' => 'Repair', 'inspection' => 'Inspection', 'tyres' => 'Tyres', 'other' => 'Other'], 'rules' => 'required|string'],
                'odometer' => ['label' => 'Odometer', 'type' => 'number', 'step' => '0.01', 'rules' => 'nullable|numeric|min:0'],
                'start_date' => ['label' => 'Start Date', 'type' => 'date', 'rules' => 'required|date'],
                'completion_date' => ['label' => 'Completion Date', 'type' => 'date', 'rules' => 'nullable|date|after_or_equal:start_date'],
                'next_service_date' => ['label' => 'Next Service Date', 'type' => 'date', 'rules' => 'nullable|date'],
                'next_service_odometer' => ['label' => 'Next Service Odometer', 'type' => 'number', 'step' => '0.01', 'rules' => 'nullable|numeric|min:0'],
                'parts_amount' => ['label' => 'Parts Amount', 'type' => 'number', 'step' => '0.01', 'rules' => 'nullable|numeric|min:0'],
                'labour_amount' => ['label' => 'Labour Amount', 'type' => 'number', 'step' => '0.01', 'rules' => 'nullable|numeric|min:0'],
                'vat_amount' => ['label' => 'VAT Amount', 'type' => 'number', 'step' => '0.01', 'rules' => 'nullable|numeric|min:0'],
                'total_amount' => ['label' => 'Total Amount', 'type' => 'number', 'step' => '0.01', 'rules' => 'required|numeric|min:0'],
                'status' => ['label' => 'Status', 'type' => 'select', 'options' => ['open' => 'Open', 'in_progress' => 'In Progress', 'completed' => 'Completed', 'cancelled' => 'Cancelled'], 'rules' => 'required|string'],
                'description' => ['label' => 'Description', 'type' => 'textarea', 'rules' => 'nullable|string'],
            ],
        ],
        'fuel' => [
            'title' => 'Fuel Entries', 'singular' => 'Fuel Entry', 'model' => FuelEntry::class,
            'permission' => 'fuel_entries', 'company_scoped' => true, 'branch_scoped' => true,
            'search' => ['payment_method', 'receipt_reference'],
            'columns' => ['entry_date' => 'Date', 'litres' => 'Litres', 'price_per_litre' => 'Price/Litre', 'total_amount' => 'Total', 'payment_method' => 'Payment Method', 'receipt_reference' => 'Receipt'],
            'fields' => [
                'branch_id' => ['label' => 'Branch', 'type' => 'relation', 'model' => Branch::class, 'option_label' => 'code_name', 'rules' => 'nullable|integer'],
                'vehicle_id' => ['label' => 'Vehicle', 'type' => 'relation', 'model' => Vehicle::class, 'option_label' => 'plate_number', 'rules' => 'required|integer'],
                'driver_id' => ['label' => 'Driver', 'type' => 'relation', 'model' => Driver::class, 'option_label' => 'name', 'rules' => 'nullable|integer'],
                'vendor_id' => ['label' => 'Fuel Station / Vendor', 'type' => 'relation', 'model' => Party::class, 'option_label' => 'legal_name', 'rules' => 'nullable|integer'],
                'trip_id' => ['label' => 'Trip', 'type' => 'relation', 'model' => Trip::class, 'option_label' => 'trip_number', 'rules' => 'nullable|integer'],
                'entry_date' => ['label' => 'Date', 'type' => 'date', 'rules' => 'required|date'],
                'odometer' => ['label' => 'Odometer', 'type' => 'number', 'step' => '0.01', 'rules' => 'nullable|numeric|min:0'],
                'litres' => ['label' => 'Litres', 'type' => 'number', 'step' => '0.0001', 'rules' => 'required|numeric|min:0.0001'],
                'price_per_litre' => ['label' => 'Price Per Litre', 'type' => 'number', 'step' => '0.0001', 'rules' => 'required|numeric|min:0'],
                'amount_before_vat' => ['label' => 'Amount Before VAT', 'type' => 'number', 'step' => '0.01', 'rules' => 'required|numeric|min:0'],
                'vat_amount' => ['label' => 'VAT Amount', 'type' => 'number', 'step' => '0.01', 'rules' => 'nullable|numeric|min:0'],
                'total_amount' => ['label' => 'Total Amount', 'type' => 'number', 'step' => '0.01', 'rules' => 'required|numeric|min:0'],
                'payment_method' => ['label' => 'Payment Method', 'type' => 'select', 'options' => ['cash' => 'Cash', 'bank' => 'Bank', 'card' => 'Card', 'fuel_card' => 'Fuel Card'], 'rules' => 'required|string'],
                'receipt_reference' => ['label' => 'Receipt Reference', 'rules' => 'nullable|string|max:150'],
            ],
        ],
    ],
];
