from django.urls import path
from . import views
from . import ajax_views
from . import api_views
from . import simple_chart_api

app_name = 'reports'

urlpatterns = [
    # Main dashboard
    path('', views.reports_dashboard, name='reports_dashboard'),
    path('clean/', views.clean_dashboard, name='clean_dashboard'),
    path('comprehensive/', views.comprehensive_dashboard, name='comprehensive_dashboard'),
    path('api-dashboard/', views.api_dashboard, name='api_dashboard'),
    path('legacy/', views.reports_dashboard, name='legacy_dashboard'),
    path('api/report-data/', views.api_report_data, name='api_report_data'),
    path('api/dashboard-data/', views.api_dashboard_data, name='api_dashboard_data'),
    
    # Enhanced API endpoints for dynamic data loading (Task 9)
    path('api/v2/dashboard-data/', api_views.DashboardDataAPI.as_view(), name='dashboard_data_api_v2'),
    path('api/v2/report-filter/', api_views.ReportFilterAPI.as_view(), name='report_filter_api'),
    path('api/v2/paginated-data/', api_views.PaginatedDataAPI.as_view(), name='paginated_data_api'),
    path('api/v2/real-time-refresh/', api_views.real_time_refresh_api, name='real_time_refresh_api'),
    path('api/v2/search/', api_views.search_api, name='search_api'),
    path('api/v2/export/', api_views.export_filtered_data_api, name='export_filtered_data_api'),
    path('api/v2/chart-data/', api_views.chart_data_api, name='chart_data_api'),
    path('api/simple-chart-data/', simple_chart_api.simple_chart_data, name='simple_chart_data'),
    
    # AJAX endpoints for real-time filtering
    path('api/filtered-data/', ajax_views.FilteredDataAPIView.as_view(), name='filtered_data_api'),
    path('api/chart-data/<str:report_type>/<str:chart_type>/', ajax_views.get_chart_data, name='get_chart_data'),
    path('api/chart-preferences/', ajax_views.update_chart_preferences, name='update_chart_preferences'),
    
    # Enhanced report views with interactive charts
    path('loans-due/', views.loans_due_today_report, name='loans_due_report'),
    path('loans-due/enhanced/', views.enhanced_loans_due_report, name='enhanced_loans_due_report'),
    path('loans-due/legacy/', views.loans_due_report, name='loans_due_report_legacy'),
    path('delinquent-loans/', views.enhanced_delinquent_loans_report, name='delinquent_loans_report'),
    path('delinquent-loans/enhanced/', views.enhanced_delinquent_loans_report, name='enhanced_delinquent_loans_report'),
    path('delinquent-loans/legacy/', views.delinquent_loans_report, name='delinquent_loans_report_legacy'),
    path('missed-payments/', views.missed_payments_report, name='missed_payments_report'),
    path('missed-payments/client/<uuid:client_id>/', views.missed_payments_detail, name='missed_payments_detail'),
    path('loans-in-arrears/', views.enhanced_arrears_report, name='loans_in_arrears_report'),
    path('loans-in-arrears/enhanced/', views.enhanced_arrears_report, name='enhanced_loans_in_arrears_report'),
    path('loans-in-arrears/legacy/', views.loans_in_arrears_report, name='loans_in_arrears_report_legacy'),
    path('processing-fees/', views.enhanced_processing_fees_report, name='processing_fees_report'),
    path('processing-fees/enhanced/', views.enhanced_processing_fees_report, name='enhanced_processing_fees_report'),
    path('processing-fees/legacy/', views.processing_fees_report, name='processing_fees_report_legacy'),
    path('interest-income/', views.enhanced_interest_income_report, name='interest_income_report'),
    path('interest-income/enhanced/', views.enhanced_interest_income_report, name='enhanced_interest_income_report'),
    path('interest-income/legacy/', views.interest_income_report, name='interest_income_report_legacy'),
    path('registration-fees/', views.enhanced_registration_fees_report, name='registration_fees_report'),
    path('registration-fees/enhanced/', views.enhanced_registration_fees_report, name='enhanced_registration_fees_report'),
    path('registration-fees/legacy/', views.registration_fees_report, name='registration_fees_report_legacy'),
    path('customer-requests-report/', views.customer_requests_report, name='customer_requests_report'),
    path('overdue-loans/', views.overdue_loans_report, name='overdue_loans_report'),
    path('completed-loans/', views.completed_loans_report, name='completed_loans_report'),
    path('disbursed-loans/', views.disbursed_loans_report, name='disbursed_loans_report'),
    path('age-gender-analytics/', views.age_gender_analytics_report, name='age_gender_analytics_report'),
    
    # Detailed views for dashboard metrics
    path('portfolio-details/', views.portfolio_details, name='portfolio_details'),
    path('outstanding-loans/', views.outstanding_loans, name='outstanding_loans'),
    path('collection-details/', views.collection_details, name='collection_details'),
    
    # Customer request management
    path('customer-requests/', views.customer_requests_list, name='customer_requests_list'),
    path('customer-requests/create/', views.create_customer_request, name='create_customer_request'),
    path('customer-requests/<uuid:pk>/', views.customer_request_detail, name='customer_request_detail'),
    path('customer-requests/analytics/', views.customer_requests_analytics, name='customer_requests_analytics'),
    path('customer-requests/search/', views.customer_requests_search, name='customer_requests_search'),
    path('customer-requests/bulk-update/', views.bulk_update_requests, name='bulk_update_requests'),
    
    # Registration fee management
    path('registration-fees/settings/', views.registration_fees_settings, name='registration_fees_settings'),
    path('registration-fees/record-payment/', views.record_registration_fee_payment, name='record_registration_fee_payment'),
    path('registration-fees/payment/<uuid:pk>/', views.registration_fee_payment_detail, name='registration_fee_payment_detail'),
    path('registration-fees/list/', views.registration_fees_list, name='registration_fees_list'),
    path('registration-fees/audit-trail/', views.registration_fee_audit_trail, name='registration_fee_audit_trail'),
    
    # Legacy report views (keeping for compatibility)
    path('borrowers/', views.borrower_reports, name='borrower_reports'),
    path('loans/', views.loan_reports, name='loan_reports'),
    path('collections/', views.collection_reports, name='collection_reports'),
    path('defaults/', views.default_reports, name='default_reports'),
    path('rollovers/', views.rollover_reports, name='rollover_reports'),
    path('export/<str:report_type>/', views.export_report, name='export_report'),
    path('loan-analytics/', views.loan_analytics_dashboard, name='loan_analytics_dashboard'),
    path('loan-analytics/report/', views.loan_analytics_report, name='loan_analytics_report'),
] 