chnage the custome filter logic for the Transaction bills
This commit is contained in:
parent
0859bb3255
commit
9d6bd24937
@ -8,6 +8,7 @@ from django.forms import ValidationError
|
|||||||
from django.utils.formats import number_format
|
from django.utils.formats import number_format
|
||||||
from django_ledger.io.io_core import get_localdate,validate_activity
|
from django_ledger.io.io_core import get_localdate,validate_activity
|
||||||
from django_ledger.models import InvoiceModel, JournalEntryModel, BillModel
|
from django_ledger.models import InvoiceModel, JournalEntryModel, BillModel
|
||||||
|
from django.db.models import Case, Value, When, IntegerField
|
||||||
|
|
||||||
register = template.Library()
|
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'):
|
def transactions_table(object_type: Union[JournalEntryModel, BillModel, InvoiceModel], style='detail'):
|
||||||
if isinstance(object_type, JournalEntryModel):
|
if isinstance(object_type, JournalEntryModel):
|
||||||
transaction_model_qs = object_type.transactionmodel_set.all().with_annotated_details().order_by(
|
transaction_model_qs = object_type.transactionmodel_set.all().with_annotated_details().order_by(
|
||||||
'-timestamp')
|
'-timestamp',
|
||||||
|
)
|
||||||
elif isinstance(object_type, BillModel):
|
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):
|
elif isinstance(object_type, InvoiceModel):
|
||||||
transaction_model_qs = object_type.get_transaction_queryset(annotated=True).order_by('-timestamp')
|
transaction_model_qs = object_type.get_transaction_queryset(annotated=True).order_by('-timestamp')
|
||||||
else:
|
else:
|
||||||
|
|||||||
@ -17,7 +17,9 @@
|
|||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody class="fs-9">
|
<tbody class="fs-9">
|
||||||
|
|
||||||
{% for transaction_model in transaction_model_qs %}
|
{% for transaction_model in transaction_model_qs %}
|
||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
<td class=" white-space-nowrap align-middle ps-2" scope="col" >{{ transaction_model.timestamp }}</td>
|
<td class=" white-space-nowrap align-middle ps-2" scope="col" >{{ transaction_model.timestamp }}</td>
|
||||||
<td class=" white-space-nowrap align-middle" scope="col">{{ transaction_model.account_code }}</td>
|
<td class=" white-space-nowrap align-middle" scope="col">{{ transaction_model.account_code }}</td>
|
||||||
|
|||||||
@ -3,8 +3,8 @@
|
|||||||
{% block title %}{{ _('Leads')|capfirst }}{% endblock title %}
|
{% block title %}{{ _('Leads')|capfirst }}{% endblock title %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<div class="row g-3">
|
<div class="row g-3 mt-4">
|
||||||
<h2 class="mb-4">{{ _("Leads")|capfirst }}</h2>
|
<h2 class="mb-2">{{ _("Leads")|capfirst }}</h2>
|
||||||
<!-- Action Tracking Modal -->
|
<!-- Action Tracking Modal -->
|
||||||
{% include "crm/leads/partials/update_action.html" %}
|
{% include "crm/leads/partials/update_action.html" %}
|
||||||
|
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
{% load i18n static humanize %}
|
{% load i18n static humanize %}
|
||||||
{% block title %}{{ _("Opportunity Detail") }}{% endblock title %}
|
{% block title %}{{ _("Opportunity Detail") }}{% endblock title %}
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<div class="row align-items-center justify-content-between g-3 mb-4">
|
<div class="row align-items-center justify-content-between g-3 mb-4 mt-4">
|
||||||
<div class="col-12 col-md-auto">
|
<div class="col-12 col-md-auto">
|
||||||
<h2 class="mb-0">{{ _("Opportunity details")}}</h2>
|
<h2 class="mb-0">{{ _("Opportunity details")}}</h2>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -3,7 +3,7 @@
|
|||||||
{% load custom_filters %}
|
{% load custom_filters %}
|
||||||
{% block title %}{{ _("Opportunities") }}{% endblock title %}
|
{% block title %}{{ _("Opportunities") }}{% endblock title %}
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<div class="row g-3">
|
<div class="row g-3 mt-4">
|
||||||
<div class="col-12">
|
<div class="col-12">
|
||||||
<h2 class="mb-3">{{ _("Opportunities") }}</h2>
|
<h2 class="mb-3">{{ _("Opportunities") }}</h2>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -5,8 +5,8 @@
|
|||||||
{% block vendors %}<a class="nav-link active">{{ _("Customers")|capfirst }}</a>{% endblock %}
|
{% block vendors %}<a class="nav-link active">{{ _("Customers")|capfirst }}</a>{% endblock %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<div class="row">
|
<div class="row g-3 mt-4">
|
||||||
<h4 class="mb-4">{{ _("Customers")|capfirst }}</h4>
|
<h2 class="mb-2">{{ _("Customers")|capfirst }}</h2>
|
||||||
<div class="row g-3 justify-content-between mb-4">
|
<div class="row g-3 justify-content-between mb-4">
|
||||||
<div class="col-auto">
|
<div class="col-auto">
|
||||||
<div class="d-md-flex justify-content-between">
|
<div class="d-md-flex justify-content-between">
|
||||||
|
|||||||
@ -53,7 +53,7 @@
|
|||||||
</tr>
|
</tr>
|
||||||
{% empty %}
|
{% empty %}
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="6" class="text-center">{% trans "No Quotations Found" %}</td>
|
<td colspan="6" class="text-center">{% trans "No Quotation Found" %}</td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</tbody>
|
</tbody>
|
||||||
|
|||||||
@ -37,7 +37,7 @@
|
|||||||
</tr>
|
</tr>
|
||||||
{% empty %}
|
{% empty %}
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="6" class="text-center">{% trans "No Quotations Found" %}</td>
|
<td colspan="6" class="text-center">{% trans "No journal entry Found" %}</td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</tbody>
|
</tbody>
|
||||||
|
|||||||
@ -46,7 +46,7 @@
|
|||||||
</tr>
|
</tr>
|
||||||
{% empty %}
|
{% empty %}
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="6" class="text-center">{% trans "No Quotations Found" %}</td>
|
<td colspan="6" class="text-center">{% trans "No Order Found" %}</td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</tbody>
|
</tbody>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user