From b75534b6016ab3e518bafb0f6fcf02de19de6507 Mon Sep 17 00:00:00 2001 From: Faheedkhan Date: Wed, 18 Jun 2025 13:21:25 +0300 Subject: [PATCH 1/6] update1 --- templates/bill/transactions/tags/txs_table.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/templates/bill/transactions/tags/txs_table.html b/templates/bill/transactions/tags/txs_table.html index ccf6762f..c0e9cd70 100644 --- a/templates/bill/transactions/tags/txs_table.html +++ b/templates/bill/transactions/tags/txs_table.html @@ -18,13 +18,13 @@ {% for transaction_model in transaction_model_qs %} - {{ transaction_model.timestamp }} + {{ transaction_model.timestamp }} {{ transaction_model.account_code }} {{ transaction_model.account_name }} {% if transaction_model.entity_unit_name %}{{ transaction_model.entity_unit_name }}{% endif %} {% if transaction_model.is_credit %}${{ transaction_model.amount | currency_format }}{% endif %} {% if transaction_model.is_debit %}${{ transaction_model.amount | currency_format }}{% endif %} - {% if transaction_model.description %}{{ transaction_model.description }}{% endif %} + {% if transaction_model.description %}{{ transaction_model.description }}{% endif %} {% endfor %} -- 2.39.5 From 0859bb325551ea43cc34bc001df9eb8883f2cd97 Mon Sep 17 00:00:00 2001 From: Faheedkhan Date: Wed, 18 Jun 2025 14:47:16 +0300 Subject: [PATCH 2/6] update3 --- templates/bill/bill_detail.html | 6 +- .../bill/transactions/tags/txs_table.html | 58 +++++++++---------- templates/purchase_orders/po_form.html | 2 +- 3 files changed, 33 insertions(+), 33 deletions(-) diff --git a/templates/bill/bill_detail.html b/templates/bill/bill_detail.html index 2d913320..31715ed9 100644 --- a/templates/bill/bill_detail.html +++ b/templates/bill/bill_detail.html @@ -152,7 +152,7 @@ {% trans 'PO' %} - + {% for bill_item in itemtxs_qs %} @@ -171,7 +171,7 @@ - {% currency_symbol %}{{ bill_item.unit_cost | currency_format }} + {{ bill_item.unit_cost | currency_format }} @@ -179,7 +179,7 @@ - {% currency_symbol %}{{ bill_item.total_amount | currency_format }} + {{ bill_item.total_amount | currency_format }} diff --git a/templates/bill/transactions/tags/txs_table.html b/templates/bill/transactions/tags/txs_table.html index c0e9cd70..019e9cf4 100644 --- a/templates/bill/transactions/tags/txs_table.html +++ b/templates/bill/transactions/tags/txs_table.html @@ -2,6 +2,7 @@ {% load django_ledger %} {% if style == 'detail' %} +
@@ -15,24 +16,24 @@ - + {% for transaction_model in transaction_model_qs %} - - - - - - - + + + + + + + {% endfor %} - - - - - + + + + +
{% trans 'Description' %}
{{ transaction_model.timestamp }}{{ transaction_model.account_code }}{{ transaction_model.account_name }}{% if transaction_model.entity_unit_name %}{{ transaction_model.entity_unit_name }}{% endif %}{% if transaction_model.is_credit %}${{ transaction_model.amount | currency_format }}{% endif %}{% if transaction_model.is_debit %}${{ transaction_model.amount | currency_format }}{% endif %}{% if transaction_model.description %}{{ transaction_model.description }}{% endif %}{{ transaction_model.timestamp }}{{ transaction_model.account_code }}{{ transaction_model.account_name }}{% if transaction_model.entity_unit_name %}{{ transaction_model.entity_unit_name }}{% endif %}{% if transaction_model.is_credit %}{{ transaction_model.amount | currency_format }}{% endif %}{% if transaction_model.is_debit %}{{ transaction_model.amount | currency_format }}{% endif %}{% if transaction_model.description %}{{ transaction_model.description }}{% endif %}
{% trans 'Total' %}{% currency_symbol %}{{ total_credits | currency_format }}{% currency_symbol %}{{ total_debits | currency_format }}{% trans 'Total' %}{% currency_symbol %}{{ total_credits | currency_format }}{% currency_symbol %}{{ total_debits | currency_format }}
@@ -42,29 +43,28 @@ - - - - - + + + + - + {% for transaction_model in transaction_model_qs %} - - - - - + + + + + {% endfor %} - - - - - + + + + +
{% trans 'Account' %}{% trans 'Account Name' %}{% trans 'Credit' %}{% trans 'Debit' %}{% trans 'Description' %}{% trans 'Account Name' %}{% trans 'Credit' %}{% trans 'Debit' %}{% trans 'Description' %}
{{ transaction_model.account_code }}{{ transaction_model.account_name }}{% if transaction_model.is_credit %}${{ transaction_model.amount | currency_format }}{% endif %}{% if transaction_model.is_debit %}${{ transaction_model.amount | currency_format }}{% endif %}{% if transaction_model.description %}{{ transaction_model.description }}{% endif %}{{ transaction_model.account_code }}{{ transaction_model.account_name }}{% if transaction_model.is_credit %}{{ transaction_model.amount | currency_format }}{% endif %}{% if transaction_model.is_debit %}{{ transaction_model.amount | currency_format }}{% endif %}{% if transaction_model.description %}{{ transaction_model.description }}{% endif %}
{% trans 'Total' %}{% currency_symbol %}{{ total_credits | currency_format }}{% currency_symbol %}{{ total_debits | currency_format }}{% trans 'Total' %}{% currency_symbol %}{{ total_credits | currency_format }}{% currency_symbol %}{{ total_debits | currency_format }}
diff --git a/templates/purchase_orders/po_form.html b/templates/purchase_orders/po_form.html index 044a59a8..e29d2dcf 100644 --- a/templates/purchase_orders/po_form.html +++ b/templates/purchase_orders/po_form.html @@ -10,7 +10,7 @@ {% endif %} {% endblock %} {% block content %} -
+
-- 2.39.5 From 9d6bd249374ca25b989dab4edca8365c3d8fb6ef Mon Sep 17 00:00:00 2001 From: Faheedkhan Date: Wed, 18 Jun 2025 20:41:15 +0300 Subject: [PATCH 3/6] chnage the custome filter logic for the Transaction bills --- inventory/templatetags/custom_filters.py | 19 +++++++++++++++++-- .../bill/transactions/tags/txs_table.html | 2 ++ templates/crm/leads/lead_list.html | 4 ++-- .../crm/opportunities/opportunity_detail.html | 2 +- .../crm/opportunities/opportunity_list.html | 2 +- templates/customers/customer_list.html | 4 ++-- templates/sales/estimates/estimate_list.html | 2 +- templates/sales/journals/journal_list.html | 2 +- templates/sales/orders/order_list.html | 2 +- 9 files changed, 28 insertions(+), 11 deletions(-) diff --git a/inventory/templatetags/custom_filters.py b/inventory/templatetags/custom_filters.py index 862f212a..9d91344b 100644 --- a/inventory/templatetags/custom_filters.py +++ b/inventory/templatetags/custom_filters.py @@ -8,6 +8,7 @@ from django.forms import ValidationError from django.utils.formats import number_format from django_ledger.io.io_core import get_localdate,validate_activity from django_ledger.models import InvoiceModel, JournalEntryModel, BillModel +from django.db.models import Case, Value, When, IntegerField register = template.Library() @@ -398,9 +399,23 @@ def bill_item_formset_table(context, item_formset): def transactions_table(object_type: Union[JournalEntryModel, BillModel, InvoiceModel], style='detail'): if isinstance(object_type, JournalEntryModel): transaction_model_qs = object_type.transactionmodel_set.all().with_annotated_details().order_by( - '-timestamp') + '-timestamp', + ) elif isinstance(object_type, BillModel): - transaction_model_qs = object_type.get_transaction_queryset(annotated=True).order_by('-timestamp') + # Specific ordering for BillModel (timestamp ascending, then debit before credit) + qs = object_type.get_transaction_queryset(annotated=True) + transaction_model_qs = qs.annotate( + debit_credit_sort_order=Case( + When(tx_type='debit', then=Value(0)), # Debits will get sort order 0 + When(tx_type='credit', then=Value(1)), # Credits will get sort order 1 + default=Value(2), # Fallback for any other tx_type, if applicable + output_field=IntegerField() + ) + ).order_by( + '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): transaction_model_qs = object_type.get_transaction_queryset(annotated=True).order_by('-timestamp') else: diff --git a/templates/bill/transactions/tags/txs_table.html b/templates/bill/transactions/tags/txs_table.html index 019e9cf4..115bfbff 100644 --- a/templates/bill/transactions/tags/txs_table.html +++ b/templates/bill/transactions/tags/txs_table.html @@ -17,7 +17,9 @@ + {% for transaction_model in transaction_model_qs %} + {{ transaction_model.timestamp }} {{ transaction_model.account_code }} diff --git a/templates/crm/leads/lead_list.html b/templates/crm/leads/lead_list.html index 17f10ab7..db95d153 100644 --- a/templates/crm/leads/lead_list.html +++ b/templates/crm/leads/lead_list.html @@ -3,8 +3,8 @@ {% block title %}{{ _('Leads')|capfirst }}{% endblock title %} {% block content %} -
-

{{ _("Leads")|capfirst }}

+
+

{{ _("Leads")|capfirst }}

{% include "crm/leads/partials/update_action.html" %} diff --git a/templates/crm/opportunities/opportunity_detail.html b/templates/crm/opportunities/opportunity_detail.html index 240cd911..954a92e3 100644 --- a/templates/crm/opportunities/opportunity_detail.html +++ b/templates/crm/opportunities/opportunity_detail.html @@ -2,7 +2,7 @@ {% load i18n static humanize %} {% block title %}{{ _("Opportunity Detail") }}{% endblock title %} {% block content %} -
+

{{ _("Opportunity details")}}

diff --git a/templates/crm/opportunities/opportunity_list.html b/templates/crm/opportunities/opportunity_list.html index 625eca40..f1d87a54 100644 --- a/templates/crm/opportunities/opportunity_list.html +++ b/templates/crm/opportunities/opportunity_list.html @@ -3,7 +3,7 @@ {% load custom_filters %} {% block title %}{{ _("Opportunities") }}{% endblock title %} {% block content %} -
+

{{ _("Opportunities") }}

diff --git a/templates/customers/customer_list.html b/templates/customers/customer_list.html index 9b06144e..50a7313a 100644 --- a/templates/customers/customer_list.html +++ b/templates/customers/customer_list.html @@ -5,8 +5,8 @@ {% block vendors %}{{ _("Customers")|capfirst }}{% endblock %} {% block content %} -
-

{{ _("Customers")|capfirst }}

+
+

{{ _("Customers")|capfirst }}

diff --git a/templates/sales/estimates/estimate_list.html b/templates/sales/estimates/estimate_list.html index 981f1054..ff220d2e 100644 --- a/templates/sales/estimates/estimate_list.html +++ b/templates/sales/estimates/estimate_list.html @@ -53,7 +53,7 @@ {% empty %} - {% trans "No Quotations Found" %} + {% trans "No Quotation Found" %} {% endfor %} diff --git a/templates/sales/journals/journal_list.html b/templates/sales/journals/journal_list.html index c5665d23..d43c4159 100644 --- a/templates/sales/journals/journal_list.html +++ b/templates/sales/journals/journal_list.html @@ -37,7 +37,7 @@ {% empty %} - {% trans "No Quotations Found" %} + {% trans "No journal entry Found" %} {% endfor %} diff --git a/templates/sales/orders/order_list.html b/templates/sales/orders/order_list.html index 621dd8a1..18c4d701 100644 --- a/templates/sales/orders/order_list.html +++ b/templates/sales/orders/order_list.html @@ -46,7 +46,7 @@ {% empty %} - {% trans "No Quotations Found" %} + {% trans "No Order Found" %} {% endfor %} -- 2.39.5 From 8f5472ec5295d6fa2227decb82e4c9f4a7d6ac89 Mon Sep 17 00:00:00 2001 From: Faheedkhan Date: Thu, 19 Jun 2025 17:15:18 +0300 Subject: [PATCH 4/6] 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 %} -