from django.urls import path

from .views import (
    # =========================================================
    # AUTH
    # =========================================================
    LoginAPIView,
    ForgotPasswordAPIView,
    ResetPasswordAPIView,

    # =========================================================
    # ADMIN DASHBOARD
    # =========================================================
    DashboardAPIView,

    # =========================================================
    # BUSINESS
    # =========================================================
    BusinessListCreateAPIView,
    BusinessDetailAPIView,
    BusinessDocumentCreateAPIView,
    BusinessDocumentListAPIView,
    BusinessInvestorsAPIView,

    # =========================================================
    # INVESTOR
    # =========================================================
    InvestorDocumentListAPIView,
    InvestorListCreateAPIView,
    InvestorDetailAPIView,
    InvestorPortfolioAPIView,

    # =========================================================
    # SCHEME
    # =========================================================
    SchemeListCreateAPIView,
    SchemeDetailAPIView,

    # =========================================================
    # KUBER -> BUSINESS INVESTMENT
    # =========================================================
    KuberBusinessInvestmentListCreateAPIView,
    KuberBusinessInvestmentDetailAPIView,
    BusinessCreditProfitAPIView,
    KuberBusinessPayoutAPIView,

    # =========================================================
    # INVESTMENT
    # =========================================================
    InvestmentListCreateAPIView,
    InvestmentDetailAPIView,

    # =========================================================
    # BALANCE SHEET
    # =========================================================
    BalanceSheetListCreateAPIView,
    BalanceSheetDetailAPIView,
    DailyFinancialStatementListCreateAPIView,
    DailyFinancialStatementDetailAPIView,

    # =========================================================
    # LEDGER
    # =========================================================
    LedgerListAPIView,
    GenerateDailyLedgerAPIView,

    # =========================================================
    # PAYOUT
    # =========================================================
    PayoutListCreateAPIView,

    # =========================================================
    # CERTIFICATE
    # =========================================================
    CertificateListCreateAPIView,
    CertificateDetailAPIView,
    CertificateAttachmentDeleteAPIView,

    # =========================================================
    # ACCOUNTANT
    # =========================================================
    AccountantListCreateAPIView,
    AccountantDetailAPIView,
    AccountantPermissionAPIView,

    # =========================================================
    # RECURRING CONTRIBUTION
    # =========================================================
    RecurringContributionListCreateAPIView,
    RecurringContributionDetailAPIView,

    # =========================================================
    # AUDIT / RESTORE
    # =========================================================
    AuditLogListAPIView,
    RestoreBinAPIView,
    RestoreItemAPIView,

    # =========================================================
    # EXPORT
    # =========================================================
    ExportInvestmentsAPIView,
    ExportLedgerAPIView,

    # =========================================================
    # BUSINESS PORTAL
    # =========================================================
    BusinessPortalMeAPIView,
    BusinessPortalDashboardAPIView,
    BusinessPortalInvestorsAPIView,
    BusinessPortalInvestmentsAPIView,
    BusinessPortalKuberInvestmentsAPIView,
    BusinessPortalBalanceSheetsAPIView,
    BusinessPortalFinancialStatementsAPIView,
    BusinessPortalLedgerAPIView,

    # =========================================================
    # INVESTOR PORTAL
    # =========================================================
    InvestorPortalDashboardAPIView,
    InvestorPortalExportAPIView,
    InvestorPortalAvailableSchemesAPIView,
    InvestorPortalAvailableBusinessesAPIView,
    InvestorPortalProfileAPIView,
    InvestorPortalInvestmentsAPIView,
    InvestorPortalCertificatesAPIView,
    InvestorPortalBusinessPerformanceAPIView,
    BusinessPerformanceDashboardAPIView,
)


urlpatterns = [
    path(
        "business-performance/",
        BusinessPerformanceDashboardAPIView.as_view(),
        name="business-performance-dashboard",
    ),


    # =========================================================
    # AUTH
    # =========================================================

    path(
        "auth/login/",
        LoginAPIView.as_view(),
        name="auth-login",
    ),

    path(
        "auth/forgot-password/",
        ForgotPasswordAPIView.as_view(),
        name="auth-forgot-password",
    ),

    path(
        "auth/reset-password/",
        ResetPasswordAPIView.as_view(),
        name="auth-reset-password",
    ),


    # =========================================================
    # ADMIN DASHBOARD
    # =========================================================

    path(
        "dashboard/",
        DashboardAPIView.as_view(),
        name="admin-dashboard",
    ),


    # =========================================================
    # BUSINESS PORTAL
    #
    # These endpoints are ONLY for the logged-in BUSINESS user.
    # They must NOT use the Admin business endpoints.
    # =========================================================

    path(
        "business-portal/me/",
        BusinessPortalMeAPIView.as_view(),
        name="business-portal-me",
    ),

    path(
        "business-portal/dashboard/",
        BusinessPortalDashboardAPIView.as_view(),
        name="business-portal-dashboard",
    ),

    path(
        "business-portal/investors/",
        BusinessPortalInvestorsAPIView.as_view(),
        name="business-portal-investors",
    ),

    path(
        "business-portal/investments/",
        BusinessPortalInvestmentsAPIView.as_view(),
        name="business-portal-investments",
    ),

    path(
        "business-portal/kuber-investments/",
        BusinessPortalKuberInvestmentsAPIView.as_view(),
        name="business-portal-kuber-investments",
    ),

    path(
        "business-portal/balance-sheets/",
        BusinessPortalBalanceSheetsAPIView.as_view(),
        name="business-portal-balance-sheets",
    ),

    path(
        "business-portal/financial-statements/",
        BusinessPortalFinancialStatementsAPIView.as_view(),
        name="business-portal-financial-statements",
    ),

    path(
        "business-portal/ledger/",
        BusinessPortalLedgerAPIView.as_view(),
        name="business-portal-ledger",
    ),


    # =========================================================
    # ADMIN BUSINESS MANAGEMENT
    # =========================================================

    path(
        "businesses/",
        BusinessListCreateAPIView.as_view(),
        name="business-list-create",
    ),

    path(
        "businesses/<int:pk>/",
        BusinessDetailAPIView.as_view(),
        name="business-detail",
    ),

    path(
        "businesses/<int:business_id>/documents/",
        BusinessDocumentListAPIView.as_view(),
        name="business-documents",
    ),

    path(
        "businesses/<int:business_id>/documents/add/",
        BusinessDocumentCreateAPIView.as_view(),
        name="business-document-add",
    ),

    path(
        "businesses/<int:business_id>/investors/",
        BusinessInvestorsAPIView.as_view(),
        name="business-investors",
    ),


    # =========================================================
    # ADMIN INVESTOR MANAGEMENT
    # =========================================================

    path(
        "investors/",
        InvestorListCreateAPIView.as_view(),
        name="investor-list-create",
    ),

    path(
        "investors/<int:pk>/",
        InvestorDetailAPIView.as_view(),
        name="investor-detail",
    ),

    path(
        "investors/<int:pk>/portfolio/",
        InvestorPortfolioAPIView.as_view(),
        name="investor-portfolio",
    ),

    path(
        "investors/<int:investor_id>/documents/",
        InvestorDocumentListAPIView.as_view(),
        name="investor-documents",
    ),


    # =========================================================
    # SCHEMES
    # =========================================================

    path(
        "schemes/",
        SchemeListCreateAPIView.as_view(),
        name="scheme-list-create",
    ),

    path(
        "schemes/<int:pk>/",
        SchemeDetailAPIView.as_view(),
        name="scheme-detail",
    ),


    # =========================================================
    # KUBER -> BUSINESS INVESTMENTS
    # =========================================================

    path(
        "kuber-investments/",
        KuberBusinessInvestmentListCreateAPIView.as_view(),
        name="kuber-business-investment-list-create",
    ),

    path(
        "kuber-investments/<int:pk>/",
        KuberBusinessInvestmentDetailAPIView.as_view(),
        name="kuber-business-investment-detail",
    ),

    path(
        "business-credit-profit/",
        BusinessCreditProfitAPIView.as_view(),
        name="business-credit-profit",
    ),

    path(
        "kuber-business-payout/",
        KuberBusinessPayoutAPIView.as_view(),
        name="kuber-business-payout",
    ),


    # =========================================================
    # INVESTMENTS
    # =========================================================

    path(
        "investments/",
        InvestmentListCreateAPIView.as_view(),
        name="investment-list-create",
    ),

    path(
        "investments/<int:pk>/",
        InvestmentDetailAPIView.as_view(),
        name="investment-detail",
    ),

    path(
        "investments/<int:investment_id>/recurring-contributions/",
        RecurringContributionListCreateAPIView.as_view(),
        name="recurring-contribution-list-create",
    ),

    path(
        "investments/<int:investment_id>/recurring-contributions/<int:pk>/",
        RecurringContributionDetailAPIView.as_view(),
        name="recurring-contribution-detail",
    ),


    # =========================================================
    # BALANCE SHEETS
    # =========================================================

    path(
        "balance-sheets/",
        BalanceSheetListCreateAPIView.as_view(),
        name="balance-sheet-list-create",
    ),

    path(
        "balance-sheets/<int:pk>/",
        BalanceSheetDetailAPIView.as_view(),
        name="balance-sheet-detail",
    ),

    path(
        "daily-financial-statements/",
        DailyFinancialStatementListCreateAPIView.as_view(),
        name="daily-financial-statement-list-create",
    ),

    path(
        "daily-financial-statements/<int:pk>/",
        DailyFinancialStatementDetailAPIView.as_view(),
        name="daily-financial-statement-detail",
    ),


    # =========================================================
    # LEDGER
    # =========================================================

    path(
        "ledger/",
        LedgerListAPIView.as_view(),
        name="ledger-list",
    ),

    path(
        "ledger/generate-daily/",
        GenerateDailyLedgerAPIView.as_view(),
        name="ledger-generate-daily",
    ),


    # =========================================================
    # PAYOUTS
    # =========================================================

    path(
        "payouts/",
        PayoutListCreateAPIView.as_view(),
        name="payout-list-create",
    ),


    # =========================================================
    # CERTIFICATES
    # =========================================================

    path(
        "certificates/",
        CertificateListCreateAPIView.as_view(),
        name="certificate-list-create",
    ),

    path(
        "certificates/<int:pk>/",
        CertificateDetailAPIView.as_view(),
        name="certificate-detail",
    ),

    path(
        "certificates/<int:pk>/attachments/<int:attachment_id>/",
        CertificateAttachmentDeleteAPIView.as_view(),
        name="certificate-attachment-delete",
    ),


    # =========================================================
    # ACCOUNTANTS
    # =========================================================

    path(
        "accountants/",
        AccountantListCreateAPIView.as_view(),
        name="accountant-list-create",
    ),

    path(
        "accountants/<int:pk>/",
        AccountantDetailAPIView.as_view(),
        name="accountant-detail",
    ),

    path(
        "accountants/<int:pk>/permissions/",
        AccountantPermissionAPIView.as_view(),
        name="accountant-permissions",
    ),


    # =========================================================
    # AUDIT
    # =========================================================

    path(
        "audit/",
        AuditLogListAPIView.as_view(),
        name="audit-list",
    ),


    # =========================================================
    # RESTORE
    # =========================================================

    path(
        "restore-bin/",
        RestoreBinAPIView.as_view(),
        name="restore-bin",
    ),

    path(
        "restore/<str:resource>/<int:pk>/",
        RestoreItemAPIView.as_view(),
        name="restore-item",
    ),


    # =========================================================
    # EXPORTS
    # =========================================================

    path(
        "exports/investments.xlsx",
        ExportInvestmentsAPIView.as_view(),
        name="export-investments",
    ),

    path(
        "exports/ledger/",
        ExportLedgerAPIView.as_view(),
        name="export-ledger",
    ),


    # =========================================================
    # INVESTOR PORTAL
    # =========================================================

    path(
        "investor-portal/dashboard/",
        InvestorPortalDashboardAPIView.as_view(),
        name="investor-portal-dashboard",
    ),

    path(
        "investor-portal/me/",
        InvestorPortalProfileAPIView.as_view(),
        name="investor-portal-me",
    ),

    path(
        "investor-portal/investments/",
        InvestorPortalInvestmentsAPIView.as_view(),
        name="investor-portal-investments",
    ),

    path(
        "investor-portal/businesses/",
        InvestorPortalAvailableBusinessesAPIView.as_view(),
        name="investor-portal-businesses",
    ),

    path(
        "investor-portal/schemes/",
        InvestorPortalAvailableSchemesAPIView.as_view(),
        name="investor-portal-schemes",
    ),

    path(
        "investor-portal/export/",
        InvestorPortalExportAPIView.as_view(),
        name="investor-portal-export",
    ),

    path(
        "investor-portal/business-performance/",
        InvestorPortalBusinessPerformanceAPIView.as_view(),
        name="investor-portal-business-performance",
    ),

    path(
        "investor-portal/certificates/",
        InvestorPortalCertificatesAPIView.as_view(),
        name="investor-portal-certificates",
    ),
]