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 %}