add sales list
This commit is contained in:
parent
c37f87299b
commit
387b7b099c
@ -22,6 +22,7 @@ from django_ledger.models import (
|
||||
BillModel,
|
||||
VendorModel,
|
||||
CustomerModel,
|
||||
ItemTransactionModel
|
||||
)
|
||||
from decimal import Decimal
|
||||
|
||||
@ -815,3 +816,23 @@ class CarFinanceCalculator:
|
||||
|
||||
|
||||
|
||||
def get_item_transactions(txs):
|
||||
transactions = []
|
||||
for tx in txs:
|
||||
data = {}
|
||||
if tx.item_model.additional_info.get('car_info'):
|
||||
data["info"] = tx.item_model.additional_info.get('car_info')
|
||||
if tx.item_model.additional_info.get('car_finance'):
|
||||
data["finance"] = tx.item_model.additional_info.get('car_finance')
|
||||
if tx.has_estimate():
|
||||
data["estimate"] = tx.ce_model
|
||||
data["has_estimate"] = True
|
||||
data["customer"] = tx.ce_model.customer
|
||||
if tx.has_invoice():
|
||||
data["invoice"] = tx.invoice_model
|
||||
data["has_invoice"] = True
|
||||
data["customer"] = tx.invoice_model.customer
|
||||
if bool(data):
|
||||
transactions.append(data)
|
||||
print(data)
|
||||
return transactions
|
||||
@ -14,6 +14,7 @@ from django_ledger.forms.bill import (
|
||||
from django.utils.decorators import method_decorator
|
||||
from django.views.decorators.csrf import csrf_exempt
|
||||
from django_ledger.models import (
|
||||
ItemTransactionModel,
|
||||
EntityModel,
|
||||
InvoiceModel,
|
||||
BankAccountModel,
|
||||
@ -94,6 +95,7 @@ from .utils import (
|
||||
get_calculations,
|
||||
get_car_finance_data,
|
||||
get_financial_values,
|
||||
get_item_transactions,
|
||||
reserve_car,
|
||||
send_email,
|
||||
get_user_type,
|
||||
@ -2348,10 +2350,9 @@ def account_delete(request, pk):
|
||||
|
||||
# Sales list
|
||||
def sales_list_view(request):
|
||||
items = ItemModel.objects.all()
|
||||
context = {
|
||||
"items":items
|
||||
}
|
||||
transactions = ItemTransactionModel.objects.all()[:10]
|
||||
txs = get_item_transactions(transactions)
|
||||
context = {"txs":txs}
|
||||
return render(request, "sales/sales_list.html",context)
|
||||
|
||||
# Estimates
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
from django_ledger.models.invoice import InvoiceModel
|
||||
from django_ledger.utils import accruable_net_summary
|
||||
from decimal import Decimal
|
||||
from django_ledger.models import EstimateModel,EntityModel,ItemModel
|
||||
from django_ledger.models import EstimateModel,EntityModel,ItemModel,ItemTransactionModel
|
||||
from rich import print
|
||||
from datetime import date
|
||||
from inventory.models import Car, Dealer, VatRate,Lead,CarMake,CarModel,Schedule
|
||||
@ -94,9 +94,25 @@ def run():
|
||||
# print(hash_object.hexdigest() , i.id_car_make.name, i.id_car_model.name)
|
||||
|
||||
|
||||
items = ItemModel.objects.all()
|
||||
for item in items:
|
||||
pass
|
||||
def get_item(tx:ItemTransactionModel):
|
||||
data = {"data": {}}
|
||||
data["data"]["info"] = tx.item_model.additional_info.get('car_info')
|
||||
data["data"]["finance"] = tx.item_model.additional_info.get('car_finance')
|
||||
if tx.has_estimate():
|
||||
data["data"]["estimate"] = tx.ce_model
|
||||
data["data"]["has_estimate"] = True
|
||||
data["data"]["customer"] = tx.ce_model.customer
|
||||
if tx.has_invoice():
|
||||
data["data"]["invoice"] = tx.invoice_model
|
||||
data["data"]["has_invoice"] = True
|
||||
data["data"]["customer"] = tx.invoice_model.customer
|
||||
return data
|
||||
|
||||
transactions = ItemTransactionModel.objects.all()
|
||||
output = []
|
||||
for transaction in transactions:
|
||||
output.append(get_item(transaction))
|
||||
print(output)
|
||||
# info = item.additional_info["car_info"]
|
||||
# finance = item.additional_info["car_finance"]
|
||||
# print({"vin":info["make"],"mode":info["model"],"year":info["year"],"trim":info["trim"],"mileage":info["mileage"],"cost_price":finance["cost_price"],"selling_price":finance["selling_price"]})
|
||||
@ -136,6 +136,14 @@
|
||||
</a>
|
||||
<!-- more inner pages-->
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="{% url 'sales_list' %}">
|
||||
<div class="d-flex align-items-center">
|
||||
<span class="nav-link-icon"><span class="fas fa-money-check"></span></span><span class="nav-link-text">{% trans "Sales"|capfirst %}</span>
|
||||
</div>
|
||||
</a>
|
||||
<!-- more inner pages-->
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -29,7 +29,7 @@
|
||||
<div id="projectSummary">
|
||||
<div class="row g-3 justify-content-between align-items-end mb-4">
|
||||
<div class="col-12 col-sm-auto">
|
||||
<ul class="nav nav-links mx-n2" hx-boost="true" hx-push-url='false' hx-target=".table-responsive" hx-select=".table-responsive" hx-swap="innerHTML show:window:top" hx-indicator=".htmx-indicator"
|
||||
{% comment %} <ul class="nav nav-links mx-n2" hx-boost="true" hx-push-url='false' hx-target=".table-responsive" hx-select=".table-responsive" hx-swap="innerHTML show:window:top" hx-indicator=".htmx-indicator"
|
||||
hx-on::before-request="on_before_request()"
|
||||
hx-on::after-request="on_after_request()"
|
||||
>
|
||||
@ -39,7 +39,7 @@
|
||||
<li class="nav-item"><a class="nav-link px-2 py-1" href="{% url 'car_list' %}?status=transfer"><span>Transfer</span><span class="text-body-tertiary fw-semibold">({{stats.transfer}})</span></a></li>
|
||||
<li class="nav-item"><a class="nav-link px-2 py-1" href="{% url 'car_list' %}?status=sold"><span>Sold</span><span class="text-body-tertiary fw-semibold">({{stats.sold}})</span></a></li>
|
||||
<li class="nav-item"><button hx-on:click="toggle_filter()" class="nav-link px-2 py-1"><span>Filter</span><span class="text-body-tertiary fw-semibold"></span></button></li>
|
||||
</ul>
|
||||
</ul> {% endcomment %}
|
||||
</div>
|
||||
<div class="col-12 col-sm-auto">
|
||||
<div class="d-flex align-items-center">
|
||||
@ -129,35 +129,86 @@
|
||||
<table class="table fs-9 mb-0 border-top border-translucent">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="sort white-space-nowrap align-middle ps-0" scope="col" data-sort="projectName" style="width:10%;">Make</th>
|
||||
<th class="sort align-middle ps-3" scope="col" data-sort="assignees" style="width:10%;">Model</th>
|
||||
<th class="sort align-middle ps-3" scope="col" data-sort="start" style="width:10%;">Year</th>
|
||||
<th class="sort align-middle ps-3" scope="col" data-sort="deadline" style="width:15%;">Trim</th>
|
||||
<th class="sort align-middle ps-3" scope="col" data-sort="task" style="width:12%;">VIN</th>
|
||||
<th class="sort align-middle ps-3" scope="col" data-sort="task" style="width:12%;">Receiving Date</th>
|
||||
|
||||
<th class="sort align-middle text-end" scope="col" data-sort="statuses" style="width:10%;">STATUS</th>
|
||||
<th class="sort white-space-nowrap align-middle ps-0" scope="col" data-sort="projectName" style="width:10%;">Customer Name</th>
|
||||
<th class="sort align-middle ps-3" scope="col" data-sort="assignees" style="width:5%;">Customer Address</th>
|
||||
<th class="sort align-middle ps-3" scope="col" data-sort="start" style="width:5%;">Customer Phone</th>
|
||||
<th class="sort align-middle ps-3" scope="col" data-sort="deadline" style="width:5%;">Make</th>
|
||||
<th class="sort align-middle ps-3" scope="col" data-sort="task" style="width:5%;">Model</th>
|
||||
<th class="sort align-middle ps-3" scope="col" data-sort="task" style="width:5%;">VIN</th>
|
||||
<th class="sort align-middle ps-3" scope="col" data-sort="task" style="width:5%;">Trim</th>
|
||||
<th class="sort align-middle ps-3" scope="col" data-sort="task" style="width:5%;">Selling Price</th>
|
||||
<th class="sort align-middle ps-3" scope="col" data-sort="task" style="width:7%;">Estimate</th>
|
||||
<th class="sort align-middle ps-3" scope="col" data-sort="task" style="width:7%;">Invoice</th>
|
||||
<th class="sort align-middle ps-3" scope="col" data-sort="task" style="width:7%;">Sales Staff</th>
|
||||
<th class="sort align-middle text-end" scope="col" style="width:10%;"></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class="list" id="project-list-table-body">
|
||||
{% for car in cars %}
|
||||
{% for tx in txs %}
|
||||
<tr class="position-static">
|
||||
<td class="align-middle time white-space-nowrap ps-0 projectName py-4"><a class="fw-bold fs-8" href="{% url 'car_detail' car.pk %}">{{car.id_car_make}}</a></td>
|
||||
<td class="align-middle white-space-nowrap start ps-3 py-4">
|
||||
<p class="mb-0 fs-9 text-body">{{car.id_car_model}}</p>
|
||||
<td class="align-middle white-space-nowrap deadline ps-3 py-4">
|
||||
<p class="mb-0 fs-9 text-body">{{tx.customer.customer_name}}</p>
|
||||
</td>
|
||||
<td class="align-middle white-space-nowrap deadline ps-3 py-4">
|
||||
<p class="mb-0 fs-9 text-body">{{car.year}}</p>
|
||||
<p class="mb-0 fs-9 text-body">{{tx.customer.address_1}}</p>
|
||||
</td>
|
||||
<td class="align-middle white-space-nowrap deadline ps-3 py-4">
|
||||
<p class="mb-0 fs-9 text-body">{{tx.customer.phone}}</p>
|
||||
</td>
|
||||
<td class="align-middle time white-space-nowrap ps-0 projectName py-4">{{tx.info.make}}</td>
|
||||
<td class="align-middle white-space-nowrap start ps-3 py-4">
|
||||
<p class="mb-0 fs-9 text-body">{{tx.info.model}}</p>
|
||||
</td>
|
||||
<td class="align-middle white-space-nowrap deadline ps-3 py-4">
|
||||
<p class="mb-0 fs-9 text-body">{{tx.info.vin}}</p>
|
||||
</td>
|
||||
<td class="align-middle white-space-nowrap task ps-3 py-4">
|
||||
<p class="fw-bo text-body fs-9 mb-0">{{car.id_car_trim}}</p>
|
||||
<p class="fw-bo text-body fs-9 mb-0">{{tx.info.trim}}</p>
|
||||
</td>
|
||||
<td class="align-middle white-space-nowrap task ps-3 py-4">
|
||||
<p class="fw-bo text-body fs-9 mb-0">{{car.vin}}</p>
|
||||
<p class="fw-bo text-body fs-9 mb-0">{{tx.finance.total}}</p>
|
||||
</td>
|
||||
<td class="align-middle white-space-nowrap task ps-3 py-4">
|
||||
<p class="fw-bo text-body fs-9 mb-0">{{car.receiving_date}}</p>
|
||||
{% if tx.has_estimate %}
|
||||
<p class="fw-bo text-body fs-9 mb-0">
|
||||
<a href="{% url 'estimate_detail' tx.estimate.uuid %}">
|
||||
{{tx.estimate.estimate_number}}
|
||||
</a><br>
|
||||
{% if tx.estimate.status == "draft" %}
|
||||
<span class="badge badge-phoenix badge-phoenix-warning">{{tx.estimate.status}}</span>
|
||||
{% elif tx.estimate.status == "in_review" %}
|
||||
<span class="badge badge-phoenix badge-phoenix-info">{{tx.estimate.status}}</span>
|
||||
{% elif tx.estimate.status == "approved" %}
|
||||
<span class="badge badge-phoenix badge-phoenix-success">{{tx.estimate.status}}</span>
|
||||
{% elif tx.estimate.status == "completed" %}
|
||||
<span class="badge badge-phoenix badge-phoenix-success">{{tx.estimate.status}}</span>
|
||||
{% endif %}
|
||||
</p>
|
||||
{% endif %}
|
||||
</td>
|
||||
<td class="align-middle white-space-nowrap task ps-3 py-4">
|
||||
{% if tx.has_invoice %}
|
||||
<p class="fw-bo text-body fs-9 mb-0">
|
||||
<a href="{% url 'invoice_detail' tx.invoice.uuid %}">
|
||||
{{tx.invoice.invoice_number}}
|
||||
</a><br>
|
||||
{% if tx.invoice.is_draft %}
|
||||
<span class="badge badge-phoenix badge-phoenix-warning">{{tx.invoice.invoice_status}}</span>
|
||||
{% elif tx.invoice.is_review %}
|
||||
<span class="badge badge-phoenix badge-phoenix-info">{{tx.invoice.invoice_status}}</span>
|
||||
{% elif tx.invoice.is_approved %}
|
||||
<span class="badge badge-phoenix badge-phoenix-info">{{tx.invoice.invoice_status}}</span>
|
||||
{% elif tx.invoice.is_completed %}
|
||||
<span class="badge badge-phoenix badge-phoenix-success">{{tx.invoice.invoice_status}}</span>
|
||||
{% elif tx.invoice.is_paid %}
|
||||
<span class="badge badge-phoenix badge-phoenix-success">{{tx.invoice.invoice_status}}</span>
|
||||
{% elif tx.invoice.is_canceled %}
|
||||
<span class="badge badge-phoenix badge-phoenix-danger">{{tx.invoice.invoice_status}}</span>
|
||||
{% elif tx.invoice.is_past_due %}
|
||||
<span class="badge badge-phoenix badge-phoenix-danger">Past Due</span>
|
||||
{% endif %}
|
||||
</p>
|
||||
{% endif %}
|
||||
</td>
|
||||
|
||||
<td class="align-middle white-space-nowrap text-end statuses">
|
||||
@ -186,7 +237,7 @@
|
||||
|
||||
<div class="d-flex flex-wrap align-items-center justify-content-between py-3 pe-0 fs-9 border-bottom border-translucent">
|
||||
<div class="d-flex">
|
||||
<p class="mb-0 d-none d-sm-block me-3 fw-semibold text-body" data-list-info="data-list-info"></p><a class="fw-semibold" href="#!" data-list-view="*">View all<span class="fas fa-angle-right ms-1" data-fa-transform="down-1"></span></a><a class="fw-semibold d-none" href="#!" data-list-view="less">View Less<span class="fas fa-angle-right ms-1" data-fa-transform="down-1"></span></a>
|
||||
|
||||
</div>
|
||||
<div class="d-flex" hx-boost="true" hx-push-url='false' hx-include=".make,.model,.year,.car_status" hx-target=".table-responsive" hx-select=".table-responsive" hx-swap="innerHTML" hx-indicator=".htmx-indicator"
|
||||
hx-on::before-request="on_before_request()"
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user