formating and lintitng

This commit is contained in:
ismail 2025-06-22 20:07:52 +03:00
parent 7b3fc15efd
commit 50db32600b
20 changed files with 3523 additions and 1278 deletions

View File

@ -1355,11 +1355,27 @@ class SaleOrderForm(forms.ModelForm):
class Meta:
model = SaleOrder
fields = [
"customer","expected_delivery_date","estimate","opportunity","comments","order_date","status"]
"customer",
"expected_delivery_date",
"estimate",
"opportunity",
"comments",
"order_date",
"status",
]
widgets = {
"expected_delivery_date": forms.DateInput(attrs={"type": "date", "label": _("Expected Delivery Date")}),
"order_date": forms.DateInput(attrs={"type": "date", "label": _("Order Date")}),
"customer": forms.Select(attrs={"class": "form-control","label": _("Customer"),}),
"expected_delivery_date": forms.DateInput(
attrs={"type": "date", "label": _("Expected Delivery Date")}
),
"order_date": forms.DateInput(
attrs={"type": "date", "label": _("Order Date")}
),
"customer": forms.Select(
attrs={
"class": "form-control",
"label": _("Customer"),
}
),
}

File diff suppressed because it is too large Load Diff

View File

@ -4,14 +4,13 @@ from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('inventory', '0001_initial'),
("inventory", "0001_initial"),
]
operations = [
migrations.RemoveField(
model_name='saleorder',
name='journal_entry',
model_name="saleorder",
name="journal_entry",
),
]

View File

@ -5,16 +5,20 @@ from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('django_ledger', '0022_alter_billmodel_bill_items_and_more'),
('inventory', '0002_remove_saleorder_journal_entry'),
("django_ledger", "0022_alter_billmodel_bill_items_and_more"),
("inventory", "0002_remove_saleorder_journal_entry"),
]
operations = [
migrations.AddField(
model_name='saleorder',
name='journal_entry',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='django_ledger.journalentrymodel'),
model_name="saleorder",
name="journal_entry",
field=models.ForeignKey(
blank=True,
null=True,
on_delete=django.db.models.deletion.SET_NULL,
to="django_ledger.journalentrymodel",
),
),
]

View File

@ -4,58 +4,57 @@ from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('inventory', '0003_saleorder_journal_entry'),
("inventory", "0003_saleorder_journal_entry"),
]
operations = [
migrations.RemoveField(
model_name='saleorder',
name='agreed_price',
model_name="saleorder",
name="agreed_price",
),
migrations.RemoveField(
model_name='saleorder',
name='customer',
model_name="saleorder",
name="customer",
),
migrations.RemoveField(
model_name='saleorder',
name='down_payment_amount',
model_name="saleorder",
name="down_payment_amount",
),
migrations.RemoveField(
model_name='saleorder',
name='estimate',
model_name="saleorder",
name="estimate",
),
migrations.RemoveField(
model_name='saleorder',
name='journal_entry',
model_name="saleorder",
name="journal_entry",
),
migrations.RemoveField(
model_name='saleorder',
name='loan_amount',
model_name="saleorder",
name="loan_amount",
),
migrations.RemoveField(
model_name='saleorder',
name='opportunity',
model_name="saleorder",
name="opportunity",
),
migrations.RemoveField(
model_name='saleorder',
name='payment_method',
model_name="saleorder",
name="payment_method",
),
migrations.RemoveField(
model_name='saleorder',
name='remaining_balance',
model_name="saleorder",
name="remaining_balance",
),
migrations.RemoveField(
model_name='saleorder',
name='total_paid_amount',
model_name="saleorder",
name="total_paid_amount",
),
migrations.RemoveField(
model_name='saleorder',
name='trade_in_value',
model_name="saleorder",
name="trade_in_value",
),
migrations.RemoveField(
model_name='saleorder',
name='trade_in_vehicle',
model_name="saleorder",
name="trade_in_vehicle",
),
]

View File

@ -4,14 +4,13 @@ from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('inventory', '0004_remove_saleorder_agreed_price_and_more'),
("inventory", "0004_remove_saleorder_agreed_price_and_more"),
]
operations = [
migrations.RemoveField(
model_name='saleorder',
name='car',
model_name="saleorder",
name="car",
),
]

View File

@ -5,16 +5,20 @@ from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('inventory', '0005_remove_saleorder_car'),
("inventory", "0005_remove_saleorder_car"),
]
operations = [
migrations.AddField(
model_name='saleorder',
name='dealer',
field=models.ForeignKey(default=1, on_delete=django.db.models.deletion.CASCADE, related_name='sale_orders', to='inventory.dealer'),
model_name="saleorder",
name="dealer",
field=models.ForeignKey(
default=1,
on_delete=django.db.models.deletion.CASCADE,
related_name="sale_orders",
to="inventory.dealer",
),
preserve_default=False,
),
]

View File

@ -5,16 +5,22 @@ from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('django_ledger', '0022_alter_billmodel_bill_items_and_more'),
('inventory', '0006_saleorder_dealer'),
("django_ledger", "0022_alter_billmodel_bill_items_and_more"),
("inventory", "0006_saleorder_dealer"),
]
operations = [
migrations.AddField(
model_name='saleorder',
name='estimate',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='sale_orders', to='django_ledger.estimatemodel', verbose_name='Estimate'),
model_name="saleorder",
name="estimate",
field=models.ForeignKey(
blank=True,
null=True,
on_delete=django.db.models.deletion.CASCADE,
related_name="sale_orders",
to="django_ledger.estimatemodel",
verbose_name="Estimate",
),
),
]

View File

@ -5,15 +5,21 @@ from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('inventory', '0007_saleorder_estimate'),
("inventory", "0007_saleorder_estimate"),
]
operations = [
migrations.AddField(
model_name='saleorder',
name='opportunity',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='sale_orders', to='inventory.opportunity', verbose_name='Opportunity'),
model_name="saleorder",
name="opportunity",
field=models.ForeignKey(
blank=True,
null=True,
on_delete=django.db.models.deletion.CASCADE,
related_name="sale_orders",
to="inventory.opportunity",
verbose_name="Opportunity",
),
),
]

View File

@ -5,15 +5,21 @@ from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('inventory', '0008_saleorder_opportunity'),
("inventory", "0008_saleorder_opportunity"),
]
operations = [
migrations.AddField(
model_name='saleorder',
name='customer',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='sale_orders', to='inventory.customer', verbose_name='Customer'),
model_name="saleorder",
name="customer",
field=models.ForeignKey(
blank=True,
null=True,
on_delete=django.db.models.deletion.CASCADE,
related_name="sale_orders",
to="inventory.customer",
verbose_name="Customer",
),
),
]

View File

@ -6,21 +6,34 @@ from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('inventory', '0009_saleorder_customer'),
("inventory", "0009_saleorder_customer"),
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
]
operations = [
migrations.AlterField(
model_name='saleorder',
name='created_by',
field=models.ForeignKey(blank=True, help_text='The user who created this sales order.', null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='created_sales_orders', to=settings.AUTH_USER_MODEL),
model_name="saleorder",
name="created_by",
field=models.ForeignKey(
blank=True,
help_text="The user who created this sales order.",
null=True,
on_delete=django.db.models.deletion.SET_NULL,
related_name="created_sales_orders",
to=settings.AUTH_USER_MODEL,
),
),
migrations.AlterField(
model_name='saleorder',
name='last_modified_by',
field=models.ForeignKey(blank=True, help_text='The user who last modified this sales order.', null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='modified_sales_orders', to=settings.AUTH_USER_MODEL),
model_name="saleorder",
name="last_modified_by",
field=models.ForeignKey(
blank=True,
help_text="The user who last modified this sales order.",
null=True,
on_delete=django.db.models.deletion.SET_NULL,
related_name="modified_sales_orders",
to=settings.AUTH_USER_MODEL,
),
),
]

View File

@ -2479,7 +2479,6 @@ class SaleOrder(models.Model):
return self.invoice.get_itemtxs_data()[0]
return []
@property
def cars(self):
if self.items:
@ -2497,6 +2496,7 @@ class CustomGroup(models.Model):
@property
def entity(self):
return self.invoice.entity
@property
def users(self):
return self.group.user_set.all()

View File

@ -309,7 +309,9 @@ def update_item_model_cost(sender, instance, created, **kwargs):
# entity.get_all_accounts()
# .filter(name="Cash", role=roles.ASSET_CA_CASH)
# .first()
entity.get_all_accounts().filter(role=roles.ASSET_CA_CASH,role_default=True).first()
entity.get_all_accounts()
.filter(role=roles.ASSET_CA_CASH, role_default=True)
.first()
)
ledger = LedgerModel.objects.create(

View File

@ -9,6 +9,7 @@ from django.forms import ValidationError
from django.utils.formats import number_format
from django_ledger.io.io_core import get_localdate, validate_activity
from django_ledger.models import InvoiceModel, JournalEntryModel, BillModel
register = template.Library()
@ -452,7 +453,9 @@ def po_item_formset_table(context, po_model, itemtxs_formset):
# print(len(itemtxs_formset.forms))
for form in itemtxs_formset.forms:
form.fields['item_model'].queryset = form.fields['item_model'].queryset.filter(item_role="inventory")
form.fields["item_model"].queryset = form.fields["item_model"].queryset.filter(
item_role="inventory"
)
return {
"entity_slug": context["view"].kwargs["entity_slug"],
"po_model": po_model,
@ -604,27 +607,26 @@ def get_vehicle_type_name(car_serie):
return "sedan"
@register.filter
def status_badge_color(status):
color_map = {
'PENDING_APPROVAL': 'warning',
'APPROVED': 'info',
'IN_FINANCING': 'primary',
'PARTIALLY_PAID': 'success',
'FULLY_PAID': 'success',
'PENDING_DELIVERY': 'warning',
'DELIVERED': 'success',
'CANCELLED': 'danger',
"PENDING_APPROVAL": "warning",
"APPROVED": "info",
"IN_FINANCING": "primary",
"PARTIALLY_PAID": "success",
"FULLY_PAID": "success",
"PENDING_DELIVERY": "warning",
"DELIVERED": "success",
"CANCELLED": "danger",
}
return color_map.get(status, 'secondary')
return color_map.get(status, "secondary")
@register.inclusion_tag('inventory/tags/inventory_table.html', takes_context=True)
@register.inclusion_tag("inventory/tags/inventory_table.html", takes_context=True)
def inventory_table(context, queryset):
ctx = {
'entity_slug': context['view'].kwargs['entity_slug'],
'inventory_list': queryset
"entity_slug": context["view"].kwargs["entity_slug"],
"inventory_list": queryset,
}
ctx.update(queryset.aggregate(inventory_total_value=Sum('total_value')))
return ctx
ctx.update(queryset.aggregate(inventory_total_value=Sum("total_value")))
return ctx

View File

@ -375,9 +375,16 @@ urlpatterns = [
views.sales_list_view,
name="sales_list",
),
path('sale_orders/<int:pk>/', views.SaleOrderDetailView.as_view(), name='order_detail'),
path('inventory/<slug:entity_slug>/list/', views.InventoryListView.as_view(), name='inventort_list'),
path(
"sale_orders/<int:pk>/",
views.SaleOrderDetailView.as_view(),
name="order_detail",
),
path(
"inventory/<slug:entity_slug>/list/",
views.InventoryListView.as_view(),
name="inventort_list",
),
# Sales URLs quotation_create
# path(
# "sales/quotations/create/",

View File

@ -3626,26 +3626,28 @@ def sales_list_view(request):
context = {"txs": page_obj, "page_obj": page_obj}
return render(request, "sales/sales_list.html", context)
class SaleOrderDetailView(LoginRequiredMixin, DetailView):
model = models.SaleOrder
template_name = 'sales/saleorder_detail.html'
context_object_name = 'sale_order'
template_name = "sales/saleorder_detail.html"
context_object_name = "sale_order"
def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
sale_order = self.get_object()
# Add additional context data
context['status_choices'] = dict(models.SaleOrder.STATUS_CHOICES)
context['page_title'] = _('Sales Order Details')
context["status_choices"] = dict(models.SaleOrder.STATUS_CHOICES)
context["page_title"] = _("Sales Order Details")
# Calculate any additional properties you want to display
context['is_delivered'] = sale_order.status == 'DELIVERED'
context['is_cancelled'] = sale_order.status == 'CANCELLED'
context['is_pending_approval'] = sale_order.status == 'PENDING_APPROVAL'
context["is_delivered"] = sale_order.status == "DELIVERED"
context["is_cancelled"] = sale_order.status == "CANCELLED"
context["is_pending_approval"] = sale_order.status == "PENDING_APPROVAL"
return context
# Estimates
class EstimateListView(LoginRequiredMixin, PermissionRequiredMixin, ListView):
"""
@ -4042,8 +4044,7 @@ def create_sale_order(request, pk):
customer = estimate.customer.customer_set.first()
form.fields["estimate"].queryset = EstimateModel.objects.filter(pk=pk)
form.initial["estimate"] = estimate
form.fields["customer"].queryset = models.Customer.objects.filter(
pk=customer.pk)
form.fields["customer"].queryset = models.Customer.objects.filter(pk=customer.pk)
form.initial["customer"] = customer
if hasattr(estimate, "opportunity"):
form.initial["opportunity"] = estimate.opportunity
@ -4569,7 +4570,6 @@ def invoice_create(request, pk):
}
)
context = {
"form": form,
"estimate": estimate,
@ -8966,7 +8966,11 @@ def InventoryItemCreateView(request):
trim_name = models.CarTrim.objects.get(pk=trim)
inventory_name = f"{make_name.name} || {model_name.name} || {serie_name.name} || {trim_name.name} || {year} || {exterior.name} || {interior.name}"
if inventory := entity.get_items_inventory().filter(name=inventory_name).first():
if (
inventory := entity.get_items_inventory()
.filter(name=inventory_name)
.first()
):
messages.error(request, _("Inventory item already exists"))
return redirect(f"{reverse('inventory_item_create')}?for_po={for_po}")
uom = entity.get_uom_all().get(name="Unit")
@ -9123,8 +9127,8 @@ class PurchaseOrderUpdateView(PurchaseOrderModelUpdateViewBase):
else:
itemtxs_qs, itemtxs_agg = po_model.get_itemtxs_data()
context['itemtxs_qs'] = itemtxs_qs
context['itemtxs_formset'] = itemtxs_formset
context["itemtxs_qs"] = itemtxs_qs
context["itemtxs_formset"] = itemtxs_formset
return context
def get_success_url(self):
@ -9255,7 +9259,7 @@ class BasePurchaseOrderActionActionView(BasePurchaseOrderActionActionViewBase):
po_model: PurchaseOrderModel = self.get_object()
try:
getattr(po_model, self.action_name)(commit=self.commit,**kwargs)
getattr(po_model, self.action_name)(commit=self.commit, **kwargs)
messages.add_message(
request,
message="PO updated successfully.",
@ -9510,7 +9514,6 @@ def bulk_update_car_price(request):
return response
class InventoryListView(InventoryListViewBase):
template_name = "inventory/list.html"
@ -9521,4 +9524,4 @@ class InventoryListView(InventoryListViewBase):
self.queryset = ItemTransactionModel.objects.inventory_pipeline_aggregate(
entity_slug=dealer.entity.slug,
)
return super().get_queryset()
return super().get_queryset()

View File

@ -3,297 +3,297 @@
{%block title%} {%trans 'Stocks'%} {%endblock%}
{% block customCSS %}
<style>
.htmx-indicator {
opacity: 0;
transition: opacity 500ms ease-in;
}
.htmx-request .htmx-indicator {
opacity: 1;
}
.htmx-request.htmx-indicator {
opacity: 1;
}
.on-before-request {
opacity: 0.5;
pointer-events: none;
}
.transition {
transition: all ease-in 1s;
}
</style>
<style>
.htmx-indicator {
opacity: 0;
transition: opacity 500ms ease-in;
}
.htmx-request .htmx-indicator {
opacity: 1;
}
.htmx-request.htmx-indicator {
opacity: 1;
}
.on-before-request {
opacity: 0.5;
pointer-events: none;
}
.transition {
transition: all ease-in 1s;
}
</style>
{% endblock customCSS %}
{% block content %}
<div class="mb-9">
<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"
hx-on::before-request="on_before_request()"
hx-on::after-request="on_after_request()">
<li class="nav-item">
<a class="nav-link px-2 py-1 active" aria-current="page" href="{% url 'car_list' %}"><span>{{ _("All") }}</span><span class="text-body-tertiary fw-semibold">({{ stats.all }})</span></a>
</li>
<li class="nav-item">
<a class="nav-link px-2 py-1" href="{% url 'car_list' %}?status=available"><span>{{ _("Available") }}</span><span class="text-body-tertiary fw-semibold">({{ stats.available }})</span></a>
</li>
<li class="nav-item">
<a class="nav-link px-2 py-1" href="{% url 'car_list' %}?status=reserved"><span>{{ _("Reserved") }}</span><span class="text-body-tertiary fw-semibold">({{ stats.reserved }})</span></a>
</li>
<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="btn btn-sm btn-phoenix-primary px-2 py-1">
<span><span class="fa fa-filter me-1"></span>{{ _("Filter") }}</span><span class="fas fa-caret-down fs-9 ms-1 filter-icon"></span>
</button>
</li>
</ul>
</div>
<div class="col-12 col-sm-auto">
<div class="d-flex align-items-center">
<div class="spinner-border mx-3 htmx-indicator" role="status">
<span class="visually-hidden">Loading...</span>
</div>
<div class="search-box me-3">
<form class="position-relative">
<input
class="form-control search-input search"
name="search"
type="search"
placeholder="Search"
aria-label="Search"
hx-get="{% url 'car_list' %}"
hx-trigger="keyup changed delay:500ms"
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()"
/>
<span class="fas fa-search search-box-icon"></span>
</form>
</div>
</div>
</div>
</div>
<div class="d-flex align-items-center d-none filter">
<select
hx-get="{% url 'car_list' %}"
name="make"
hx-target=".model-select"
hx-select=".model-select"
hx-swap="outerHTML show:window:top"
hx-indicator=".htmx-indicator"
class="form-select form-control-sm me-1 make"
aria-label="Default select example"
hx-on::before-request="filter_before_request()"
hx-on::after-request="filter_after_request()">
<option selected="" value="" disabled>{{ _("Make") }}</option>
{% for m in make %}
<option value="{{ m.pk }}">{{ m.get_local_name|default:m.name }}</option>
{% endfor %}
</select>
<select
hx-get="{% url 'car_list' %}"
hx-include=".make"
name="model"
hx-target=".year"
hx-select=".year"
hx-swap="outerHTML show:window:top"
hx-indicator=".htmx-indicator"
class="form-select form-control-sm me-1 model-select"
aria-label="Default select example"
hx-on::before-request="filter_before_request()"
hx-on::after-request="filter_after_request()">
<option selected="" value="" disabled>{{ _("Model") }}</option>
{% for m in model %}
<option value="{{ m.pk }}">{{ m.get_local_name|default:m.name }}</option>
{% endfor %}
</select>
<select class="form-select form-control-sm me-1 year" name="year" aria-label="Default select example">
<option selected="" value="" disabled>{{ _("Year") }}</option>
{% for y in year %}
<option value="{{ y.0 }}">{{ y.0 }}</option>
{% endfor %}
</select>
<select class="form-select form-control-sm me-1 car_status" name="car_status" aria-label="Default select example">
<option selected="" value="">{{ _("All") }}</option>
<option value="available">{{ _("Available") }}</option>
<option value="reserved">{{ _("Reserved") }}</option>
<option value="sold">{{ _("Sold") }}</option>
<option value="transfer">{{ _("Transfer") }}</option>
</select>
<button
id="search"
hx-get="{% url 'car_list' %}"
hx-include=".make,.model,.year,.car_status"
hx-indicator=".htmx-indicator"
hx-target=".table-responsive"
hx-select=".table-responsive"
hx-swap="outerHTML show:window:top"
class="btn btn-sm btn-phoenix-primary ms-1"
hx-on::before-request="filter_before_request()"
hx-on::after-request="filter_after_request()">
{{ _("Search") }}
</button>
</div>
<div class="row">
<form hx-boost="true" action="{% url 'bulk_update_car_price' %}" method="post" hx-include=".car-checkbox" class="update-price-form d-flex flex-row align-items-center ms-auto w-25 d-none" style="float: right;">
{% csrf_token %}
<div class="form-floating me-2">
<input class="form-control" type="number" placeholder='{{ _("Search") }}' name="price" aria-label="Price" id="price" />
<label for="price">{{ _("Price") }}</label>
</div>
<button class="btn btn-outline-primary" type="submit">{{ _("Search") }}</button>
</form>
<div class="table-responsive scrollbar transition">
<div class="d-flex flex-wrap align-items-center justify-content-between py-3 pe-0 fs-9">
<div
class="d-flex"
<div class="mb-9">
<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-include=".make,.model,.year,.car_status"
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()"></div>
<div class="w-100 list table-responsive" >
<div class="form-check">
<input class="form-check-input ms-4" type="checkbox" id="select-all" /> <span class="ms-1 text-body-tertiary">{{ _("Select All") }}</span>
hx-on::after-request="on_after_request()">
<li class="nav-item">
<a class="nav-link px-2 py-1 active" aria-current="page" href="{% url 'car_list' %}"><span>{{ _("All") }}</span><span class="text-body-tertiary fw-semibold">({{ stats.all }})</span></a>
</li>
<li class="nav-item">
<a class="nav-link px-2 py-1" href="{% url 'car_list' %}?status=available"><span>{{ _("Available") }}</span><span class="text-body-tertiary fw-semibold">({{ stats.available }})</span></a>
</li>
<li class="nav-item">
<a class="nav-link px-2 py-1" href="{% url 'car_list' %}?status=reserved"><span>{{ _("Reserved") }}</span><span class="text-body-tertiary fw-semibold">({{ stats.reserved }})</span></a>
</li>
<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="btn btn-sm btn-phoenix-primary px-2 py-1">
<span><span class="fa fa-filter me-1"></span>{{ _("Filter") }}</span><span class="fas fa-caret-down fs-9 ms-1 filter-icon"></span>
</button>
</li>
</ul>
</div>
<div class="col-12 col-sm-auto">
<div class="d-flex align-items-center">
<div class="spinner-border mx-3 htmx-indicator" role="status">
<span class="visually-hidden">Loading...</span>
</div>
{% for car in cars %}
<div class="card border mb-3 py-0 px-0" id="project-list-table-body">
<div class="card-body">
<div class="row align-items-center">
<div class="col-auto">
<div class="form-check">
<input class="form-check-input car-checkbox" type="checkbox" name="car" value="{{ car.pk }}" id="car-{{car.pk}}" />
</div>
</div>
<!-- Vehicle Image/Icon -->
<div class="col-auto">
<div class="avatar avatar-3xl">
<img class="rounded-soft shadow shadow-lg" src="{% static 'images/cars/' %}{{ car.vin }}.png" alt="{{ car.vin }}" />
</div>
</div>
<!-- Vehicle Details -->
<div class="col">
<div class="row">
<!-- Make/Model/Specs -->
<div class="col-md-4">
<h5 class="text-body-emphasis fw-bold">{{ car.year }}</h5>
<p class="text-body-emphasis fw-bold">
<a href="{% url 'car_detail' car.slug %}" class="text-decoration-none text-body-emphasis">
{{ car.id_car_make.get_local_name }}
</a>
<small>{{ car.id_car_model.get_local_name }}</small>
</p>
<small class="text-body-secondary" dir="ltr">
{{ car.id_car_trim }}
</small>
<div class="search-box me-3">
<form class="position-relative">
<input
class="form-control search-input search"
name="search"
type="search"
placeholder="Search"
aria-label="Search"
hx-get="{% url 'car_list' %}"
hx-trigger="keyup changed delay:500ms"
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()"
/>
<span class="fas fa-search search-box-icon"></span>
</form>
</div>
</div>
</div>
</div>
<div class="d-flex align-items-center d-none filter">
<select
hx-get="{% url 'car_list' %}"
name="make"
hx-target=".model-select"
hx-select=".model-select"
hx-swap="outerHTML show:window:top"
hx-indicator=".htmx-indicator"
class="form-select form-control-sm me-1 make"
aria-label="Default select example"
hx-on::before-request="filter_before_request()"
hx-on::after-request="filter_after_request()">
<option selected="" value="" disabled>{{ _("Make") }}</option>
{% for m in make %}
<option value="{{ m.pk }}">{{ m.get_local_name|default:m.name }}</option>
{% endfor %}
</select>
<select
hx-get="{% url 'car_list' %}"
hx-include=".make"
name="model"
hx-target=".year"
hx-select=".year"
hx-swap="outerHTML show:window:top"
hx-indicator=".htmx-indicator"
class="form-select form-control-sm me-1 model-select"
aria-label="Default select example"
hx-on::before-request="filter_before_request()"
hx-on::after-request="filter_after_request()">
<option selected="" value="" disabled>{{ _("Model") }}</option>
{% for m in model %}
<option value="{{ m.pk }}">{{ m.get_local_name|default:m.name }}</option>
{% endfor %}
</select>
<select class="form-select form-control-sm me-1 year" name="year" aria-label="Default select example">
<option selected="" value="" disabled>{{ _("Year") }}</option>
{% for y in year %}
<option value="{{ y.0 }}">{{ y.0 }}</option>
{% endfor %}
</select>
<select class="form-select form-control-sm me-1 car_status" name="car_status" aria-label="Default select example">
<option selected="" value="">{{ _("All") }}</option>
<option value="available">{{ _("Available") }}</option>
<option value="reserved">{{ _("Reserved") }}</option>
<option value="sold">{{ _("Sold") }}</option>
<option value="transfer">{{ _("Transfer") }}</option>
</select>
<button
id="search"
hx-get="{% url 'car_list' %}"
hx-include=".make,.model,.year,.car_status"
hx-indicator=".htmx-indicator"
hx-target=".table-responsive"
hx-select=".table-responsive"
hx-swap="outerHTML show:window:top"
class="btn btn-sm btn-phoenix-primary ms-1"
hx-on::before-request="filter_before_request()"
hx-on::after-request="filter_after_request()">
{{ _("Search") }}
</button>
</div>
<div class="row">
<form hx-boost="true" action="{% url 'bulk_update_car_price' %}" method="post" hx-include=".car-checkbox" class="update-price-form d-flex flex-row align-items-center ms-auto w-25 d-none" style="float: right;">
{% csrf_token %}
<div class="form-floating me-2">
<input class="form-control" type="number" placeholder='{{ _("Search") }}' name="price" aria-label="Price" id="price" />
<label for="price">{{ _("Price") }}</label>
</div>
<button class="btn btn-outline-primary" type="submit">{{ _("Search") }}</button>
</form>
<div class="table-responsive scrollbar transition">
<div class="d-flex flex-wrap align-items-center justify-content-between py-3 pe-0 fs-9">
<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 show:window:top"
hx-indicator=".htmx-indicator"
hx-on::before-request="on_before_request()"
hx-on::after-request="on_after_request()"></div>
<div class="w-100 list table-responsive" >
<div class="form-check">
<input class="form-check-input ms-4" type="checkbox" id="select-all" /> <span class="ms-1 text-body-tertiary">{{ _("Select All") }}</span>
</div>
{% for car in cars %}
<div class="card border mb-3 py-0 px-0" id="project-list-table-body">
<div class="card-body">
<div class="row align-items-center">
<div class="col-auto">
<div class="form-check">
<input class="form-check-input car-checkbox" type="checkbox" name="car" value="{{ car.pk }}" id="car-{{car.pk}}" />
</div>
</div>
<!-- Vehicle Image/Icon -->
<div class="col-auto">
<div class="avatar avatar-3xl">
<img class="rounded-soft shadow shadow-lg" src="{% static 'images/cars/' %}{{ car.vin }}.png" alt="{{ car.vin }}" />
</div>
</div>
<!-- Vehicle Details -->
<div class="col">
<div class="row">
<!-- Make/Model/Specs -->
<div class="col-md-4">
<h5 class="text-body-emphasis fw-bold">{{ car.year }}</h5>
<p class="text-body-emphasis fw-bold">
<a href="{% url 'car_detail' car.slug %}" class="text-decoration-none text-body-emphasis">
{{ car.id_car_make.get_local_name }}
</a>
<small>{{ car.id_car_model.get_local_name }}</small>
</p>
<small class="text-body-secondary" dir="ltr">
{{ car.id_car_trim }}
</small>
</div>
<!-- Color and Date -->
<div class="col-md-3">
<p class="text-body mb-1">
{{ car.colors.exterior.get_local_name }}
</p>
<small class="text-body-secondary">
{{ car.receiving_date|naturalday|capfirst }}
</small>
</div>
<div class="col-md-3">
<p class="text-body mb-1">
{{ car.colors.exterior.get_local_name }}
</p>
<small class="text-body-secondary">
{{ car.receiving_date|naturalday|capfirst }}
</small>
</div>
<!-- Status Badge -->
<div class="col-md-3">
{% if car.status == "available" %}
<span class="badge badge-phoenix fs-10 badge-phoenix-success text-uppercase px-3 py-2">{{ _("Available") }}</span>
{% elif car.status == "reserved" %}
<span class="badge badge-phoenix fs-10 badge-phoenix-warning text-uppercase px-3 py-2">{{ _("Reserved") }}</span>
{% elif car.status == "sold" %}
<span class="badge badge-phoenix fs-10 badge-phoenix-danger text-uppercase px-3 py-2">{{ _("Sold") }}</span>
{% elif car.status == "transfer" %}
<span class="badge badge-phoenix fs-10 badge-phoenix-info text-uppercase px-3 py-2">{{ _("Transfer") }}</span>
{% endif %}
</div>
<div class="col-md-3">
{% if car.status == "available" %}
<span class="badge badge-phoenix fs-10 badge-phoenix-success text-uppercase px-3 py-2">{{ _("Available") }}</span>
{% elif car.status == "reserved" %}
<span class="badge badge-phoenix fs-10 badge-phoenix-warning text-uppercase px-3 py-2">{{ _("Reserved") }}</span>
{% elif car.status == "sold" %}
<span class="badge badge-phoenix fs-10 badge-phoenix-danger text-uppercase px-3 py-2">{{ _("Sold") }}</span>
{% elif car.status == "transfer" %}
<span class="badge badge-phoenix fs-10 badge-phoenix-info text-uppercase px-3 py-2">{{ _("Transfer") }}</span>
{% endif %}
</div>
<!-- Ready Status -->
<div class="col-md-2">
<div class="d-flex align-items-center">
<span class="fs-10 fw-light me-2">{{ _("Inventory Ready") }}</span>
{% if car.ready %}
<span class="badge bg-success rounded-circle p-1 me-2">
<span class="visually-hidden">Ready</span>
</span>
<span class="text-success fw-bold">{{ _("Yes") }}</span>
{% else %}
<span class="badge bg-danger rounded-circle p-1 me-2">
<span class="visually-hidden">Not Ready</span>
</span>
<span class="text-danger fw-bold">{{ _("No") }}</span>
{% endif %}
<div class="col-md-2">
<div class="d-flex align-items-center">
<span class="fs-10 fw-light me-2">{{ _("Inventory Ready") }}</span>
{% if car.ready %}
<span class="badge bg-success rounded-circle p-1 me-2">
<span class="visually-hidden">Ready</span>
</span>
<span class="text-success fw-bold">{{ _("Yes") }}</span>
{% else %}
<span class="badge bg-danger rounded-circle p-1 me-2">
<span class="visually-hidden">Not Ready</span>
</span>
<span class="text-danger fw-bold">{{ _("No") }}</span>
{% endif %}
</div>
</div>
</div>
</div>
<!-- Action Menu -->
<div class="col-auto">
<div class="btn-reveal-trigger position-static">
<button
class="btn btn-sm dropdown-toggle dropdown-caret-none transition-none btn-reveal fs-10"
type="button"
data-bs-toggle="dropdown"
data-boundary="window"
aria-haspopup="true"
aria-expanded="false"
data-bs-reference="parent">
<span class="fas fa-ellipsis-h fs-10"></span>
</button>
<div class="dropdown-menu dropdown-menu-end py-2">
<a class="dropdown-item" href="{% url 'car_detail' car.slug %}"> <span class="fas fa-eye me-2"></span>{{ _("View") }} </a>
<a class="dropdown-item" href="{% url 'car_update' car.slug %}"> <span class="fas fa-edit me-2"></span>{{ _("Edit") }} </a>
<div class="dropdown-divider"></div>
<a class="dropdown-item text-danger" href="{% url 'car_delete' car.slug %}"> <span class="fas fa-trash me-2"></span>{{ _("Remove") }} </a>
</div>
</div>
</div>
</div>
</div>
<!-- Action Menu -->
<div class="col-auto">
<div class="btn-reveal-trigger position-static">
<button
class="btn btn-sm dropdown-toggle dropdown-caret-none transition-none btn-reveal fs-10"
type="button"
data-bs-toggle="dropdown"
data-boundary="window"
aria-haspopup="true"
aria-expanded="false"
data-bs-reference="parent">
<span class="fas fa-ellipsis-h fs-10"></span>
</button>
<div class="dropdown-menu dropdown-menu-end py-2">
<a class="dropdown-item" href="{% url 'car_detail' car.slug %}"> <span class="fas fa-eye me-2"></span>{{ _("View") }} </a>
<a class="dropdown-item" href="{% url 'car_update' car.slug %}"> <span class="fas fa-edit me-2"></span>{{ _("Edit") }} </a>
<div class="dropdown-divider"></div>
<a class="dropdown-item text-danger" href="{% url 'car_delete' car.slug %}"> <span class="fas fa-trash me-2"></span>{{ _("Remove") }} </a>
</div>
</div>
</div>
{% empty %}
<div class="text-center py-5">
<div class="text-body-secondary">
<span class="fas fa-car fa-4x mb-3 opacity-50"></span>
<h4 class="text-body-secondary">{{ _("No vehicles found") }}</h4>
<p class="text-body-tertiary">{{ _("Try adjusting your search criteria or filters") }}</p>
</div>
</div>
</div>
{% endfor %}
</div>
{% empty %}
<div class="text-center py-5">
<div class="text-body-secondary">
<span class="fas fa-car fa-4x mb-3 opacity-50"></span>
<h4 class="text-body-secondary">{{ _("No vehicles found") }}</h4>
<p class="text-body-tertiary">{{ _("Try adjusting your search criteria or filters") }}</p>
</div>
</div>
{% endfor %}
</div>
</div>
<div class="d-flex justify-content-end mt-3">
<div class="d-flex">
{% if is_paginated %} {% include 'partials/pagination.html' %} {% endif %}
<div class="d-flex justify-content-end mt-3">
<div class="d-flex">
{% if is_paginated %} {% include 'partials/pagination.html' %} {% endif %}
</div>
</div>
</div>
</div>
</div>
</div>
{% endblock %} {% block customJS %}
{% endblock %} {% block customJS %}
<script>
links = document.querySelectorAll(".nav-link");
links.forEach((link) => {
@ -357,5 +357,5 @@
}
}
</script>
{% endblock customJS %}
{% endblock customJS %}
</div>

View File

@ -4,80 +4,80 @@
{% load custom_filters %}
{% block content %}
<div class="container-fluid px-4 py-4">
<div class="row g-4">
<div class="container-fluid px-4 py-4">
<div class="row g-4">
<!-- Inventory Ordered Card -->
<div class="col-12">
<div class="card shadow-sm border-0">
<div class="card-header text-white">
<h2 class="h4 mb-0 fw-light text-center">
<i class="bi bi-cart-check me-2"></i>{% trans "Inventory Ordered" %}
</h2>
</div>
<div class="card-body p-0">
{% if inventory_ordered %}
<div class="table-responsive">
{% inventory_table inventory_ordered %}
</div>
{% else %}
<div class="p-4 text-center text-muted">
<i class="bi bi-box-seam display-6 mb-3"></i>
<p class="lead mb-0">{% trans "No inventory in ordered status." %}</p>
</div>
{% endif %}
<div class="col-12">
<div class="card shadow-sm border-0">
<div class="card-header text-white">
<h2 class="h4 mb-0 fw-light text-center">
<i class="bi bi-cart-check me-2"></i>{% trans "Inventory Ordered" %}
</h2>
</div>
<div class="card-body p-0">
{% if inventory_ordered %}
<div class="table-responsive">
{% inventory_table inventory_ordered %}
</div>
{% else %}
<div class="p-4 text-center text-muted">
<i class="bi bi-box-seam display-6 mb-3"></i>
<p class="lead mb-0">{% trans "No inventory in ordered status." %}</p>
</div>
{% endif %}
</div>
</div>
</div>
</div>
<!-- Inventory In Transit Card -->
<div class="col-12">
<div class="card shadow-sm border-0">
<div class="card-header text-white">
<h2 class="h4 mb-0 fw-light text-center">
<i class="bi bi-truck me-2"></i>{% trans "Inventory In Transit" %}
</h2>
</div>
<div class="card-body p-0">
{% if inventory_in_transit %}
<div class="table-responsive">
{% inventory_table inventory_in_transit %}
</div>
{% else %}
<div class="p-4 text-center text-muted">
<i class="bi bi-box-seam display-6 mb-3"></i>
<p class="lead mb-0">{% trans "No inventory in transit." %}</p>
</div>
{% endif %}
<div class="col-12">
<div class="card shadow-sm border-0">
<div class="card-header text-white">
<h2 class="h4 mb-0 fw-light text-center">
<i class="bi bi-truck me-2"></i>{% trans "Inventory In Transit" %}
</h2>
</div>
<div class="card-body p-0">
{% if inventory_in_transit %}
<div class="table-responsive">
{% inventory_table inventory_in_transit %}
</div>
{% else %}
<div class="p-4 text-center text-muted">
<i class="bi bi-box-seam display-6 mb-3"></i>
<p class="lead mb-0">{% trans "No inventory in transit." %}</p>
</div>
{% endif %}
</div>
</div>
</div>
</div>
<!-- Inventory Received Card -->
<div class="col-12">
<div class="card shadow-sm border-0">
<div class="card-header text-white">
<h2 class="h4 mb-0 fw-light text-center">
<i class="bi bi-check-circle me-2"></i>{% trans "Inventory Received" %}
</h2>
</div>
<div class="card-body p-0">
{% if inventory_received %}
<div class="table-responsive">
{% inventory_table inventory_received %}
</div>
{% else %}
<div class="p-4 text-center text-muted">
<i class="bi bi-box-seam display-6 mb-3"></i>
<p class="lead mb-0">{% trans "No inventory in received status." %}</p>
</div>
{% endif %}
<div class="col-12">
<div class="card shadow-sm border-0">
<div class="card-header text-white">
<h2 class="h4 mb-0 fw-light text-center">
<i class="bi bi-check-circle me-2"></i>{% trans "Inventory Received" %}
</h2>
</div>
<div class="card-body p-0">
{% if inventory_received %}
<div class="table-responsive">
{% inventory_table inventory_received %}
</div>
{% else %}
<div class="p-4 text-center text-muted">
<i class="bi bi-box-seam display-6 mb-3"></i>
<p class="lead mb-0">{% trans "No inventory in received status." %}</p>
</div>
{% endif %}
</div>
</div>
</div>
</div>
<!-- Action Button -->
<div class="col-12 text-end mt-3">
</div>
<div class="col-12 text-end mt-3">
</div>
</div>
</div>
</div>
{% endblock %}

View File

@ -128,64 +128,64 @@
</ul>
</div>
</div>
</div>
<!-- Status -->
<div class="col-md-6">
{{form.status|as_crispy_field}}
</div>
<div class="col-md-6">
{{form.status|as_crispy_field}}
</div>
</div>
</div>
<!-- Financial Details Section -->
<div class="form-section">
<h4 class="form-section-header">
<i class="fas fa-money-bill-wave me-2"></i> Financial Details
</h4>
</div>
<div class="form-section">
<h4 class="form-section-header">
<i class="fas fa-money-bill-wave me-2"></i> Financial Details
</h4>
</div>
<!-- Delivery Information Section -->
<div class="form-section">
<h4 class="form-section-header">
<i class="fas fa-truck me-2"></i> Delivery Information
</h4>
<div class="form-section">
<h4 class="form-section-header">
<i class="fas fa-truck me-2"></i> Delivery Information
</h4>
<div class="row g-3">
<div class="row g-3">
<!-- Expected Delivery Date -->
<div class="col-md-6">
{{form.order_date|as_crispy_field}}
</div>
<div class="col-md-6">
{{form.expected_delivery_date|as_crispy_field}}
</div>
<div class="col-md-6">
{{form.order_date|as_crispy_field}}
</div>
<div class="col-md-6">
{{form.expected_delivery_date|as_crispy_field}}
</div>
</div>
<!-- Comments -->
<div class="col-12">
<label for="comments" class="form-label">Comments</label>
<textarea class="form-control" id="comments" rows="3" placeholder="Enter any additional comments..."></textarea>
</div>
<div class="col-12">
<label for="comments" class="form-label">Comments</label>
<textarea class="form-control" id="comments" rows="3" placeholder="Enter any additional comments..."></textarea>
</div>
</div>
<!-- Form Actions -->
<div class="form-actions mt-4">
<div class="d-flex justify-content-between">
<a href="{% url 'estimate_detail' estimate.pk %}" type="button" class="btn btn-phoenix-secondary">
<i class="fas fa-times me-2"></i> Cancel
</a>
<div>
<div class="form-actions mt-4">
<div class="d-flex justify-content-between">
<a href="{% url 'estimate_detail' estimate.pk %}" type="button" class="btn btn-phoenix-secondary">
<i class="fas fa-times me-2"></i> Cancel
</a>
<div>
<button type="submit" class="btn btn-phoenix-primary">
<i class="fas fa-check-circle me-2"></i> Submit Order
</button>
</div>
<button type="submit" class="btn btn-phoenix-primary">
<i class="fas fa-check-circle me-2"></i> Submit Order
</button>
</div>
</div>
</form>
</div>
</div>
</form>
</div>
</div>
</div>

View File

@ -5,265 +5,265 @@
{% block title %}{{ page_title }} - {{ sale_order.formatted_order_id }}{% endblock %}
{% block content %}
<div class="container mt-4">
<div class="card">
<div class="card-header">
<h2 class="mb-0">
{% trans "Sales Order" %} #{{ sale_order.formatted_order_id }}
<span class="badge bg-{{ sale_order.status|status_badge_color }} float-end">
{{ status_choices|get_item:sale_order.status }}
</span>
</h2>
</div>
<div class="container mt-4">
<div class="card">
<div class="card-header">
<h2 class="mb-0">
{% trans "Sales Order" %} #{{ sale_order.formatted_order_id }}
<span class="badge bg-{{ sale_order.status|status_badge_color }} float-end">
{{ status_choices|get_item:sale_order.status }}
</span>
</h2>
</div>
<div class="card-body">
<div class="card-body">
<!-- Basic Information -->
<div class="row mb-4">
<div class="col-md-6">
<h4>{% trans "Customer Information" %}</h4>
<p>
<strong>{% trans "Name" %}:</strong> {{ sale_order.full_name }}<br>
{% if sale_order.customer %}
<strong>{% trans "Contact" %}:</strong> {{ sale_order.customer.phone_number }}<br>
<strong>{% trans "Email" %}:</strong> {{ sale_order.customer.email }}
{% endif %}
</p>
</div>
<div class="col-md-6">
<h4>{% trans "Order Details" %}</h4>
<p>
<strong>{% trans "Order Date" %}:</strong> {{ sale_order.order_date|date }}<br>
<strong>{% trans "Dealer" %}:</strong> {{ sale_order.dealer.name }}<br>
<strong>{% trans "Created By" %}:</strong> {{ sale_order.created_by }}
</p>
</div>
</div>
<!-- Estimate Information -->
{% if sale_order.estimate %}
<div class="row mb-4">
<div class="col-12">
<h4>{% trans "Estimate Information" %}</h4>
<div class="card">
<div class="card-body">
<div class="row">
<div class="col-md-6">
<p>
<strong>{% trans "Estimate Number" %}:</strong> {{ sale_order.estimate.estimate_number }}<br>
<strong>{% trans "Date" %}:</strong> {{ sale_order.estimate.created|date }}<br>
<strong>{% trans "Status" %}:</strong> <span class="badge {% if sale_order.estimate.status == 'draft' %}bg-warning{% elif sale_order.estimate.status == 'in_review' %}bg-info{% elif sale_order.estimate.status == 'approved' %}bg-primary{% elif sale_order.estimate.status == 'completed' %}bg-success{% elif sale_order.estimate.status == 'canceled' %}bg-danger{% endif %}">{{ sale_order.estimate.get_status_display }}</span>
</p>
</div>
<div class="col-md-6">
</div>
</div>
{% if sale_order.estimate.notes %}
<div class="mt-3">
<strong>{% trans "Notes" %}:</strong>
<div class="border p-2 mt-1">{{ sale_order.estimate.notes|linebreaks }}</div>
</div>
{% endif %}
</div>
</div>
</div>
</div>
{% endif %}
<!-- Invoice Information -->
{% if sale_order.invoice %}
<div class="row mb-4">
<div class="col-12">
<h4>{% trans "Invoice Information" %}</h4>
<div class="card">
<div class="card-body">
<div class="row">
<div class="col-md-6">
<p>
<strong>{% trans "Invoice Number" %}:</strong> {{ sale_order.invoice.invoice_number }}<br>
<strong>{% trans "Date" %}:</strong> {{ sale_order.invoice.created|date }}<br>
<strong>{% trans "Status" %}:</strong>
<span class="badge {% if sale_order.invoice.invoice_status == 'draft' %}bg-warning{% elif sale_order.invoice.invoice_status == 'in_review' %}bg-info{% elif sale_order.invoice.invoice_status == 'approved' %}bg-primary{% elif sale_order.invoice.invoice_status == 'paid' %}bg-success{% elif sale_order.invoice.invoice_status == 'declined' %}bg-danger{% endif %}">
{{ sale_order.invoice.invoice_status|capfirst }}
</span>
</p>
</div>
<div class="col-md-6">
<p>
<table>
<tbody>
<tr>
<td style="padding-right: 0.5rem;"><strong>{% trans "Amount Paid" %}:</strong></td>
<td style="padding-left: 0.5rem;"><span class="currency">{{CURRENCY}}</span>{{ sale_order.invoice.amount_paid|floatformat:2 }}</td>
</tr>
<tr>
<td style="padding-right: 0.5rem;"><strong>{% trans "Balance Due" %}:</strong></td>
<td style="padding-left: 0.5rem;"><span class="currency">{{CURRENCY}}</span>{{ sale_order.invoice.amount_due|floatformat:2 }}</td>
</tr>
<tr>
<td style="padding-right: 0.5rem;"><strong>{% trans "Amount Unearned" %}:</strong></td>
<td style="padding-left: 0.5rem;"><span class="currency">{{CURRENCY}}</span>{{ sale_order.invoice.amount_unearned|floatformat:2 }}</td>
</tr>
<tr>
<td style="padding-right: 0.5rem;"><strong>{% trans "Amount Receivable" %}:</strong></td>
<td style="padding-left: 0.5rem;"><span class="currency">{{CURRENCY}}</span>{{ sale_order.invoice.amount_receivable|floatformat:2 }}</td>
</tr>
</tbody>
</table>
</p>
</div>
</div>
{% if sale_order.invoice.notes %}
<div class="mt-3">
<strong>{% trans "Notes" %}:</strong>
<div class="border p-2 mt-1">{{ sale_order.invoice.notes|linebreaks }}</div>
</div>
{% endif %}
</div>
</div>
</div>
</div>
{% endif %}
<!-- Ledger Information -->
{% if sale_order.invoice.ledger %}
<div class="row mb-4">
<div class="col-12">
<h4>{% trans "Ledger Information" %}</h4>
<div class="card">
<div class="card-body">
<div class="row">
<div class="col-md-6">
<p>
<strong>{% trans "Ledger Number" %}: </strong><a href="{% url 'ledger_detail' entity_slug=sale_order.invoice.ledger.entity.slug pk=sale_order.invoice.ledger.pk %}" target="_blank" rel="noopener noreferrer"> {{ sale_order.invoice.ledger }} <i class="fa fa-external-link" aria-hidden="true"></i></a><br>
<strong>{% trans "Date" %}:</strong> {{ sale_order.invoice.ledger.created|date }}<br>
</p>
</div>
<div class="col-md-6">
<p>
<table>
<tbody>
{% for je in sale_order.invoice.ledger.journal_entries.all %}
<tr>
<td style="padding-right: 0.5rem;"><strong>{{je}}</strong></td>
</tr>
{% endfor %}
</tbody>
</table>
</p>
</div>
</div>
{% if sale_order.invoice.notes %}
<div class="mt-3">
<strong>{% trans "Notes" %}:</strong>
<div class="border p-2 mt-1">{{ sale_order.invoice.notes|linebreaks }}</div>
</div>
{% endif %}
</div>
</div>
</div>
</div>
{% endif %}
<!-- Delivery Information -->
{% if sale_order.expected_delivery_date or sale_order.actual_delivery_date %}
<div class="row mb-4">
<div class="col-12">
<h4>{% trans "Delivery Information" %}</h4>
<p>
{% if sale_order.expected_delivery_date %}
<strong>{% trans "Expected Delivery" %}:</strong> {{ sale_order.expected_delivery_date|date:"DATE_FORMAT" }}<br>
{% endif %}
{% if sale_order.actual_delivery_date %}
<strong>{% trans "Actual Delivery" %}:</strong> {{ sale_order.actual_delivery_date|date:"DATETIME_FORMAT" }}
{% endif %}
</p>
</div>
</div>
{% endif %}
<!-- Cars/Items -->
{% if sale_order.cars %}
<div class="row mb-4">
<div class="col-12">
<h4>{% trans "Vehicles" %}</h4>
<div class="table-responsive">
<table class="table table-striped">
<thead>
<tr>
<th>{% trans "Make" %}</th>
<th>{% trans "Model" %}</th>
<th>{% trans "Year" %}</th>
<th>{% trans "VIN" %}</th>
<th>{% trans "Price" %}</th>
</tr>
</thead>
<tbody>
{% for car in sale_order.cars %}
<tr>
<td>{{ car.id_car_make }}</td>
<td>{{ car.id_car_model }}</td>
<td>{{ car.year }}</td>
<td>{{ car.vin }}</td>
<td><span class="currency">{{CURRENCY}}</span>{{ car.finances.selling_price|floatformat:2 }}</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
</div>
{% endif %}
<!-- Cancellation Info -->
{% if is_cancelled %}
<div class="row mb-4">
<div class="col-12">
<div class="alert alert-danger">
<h4>{% trans "Order Cancelled" %}</h4>
<div class="row mb-4">
<div class="col-md-6">
<h4>{% trans "Customer Information" %}</h4>
<p>
<strong>{% trans "Cancellation Date" %}:</strong> {{ sale_order.cancelled_date|date:"DATETIME_FORMAT" }}<br>
<strong>{% trans "Reason" %}:</strong> {{ sale_order.cancellation_reason }}
<strong>{% trans "Name" %}:</strong> {{ sale_order.full_name }}<br>
{% if sale_order.customer %}
<strong>{% trans "Contact" %}:</strong> {{ sale_order.customer.phone_number }}<br>
<strong>{% trans "Email" %}:</strong> {{ sale_order.customer.email }}
{% endif %}
</p>
</div>
<div class="col-md-6">
<h4>{% trans "Order Details" %}</h4>
<p>
<strong>{% trans "Order Date" %}:</strong> {{ sale_order.order_date|date }}<br>
<strong>{% trans "Dealer" %}:</strong> {{ sale_order.dealer.name }}<br>
<strong>{% trans "Created By" %}:</strong> {{ sale_order.created_by }}
</p>
</div>
</div>
</div>
{% endif %}
<!-- Comments -->
{% if sale_order.comments %}
<div class="row">
<div class="col-12">
<h4>{% trans "Comments" %}</h4>
<div class="card bg-light">
<div class="card-body">
{{ sale_order.comments|linebreaks }}
<!-- Estimate Information -->
{% if sale_order.estimate %}
<div class="row mb-4">
<div class="col-12">
<h4>{% trans "Estimate Information" %}</h4>
<div class="card">
<div class="card-body">
<div class="row">
<div class="col-md-6">
<p>
<strong>{% trans "Estimate Number" %}:</strong> {{ sale_order.estimate.estimate_number }}<br>
<strong>{% trans "Date" %}:</strong> {{ sale_order.estimate.created|date }}<br>
<strong>{% trans "Status" %}:</strong> <span class="badge {% if sale_order.estimate.status == 'draft' %}bg-warning{% elif sale_order.estimate.status == 'in_review' %}bg-info{% elif sale_order.estimate.status == 'approved' %}bg-primary{% elif sale_order.estimate.status == 'completed' %}bg-success{% elif sale_order.estimate.status == 'canceled' %}bg-danger{% endif %}">{{ sale_order.estimate.get_status_display }}</span>
</p>
</div>
<div class="col-md-6">
</div>
</div>
{% if sale_order.estimate.notes %}
<div class="mt-3">
<strong>{% trans "Notes" %}:</strong>
<div class="border p-2 mt-1">{{ sale_order.estimate.notes|linebreaks }}</div>
</div>
{% endif %}
</div>
</div>
</div>
</div>
</div>
</div>
{% endif %}
</div>
{% endif %}
<div class="card-footer text-end">
<a href="{% url 'order_list' %}" class="btn btn-secondary">
{% trans "Back to List" %}
</a>
<!-- Invoice Information -->
{% if sale_order.invoice %}
<div class="row mb-4">
<div class="col-12">
<h4>{% trans "Invoice Information" %}</h4>
<div class="card">
<div class="card-body">
<div class="row">
<div class="col-md-6">
<p>
<strong>{% trans "Invoice Number" %}:</strong> {{ sale_order.invoice.invoice_number }}<br>
<strong>{% trans "Date" %}:</strong> {{ sale_order.invoice.created|date }}<br>
<strong>{% trans "Status" %}:</strong>
<span class="badge {% if sale_order.invoice.invoice_status == 'draft' %}bg-warning{% elif sale_order.invoice.invoice_status == 'in_review' %}bg-info{% elif sale_order.invoice.invoice_status == 'approved' %}bg-primary{% elif sale_order.invoice.invoice_status == 'paid' %}bg-success{% elif sale_order.invoice.invoice_status == 'declined' %}bg-danger{% endif %}">
{{ sale_order.invoice.invoice_status|capfirst }}
</span>
</p>
</div>
<div class="col-md-6">
<p>
<table>
<tbody>
<tr>
<td style="padding-right: 0.5rem;"><strong>{% trans "Amount Paid" %}:</strong></td>
<td style="padding-left: 0.5rem;"><span class="currency">{{CURRENCY}}</span>{{ sale_order.invoice.amount_paid|floatformat:2 }}</td>
</tr>
<tr>
<td style="padding-right: 0.5rem;"><strong>{% trans "Balance Due" %}:</strong></td>
<td style="padding-left: 0.5rem;"><span class="currency">{{CURRENCY}}</span>{{ sale_order.invoice.amount_due|floatformat:2 }}</td>
</tr>
<tr>
<td style="padding-right: 0.5rem;"><strong>{% trans "Amount Unearned" %}:</strong></td>
<td style="padding-left: 0.5rem;"><span class="currency">{{CURRENCY}}</span>{{ sale_order.invoice.amount_unearned|floatformat:2 }}</td>
</tr>
<tr>
<td style="padding-right: 0.5rem;"><strong>{% trans "Amount Receivable" %}:</strong></td>
<td style="padding-left: 0.5rem;"><span class="currency">{{CURRENCY}}</span>{{ sale_order.invoice.amount_receivable|floatformat:2 }}</td>
</tr>
</tbody>
</table>
</p>
</div>
</div>
{% if sale_order.invoice.notes %}
<div class="mt-3">
<strong>{% trans "Notes" %}:</strong>
<div class="border p-2 mt-1">{{ sale_order.invoice.notes|linebreaks }}</div>
</div>
{% endif %}
</div>
</div>
</div>
</div>
{% endif %}
<!-- Ledger Information -->
{% if sale_order.invoice.ledger %}
<div class="row mb-4">
<div class="col-12">
<h4>{% trans "Ledger Information" %}</h4>
<div class="card">
<div class="card-body">
<div class="row">
<div class="col-md-6">
<p>
<strong>{% trans "Ledger Number" %}: </strong><a href="{% url 'ledger_detail' entity_slug=sale_order.invoice.ledger.entity.slug pk=sale_order.invoice.ledger.pk %}" target="_blank" rel="noopener noreferrer"> {{ sale_order.invoice.ledger }} <i class="fa fa-external-link" aria-hidden="true"></i></a><br>
<strong>{% trans "Date" %}:</strong> {{ sale_order.invoice.ledger.created|date }}<br>
</p>
</div>
<div class="col-md-6">
<p>
<table>
<tbody>
{% for je in sale_order.invoice.ledger.journal_entries.all %}
<tr>
<td style="padding-right: 0.5rem;"><strong>{{je}}</strong></td>
</tr>
{% endfor %}
</tbody>
</table>
</p>
</div>
</div>
{% if sale_order.invoice.notes %}
<div class="mt-3">
<strong>{% trans "Notes" %}:</strong>
<div class="border p-2 mt-1">{{ sale_order.invoice.notes|linebreaks }}</div>
</div>
{% endif %}
</div>
</div>
</div>
</div>
{% endif %}
<!-- Delivery Information -->
{% if sale_order.expected_delivery_date or sale_order.actual_delivery_date %}
<div class="row mb-4">
<div class="col-12">
<h4>{% trans "Delivery Information" %}</h4>
<p>
{% if sale_order.expected_delivery_date %}
<strong>{% trans "Expected Delivery" %}:</strong> {{ sale_order.expected_delivery_date|date:"DATE_FORMAT" }}<br>
{% endif %}
{% if sale_order.actual_delivery_date %}
<strong>{% trans "Actual Delivery" %}:</strong> {{ sale_order.actual_delivery_date|date:"DATETIME_FORMAT" }}
{% endif %}
</p>
</div>
</div>
{% endif %}
<!-- Cars/Items -->
{% if sale_order.cars %}
<div class="row mb-4">
<div class="col-12">
<h4>{% trans "Vehicles" %}</h4>
<div class="table-responsive">
<table class="table table-striped">
<thead>
<tr>
<th>{% trans "Make" %}</th>
<th>{% trans "Model" %}</th>
<th>{% trans "Year" %}</th>
<th>{% trans "VIN" %}</th>
<th>{% trans "Price" %}</th>
</tr>
</thead>
<tbody>
{% for car in sale_order.cars %}
<tr>
<td>{{ car.id_car_make }}</td>
<td>{{ car.id_car_model }}</td>
<td>{{ car.year }}</td>
<td>{{ car.vin }}</td>
<td><span class="currency">{{CURRENCY}}</span>{{ car.finances.selling_price|floatformat:2 }}</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
</div>
{% endif %}
<!-- Cancellation Info -->
{% if is_cancelled %}
<div class="row mb-4">
<div class="col-12">
<div class="alert alert-danger">
<h4>{% trans "Order Cancelled" %}</h4>
<p>
<strong>{% trans "Cancellation Date" %}:</strong> {{ sale_order.cancelled_date|date:"DATETIME_FORMAT" }}<br>
<strong>{% trans "Reason" %}:</strong> {{ sale_order.cancellation_reason }}
</p>
</div>
</div>
</div>
{% endif %}
<!-- Comments -->
{% if sale_order.comments %}
<div class="row">
<div class="col-12">
<h4>{% trans "Comments" %}</h4>
<div class="card bg-light">
<div class="card-body">
{{ sale_order.comments|linebreaks }}
</div>
</div>
</div>
</div>
{% endif %}
</div>
<div class="card-footer text-end">
<a href="{% url 'order_list' %}" class="btn btn-secondary">
{% trans "Back to List" %}
</a>
<!-- Add links to view full estimate and invoice if they exist -->
{% if sale_order.estimate %}
<a href="{% url 'estimate_detail' sale_order.estimate.pk %}" class="btn btn-info ms-2">
{% trans "View Full Estimate" %}
</a>
{% endif %}
{% if sale_order.estimate %}
<a href="{% url 'estimate_detail' sale_order.estimate.pk %}" class="btn btn-info ms-2">
{% trans "View Full Estimate" %}
</a>
{% endif %}
{% if sale_order.invoice %}
<a href="{% url 'invoice_detail' sale_order.invoice.pk %}" class="btn btn-info ms-2">
{% trans "View Full Invoice" %}
</a>
{% endif %}
{% if sale_order.invoice %}
<a href="{% url 'invoice_detail' sale_order.invoice.pk %}" class="btn btn-info ms-2">
{% trans "View Full Invoice" %}
</a>
{% endif %}
</div>
</div>
</div>
</div>
{% endblock %}