car_sale report changes

This commit is contained in:
Faheedkhan 2025-08-06 15:32:05 +03:00
commit 009fcce730
7 changed files with 55 additions and 47 deletions

View File

@ -742,7 +742,9 @@ class Car(Base):
) )
except Exception: except Exception:
return False return False
@property
def invoice(self):
return self.item_model.invoicemodel_set.first if self.item_model.invoicemodel_set.first() else None
def get_transfer(self): def get_transfer(self):
return self.transfer_logs.filter(active=True).first() return self.transfer_logs.filter(active=True).first()

View File

@ -1282,8 +1282,8 @@ urlpatterns = [
), ),
path('car-sale-report/<slug:dealer_slug>/csv/', views.car_sale_report_csv_export, name='car-sale-report-csv-export'), path('car-sale-report/<slug:dealer_slug>/csv/', views.car_sale_report_csv_export, name='car-sale-report-csv-export'),
path('feature/recalls/', views.RecallListView.as_view(), name='recall_list'), path('feature/recall/', views.RecallListView.as_view(), name='recall_list'),
path('feature/recall/', views.RecallFilterView, name='recall_filter'), path('feature/recall/filter/', views.RecallFilterView, name='recall_filter'),
path('feature/recall/<int:pk>/view/', views.RecallDetailView.as_view(), name='recall_detail'), path('feature/recall/<int:pk>/view/', views.RecallDetailView.as_view(), name='recall_detail'),
path('feature/recall/create/', views.RecallCreateView.as_view(), name='recall_create'), path('feature/recall/create/', views.RecallCreateView.as_view(), name='recall_create'),
path('feature/recall/success/', views.RecallSuccessView.as_view(), name='recall_success'), path('feature/recall/success/', views.RecallSuccessView.as_view(), name='recall_success'),

View File

@ -47,13 +47,13 @@
{% endif %} {% endif %}
{% if perms.inventory.add_car %} {% if perms.inventory.add_car %}
<li class="nav-item"> {% comment %} <li class="nav-item">
<a class="nav-link" href="{% url 'upload_cars' request.dealer.slug %}"> <a class="nav-link" href="{% url 'upload_cars' request.dealer.slug %}">
<div class="d-flex align-items-center"> <div class="d-flex align-items-center">
<span class="nav-link-icon"><span class="fas fa-file-import"></span></span><span class="nav-link-text">{% trans "Bulk Upload"|capfirst %}</span> <span class="nav-link-icon"><span class="fas fa-file-import"></span></span><span class="nav-link-text">{% trans "Bulk Upload"|capfirst %}</span>
</div> </div>
</a> </a>
</li> </li> {% endcomment %}
{% endif %} {% endif %}
{% if perms.django_ledger.view_purchaseordermodel %} {% if perms.django_ledger.view_purchaseordermodel %}
<li class="nav-item"> <li class="nav-item">

View File

@ -127,7 +127,11 @@
</div> </div>
</div> </div>
</div> </div>
</div> </div>
</section> </section>
<section id="sale-details" class="mb-3"> <section id="sale-details" class="mb-3">
@ -137,47 +141,48 @@
<i class="bi bi-download me-2"></i>{% trans 'Download as CSV' %} <i class="bi bi-download me-2"></i>{% trans 'Download as CSV' %}
</a> </a>
</div> </div>
<div class="table-responsive "> <div class="table-responsive">
<table class="table table-sm table-striped table-hover "> <table class="table table-striped table-hover table-bordered table-sm">
<thead class="bg-body-highlight"> <thead>
<tr> <tr>
<th scope="col">{% trans 'VIN' %}</th> <th class="fs-9">{% trans 'VIN' %}</th>
<th scope="col">{% trans 'Make' %}</th> <th class="fs-9">{% trans 'Make' %}</th>
<th scope="col">{% trans 'Model' %}</th> <th class="fs-9">{% trans 'Model' %}</th>
<th scope="col">{% trans 'Year' %}</th> <th class="fs-9">{% trans 'Year' %}</th>
<th scope="col">{% trans 'Serie' %}</th> <th class="fs-9">{% trans 'Serie' %}</th>
<th scope="col">{% trans 'Trim' %}</th> <th class="fs-9">{% trans 'Trim' %}</th>
<th scope="col">{% trans 'Mileage' %}</th> <th class="fs-9">{% trans 'Mileage' %}</th>
<th scope="col">{% trans 'Stock Type' %}</th> <th class="fs-9">{% trans 'Stock Type' %}</th>
<th scope="col">{% trans 'Created Date' %}</th> <th class="fs-9">{% trans 'Created Date' %}</th>
<th scope="col">{% trans 'Sold Date' %}</th> <th class="fs-9">{% trans 'Sold Date' %}</th>
<th scope="col">{% trans 'Cost Price' %}</th> <th class="fs-9">{% trans 'Cost Price' %}</th>
<th scope="col">{% trans 'Marked Price' %}</th> <th class="fs-9">{% trans 'Marked Price' %}</th>
<th scope="col">{% trans 'Discount Amount' %}</th> <th class="fs-9">{% trans 'Discount Amount' %}</th>
<th scope="col">{% trans 'Selling Price' %}</th> <th class="fs-9">{% trans 'Selling Price' %}</th>
<th scope="col">{% trans 'Tax Amount' %}</th> <th class="fs-9">{% trans 'Tax Amount' %}</th>
<th scope="col">{% trans 'Invoice Number' %}</th> <th class="fs-9">{% trans 'Invoice Number' %}</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
{% for car in cars_sold %} {% for car in cars_sold %}
<tr> <tr>
<td>{{ car.vin }}</td> <td class="ps-1 fs-9">{{ car.vin }}</td>
<td>{{ car.id_car_make.name }}</td> <td class="fs-9">{{ car.id_car_make.name }}</td>
<td>{{ car.id_car_model.name }}</td> <td class="fs-9">{{ car.id_car_model.name }}</td>
<td>{{ car.year }}</td> <td class="fs-9">{{ car.year }}</td>
<td>{{ car.id_car_serie.name }}</td> <td class="fs-9">{{ car.id_car_serie.name }}</td>
<td>{{ car.id_car_trim.name }}</td> <td class="fs-9">{{ car.id_car_trim.name }}</td>
<td>{{ car.mileage }}</td> <td class="fs-9">{{ car.mileage }}</td>
<td>{{ car.stock_type }}</td> <td class="fs-9">{{ car.stock_type }}</td>
<td>{{ car.created_at }}</td> <td class="fs-9">{{ car.created_at|date }}</td>
<td>{{ car.sold_date }}</td> <td class="fs-9">{{ car.invoice.date_paid|date|default_if_none:"-" }}</td>
<td>{{ car.finances.cost_price }}</td> <td class="fs-9">{{ car.finances.cost_price }}</td>
<td>{{ car.finances.marked_price }}</td> <td class="fs-9">{{ car.finances.marked_price }}</td>
<td>{{ car.finances.discount_amount }}</td> <td class="fs-9">{{ car.finances.discount_amount }}</td>
<td>{{ car.finances.selling_price }}</td> <td class="fs-9">{{ car.finances.selling_price }}</td>
<td>{{ car.finances.vat_amount }}</td> <td class="fs-9">{{ car.finances.vat_amount }}</td>
<td>{{ car.item_model.invoicemodel_set.first.invoice_number }}</td> <td class="fs-9">{{ car.invoice.invoice_number }}</td>
</tr> </tr>
{% endfor %} {% endfor %}
</tbody> </tbody>

View File

@ -4,8 +4,10 @@
{% block content %} {% block content %}
<div class="container mt-4"> <div class="container mt-4">
<h2>{% trans "Recall History" %}</h2> <div class="d-flex justify-content-between mb-3">
<h2>{% trans "Recall History" %}</h2>
<a href="{% url 'recall_filter' %}" class="btn btn-primary">{% trans "Create Recall" %}</a>
</div>
<div class="card mb-4"> <div class="card mb-4">
<div class="card-body"> <div class="card-body">
<div class="table-responsive"> <div class="table-responsive">
@ -13,7 +15,7 @@
<thead class="thead-dark"> <thead class="thead-dark">
<tr> <tr>
<th>{% trans "Title" %}</th> <th>{% trans "Title" %}</th>
<th>{% trans "Sent" %}</th> <th>{% trans "Sent At" %}</th>
<th>{% trans "Make" %}</th> <th>{% trans "Make" %}</th>
<th>{% trans "Model" %}</th> <th>{% trans "Model" %}</th>
<th>{% trans "Series" %}</th> <th>{% trans "Series" %}</th>
@ -28,7 +30,7 @@
<td>{{ recall.title }}</td> <td>{{ recall.title }}</td>
<td> <td>
<span title="{{ recall.created_at }}"> <span title="{{ recall.created_at }}">
{{ recall.created_at|naturaltime }} {{ recall.created_at|date }}
</span> </span>
</td> </td>
<td><img src="{{ recall.make.logo.url }}" width="50" height="50"> &nbsp;{{ recall.make|default:"-" }}</td> <td><img src="{{ recall.make.logo.url }}" width="50" height="50"> &nbsp;{{ recall.make|default:"-" }}</td>

View File

@ -8,7 +8,7 @@
<h4 class="alert-heading">{% trans "Recall Initiated Successfully!" %}</h4> <h4 class="alert-heading">{% trans "Recall Initiated Successfully!" %}</h4>
<p>{% trans "The recall has been created and notifications have been sent to all affected dealers." %}</p> <p>{% trans "The recall has been created and notifications have been sent to all affected dealers." %}</p>
<hr> <hr>
<a href="{% url 'recall_filter' %}" class="btn btn-primary"> <a href="{% url 'recall_list' %}" class="btn btn-primary">
{% trans "Back to Recall Management" %} {% trans "Back to Recall Management" %}
</a> </a>
</div> </div>

View File

@ -137,7 +137,7 @@
{% endif %} {% endif %}
</div> </div>
<div> <div>
<div class="col-lg-8 col-md-10 needs-validation {% if not items or not customer_count %}d-none{% endif %}"> <div class="col-lg-12 col-md-10 needs-validation {% if not items or not customer_count %}d-none{% endif %}">
<div class="card shadow-sm border-0 rounded-3"> <div class="card shadow-sm border-0 rounded-3">
<div class="card-header bg-gray-200 py-3 border-0 rounded-top-3"> <div class="card-header bg-gray-200 py-3 border-0 rounded-top-3">
<h3 class="mb-0 fs-4 text-center"> <h3 class="mb-0 fs-4 text-center">
@ -148,7 +148,6 @@
<form id="mainForm" method="post" class="needs-validation {% if not items and not customer_count %}d-none{% endif %}"> <form id="mainForm" method="post" class="needs-validation {% if not items and not customer_count %}d-none{% endif %}">
{% csrf_token %} {% csrf_token %}
<div class="row g-3 col-12"> <div class="row g-3 col-12">
{{ form|crispy }} {{ form|crispy }}