<?php

//*? Imports
    //* Packages and Libraries
    use Illuminate\Support\Facades\Route;
    use Illuminate\Support\Facades\Auth;

    //* Controllers
      // Environment
        use App\Http\Controllers\Environment\AuthController;
        use App\Http\Controllers\Environment\BusinessController;
        use App\Http\Controllers\Environment\PaymentMethodController;
        use App\Http\Controllers\Environment\SystemConfigurationController;
        use App\Http\Controllers\Environment\TokensController;
        use App\Http\Controllers\Environment\UserController;

      // Support
        use App\Http\Controllers\Support\DefaultViewsController;
        use App\Http\Controllers\Support\CatalogController;
        use App\Http\Controllers\Support\HomeController;

        use App\Http\Controllers\Apis\CurrencyController;
        use App\Http\Controllers\Apis\ZipCodeController;

// Hotel
        use App\Http\Controllers\Hotel\AgencyController;
        use App\Http\Controllers\Hotel\CalendarController;
        use App\Http\Controllers\Hotel\ClientsController;
        use App\Http\Controllers\Hotel\HotelCSVController;
        use App\Http\Controllers\Hotel\HotelPDFController;
        use App\Http\Controllers\Hotel\InformesHotelController;
        use App\Http\Controllers\Hotel\RegimenController;
        use App\Http\Controllers\Hotel\ReservationChargesController;
        use App\Http\Controllers\Hotel\ReservationController;
        use App\Http\Controllers\Hotel\ReservationPaymentsController;
        use App\Http\Controllers\Hotel\ReservationTicketsController;
        use App\Http\Controllers\Hotel\RoomController;
        use App\Http\Controllers\Hotel\RoomGroupController;
        use App\Http\Controllers\Hotel\RoomTypeController;
        use App\Http\Controllers\Hotel\SeasonController;
        use App\Http\Controllers\Hotel\SourceController;

        //Restaurant
        use App\Http\Controllers\Restaurant\InformesRestauranteController;
        use App\Http\Controllers\Restaurant\OrderController;
        use App\Http\Controllers\Restaurant\PedidoController;
        use App\Http\Controllers\Restaurant\ProductCategoryController;
        use App\Http\Controllers\Restaurant\ProductController;
        use App\Http\Controllers\Restaurant\RestaurantCSVController;
        use App\Http\Controllers\Restaurant\RestaurantPDFController;
        use App\Http\Controllers\Restaurant\TableController;

      // Modules
        use App\Http\Controllers\Modules\Audits\AuditController;

        use App\Http\Controllers\Modules\OtaConnections\AllotmentEventController;
        use App\Http\Controllers\Modules\OtaConnections\OTAConnectionController;

        use App\Http\Controllers\Invoicing\SignedManifestController;
        use App\Http\Controllers\Invoicing\TaxBranchController;
        use App\Http\Controllers\Invoicing\TaxFormatController;
        use App\Http\Controllers\Invoicing\TaxInvoiceController;
        use App\Http\Controllers\Invoicing\TaxClientController;
        use App\Http\Controllers\Invoicing\TaxPaymentController;
        use App\Http\Controllers\Invoicing\TaxProdServController;
        use App\Http\Controllers\Invoicing\FacturapiWebhooksController;

        use App\Http\Controllers\Modules\ShiftController;

//*? Routes
  /*
    |--------------------------------------------------------------------------
    | 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!
    |
  */
  //* Test (Sección de rutas Temporales que no deben llegar a Deploy)

  //* Public Routes
    //- Views
      // Default Routes
        Route::get('/', function () {
            return redirect(Auth::check() ? '/home' : '/login');
        });

      // Calendario de eventos
        Route::get('/public-calendar', [CalendarController::class, 'publicCalendar'])->name('calendar.publicCalendar');

    //-Settings
      // Configuración del hotel
        Route::get('/system-settings', [SystemConfigurationController::class, 'getSystemSettings']);
        Route::get('/system-translations', [SystemConfigurationController::class, 'getSystemTranslations']);

  //* Webhooks Routes
    // Invoicing
    Route::post('/webhooks/facturapi', [FacturapiWebhooksController::class, 'handle'])->name('webhooks.facturapi');

  //* Protected Routes
    Route::middleware([
        'auth:sanctum',
        config('jetstream.auth_session'),
        'verified'
    ])->group(function () {

      //? Environment
        //* Session
            Route::post('/logout-harsi', [AuthController::class, 'logout'])->name('auth.harsiLogout');

        //* Configuración del hotel
            Route::get('/system-settings/refresh', function() {
                session()->reflash(); // Fuerza que los datos de la sesión se mantengan actualizados
                return response()->json(['message' => 'Sesión actualizada']);
            });

        //* Tokens
          // Api
            Route::get('/tokens/generate-api-token', [TokensController::class, 'generateApiToken']);

        //* Configuración
            Route::post('/system-settings/update', [SystemConfigurationController::class, 'updateSettings'])->name('settings.update');

        //* Datos del hotel
            Route::post('/establishments/update/tax-information', [BusinessController::class, 'updateTaxData'])->name('establishments.updateTaxData');
            Route::post('/establishments/update/certificate-information', [BusinessController::class, 'updateCertificateData'])->name('establishments.updateCertificateData');
            Route::get('/establishments/check-certificate-validity', [BusinessController::class, 'validateCertificatesValidity']);

            Route::resource('establishments', BusinessController::class);
            Route::post('/establishments/update', [BusinessController::class, 'update'])->name('establishments.update');
            Route::post('/establishments/hotelPhoto', [BusinessController::class, 'setHotelPhoto'])->name('establishments.setHotelPhoto');
            Route::get('/establishments/{id}/destroy', [BusinessController::class, 'destroy']);

        //* Métodos de pago
            Route::resource('payment-methods', PaymentMethodController::class);
            Route::post('/payment-methods/update', [PaymentMethodController::class, 'update'])->name('payment-methods.update');
            Route::get('/payment-methods/{id}/destroy', [PaymentMethodController::class, 'destroy']);

        //* Usuarios
            Route::resource('users', UserController::class);
            Route::post('/users/update', [UserController::class, 'update'])->name('users.update');
            Route::get('/users/{id}/destroy', [UserController::class, 'destroy']);

      //? Support
        Route::get('/dashboard', [DefaultViewsController::class, 'dashboard'])->name('dashboard');
        Route::get('/inactivity-page', [DefaultViewsController::class, 'inactivityPage']);

        Route::resource('home', HomeController::class);
        Route::delete('/home/reservation/{id}/{type}/no-show', [HomeController::class, 'noShow']);

      //? Hotel
        //* Agencias
            Route::resource('agencies', AgencyController::class);
            Route::post('/agencies/update', [AgencyController::class, 'update'])->name('agencies.update');
            Route::get('/agencies/{id}/destroy', [AgencyController::class, 'destroy']);

        //* Calendario de Reservas
            Route::get('/calendar', [CalendarController::class, 'index'])->name('calendar.index');

        //* Clientes
            Route::resource('clients', ClientsController::class);
            Route::post('/clients/update', [ClientsController::class, 'update'])->name('clients.update');
            Route::get('/clients/{id}/destroy', [ClientsController::class, 'destroy']);

        //* Regímenes
            Route::resource('regimens', RegimenController::class);
            Route::post('/regimens/update', [RegimenController::class, 'update'])->name('regimens.update');
            Route::get('/regimens/{id}/destroy', [RegimenController::class, 'destroy']);

        //* Pagos sobre Reservas
            Route::post('/reservation-payments/lodging', [ReservationPaymentsController::class, 'storeLodgingPayments'])->name('reservationPayments.lodging.store');
            Route::post('/reservation-payments/extra', [ReservationPaymentsController::class, 'storeExtraPayments'])->name('reservationPayments.extra.store');
            Route::post('/reservation-payments/consumption', [ReservationPaymentsController::class, 'storeConsumptionPayments'])->name('reservationPayments.consumption.store');

            Route::get('/reservation-payments/lodging/{id}/destroy', [ReservationPaymentsController::class, 'removeLodgingPayments'])->name('reservationPayments.lodging.delete');
            Route::get('/reservation-payments/extra/{id}/destroy', [ReservationPaymentsController::class, 'removeExtraPayments'])->name('reservationPayments.extra.delete');
            Route::get('/reservation-payments/consumption/{id}/destroy', [ReservationPaymentsController::class, 'removeConsumptionPayments'])->name('reservationPayments.consumption.delete');

            Route::get('/reservation-payments/lodging/{id}/edit', [ReservationPaymentsController::class, 'editLodgingPayments'])->name('reservationPayments.lodging.edit');
            Route::get('/reservation-payments/extra/{id}/edit', [ReservationPaymentsController::class, 'editExtraPayments'])->name('reservationPayments.extra.edit');
            Route::get('/reservation-payments/consumption/{id}/edit', [ReservationPaymentsController::class, 'editConsumptionPayments'])->name('reservationPayments.consumption.edit');

            Route::post('/reservation-payments/lodging/update', [ReservationPaymentsController::class, 'updateLodgingPayments'])->name('reservationPayments.lodging.update');
            Route::post('/reservation-payments/extra/update', [ReservationPaymentsController::class, 'updateExtraPayments'])->name('reservationPayments.extra.update');
            Route::post('/reservation-payments/consumption/update', [ReservationPaymentsController::class, 'updateConsumptionPayments'])->name('reservationPayments.consumption.update');

        //* Cargos sobre Reservas
            Route::post('/reservation-charges/extra', [ReservationChargesController::class, 'storeExtraCharges'])->name('reservationCharges.extra.store');
            Route::post('/reservation-charges/consumption', [ReservationChargesController::class, 'storeConsumptionCharges'])->name('reservationCharges.consumption.store');

            Route::get('/reservation-charges/extra/{id}/destroy', [ReservationChargesController::class, 'removeExtraCharges'])->name('reservationCharges.extra.delete');
            Route::get('/reservation-charges/consumption/{id}/destroy', [ReservationChargesController::class, 'removeConsumptionCharges'])->name('reservationCharges.consumption.delete');

            Route::get('/reservation-charges/extra/{id}/edit', [ReservationChargesController::class, 'editExtraCharges'])->name('reservationCharges.extra.edit');
            Route::get('/reservation-charges/consumption/{id}/edit', [ReservationChargesController::class, 'editConsumptionCharges'])->name('reservationCharges.consumption.edit');

            Route::post('/reservation-charges/extra/update', [ReservationChargesController::class, 'updateExtraCharges'])->name('reservationCharges.extra.update');
            Route::post('/reservation-charges/consumption/update', [ReservationChargesController::class, 'updateConsumptionCharges'])->name('reservationCharges.consumption.update');

        //* Reservaciones
            Route::resource('reservations', ReservationController::class);

            Route::post('/reservations/update', [ReservationController::class, 'update'])->name('reservations.update');
            Route::post('/reservations/filter-table', [ReservationController::class, 'filterTable'])->name('reservations.filter');

            Route::get('/reservations/{id}/destroy', [ReservationController::class, 'destroy']);
            Route::get('/reservations/{id}/find-history-data', [ReservationController::class, 'findHistoryData']);

        //*Tickets
            // Detalles de reservas - Estancia general
            Route::get('/reservation-tickets/full-stay', [ReservationTicketsController::class, 'fullStayTickets'])->name('reservation.tickets.fullStays');
            Route::get('/reservation-tickets/full-stay/{id}', [ReservationTicketsController::class, 'showFullStay'])->name('reservation.tickets.fullStays.show');
            Route::get('/reservation-tickets/full-stay/{id}/download', [ReservationTicketsController::class, 'downloadFullStayTicket'])->name('reservation.tickets.fullStays.download');

            Route::post('/reservation-tickets/full-stay/{id}/send-ticket', [ReservationTicketsController::class, 'sendFullStayTicket'])->name('reservation.tickets.fullStays.sendTicket');

            // Detalles de reservas - Consumo en el hotel
            Route::get('/reservation-tickets/hotel-consumption', [ReservationTicketsController::class, 'consumptionTickets'])->name('reservation.tickets.hotelConsumptions');
            Route::get('/reservation-tickets/hotel-consumption/{id}', [ReservationTicketsController::class, 'showConsumptions'])->name('reservation.tickets.hotelConsumptions.show');

        //* Habitaciones
            Route::resource('rooms', RoomController::class);
            Route::post('/rooms/update', [RoomController::class, 'update'])->name('rooms.update');
            Route::get('/rooms/{id}/destroy', [RoomController::class, 'destroy']);
            Route::get('/rooms/{id}/check-entry-and-cleaning-time', [RoomController::class, 'checkEntryAndCleaningTime']);

        //* Grupos de habitaciones
            Route::resource('room-groups', RoomGroupController::class);
            Route::post('/room-groups/update', [RoomGroupController::class, 'update'])->name('room-groups.update');
            Route::get('/room-groups/{id}/destroy', [RoomGroupController::class, 'destroy']);

        //* Tipos de habitaciones
            Route::resource('room-types', RoomTypeController::class);
            Route::post('/room-types/update', [RoomTypeController::class, 'update'])->name('room-types.update');
            Route::get('/room-types/{id}/destroy', [RoomTypeController::class, 'destroy']);

        //* Temporadas Globales
            Route::resource('seasons', SeasonController::class);
            Route::post('/seasons/update', [SeasonController::class, 'update'])->name('seasons.update');
            Route::get('/seasons/{id}/destroy', [SeasonController::class, 'destroy']);

        //* Fuentes de reserva
            Route::resource('sources', SourceController::class);
            Route::post('/sources/update', [SourceController::class, 'update'])->name('sources.update');
            Route::get('/sources/{id}/destroy', [SourceController::class, 'destroy']);


        //* Consultas y Reportes (Hoteleria)
            Route::get('/hotel/reports', [InformesHotelController::class, 'index'])->name('hotel.reports');

          // Incomes
            Route::get('/hotel/reports/checkin-balances', [InformesHotelController::class, 'checkinBalances'])->name('hotel.reports.checkinBalances');
            Route::get('/hotel/reports/checkout-balances', [InformesHotelController::class, 'checkoutBalances'])->name('hotel.reports.checkoutBalances');
            Route::get('/hotel/reports/income-per-month', [InformesHotelController::class, 'incomePerMonth'])->name('hotel.reports.incomePerMonth');
            Route::get('/hotel/reports/income-per-period', [InformesHotelController::class, 'incomePerPeriod'])->name('hotel.reports.incomePerPeriod');
            Route::get('/hotel/reports/income-per-period-and-payment-method', [InformesHotelController::class, 'incomePerPeriodAndPaymentMethod'])->name('hotel.reports.incomePerPeriodAndPaymentMethod');
            Route::get('/hotel/reports/income-per-period-and-room-type', [InformesHotelController::class, 'incomePerPeriodAndRoomType'])->name('hotel.reports.incomePerPeriodAndRoomType');

          // Reservation
            Route::get('/hotel/reports/reservations-per-period', [InformesHotelController::class, 'reservationsPerPeriod'])->name('hotel.reports.reservationsPerPeriod');
            Route::get('/hotel/reports/deferred-bookings', [InformesHotelController::class, 'deferredBookings'])->name('hotel.reports.deferredBookings');
            Route::get('/hotel/reports/common-sources', [InformesHotelController::class, 'commonSources'])->name('hotel.reports.commonSources');

            Route::get('/hotel/reports/booking-history', [InformesHotelController::class, 'bookingHistory'])->name('hotel.reports.bookingHistory');
            Route::get('/hotel/reports/booking-history/{id}', [InformesHotelController::class, 'bookingHistoryData'])->name('hotel.reports.bookingHistoryData');

            Route::get('/hotel/reports/booking-update-history/{folio}', [InformesHotelController::class, 'bookingUpdateHistory'])->name('hotel.reports.bookingUpdateHistory');
            Route::get('/hotel/reports/checkin-per-user-and-period', [InformesHotelController::class, 'checkinPerUserAndPeriod'])->name('hotel.reports.checkinPerUserAndPeriod');

            Route::get('/hotel/reports/occupation-per-period', [InformesHotelController::class, 'occupationPerPeriod'])->name('hotel.reports.occupationPerPeriod');
            Route::get('/hotel/reports/occupation-per-month', [InformesHotelController::class, 'occupationPerMonth'])->name('hotel.reports.occupationPerMonth');
            Route::get('/hotel/reports/occupation-per-year', [InformesHotelController::class, 'occupationPerYear'])->name('hotel.reports.occupationPerYear');

            Route::get('/hotel/reports/arrives-per-period', [InformesHotelController::class, 'arrivesPerPeriod'])->name('hotel.reports.arrivesPerPeriod');
            Route::get('/hotel/reports/overbooking-per-period', [InformesHotelController::class, 'overbookingPerPeriod'])->name('hotel.reports.overbookingPerPeriod');
            Route::get('/hotel/reports/overbooking-on-future', [InformesHotelController::class, 'overbookingOnFuture'])->name('hotel.reports.overbookingOnFuture');

            Route::get('/hotel/reports/regimen-per-period', [InformesHotelController::class, 'regimenPerPeriod'])->name('hotel.reports.regimenPerPeriod');
            Route::get('/hotel/reports/regimen-per-period/{start}/{end}', [InformesHotelController::class, 'regimenPerPeriodData'])->name('hotel.reports.regimenPerPeriodData');

            Route::get('/hotel/reports/on-destiny-per-period', [InformesHotelController::class, 'onDestinyPerPeriod'])->name('hotel.reports.onDestinyPerPeriod');
            Route::get('/hotel/reports/credit-per-period', [InformesHotelController::class, 'creditPerPeriod'])->name('hotel.reports.creditPerPeriod');
            Route::get('/hotel/reports/courtesy-per-period', [InformesHotelController::class, 'courtesyPerPeriod'])->name('hotel.reports.courtesyPerPeriod');

          // Clients
            Route::get('/hotel/reports/clients-per-period', [InformesHotelController::class, 'clientsPerPeriod'])->name('hotel.reports.clientsPerPeriod');

        //* Consultas y Reportes (Hoteleria) as CSV
          // Incomes
            Route::post('/hotel/csv/checkin-balances', [HotelCSVController::class, 'checkinBalances']);
            Route::post('/hotel/csv/checkout-balances', [HotelCSVController::class, 'checkoutBalances']);
            Route::post('/hotel/csv/income-per-month', [HotelCSVController::class, 'incomePerMonth']);
            Route::post('/hotel/csv/income-per-period', [HotelCSVController::class, 'incomePerPeriod']);
            Route::post('/hotel/csv/income-per-period-and-payment-method', [HotelCSVController::class, 'incomePerPeriodAndPaymentMethod']);
            Route::post('/hotel/csv/income-per-period-and-room-type', [HotelCSVController::class, 'incomePerPeriodAndRoomType']);

          // Reservation
            Route::get('/hotel/csv/reservations-per-period/{start}/{end}', [HotelCSVController::class, 'reservationsPerPeriod']);
            Route::get('/hotel/csv/deferred-bookings/{start}/{end}', [HotelCSVController::class, 'deferredBookings']);
            Route::get('/hotel/csv/common-sources', [HotelCSVController::class, 'commonSources']);
            Route::get('/hotel/csv/booking-history/{start}/{end}', [HotelCSVController::class, 'bookingHistory']);
            Route::get('/hotel/csv/booking-update-history/{folio}', [HotelCSVController::class, 'bookingUpdateHistory']);
            Route::get('/hotel/csv/checkin-per-user-and-period', [HotelCSVController::class, 'checkinPerUserAndPeriod']);
            Route::get('/hotel/csv/occupation-per-period', [HotelCSVController::class, 'occupationPerPeriod']);
            Route::get('/hotel/csv/occupation-per-month', [HotelCSVController::class, 'occupationPerMonth']);
            Route::get('/hotel/csv/occupation-per-year', [HotelCSVController::class, 'occupationPerYear']);
            Route::get('/hotel/csv/arrives-per-period/{start}/{end}', [HotelCSVController::class, 'arrivesPerPeriod']);
            Route::get('/hotel/csv/overbooking-per-period/{start}/{end}', [HotelCSVController::class, 'overbookingPerPeriod']);
            Route::get('/hotel/csv/overbooking-on-future', [HotelCSVController::class, 'overbookingOnFuture']);
            Route::get('/hotel/csv/regimen-per-period/{start}/{end}', [HotelCSVController::class, 'regimenPerPeriod']);
            Route::get('/hotel/csv/on-destiny-per-period/{start}/{end}', [HotelCSVController::class, 'onDestinyPerPeriod']);
            Route::get('/hotel/csv/credit-per-period/{start}/{end}', [HotelCSVController::class, 'creditPerPeriod']);
            Route::get('/hotel/csv/courtesy-per-period/{start}/{end}', [HotelCSVController::class, 'courtesyPerPeriod']);

          // Clients
            Route::get('/hotel/csv/clients-per-period', [HotelCSVController::class, 'clientsPerPeriod']);

      //? Restaurante

        //* Ordenes de restaurante
            Route::resource('orders', OrderController::class);
            Route::delete('/orders/{id}/destroy', [OrderController::class, 'destroy']);

        //* Comandas de restaurante
            Route::get('/commands', [PedidoController::class, 'index'])->name('commands.index');
            Route::post('/commands', [PedidoController::class, 'store'])->name('commands.store');

        //* Categorías de producto (restaurant)
            Route::resource('product-categories', ProductCategoryController::class);
            Route::post('/product-categories/update', [ProductCategoryController::class, 'update'])->name('product-categories.update');
            Route::get('/product-categories/{id}/destroy', [ProductCategoryController::class, 'destroy']);

        //* Productos Restaurant
            Route::resource('products', ProductController::class);
            Route::post('/products/update', [ProductController::class, 'update'])->name('products.update');
            Route::get('/products/{id}/destroy', [ProductController::class, 'destroy']);

        //* Mesas
            Route::resource('tables', TableController::class);
            Route::post('/tables/update', [TableController::class, 'update'])->name('tables.update');
            Route::get('/tables/{id}/destroy', [TableController::class, 'destroy']);


        //* Consultas y Reportes (Restaurante)
            Route::get('/restaurant', [InformesRestauranteController::class, 'index'])->name('restaurant.reports');

          // Incomes
            Route::get('/restaurant/reports/daily-restaurant-income', [InformesRestauranteController::class, 'dailyRestaurantIncome'])->name('restaurant.reports.dailyRestaurantIncome');
            Route::get('/restaurant/reports/income-per-period-and-category', [InformesRestauranteController::class, 'incomePerPeriodAndCategory'])->name('restaurant.reports.incomePerPeriodAndCategory');
            Route::get('/restaurant/reports/income-per-period-and-amenities', [InformesRestauranteController::class, 'incomePerPeriodAndAmenities'])->name('restaurant.reports.incomePerPeriodAndAmenities');

        //* Consultas y Reportes (Restaurante) as CSV
          // Incomes
            Route::post('/restaurant/csv/daily-restaurant-income', [RestaurantCSVController::class, 'dailyRestaurantIncome']);
            Route::post('/restaurant/csv/income-per-period-and-category', [RestaurantCSVController::class, 'incomePerPeriodAndCategory']);
            Route::post('/restaurant/csv/income-per-period-and-amenities', [RestaurantCSVController::class, 'incomePerPeriodAndAmenities']);

      //? Facturación
        //* Settings
          // Signed Manifiesto
            Route::get('/signed-manifest/status', [SignedManifestController::class, 'checkManifestStatus'])->name('signed-manifest.checkStatus');
            Route::get('/signed-manifest', [SignedManifestController::class, 'signedManifest'])->name('signed-manifest.index');
            Route::post('/signed-manifest/confirm', [SignedManifestController::class, 'confirmManifest'])->name('signed-manifest.confirm');

        //* Catalogs
            Route::get('/sat-catalogs/prod-serv/search', [CatalogController::class, 'searchProdServ'])->name('catalogs.prod-serv.search');
            Route::get('/catalogs/prod-serv/find', [CatalogController::class, 'findProdServ'])->name('catalogs.prod-serv.find');

            Route::get('/sat-catalogs/units/search', [CatalogController::class, 'searchUnits'])->name('catalogs.units.search');
            Route::get('/catalogs/units/find', [CatalogController::class, 'findUnit'])->name('catalogs.units.find');

        //* Receptores (Clientes)
            Route::get('/invoicing/clients/find', [TaxClientController::class, 'searchReceiver'])->name('tax-clients.find');
            Route::get('/invoicing/clients/{id}/edit', [TaxClientController::class, 'edit'])->name('tax-clients.edit');
            Route::get('/invoicing/clients', [TaxClientController::class, 'index'])->name('tax-clients.index');

            Route::post('/invoicing/clients', [TaxClientController::class, 'store'])->name('tax-clients.store');
            Route::patch('/invoicing/clients/{id}', [TaxClientController::class, 'update'])->name('tax-clients.update');

        //* Facturas
          // Shared
            Route::get('/invoicing/invoices', [TaxInvoiceController::class, 'index'])->name('invoices.index');
            Route::get('/invoicing/invoices/filter-table', [TaxInvoiceController::class, 'filterTable'])->name('invoices.filter');
            Route::post('/invoicing/invoices/clear-session-filter', [TaxInvoiceController::class, 'clearSessionFilter'])->name('invoices.clearSessionFilter');
            Route::get('/invoicing/invoices/search', [TaxInvoiceController::class, 'searchBySatUuid'])->name('invoices.searchByUuid');
            Route::get('/invoicing/invoices/create/{service_type?}/{service_id?}', [TaxInvoiceController::class, 'create'])/*->middleware('stamping.limit')*/->name('invoices.create');

            Route::delete('/invoicing/invoices/{id}/destroy', [TaxInvoiceController::class, 'destroy'])->name('invoices.destroy');

          // Nuevas / Timbradas
            Route::get('/invoicing/invoices/{id}', [TaxInvoiceController::class, 'show'])->name('invoices.show');
            Route::get('/invoicing/invoices/{id}/download-xml', [TaxInvoiceController::class, 'downloadXml'])->name('invoices.download.xml');
            Route::get('/invoicing/invoices/{id}/duplicate-as-draft', [TaxInvoiceController::class, 'duplicateAsDraft'])->name('invoices.duplicateAsDraft');

            Route::post('/invoicing/invoices/cancel/{id}', [TaxInvoiceController::class, 'cancel'])->name('invoices.cancel');
            Route::post('/invoicing/invoices/certify/{id?}', [TaxInvoiceController::class, 'certify'])->name('invoices.certify');
            Route::post('/invoicing/invoices/{id}/send-cfdi', [TaxInvoiceController::class, 'sendCfdiByEmail'])->name('invoices.sendCFDI');

          // Borradores
            Route::get('/invoicing/draft-invoices/preview/{id?}', [TaxInvoiceController::class, 'preview'])->name('invoices.drafts.preview');
            Route::get('/invoicing/draft-invoices/{id}/edit', [TaxInvoiceController::class, 'editDraft'])->name('invoices.drafts.edit');

            Route::post('/invoicing/draft-invoices/preview', [TaxInvoiceController::class, 'preview'])->name('invoices.drafts.previewForm');
            Route::post('/invoicing/draft-invoices/upsert/{id?}', [TaxInvoiceController::class, 'upsertDraft'])->name('invoices.drafts.upsert');

        //* Complementos de Pago
            Route::get('/invoicing/invoices/{invoice_id}/payment-history', [TaxPaymentController::class, 'invoicePaymentHistory'])->name('tax-payments.invoicePaymentHistory');

            Route::get('/invoicing/invoices/payment-complement/search', [TaxPaymentController::class, 'searchBySatUuid'])->name('tax-payments.searchByUuid');
            Route::get('/invoicing/invoices/payment-complement/{id}', [TaxPaymentController::class, 'show'])->name('tax-payments.show');
            Route::get('/invoicing/invoices/payment-complement/{id}/download-xml', [TaxPaymentController::class, 'downloadXml'])->name('tax-payments.download.xml');

            Route::post('/invoicing/invoices/payment-complement/certify', [TaxPaymentController::class, 'certify'])->name('tax-payments.certify');
            Route::post('/invoicing/invoices/payment-complement/{id}/cancel', [TaxPaymentController::class, 'cancel'])->name('tax-payments.cancel');
            Route::post('/invoicing/invoices/payment-complement/{id}/send-cfdi', [TaxPaymentController::class, 'sendPaymentCfdiByEmail'])->name('tax-payments.sendCFDI');

        //* Complementos de Pago Multiple
            Route::get('/invoicing/invoices/multi-payments/related-invoices', [TaxPaymentController::class, 'getInvoicesForMultiPayments'])->name('tax-payments.multi-payments');
            Route::get('/invoicing/invoices/multi-payments/details', [TaxPaymentController::class, 'getDetailsOnInvoicesForMultiPayments'])->name('tax-payments.multi-payments.details');
            Route::post('/invoicing/invoices/multi-payments/certify', [TaxPaymentController::class, 'certifyMultiple'])->name('tax-payments.multi-payments.certify');

        //* Sucursales
            Route::get('/invoicing/branches', [TaxBranchController::class, 'index'])->name('tax-branches.index');
            Route::get('/invoicing/branches/{id}/edit', [TaxBranchController::class, 'edit'])->name('tax-branches.edit');

            Route::post('/invoicing/branches', [TaxBranchController::class, 'store'])->name('tax-branches.store');
            Route::post('/invoicing/branches/update', [TaxBranchController::class, 'update'])->name('tax-branches.update');
            Route::delete('/invoicing/branches/{id}/destroy', [TaxBranchController::class, 'destroy'])->name('tax-branches.destroy');

        //* Productos/Servicios
            Route::get('/invoicing/products-and-services/find', [TaxProdServController::class, 'searchProdServ'])->name('tax-prod-servs.find');

            Route::get('/invoicing/products-and-services', [TaxProdServController::class, 'index'])->name('tax-prod-servs.index');
            Route::get('/invoicing/products-and-services/{id}/edit', [TaxProdServController::class, 'edit'])->name('tax-prod-servs.edit');

            Route::post('/invoicing/products-and-services', [TaxProdServController::class, 'store'])->name('tax-prod-servs.store');
            Route::post('/invoicing/products-and-services/update', [TaxProdServController::class, 'update'])->name('tax-prod-servs.update');
            Route::delete('/invoicing/products-and-services/{id}/destroy', [TaxProdServController::class, 'destroy'])->name('tax-prod-servs.destroy');

        //* Formatos y Colores
            Route::get('/invoicing/formats', [TaxFormatController::class, 'index'])->name('tax-formats.index');
            Route::get('/invoicing/formats/{id}/edit', [TaxFormatController::class, 'edit'])->name('tax-formats.edit');

            Route::post('/invoicing/formats', [TaxFormatController::class, 'store'])->name('tax-formats.store');
            Route::post('/invoicing/formats/update', [TaxFormatController::class, 'update'])->name('tax-formats.update');
            Route::delete('/invoicing/formats/{id}/destroy', [TaxFormatController::class, 'destroy'])->name('tax-formats.destroy');

      //? PDF
          // Hotel
            Route::get('/pdf/users', [HotelPDFController::class, 'userList'])->name('users.pdf');
            Route::get('/pdf/rooms', [HotelPDFController::class, 'roomList'])->name('rooms.pdf');
            Route::get('/pdf/agencies', [HotelPDFController::class, 'agencyList'])->name('agencies.pdf');
          // Restaurant
            Route::get('/pdf/categories', [RestaurantPDFController::class, 'categoryList'])->name('categories.pdf');
            Route::get('/pdf/products', [RestaurantPDFController::class, 'productList'])->name('products.pdf');
            Route::get('/pdf/sales', [RestaurantPDFController::class, 'salesList'])->name('sales.pdf');

      //? Modules
        //* Turnos Laborales
            Route::resource('shifts', ShiftController::class);
            Route::post('/shifts/update', [ShiftController::class, 'update'])->name('shifts.update');
            Route::get('/shifts/{id}/destroy', [ShiftController::class, 'destroy']);

        //* Auditorias
            Route::get('/audits/check-shift-and-audits', [AuditController::class, 'checkShiftAndAudits']);
            Route::get('/audits/conclude-shift', [AuditController::class, 'concludeShift'])->name('audits.concludeShift');
            Route::get('/audits/conclude-and-audit-shift', [AuditController::class, 'concludeAndAuditShift']);
            Route::get('/audits/validate-timeless-request', [AuditController::class, 'validateTimelessAuditRequest']);
            Route::get('/audits/{id}/audit-shift', [AuditController::class, 'auditShift']);
            Route::post('/audits/store-timeless-audit', [AuditController::class, 'storeTimelessAudit'])->name('audits.storeTimeless');

            Route::resource('audits', AuditController::class);

        //* Conexión con OTA's
            Route::get('/otas', [OTAConnectionController::class, 'index'])->name('otas.index');
            Route::get('/otas/{id}/edit', [OTAConnectionController::class, 'edit'])->name('otas.edit');

            Route::post('/otas/update', [OTAConnectionController::class, 'update'])->name('otas.update');
            Route::post('/otas/configure-room-type', [OTAConnectionController::class, 'configureRoomType'])->name('otas.configureRoomType');

            // Allotment Configuration
            Route::get('/otas/allotment-calendar', [AllotmentEventController::class, 'allotmentCalendar'])->name('otas.allotment-calendar');
            Route::get('/otas/allotment/{date}', [AllotmentEventController::class, 'getDateAllotment'])->name('otas.allotmentPerDate');
            Route::get('/otas/allotment-verification', [AllotmentEventController::class, 'checkExistence'])->name('otas.allotment.verification');
            Route::post('/otas/allotment-configuration', [AllotmentEventController::class, 'storeOrUpdate'])->name('otas.allotment.store');

      //? External Connections
          //* Api Banxico
            Route::get('/banxico/{code}', [CurrencyController::class,'getRate']);

          //* Api Postalia
            Route::get('/postalia/{zip}', [ZipCodeController::class, 'getAddressInformation']);
    });
