from django.urls import path
from . import views
from .penalty_views import (
    apply_manual_penalty,
    calculate_suggested_penalty,
    delete_penalty,
    penalty_history
)

app_name = 'loans'

urlpatterns = [
    path('', views.loans, name='loans'),
    path('filtered/', views.filtered_loans, name='filtered_loans'),
    path('rolled-over/', views.rolled_over_loans, name='rolled_over_loans'),
    path('applications/', views.loan_applications, name='applications'),
    path('applications/filtered/', views.filtered_applications, name='filtered_applications'),
    path('repayments/', views.repayments, name='repayments'),
    path('repayments/new/', views.new_repayment, name='new_repayment'),
    path('repayments/export/excel/', views.export_repayments_excel, name='export_repayments_excel'),
    path('repayments/export/pdf/', views.export_repayments_pdf, name='export_repayments_pdf'),
    path('completed/', views.completed_loans, name='completed_loans'),
    path('api/loan-data/', views.api_loan_data, name='api_loan_data'),
    path('api/recent-activity/', views.api_recent_activity, name='api_recent_activity'),
    path('ajax/', views.loans_ajax, name='loans_ajax'),
    path('new/', views.new_application, name='new_application'),
    path('add-existing/', views.add_existing_loan, name='add_existing_loan'),
    path('applications/<uuid:pk>/', views.application_detail, name='application_detail'),
    path('<uuid:pk>/', views.loan_detail, name='loan_detail'),
    path('<uuid:pk>/repay/', views.record_repayment, name='record_repayment'),
    path('<uuid:pk>/rollover/', views.request_rollover, name='request_rollover'),
    path('rollovers/', views.rollovers, name='rollovers'),
    path('rollovers/<uuid:pk>/approve/', views.approve_rollover, name='approve_rollover'),
    path('rollovers/<uuid:pk>/reject/', views.reject_rollover, name='reject_rollover'),
    path('<uuid:pk>/approve/', views.approve_application, name='approve_application'),
    path('<uuid:pk>/reject/', views.reject_application, name='reject_application'),
    path('<uuid:pk>/update-status/', views.update_loan_status, name='update_loan_status'),
    path('<uuid:pk>/edit/', views.edit_loan, name='edit_loan'),
    path('<uuid:pk>/delete/', views.delete_loan, name='delete_loan'),
    path('deleted/', views.deleted_loans, name='deleted_loans'),
    path('<uuid:pk>/restore/', views.restore_loan, name='restore_loan'),
    path('<uuid:pk>/permanently-delete/', views.permanently_delete_loan, name='permanently_delete_loan'),
    path('<uuid:pk>/refresh-payments/', views.refresh_loan_payments, name='refresh_loan_payments'),
    path('refresh-all-payments/', views.refresh_all_payments, name='refresh_all_payments'),
    path('<uuid:pk>/receipt/', views.loan_receipt, name='loan_receipt'),
    path('<uuid:pk>/amortization/', views.loan_amortization, name='loan_amortization'),
    path('<uuid:pk>/interest-schedule/', views.interest_schedule, name='interest_schedule'),
    path('repayments/<uuid:pk>/edit/', views.edit_repayment, name='edit_repayment'),
    path('repayments/<uuid:pk>/delete/', views.delete_repayment, name='delete_repayment'),
    
    # Penalty Management
    path('<uuid:loan_id>/penalty/apply/', apply_manual_penalty, name='apply_manual_penalty'),
    path('<uuid:loan_id>/penalty/calculate/', calculate_suggested_penalty, name='calculate_suggested_penalty'),
    path('<uuid:loan_id>/penalty/history/', penalty_history, name='penalty_history'),
    path('penalty/<uuid:penalty_id>/delete/', delete_penalty, name='delete_penalty'),
    
    # PDF Report Generation
    path('reports/pdf/loans-dashboard/', views.generate_loans_dashboard_pdf, name='generate_loans_dashboard_pdf'),
    path('reports/pdf/clients-dashboard/', views.generate_clients_dashboard_pdf, name='generate_clients_dashboard_pdf'),
    path('reports/pdf/payments-dashboard/', views.generate_payments_dashboard_pdf, name='generate_payments_dashboard_pdf'),
    path('reports/pdf/reports-dashboard/', views.generate_reports_dashboard_pdf, name='generate_reports_dashboard_pdf'),
    path('reports/pdf/portfolio-dashboard/', views.generate_portfolio_dashboard_pdf, name='generate_portfolio_dashboard_pdf'),
    path('reports/pdf/custom-analytics/', views.generate_custom_analytics_pdf, name='generate_custom_analytics_pdf'),
    path('analytics-dashboard/', views.analytics_dashboard, name='analytics_dashboard'),
]