aging inventory list pagination and total car count fix
This commit is contained in:
parent
490723c3f4
commit
4820ca1b04
@ -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):
|
||||
|
||||
@ -80,7 +80,7 @@
|
||||
{% if is_paginated %}
|
||||
<div class="d-flex justify-content-between mb-4">
|
||||
<span class="text-muted">{% trans "Page" %} {{ page_obj.number }} {% trans "of" %} {{ page_obj.paginator.num_pages }}</span>
|
||||
<span class="text-muted">{% trans "Total Aging Cars:" %} {{ page_obj.paginator.count }}</span>
|
||||
<span class="text-muted">{% trans "Total Aging Cars:" %} {{ count_of_aging_cars }}</span>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% if cars %}
|
||||
@ -118,12 +118,11 @@
|
||||
<div>{% trans "Excellent! There are no cars in the aging inventory at the moment." %}</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
<div class="d-flex justify-content-end mt-3">
|
||||
<div class="d-flex">
|
||||
|
||||
{% if is_paginated %}
|
||||
{% include 'partials/pagination.html' %}
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
{% endblock content %}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user