From 7144caecec490faaef5a0c9073f79d5a1fa10d55 Mon Sep 17 00:00:00 2001 From: Marwan Alwali Date: Thu, 13 Feb 2025 14:14:56 +0300 Subject: [PATCH] update --- inventory/__pycache__/views.cpython-311.pyc | Bin 192404 -> 192611 bytes inventory/signals.py | 35 ++-- inventory/views.py | 10 +- .../sales/estimates/estimate_preview.html | 4 +- templates/sales/invoices/invoice_preview.html | 171 +++++++++--------- 5 files changed, 114 insertions(+), 106 deletions(-) diff --git a/inventory/__pycache__/views.cpython-311.pyc b/inventory/__pycache__/views.cpython-311.pyc index e919829bcc235dc8c42179ba929b9672be624f71..9a332a1c9da497cb9b42bfbb7b502e1ad74cacdd 100644 GIT binary patch delta 1711 zcmY*ZdvJ_b6#vd|cfW}2mvm#ZyLsC@L@ESn>M>|cHPvW5!wg2Fno^qyve~Ie*K;sx zrl>D+h*v@c4MRM7i7BZ^Tcsw^v|_xqYC59`?Mz3e^nPJI?jQHw^Si%u?(dv)=ayaz z`R#g$wq4WOD{|~>+&yLbLT!mg2Q@_5C`RwTCcy-sN&hxJO8=rbR3CTU$$g_KJksP> zJQl;p7zHSVv95yGt>5VEFw4VsdP}R*WcHi&$|FhYD)QFJZDX;M@7oY=vG`4X3pa$2 z)1-Jbc84R@tr;PV;R$`ZDvIBdANFD|-5slcw()}!ieOhcMTT?;9PUy%yPSHqo2&ZO zk|bXjuKW~shhHfOs+P)X+SD0bQhe#$7>yYCx^u0M>^!pr9HD-TCn^xCB3duLo$x9Y zV?c2)v*bQD;4w#TD%vP!zv}DvG;UrwCGop<*la;QQ-CQmGI`?l%3>FMSugH?-#`N# z&+|I?gI>Yi0mdt6LIB;>zS=BPHS^<3GP(=%0l~mfb(b}=e+Ofgf z@s`!uWR1UI?R4JSso5D_I=9K0+MLv@*%4J*)Z|EQcExPanq2APqeu*B7qr)^C?ysu zGr=Y5-56m~uNp`lKLMgROGTK-O2z=tLoq)EcZvQL(^9dHR7LixWT0OB$iam!3g)yf zxG9&gG;F53Vow_O5Q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u69|A|M?BMB&0R7&<7K<1(<0lEk45Tp&sni!*T;lp%&Zjv=7wJU0uK zG+DG~!3vrsFbW?N%@xP9;WALA=<^hGB9BPRK?i6Z_Zf@+v|2nf7DtF0eZd{<%*6t# z6Pt2nL~XyWDEFS0oFl}YamXRs(cN-9!-*UV=O)XIJ+K`yqJm}PD33p1FUOM0!#ChG zO=8sIEWN|E z@%r$dkMJWU2#H-*X_|1IKn=-SIzPoiDiH3^P)9Ucgq^|_qLE#$9CRAr(0piB 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