This commit is contained in:
gitea 2025-02-13 14:21:22 +00:00
commit bb9630cc33
5 changed files with 114 additions and 106 deletions

View File

@ -12,7 +12,7 @@ from django_ledger.models import (
ItemModelAbstract,
UnitOfMeasureModel,
VendorModel,
EstimateModel
EstimateModel, CustomerModel
)
from . import models
from django.utils.timezone import now
@ -669,32 +669,35 @@ def create_customer_user(sender, instance, created, **kwargs):
if created:
user = User.objects.create(
username=instance.email,
email=instance.email,
email=instance.email,
is_active=False,
first_name=instance.additional_info.get('first_name',''),
last_name=instance.additional_info.get('last_name','')
)
user.is_active = False
user.is_staff = False
user.save()
instance.user = user
instance.save()
# @receiver(post_save, sender=models.Customer)
# def create_customer_user(sender, instance, created, **kwargs):
# @receiver(post_save, sender=models.Lead)
# def create_customer_from_lead(sender, instance, created, **kwargs):
# dealer = instance.dealer
# entity = dealer.entity
# if created:
# user = User.objects.create(
# username=instance.email,
# email=instance.email,
# password=None,
# first_name=instance.first_name,
# last_name=instance.last_name
# customer = entity.create_customer(
# customer_model_kwargs={
# "customer_name": instance.full_name,
# "address_1": instance.address,
# "phone": instance.phone_number,
# "email": instance.email,
# "sales_tax_rate": 0.15,
# }
# )
# user.is_active = True
# user.is_staff = True
# user.save()
# instance.user = user
# instance.customer = customer
# instance.save()
# Create Item
@receiver(post_save, sender=models.Car)
def create_item_model(sender, instance, created, **kwargs):

View File

@ -3221,6 +3221,8 @@ def lead_convert(request, pk):
@login_required
def schedule_lead(request, pk):
dealer = get_user_type(request)
print(dealer)
lead = get_object_or_404(models.Lead, pk=pk)
if request.method == "POST":
form = forms.ScheduleForm(request.POST)
@ -3246,13 +3248,13 @@ def schedule_lead(request, pk):
service=service,
staff_member=StaffMember.objects.first()
)
print(lead.customer)
# Create Appointment
Appointment.objects.create(
client=request.user, # Replace with the appropriate client
client=lead.customer.user, # Replace with the appropriate client
appointment_request=appointment_request,
phone="123-456-7890", # Replace with actual phone number
address="123 Main St", # Replace with actual address
phone=lead.customer.phone, # Replace with actual phone number
address=lead.customer.address_1, # Replace with actual address
)
messages.success(request, "Lead scheduled and appointment created successfully!")

View File

@ -81,9 +81,11 @@
margin-top: 1rem;
}
.footer-note {
position: absolute;
text-align: center;
color: #777;
margin-top: 3rem;
margin-left: 0;
margin-top: 0;
font-size: 1rem;
font-weight: 400;
}

View File

@ -1,4 +1,4 @@
{% load i18n static custom_filters num2words_tags%}
{% load i18n static custom_filters num2words_tags %}
<!DOCTYPE html>
<html lang="ar">
<head>
@ -7,7 +7,7 @@
<title>Invoice</title>
<!-- CSS -->
<link href="{% static 'css/theme.min.css' %}" type="text/css" rel="stylesheet" id="style-default">
<link href="{% static 'css/user.min.css' %}" type="text/css" rel="stylesheet" id="user-style-default">
<link href="{% static 'css/user.min.css' %}" type="text/css" rel="stylesheet" id="user-style-default">
<!-- Google Fonts - Roboto -->
<link href="https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;500;700&display=swap" rel="stylesheet">
<!-- Custom CSS -->
@ -26,6 +26,7 @@
background: white;
border-radius: 5px;
box-shadow: 0 0 5px rgba(0, 0, 0, 0.1);
position: relative;
}
.invoice-header {
text-align: center;
@ -51,85 +52,88 @@
}
.invoice-total {
text-align: right;
font-size: 14px;
font-size: 13px;
font-weight: 600;
margin-top: 10px;
}
.footer-note {
position: absolute;
bottom: 35mm;
bottom: 10mm;
left: 10mm;
right: 10mm;
font-size: 10px;
margin-top: auto;
margin-right: auto;
width: 28%;
}
display: flex;
justify-content: space-between;
align-items: center;
}
.logo-img img {
width: 10mm;
height: 10mm;
}
.table-responsive {
overflow-x: auto;
}
</style>
</head>
<body>
<div class="row p-2">
<div class="col-2">
<button class="btn btn-sm btn-danger w-100" onclick="window.history.back()">الرجوع / Back</button>
<button class="btn btn-sm btn-danger w-100" onclick="window.history.back()">الرجوع&nbsp;/&nbsp;Back</button>
</div>
<div class="col-2">
<button class="btn btn-sm btn-primary w-100" id="download-pdf">تحميل / Download</button>
</div>
<div class="col-8">
<button class="btn btn-sm btn-primary w-100" id="download-pdf">تحميل&nbsp;/&nbsp;Download</button>
</div>
<div class="col-8"></div>
</div>
<div class="invoice-container" id="invoice-content">
<div class="invoice-header">
<h5 class="fs-5">Tax Invoice / فاتورة ضريبية</h5>
<div class="invoice-container" id="invoice-content">
<div class="invoice-header">
<h5 class="fs-5">Tax&nbsp;Invoice&nbsp;&nbsp;/&nbsp;&nbsp;فاتورة&nbsp;ضريبية</h5>
</div>
<div class="invoice-details">
<table class="table table-sm table-responsive">
<tr>
<td>
<div class="qr-code">
<img src="{% static 'qr_code/Marwan_qr.png' %}" alt="QR Code">
</div>
</td>
<td></td>
<td>
<div class="qr-code">
<img class="rounded-soft" src="{{ dealer.logo.url|default:'' }}" alt="Dealer Logo"/>
</div>
</td>
</tr>
<tr>
<td><strong>{{ dealer.name }}</strong></td>
<td></td>
<td class="text-end"><strong>{{ dealer.arabic_name }}</strong></td>
</tr>
<tr>
<td><strong>Address</strong></td>
<td>{{ dealer.address }}</td>
<td class="text-end"><strong>العنوان</strong></td>
</tr>
<tr>
<td><strong>Phone</strong></td>
<td>{{ dealer.phone_number }}</td>
<td class="text-end"><strong>جوال</strong></td>
</tr>
<tr>
<td><strong>VAT Number</strong></td>
<td>{{ dealer.vrn }}</td>
<td class="text-end"><strong>الرقم الضريبي</strong></td>
</tr>
</table>
</div>
<div>
</div>
<div class="invoice-details">
<table class="table table-sm table-responsive ">
<tr>
<td>
<div class="qr-code">
<img src="{% static 'qr_code/Marwan_qr.png' %}" alt="QR Code">
</div>
</td>
<td></td>
<td>
<div class="qr-code">
<img class="rounded-soft" src="{{ dealer.logo.url|default:'' }}" alt="Dealer Logo"/>
</div>
</td>
</tr>
<tr>
<td><strong>{{ dealer.name }}</strong></td>
<td></td>
<td class="text-end"><strong>{{ dealer.arabic_name }}</strong></td>
</tr>
<tr>
<td><strong>Address</strong></td>
<td>{{ dealer.address }}</td>
<td class="text-end"><strong>العنوان</strong></td>
</tr>
<tr>
<td><strong>Phone</strong></td>
<td>{{ dealer.phone_number }}</td>
<td class="text-end"><strong>جوال</strong></td>
</tr>
<tr>
<td><strong>VAT Number</strong></td>
<td>{{ dealer.vrn }}</td>
<td class="text-end"><strong>الرقم الضريبي</strong></td>
</tr>
</table>
</div>
<div class="invoice-details">
<table class="table table-sm table-bordered">
<tr>
<td class="ps-1"><strong>Invoice Number</strong></td>
<td class="ps-1"><strong>Invoice&nbsp;Number</strong></td>
<td class="text-center">{{ invoice.invoice_number }}</td>
<td class="text-end p-1"><strong>رقم الفاتورة</strong></td>
<td class="text-end p-1"><strong>رقم&nbsp;الفاتورة</strong></td>
</tr>
<tr>
<td class="ps-1"><strong>Date</strong></td>
@ -142,25 +146,25 @@
<td class="text-end p-1"><strong>العميل</strong></td>
</tr>
<tr>
<td class="ps-1"><strong>VAT Number</strong></td>
<td class="ps-1"><strong>VAT&nbsp;ID</strong></td>
<td class="text-center">{{ invoice.customer.vrn|default:"-" }}</td>
<td class="text-end p-1"><strong>الرقم الضريبي</strong></td>
<td class="text-end p-1"><strong>الرقم&nbsp;الضريبي</strong></td>
</tr>
<tr>
<td class="ps-1"><strong>Email</strong></td>
<td class="text-center">{{ invoice.customer.email|default:"N/A" }}</td>
<td class="text-end p-1"><strong>البريد الالكتروني</strong></td>
<td class="text-end p-1"><strong>البريد&nbsp;الالكتروني</strong></td>
</tr>
<tr>
<td class="ps-1"><strong>Terms</strong></td>
<td class="text-center">{{ invoice.get_terms_display }}</td>
<td class="text-end p-1"><strong>طريقة الدفع</strong></td>
<td class="text-end p-1"><strong>طريقة&nbsp;الدفع</strong></td>
</tr>
</table>
</div>
<div class="d-flex justify-content-between">
<span class="fs-9 fw-thin">Car Details</span>
<span class="fs-9 fw-thin">تفاصيل السيارة</span>
<span class="fs-9 fw-thin">Car&nbsp;Details</span>
<span class="fs-9 fw-thin">تفاصيل&nbsp;السيارة</span>
</div>
<div class="invoice-table">
<table class="table table-sm table-bordered">
@ -180,7 +184,6 @@
{% for item in data.cars %}
<tr>
<td class="ps-1 fs-10 align-content-center" colspan="3">{{ item.make }} - {{ item.model }} - {{ item.trim }}</td>
<td class="text-center fs-10 align-content-center">{{ item.year }}</td>
<td class="ps-1 fs-10 align-content-center">{{ item.vin }}</td>
<td class="text-center fs-10 align-content-center">{{ item.quantity|floatformat:-1 }}</td>
@ -198,19 +201,19 @@
</table>
</div>
<div class="d-flex justify-content-between">
<span class="fs-9 fw-thin">Additional Services</span>
<span class="fs-9 fw-thin">الخدمات الإضافية</span>
</div>
<div class="d-flex justify-content-between">
<span class="fs-9 fw-thin">Additional&nbsp;Services</span>
<span class="fs-9 fw-thin">الخدمات&nbsp;الإضافية</span>
</div>
{% if data.additionals %}
{% if data.additionals %}
<div class="invoice-table">
<table class="table table-sm table-bordered">
<thead>
<tr>
<th class="text-center fs-10 align-content-center">Type / النوع</th>
<th class="text-center fs-10 align-content-center">Price / السعر</th>
<th class="text-center fs-10 align-content-center">Taxable / خاضع للضريبة</th>
<th class="text-center fs-10 align-content-center">Type&nbsp;/&nbsp;النوع</th>
<th class="text-center fs-10 align-content-center">Price&nbsp;/&nbsp;القيمة</th>
<th class="text-center fs-10 align-content-center">Taxable&nbsp;/&nbsp;خاضع للضريبة</th>
</tr>
</thead>
<tbody>
@ -227,32 +230,30 @@
{% endif %}
<div class="d-flex justify-content-end">
<div class="table-responsive">
<table class="table table-sm table-responsive ">
<table class="table table-sm table-responsive">
<tr>
<td class="text-start ps-1"><strong class="fs-9">VAT</strong></td>
<td class="text-center"><span class="fs-9">{{ data.total_vat_amount|floatformat:2 }} {{ CURRENCY }}</span></td>
<td class="text-end"><strong class="fs-9">ضريبة القيمة المضافة</strong></td>
<td class="text-end"><strong class="fs-9">ضريبة&nbsp;القيمة&nbsp;المضافة</strong></td>
</tr>
<tr>
<td class="text-start ps-1"><strong class="fs-9">Total</strong></td>
<td class="text-center"><span class="fs-9">{{ data.grand_total|floatformat:2 }} {{ CURRENCY }}</span></td>
<td class="text-center"><span class="fs-9">{{ data.grand_total|floatformat:2 }}&nbsp;{{ CURRENCY }}</span></td>
<td class="text-end"><strong class="fs-9">الإجمالي</strong></td>
</tr>
<tr>
<td class="text-end" colspan="3"><span class="fs-9 fw-bold">كتابةً: </span><span class="fs-9">{{ data.grand_total|num_to_words }} {{ CURRENCY }}</span></td>
<td class="text-end" colspan="3"><span class="fs-9 fw-bold">كتابةً:&nbsp;</span><span class="fs-9">{{ data.grand_total|num_to_words }}&nbsp;{{ CURRENCY }}</span></td>
</tr>
</table>
</div>
</div>
<div class="footer-note d-flex justify-content-between align-items-end">
<div class="footer-note">
<div class="logo-img text-center">
<img src="{% static 'images/logos/logo-d-pdf.png' %}" style="width: 10mm; height: 10mm;"/>
<p class="fs-11 fw-bold"><span>Haikal</span> | <span>هيكل</span></p>
<img src="{% static 'images/logos/logo-d-pdf.png' %}" alt="Logo"/>
<p class="fs-11 fw-bold"><span>Haikal</span>&nbsp;|&nbsp;<span>هيكل</span></p>
</div>
<p class="fs-11"><span class="fw-thin">Powered by </span><a class="text-decoration-none" href="https://tenhal.sa" style="color: #112e40;"><span>TENHAL</span> | <span>تنحل</span></a></p>
<p class="fs-11"><span class="fw-thin">Powered&nbsp;by&nbsp;</span><a class="text-decoration-none" href="https://tenhal.sa" style="color: #112e40;"><span>TENHAL</span>&nbsp;|&nbsp;<span>تنحل</span></a></p>
</div>
</div>
<script src="{% static 'vendors/bootstrap/bootstrap.min.js' %}"></script>
@ -269,4 +270,4 @@
});
</script>
</body>
</html>
</html>