# finance/urls.py
from django.urls import path
from . import views

app_name = 'finance'

urlpatterns = [

    # ── Bursar Dashboard ────────────────────────────────────────────────────
    path('bursar/', views.BursarDashboardView.as_view(), name='bursar_dashboard'),

    # ── Fee Structures ──────────────────────────────────────────────────────
    path('fees/',                    views.FeeStructureListView.as_view(),   name='fee_list'),
    path('fees/add/',                views.FeeStructureCreateView.as_view(), name='fee_add'),
    path('fees/<int:pk>/',           views.FeeStructureDetailView.as_view(), name='fee_detail'),
    path('fees/<int:pk>/edit/',      views.FeeStructureUpdateView.as_view(), name='fee_edit'),
    path('fees/<int:pk>/delete/',    views.FeeStructureDeleteView.as_view(), name='fee_delete'),

    # ── School Item Prices (uniforms, sportswear, report card, pullovers) ───
    path('school-items/',            views.SchoolItemPriceListView.as_view(),   name='school_item_list'),
    path('school-items/add/',        views.SchoolItemPriceCreateView.as_view(), name='school_item_add'),
    path('school-items/<int:pk>/edit/', views.SchoolItemPriceUpdateView.as_view(), name='school_item_edit'),

    # ── Student Enrollment Fees ─────────────────────────────────────────────
    path('enrollment-fees/',         views.StudentEnrollmentFeeListView.as_view(),   name='enrollment_fee_list'),
    path('enrollment-fees/add/',     views.StudentEnrollmentFeeCreateView.as_view(), name='enrollment_fee_add'),

    # ── Invoices ────────────────────────────────────────────────────────────
    path('invoices/',                views.InvoiceListView.as_view(),   name='invoice_list'),
    path('invoices/create/',         views.InvoiceCreateView.as_view(), name='invoice_create'),
    path('invoices/bulk/',           views.BulkInvoiceGenerateView.as_view(), name='bulk_invoice'),
    path('invoices/export/',         views.export_invoices_csv,         name='export_invoices'),
    path('invoices/<int:pk>/',       views.InvoiceDetailView.as_view(), name='invoice_detail'),
    path('invoices/<int:pk>/edit/',  views.InvoiceUpdateView.as_view(), name='invoice_edit'),
    path('invoices/<int:pk>/delete/', views.InvoiceDeleteView.as_view(), name='invoice_delete'),
    path('invoices/<int:pk>/send/',  views.mark_invoice_as_sent,        name='invoice_send'),
    path('invoices/<int:pk>/remind/', views.send_payment_reminder,      name='invoice_remind'),

    # ── Payments ────────────────────────────────────────────────────────────
    path('payments/',                views.PaymentListView.as_view(),   name='payment_list'),
    path('payments/add/',            views.PaymentCreateView.as_view(), name='payment_add'),
    path('payments/export/',         views.export_payments_csv,         name='export_payments'),
    path('payments/<int:pk>/',       views.PaymentDetailView.as_view(), name='payment_detail'),
    path('payments/<int:pk>/edit/',  views.PaymentUpdateView.as_view(), name='payment_edit'),
    path('payments/<int:pk>/receipt/', views.generate_receipt,          name='generate_receipt'),

    # ── Expenses ────────────────────────────────────────────────────────────
    path('expenses/',                views.ExpenseListView.as_view(),   name='expense_list'),
    path('expenses/add/',            views.ExpenseCreateView.as_view(), name='expense_add'),
    path('expenses/<int:pk>/edit/',  views.ExpenseUpdateView.as_view(), name='expense_edit'),
    path('expenses/<int:pk>/approve/', views.approve_expense,           name='expense_approve'),
    path('expenses/categories/',     views.ExpenseCategoryListView.as_view(), name='expense_categories'),

    # ── Discounts ───────────────────────────────────────────────────────────
    path('discounts/',               views.DiscountListView.as_view(),        name='discount_list'),
    path('discounts/add/',           views.DiscountCreateView.as_view(),      name='discount_add'),
    path('discounts/student/add/',   views.StudentDiscountCreateView.as_view(), name='student_discount_add'),

    # ── Reports ─────────────────────────────────────────────────────────────
    path('reports/',                 views.FinancialReportsView.as_view(),    name='financial_reports'),
    path('reports/generate/',        views.generate_financial_report,         name='generate_report'),

    # ── API ─────────────────────────────────────────────────────────────────
    path('api/stats/',               views.get_finance_stats,                 name='finance_stats'),
]