This commit is contained in:
Marwan Alwali 2025-02-24 14:35:10 +03:00
parent 27530ab096
commit 2671db939a
9 changed files with 59 additions and 36 deletions

View File

@ -2,6 +2,7 @@ from random import randint
from django import template
from calendar import month_abbr
from django.urls import reverse
from django.utils.formats import number_format
from django_ledger.io.io_core import get_localdate,validate_activity
from django.conf import settings
from django.utils.translation import get_language
@ -352,4 +353,10 @@ def date_picker(context, nav_url=None, date_picker_id=None):
@register.filter
def splitlines(value):
"""Splits text into lines"""
return value.splitlines()
return value.splitlines()
@register.filter(name='currency_format')
def currency_format(value):
if not value:
value = 0.00
return number_format(value, decimal_pos=2, use_l10n=True, force_grouping=True)

View File

@ -1280,15 +1280,14 @@ class CustomerDetailView(LoginRequiredMixin, DetailView):
dealer = get_user_type(self.request)
entity = dealer.entity
context = super().get_context_data(**kwargs)
# customer = f"{context['customer'].first_name} {context['customer'].middle_name} {context['customer'].last_name}"
# context["estimates"] = entity.get_estimates().filter(
# customer__customer_name=name
# )
estimates = entity.get_estimates().filter(customer=self.object)
invoices = entity.get_invoices().filter(customer=self.object)
# txs = entity. transactions(customer=self.object)
total = estimates.count() + invoices.count()
context["estimates"] = estimates
context["invoices"] = invoices
# context["txs"] = txs
context["total"] = total
@ -2632,6 +2631,7 @@ def account_delete(request, pk):
# Sales list
@login_required
def sales_list_view(request):
dealer = get_user_type(request)
entity = dealer.entity

View File

@ -1,11 +1,7 @@
{% load i18n static crispy_forms_filters %}
<form method="post" action="{% url 'add_note_to_customer' customer.pk %}" enctype="multipart/form-data">
<form method="post" action="{% url 'add_note_to_customer' customer.pk %}" enctype="multipart/form-data">
{% csrf_token %}
{{ form|crispy }}
<button type="submit" class="btn btn-sm btn-success w-100">{{ _("Add") }}</button>
</form>
<button type="submit" class="btn btn-sm btn-success w-100">{{ _("Add") }}</button>
</form>

View File

@ -1,5 +1,5 @@
{% extends "base.html" %}
{% load i18n static crispy_forms_filters%}
{% load i18n static crispy_forms_filters custom_filters%}
{% block title %}{{ _("View Customer") }}{% endblock title %}
@ -41,7 +41,7 @@
<div class="avatar avatar-5xl"><img class="rounded-circle" src="{% static "images/team/15.webp" %}" alt="" /></div>
</div>
<div class="col-12 col-sm-auto flex-1">
<h3>{{ customer.additional_info }}</h3>
<h3>{{ customer.customer_name }}</h3>
<p class="text-body-secondary">{{ customer.created|timesince}}</p>
</div>
</div>
@ -105,30 +105,51 @@
</div>
<div class="col-12 col-xxl-8">
<div class="mb-6">
<h3 class="mb-4">{{ _("Cars") }} <span class="text-body-tertiary fw-normal">({{ total }})</span></h3>
<h3 class="mb-4">{{ _("Related") }} <span class="text-body-tertiary fw-normal">({{ total }})</span></h3>
<div class="border-top border-bottom border-translucent" id="customerOrdersTable" data-list='{"valueNames":["order","total","payment_status","fulfilment_status","delivery_type","date"],"page":6,"pagination":true}'>
<div class="table-responsive scrollbar">
<table class="table table-sm fs-9 mb-0">
<thead>
<tr>
<th class="sort white-space-nowrap align-middle ps-0 pe-3" scope="col" data-sort="order" style="width:10%;">ORDER</th>
<th class="sort align-middle text-end pe-7" scope="col" data-sort="total" style="width:10%;">TOTAL</th>
<th class="sort align-middle white-space-nowrap pe-3" scope="col" data-sort="payment_status" style="width:15%;">PAYMENT STATUS</th>
<th class="sort align-middle white-space-nowrap text-start pe-3" scope="col" data-sort="fulfilment_status" style="width:20%;">FULFILMENT STATUS</th>
<th class="sort align-middle white-space-nowrap text-start" scope="col" data-sort="delivery_type" style="width:30%;">DELIVERY TYPE</th>
<th class="sort align-middle text-end pe-0" scope="col" data-sort="date">DATE</th>
<th class="sort white-space-nowrap align-middle ps-0 pe-3" scope="col" data-sort="order" style="width:30%;">{% trans 'Type'|upper %}</th>
<th class="sort align-middle text-end pe-7" scope="col" data-sort="total" style="width:10%;">{% trans 'Total'|upper %}</th>
<th class="sort align-middle white-space-nowrap pe-3" scope="col" data-sort="payment_status" style="width:20%;">{% trans 'Payment Status'|upper %}</th>
<th class="sort align-middle white-space-nowrap text-start pe-3" scope="col" data-sort="fulfilment_status" style="width:20%;">{% trans 'Fulfilment Status'|upper %}</th>
<th class="sort align-middle text-end pe-0" scope="col" data-sort="date">{% trans 'Date'|upper %}</th>
<th class="sort text-end align-middle pe-0 ps-5" scope="col"></th>
</tr>
</thead>
<tbody class="list" id="customer-order-table-body">
{% for estimate in estimates %}
<tr class="hover-actions-trigger btn-reveal-trigger position-static">
<td class="order align-middle white-space-nowrap ps-0"><a class="fw-semibold" href="#!">#2453</a></td>
<td class="total align-middle text-end fw-semibold pe-7 text-body-highlight">$87</td>
<td class="payment_status align-middle white-space-nowrap text-start fw-bold text-body-tertiary"><span class="badge badge-phoenix fs-10 badge-phoenix-success"><span class="badge-label">Paid</span><span class="ms-1" data-feather="check" style="height:12.8px;width:12.8px;"></span></span></td>
<td class="fulfilment_status align-middle white-space-nowrap text-start fw-bold text-body-tertiary"><span class="badge badge-phoenix fs-10 badge-phoenix-success"><span class="badge-label">Order Fulfilled</span><span class="ms-1" data-feather="check" style="height:12.8px;width:12.8px;"></span></span></td>
<td class="delivery_type align-middle white-space-nowrap text-body fs-9 text-start">Cash on delivery</td>
<td class="date align-middle white-space-nowrap text-body-tertiary fs-9 ps-4 text-end">Dec 12, 12:56 PM</td>
<td class="order align-middle white-space-nowrap ps-0">
<p class="fw-semibold mb-0" >{{ estimate.estimate_number }}</p>
</td>
<td class="total align-middle text-end fw-semibold pe-7 text-body-highlight">{{ estimate.revenue_estimate|currency_format }}</td>
<td class="payment_status align-middle white-space-nowrap text-start fw-bold text-body-tertiary">
<span class="badge badge-phoenix fs-10 badge-phoenix-success">
<span class="badge-label">Paid</span>
<span class="ms-1" data-feather="check" style="height:12.8px;width:12.8px;"></span>
</span>
</td>
<td class="fulfilment_status align-middle white-space-nowrap text-start fw-bold text-body-tertiary">
{% if estimate.status == 'draft' %}
<span class="badge badge-phoenix badge-phoenix-warning">{% trans "Draft" %}</span>
{% elif estimate.status == 'in_review' %}
<span class="badge badge-phoenix badge-phoenix-info">{% trans "In Review" %}</span>
{% elif estimate.status == 'approved' %}
<span class="badge badge-phoenix badge-phoenix-success">{% trans "Approved" %}</span>
{% elif estimate.status == 'declined' %}
<span class="badge badge-phoenix badge-phoenix-danger">{% trans "Declined" %}</span>
{% elif estimate.status == 'canceled' %}
<span class="badge badge-phoenix badge-phoenix-danger">{% trans "Canceled" %}</span>
{% elif estimate.status == 'completed' %}
<span class="badge badge-phoenix badge-phoenix-success">{% trans "Completed" %}</span>
{% elif estimate.status == 'void' %}
<span class="badge badge-phoenix badge-phoenix-secondary">{% trans "Void" %}</span>
{% endif %}
</td>
<td class="date align-middle white-space-nowrap text-body-tertiary fs-9 ps-4 text-end">{{ estimate.created }}</td>
<td class="align-middle white-space-nowrap text-end pe-0 ps-5">
<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>
@ -138,7 +159,7 @@
</div>
</td>
</tr>
{% endfor %}
</tbody>
</table>

View File

@ -1,5 +1,5 @@
{% extends 'base.html' %}
{% load i18n static %}
{% load i18n static custom_filters %}
{% block content %}
<script src="{% static 'js/echarts.js' %}"></script>
@ -132,7 +132,7 @@
</div>
</div>
<div class="mt-3 mt-md-0">
<h3 class="text-body-highlight mb-2">{{ total_selling_price }} {{ CURRENCY }}</h3>
<h3 class="text-body-highlight mb-2">{{ total_selling_price|currency_format }} {{ CURRENCY }}</h3>
</div>
</div>
</div>
@ -147,7 +147,7 @@
</div>
</div>
<div class="mt-3 mt-md-0">
<h3 class="text-body-highlight mb-2">{{ total_profit }} {{ CURRENCY }}</h3>
<h3 class="text-body-highlight mb-2">{{ total_profit|currency_format }} {{ CURRENCY }}</h3>
</div>
</div>
</div>

View File

@ -5,7 +5,6 @@
{% block content %}
<div id="chart" class="echart-basic-bar-chart-example" style="min-height:300px"></div>
<section class="py-5">
<div class="container-fluid">
<div class="row">

View File

@ -183,7 +183,7 @@
<tr class="bg-body-secondary total-sum">
<td class="align-middle ps-4 fw-semibold text-body-highlight" colspan="7">{% trans "Discount Amount" %}</td>
<td class="align-middle text-start text-danger fw-semibold ">
<span id="grand-total">- {{data.total_discount}}</span>
<span id="grand-total">- {{data.total_discount}}</span>
</td>
</tr>
<tr class="bg-body-secondary total-sum">
@ -192,11 +192,11 @@
{% for service in data.additionals %}
<small><span class="fw-semibold">+ {{service.name}} - {{service.total}}</span></small><br>
{% endfor %}
</td>
</td>
</tr>
<tr class="bg-body-secondary total-sum">
<td class="align-middle ps-4 fw-bolder text-body-highlight" colspan="7">{% trans "Grand Total" %}</td>
<td class="align-middle text-start fw-bolder">
<td class="align-middle text-start fw-bolder">
<span id="grand-total">{{data.grand_total}}</span>
</td>
</tr>