from django.urls import path
from . import views

urlpatterns = [
    path('', views.index, name='index'),
    path('inventory/', views.inventory, name='inventory'),
    path('pos/', views.pos, name='pos'),
    path('pos/customer-display/', views.customer_display, name='customer_display'),
    path('customers/', views.customers, name='customers'),
    path('suppliers/', views.suppliers, name='suppliers'),
    path('purchases/', views.purchases, name='purchases'),
    path('reports/', views.reports, name='reports'),
    path('reports/customer-statement/', views.customer_statement, name='customer_statement'),
    path('reports/supplier-statement/', views.supplier_statement, name='supplier_statement'),
    path('reports/cashflow/', views.cashflow_report, name='cashflow_report'),
    path('settings/', views.settings_view, name='settings'),
    path('profile/', views.profile_view, name='profile'),
    path('users/', views.user_management, name='user_management'),
    path('api/group-details/<int:pk>/', views.group_details_api, name='group_details_api'),
    
    # Invoices (Sales)
    path('invoices/', views.invoice_list, name='invoices'),
    path('invoices/create/', views.invoice_create, name='invoice_create'),
    path('invoices/<int:pk>/', views.invoice_detail, name='invoice_detail'),
    path('invoices/payment/<int:pk>/', views.add_sale_payment, name='add_sale_payment'),
    path('invoices/delete/<int:pk>/', views.delete_sale, name='delete_sale'),
    path('invoices/payments/', views.customer_payments, name='customer_payments'),
    path('invoices/receipt/<int:pk>/', views.customer_payment_receipt, name='customer_payment_receipt'),
    path('invoices/sale-receipt/<int:pk>/', views.sale_receipt, name='sale_receipt'),
    path("invoices/edit/<int:pk>/", views.edit_invoice, name="edit_invoice"),
    
    # Quotations
    path('quotations/', views.quotations, name='quotations'),
    path('quotations/create/', views.quotation_create, name='quotation_create'),
    path('quotations/<int:pk>/', views.quotation_detail, name='quotation_detail'),
    path('quotations/convert/<int:pk>/', views.convert_quotation_to_invoice, name='convert_quotation_to_invoice'),
    path('quotations/delete/<int:pk>/', views.delete_quotation, name='delete_quotation'),
    path('api/create-quotation/', views.create_quotation_api, name='create_quotation_api'),
    
    # Sales Returns
    path('sales/returns/', views.sales_returns, name='sales_returns'),
    path('sales/returns/create/', views.sale_return_create, name='sale_return_create'),
    path('sales/returns/<int:pk>/', views.sale_return_detail, name='sale_return_detail'),
    path('sales/returns/delete/<int:pk>/', views.delete_sale_return, name='delete_sale_return'),
    path('api/create-sale-return/', views.create_sale_return_api, name='create_sale_return_api'),
    
    # Purchases (Invoices)
    path('purchases/create/', views.purchase_create, name='purchase_create'),
    path('purchases/<int:pk>/', views.purchase_detail, name='purchase_detail'),
    path('purchases/payment/<int:pk>/', views.add_purchase_payment, name='add_purchase_payment'),
    path('purchases/delete/<int:pk>/', views.delete_purchase, name='delete_purchase'),
    path('purchases/payments/', views.supplier_payments, name='supplier_payments'),
    
    # Purchase Returns
    path('purchases/returns/', views.purchase_returns, name='purchase_returns'),
    path('purchases/returns/create/', views.purchase_return_create, name='purchase_return_create'),
    path('purchases/returns/<int:pk>/', views.purchase_return_detail, name='purchase_return_detail'),
    path('purchases/returns/delete/<int:pk>/', views.delete_purchase_return, name='delete_purchase_return'),
    path('api/create-purchase-return/', views.create_purchase_return_api, name='create_purchase_return_api'),
    
    # Expenses
    path('expenses/', views.expenses_view, name='expenses'),
    path('expenses/create/', views.expense_create_view, name='expense_create'),
    path('expenses/delete/<int:pk>/', views.expense_delete_view, name='expense_delete'),
    path('expenses/categories/', views.expense_categories_view, name='expense_categories'),
    path('expenses/categories/delete/<int:pk>/', views.expense_category_delete_view, name='expense_category_delete'),

    # API / Actions
    path('api/create-sale/', views.create_sale_api, name='create_sale_api'),
    path('api/update-sale/<int:pk>/', views.update_sale_api, name='update_sale_api'),
    path('api/create-purchase/', views.create_purchase_api, name='create_purchase_api'),
    
    # POS Held Sales
    path('api/hold-sale/', views.hold_sale_api, name='hold_sale_api'),
    path('api/held-sales/', views.get_held_sales_api, name='get_held_sales_api'),
    path('api/recall-held-sale/<int:pk>/', views.recall_held_sale_api, name='recall_held_sale_api'),
    path('api/delete-held-sale/<int:pk>/', views.delete_held_sale_api, name='delete_held_sale_api'),
    
    # Customers
    path('customers/add/', views.add_customer, name='add_customer'),
    path('customers/edit/<int:pk>/', views.edit_customer, name='edit_customer'),
    path('customers/delete/<int:pk>/', views.delete_customer, name='delete_customer'),
    path('api/add-customer-ajax/', views.add_customer_ajax, name='add_customer_ajax'),
    path('api/search-customers/', views.search_customers_api, name='search_customers_api'),
    
    # Suppliers
    path('suppliers/add/', views.add_supplier, name='add_supplier'),
    path('suppliers/edit/<int:pk>/', views.edit_supplier, name='edit_supplier'),
    path('suppliers/delete/<int:pk>/', views.delete_supplier, name='delete_supplier'),
    path('api/add-supplier-ajax/', views.add_supplier_ajax, name='add_supplier_ajax'),
    
    # Inventory
    path('inventory/suggest-sku/', views.suggest_sku, name='suggest_sku'),
    path('inventory/add/', views.add_product, name='add_product'),
    path('inventory/edit/<int:pk>/', views.edit_product, name='edit_product'),
    path('inventory/delete/<int:pk>/', views.delete_product, name='delete_product'),
    path('inventory/barcodes/', views.barcode_labels, name='barcode_labels'),
    path('inventory/import/', views.import_products, name='import_products'),
    
    # Categories
    path('inventory/category/add/', views.add_category, name='add_category'),
    path('inventory/category/edit/<int:pk>/', views.edit_category, name='edit_category'),
    path('inventory/category/delete/<int:pk>/', views.delete_category, name='delete_category'),
    path('api/add-category-ajax/', views.add_category_ajax, name='add_category_ajax'),
    
    # Units
    path('inventory/unit/add/', views.add_unit, name='add_unit'),
    path('inventory/unit/edit/<int:pk>/', views.edit_unit, name='edit_unit'),
    path('inventory/unit/delete/<int:pk>/', views.delete_unit, name='delete_unit'),
    path('api/add-unit-ajax/', views.add_unit_ajax, name='add_unit_ajax'),

    # Payment Methods
    path('settings/payment-methods/add/', views.add_payment_method, name='add_payment_method'),
    path('settings/payment-methods/edit/<int:pk>/', views.edit_payment_method, name='edit_payment_method'),
    path('settings/payment-methods/delete/<int:pk>/', views.delete_payment_method, name='delete_payment_method'),
    path('api/add-payment-method-ajax/', views.add_payment_method_ajax, name='add_payment_method_ajax'),

    # Loyalty
    path('settings/loyalty/add/', views.add_loyalty_tier, name='add_loyalty_tier'),
    path('settings/loyalty/edit/<int:pk>/', views.edit_loyalty_tier, name='edit_loyalty_tier'),
    path('settings/loyalty/delete/<int:pk>/', views.delete_loyalty_tier, name='delete_loyalty_tier'),
    path('api/customer-loyalty/<int:pk>/', views.get_customer_loyalty_api, name='get_customer_loyalty_api'),
    
    # WhatsApp
    path('api/send-invoice-whatsapp/', views.send_invoice_whatsapp, name='send_invoice_whatsapp'),
    path('api/test-whatsapp/', views.test_whatsapp_connection, name='test_whatsapp_connection'),

    # Devices
    path('settings/devices/add/', views.add_device, name='add_device'),
    path('settings/devices/edit/<int:pk>/', views.edit_device, name='edit_device'),
    path('settings/devices/delete/<int:pk>/', views.delete_device, name='delete_device'),

    # System Backup
    path('settings/backup/download/', views.backup_database, name='backup_database'),
    path('settings/backup/restore/', views.restore_database, name='restore_database'),
]