ordered the txns based on debit listed first

This commit is contained in:
Faheedkhan 2025-06-19 17:15:18 +03:00
parent 9d6bd24937
commit 8f5472ec52
11 changed files with 47 additions and 32 deletions

View File

@ -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'
return 'sedan'

View File

@ -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",

View File

@ -9,9 +9,9 @@
<form action="" method="post">
{% csrf_token %}
<div class="col-12 col-xl-8">
<div class="border-bottom mb-4">
<div class=" mb-4">
<div class="row gx-3 mb-6 gy-6 gy-sm-3">
<div class="row gx-3 mb-4 gy-6 gy-sm-3">
<div class="col-12 col-sm-8">
<h4 class="mb-4">Default Invoice Accounts</h4>
<div class="form-icon-container mb-3">
@ -25,7 +25,7 @@
</div>
</div>
</div>
<div class="row gx-3 mb-6 gy-6 gy-sm-3">
<div class="row gx-3 mb-4 gy-6 gy-sm-3">
<div class="col-12 col-sm-8">
<h4 class="mb-4">Default Bill Accounts</h4>
<div class="form-icon-container mb-3">

View File

@ -231,19 +231,24 @@
</tr>
{% endfor %}
</tbody>
{% endif %}
</table>
</div>
</div>
</div>
<div class="d-flex justify-content-end mt-3">
<div class="d-flex">
<div class="d-flex justify-content-end mt-3">
<div class="d-flex">
{% if is_paginated %}
{% include 'partials/pagination.html' %}
{% endif %}
</div>
</div>
{% else %}
<tr>
<td colspan="6" class="text-center">{% trans "No Lead Yet" %}</td>
</tr>
{% endif %}
</div>
</div>
</div>
</div>
{% endblock %}

View File

@ -9,14 +9,14 @@
<div class="col-md-8">
<!-- Form Header -->
<h4 class="mb-3">{{ _("Update Dealer Information") }}</h4>
<h3 class="mb-3">{{ _("Update Dealer Information") }}</h3>
<form method="post" enctype="multipart/form-data" class="needs-validation" novalidate>
{% csrf_token %}
{{ form|crispy }}
<div class="gap-2 mt-3">
<button type="submit" class="btn btn-phoenix-success btn-sm">
<i class="fa fa-save"></i> {{ _("Save") }}
<button type="submit" class="btn btn-phoenix-success btn-sm me-2">
<i class="fa fa-save me-1"></i> {{ _("Save") }}
</button>
<a href="{{request.META.HTTP_REFERER}}" class="btn btn-sm btn-phoenix-danger"><i class="fa-solid fa-ban me-1"></i>{% trans "Cancel" %}</a>

View File

@ -7,16 +7,17 @@
<div class="col-sm-6">
<form action="{% url 'billing_info' %}{% if request.GET.next %}?next={{ request.GET.next }}{% endif %}" method="post" class="form">
<legend>{% trans "Provide billing data"|upper %}</legend>
{% comment %} <legend>{% trans "Provide billing data"|upper %}</legend> {% endcomment %}
<h3>{% trans "Provide billing data"|upper %}</h3>
{% csrf_token %}
{{ form|crispy }}
{% if object %}
<a class="btn btn-sm btn-phoenix-danger" href="{% url 'billing_info_delete' %}"><i class="fa-solid fa-trash me-1"></i> {{ _("Delete") }}</a>
{% endif %}
<button type="submit" class="btn btn-sm btn-phoenix-success">
<button type="submit" class="btn btn-sm btn-phoenix-success me-2">
<i class="fa fa-save me-1"></i>{{ _("Save") }}
</button>
{% if object %}
<a class="btn btn-sm btn-phoenix-danger " href="{% url 'billing_info_delete' %}"><i class="fa-solid fa-trash me-1"></i> {{ _("Delete") }}</a>
{% endif %}
</form>
</div>

View File

@ -107,7 +107,7 @@
</select>
</div>
<div class="row g-4 mt-4">
<div class="col">
<div class="col ms-6">
<p class="fs-5 mb-2">{% trans 'Exterior Colors' %}</p>
<div class="color-options-container">
{% for color in form.fields.exterior.queryset %}

View File

@ -42,7 +42,7 @@
{% if purchase_orders %}
{% for po in purchase_orders %}
<tr class="hover-actions-trigger btn-reveal-trigger position-static">
<td class="align-middle product white-space-nowrap">{{ po.po_number }}</td>
<td class="align-middle product white-space-nowrap ps-1">{{ po.po_number }}</td>
<td class="align-middle product white-space-nowrap">{{ po.po_title }}</td>
<td class="align-middle product white-space-nowrap">
<span class="">

View File

@ -10,9 +10,9 @@
{% if po.po_status == 'draft' %}
<h4 class="ms-2 text-warning mb-0">{{ po.po_status|capfirst }}</h4>
{% elif po.po_status == 'in_review' %}
<h4 class="ms-2 text-primary mb-0">{{ po.po_status|capfirst }}</h4>
<h4 class="ms-2 text-secondary mb-0">{{ po.po_status|capfirst }}</h4>
{% elif po.po_status == 'approved' %}
<h4 class="ms-2 text-info mb-0">{{ po.po_status|capfirst }}</h4>
<h4 class="ms-2 text-success mb-0">{{ po.po_status|capfirst }}</h4>
{% elif po.po_status == 'fulfilled' %}
<h4 class="ms-2 text-success mb-0">{{ po.po_status|capfirst }}</h4>
{% elif po.po_status == 'void' %}

View File

@ -15,7 +15,7 @@
<a href="{% url 'user_create' %}" class="btn btn-sm btn-phoenix-primary me-4"><i class="fa-solid fa-user-tie me-1"></i> {% trans "Add New Staff" %}</a>
<a href="{% url 'group_list' %}" class="btn btn-sm btn-phoenix-success"><i class="fa-solid fa-user-group me-1"></i> {% trans "Manage Groups & Permissions" %}</a>
{% else %}
<div class="alert alert-outline-info d-flex align-items-center" role="alert">
<div class="alert alert-outline-warning d-flex align-items-center" role="alert">
<i class="fa-solid fa-circle-info fs-6"></i>
<p class="mb-0 flex-1">{{ _("No Active Subscription,please activate your subscription.") }}<a href="{% url 'pricing_page' %}" class="ms-3 text-body-primary fs-9">Manage Subscription</a></p>
<button class="btn-close" type="button" data-bs-dismiss="alert" aria-label="Close"></button>

View File

@ -72,7 +72,7 @@
<th class="sort white-space-nowrap align-middle"
scope="col"
data-sort="date"
style="width:15%">{{ _("Create date") }}</th>
style="width:15%">{{ _("Created date") }}</th>
<th class="sort white-space-nowrap align-middle" scope="col"></th>
</tr>
</thead>