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: class Meta:
model = SaleOrder model = SaleOrder
fields = [ fields = [
"customer","expected_delivery_date","estimate","opportunity","comments","order_date","status"] "customer",
"expected_delivery_date",
"estimate",
"opportunity",
"comments",
"order_date",
"status",
]
widgets = { widgets = {
"expected_delivery_date": forms.DateInput(attrs={"type": "date", "label": _("Expected Delivery Date")}), "expected_delivery_date": forms.DateInput(
"order_date": forms.DateInput(attrs={"type": "date", "label": _("Order Date")}), attrs={"type": "date", "label": _("Expected Delivery Date")}
"customer": forms.Select(attrs={"class": "form-control","label": _("Customer"),}), ),
"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): class Migration(migrations.Migration):
dependencies = [ dependencies = [
('inventory', '0001_initial'), ("inventory", "0001_initial"),
] ]
operations = [ operations = [
migrations.RemoveField( migrations.RemoveField(
model_name='saleorder', model_name="saleorder",
name='journal_entry', name="journal_entry",
), ),
] ]

View File

@ -5,16 +5,20 @@ from django.db import migrations, models
class Migration(migrations.Migration): class Migration(migrations.Migration):
dependencies = [ dependencies = [
('django_ledger', '0022_alter_billmodel_bill_items_and_more'), ("django_ledger", "0022_alter_billmodel_bill_items_and_more"),
('inventory', '0002_remove_saleorder_journal_entry'), ("inventory", "0002_remove_saleorder_journal_entry"),
] ]
operations = [ operations = [
migrations.AddField( migrations.AddField(
model_name='saleorder', model_name="saleorder",
name='journal_entry', name="journal_entry",
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='django_ledger.journalentrymodel'), 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): class Migration(migrations.Migration):
dependencies = [ dependencies = [
('inventory', '0003_saleorder_journal_entry'), ("inventory", "0003_saleorder_journal_entry"),
] ]
operations = [ operations = [
migrations.RemoveField( migrations.RemoveField(
model_name='saleorder', model_name="saleorder",
name='agreed_price', name="agreed_price",
), ),
migrations.RemoveField( migrations.RemoveField(
model_name='saleorder', model_name="saleorder",
name='customer', name="customer",
), ),
migrations.RemoveField( migrations.RemoveField(
model_name='saleorder', model_name="saleorder",
name='down_payment_amount', name="down_payment_amount",
), ),
migrations.RemoveField( migrations.RemoveField(
model_name='saleorder', model_name="saleorder",
name='estimate', name="estimate",
), ),
migrations.RemoveField( migrations.RemoveField(
model_name='saleorder', model_name="saleorder",
name='journal_entry', name="journal_entry",
), ),
migrations.RemoveField( migrations.RemoveField(
model_name='saleorder', model_name="saleorder",
name='loan_amount', name="loan_amount",
), ),
migrations.RemoveField( migrations.RemoveField(
model_name='saleorder', model_name="saleorder",
name='opportunity', name="opportunity",
), ),
migrations.RemoveField( migrations.RemoveField(
model_name='saleorder', model_name="saleorder",
name='payment_method', name="payment_method",
), ),
migrations.RemoveField( migrations.RemoveField(
model_name='saleorder', model_name="saleorder",
name='remaining_balance', name="remaining_balance",
), ),
migrations.RemoveField( migrations.RemoveField(
model_name='saleorder', model_name="saleorder",
name='total_paid_amount', name="total_paid_amount",
), ),
migrations.RemoveField( migrations.RemoveField(
model_name='saleorder', model_name="saleorder",
name='trade_in_value', name="trade_in_value",
), ),
migrations.RemoveField( migrations.RemoveField(
model_name='saleorder', model_name="saleorder",
name='trade_in_vehicle', name="trade_in_vehicle",
), ),
] ]

View File

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

View File

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

View File

@ -5,16 +5,22 @@ from django.db import migrations, models
class Migration(migrations.Migration): class Migration(migrations.Migration):
dependencies = [ dependencies = [
('django_ledger', '0022_alter_billmodel_bill_items_and_more'), ("django_ledger", "0022_alter_billmodel_bill_items_and_more"),
('inventory', '0006_saleorder_dealer'), ("inventory", "0006_saleorder_dealer"),
] ]
operations = [ operations = [
migrations.AddField( migrations.AddField(
model_name='saleorder', model_name="saleorder",
name='estimate', 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'), 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): class Migration(migrations.Migration):
dependencies = [ dependencies = [
('inventory', '0007_saleorder_estimate'), ("inventory", "0007_saleorder_estimate"),
] ]
operations = [ operations = [
migrations.AddField( migrations.AddField(
model_name='saleorder', model_name="saleorder",
name='opportunity', 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'), 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): class Migration(migrations.Migration):
dependencies = [ dependencies = [
('inventory', '0008_saleorder_opportunity'), ("inventory", "0008_saleorder_opportunity"),
] ]
operations = [ operations = [
migrations.AddField( migrations.AddField(
model_name='saleorder', model_name="saleorder",
name='customer', 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'), 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): class Migration(migrations.Migration):
dependencies = [ dependencies = [
('inventory', '0009_saleorder_customer'), ("inventory", "0009_saleorder_customer"),
migrations.swappable_dependency(settings.AUTH_USER_MODEL), migrations.swappable_dependency(settings.AUTH_USER_MODEL),
] ]
operations = [ operations = [
migrations.AlterField( migrations.AlterField(
model_name='saleorder', model_name="saleorder",
name='created_by', 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), 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( migrations.AlterField(
model_name='saleorder', model_name="saleorder",
name='last_modified_by', 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), 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 self.invoice.get_itemtxs_data()[0]
return [] return []
@property @property
def cars(self): def cars(self):
if self.items: if self.items:
@ -2497,6 +2496,7 @@ class CustomGroup(models.Model):
@property @property
def entity(self): def entity(self):
return self.invoice.entity return self.invoice.entity
@property @property
def users(self): def users(self):
return self.group.user_set.all() 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() # entity.get_all_accounts()
# .filter(name="Cash", role=roles.ASSET_CA_CASH) # .filter(name="Cash", role=roles.ASSET_CA_CASH)
# .first() # .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( ledger = LedgerModel.objects.create(

View File

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

View File

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

View File

@ -3626,26 +3626,28 @@ def sales_list_view(request):
context = {"txs": page_obj, "page_obj": page_obj} context = {"txs": page_obj, "page_obj": page_obj}
return render(request, "sales/sales_list.html", context) return render(request, "sales/sales_list.html", context)
class SaleOrderDetailView(LoginRequiredMixin, DetailView): class SaleOrderDetailView(LoginRequiredMixin, DetailView):
model = models.SaleOrder model = models.SaleOrder
template_name = 'sales/saleorder_detail.html' template_name = "sales/saleorder_detail.html"
context_object_name = 'sale_order' context_object_name = "sale_order"
def get_context_data(self, **kwargs): def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs) context = super().get_context_data(**kwargs)
sale_order = self.get_object() sale_order = self.get_object()
# Add additional context data # Add additional context data
context['status_choices'] = dict(models.SaleOrder.STATUS_CHOICES) context["status_choices"] = dict(models.SaleOrder.STATUS_CHOICES)
context['page_title'] = _('Sales Order Details') context["page_title"] = _("Sales Order Details")
# Calculate any additional properties you want to display # Calculate any additional properties you want to display
context['is_delivered'] = sale_order.status == 'DELIVERED' context["is_delivered"] = sale_order.status == "DELIVERED"
context['is_cancelled'] = sale_order.status == 'CANCELLED' context["is_cancelled"] = sale_order.status == "CANCELLED"
context['is_pending_approval'] = sale_order.status == 'PENDING_APPROVAL' context["is_pending_approval"] = sale_order.status == "PENDING_APPROVAL"
return context return context
# Estimates # Estimates
class EstimateListView(LoginRequiredMixin, PermissionRequiredMixin, ListView): class EstimateListView(LoginRequiredMixin, PermissionRequiredMixin, ListView):
""" """
@ -4042,8 +4044,7 @@ def create_sale_order(request, pk):
customer = estimate.customer.customer_set.first() customer = estimate.customer.customer_set.first()
form.fields["estimate"].queryset = EstimateModel.objects.filter(pk=pk) form.fields["estimate"].queryset = EstimateModel.objects.filter(pk=pk)
form.initial["estimate"] = estimate form.initial["estimate"] = estimate
form.fields["customer"].queryset = models.Customer.objects.filter( form.fields["customer"].queryset = models.Customer.objects.filter(pk=customer.pk)
pk=customer.pk)
form.initial["customer"] = customer form.initial["customer"] = customer
if hasattr(estimate, "opportunity"): if hasattr(estimate, "opportunity"):
form.initial["opportunity"] = estimate.opportunity form.initial["opportunity"] = estimate.opportunity
@ -4569,7 +4570,6 @@ def invoice_create(request, pk):
} }
) )
context = { context = {
"form": form, "form": form,
"estimate": estimate, "estimate": estimate,
@ -8966,7 +8966,11 @@ def InventoryItemCreateView(request):
trim_name = models.CarTrim.objects.get(pk=trim) 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}" 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")) messages.error(request, _("Inventory item already exists"))
return redirect(f"{reverse('inventory_item_create')}?for_po={for_po}") return redirect(f"{reverse('inventory_item_create')}?for_po={for_po}")
uom = entity.get_uom_all().get(name="Unit") uom = entity.get_uom_all().get(name="Unit")
@ -9123,8 +9127,8 @@ class PurchaseOrderUpdateView(PurchaseOrderModelUpdateViewBase):
else: else:
itemtxs_qs, itemtxs_agg = po_model.get_itemtxs_data() itemtxs_qs, itemtxs_agg = po_model.get_itemtxs_data()
context['itemtxs_qs'] = itemtxs_qs context["itemtxs_qs"] = itemtxs_qs
context['itemtxs_formset'] = itemtxs_formset context["itemtxs_formset"] = itemtxs_formset
return context return context
def get_success_url(self): def get_success_url(self):
@ -9255,7 +9259,7 @@ class BasePurchaseOrderActionActionView(BasePurchaseOrderActionActionViewBase):
po_model: PurchaseOrderModel = self.get_object() po_model: PurchaseOrderModel = self.get_object()
try: try:
getattr(po_model, self.action_name)(commit=self.commit,**kwargs) getattr(po_model, self.action_name)(commit=self.commit, **kwargs)
messages.add_message( messages.add_message(
request, request,
message="PO updated successfully.", message="PO updated successfully.",
@ -9510,7 +9514,6 @@ def bulk_update_car_price(request):
return response return response
class InventoryListView(InventoryListViewBase): class InventoryListView(InventoryListViewBase):
template_name = "inventory/list.html" template_name = "inventory/list.html"
@ -9521,4 +9524,4 @@ class InventoryListView(InventoryListViewBase):
self.queryset = ItemTransactionModel.objects.inventory_pipeline_aggregate( self.queryset = ItemTransactionModel.objects.inventory_pipeline_aggregate(
entity_slug=dealer.entity.slug, 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 title%} {%trans 'Stocks'%} {%endblock%}
{% block customCSS %} {% block customCSS %}
<style> <style>
.htmx-indicator { .htmx-indicator {
opacity: 0; opacity: 0;
transition: opacity 500ms ease-in; transition: opacity 500ms ease-in;
} }
.htmx-request .htmx-indicator { .htmx-request .htmx-indicator {
opacity: 1; opacity: 1;
} }
.htmx-request.htmx-indicator { .htmx-request.htmx-indicator {
opacity: 1; opacity: 1;
} }
.on-before-request { .on-before-request {
opacity: 0.5; opacity: 0.5;
pointer-events: none; pointer-events: none;
} }
.transition { .transition {
transition: all ease-in 1s; transition: all ease-in 1s;
} }
</style> </style>
{% endblock customCSS %} {% endblock customCSS %}
{% block content %} {% block content %}
<div class="mb-9"> <div class="mb-9">
<div id="projectSummary"> <div id="projectSummary">
<div class="row g-3 justify-content-between align-items-end mb-4"> <div class="row g-3 justify-content-between align-items-end mb-4">
<div class="col-12 col-sm-auto"> <div class="col-12 col-sm-auto">
<ul <ul
class="nav nav-links mx-n2" 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"
hx-boost="true" hx-boost="true"
hx-push-url="false" hx-push-url="false"
hx-include=".make,.model,.year,.car_status"
hx-target=".table-responsive" hx-target=".table-responsive"
hx-select=".table-responsive" hx-select=".table-responsive"
hx-swap="innerHTML show:window:top" hx-swap="innerHTML show:window:top"
hx-indicator=".htmx-indicator" hx-indicator=".htmx-indicator"
hx-on::before-request="on_before_request()" hx-on::before-request="on_before_request()"
hx-on::after-request="on_after_request()"></div> hx-on::after-request="on_after_request()">
<div class="w-100 list table-responsive" > <li class="nav-item">
<div class="form-check"> <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>
<input class="form-check-input ms-4" type="checkbox" id="select-all" /> <span class="ms-1 text-body-tertiary">{{ _("Select All") }}</span> </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>
{% for car in cars %} <div class="search-box me-3">
<div class="card border mb-3 py-0 px-0" id="project-list-table-body"> <form class="position-relative">
<div class="card-body"> <input
<div class="row align-items-center"> class="form-control search-input search"
<div class="col-auto"> name="search"
<div class="form-check"> type="search"
<input class="form-check-input car-checkbox" type="checkbox" name="car" value="{{ car.pk }}" id="car-{{car.pk}}" /> placeholder="Search"
</div> aria-label="Search"
</div> hx-get="{% url 'car_list' %}"
<!-- Vehicle Image/Icon --> hx-trigger="keyup changed delay:500ms"
<div class="col-auto"> hx-target=".table-responsive"
<div class="avatar avatar-3xl"> hx-select=".table-responsive"
<img class="rounded-soft shadow shadow-lg" src="{% static 'images/cars/' %}{{ car.vin }}.png" alt="{{ car.vin }}" /> hx-swap="innerHTML show:window:top"
</div> hx-indicator=".htmx-indicator"
</div> hx-on::before-request="on_before_request()"
<!-- Vehicle Details --> hx-on::after-request="on_after_request()"
<div class="col"> />
<div class="row"> <span class="fas fa-search search-box-icon"></span>
<!-- Make/Model/Specs --> </form>
<div class="col-md-4"> </div>
<h5 class="text-body-emphasis fw-bold">{{ car.year }}</h5> </div>
<p class="text-body-emphasis fw-bold"> </div>
<a href="{% url 'car_detail' car.slug %}" class="text-decoration-none text-body-emphasis"> </div>
{{ car.id_car_make.get_local_name }} <div class="d-flex align-items-center d-none filter">
</a> <select
<small>{{ car.id_car_model.get_local_name }}</small> hx-get="{% url 'car_list' %}"
</p> name="make"
<small class="text-body-secondary" dir="ltr"> hx-target=".model-select"
{{ car.id_car_trim }} hx-select=".model-select"
</small> 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> </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 --> <!-- Color and Date -->
<div class="col-md-3"> <div class="col-md-3">
<p class="text-body mb-1"> <p class="text-body mb-1">
{{ car.colors.exterior.get_local_name }} {{ car.colors.exterior.get_local_name }}
</p> </p>
<small class="text-body-secondary"> <small class="text-body-secondary">
{{ car.receiving_date|naturalday|capfirst }} {{ car.receiving_date|naturalday|capfirst }}
</small> </small>
</div> </div>
<!-- Status Badge --> <!-- Status Badge -->
<div class="col-md-3"> <div class="col-md-3">
{% if car.status == "available" %} {% if car.status == "available" %}
<span class="badge badge-phoenix fs-10 badge-phoenix-success text-uppercase px-3 py-2">{{ _("Available") }}</span> <span class="badge badge-phoenix fs-10 badge-phoenix-success text-uppercase px-3 py-2">{{ _("Available") }}</span>
{% elif car.status == "reserved" %} {% elif car.status == "reserved" %}
<span class="badge badge-phoenix fs-10 badge-phoenix-warning text-uppercase px-3 py-2">{{ _("Reserved") }}</span> <span class="badge badge-phoenix fs-10 badge-phoenix-warning text-uppercase px-3 py-2">{{ _("Reserved") }}</span>
{% elif car.status == "sold" %} {% elif car.status == "sold" %}
<span class="badge badge-phoenix fs-10 badge-phoenix-danger text-uppercase px-3 py-2">{{ _("Sold") }}</span> <span class="badge badge-phoenix fs-10 badge-phoenix-danger text-uppercase px-3 py-2">{{ _("Sold") }}</span>
{% elif car.status == "transfer" %} {% elif car.status == "transfer" %}
<span class="badge badge-phoenix fs-10 badge-phoenix-info text-uppercase px-3 py-2">{{ _("Transfer") }}</span> <span class="badge badge-phoenix fs-10 badge-phoenix-info text-uppercase px-3 py-2">{{ _("Transfer") }}</span>
{% endif %} {% endif %}
</div> </div>
<!-- Ready Status --> <!-- Ready Status -->
<div class="col-md-2"> <div class="col-md-2">
<div class="d-flex align-items-center"> <div class="d-flex align-items-center">
<span class="fs-10 fw-light me-2">{{ _("Inventory Ready") }}</span> <span class="fs-10 fw-light me-2">{{ _("Inventory Ready") }}</span>
{% if car.ready %} {% if car.ready %}
<span class="badge bg-success rounded-circle p-1 me-2"> <span class="badge bg-success rounded-circle p-1 me-2">
<span class="visually-hidden">Ready</span> <span class="visually-hidden">Ready</span>
</span> </span>
<span class="text-success fw-bold">{{ _("Yes") }}</span> <span class="text-success fw-bold">{{ _("Yes") }}</span>
{% else %} {% else %}
<span class="badge bg-danger rounded-circle p-1 me-2"> <span class="badge bg-danger rounded-circle p-1 me-2">
<span class="visually-hidden">Not Ready</span> <span class="visually-hidden">Not Ready</span>
</span> </span>
<span class="text-danger fw-bold">{{ _("No") }}</span> <span class="text-danger fw-bold">{{ _("No") }}</span>
{% endif %} {% 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>
</div> </div>
</div> </div>
</div>
<!-- Action Menu --> {% empty %}
<div class="col-auto"> <div class="text-center py-5">
<div class="btn-reveal-trigger position-static"> <div class="text-body-secondary">
<button <span class="fas fa-car fa-4x mb-3 opacity-50"></span>
class="btn btn-sm dropdown-toggle dropdown-caret-none transition-none btn-reveal fs-10" <h4 class="text-body-secondary">{{ _("No vehicles found") }}</h4>
type="button" <p class="text-body-tertiary">{{ _("Try adjusting your search criteria or filters") }}</p>
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> </div>
</div> {% endfor %}
</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>
{% endfor %}
</div> </div>
</div> <div class="d-flex justify-content-end mt-3">
<div class="d-flex justify-content-end mt-3"> <div class="d-flex">
<div class="d-flex"> {% if is_paginated %} {% include 'partials/pagination.html' %} {% endif %}
{% if is_paginated %} {% include 'partials/pagination.html' %} {% endif %} </div>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
</div> {% endblock %} {% block customJS %}
{% endblock %} {% block customJS %}
<script> <script>
links = document.querySelectorAll(".nav-link"); links = document.querySelectorAll(".nav-link");
links.forEach((link) => { links.forEach((link) => {
@ -357,5 +357,5 @@
} }
} }
</script> </script>
{% endblock customJS %} {% endblock customJS %}
</div> </div>

View File

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

View File

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

View File

@ -5,265 +5,265 @@
{% block title %}{{ page_title }} - {{ sale_order.formatted_order_id }}{% endblock %} {% block title %}{{ page_title }} - {{ sale_order.formatted_order_id }}{% endblock %}
{% block content %} {% block content %}
<div class="container mt-4"> <div class="container mt-4">
<div class="card"> <div class="card">
<div class="card-header"> <div class="card-header">
<h2 class="mb-0"> <h2 class="mb-0">
{% trans "Sales Order" %} #{{ sale_order.formatted_order_id }} {% trans "Sales Order" %} #{{ sale_order.formatted_order_id }}
<span class="badge bg-{{ sale_order.status|status_badge_color }} float-end"> <span class="badge bg-{{ sale_order.status|status_badge_color }} float-end">
{{ status_choices|get_item:sale_order.status }} {{ status_choices|get_item:sale_order.status }}
</span> </span>
</h2> </h2>
</div> </div>
<div class="card-body"> <div class="card-body">
<!-- Basic Information --> <!-- Basic Information -->
<div class="row mb-4"> <div class="row mb-4">
<div class="col-md-6"> <div class="col-md-6">
<h4>{% trans "Customer Information" %}</h4> <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>
<p> <p>
<strong>{% trans "Cancellation Date" %}:</strong> {{ sale_order.cancelled_date|date:"DATETIME_FORMAT" }}<br> <strong>{% trans "Name" %}:</strong> {{ sale_order.full_name }}<br>
<strong>{% trans "Reason" %}:</strong> {{ sale_order.cancellation_reason }} {% 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> </p>
</div> </div>
</div> </div>
</div>
{% endif %}
<!-- Comments --> <!-- Estimate Information -->
{% if sale_order.comments %} {% if sale_order.estimate %}
<div class="row"> <div class="row mb-4">
<div class="col-12"> <div class="col-12">
<h4>{% trans "Comments" %}</h4> <h4>{% trans "Estimate Information" %}</h4>
<div class="card bg-light"> <div class="card">
<div class="card-body"> <div class="card-body">
{{ sale_order.comments|linebreaks }} <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>
</div> {% endif %}
</div>
{% endif %}
</div>
<div class="card-footer text-end"> <!-- Invoice Information -->
<a href="{% url 'order_list' %}" class="btn btn-secondary"> {% if sale_order.invoice %}
{% trans "Back to List" %} <div class="row mb-4">
</a> <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 --> <!-- Add links to view full estimate and invoice if they exist -->
{% if sale_order.estimate %} {% if sale_order.estimate %}
<a href="{% url 'estimate_detail' sale_order.estimate.pk %}" class="btn btn-info ms-2"> <a href="{% url 'estimate_detail' sale_order.estimate.pk %}" class="btn btn-info ms-2">
{% trans "View Full Estimate" %} {% trans "View Full Estimate" %}
</a> </a>
{% endif %} {% endif %}
{% if sale_order.invoice %} {% if sale_order.invoice %}
<a href="{% url 'invoice_detail' sale_order.invoice.pk %}" class="btn btn-info ms-2"> <a href="{% url 'invoice_detail' sale_order.invoice.pk %}" class="btn btn-info ms-2">
{% trans "View Full Invoice" %} {% trans "View Full Invoice" %}
</a> </a>
{% endif %} {% endif %}
</div>
</div> </div>
</div> </div>
</div>
{% endblock %} {% endblock %}