From 8f5472ec5295d6fa2227decb82e4c9f4a7d6ac89 Mon Sep 17 00:00:00 2001 From: Faheedkhan Date: Thu, 19 Jun 2025 17:15:18 +0300 Subject: [PATCH] ordered the txns based on debit listed first --- inventory/templatetags/custom_filters.py | 7 ++++--- inventory/views.py | 18 +++++++++++++----- templates/account/user_settings.html | 6 +++--- templates/crm/leads/lead_list.html | 17 +++++++++++------ templates/dealers/dealer_form.html | 6 +++--- .../plans/billing_info_create_or_update.html | 13 +++++++------ .../car_inventory_item_form.html | 2 +- templates/purchase_orders/po_list.html | 2 +- templates/purchase_orders/po_upload_cars.html | 4 ++-- templates/users/user_list.html | 2 +- templates/vendors/vendors_list.html | 2 +- 11 files changed, 47 insertions(+), 32 deletions(-) diff --git a/inventory/templatetags/custom_filters.py b/inventory/templatetags/custom_filters.py index 9d91344b..965ac3ca 100644 --- a/inventory/templatetags/custom_filters.py +++ b/inventory/templatetags/custom_filters.py @@ -412,8 +412,8 @@ def transactions_table(object_type: Union[JournalEntryModel, BillModel, InvoiceM output_field=IntegerField() ) ).order_by( - 'timestamp', # Primary sort: chronological (oldest first) - 'debit_credit_sort_order', # Secondary sort: Debits (0) before Credits (1) + '-timestamp', # Primary sort: chronological (oldest first) + '-debit_credit_sort_order', # Secondary sort: Debits (0) before Credits (1) 'pk' # Optional: Tie-breaker for consistent order ) elif isinstance(object_type, InvoiceModel): @@ -529,4 +529,5 @@ def get_vehicle_type_name(car_serie): elif 'liftback' in serie_lower: return 'liftback' else: - return 'sedan' \ No newline at end of file + return 'sedan' + \ No newline at end of file diff --git a/inventory/views.py b/inventory/views.py index 8c653a3b..8927a6a8 100644 --- a/inventory/views.py +++ b/inventory/views.py @@ -67,6 +67,7 @@ from django.views.generic import ( ArchiveIndexView, ) +from django.db.models import Case, Value, IntegerField, When # Django Ledger from django_ledger.io import roles @@ -8123,6 +8124,7 @@ class JournalEntryListView(LoginRequiredMixin, ListView): model = JournalEntryModel context_object_name = "journal_entries" template_name = "ledger/journal_entry/journal_entry_list.html" + ordering=['-timestamp'] def get_queryset(self): qs = super().get_queryset() @@ -8229,11 +8231,17 @@ def JournalEntryTransactionsView(request, pk): :rtype: django.http.HttpResponse """ journal = JournalEntryModel.objects.filter(pk=pk).first() - transactions = ( - TransactionModel.objects.filter(journal_entry=journal) - .order_by("account__code") - .all() - ) + # transactions = ( + # TransactionModel.objects.filter(journal_entry=journal) + # .order_by("account__code") + # .all() + # ) + qs=TransactionModel.objects.filter(journal_entry=journal).all() + transactions=qs.annotate( + debit_credit_sort_order=Case(When(tx_type='debit',then=Value(0)), + When(tx_type='credit',then=Value(1)), + output_field=IntegerField()) + ).order_by('debit_credit_sort_order') return render( request, "ledger/journal_entry/journal_entry_transactions.html", diff --git a/templates/account/user_settings.html b/templates/account/user_settings.html index 366114f2..9842c9bb 100644 --- a/templates/account/user_settings.html +++ b/templates/account/user_settings.html @@ -9,9 +9,9 @@
{% csrf_token %}
-
+
-
+

Default Invoice Accounts

@@ -25,7 +25,7 @@
-
+

Default Bill Accounts

diff --git a/templates/crm/leads/lead_list.html b/templates/crm/leads/lead_list.html index db95d153..ee08f36e 100644 --- a/templates/crm/leads/lead_list.html +++ b/templates/crm/leads/lead_list.html @@ -231,19 +231,24 @@ {% endfor %} - {% endif %} +
-
-
-
-
+
+
{% if is_paginated %} {% include 'partials/pagination.html' %} {% endif %} +
+ {% else %} + + {% trans "No Lead Yet" %} + + {% endif %}
-
+
+
{% endblock %} diff --git a/templates/dealers/dealer_form.html b/templates/dealers/dealer_form.html index 79e0d891..54a0dcc1 100644 --- a/templates/dealers/dealer_form.html +++ b/templates/dealers/dealer_form.html @@ -9,14 +9,14 @@
-

{{ _("Update Dealer Information") }}

+

{{ _("Update Dealer Information") }}

{% csrf_token %} {{ form|crispy }}
- {% trans "Cancel" %} diff --git a/templates/plans/billing_info_create_or_update.html b/templates/plans/billing_info_create_or_update.html index 79010cdc..e2d07dab 100644 --- a/templates/plans/billing_info_create_or_update.html +++ b/templates/plans/billing_info_create_or_update.html @@ -7,16 +7,17 @@
- {% trans "Provide billing data"|upper %} + {% comment %} {% trans "Provide billing data"|upper %} {% endcomment %} +

{% trans "Provide billing data"|upper %}

{% csrf_token %} {{ form|crispy }} - {% if object %} - {{ _("Delete") }} - {% endif %} - - + {% if object %} + {{ _("Delete") }} + {% endif %}
diff --git a/templates/purchase_orders/car_inventory_item_form.html b/templates/purchase_orders/car_inventory_item_form.html index 2bc04cff..67efd78e 100644 --- a/templates/purchase_orders/car_inventory_item_form.html +++ b/templates/purchase_orders/car_inventory_item_form.html @@ -107,7 +107,7 @@
-
+

{% trans 'Exterior Colors' %}

{% for color in form.fields.exterior.queryset %} diff --git a/templates/purchase_orders/po_list.html b/templates/purchase_orders/po_list.html index c0f48569..73ba0350 100644 --- a/templates/purchase_orders/po_list.html +++ b/templates/purchase_orders/po_list.html @@ -42,7 +42,7 @@ {% if purchase_orders %} {% for po in purchase_orders %} - {{ po.po_number }} + {{ po.po_number }} {{ po.po_title }} diff --git a/templates/purchase_orders/po_upload_cars.html b/templates/purchase_orders/po_upload_cars.html index 7a3ffefb..63a49990 100644 --- a/templates/purchase_orders/po_upload_cars.html +++ b/templates/purchase_orders/po_upload_cars.html @@ -10,9 +10,9 @@ {% if po.po_status == 'draft' %}

{{ po.po_status|capfirst }}

{% elif po.po_status == 'in_review' %} -

{{ po.po_status|capfirst }}

+

{{ po.po_status|capfirst }}

{% elif po.po_status == 'approved' %} -

{{ po.po_status|capfirst }}

+

{{ po.po_status|capfirst }}

{% elif po.po_status == 'fulfilled' %}

{{ po.po_status|capfirst }}

{% elif po.po_status == 'void' %} diff --git a/templates/users/user_list.html b/templates/users/user_list.html index 73523e74..22aebed5 100644 --- a/templates/users/user_list.html +++ b/templates/users/user_list.html @@ -15,7 +15,7 @@ {% trans "Add New Staff" %} {% trans "Manage Groups & Permissions" %} {% else %} -