<?php

use Illuminate\Support\Facades\Route;
use App\Http\Controllers\MaintananceCOAController;
use App\Http\Controllers\CustomerCategoryController;
use App\Http\Controllers\SalesRepController;
use App\Http\Controllers\AreaController;
use App\Http\Controllers\AgeingController;
use App\Http\Controllers\AccountsController;
use App\Http\Controllers\SupplierCategoryController;
use App\Http\Controllers\SupplierAccountsController;
use App\Http\Controllers\TaxController;
use App\Http\Controllers\HomeCurrencyController;
use App\Http\Controllers\DailyRateController;
use App\Http\Controllers\ForeignCurrencyController;
use App\Http\Controllers\ProjectController;
use App\Http\Controllers\WarehouseController;
use App\Http\Controllers\InventoryCategoryController;
use App\Http\Controllers\BinLocationController;
use App\Http\Controllers\PriceListNameController;
use App\Http\Controllers\PriceListingController;
use App\Http\Controllers\PriceListingSetupController;
use App\Http\Controllers\UomCategoryController;
use App\Http\Controllers\UomController;
use App\Http\Controllers\UomConversionController;
use App\Http\Controllers\TransactionTypeController;
use App\Http\Controllers\CustomerTransactionController;
use App\Http\Controllers\SupplierTransactionController;
use App\Http\Controllers\InventoryTransactionController;
use App\Http\Controllers\DocumentController;
use App\Http\Controllers\StatementsController;
use App\Http\Controllers\SupplierDocumentController;
use App\Http\Controllers\SupplierJournalController;
use App\Http\Controllers\CustomerJournalController;
use App\Http\Controllers\GeneralJournalController;
use App\Http\Controllers\CashbookController;
use App\Http\Controllers\InventoryJournalController;
use App\Http\Controllers\CashbookEntryController;
use App\Http\Controllers\TaxReportController;
use App\Http\Controllers\CustomerListingReportController;
use App\Http\Controllers\CustomerStatementReportController;
use App\Http\Controllers\CustomerDailyTransactionController;
use App\Http\Controllers\OutstandingSalesReportController;
use App\Http\Controllers\InvoiceReportController;
use App\Http\Controllers\SupplierListingReportController;
use App\Http\Controllers\SalesCollectionReportController;
use App\Http\Controllers\SupplierStatementReportController;
use App\Http\Controllers\SupplierDailyTransactionController;
use App\Http\Controllers\SupplierPaymentsReportController;
use App\Http\Controllers\DocumentReprintController;
use App\Http\Controllers\OutstandingPaymentsReportController;
use App\Http\Controllers\SupplierInvoiceReportController;
use App\Http\Controllers\SupplierDocumentReprintController;
use App\Http\Controllers\GlTransactionController;
use App\Http\Controllers\CashbookDailyTransactionController;
use App\Http\Controllers\ProjectReportController;
use App\Http\Controllers\InventoryStockLevelController;
use App\Http\Controllers\InventoryMovementReportController;
use App\Http\Controllers\WarehouseTransferReportController;
use App\Http\Controllers\StockValuationController;
use App\Http\Controllers\SalesAnalysisController;
use App\Http\Controllers\UserController;
use App\Http\Controllers\PermissionController;
use App\Http\Controllers\RoleController;
use App\Http\Controllers\GroupController;
use App\Http\Controllers\CompanySettingsController;
use App\Http\Controllers\SupplierAgeingController;
use App\Http\Controllers\HomeController;
use App\Http\Controllers\StockManagementReportController;
use App\Http\Controllers\ChartOfAccounts\GeneralLedgerController as CoaGeneralLedgerController;
use App\Http\Controllers\ChartOfAccounts\MainSubAccountController as CoaMainSubAccountController;
use App\Http\Controllers\ChartOfAccounts\SubAccountController as CoaSubAccountController;
use App\Http\Controllers\ChartOfAccounts\AccountTypeController as CoaAccountTypeController;
use App\Http\Controllers\ChartOfAccounts\SubAccountLevelController as CoaSubAccountLevelController;
use App\Http\Controllers\MasterFileDashboardController;
use App\Http\Controllers\Processing\CustomerProcessingController;
use App\Http\Controllers\Processing\SupplierProcessingController;
use App\Http\Controllers\Processing\DocumentLinkingController;
use App\Http\Controllers\Api\GlAccountPickerController;
use App\Http\Controllers\Api\InvoiceLookupController;
use App\Http\Controllers\DocumentPdfController;
use App\Http\Controllers\Reports\IncomeStatementController;
use App\Http\Controllers\Reports\BalanceSheetController;
use App\Http\Controllers\QuantaIndexController;
use App\Http\Controllers\ProfileController;
use Illuminate\Support\Facades\Auth;
/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider and all of them will
| be assigned to the "web" middleware group. Make something great!
|
*/

Route::get('/', function () {
    return view('auth.login');
});

Route::get('/privacy', fn() => view('legal.privacy'))->name('privacy');
Route::get('/terms', fn() => view('legal.terms'))->name('terms');

Auth::routes();

Route::middleware(['auth', 'SessionTimeout'])->group(function () {
Route::get('/home', [HomeController::class, 'index'])->name('home');

// User Profile Routes
Route::get('/profile', [ProfileController::class, 'show'])->name('profile.show');
Route::put('/profile', [ProfileController::class, 'update'])->name('profile.update');
Route::post('/profile/photo', [ProfileController::class, 'uploadPhoto'])->name('profile.photo');
Route::post('/profile/logout-all', [ProfileController::class, 'logoutAll'])->name('profile.logout-all');

Route::get('/master-files', [MasterFileDashboardController::class, 'index'])->name('master-files.dashboard');
foreach (QuantaIndexController::pageRoutes() as $page => $routeName) {
    Route::get("/{$page}/index", [QuantaIndexController::class, 'index'])
        ->defaults('page', $page)
        ->name($routeName);
}
Route::delete('/quanta-index/{page}/{id}', [QuantaIndexController::class, 'destroy'])->name('quanta-index.destroy');
Route::get('/session-expired', function (\Illuminate\Http\Request $request) {
    Auth::logout();
    $request->session()->invalidate();
    $request->session()->regenerateToken();

    return redirect()->route('login')->withErrors([
        'email' => 'Your session has expired due to inactivity. Please log in again.',
    ]);
})->name('session.expired');

//=============Edit==============

// --Users-- routes using resource
Route::resource('users', UserController::class);

// Password change routes remain separate
Route::get('/users/change-password/{id}', [UserController::class, 'changePasswordForm'])->name('users.change-password-form');
Route::post('/users/change-password/{id}', [UserController::class, 'changePassword'])->name('users.change-password');
//Permissions routes
Route::resource('permissions', PermissionController::class);

// Extra route for permission assignment
Route::get('/users/{user}/permissions', [UserController::class, 'editPermissions'])->name('users.permissions.edit');
Route::post('/users/{user}/permissions', [UserController::class, 'updatePermissions'])->name('users.permissions.update');
Route::post('/users/{user}/permissions', [UserController::class, 'savePermissions'])->name('users.permissions.store');
Route::get('users/permissions/{id}', [UserController::class, 'addPermissions'])->name('user-permissions.addPermissions');
Route::post('users/permissions/{id}', [UserController::class, 'savePermissions'])->name('user-permissions.savePermissions');

//Roles routes
Route::resource('roles', RoleController::class);

//groups routes
Route::resource('groups', GroupController::class);

//==Chart_of_accounts==
// Account Types Module
Route::get('/account-types', [MaintananceCOAController::class, 'create_account_type'])->name('account_types.create');
Route::post('/account-types/store', [MaintananceCOAController::class, 'store_account_type'])->name('account_types.store');
Route::post('/account-types/edit', [MaintananceCOAController::class, 'edit_account_type'])->name('account_types.edit');
Route::get('/account-types/delete/{id}', [MaintananceCOAController::class, 'delete_account_type'])->name('account_types.delete');

// departments
Route::get('/departments', [MaintananceCOAController::class, 'create_dept'])->name('departments.create');
Route::post('/store/departments', [MaintananceCOAController::class, 'store_dept'])->name('departments.store');
Route::post('/edit/departments', [MaintananceCOAController::class, 'edit_dept'])->name('departments.edit');
Route::get('/delete/departments/{id}', [MaintananceCOAController::class, 'delete_dept'])->name('departments.delete');

// General Ledger Routes
Route::get('/ledger', [MaintananceCOAController::class, 'createGL'])->name('ledger.create');
Route::post('/store/ledger', [MaintananceCOAController::class, 'storeGL'])->name('ledger.store');
Route::post('/EditMainAccounts', [MaintananceCOAController::class, 'editMainAccount'])->name('editMainAccount');
Route::delete('/ledger/delete/{id}', [MaintananceCOAController::class, 'deleteMainAccount'])->name('deleteMainAccount');

//subaccount
Route::get('/subacc/{id}', [MaintananceCOAController::class, 'addSubAccount'])->name('subacc.add');
Route::post('/store/subaccount', [MaintananceCOAController::class, 'storeSubAccount'])->name('subacc.store');
Route::post('/EditSubAccount', [MaintananceCOAController::class, 'editSubAccount'])->name('editSubAccount');
Route::get('/DeleteSubAccount/{table}/{id}', [MaintananceCOAController::class, 'deleteSubAccount'])->name('subaccount.delete');

// New Chart of Accounts index pages (nested navigation)
Route::prefix('chart-of-accounts')->name('chart-of-accounts.')->group(function () {
    Route::get('/account-types', [CoaAccountTypeController::class, 'index'])->name('account-types.index');
    Route::delete('/account-types/{accountType}', [CoaAccountTypeController::class, 'destroy'])->name('account-types.destroy');

    Route::get('/general-ledger', [CoaGeneralLedgerController::class, 'index'])->name('general-ledger.index');
    Route::delete('/general-ledger/{generalLedger}', [CoaGeneralLedgerController::class, 'destroy'])->name('general-ledger.destroy');

    // RETIRED: main_sub_accounts removed from hierarchy
    // Route::get('/general-ledger/{generalLedger}/main-sub-accounts', [CoaMainSubAccountController::class, 'index'])
    //     ->name('general-ledger.main-sub-accounts.index');
    // Route::delete('/general-ledger/{generalLedger}/main-sub-accounts/{mainSubAccount}', [CoaMainSubAccountController::class, 'destroy'])
    //     ->name('general-ledger.main-sub-accounts.destroy');

    // Route::get('/main-sub-accounts/{mainSubAccount}/sub-accounts', [CoaSubAccountController::class, 'index'])
    //     ->name('main-sub-accounts.sub-accounts.index');
    // Route::delete('/main-sub-accounts/{mainSubAccount}/sub-accounts/{subAccount}', [CoaSubAccountController::class, 'destroy'])
    //     ->name('main-sub-accounts.sub-accounts.destroy');

    Route::get('/main-accounts/{mainAccount}/sub-accounts', [CoaSubAccountController::class, 'index'])
        ->name('main-accounts.sub-accounts.index');
    Route::delete('/sub-accounts/{table}/{id}', [CoaSubAccountController::class, 'destroy'])
        ->name('main-accounts.sub-accounts.destroy');

    Route::get('/sub-accounts/level/{level}/{parentId}/children', [CoaSubAccountLevelController::class, 'index'])
        ->name('sub-accounts.level.index');
    Route::delete('/sub-accounts/level/{level}/{parentId}/children/{childId}', [CoaSubAccountLevelController::class, 'destroy'])
        ->name('sub-accounts.level.destroy');
});

// Cashbook Entries
Route::get('/cashbook-entries', [CashbookEntryController::class, 'createCashbook'])->name('cashbook.entries.create');
Route::post('/cashbook-entries/store', [CashbookEntryController::class, 'storeCashbook'])->name('cashbook.entries.store');
Route::post('/cashbook-entries/edit', [CashbookEntryController::class, 'editCashbook'])->name('cashbook.entries.edit');
Route::get('/cashbook-entries/delete/{id}', [CashbookEntryController::class, 'deleteCashbook'])->name('cashbook.entries.delete');

//==Transaction==

// Transaction Types Routes
Route::controller(TransactionTypeController::class)->prefix('transactionTypes')->group(function () {
    Route::get('/', 'index')->name('transactionTypes.index');
    Route::post('/store', 'store')->name('transactionTypes.store');
    Route::get('/edit/{id}', 'edit')->name('transactionTypes.edit');
    Route::put('/update/{id}', 'update')->name('transactionTypes.update');
    Route::delete('/delete/{id}', 'destroy')->name('transactionTypes.destroy');
});

// Customer Transaction Routes
Route::controller(CustomerTransactionController::class)->prefix('customer-transactions')->group(function () {
    Route::get('/', 'index')->name('customerTransactions.index');
    Route::get('/create/{type}', 'create')->name('customerTransactions.create');
    Route::post('/store', 'store')->name('customerTransactions.store');
    Route::get('/edit/{id}', 'edit')->name('customerTransactions.edit');
    Route::put('/update/{id}', 'update')->name('customerTransactions.update');
    Route::delete('/delete/{id}', 'destroy')->name('customerTransactions.destroy');
});

// Supplier Transaction Routes
Route::controller(SupplierTransactionController::class)->prefix('supplier-transactions')->group(function () {
    Route::get('/', 'index')->name('supplierTransactions.index');
    Route::get('/create/{type}', 'create')->name('supplierTransactions.create');
    Route::post('/store', 'store')->name('supplierTransactions.store');
    Route::get('/edit/{id}', 'edit')->name('supplierTransactions.edit');
    Route::put('/update/{id}', 'update')->name('supplierTransactions.update');
    Route::delete('/delete/{id}', 'destroy')->name('supplierTransactions.destroy');
});

// Inventory Transaction Routes
Route::controller(InventoryTransactionController::class)->prefix('inventory-transactions')->group(function () {
    Route::get('/', 'index')->name('inventoryTransactions.index');
    Route::get('/create/{type}', 'create')->name('inventoryTransactions.create');
    Route::post('/store', 'store')->name('inventoryTransactions.store');
    Route::get('/edit/{id}', 'edit')->name('inventoryTransactions.edit');
    Route::put('/update/{id}', 'update')->name('inventoryTransactions.update');
    Route::delete('/delete/{id}', 'destroy')->name('inventoryTransactions.destroy');
});
//==Tax==

Route::get('/tax', [TaxController::class, 'createTax'])->name('tax.create');
Route::post('/store/tax', [TaxController::class, 'storeTax'])->name('tax.store');
Route::post('/tax/edit', [TaxController::class, 'editTax'])->name('tax.edit');
Route::get('/tax/delete/{id}', [TaxController::class, 'deleteTax'])->name('tax.delete');

//==Multicurrency
// Currencies Module
Route::get('/currency', [MaintananceCOAController::class, 'createCurrency'])->name('currency.create');
Route::post('/currency/store', [MaintananceCOAController::class, 'storeCurrency'])->name('currency.store');
Route::post('/currency/edit', [MaintananceCOAController::class, 'editCurrency'])->name('currency.edit');
Route::get('/currency/delete/{id}', [MaintananceCOAController::class, 'deleteCurrency'])->name('currency.delete');

//home currency
Route::get('/home_currency', [HomeCurrencyController::class, 'create'])->name('home_currency.create');
Route::post('/home_currency/store', [HomeCurrencyController::class, 'store'])->name('home_currency.store');
Route::post('/home_currency/edit', [HomeCurrencyController::class, 'edit'])->name('home_currency.edit');
Route::get('/home_currency/delete/{id}', [HomeCurrencyController::class, 'delete'])->name('home_currency.delete');

// DailyRates routes:
Route::get('/daily-rates', [DailyRateController::class, 'create_rate'])->name('daily_rates.create');
Route::post('/daily-rates/store', [DailyRateController::class, 'store_rate'])->name('daily_rates.store');
Route::post('/daily-rates/edit', [DailyRateController::class, 'edit_rate'])->name('daily_rates.edit');
Route::get('/daily-rates/delete/{id}', [DailyRateController::class, 'delete_rate'])->name('daily_rates.delete');


//==CUSTOMERS==
// Customer Accounts Module
Route::get('/customer/accounts', [AccountsController::class, 'create_customer_account'])->name('customer.accounts.create');
Route::post('/customer/accounts/store', [AccountsController::class, 'store_customer_account'])->name('customer.accounts.store');
Route::post('/customer/accounts/edit', [AccountsController::class, 'edit_customer_account'])->name('customer.accounts.edit');
Route::get('/customer/accounts/delete/{id}', [AccountsController::class, 'delete_customer_account'])->name('customer.accounts.delete');
Route::get('/get-ageing-terms/{id}', [AccountsController::class, 'get_ageing_terms'])->name('get.ageing.terms');

// Customer Categories Module
Route::get('/customer/categories', [CustomerCategoryController::class, 'create_customer_category'])->name('customer.categories.create');
Route::post('/customer/categories/store', [CustomerCategoryController::class, 'store_customer_category'])->name('customer.categories.store');
Route::post('/customer/categories/edit', [CustomerCategoryController::class, 'edit_customer_category'])->name('customer.categories.edit');
Route::get('/customer/categories/delete/{id}', [CustomerCategoryController::class, 'delete_customer_category'])->name('customer.categories.delete');

// Sales Representatives Module
Route::get('/sales-reps', [SalesRepController::class, 'create_sales_rep'])->name('sales.reps.create');
Route::post('/sales-reps/store', [SalesRepController::class, 'store_sales_rep'])->name('sales.reps.store');
Route::post('/sales-reps/edit', [SalesRepController::class, 'edit_sales_rep'])->name('sales.reps.edit');
Route::get('/sales-reps/delete/{id}', [SalesRepController::class, 'delete_sales_rep'])->name('sales.reps.delete');

// Areas Module
Route::get('/areas', [AreaController::class, 'create_area'])->name('areas.create');
Route::post('/areas/store', [AreaController::class, 'store_area'])->name('areas.store');
Route::post('/areas/edit', [AreaController::class, 'edit_area'])->name('areas.edit');
Route::get('/areas/delete/{id}', [AreaController::class, 'delete_area'])->name('areas.delete');

// Customer Ageing Routes
Route::get('/customer_ageing', [AgeingController::class, 'index'])->name('customer_ageing.index');
Route::post('/customer_ageing/store', [AgeingController::class, 'store'])->name('customer_ageing.store');
Route::get('/customer_ageing/edit/{id}', [AgeingController::class, 'edit'])->name('customer_ageing.edit.data');
Route::post('/customer_ageing/update', [AgeingController::class, 'update'])->name('customer_ageing.update');
Route::get('/customer_ageing/delete/{id}', [AgeingController::class, 'destroy'])->name('customer_ageing.delete');

//==SUPPLIERS==

// Supplier Accounts Module
Route::get('/supplier/accounts', [SupplierAccountsController::class, 'create_supplier_account'])->name('supplier.accounts.create');
Route::post('/supplier/accounts/store', [SupplierAccountsController::class, 'store_supplier_account'])->name('supplier.accounts.store');
Route::post('/supplier/accounts/edit', [SupplierAccountsController::class, 'edit_supplier_account'])->name('supplier.accounts.edit');
Route::get('/supplier/accounts/delete/{id}', [SupplierAccountsController::class, 'delete_supplier_account'])->name('supplier.accounts.delete');

/// Supplier Categories Module
Route::get('/supplier/categories', [SupplierCategoryController::class, 'create_supplier_category'])->name('supplier.categories.create');
Route::post('/supplier/categories/store', [SupplierCategoryController::class, 'store_supplier_category'])->name('supplier.categories.store');
Route::post('/supplier/categories/edit', [SupplierCategoryController::class, 'edit_supplier_category'])->name('supplier.categories.edit');
Route::get('/supplier/categories/delete/{id}', [SupplierCategoryController::class, 'delete_supplier_category'])->name('supplier.categories.delete');

// Areas Module (for Suppliers)
Route::get('/supplier/areas', [SupplierCategoryController::class, 'create_area'])->name('supplier.areas.create');
Route::post('/supplier/areas/store', [SupplierCategoryController::class, 'store_area'])->name('supplier.areas.store');
Route::post('/supplier/areas/edit', [SupplierCategoryController::class, 'edit_area'])->name('supplier.areas.edit');
Route::get('/supplier/areas/delete/{id}', [SupplierCategoryController::class, 'delete_area'])->name('supplier.areas.delete');

// Supplier Ageing Routes
Route::get('/supplier_ageing', [SupplierAgeingController::class, 'index'])->name('supplier_ageing.index');
Route::post('/supplier_ageing/store', [SupplierAgeingController::class, 'store'])->name('supplier_ageing.store');
Route::get('/supplier_ageing/edit/{id}', [SupplierAgeingController::class, 'edit'])->name('supplier_ageing.edit.data');
Route::post('/supplier_ageing/update', [SupplierAgeingController::class, 'update'])->name('supplier_ageing.update');
Route::get('/supplier_ageing/delete/{id}', [SupplierAgeingController::class, 'destroy'])->name('supplier_ageing.delete');


//==PROJECTS==

// Projects routes
Route::get('/projects', [ProjectController::class, 'create_project'])->name('projects.create');
Route::post('/projects/store', [ProjectController::class, 'store_project'])->name('projects.store');
Route::post('/projects/edit', [ProjectController::class, 'edit_project'])->name('projects.edit');
Route::get('/projects/delete/{id}', [ProjectController::class, 'delete_project'])->name('projects.delete');


//==INVENTORY==

// Warehouses
Route::get('/supplier/warehouses', [WarehouseController::class, 'create_warehouse'])->name('supplier.warehouses.create');
Route::post('/supplier/warehouses/store', [WarehouseController::class, 'store_warehouse'])->name('supplier.warehouses.store');
Route::post('/supplier/warehouses/edit', [WarehouseController::class, 'edit_warehouse'])->name('supplier.warehouses.edit');
Route::get('/supplier/warehouses/delete/{id}', [WarehouseController::class, 'delete_warehouse'])->name('supplier.warehouses.delete');

// Categories
Route::get('inventory-categories', [InventoryCategoryController::class, 'create_inventory_category'])->name('supplier.inventory_categories.create');
Route::post('inventory-categories/store', [InventoryCategoryController::class, 'store_inventory_category'])->name('supplier.inventory_categories.store');
Route::post('inventory-categories/edit', [InventoryCategoryController::class, 'edit_inventory_category'])->name('supplier.inventory_categories.edit');
Route::get('inventory-categories/delete/{id}', [InventoryCategoryController::class, 'delete_inventory_category'])->name('supplier.inventory_categories.delete');

// Bin Locations
Route::get('bin-locations', [BinLocationController::class, 'create_bin_location'])->name('supplier.bin_locations.create');
Route::post('bin-locations/store', [BinLocationController::class, 'store_bin_location'])->name('supplier.bin_locations.store');
Route::post('bin-locations/edit', [BinLocationController::class, 'edit_bin_location'])->name('supplier.bin_locations.edit');
Route::get('bin-locations/delete/{id}', [BinLocationController::class, 'delete_bin_location'])->name('supplier.bin_locations.delete');

// Price List Names
Route::get('price-list-names', [PriceListNameController::class, 'create_price_list_name'])->name('supplier.price_list_names.create');
Route::post('price-list-names/store', [PriceListNameController::class, 'store_price_list_name'])->name('supplier.price_list_names.store');
Route::post('price-list-names/edit', [PriceListNameController::class, 'edit_price_list_name'])->name('supplier.price_list_names.edit');
Route::get('price-list-names/delete/{id}', [PriceListNameController::class, 'delete_price_list_name'])->name('supplier.price_list_names.delete');

// Price Listing
Route::get('price-listings', [PriceListingController::class, 'create_price_listing'])->name('supplier.price_listings.create');
Route::post('price-listings/store', [PriceListingController::class, 'store_price_listing'])->name('supplier.price_listings.store');
Route::post('price-listings/edit', [PriceListingController::class, 'edit_price_listing'])->name('supplier.price_listings.edit');
Route::get('price-listings/delete/{id}', [PriceListingController::class, 'delete_price_listing'])->name('supplier.price_listings.delete');

// Item Types
// Listing & form
Route::get('item-types', [PriceListingSetupController::class, 'index'])->name('supplier.item_types.index');
Route::post('item-types/store', [PriceListingSetupController::class, 'store'])->name('supplier.item_types.store');
Route::post('item-types/edit', [PriceListingSetupController::class, 'update'])->name('supplier.item_types.edit');
Route::get('item-types/delete/{id}', [PriceListingSetupController::class, 'destroy'])->name('supplier.item_types.delete');
Route::get('/supplier/item-types/{id}/warehouse-quantities',
    [PriceListingSetupController::class, 'getWarehouseQuantities']
);

// Sub-pages: Pricing, Warehouse, Images
Route::get('item-types/{id}/pricing', [PriceListingSetupController::class, 'pricing'])->name('supplier.item_types.pricing');

Route::get('item-types/{id}/warehouse', [PriceListingSetupController::class, 'warehouse'])->name('supplier.item_types.warehouse');

Route::get('item-types/{id}/images', [PriceListingSetupController::class, 'images'])->name('supplier.item_types.images');

Route::get('item-types/{id}/iinformation', [PriceListingSetupController::class, 'images'])->name('supplier.item_types.information');

// UOM Categories
Route::get('uom-categories', [UomCategoryController::class, 'create'])->name('uom_categories.create');
Route::post('uom-categories/store', [UomCategoryController::class, 'store'])->name('uom_categories.store');
Route::post('uom-categories/edit', [UomCategoryController::class, 'edit'])->name('uom_categories.edit');
Route::get('uom-categories/delete/{id}', [UomCategoryController::class, 'delete'])->name('uom_categories.delete');


// ... existing UOM routes ...
Route::get('uoms', [UomController::class, 'index'])->name('uoms.index');
Route::post('uoms/store', [UomController::class, 'store'])->name('uoms.store');
Route::post('uoms/edit', [UomController::class, 'edit'])->name('uoms.edit');
Route::get('uoms/delete/{id}', [UomController::class, 'delete'])->name('uoms.delete');


// UOM Conversions
Route::get('uom-conversions', [UomConversionController::class, 'index'])->name('uom_conversions.index');
Route::post('uom-conversions/store', [UomConversionController::class, 'store'])->name('uom_conversions.store');
Route::post('uom-conversions/edit', [UomConversionController::class, 'edit'])->name('uom_conversions.edit');
Route::get('uom-conversions/delete/{id}', [UomConversionController::class, 'delete'])->name('uom_conversions.delete');


//======================= Process ==============================
Route::prefix('processing')->name('processing.')->group(function () {
    Route::get('/customers', [CustomerProcessingController::class, 'index'])->name('customers.index');
    Route::get('/customers/{customer}', [CustomerProcessingController::class, 'show'])->name('customers.show');

    Route::get('/suppliers', [SupplierProcessingController::class, 'index'])->name('suppliers.index');

    Route::post('/documents/{document}/convert/{targetType}', [DocumentLinkingController::class, 'convert'])
        ->name('documents.convert');
});

Route::get('/api/gl-accounts/{glId}/pickable-accounts', [GlAccountPickerController::class, 'show'])
    ->middleware(['auth', 'SessionTimeout'])
    ->name('api.gl-accounts.pickable');
Route::get('/api/invoices/search', [InvoiceLookupController::class, 'search'])
    ->middleware(['auth', 'SessionTimeout'])
    ->name('api.invoices.search');
Route::get('/api/invoices/{invoice}', [InvoiceLookupController::class, 'show'])
    ->middleware(['auth', 'SessionTimeout'])
    ->name('api.invoices.show');

Route::get('/documents/{type}/{id}/pdf', [DocumentPdfController::class, 'download'])
    ->middleware(['auth', 'SessionTimeout'])
    ->name('documents.download-pdf');

// Financial report routes
Route::get('/reports/income-statement', [IncomeStatementController::class, 'index'])
    ->middleware(['auth', 'SessionTimeout'])
    ->name('reports.income-statement');
Route::get('/reports/balance-sheet', [BalanceSheetController::class, 'index'])
    ->middleware(['auth', 'SessionTimeout'])
    ->name('reports.balance-sheet');


Route::prefix('documents')->group(function () {
    Route::get('{type}/create', [DocumentController::class, 'create'])->name('documents.create');
    Route::post('{type}', [DocumentController::class, 'store'])->name('documents.store');
    Route::get('{document}/edit', [DocumentController::class, 'edit'])->name('documents.edit');
    Route::get('{document}/process', [DocumentController::class, 'process'])->name('documents.process');
    Route::get('{document}/delivery-note', [DocumentController::class, 'deliveryNote'])->name('documents.delivery-note');
    Route::get('{document}/invoice', [DocumentController::class, 'invoice'])->name('documents.invoice');
    Route::get('{document}/pdf', [DocumentController::class, 'pdf'])->name('documents.pdf'); // ✅ NEW route for documents/pdf.blade.php
    Route::post('settings/update', [DocumentController::class, 'updateDocumentSettings'])->name('settings.update-document');
    
    // Document linking & conversion routes
    Route::get('{document}/convert-to-invoice', [DocumentController::class, 'convertToInvoice'])->name('documents.convert-to-invoice');
    Route::get('{document}/convert-to-sales-order', [DocumentController::class, 'convertToSalesOrder'])->name('documents.convert-to-sales-order');
    Route::get('{document}/convert-to-invoice-from-sales-order', [DocumentController::class, 'convertToInvoiceFromSalesOrder'])->name('documents.convert-to-invoice-from-sales-order');
    Route::get('{document}/apply-credit-note', [DocumentController::class, 'applyCreditNoteForm'])->name('documents.apply-credit-note-form');
    Route::post('{document}/apply-credit-note', [DocumentController::class, 'applyCreditNoteSubmit'])->name('documents.apply-credit-note-submit');
});

Route::prefix('customer')->group(function () {
    Route::get('quotation', [DocumentController::class, 'create'])->name('customer.quotation')->defaults('type', 'quotation');
    Route::get('sales-order', [DocumentController::class, 'create'])->name('customer.sales-order')->defaults('type', 'sales_order');
    Route::get('invoice', [DocumentController::class, 'create'])->name('customer.invoice')->defaults('type', 'invoice');
    Route::get('credit-note', [DocumentController::class, 'create'])->name('customer.credit-note')->defaults('type', 'credit_note');
    Route::get('debit-note', [DocumentController::class, 'create'])->name('customer.debit-note')->defaults('type', 'debit_note');
    // Route::get('receipt', [DocumentController::class, 'create'])->name('customer.receipt')->defaults('type', 'receipt');
    Route::get('/documents/{document}/delivery-note-preview', [DocumentController::class, 'deliveryNotePreview'])->name('documents.delivery-note-preview');
    Route::get('/documents/{document}/invoice-preview', [DocumentController::class, 'invoicePreview'])->name('documents.invoice-preview');

});

// Receipt routes
Route::prefix('receipts')->group(function () {
    Route::get('create', [DocumentController::class, 'createReceipt'])->name('receipts.create');
    Route::post('', [DocumentController::class, 'storeReceipt'])->name('receipts.store');
    Route::get('{receipt}/pdf', [DocumentController::class, 'receiptPdf'])->name('receipts.pdf');
    Route::get('{receipt}/link-invoice', [DocumentController::class, 'linkInvoiceForm'])->name('receipts.link-invoice-form');
    Route::post('{receipt}/link-invoice', [DocumentController::class, 'linkInvoiceSubmit'])->name('receipts.link-invoice-submit');
});

// API route for customer invoices
Route::get('/api/customers/{customer}/invoices', [DocumentController::class, 'customerInvoices']);

// Document settings update
Route::post('/settings/update-document', [DocumentController::class, 'updateDocumentSettings'])
    ->name('settings.update-document');



// Supplier Documents Routes
Route::prefix('supplier-documents')->group(function () {
    Route::get('{type}/create', [SupplierDocumentController::class, 'create'])->name('supplier.documents.create');
    Route::post('{type}', [SupplierDocumentController::class, 'store'])->name('supplier.documents.store');
    Route::get('{document}/delivery-note', [SupplierDocumentController::class, 'deliveryNote'])->name('supplier.documents.delivery-note');
    Route::get('{document}/invoice', [SupplierDocumentController::class, 'invoice'])->name('supplier.documents.invoice');
    Route::get('{document}/pdf', [SupplierDocumentController::class, 'pdf'])->name('supplier.documents.pdf');
    Route::post('settings/update', [SupplierDocumentController::class, 'updateDocumentSettings'])->name('supplier.settings.update-document');

    // Added API route for item availability
    Route::get('/api/item-availability', [SupplierDocumentController::class, 'getItemAvailability'])->name('supplier.documents.api.item-availability');

    // Warehouse Transfer Specific Actions (POST, GET inventory levels)
    Route::get('warehouse/transfer', [SupplierDocumentController::class, 'warehouseTransfer'])->name('warehouse.transfer');
    Route::post('warehouse/transfer', [SupplierDocumentController::class, 'storeWarehouseTransfer'])->name('warehouse.transfer.store');
    Route::get('/warehouse/available/{itemId}/{fromWarehouseId}/{toWarehouseId}', [WarehouseController::class, 'available']);
    
    // Supplier Document linking & conversion routes
    Route::get('{document}/convert-to-grv', [SupplierDocumentController::class, 'convertToGrv'])->name('supplier.documents.convert-to-grv');
    Route::get('{document}/convert-to-supplier-invoice', [SupplierDocumentController::class, 'convertToSupplierInvoice'])->name('supplier.documents.convert-to-supplier-invoice');
    Route::get('{document}/convert-to-supplier-invoice-from-grv', [SupplierDocumentController::class, 'convertToSupplierInvoiceFromGrv'])->name('supplier.documents.convert-to-supplier-invoice-from-grv');
    Route::get('{document}/apply-credit-note', [SupplierDocumentController::class, 'applyCreditNoteForm'])->name('supplier.documents.apply-credit-note-form');
    Route::post('{document}/apply-credit-note', [SupplierDocumentController::class, 'applyCreditNoteSubmit'])->name('supplier.documents.apply-credit-note-submit');
});


// Supplier Document Types Shortcuts
Route::prefix('supplier')->group(function () {
    Route::get('purchase-order', [SupplierDocumentController::class, 'create'])->name('supplier.purchase-order')->defaults('type', 'purchase_order');
    Route::get('goods-received', [SupplierDocumentController::class, 'create'])->name('supplier.goods-received')->defaults('type', 'goods_received');
    Route::get('sales-invoice', [SupplierDocumentController::class, 'create'])->name('supplier.sales-invoice')->defaults('type', 'sales_invoice');
    Route::get('returns-debit', [SupplierDocumentController::class, 'create'])->name('supplier.returns-debit')->defaults('type', 'returns_debit');
    Route::get('credit-supplier', [SupplierDocumentController::class, 'create'])->name('supplier.credit-supplier')->defaults('type', 'credit_supplier');
    Route::get('warehouse-transfer', [SupplierDocumentController::class, 'create'])->name('supplier.warehouse-transfer')->defaults('type', 'warehouse_transfer');
});

//ChartOfAccountsReport
Route::get('/ChartOfAccountsReport', [StatementsController::class, 'PrintChartOfAccounts'])->name('ChartOfAccountsReport');
Route::post('/ChartOfAccountsReport', [StatementsController::class, 'fetchAccountsByType'])->name('fetchChartOfAccounts');


// Supplier Journal Routes
Route::get('/supplier-journal', [SupplierJournalController::class, 'index'])->name('supplier.journal.index');
Route::post('/supplier-journal/store', [SupplierJournalController::class, 'store'])->name('supplier.journal.store');
Route::post('/supplier-journal/update', [SupplierJournalController::class, 'update'])->name('supplier.journal.update');
Route::post('/supplier-journal/process', [SupplierJournalController::class, 'process'])->name('supplier.journal.process');
Route::delete('/supplier-journal/delete/{id}', [SupplierJournalController::class, 'destroy'])->name('supplier.journal.destroy');
// Process a single journal entry
Route::post('/supplier-journal/process/{id}', [SupplierJournalController::class, 'processSingle'])->name('supplier.journal.processSingle');
Route::post('/supplier-journal/process-all', [SupplierJournalController::class, 'process'])->name('supplier.journal.processAll');


// Customer Journal Routes
Route::get('/customer-journal', [CustomerJournalController::class, 'index'])->name('customer.journal.index');
Route::post('/customer-journal/store', [CustomerJournalController::class, 'store'])->name('customer.journal.store');
Route::post('/customer-journal/update', [CustomerJournalController::class, 'update'])->name('customer.journal.update');
Route::post('/customer-journal/process', [CustomerJournalController::class, 'process'])->name('customer.journal.process');
Route::delete('/customer-journal/delete/{id}', [CustomerJournalController::class, 'destroy'])->name('customer.journal.destroy');
// Process a single journal entry
Route::post('/customer-journal/process/{id}', [CustomerJournalController::class, 'processSingle'])->name('customer.journal.processSingle');


// General Journal Routes
Route::get('/general-journal', [GeneralJournalController::class, 'index'])->name('general.journal.index');
Route::post('/general-journal/store', [GeneralJournalController::class, 'store'])->name('general.journal.store');
Route::post('/general-journal/update', [GeneralJournalController::class, 'update'])->name('general.journal.update');
Route::post('/general-journal/process', [GeneralJournalController::class, 'process'])->name('general.journal.process');
Route::delete('/general-journal/delete/{id}', [GeneralJournalController::class, 'destroy'])->name('general.journal.destroy');
// Process a single journal entry
Route::post('/general-journal/process/{id}', [GeneralJournalController::class, 'processSingle'])->name('general.journal.processSingle');

// Cashbook Routes
Route::get('/cashbook', [CashbookController::class, 'index'])->name('cashbook.index');
Route::post('/cashbook/accounts', [CashbookController::class, 'getAccounts'])->name('cashbook.accounts');
Route::post('/cashbook/references', [CashbookController::class, 'getReferences'])->name('cashbook.references');
Route::post('/cashbook/store', [CashbookController::class, 'store'])->name('cashbook.store');
Route::post('/cashbook/update', [CashbookController::class, 'update'])->name('cashbook.update');
Route::post('/cashbook/process', [CashbookController::class, 'process'])->name('cashbook.process');
Route::delete('/cashbook/delete/{id}', [CashbookController::class, 'destroy'])->name('cashbook.destroy');
// Process a single cashbook entry
Route::post('/cashbook/process/{id}', [CashbookController::class, 'processSingle'])->name('cashbook.processSingle');
Route::get('/cashbook/edit/{id}', [CashbookController::class, 'edit'])->name('cashbook.edit');

// Inventory Journal Routes
Route::get('/inventory-journal', [InventoryJournalController::class, 'index'])->name('inventory.journal.index');
Route::post('/inventory-journal/store', [InventoryJournalController::class, 'store'])->name('inventory.journal.store');
Route::post('/inventory-journal/update', [InventoryJournalController::class, 'update'])->name('inventory.journal.update');
Route::post('/inventory-journal/process', [InventoryJournalController::class, 'process'])->name('inventory.journal.process');
Route::delete('/inventory-journal/delete/{id}', [InventoryJournalController::class, 'destroy'])->name('inventory.journal.destroy');
// Process a single journal entry
Route::post('/inventory-journal/process/{id}', [InventoryJournalController::class, 'processSingle'])->name('inventory.journal.processSingle');


//============================================= REPORTS ===========================================================

// TaxReport
Route::get('/tax-report', [TaxReportController::class, 'index'])->name('taxReport.index');
Route::post('/tax-report/generate', [TaxReportController::class, 'generate'])->name('taxReport.generate');
Route::get('/tax-report/download-pdf', [TaxReportController::class, 'downloadPdf'])->name('taxReport.downloadPdf');

// Customer Listing Report Routes
Route::get('/customer-listing-report', [CustomerListingReportController::class, 'index'])->name('customerListingReport.index');
Route::post('/customer-listing-report/generate', [CustomerListingReportController::class, 'generate'])->name('customerListingReport.generate');
Route::post('/customer-listing-report/download-pdf', [CustomerListingReportController::class, 'downloadPdf'])->name('customerListingReport.downloadPdf');

// customer Statements
// Customer Statement Report Routes
Route::get('/reports/customer-statement', [CustomerStatementReportController::class, 'index'])->name('customerStatementReport.index');
Route::post('/reports/customer-statement/generate', [CustomerStatementReportController::class, 'generate'])->name('customerStatementReport.generate');
Route::post('/reports/customer-statement/download-pdf', [CustomerStatementReportController::class, 'downloadPdf'])->name('customerStatementReport.downloadPdf');

// Customer Daily Transaction Routes
Route::get('/customer-daily-transaction', [CustomerDailyTransactionController::class, 'index'])->name('customerDailyTransaction.index');
Route::post('/customer-daily-transaction/generate', [CustomerDailyTransactionController::class, 'generate'])->name('customerDailyTransaction.generate');
Route::post('/customer-daily-transaction/download-pdf', [CustomerDailyTransactionController::class, 'downloadPdf'])->name('customerDailyTransaction.downloadPdf');
// Sales Colection
Route::get('/sales-collection-report', [SalesCollectionReportController::class, 'index'])->name('salesCollectionReport.index');
Route::post('/sales-collection-report/generate', [SalesCollectionReportController::class, 'generate'])->name('salesCollectionReport.generate');
Route::post('/sales-collection-report/download-pdf', [SalesCollectionReportController::class, 'downloadPdf'])->name('salesCollectionReport.downloadPdf');

// Outstanding Sales Report Routes
Route::get('/outstanding-sales-report', [OutstandingSalesReportController::class, 'index'])->name('outstandingSalesReport.index');
Route::post('/outstanding-sales-report/generate', [OutstandingSalesReportController::class, 'generate'])->name('outstandingSalesReport.generate');
Route::post('/outstanding-sales-report/download-pdf', [OutstandingSalesReportController::class, 'downloadPdf'])->name('outstandingSalesReport.downloadPdf');

// Invoice summary report
Route::get('/invoice-summary-report', [InvoiceReportController::class, 'index'])->name('invoiceSummaryReport.index');
Route::post('/invoice-summary-report/generate', [InvoiceReportController::class, 'generate'])->name('invoiceSummaryReport.generate');
Route::post('/invoice-summary-report/download-pdf', [InvoiceReportController::class, 'downloadPdf'])->name('invoiceSummaryReport.downloadPdf');

// Supplier Listing Report Routes
Route::prefix('supplier-listing-report')->group(function () {
    Route::get('/', [SupplierListingReportController::class, 'index'])->name('supplierListingReport.index');
    Route::post('/generate', [SupplierListingReportController::class, 'generate'])->name('supplierListingReport.generate');
    Route::post('/download-pdf', [SupplierListingReportController::class, 'downloadPdf'])->name('supplierListingReport.downloadPdf');
});


// Supplier Statement Report Routes
Route::get('/reports/supplier-statement', [SupplierStatementReportController::class, 'index'])->name('supplierStatementReport.index');
Route::post('/reports/supplier-statement/generate', [SupplierStatementReportController::class, 'generate'])->name('supplierStatementReport.generate');
Route::post('/reports/supplier-statement/download-pdf', [SupplierStatementReportController::class, 'downloadPdf'])->name('supplierStatementReport.downloadPdf');

// Supplier Daily Transaction Routes
Route::get('/supplier-daily-transaction', [SupplierDailyTransactionController::class, 'index'])->name('supplierDailyTransaction.index');
Route::post('/supplier-daily-transaction/generate', [SupplierDailyTransactionController::class, 'generate'])->name('supplierDailyTransaction.generate');
Route::post('/supplier-daily-transaction/download-pdf', [SupplierDailyTransactionController::class, 'downloadPdf'])->name('supplierDailyTransaction.downloadPdf');

// Supplier Payments Routes
Route::get('/supplier-payments-report', [SupplierPaymentsReportController::class, 'index'])->name('supplierPaymentsReport.index');
Route::post('/supplier-payments-report/generate', [SupplierPaymentsReportController::class, 'generate'])->name('supplierPaymentsReport.generate');
Route::post('/supplier-payments-report/download-pdf', [SupplierPaymentsReportController::class, 'downloadPdf'])->name('supplierPaymentsReport.downloadPdf');

// Document Reprint Routes
Route::prefix('document-reprint')->group(function () {
    Route::get('/', [DocumentReprintController::class, 'index'])->name('documentReprint.index');
    Route::post('/generate', [DocumentReprintController::class, 'generate'])->name('documentReprint.generate');
    Route::get('/document/{id}/reprint', [DocumentReprintController::class, 'reprintDocument'])->name('documentReprint.reprintDocument');
    Route::get('/receipt/{id}/reprint', [DocumentReprintController::class, 'reprintReceipt'])->name('documentReprint.reprintReceipt');
    Route::get('/document/{id}/download', [DocumentReprintController::class, 'downloadDocument'])->name('documentReprint.downloadDocument');
    Route::get('/receipt/{id}/download', [DocumentReprintController::class, 'downloadReceipt'])->name('documentReprint.downloadReceipt');
});

// Outstanding Payments Report Routes
Route::get('/reports/outstanding-payments', [OutstandingPaymentsReportController::class, 'index'])->name('outstandingPaymentsReport.index');
Route::post('/reports/outstanding-payments/generate', [OutstandingPaymentsReportController::class, 'generate'])->name('outstandingPaymentsReport.generate');
Route::post('/reports/outstanding-payments/download-pdf', [OutstandingPaymentsReportController::class, 'downloadPdf'])->name('outstandingPaymentsReport.downloadPdf');

// Supplier Invoice Report Routes
Route::get('/reports/supplier-invoice-summary', [SupplierInvoiceReportController::class, 'index'])->name('supplierInvoiceSummaryReport.index');
Route::post('/reports/supplier-invoice-summary/generate', [SupplierInvoiceReportController::class, 'generate'])->name('supplierInvoiceSummaryReport.generate');
Route::post('/reports/supplier-invoice-summary/download-pdf', [SupplierInvoiceReportController::class, 'downloadPdf'])->name('supplierInvoiceSummaryReport.downloadPdf');

// Supplier Document Reprint Routes
Route::prefix('supplier-document-reprint')->group(function () {
    Route::get('/', [SupplierDocumentReprintController::class, 'index'])->name('supplierDocumentReprint.index');
    Route::post('/generate', [SupplierDocumentReprintController::class, 'generate'])->name('supplierDocumentReprint.generate');
    Route::get('/reprint/{id}', [SupplierDocumentReprintController::class, 'reprintDocument'])->name('supplierDocumentReprint.reprintDocument');
    Route::get('/download/{id}', [SupplierDocumentReprintController::class, 'downloadDocument'])->name('supplierDocumentReprint.downloadDocument');
});


//gl transaction
Route::get('gl-transactions', [GlTransactionController::class, 'index'])->name('glTransaction.index');
Route::post('gl-transactions/generate', [GlTransactionController::class, 'generate'])->name('glTransaction.generate');
Route::post('gl-transactions/download-pdf', [GlTransactionController::class, 'downloadPdf'])->name('glTransaction.downloadPdf');


// Cashbook Daily Transaction Routes
Route::get('/cashbook-daily-transaction', [CashbookDailyTransactionController::class, 'index'])->name('cashbookDailyTransaction.index');
Route::post('/cashbook-daily-transaction/generate', [CashbookDailyTransactionController::class, 'generate'])->name('cashbookDailyTransaction.generate');
Route::post('/cashbook-daily-transaction/download-pdf', [CashbookDailyTransactionController::class, 'downloadPdf'])->name('cashbookDailyTransaction.downloadPdf');

// Project Reports Routes
Route::get('/project-reports', [ProjectReportController::class, 'index'])->name('projectReports.index');
Route::get('/project-listing-report', [ProjectReportController::class, 'listing'])->name('projectReports.listing');
Route::post('/project-listing-report/download-pdf', [ProjectReportController::class, 'downloadPdf'])->name('projectReports.downloadPdf');

// Inventory Stock Level Routes
Route::get('/inventory-stock-level', [InventoryStockLevelController::class, 'index'])->name('inventoryStockLevel.index');
Route::post('/inventory-stock-level/generate', [InventoryStockLevelController::class, 'generate'])->name('inventoryStockLevel.generate');
Route::post('/inventory-stock-level/download-pdf', [InventoryStockLevelController::class, 'downloadPdf'])->name('inventoryStockLevel.downloadPdf');

// Inventory Movement Report Routes
Route::get('/inventory-movement-report', [InventoryMovementReportController::class, 'index'])->name('inventoryMovementReport.index');
Route::post('/inventory-movement-report/generate', [InventoryMovementReportController::class, 'generate'])->name('inventoryMovementReport.generate');
Route::post('/inventory-movement-report/download-pdf', [InventoryMovementReportController::class, 'downloadPdf'])->name('inventoryMovementReport.downloadPdf');
Route::post('/inventory-movement-report/download-excel', [InventoryMovementReportController::class, 'downloadExcel'])->name('inventoryMovementReport.downloadExcel');

// Warehouse Transfer Report Routes
Route::get('/warehouse-transfer-report', [WarehouseTransferReportController::class, 'index'])->name('warehouseTransferReport.index');
Route::post('/warehouse-transfer-report/generate', [WarehouseTransferReportController::class, 'generate'])->name('warehouseTransferReport.generate');
Route::post('/warehouse-transfer-report/download-pdf', [WarehouseTransferReportController::class, 'downloadPdf'])->name('warehouseTransferReport.downloadPdf');

// Stock Valuation Report Routes
Route::get('/stock-valuation-report', [StockValuationController::class, 'index'])->name('stockValuation.index');
Route::post('/stock-valuation-report/generate', [StockValuationController::class, 'generate'])->name('stockValuation.generate');
Route::post('/stock-valuation-report/download-pdf', [StockValuationController::class, 'downloadPdf'])->name('stockValuation.downloadPdf');

// Sales Analysis
Route::get('/reports/sales-analysis', [SalesAnalysisController::class, 'index'])->name('salesAnalysis.index');
Route::post('/reports/sales-analysis/generate', [SalesAnalysisController::class, 'generate'])->name('salesAnalysis.generate');
Route::post('/reports/sales-analysis/download-pdf', [SalesAnalysisController::class, 'downloadPdf'])->name('salesAnalysis.downloadPdf');


// Company Settings Routes
Route::prefix('company-settings')->group(function () {
    Route::get('/', [CompanySettingsController::class, 'index'])->name('company-settings.index');
    Route::get('/create', [CompanySettingsController::class, 'create'])->name('company-settings.create');
    Route::post('/', [CompanySettingsController::class, 'store'])->name('company-settings.store');
    Route::get('/edit', [CompanySettingsController::class, 'edit'])->name('company-settings.edit');
    Route::put('/', [CompanySettingsController::class, 'update'])->name('company-settings.update');
    Route::delete('/', [CompanySettingsController::class, 'destroy'])->name('company-settings.destroy');
});

// Stock Management Report Routes
Route::get('/stock-management-report', [StockManagementReportController::class, 'index'])->name('stockManagement.index');
Route::post('/stock-management-report/generate', [StockManagementReportController::class, 'generate'])->name('stockManagement.generate');
Route::post('/stock-management-report/download-pdf', [StockManagementReportController::class, 'downloadPdf'])->name('stockManagement.downloadPdf');

// User sales report Routes
Route::get('/user_sales_report', [CustomerDailyTransactionController::class, 'usersales'])->name('usersalesreport.index');
Route::post('/user_sales_report/generate', [CustomerDailyTransactionController::class, 'generateusersales'])->name('usersales.generate');
Route::post('/user_sales_report/download-pdf', [CustomerDailyTransactionController::class, 'downloadPdf'])->name('customerDailyTransaction.downloadPdf');

// Inventory sales report Routes
Route::get('/inventory_sales_report', [CustomerDailyTransactionController::class, 'inventorysales'])->name('inventorysalesreport.index');
Route::post('/inventory_sales_report/generate', [CustomerDailyTransactionController::class, 'generateinventorysales'])->name('inventorysales.generate');
Route::post('/inventory_sales_report/download-pdf', [CustomerDailyTransactionController::class, 'downloadPdf'])->name('customerDailyTransaction.downloadPdf');

// sales report Routes
Route::get('/sales_report', [CustomerDailyTransactionController::class, 'sales'])->name('salesreport.index');
Route::post('/sales_report/generate', [CustomerDailyTransactionController::class, 'generatedailysales'])->name('dailysales.generate');
Route::post('/sales_report/download-pdf', [CustomerDailyTransactionController::class, 'downloadPdf'])->name('customerDailyTransaction.downloadPdf');


});
