fixed issue with search

This commit is contained in:
Faheedkhan 2025-08-03 13:10:36 +03:00
commit e4335cebc3
27 changed files with 127 additions and 96 deletions

View File

@ -48,7 +48,7 @@ from imagekit.models import ImageSpecField
from imagekit.processors import ResizeToFill
# from plans.models import AbstractPlan
# from simple_history.models import HistoricalRecords
from plans.models import Invoice
class Base(models.Model):
id = models.UUIDField(
@ -1262,6 +1262,9 @@ class Dealer(models.Model, LocalizedNameMixin):
def __str__(self):
return self.name
@property
def invoices(self):
return Invoice.objects.filter(order__user=self.user)
class StaffTypes(models.TextChoices):
# MANAGER = "manager", _("Manager")

View File

@ -502,7 +502,7 @@ def create_item_service(sender, instance, created, **kwargs):
"""
if created:
entity = instance.dealer.entity
uom = entity.get_uom_all().get(name=str(instance.uom).lower())
uom = entity.get_uom_all().filter(unit_abbr=instance.uom).first()
cogs = (
entity.get_all_accounts()
.filter(role=roles.COGS, active=True, role_default=True)

View File

@ -1094,16 +1094,13 @@ class CarFinanceCalculator:
total_vat_amount = total_price_discounted * self.vat_rate
return {
"total_price_before_discount": round(
total_price, 2
),
"total_price": round(total_price_discounted, 2),
"total_vat_amount": round(total_vat_amount, 2),
"total_discount": round(Decimal(total_discount)),
"total_additionals": round(total_additionals, 2),
"grand_total": round(
total_price_discounted + total_vat_amount + total_additionals, 2
),
"total_price_discounted":total_price_discounted,
"total_price_before_discount":total_price,
"total_price": total_price_discounted,
"total_vat_amount": total_vat_amount,
"total_discount": Decimal(total_discount),
"total_additionals": total_additionals,
"grand_total":total_price_discounted + total_vat_amount + total_additionals,
}
def get_finance_data(self):
@ -1114,6 +1111,7 @@ class CarFinanceCalculator:
self._get_quantity(item) for item in self.item_transactions
),
"total_price": totals["total_price"],
"total_price_discounted": totals["total_price_discounted"],
"total_price_before_discount": totals["total_price_before_discount"],
"total_vat": totals["total_vat_amount"] + totals["total_price"],
"total_vat_amount": totals["total_vat_amount"],

View File

@ -7204,6 +7204,7 @@ class ItemServiceCreateView(
def form_valid(self, form):
dealer = get_user_type(self.request)
vat = models.VatRate.objects.get(dealer=dealer, is_active=True)
form.instance.dealer = dealer
# if form.instance.taxable:
# form.instance.price = (form.instance.price * vat.rate) + form.instance.price
@ -7253,7 +7254,11 @@ class ItemServiceUpdateView(
def form_valid(self, form):
dealer = get_user_type(self.request)
vat = models.VatRate.objects.get(dealer=dealer, is_active=True)
uom = dealer.entity.get_uom_all().filter(unit_abbr=form.instance.uom).first()
form.instance.dealer = dealer
form.instance.uom = uom.name
form.instance.item.uom = uom
# if form.instance.taxable:
# form.instance.price = (form.instance.price * vat.rate) + form.instance.price
return super().form_valid(form)
@ -10607,7 +10612,7 @@ def purchase_report_view(request,dealer_slug):
po_quantity=0
for item in items:
po_amount+=item["total"]
po_quantity+=item["q"]
po_quantity+=item["q"]
total_po_amount+=po_amount
total_po_cars+=po_quantity

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.8 MiB

View File

@ -282,9 +282,9 @@
</div>
</div>
</section>
<section class="pt-lg-0 pt-xl-8">
{% include 'footer.html' %}
</section>
<script src="{% static 'js/phoenix.js' %}"></script>
{% endblock content %}
{% block customJS %}

View File

@ -5,7 +5,8 @@
{{ _("Leads") |capfirst }}
{% endblock title %}
{% block content %}
{% if page_obj.object_list %}
{% if page_obj.object_list or request.GET.q%}
<div class="row g-3 mt-4 mb-4">
<h2 class="mb-2">
{{ _("Leads") |capfirst }}

View File

@ -5,7 +5,7 @@
{{ _("Opportunities") }}
{% endblock title %}
{% block content %}
{% if opportunities %}
{% if opportunities or request.GET.q%}
<div class="row g-3 mt-4">
<div class="col-12">
<h2 class="mb-3">

View File

@ -6,7 +6,7 @@
{% endblock title %}
{% block vendors %}<a class="nav-link active">{{ _("Customers") |capfirst }}</a>{% endblock %}
{% block content %}
{% if customers %}
{% if customers or request.GET.q%}
<div class="row g-3 mt-4">
<h2 class="mb-2">
{{ _("Customers") |capfirst }}

View File

@ -11,7 +11,7 @@
<!--heading -->
<div class="row align-items-center justify-content-between g-3 mb-4">
<div class="col-auto">
<h3 class="mb-0">{% trans 'Customer details' %}</h3>
<h3 class="mb-0">{% trans 'Customer details' %}<li class="fas fa-user ms-2 text-primary"></li></h3>
</div>
<div class="col-auto">
<div class="row g-3">
@ -127,20 +127,16 @@
</div>
<div class="col-12 mt-3">
<div class="mb-6">
<div class="border-top border-bottom border-translucent"
id="customerOrdersTable"
data-list='{"valueNames":["order","total","payment_status","fulfilment_status","delivery_type","date"],"page":6,"pagination":true}'>
<div>
<div class="table-responsive scrollbar">
<table class="table table-sm fs-9 mb-0">
<thead>
<thead class="bg-body-highlight">
<tr>
<th class="sort white-space-nowrap align-middle" scope="col" data-sort="leads">{% trans 'Leads'|upper %}</th>
<th class="sort align-middle " scope="col" data-sort="opportunities">{% trans 'Opportunities'|upper %}</th>
<th class="sort align-middle " scope="col" data-sort="estimates">{% trans 'Estimates'|upper %}</th>
<th class="sort align-middle " scope="col" data-sort="sale_orders">{% trans 'Sale orders'|upper %}</th>
<th class="sort align-middle " scope="col" data-sort="invoices">{% trans 'Invoices'|upper %}</th>
<th class="sort align-middle " scope="col" data-sort="car">{% trans 'Car'|upper %}</th>
<th class="sort align-middle" scope="col" >{% trans 'Leads'|upper %}</th>
<th class="sort align-middle " scope="col" >{% trans 'Opportunities'|upper %}</th>
<th class="sort align-middle " scope="col">{% trans 'Estimates'|upper %}</th>
</tr>
</thead>
@ -148,44 +144,69 @@
{% for lead in leads %}
<tr>
<td><a href="{% url 'lead_detail' request.dealer.slug lead.slug%}">{{lead}} ({{ forloop.counter }})<a></td>
<td><a href="{$ url 'opportunity_detail' lead.opportunity.slug request.dealer.slug}">{{lead.opportunity}} ({{ forloop.counter }})</a></td>
<td><a href="{% url 'opportunity_detail' request.dealer.slug lead.opportunity.slug%}">{{lead.opportunity}} ({{ forloop.counter }})</a></td>
<td>
{% for estimate in lead.customer.customer_model.estimatemodel_set.all %}
<div class="me-2"><a href="{% url 'estimate_detail' request.dealer.slug estimate.pk %}">{{estimate}}</a></div>
<hr>
{% endfor %}
</td>
{% for estimate in lead.customer.customer_model.estimatemodel_set.all %}
<h4 class="me-2 my-1"><a href="{% url 'estimate_detail' request.dealer.slug estimate.pk %}"><span class="me-2">#{{forloop.counter }}</span>{{estimate}}</a></h4>
<table class="table table-sm">
<thead class="bg-body-highlight">
<tr>
<th class="sort align-middle " scope="col">{% trans 'Sale orders'|upper %}</th>
<th class="sort align-middle " scope="col">{% trans 'Invoices'|upper %}</th>
<th class="sort align-middle " scope="col">{% trans 'Car VIN'|upper %}</th>
</tr>
</thead>
<tbody>
<tr>
<td>
{% for sale_order in estimate.sale_orders.all %}
<div><a href={% url 'order_detail' request.dealer.slug sale_order.pk%}>{{estimate.sale_orders.first}}</a></div>
{% endfor %}
</td>
<td>
{% for estimate in lead.customer.customer_model.estimatemodel_set.all %}
<div><a href={% url 'order_detail' request.dealer.slug estimate.sale_orders.first.pk%}>{{estimate.sale_orders.first}}</a></div>
<hr>
{% endfor %}
</td>
<td>
{% for invoice in lead.customer.customer_model.invoicemodel_set.all %}
<td>
{% for invoice in estimate.invoicemodel_set.all %}
{% if invoice.is_paid %}
<span class="badge badge-phoenix fs-10 badge-phoenix-success">
<div><a href="{% url 'invoice_detail' request.dealer.slug request.entity.slug invoice.pk %}">{{invoice}}</a></div>
</span>
{%else%}
<span class="badge badge-phoenix fs-10 badge-phoenix-info">
<div><a href="{% url 'invoice_detail' request.dealer.slug request.entity.slug invoice.pk %}">{{invoice}}</a></div>
</span>
{% endif %}
{% if invoice.is_paid %}
<span class="badge badge-phoenix fs-10 badge-phoenix-success">
<div><a href="{% url 'invoice_detail' request.dealer.slug request.entity.slug invoice.pk %}">{{invoice}}</a></div>
</span>
{%else%}
<span class="badge badge-phoenix fs-10 badge-phoenix-info">
<div><a href="{% url 'invoice_detail' request.dealer.slug request.entity.slug invoice.pk %}">{{invoice}}</a></div>
</span>
{% endif %}
<hr>
{% endfor %}
{% endfor %}
</td>
<td>
<div><a href="#">{{estimate.itemtransactionmodel_set.first.item_model.name}}</a></div>
<td>
</tr>
</tbody>
</table>
<br>
{% endfor %}
</td>
<td>
{% for estimate in lead.customer.customer_model.invoicemodel_set.all %}
<div><a href="#">{{estimate.itemtransactionmodel_set.first.item_model.name}}</a></div>
<hr>
{% endfor %}
<td>
<tr>

View File

@ -7,6 +7,7 @@
<div class="row align-items-center justify-content-between g-3 mb-4">
<div class="col-auto">
<h2 class="mb-0">{% trans 'Profile' %}</h2>
</div>
<div class="col-auto">
<div class="row g-2 g-sm-3">

View File

@ -37,31 +37,33 @@
/* No specific styles for .btn-add-new or .message-box are needed here as per previous updates */
</style>
<div class="empty-state-container">
<div class="empty-state-container">
<!-- Empty State Illustration -->
{% if image %}
{% if image %}
{% static image as final_image_path %}
{% else %}
{% static 'images/no_content/no_item.jpg' as final_image_path %}
{% endif %}
{% else %}
{% static 'images/no_content/no_item.jpg' as final_image_path %}
{% endif %}
<img src="{{ final_image_path }}" alt="No-empty-state-image" class="empty-state-image">
<!-- Title -->
<h3 class="empty-state-title">
<h3 class="empty-state-title">
{% blocktrans %}No {{ value}} Yet{% endblocktrans %}
</h3>
</h3>
<!-- Description -->
<p class="empty-state-text">
<p class="empty-state-text">
{% blocktrans %}It looks like you haven't added any {{ value }} to your account.
Click the button below to get started and add your first {{ value }}!{% endblocktrans %}
</p>
</p>
<!-- Call to Action Button -->
<a class="btn btn-lg btn-primary" href="{{ url }}">
<a class="btn btn-lg btn-primary" href="{{ url }}">
<i class="fa fa-plus me-2"></i>
{% blocktrans %}Create New {{value}}{% endblocktrans %}
</a>
</div>
</a>
</div>

View File

@ -7,7 +7,7 @@
{% endblock title %}
{% block content %}
{% if groups %}
{% if groups or request.GET.q%}
<section class="">
<div class="row mt-4">
<div class="col-auto">

View File

@ -25,7 +25,7 @@
{% endblock customCSS %}
{% block content %}
{% if cars%}
{% if cars or request.GET.q%}
<div class="container-fluid" id="projectSummary">
<div class="row g-3 justify-content-between align-items-end mb-4">
<div class="col-12 col-sm-auto">

View File

@ -6,7 +6,7 @@
{% block content %}
{% if expenses %}
{% if expenses or request.GET.q %}
<div class="row mt-4">
<div class="d-flex justify-content-between mb-2">
<h3 class="">{% trans "Expenses" %} <span class="fas fa-money-bill-wave ms-2 text-primary"></span></h3>

View File

@ -5,7 +5,7 @@
{% endblock title %}
{% block content %}
{% if services %}
{% if services or request.GET.q %}
<div class="row mt-4">
<div class="d-flex justify-content-between mb-2">
<h3 class="">{% trans "Services" %}<span class="fas fa-tools text-primary ms-2"></span></h3>

View File

@ -11,7 +11,7 @@
{% endblock %}
{% block content %}
{% if bills %}
{% if bills or request.GET.q%}
<div class="row mt-4">
<div class="d-flex justify-content-between mb-2">
<h3 class="">{% trans "Bills" %}<span class="fas fa-money-bills ms-2 text-primary"></span></h3>

View File

@ -12,7 +12,7 @@
{% block content %}
{% if accounts%}
{% if accounts or request.GET.q%}
<div class="row mt-4">
<div class="d-flex justify-content-between mb-2">
<h3 class=""> {% trans "Accounts" %}<i class="fa-solid fa-book ms-2 text-primary"></i></h3>

View File

@ -5,7 +5,7 @@
{% endblock title %}
{% block content %}
{% if journal_entries %}
{% if journal_entries or request.GET.q%}
<div class="modal fade"
id="confirmModal"
tabindex="-1"

View File

@ -5,16 +5,16 @@
{% block title %}
{% trans 'Cash Flow Statement' %} {% endblock %}
{% block period_navigation %}
{% if unit_model and entity %}
<div class="col-12">{% period_navigation 'unit-cf' %}</div>
{% if unit_model and entity %}
<div class="col-12">{% period_navigation 'unit-cf' %}</div>
{% elif entity %}
<div class="col-12">{% period_navigation 'entity-cf' %}</div>
<div class="col-12">{% period_navigation 'entity-cf' %}</div>
{% elif ledger %}
<div class="col-12">{% period_navigation 'ledger-cf' %}</div>
<div class="col-12">{% period_navigation 'ledger-cf' %}</div>
{% elif unit_model %}
<div class="col-12">{% period_navigation 'unit-cf' %}</div>
{% endif %}
{% endblock %}
<div class="col-12">{% period_navigation 'unit-cf' %}</div>
{% endif %}
{% endblock period_navigation %}
{% block content %}
<div class="card">
<div class="card-body text-center">

View File

@ -70,10 +70,10 @@
{% for po in data %}
<tr>
<td class="ps-1">{{po.po_number}}</td>
<td>{{po.po_created}}</td>
<td>{{po.po_created|date}}</td>
<td>{{po.po_status}}</td>
<td>{{po.po_amount}}</td>
<td>{{po.date_fulfilled}}</td>
<td>{{po.po_fulfilled_date}}</td>
<td>staff</td>
<td>{{po.po_quantity}}</td>
<td>

View File

@ -71,7 +71,7 @@
<div class="empty-state-container alert mb-2" role="alert">
<img src="{% static message_image %}" alt="message-image" class="empty-state-image mb-2">
<img src="{% static 'images/no_content/no_item.jpg' %}" alt="message-image" class="empty-state-image mb-2">
<!-- Title -->
<h3 class="empty-state-title mb-2">
{% blocktrans %}{{ value1}}{% endblocktrans %}

View File

@ -8,7 +8,7 @@
<a class="nav-link active">{% trans 'Organizations' %}</a>
{% endblock %}
{% block content %}
{% if organizations%}
{% if organizations or request.GET.q%}
<section class="pt-5 pb-9 ">
<div class="row overflow-x-auto whitespace-nowrap -mx-2 sm:mx-0">
<h2 class="mb-4">

View File

@ -4,9 +4,9 @@
{% block title %}
{# Check if an 'object' exists in the context #}
{% if object %}
{% trans 'Update Vendor' %}
{% trans 'Update Purchase Order' %}
{% else %}
{% trans 'Add New Vendor' %}
{% trans 'Create Purchase Order' %}
{% endif %}
{% endblock %}
{% block content %}

View File

@ -5,7 +5,7 @@
{% block content %}
{% if purchase_orders %}
{% if purchase_orders or request.GET.q %}
<div class="row mt-4">
<!-- Success Message -->
{% if messages %}

View File

@ -5,7 +5,7 @@
{% endblock title %}
{% block content %}
{% if invoices %}
{% if invoices or request.GET.q%}
<div class="row mt-4">
<div class="row g-3 justify-content-between mb-4">
<div class="col-auto">

View File

@ -6,7 +6,7 @@
{% endblock title %}
{% block content %}
{%if users %}
{%if users or request.GET.q%}
<section class="">
<div class="row mt-4">
<div class="col-auto">