from django.urls import include, path, re_path
from rest_framework.routers import DefaultRouter

from apps.treasury.cheques.views import (
    ChequeAssetLedgerView,
    ChequeAttachmentView,
    ChequeBookCenterViewSet,
    ChequeClearingWorkbenchView,
    ChequeDashboardView,
    ChequeDepositBatchViewSet,
    ChequeGovernanceListView,
    ChequeInspectorDetailView,
    ChequeLeafCenterViewSet,
    ChequeLifecycleActionView,
    ChequeReportsView,
    ChequeReturnsViewSet,
    IssuedChequeViewSet,
    ReceivedChequeViewSet,
)

router = DefaultRouter()
router.register("books", ChequeBookCenterViewSet, basename="cheques-books")
router.register("leaves", ChequeLeafCenterViewSet, basename="cheques-leaves")
router.register("issued", IssuedChequeViewSet, basename="cheques-issued")
router.register("received", ReceivedChequeViewSet, basename="cheques-received")
router.register("deposit-batches", ChequeDepositBatchViewSet, basename="cheques-deposit-batches")
router.register("returns", ChequeReturnsViewSet, basename="cheques-returns")

urlpatterns = [
    path("dashboard/", ChequeDashboardView.as_view(), name="cheques-dashboard"),
    path("clearing-workbench/", ChequeClearingWorkbenchView.as_view(), name="cheques-clearing-workbench"),
    path("ledgers/<str:stage>/", ChequeAssetLedgerView.as_view(), name="cheques-asset-ledger"),
    path("reports/", ChequeReportsView.as_view(), name="cheques-reports"),
    path("governance/<str:kind>/", ChequeGovernanceListView.as_view(), name="cheques-governance"),
    path("<uuid:pk>/attachments/", ChequeAttachmentView.as_view(), name="cheques-attachments"),
    path("<uuid:pk>/lifecycle/", ChequeInspectorDetailView.as_view(), {"tab_name": "lifecycle"}, name="cheques-lifecycle"),
    path(
        "<uuid:pk>/accounting-impact/",
        ChequeInspectorDetailView.as_view(),
        {"tab_name": "accounting-impact"},
        name="cheques-accounting-impact",
    ),
    re_path(
        r"^(?P<pk>[0-9a-f-]+)/(?P<action_name>reserve|release-reservation|verify|deposit|confirm-clearing|bounce|approve-bounce|cancel|replace)/?$",
        ChequeLifecycleActionView.as_view(),
        name="cheques-action",
    ),
    path("", include(router.urls)),
]
