<?php

declare(strict_types=1);

use Illuminate\Support\Facades\Route;
use Maestro\Core\Modules\Invoices\Http\Controllers\InvoiceController;
use Maestro\Core\Modules\Invoices\Http\Controllers\VatRateController;

Route::middleware(['web', 'auth:sanctum', 'maestro.module:invoices'])
    ->prefix('api/invoices')
    ->group(function (): void {
        Route::get('/meta', [InvoiceController::class, 'meta']);

        Route::get('/vat-rates', [VatRateController::class, 'index']);
        Route::post('/vat-rates', [VatRateController::class, 'store']);
        Route::patch('/vat-rates/{vatRate}', [VatRateController::class, 'update']);
        Route::delete('/vat-rates/{vatRate}', [VatRateController::class, 'destroy']);

        Route::get('/', [InvoiceController::class, 'index']);
        Route::post('/', [InvoiceController::class, 'store']);

        Route::get('/{invoice}/pdf', [InvoiceController::class, 'pdf']);
        Route::post('/{invoice}/send', [InvoiceController::class, 'send']);
        Route::post('/{invoice}/book', [InvoiceController::class, 'book']);
        Route::post('/{invoice}/send-copy', [InvoiceController::class, 'sendCopy']);

        Route::patch('/{invoice}', [InvoiceController::class, 'update']);
        Route::delete('/{invoice}', [InvoiceController::class, 'destroy']);
        Route::get('/{invoice}', [InvoiceController::class, 'show']);
    });
