diff --git a/inventory/views.py b/inventory/views.py index 2387d62d..e887d375 100644 --- a/inventory/views.py +++ b/inventory/views.py @@ -775,8 +775,7 @@ def aging_inventory_list_view(request, dealer_slug): dealer=dealer, receiving_date__date__lt=today_local - timedelta(days=aging_threshold_days) ).exclude(status='sold') - total_aging_inventory_value=aging_cars_queryset.aggregate(total=Sum('cost_price'))['total'] - + # Apply filters to the queryset if they exist. Chaining is fine here. if selected_make: aging_cars_queryset = aging_cars_queryset.filter(id_car_make__name=selected_make) @@ -789,6 +788,9 @@ def aging_inventory_list_view(request, dealer_slug): if selected_stock_type: aging_cars_queryset = aging_cars_queryset.filter(stock_type=selected_stock_type) + total_aging_inventory_value=aging_cars_queryset.aggregate(total=Sum('cost_price'))['total'] + count_of_aging_cars = aging_cars_queryset.count() + # Get distinct values for filter dropdowns based on the initial, unfiltered aging cars queryset. # This ensures all possible filter options are always available. @@ -805,7 +807,7 @@ def aging_inventory_list_view(request, dealer_slug): # # Set up pagination - paginator = Paginator(aging_cars_queryset, 10) + paginator = Paginator(aging_cars_queryset, 1) page_number = request.GET.get('page') page_obj = paginator.get_page(page_number) @@ -826,7 +828,9 @@ def aging_inventory_list_view(request, dealer_slug): 'all_series': all_series, 'all_stock_types': all_stock_types, 'all_years': all_years, - 'total_aging_inventory_value':total_aging_inventory_value + 'total_aging_inventory_value':total_aging_inventory_value, + 'page_obj':page_obj, + 'count_of_aging_cars':count_of_aging_cars } @@ -7894,7 +7898,7 @@ class ItemExpenseListView(LoginRequiredMixin, PermissionRequiredMixin, ListView) model = ItemModel template_name = "items/expenses/expenses_list.html" context_object_name = "expenses" - paginate_by = 4 + paginate_by = 20 permission_required = ["django_ledger.view_itemmodel"] def get_queryset(self): diff --git a/templates/dashboards/aging_inventory_list.html b/templates/dashboards/aging_inventory_list.html index 54e9f5c5..7d34146b 100644 --- a/templates/dashboards/aging_inventory_list.html +++ b/templates/dashboards/aging_inventory_list.html @@ -80,7 +80,7 @@ {% if is_paginated %}