# inventory/urls.py (add to existing urls)
from django.urls import path
from . import views
from .api import product_list_json

app_name = 'inventory'

urlpatterns = [
    path('', views.inventory_dashboard, name='dashboard'),
    path('products/', views.product_list, name='product_list'),
    path('products/add/', views.add_product, name='add_product'),
    path('products/<int:product_id>/', views.product_detail, name='product_detail'),
    path('products/<int:product_id>/edit/', views.edit_product, name='edit_product'),
    path('products/<int:product_id>/toggle-visibility/', views.toggle_product_visibility, name='toggle_product_visibility'),

    # -- Product Variants --
    path('products/<int:product_id>/variants/',                       views.product_variants,        name='product_variants'),
    path('products/<int:product_id>/variants/<int:variant_id>/',      views.variant_edit,            name='variant_edit'),
    path('products/<int:product_id>/variants/<int:variant_id>/restock/', views.variant_restock,     name='variant_restock'),
    path('api/products/<int:product_id>/variants/json/',              views.api_variants_for_product, name='api_variants_json'),
    path('products/barcodes/', views.barcode_center, name='barcode_center'),
    path('products/<int:product_id>/adjust-stock/', views.adjust_stock, name='adjust_stock'),
    path('products/<int:product_id>/restock/', views.restock_product, name='restock_product'),
    path('products/<int:product_id>/reduce-stock/', views.reduce_stock, name='reduce_stock'),
    path('products/<int:product_id>/barcode/', views.print_product_barcode, name='print_product_barcode'),
    
    #Categories
    path('categories/', views.product_category_list, name='category_list'),
    path('categories/add/', views.add_category, name='add_category'),
    path('stock-history/', views.stock_adjustment_history, name='stock_adjustment_history'),

    #Export and Import
    path('products/import/', views.product_bulk_import, name='product_bulk_import'),
    path('products/import/template/', views.product_import_template, name='product_import_template'),
    path('export/', views.export_center, name='export_center'),
    path('export/products/', views.product_bulk_export, name='product_bulk_export'),
    path('export/categories/', views.category_bulk_export, name='category_bulk_export'),
    path('export/stock-movements/', views.inventory_transactions_export, name='inventory_transactions_export'),
    path('export/stock-adjustments/', views.stock_adjustments_export, name='stock_adjustments_export'),

    path("api/products/json/", product_list_json, name="product_list_json"),

    # Suppliers
    path("suppliers/", views.supplier_list, name="supplier_list"),
    path("suppliers/add/", views.supplier_create, name="supplier_create"),
    path('suppliers/<int:supplier_id>/payment/', views.supplier_record_payment, name='supplier_record_payment'),
    path("suppliers/<int:supplier_id>/", views.supplier_detail, name="supplier_detail"),
    path("suppliers/<int:supplier_id>/edit/", views.supplier_edit, name="supplier_edit"),
    path("suppliers/<int:supplier_id>/delete/", views.supplier_delete, name="supplier_delete"),

    # Purchase Orders
    path("purchase-orders/", views.purchase_order_list, name="purchase_order_list"),
    path("purchase-orders/add/<int:supplier_id>/", views.purchase_order_create, name="purchase_order_create"),
    path("purchase-orders/add/", views.purchase_order_create, name="purchase_order_create"),
    path("purchase-orders/<int:order_id>/", views.purchase_order_detail, name="purchase_order_detail"),
    path("purchase-orders/<int:order_id>/receive/", views.purchase_order_mark_received, name="purchase_order_mark_received"),

]