diff --git a/inventory/__pycache__/views.cpython-311.pyc b/inventory/__pycache__/views.cpython-311.pyc index e919829b..9a332a1c 100644 Binary files a/inventory/__pycache__/views.cpython-311.pyc and b/inventory/__pycache__/views.cpython-311.pyc differ diff --git a/inventory/signals.py b/inventory/signals.py index 79f46ba3..af7d9da2 100644 --- a/inventory/signals.py +++ b/inventory/signals.py @@ -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): diff --git a/inventory/views.py b/inventory/views.py index 44401c15..081ac43d 100644 --- a/inventory/views.py +++ b/inventory/views.py @@ -3199,6 +3199,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) @@ -3224,13 +3226,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!") diff --git a/templates/sales/estimates/estimate_preview.html b/templates/sales/estimates/estimate_preview.html index e6089f64..b73b5224 100644 --- a/templates/sales/estimates/estimate_preview.html +++ b/templates/sales/estimates/estimate_preview.html @@ -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; } diff --git a/templates/sales/invoices/invoice_preview.html b/templates/sales/invoices/invoice_preview.html index 5f8993f4..0a6adaba 100644 --- a/templates/sales/invoices/invoice_preview.html +++ b/templates/sales/invoices/invoice_preview.html @@ -1,4 +1,4 @@ -{% load i18n static custom_filters num2words_tags%} +{% load i18n static custom_filters num2words_tags %} @@ -7,7 +7,7 @@ Invoice - + @@ -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; + }
- +
- -
-
- +
+
-
-
-
Tax Invoice / فاتورة ضريبية
+
+
+
Tax Invoice  /  فاتورة ضريبية
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ QR Code +
+
+
+ Dealer Logo +
+
{{ dealer.name }}{{ dealer.arabic_name }}
Address{{ dealer.address }}العنوان
Phone{{ dealer.phone_number }}جوال
VAT Number{{ dealer.vrn }}الرقم الضريبي
-
- -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - -
-
- QR Code -
-
-
- Dealer Logo -
-
{{ dealer.name }}{{ dealer.arabic_name }}
Address{{ dealer.address }}العنوان
Phone{{ dealer.phone_number }}جوال
VAT Number{{ dealer.vrn }}الرقم الضريبي
-
- + - + @@ -142,25 +146,25 @@ - + - + - + - +
Invoice NumberInvoice Number {{ invoice.invoice_number }}رقم الفاتورةرقم الفاتورة
Dateالعميل
VAT NumberVAT ID {{ invoice.customer.vrn|default:"-" }}الرقم الضريبيالرقم الضريبي
Email {{ invoice.customer.email|default:"N/A" }}البريد الالكترونيالبريد الالكتروني
Terms {{ invoice.get_terms_display }}طريقة الدفعطريقة الدفع
- Car Details - تفاصيل السيارة + Car Details + تفاصيل السيارة
@@ -180,7 +184,6 @@ {% for item in data.cars %} - @@ -198,19 +201,19 @@
{{ item.make }} - {{ item.model }} - {{ item.trim }}{{ item.year }} {{ item.vin }} {{ item.quantity|floatformat:-1 }}
-
- Additional Services - الخدمات الإضافية -
+
+ Additional Services + الخدمات الإضافية +
- {% if data.additionals %} + {% if data.additionals %}
- - - + + + @@ -227,32 +230,30 @@ {% endif %}
-
Type / النوعPrice / السعرTaxable / خاضع للضريبةType / النوعPrice / القيمةTaxable / خاضع للضريبة
+
- + - + - - - +
VAT {{ data.total_vat_amount|floatformat:2 }} {{ CURRENCY }}ضريبة القيمة المضافةضريبة القيمة المضافة
Total{{ data.grand_total|floatformat:2 }} {{ CURRENCY }}{{ data.grand_total|floatformat:2 }} {{ CURRENCY }} الإجمالي
كتابةً: {{ data.grand_total|num_to_words }} {{ CURRENCY }}كتابةً: {{ data.grand_total|num_to_words }} {{ CURRENCY }}
- @@ -269,4 +270,4 @@ }); - + \ No newline at end of file