<?php

declare(strict_types=1);

use App\Core\Middleware\AuthMiddleware;
use App\Core\Middleware\CsrfMiddleware;
use App\Controllers\BankAccountController;
use App\Controllers\BankTransactionController;
use App\Controllers\CashboxController;
use App\Controllers\CashPaymentController;
use App\Controllers\CheckAlertController;
use App\Controllers\CheckController;
use App\Modules\Expenses\Presentation\Controllers\ExpenseFormController;
use App\Modules\Expenses\Presentation\Controllers\ExpenseIndexController;
use App\Modules\Finance\Presentation\Controllers\CashPaymentCancelController;

$router->get('/finance/cashboxes', static function (): void { (new CashboxController())->index(); }, [new AuthMiddleware()]);
$router->get('/finance/cashboxes/form', static function (): void { (new CashboxController())->form(); }, [new AuthMiddleware()]);
$router->post('/finance/cashboxes/form', static function (): void { (new CashboxController())->form(); }, [new AuthMiddleware(), new CsrfMiddleware()]);
$router->get('/finance/cashboxes/ledger', static function (): void { (new CashboxController())->ledger(); }, [new AuthMiddleware()]);
$router->get('/finance/cashboxes/txn-form', static function (): void { (new CashboxController())->txnForm(); }, [new AuthMiddleware()]);
$router->post('/finance/cashboxes/txn-form', static function (): void { (new CashboxController())->txnForm(); }, [new AuthMiddleware(), new CsrfMiddleware()]);

$router->get('/finance/cash-payments', static function (): void { (new CashPaymentController())->index(); }, [new AuthMiddleware()]);
$router->get('/finance/cash-payments/form', static function (): void { (new CashPaymentController())->form(); }, [new AuthMiddleware()]);
$router->post('/finance/cash-payments/form', static function (): void { (new CashPaymentController())->form(); }, [new AuthMiddleware(), new CsrfMiddleware()]);
$router->get('/finance/cash-payments/view', static function (): void { (new CashPaymentController())->view(); }, [new AuthMiddleware()]);
$router->get('/finance/cash-payments/cancel', static function (): void { (new CashPaymentCancelController())->handle(); }, [new AuthMiddleware()]);
$router->post('/finance/cash-payments/cancel', static function (): void { (new CashPaymentCancelController())->handle(); }, [new AuthMiddleware(), new CsrfMiddleware()]);

$router->get('/finance/bank-accounts', static function (): void { (new BankAccountController())->index(); }, [new AuthMiddleware()]);
$router->get('/finance/bank-accounts/form', static function (): void { (new BankAccountController())->form(); }, [new AuthMiddleware()]);
$router->post('/finance/bank-accounts/form', static function (): void { (new BankAccountController())->form(); }, [new AuthMiddleware(), new CsrfMiddleware()]);

$router->get('/finance/bank-transactions', static function (): void { (new BankTransactionController())->index(); }, [new AuthMiddleware()]);
$router->get('/finance/bank-transactions/form', static function (): void { (new BankTransactionController())->form(); }, [new AuthMiddleware()]);
$router->post('/finance/bank-transactions/form', static function (): void { (new BankTransactionController())->form(); }, [new AuthMiddleware(), new CsrfMiddleware()]);

$router->get('/finance/checks', static function (): void { (new CheckController())->index(); }, [new AuthMiddleware()]);
$router->get('/finance/checks/receive', static function (): void { (new CheckController())->receiveForm(); }, [new AuthMiddleware()]);
$router->post('/finance/checks/receive', static function (): void { (new CheckController())->receiveForm(); }, [new AuthMiddleware(), new CsrfMiddleware()]);
$router->get('/finance/checks/view', static function (): void { (new CheckController())->view(); }, [new AuthMiddleware()]);
$router->get('/finance/checks/endorse', static function (): void { (new CheckController())->endorseForm(); }, [new AuthMiddleware()]);
$router->post('/finance/checks/endorse', static function (): void { (new CheckController())->endorseForm(); }, [new AuthMiddleware(), new CsrfMiddleware()]);
$router->get('/finance/checks/return', static function (): void { (new CheckController())->returnForm(); }, [new AuthMiddleware()]);
$router->post('/finance/checks/return', static function (): void { (new CheckController())->returnForm(); }, [new AuthMiddleware(), new CsrfMiddleware()]);
$router->get('/finance/checks/replace', static function (): void { (new CheckController())->replaceForm(); }, [new AuthMiddleware()]);
$router->post('/finance/checks/replace', static function (): void { (new CheckController())->replaceForm(); }, [new AuthMiddleware(), new CsrfMiddleware()]);
$router->get('/finance/checks/settle-cash', static function (): void { (new CheckController())->cashSettleForm(); }, [new AuthMiddleware()]);
$router->post('/finance/checks/settle-cash', static function (): void { (new CheckController())->cashSettleForm(); }, [new AuthMiddleware(), new CsrfMiddleware()]);
$router->get('/finance/checks/alerts', static function (): void { (new CheckAlertController())->handle(); }, [new AuthMiddleware()]);


$router->get('/finance/expenses/categories', static function (): void { (new ExpenseIndexController())->categories(); }, [new AuthMiddleware()]);
$router->get('/finance/expenses/categories/form', static function (): void { (new ExpenseFormController())->categoryForm(); }, [new AuthMiddleware()]);
$router->post('/finance/expenses/categories/form', static function (): void { (new ExpenseFormController())->categoryForm(); }, [new AuthMiddleware(), new CsrfMiddleware()]);
$router->get('/finance/expenses/items', static function (): void { (new ExpenseIndexController())->items(); }, [new AuthMiddleware()]);
$router->get('/finance/expenses/items/form', static function (): void { (new ExpenseFormController())->itemForm(); }, [new AuthMiddleware()]);
$router->post('/finance/expenses/items/form', static function (): void { (new ExpenseFormController())->itemForm(); }, [new AuthMiddleware(), new CsrfMiddleware()]);
